Documentation ¶
Overview ¶
An LHash is a map structure using the linear-hashing algorithm. This implementation uses the SipHash hashing algorithm, which is available on many platforms and languages, and uses msgpack as the serialization format for the LHash state, which again, is widely available.
Multiple connections may interact with the same underlying LHash objects at the same time, as GoshawkDB ensures through the use of strong serialization that any dependent operations are safely ordered.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LHash ¶
type LHash struct { // The connection used to create this LHash object. As usual with // GoshawkDB, objects are scoped to connections so you should not // use the same LHash object from multiple connections. You can // have multiple LHash objects for the same underlying set of // GoshawkDB objects. Conn *client.Connection // The underlying Object in GoshawkDB which holds the root data for // the LHash. ObjRef client.ObjectRef // contains filtered or unexported fields }
func LHashFromObj ¶
func LHashFromObj(conn *client.Connection, objRef client.ObjectRef) *LHash
Create an LHash object from an existing given GoshawkDB Object. Use this to regain access to an existing LHash which has already been created. This function does not do any initialisation: it assumes the Object passed is already initialised for LHash.
func NewEmptyLHash ¶
func NewEmptyLHash(conn *client.Connection) (*LHash, error)
Create a brand new empty LHash. This creates a new GoshawkDB Object and initialises it for use as an LHash.
func (*LHash) Find ¶
Search the LHash for the given key. The key is hashed using the SipHash algorithm, and comparison between keys is done with bytes.Equal. If no matching key is found, a nil ObjectRef is returned.
func (*LHash) ForEach ¶
Iterate over the entries in the LHash. Iteration order is undefined. Also note that as usual, the transaction in which the iteration is occurring may need to restart one or more times in which case the callback may be invoked several times for the same entry. To detect this, call ForEach from within a transaction of your own. Iteration will stop as soon as the callback returns a non-nil error, which will also abort the transaction.
func (*LHash) Put ¶
Idempotently add the given key and value to the LHash. The key is hashed using the SipHash algorithm, and comparison between keys is done with bytes.Equal. If a matching key is found, the corresponding value is updated.