hashing

package
v9.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 8 more Imports: 10 Imported by: 0

Documentation

Overview

Package hashing provides utilities for and an implementation of a hash table which is more performant than the default go map implementation by leveraging xxh3 and some custom hash functions.

Index

Constants

View Source
const KeyNotFound = -1

KeyNotFound is the constant returned by memo table functions when a key isn't found in the table

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryBuilderIFace

type BinaryBuilderIFace interface {
	Reserve(int)
	ReserveData(int)
	Retain()
	Resize(int)
	ResizeData(int)
	Release()
	DataLen() int
	Value(int) []byte
	Len() int
	AppendNull()
	AppendString(string)
	Append([]byte)
}

type BinaryMemoTable

type BinaryMemoTable struct {
	// contains filtered or unexported fields
}

BinaryMemoTable is our hashtable for binary data using the BinaryBuilder to construct the actual data in an easy to pass around way with minimal copies while using a hash table to keep track of the indexes into the dictionary that is created as we go.

func NewBinaryMemoTable

func NewBinaryMemoTable(initial, valuesize int, bldr BinaryBuilderIFace) *BinaryMemoTable

NewBinaryMemoTable returns a hash table for Binary data, the passed in allocator will be utilized for the BinaryBuilder, if nil then memory.DefaultAllocator will be used. initial and valuesize can be used to pre-allocate the table to reduce allocations. With initial being the initial number of entries to allocate for and valuesize being the starting amount of space allocated for writing the actual binary data.

func (*BinaryMemoTable) CopyFixedWidthValues

func (b *BinaryMemoTable) CopyFixedWidthValues(start, width int, out []byte)

CopyFixedWidthValues exists to cope with the fact that the table doesn't keep track of the fixed width when inserting the null value the databuffer holds a zero length byte slice for the null value (if found)

func (*BinaryMemoTable) CopyOffsets

func (b *BinaryMemoTable) CopyOffsets(out []int32)

CopyOffsets copies the list of offsets into the passed in slice, the offsets being the start and end values of the underlying allocated bytes in the builder for the individual values of the table. out should be at least sized to Size()+1

func (*BinaryMemoTable) CopyOffsetsSubset

func (b *BinaryMemoTable) CopyOffsetsSubset(start int, out []int32)

CopyOffsetsSubset is like CopyOffsets but instead of copying all of the offsets, it gets a subset of the offsets in the table starting at the index provided by "start".

func (*BinaryMemoTable) CopyValues

func (b *BinaryMemoTable) CopyValues(out interface{})

CopyValues copies the raw binary data bytes out, out should be a []byte with at least ValuesSize bytes allocated to copy into.

func (*BinaryMemoTable) CopyValuesSubset

func (b *BinaryMemoTable) CopyValuesSubset(start int, out interface{})

CopyValuesSubset copies the raw binary data bytes out starting with the value at the index start, out should be a []byte with at least ValuesSize bytes allocated

func (*BinaryMemoTable) Get

func (b *BinaryMemoTable) Get(val interface{}) (int, bool)

Get returns the index of the specified value in the table or KeyNotFound, and a boolean indicating whether it was found in the table.

func (*BinaryMemoTable) GetNull

func (s *BinaryMemoTable) GetNull() (int, bool)

GetNull returns the index of a null that has been inserted into the table or KeyNotFound. The bool returned will be true if there was a null inserted into the table, and false otherwise.

func (*BinaryMemoTable) GetOrInsert

func (b *BinaryMemoTable) GetOrInsert(val interface{}) (idx int, found bool, err error)

GetOrInsert returns the index of the given value in the table, if not found it is inserted into the table. The return value 'found' indicates whether the value was found in the table (true) or inserted (false) along with any possible error.

func (*BinaryMemoTable) GetOrInsertNull

func (b *BinaryMemoTable) GetOrInsertNull() (idx int, found bool)

GetOrInsertNull retrieves the index of a null in the table or inserts null into the table, returning the index and a boolean indicating if it was found in the table (true) or was inserted (false).

func (*BinaryMemoTable) Release

func (b *BinaryMemoTable) Release()

Release is used to tell the underlying builder that it can release the memory allocated when the reference count reaches 0, this is safe to be called from multiple goroutines simultaneously

func (*BinaryMemoTable) Reset

func (s *BinaryMemoTable) Reset()

Reset dumps all of the data in the table allowing it to be reutilized.

func (*BinaryMemoTable) Retain

func (b *BinaryMemoTable) Retain()

Retain increases the ref count, it is safe to call it from multiple goroutines simultaneously.

func (*BinaryMemoTable) Size

func (s *BinaryMemoTable) Size() int

Size returns the current size of the memo table including the null value if one has been inserted.

func (BinaryMemoTable) TypeTraits

func (BinaryMemoTable) TypeTraits() TypeTraits

func (*BinaryMemoTable) ValuesSize

func (b *BinaryMemoTable) ValuesSize() int

ValuesSize returns the current total size of all the raw bytes that have been inserted into the memotable so far.

func (*BinaryMemoTable) VisitValues

func (b *BinaryMemoTable) VisitValues(start int, visitFn func([]byte))

VisitValues exists to run the visitFn on each value currently in the hash table.

func (*BinaryMemoTable) WriteOut

func (b *BinaryMemoTable) WriteOut(out []byte)

func (*BinaryMemoTable) WriteOutSubset

func (b *BinaryMemoTable) WriteOutSubset(start int, out []byte)

type Float32HashTable

type Float32HashTable struct {
	// contains filtered or unexported fields
}

Float32HashTable is a hashtable specifically for float32 that is utilized with the MemoTable to generalize interactions for easier implementation of dictionaries without losing performance.

func NewFloat32HashTable

func NewFloat32HashTable(cap uint64) *Float32HashTable

NewFloat32HashTable returns a new hash table for float32 values initialized with the passed in capacity or 32 whichever is larger.

func (*Float32HashTable) CopyValues

func (h *Float32HashTable) CopyValues(out []float32)

CopyValues is used for copying the values out of the hash table into the passed in slice, in the order that they were first inserted

func (*Float32HashTable) CopyValuesSubset

func (h *Float32HashTable) CopyValuesSubset(start int, out []float32)

CopyValuesSubset copies a subset of the values in the hashtable out, starting with the value at start, in the order that they were inserted.

func (*Float32HashTable) Insert

func (h *Float32HashTable) Insert(e *entryFloat32, v uint64, val float32, memoIdx int32) error

Insert updates the given entry with the provided hash value, payload value and memo index. The entry pointer must have been retrieved via lookup in order to actually insert properly.

func (*Float32HashTable) Lookup

func (h *Float32HashTable) Lookup(v uint64, cmp func(float32) bool) (*entryFloat32, bool)

Lookup retrieves the entry for a given hash value assuming it's payload value returns true when passed to the cmp func. Returns a pointer to the entry for the given hash value, and a boolean as to whether it was found. It is not safe to use the pointer if the bool is false.

func (*Float32HashTable) Reset

func (h *Float32HashTable) Reset(cap uint64)

Reset drops all of the values in this hash table and re-initializes it with the specified initial capacity as if by calling New, but without having to reallocate the object.

func (*Float32HashTable) VisitEntries

func (h *Float32HashTable) VisitEntries(visit func(*entryFloat32))

VisitEntries will call the passed in function on each *valid* entry in the hash table, a valid entry being one which has had a value inserted into it.

func (*Float32HashTable) WriteOut

func (h *Float32HashTable) WriteOut(out []byte)

func (*Float32HashTable) WriteOutSubset

func (h *Float32HashTable) WriteOutSubset(start int, out []byte)

type Float32MemoTable

type Float32MemoTable struct {
	// contains filtered or unexported fields
}

Float32MemoTable is a wrapper over the appropriate hashtable to provide an interface conforming to the MemoTable interface defined in the encoding package for general interactions regarding dictionaries.

func NewFloat32MemoTable

func NewFloat32MemoTable(num int64) *Float32MemoTable

NewFloat32MemoTable returns a new memotable with num entries pre-allocated to reduce further allocations when inserting.

func (*Float32MemoTable) CopyValues

func (s *Float32MemoTable) CopyValues(out interface{})

CopyValues will copy the values from the memo table out into the passed in slice which must be of the appropriate type.

func (*Float32MemoTable) CopyValuesSubset

func (s *Float32MemoTable) CopyValuesSubset(start int, out interface{})

CopyValuesSubset is like CopyValues but only copies a subset of values starting at the provided start index

func (*Float32MemoTable) Get

func (s *Float32MemoTable) Get(val interface{}) (int, bool)

Get returns the index of the requested value in the hash table or KeyNotFound along with a boolean indicating if it was found or not.

func (*Float32MemoTable) GetNull

func (s *Float32MemoTable) GetNull() (int, bool)

GetNull returns the index of an inserted null or KeyNotFound along with a bool that will be true if found and false if not.

func (*Float32MemoTable) GetOrInsert

func (s *Float32MemoTable) GetOrInsert(val interface{}) (idx int, found bool, err error)

GetOrInsert will return the index of the specified value in the table, or insert the value into the table and return the new index. found indicates whether or not it already existed in the table (true) or was inserted by this call (false).

func (*Float32MemoTable) GetOrInsertNull

func (s *Float32MemoTable) GetOrInsertNull() (idx int, found bool)

GetOrInsertNull will return the index of the null entry or insert a null entry if one currently doesn't exist. The found value will be true if there was already a null in the table, and false if it inserted one.

func (*Float32MemoTable) Reset

func (s *Float32MemoTable) Reset()

Reset allows this table to be re-used by dumping all the data currently in the table.

func (*Float32MemoTable) Size

func (s *Float32MemoTable) Size() int

Size returns the current number of inserted elements into the table including if a null has been inserted.

func (Float32MemoTable) TypeTraits

func (Float32MemoTable) TypeTraits() TypeTraits

func (*Float32MemoTable) WriteOut

func (s *Float32MemoTable) WriteOut(out []byte)

func (*Float32MemoTable) WriteOutLE

func (s *Float32MemoTable) WriteOutLE(out []byte)

func (*Float32MemoTable) WriteOutSubset

func (s *Float32MemoTable) WriteOutSubset(start int, out []byte)

func (*Float32MemoTable) WriteOutSubsetLE

func (s *Float32MemoTable) WriteOutSubsetLE(start int, out []byte)

type Float64HashTable

type Float64HashTable struct {
	// contains filtered or unexported fields
}

Float64HashTable is a hashtable specifically for float64 that is utilized with the MemoTable to generalize interactions for easier implementation of dictionaries without losing performance.

func NewFloat64HashTable

func NewFloat64HashTable(cap uint64) *Float64HashTable

NewFloat64HashTable returns a new hash table for float64 values initialized with the passed in capacity or 32 whichever is larger.

func (*Float64HashTable) CopyValues

func (h *Float64HashTable) CopyValues(out []float64)

CopyValues is used for copying the values out of the hash table into the passed in slice, in the order that they were first inserted

func (*Float64HashTable) CopyValuesSubset

func (h *Float64HashTable) CopyValuesSubset(start int, out []float64)

CopyValuesSubset copies a subset of the values in the hashtable out, starting with the value at start, in the order that they were inserted.

func (*Float64HashTable) Insert

func (h *Float64HashTable) Insert(e *entryFloat64, v uint64, val float64, memoIdx int32) error

Insert updates the given entry with the provided hash value, payload value and memo index. The entry pointer must have been retrieved via lookup in order to actually insert properly.

func (*Float64HashTable) Lookup

func (h *Float64HashTable) Lookup(v uint64, cmp func(float64) bool) (*entryFloat64, bool)

Lookup retrieves the entry for a given hash value assuming it's payload value returns true when passed to the cmp func. Returns a pointer to the entry for the given hash value, and a boolean as to whether it was found. It is not safe to use the pointer if the bool is false.

func (*Float64HashTable) Reset

func (h *Float64HashTable) Reset(cap uint64)

Reset drops all of the values in this hash table and re-initializes it with the specified initial capacity as if by calling New, but without having to reallocate the object.

func (*Float64HashTable) VisitEntries

func (h *Float64HashTable) VisitEntries(visit func(*entryFloat64))

VisitEntries will call the passed in function on each *valid* entry in the hash table, a valid entry being one which has had a value inserted into it.

func (*Float64HashTable) WriteOut

func (h *Float64HashTable) WriteOut(out []byte)

func (*Float64HashTable) WriteOutSubset

func (h *Float64HashTable) WriteOutSubset(start int, out []byte)

type Float64MemoTable

type Float64MemoTable struct {
	// contains filtered or unexported fields
}

Float64MemoTable is a wrapper over the appropriate hashtable to provide an interface conforming to the MemoTable interface defined in the encoding package for general interactions regarding dictionaries.

func NewFloat64MemoTable

func NewFloat64MemoTable(num int64) *Float64MemoTable

NewFloat64MemoTable returns a new memotable with num entries pre-allocated to reduce further allocations when inserting.

func (*Float64MemoTable) CopyValues

func (s *Float64MemoTable) CopyValues(out interface{})

CopyValues will copy the values from the memo table out into the passed in slice which must be of the appropriate type.

func (*Float64MemoTable) CopyValuesSubset

func (s *Float64MemoTable) CopyValuesSubset(start int, out interface{})

CopyValuesSubset is like CopyValues but only copies a subset of values starting at the provided start index

func (*Float64MemoTable) Get

func (s *Float64MemoTable) Get(val interface{}) (int, bool)

Get returns the index of the requested value in the hash table or KeyNotFound along with a boolean indicating if it was found or not.

func (*Float64MemoTable) GetNull

func (s *Float64MemoTable) GetNull() (int, bool)

GetNull returns the index of an inserted null or KeyNotFound along with a bool that will be true if found and false if not.

func (*Float64MemoTable) GetOrInsert

func (s *Float64MemoTable) GetOrInsert(val interface{}) (idx int, found bool, err error)

GetOrInsert will return the index of the specified value in the table, or insert the value into the table and return the new index. found indicates whether or not it already existed in the table (true) or was inserted by this call (false).

func (*Float64MemoTable) GetOrInsertNull

func (s *Float64MemoTable) GetOrInsertNull() (idx int, found bool)

GetOrInsertNull will return the index of the null entry or insert a null entry if one currently doesn't exist. The found value will be true if there was already a null in the table, and false if it inserted one.

func (*Float64MemoTable) Reset

func (s *Float64MemoTable) Reset()

Reset allows this table to be re-used by dumping all the data currently in the table.

func (*Float64MemoTable) Size

func (s *Float64MemoTable) Size() int

Size returns the current number of inserted elements into the table including if a null has been inserted.

func (Float64MemoTable) TypeTraits

func (Float64MemoTable) TypeTraits() TypeTraits

func (*Float64MemoTable) WriteOut

func (s *Float64MemoTable) WriteOut(out []byte)

func (*Float64MemoTable) WriteOutLE

func (s *Float64MemoTable) WriteOutLE(out []byte)

func (*Float64MemoTable) WriteOutSubset

func (s *Float64MemoTable) WriteOutSubset(start int, out []byte)

func (*Float64MemoTable) WriteOutSubsetLE

func (s *Float64MemoTable) WriteOutSubsetLE(start int, out []byte)

type Int16HashTable

type Int16HashTable struct {
	// contains filtered or unexported fields
}

Int16HashTable is a hashtable specifically for int16 that is utilized with the MemoTable to generalize interactions for easier implementation of dictionaries without losing performance.

func NewInt16HashTable

func NewInt16HashTable(cap uint64) *Int16HashTable

NewInt16HashTable returns a new hash table for int16 values initialized with the passed in capacity or 32 whichever is larger.

func (*Int16HashTable) CopyValues

func (h *Int16HashTable) CopyValues(out []int16)

CopyValues is used for copying the values out of the hash table into the passed in slice, in the order that they were first inserted

func (*Int16HashTable) CopyValuesSubset

func (h *Int16HashTable) CopyValuesSubset(start int, out []int16)

CopyValuesSubset copies a subset of the values in the hashtable out, starting with the value at start, in the order that they were inserted.

func (*Int16HashTable) Insert

func (h *Int16HashTable) Insert(e *entryInt16, v uint64, val int16, memoIdx int32) error

Insert updates the given entry with the provided hash value, payload value and memo index. The entry pointer must have been retrieved via lookup in order to actually insert properly.

func (*Int16HashTable) Lookup

func (h *Int16HashTable) Lookup(v uint64, cmp func(int16) bool) (*entryInt16, bool)

Lookup retrieves the entry for a given hash value assuming it's payload value returns true when passed to the cmp func. Returns a pointer to the entry for the given hash value, and a boolean as to whether it was found. It is not safe to use the pointer if the bool is false.

func (*Int16HashTable) Reset

func (h *Int16HashTable) Reset(cap uint64)

Reset drops all of the values in this hash table and re-initializes it with the specified initial capacity as if by calling New, but without having to reallocate the object.

func (*Int16HashTable) VisitEntries

func (h *Int16HashTable) VisitEntries(visit func(*entryInt16))

VisitEntries will call the passed in function on each *valid* entry in the hash table, a valid entry being one which has had a value inserted into it.

func (*Int16HashTable) WriteOut

func (h *Int16HashTable) WriteOut(out []byte)

func (*Int16HashTable) WriteOutSubset

func (h *Int16HashTable) WriteOutSubset(start int, out []byte)

type Int16MemoTable

type Int16MemoTable struct {
	// contains filtered or unexported fields
}

Int16MemoTable is a wrapper over the appropriate hashtable to provide an interface conforming to the MemoTable interface defined in the encoding package for general interactions regarding dictionaries.

func NewInt16MemoTable

func NewInt16MemoTable(num int64) *Int16MemoTable

NewInt16MemoTable returns a new memotable with num entries pre-allocated to reduce further allocations when inserting.

func (*Int16MemoTable) CopyValues

func (s *Int16MemoTable) CopyValues(out interface{})

CopyValues will copy the values from the memo table out into the passed in slice which must be of the appropriate type.

func (*Int16MemoTable) CopyValuesSubset

func (s *Int16MemoTable) CopyValuesSubset(start int, out interface{})

CopyValuesSubset is like CopyValues but only copies a subset of values starting at the provided start index

func (*Int16MemoTable) Get

func (s *Int16MemoTable) Get(val interface{}) (int, bool)

Get returns the index of the requested value in the hash table or KeyNotFound along with a boolean indicating if it was found or not.

func (*Int16MemoTable) GetNull

func (s *Int16MemoTable) GetNull() (int, bool)

GetNull returns the index of an inserted null or KeyNotFound along with a bool that will be true if found and false if not.

func (*Int16MemoTable) GetOrInsert

func (s *Int16MemoTable) GetOrInsert(val interface{}) (idx int, found bool, err error)

GetOrInsert will return the index of the specified value in the table, or insert the value into the table and return the new index. found indicates whether or not it already existed in the table (true) or was inserted by this call (false).

func (*Int16MemoTable) GetOrInsertNull

func (s *Int16MemoTable) GetOrInsertNull() (idx int, found bool)

GetOrInsertNull will return the index of the null entry or insert a null entry if one currently doesn't exist. The found value will be true if there was already a null in the table, and false if it inserted one.

func (*Int16MemoTable) Reset

func (s *Int16MemoTable) Reset()

Reset allows this table to be re-used by dumping all the data currently in the table.

func (*Int16MemoTable) Size

func (s *Int16MemoTable) Size() int

Size returns the current number of inserted elements into the table including if a null has been inserted.

func (Int16MemoTable) TypeTraits

func (Int16MemoTable) TypeTraits() TypeTraits

func (*Int16MemoTable) WriteOut

func (s *Int16MemoTable) WriteOut(out []byte)

func (*Int16MemoTable) WriteOutLE

func (s *Int16MemoTable) WriteOutLE(out []byte)

func (*Int16MemoTable) WriteOutSubset

func (s *Int16MemoTable) WriteOutSubset(start int, out []byte)

func (*Int16MemoTable) WriteOutSubsetLE

func (s *Int16MemoTable) WriteOutSubsetLE(start int, out []byte)

type Int32HashTable

type Int32HashTable struct {
	// contains filtered or unexported fields
}

Int32HashTable is a hashtable specifically for int32 that is utilized with the MemoTable to generalize interactions for easier implementation of dictionaries without losing performance.

func NewInt32HashTable

func NewInt32HashTable(cap uint64) *Int32HashTable

NewInt32HashTable returns a new hash table for int32 values initialized with the passed in capacity or 32 whichever is larger.

func (*Int32HashTable) CopyValues

func (h *Int32HashTable) CopyValues(out []int32)

CopyValues is used for copying the values out of the hash table into the passed in slice, in the order that they were first inserted

func (*Int32HashTable) CopyValuesSubset

func (h *Int32HashTable) CopyValuesSubset(start int, out []int32)

CopyValuesSubset copies a subset of the values in the hashtable out, starting with the value at start, in the order that they were inserted.

func (*Int32HashTable) Insert

func (h *Int32HashTable) Insert(e *entryInt32, v uint64, val int32, memoIdx int32) error

Insert updates the given entry with the provided hash value, payload value and memo index. The entry pointer must have been retrieved via lookup in order to actually insert properly.

func (*Int32HashTable) Lookup

func (h *Int32HashTable) Lookup(v uint64, cmp func(int32) bool) (*entryInt32, bool)

Lookup retrieves the entry for a given hash value assuming it's payload value returns true when passed to the cmp func. Returns a pointer to the entry for the given hash value, and a boolean as to whether it was found. It is not safe to use the pointer if the bool is false.

func (*Int32HashTable) Reset

func (h *Int32HashTable) Reset(cap uint64)

Reset drops all of the values in this hash table and re-initializes it with the specified initial capacity as if by calling New, but without having to reallocate the object.

func (*Int32HashTable) VisitEntries

func (h *Int32HashTable) VisitEntries(visit func(*entryInt32))

VisitEntries will call the passed in function on each *valid* entry in the hash table, a valid entry being one which has had a value inserted into it.

func (*Int32HashTable) WriteOut

func (h *Int32HashTable) WriteOut(out []byte)

func (*Int32HashTable) WriteOutSubset

func (h *Int32HashTable) WriteOutSubset(start int, out []byte)

type Int32MemoTable

type Int32MemoTable struct {
	// contains filtered or unexported fields
}

Int32MemoTable is a wrapper over the appropriate hashtable to provide an interface conforming to the MemoTable interface defined in the encoding package for general interactions regarding dictionaries.

func NewInt32MemoTable

func NewInt32MemoTable(num int64) *Int32MemoTable

NewInt32MemoTable returns a new memotable with num entries pre-allocated to reduce further allocations when inserting.

func (*Int32MemoTable) CopyValues

func (s *Int32MemoTable) CopyValues(out interface{})

CopyValues will copy the values from the memo table out into the passed in slice which must be of the appropriate type.

func (*Int32MemoTable) CopyValuesSubset

func (s *Int32MemoTable) CopyValuesSubset(start int, out interface{})

CopyValuesSubset is like CopyValues but only copies a subset of values starting at the provided start index

func (*Int32MemoTable) Get

func (s *Int32MemoTable) Get(val interface{}) (int, bool)

Get returns the index of the requested value in the hash table or KeyNotFound along with a boolean indicating if it was found or not.

func (*Int32MemoTable) GetNull

func (s *Int32MemoTable) GetNull() (int, bool)

GetNull returns the index of an inserted null or KeyNotFound along with a bool that will be true if found and false if not.

func (*Int32MemoTable) GetOrInsert

func (s *Int32MemoTable) GetOrInsert(val interface{}) (idx int, found bool, err error)

GetOrInsert will return the index of the specified value in the table, or insert the value into the table and return the new index. found indicates whether or not it already existed in the table (true) or was inserted by this call (false).

func (*Int32MemoTable) GetOrInsertNull

func (s *Int32MemoTable) GetOrInsertNull() (idx int, found bool)

GetOrInsertNull will return the index of the null entry or insert a null entry if one currently doesn't exist. The found value will be true if there was already a null in the table, and false if it inserted one.

func (*Int32MemoTable) Reset

func (s *Int32MemoTable) Reset()

Reset allows this table to be re-used by dumping all the data currently in the table.

func (*Int32MemoTable) Size

func (s *Int32MemoTable) Size() int

Size returns the current number of inserted elements into the table including if a null has been inserted.

func (Int32MemoTable) TypeTraits

func (Int32MemoTable) TypeTraits() TypeTraits

func (*Int32MemoTable) WriteOut

func (s *Int32MemoTable) WriteOut(out []byte)

func (*Int32MemoTable) WriteOutLE

func (s *Int32MemoTable) WriteOutLE(out []byte)

func (*Int32MemoTable) WriteOutSubset

func (s *Int32MemoTable) WriteOutSubset(start int, out []byte)

func (*Int32MemoTable) WriteOutSubsetLE

func (s *Int32MemoTable) WriteOutSubsetLE(start int, out []byte)

type Int64HashTable

type Int64HashTable struct {
	// contains filtered or unexported fields
}

Int64HashTable is a hashtable specifically for int64 that is utilized with the MemoTable to generalize interactions for easier implementation of dictionaries without losing performance.

func NewInt64HashTable

func NewInt64HashTable(cap uint64) *Int64HashTable

NewInt64HashTable returns a new hash table for int64 values initialized with the passed in capacity or 32 whichever is larger.

func (*Int64HashTable) CopyValues

func (h *Int64HashTable) CopyValues(out []int64)

CopyValues is used for copying the values out of the hash table into the passed in slice, in the order that they were first inserted

func (*Int64HashTable) CopyValuesSubset

func (h *Int64HashTable) CopyValuesSubset(start int, out []int64)

CopyValuesSubset copies a subset of the values in the hashtable out, starting with the value at start, in the order that they were inserted.

func (*Int64HashTable) Insert

func (h *Int64HashTable) Insert(e *entryInt64, v uint64, val int64, memoIdx int32) error

Insert updates the given entry with the provided hash value, payload value and memo index. The entry pointer must have been retrieved via lookup in order to actually insert properly.

func (*Int64HashTable) Lookup

func (h *Int64HashTable) Lookup(v uint64, cmp func(int64) bool) (*entryInt64, bool)

Lookup retrieves the entry for a given hash value assuming it's payload value returns true when passed to the cmp func. Returns a pointer to the entry for the given hash value, and a boolean as to whether it was found. It is not safe to use the pointer if the bool is false.

func (*Int64HashTable) Reset

func (h *Int64HashTable) Reset(cap uint64)

Reset drops all of the values in this hash table and re-initializes it with the specified initial capacity as if by calling New, but without having to reallocate the object.

func (*Int64HashTable) VisitEntries

func (h *Int64HashTable) VisitEntries(visit func(*entryInt64))

VisitEntries will call the passed in function on each *valid* entry in the hash table, a valid entry being one which has had a value inserted into it.

func (*Int64HashTable) WriteOut

func (h *Int64HashTable) WriteOut(out []byte)

func (*Int64HashTable) WriteOutSubset

func (h *Int64HashTable) WriteOutSubset(start int, out []byte)

type Int64MemoTable

type Int64MemoTable struct {
	// contains filtered or unexported fields
}

Int64MemoTable is a wrapper over the appropriate hashtable to provide an interface conforming to the MemoTable interface defined in the encoding package for general interactions regarding dictionaries.

func NewInt64MemoTable

func NewInt64MemoTable(num int64) *Int64MemoTable

NewInt64MemoTable returns a new memotable with num entries pre-allocated to reduce further allocations when inserting.

func (*Int64MemoTable) CopyValues

func (s *Int64MemoTable) CopyValues(out interface{})

CopyValues will copy the values from the memo table out into the passed in slice which must be of the appropriate type.

func (*Int64MemoTable) CopyValuesSubset

func (s *Int64MemoTable) CopyValuesSubset(start int, out interface{})

CopyValuesSubset is like CopyValues but only copies a subset of values starting at the provided start index

func (*Int64MemoTable) Get

func (s *Int64MemoTable) Get(val interface{}) (int, bool)

Get returns the index of the requested value in the hash table or KeyNotFound along with a boolean indicating if it was found or not.

func (*Int64MemoTable) GetNull

func (s *Int64MemoTable) GetNull() (int, bool)

GetNull returns the index of an inserted null or KeyNotFound along with a bool that will be true if found and false if not.

func (*Int64MemoTable) GetOrInsert

func (s *Int64MemoTable) GetOrInsert(val interface{}) (idx int, found bool, err error)

GetOrInsert will return the index of the specified value in the table, or insert the value into the table and return the new index. found indicates whether or not it already existed in the table (true) or was inserted by this call (false).

func (*Int64MemoTable) GetOrInsertNull

func (s *Int64MemoTable) GetOrInsertNull() (idx int, found bool)

GetOrInsertNull will return the index of the null entry or insert a null entry if one currently doesn't exist. The found value will be true if there was already a null in the table, and false if it inserted one.

func (*Int64MemoTable) Reset

func (s *Int64MemoTable) Reset()

Reset allows this table to be re-used by dumping all the data currently in the table.

func (*Int64MemoTable) Size

func (s *Int64MemoTable) Size() int

Size returns the current number of inserted elements into the table including if a null has been inserted.

func (Int64MemoTable) TypeTraits

func (Int64MemoTable) TypeTraits() TypeTraits

func (*Int64MemoTable) WriteOut

func (s *Int64MemoTable) WriteOut(out []byte)

func (*Int64MemoTable) WriteOutLE

func (s *Int64MemoTable) WriteOutLE(out []byte)

func (*Int64MemoTable) WriteOutSubset

func (s *Int64MemoTable) WriteOutSubset(start int, out []byte)

func (*Int64MemoTable) WriteOutSubsetLE

func (s *Int64MemoTable) WriteOutSubsetLE(start int, out []byte)

type Int8HashTable

type Int8HashTable struct {
	// contains filtered or unexported fields
}

Int8HashTable is a hashtable specifically for int8 that is utilized with the MemoTable to generalize interactions for easier implementation of dictionaries without losing performance.

func NewInt8HashTable

func NewInt8HashTable(cap uint64) *Int8HashTable

NewInt8HashTable returns a new hash table for int8 values initialized with the passed in capacity or 32 whichever is larger.

func (*Int8HashTable) CopyValues

func (h *Int8HashTable) CopyValues(out []int8)

CopyValues is used for copying the values out of the hash table into the passed in slice, in the order that they were first inserted

func (*Int8HashTable) CopyValuesSubset

func (h *Int8HashTable) CopyValuesSubset(start int, out []int8)

CopyValuesSubset copies a subset of the values in the hashtable out, starting with the value at start, in the order that they were inserted.

func (*Int8HashTable) Insert

func (h *Int8HashTable) Insert(e *entryInt8, v uint64, val int8, memoIdx int32) error

Insert updates the given entry with the provided hash value, payload value and memo index. The entry pointer must have been retrieved via lookup in order to actually insert properly.

func (*Int8HashTable) Lookup

func (h *Int8HashTable) Lookup(v uint64, cmp func(int8) bool) (*entryInt8, bool)

Lookup retrieves the entry for a given hash value assuming it's payload value returns true when passed to the cmp func. Returns a pointer to the entry for the given hash value, and a boolean as to whether it was found. It is not safe to use the pointer if the bool is false.

func (*Int8HashTable) Reset

func (h *Int8HashTable) Reset(cap uint64)

Reset drops all of the values in this hash table and re-initializes it with the specified initial capacity as if by calling New, but without having to reallocate the object.

func (*Int8HashTable) VisitEntries

func (h *Int8HashTable) VisitEntries(visit func(*entryInt8))

VisitEntries will call the passed in function on each *valid* entry in the hash table, a valid entry being one which has had a value inserted into it.

func (*Int8HashTable) WriteOut

func (h *Int8HashTable) WriteOut(out []byte)

func (*Int8HashTable) WriteOutSubset

func (h *Int8HashTable) WriteOutSubset(start int, out []byte)

type Int8MemoTable

type Int8MemoTable struct {
	// contains filtered or unexported fields
}

Int8MemoTable is a wrapper over the appropriate hashtable to provide an interface conforming to the MemoTable interface defined in the encoding package for general interactions regarding dictionaries.

func NewInt8MemoTable

func NewInt8MemoTable(num int64) *Int8MemoTable

NewInt8MemoTable returns a new memotable with num entries pre-allocated to reduce further allocations when inserting.

func (*Int8MemoTable) CopyValues

func (s *Int8MemoTable) CopyValues(out interface{})

CopyValues will copy the values from the memo table out into the passed in slice which must be of the appropriate type.

func (*Int8MemoTable) CopyValuesSubset

func (s *Int8MemoTable) CopyValuesSubset(start int, out interface{})

CopyValuesSubset is like CopyValues but only copies a subset of values starting at the provided start index

func (*Int8MemoTable) Get

func (s *Int8MemoTable) Get(val interface{}) (int, bool)

Get returns the index of the requested value in the hash table or KeyNotFound along with a boolean indicating if it was found or not.

func (*Int8MemoTable) GetNull

func (s *Int8MemoTable) GetNull() (int, bool)

GetNull returns the index of an inserted null or KeyNotFound along with a bool that will be true if found and false if not.

func (*Int8MemoTable) GetOrInsert

func (s *Int8MemoTable) GetOrInsert(val interface{}) (idx int, found bool, err error)

GetOrInsert will return the index of the specified value in the table, or insert the value into the table and return the new index. found indicates whether or not it already existed in the table (true) or was inserted by this call (false).

func (*Int8MemoTable) GetOrInsertNull

func (s *Int8MemoTable) GetOrInsertNull() (idx int, found bool)

GetOrInsertNull will return the index of the null entry or insert a null entry if one currently doesn't exist. The found value will be true if there was already a null in the table, and false if it inserted one.

func (*Int8MemoTable) Reset

func (s *Int8MemoTable) Reset()

Reset allows this table to be re-used by dumping all the data currently in the table.

func (*Int8MemoTable) Size

func (s *Int8MemoTable) Size() int

Size returns the current number of inserted elements into the table including if a null has been inserted.

func (Int8MemoTable) TypeTraits

func (Int8MemoTable) TypeTraits() TypeTraits

func (*Int8MemoTable) WriteOut

func (s *Int8MemoTable) WriteOut(out []byte)

func (*Int8MemoTable) WriteOutLE

func (s *Int8MemoTable) WriteOutLE(out []byte)

func (*Int8MemoTable) WriteOutSubset

func (s *Int8MemoTable) WriteOutSubset(start int, out []byte)

func (*Int8MemoTable) WriteOutSubsetLE

func (s *Int8MemoTable) WriteOutSubsetLE(start int, out []byte)

type MemoTable

type MemoTable interface {
	TypeTraits() TypeTraits
	// Reset drops everything in the table allowing it to be reused
	Reset()
	// Size returns the current number of unique values stored in
	// the table, including whether or not a null value has been
	// inserted via GetOrInsertNull.
	Size() int
	// GetOrInsert returns the index of the table the specified value is,
	// and a boolean indicating whether or not the value was found in
	// the table (if false, the value was inserted). An error is returned
	// if val is not the appropriate type for the table.
	GetOrInsert(val interface{}) (idx int, existed bool, err error)
	// GetOrInsertNull returns the index of the null value in the table,
	// inserting one if it hasn't already been inserted. It returns a boolean
	// indicating if the null value already existed or not in the table.
	GetOrInsertNull() (idx int, existed bool)
	// GetNull returns the index of the null value in the table, but does not
	// insert one if it doesn't already exist. Will return -1 if it doesn't exist
	// indicated by a false value for the boolean.
	GetNull() (idx int, exists bool)
	// WriteOut copys the unique values of the memotable out to the byte slice
	// provided. Must have allocated enough bytes for all the values.
	WriteOut(out []byte)
	// WriteOutSubset is like WriteOut, but only writes a subset of values
	// starting with the index offset.
	WriteOutSubset(offset int, out []byte)
}

MemoTable interface for hash tables and dictionary encoding.

Values will remember the order they are inserted to generate a valid dictionary.

type NumericMemoTable

type NumericMemoTable interface {
	MemoTable
	WriteOutLE(out []byte)
	WriteOutSubsetLE(offset int, out []byte)
}

type TypeTraits

type TypeTraits interface {
	BytesRequired(n int) int
}

type Uint16HashTable

type Uint16HashTable struct {
	// contains filtered or unexported fields
}

Uint16HashTable is a hashtable specifically for uint16 that is utilized with the MemoTable to generalize interactions for easier implementation of dictionaries without losing performance.

func NewUint16HashTable

func NewUint16HashTable(cap uint64) *Uint16HashTable

NewUint16HashTable returns a new hash table for uint16 values initialized with the passed in capacity or 32 whichever is larger.

func (*Uint16HashTable) CopyValues

func (h *Uint16HashTable) CopyValues(out []uint16)

CopyValues is used for copying the values out of the hash table into the passed in slice, in the order that they were first inserted

func (*Uint16HashTable) CopyValuesSubset

func (h *Uint16HashTable) CopyValuesSubset(start int, out []uint16)

CopyValuesSubset copies a subset of the values in the hashtable out, starting with the value at start, in the order that they were inserted.

func (*Uint16HashTable) Insert

func (h *Uint16HashTable) Insert(e *entryUint16, v uint64, val uint16, memoIdx int32) error

Insert updates the given entry with the provided hash value, payload value and memo index. The entry pointer must have been retrieved via lookup in order to actually insert properly.

func (*Uint16HashTable) Lookup

func (h *Uint16HashTable) Lookup(v uint64, cmp func(uint16) bool) (*entryUint16, bool)

Lookup retrieves the entry for a given hash value assuming it's payload value returns true when passed to the cmp func. Returns a pointer to the entry for the given hash value, and a boolean as to whether it was found. It is not safe to use the pointer if the bool is false.

func (*Uint16HashTable) Reset

func (h *Uint16HashTable) Reset(cap uint64)

Reset drops all of the values in this hash table and re-initializes it with the specified initial capacity as if by calling New, but without having to reallocate the object.

func (*Uint16HashTable) VisitEntries

func (h *Uint16HashTable) VisitEntries(visit func(*entryUint16))

VisitEntries will call the passed in function on each *valid* entry in the hash table, a valid entry being one which has had a value inserted into it.

func (*Uint16HashTable) WriteOut

func (h *Uint16HashTable) WriteOut(out []byte)

func (*Uint16HashTable) WriteOutSubset

func (h *Uint16HashTable) WriteOutSubset(start int, out []byte)

type Uint16MemoTable

type Uint16MemoTable struct {
	// contains filtered or unexported fields
}

Uint16MemoTable is a wrapper over the appropriate hashtable to provide an interface conforming to the MemoTable interface defined in the encoding package for general interactions regarding dictionaries.

func NewUint16MemoTable

func NewUint16MemoTable(num int64) *Uint16MemoTable

NewUint16MemoTable returns a new memotable with num entries pre-allocated to reduce further allocations when inserting.

func (*Uint16MemoTable) CopyValues

func (s *Uint16MemoTable) CopyValues(out interface{})

CopyValues will copy the values from the memo table out into the passed in slice which must be of the appropriate type.

func (*Uint16MemoTable) CopyValuesSubset

func (s *Uint16MemoTable) CopyValuesSubset(start int, out interface{})

CopyValuesSubset is like CopyValues but only copies a subset of values starting at the provided start index

func (*Uint16MemoTable) Get

func (s *Uint16MemoTable) Get(val interface{}) (int, bool)

Get returns the index of the requested value in the hash table or KeyNotFound along with a boolean indicating if it was found or not.

func (*Uint16MemoTable) GetNull

func (s *Uint16MemoTable) GetNull() (int, bool)

GetNull returns the index of an inserted null or KeyNotFound along with a bool that will be true if found and false if not.

func (*Uint16MemoTable) GetOrInsert

func (s *Uint16MemoTable) GetOrInsert(val interface{}) (idx int, found bool, err error)

GetOrInsert will return the index of the specified value in the table, or insert the value into the table and return the new index. found indicates whether or not it already existed in the table (true) or was inserted by this call (false).

func (*Uint16MemoTable) GetOrInsertNull

func (s *Uint16MemoTable) GetOrInsertNull() (idx int, found bool)

GetOrInsertNull will return the index of the null entry or insert a null entry if one currently doesn't exist. The found value will be true if there was already a null in the table, and false if it inserted one.

func (*Uint16MemoTable) Reset

func (s *Uint16MemoTable) Reset()

Reset allows this table to be re-used by dumping all the data currently in the table.

func (*Uint16MemoTable) Size

func (s *Uint16MemoTable) Size() int

Size returns the current number of inserted elements into the table including if a null has been inserted.

func (Uint16MemoTable) TypeTraits

func (Uint16MemoTable) TypeTraits() TypeTraits

func (*Uint16MemoTable) WriteOut

func (s *Uint16MemoTable) WriteOut(out []byte)

func (*Uint16MemoTable) WriteOutLE

func (s *Uint16MemoTable) WriteOutLE(out []byte)

func (*Uint16MemoTable) WriteOutSubset

func (s *Uint16MemoTable) WriteOutSubset(start int, out []byte)

func (*Uint16MemoTable) WriteOutSubsetLE

func (s *Uint16MemoTable) WriteOutSubsetLE(start int, out []byte)

type Uint32HashTable

type Uint32HashTable struct {
	// contains filtered or unexported fields
}

Uint32HashTable is a hashtable specifically for uint32 that is utilized with the MemoTable to generalize interactions for easier implementation of dictionaries without losing performance.

func NewUint32HashTable

func NewUint32HashTable(cap uint64) *Uint32HashTable

NewUint32HashTable returns a new hash table for uint32 values initialized with the passed in capacity or 32 whichever is larger.

func (*Uint32HashTable) CopyValues

func (h *Uint32HashTable) CopyValues(out []uint32)

CopyValues is used for copying the values out of the hash table into the passed in slice, in the order that they were first inserted

func (*Uint32HashTable) CopyValuesSubset

func (h *Uint32HashTable) CopyValuesSubset(start int, out []uint32)

CopyValuesSubset copies a subset of the values in the hashtable out, starting with the value at start, in the order that they were inserted.

func (*Uint32HashTable) Insert

func (h *Uint32HashTable) Insert(e *entryUint32, v uint64, val uint32, memoIdx int32) error

Insert updates the given entry with the provided hash value, payload value and memo index. The entry pointer must have been retrieved via lookup in order to actually insert properly.

func (*Uint32HashTable) Lookup

func (h *Uint32HashTable) Lookup(v uint64, cmp func(uint32) bool) (*entryUint32, bool)

Lookup retrieves the entry for a given hash value assuming it's payload value returns true when passed to the cmp func. Returns a pointer to the entry for the given hash value, and a boolean as to whether it was found. It is not safe to use the pointer if the bool is false.

func (*Uint32HashTable) Reset

func (h *Uint32HashTable) Reset(cap uint64)

Reset drops all of the values in this hash table and re-initializes it with the specified initial capacity as if by calling New, but without having to reallocate the object.

func (*Uint32HashTable) VisitEntries

func (h *Uint32HashTable) VisitEntries(visit func(*entryUint32))

VisitEntries will call the passed in function on each *valid* entry in the hash table, a valid entry being one which has had a value inserted into it.

func (*Uint32HashTable) WriteOut

func (h *Uint32HashTable) WriteOut(out []byte)

func (*Uint32HashTable) WriteOutSubset

func (h *Uint32HashTable) WriteOutSubset(start int, out []byte)

type Uint32MemoTable

type Uint32MemoTable struct {
	// contains filtered or unexported fields
}

Uint32MemoTable is a wrapper over the appropriate hashtable to provide an interface conforming to the MemoTable interface defined in the encoding package for general interactions regarding dictionaries.

func NewUint32MemoTable

func NewUint32MemoTable(num int64) *Uint32MemoTable

NewUint32MemoTable returns a new memotable with num entries pre-allocated to reduce further allocations when inserting.

func (*Uint32MemoTable) CopyValues

func (s *Uint32MemoTable) CopyValues(out interface{})

CopyValues will copy the values from the memo table out into the passed in slice which must be of the appropriate type.

func (*Uint32MemoTable) CopyValuesSubset

func (s *Uint32MemoTable) CopyValuesSubset(start int, out interface{})

CopyValuesSubset is like CopyValues but only copies a subset of values starting at the provided start index

func (*Uint32MemoTable) Get

func (s *Uint32MemoTable) Get(val interface{}) (int, bool)

Get returns the index of the requested value in the hash table or KeyNotFound along with a boolean indicating if it was found or not.

func (*Uint32MemoTable) GetNull

func (s *Uint32MemoTable) GetNull() (int, bool)

GetNull returns the index of an inserted null or KeyNotFound along with a bool that will be true if found and false if not.

func (*Uint32MemoTable) GetOrInsert

func (s *Uint32MemoTable) GetOrInsert(val interface{}) (idx int, found bool, err error)

GetOrInsert will return the index of the specified value in the table, or insert the value into the table and return the new index. found indicates whether or not it already existed in the table (true) or was inserted by this call (false).

func (*Uint32MemoTable) GetOrInsertNull

func (s *Uint32MemoTable) GetOrInsertNull() (idx int, found bool)

GetOrInsertNull will return the index of the null entry or insert a null entry if one currently doesn't exist. The found value will be true if there was already a null in the table, and false if it inserted one.

func (*Uint32MemoTable) Reset

func (s *Uint32MemoTable) Reset()

Reset allows this table to be re-used by dumping all the data currently in the table.

func (*Uint32MemoTable) Size

func (s *Uint32MemoTable) Size() int

Size returns the current number of inserted elements into the table including if a null has been inserted.

func (Uint32MemoTable) TypeTraits

func (Uint32MemoTable) TypeTraits() TypeTraits

func (*Uint32MemoTable) WriteOut

func (s *Uint32MemoTable) WriteOut(out []byte)

func (*Uint32MemoTable) WriteOutLE

func (s *Uint32MemoTable) WriteOutLE(out []byte)

func (*Uint32MemoTable) WriteOutSubset

func (s *Uint32MemoTable) WriteOutSubset(start int, out []byte)

func (*Uint32MemoTable) WriteOutSubsetLE

func (s *Uint32MemoTable) WriteOutSubsetLE(start int, out []byte)

type Uint64HashTable

type Uint64HashTable struct {
	// contains filtered or unexported fields
}

Uint64HashTable is a hashtable specifically for uint64 that is utilized with the MemoTable to generalize interactions for easier implementation of dictionaries without losing performance.

func NewUint64HashTable

func NewUint64HashTable(cap uint64) *Uint64HashTable

NewUint64HashTable returns a new hash table for uint64 values initialized with the passed in capacity or 32 whichever is larger.

func (*Uint64HashTable) CopyValues

func (h *Uint64HashTable) CopyValues(out []uint64)

CopyValues is used for copying the values out of the hash table into the passed in slice, in the order that they were first inserted

func (*Uint64HashTable) CopyValuesSubset

func (h *Uint64HashTable) CopyValuesSubset(start int, out []uint64)

CopyValuesSubset copies a subset of the values in the hashtable out, starting with the value at start, in the order that they were inserted.

func (*Uint64HashTable) Insert

func (h *Uint64HashTable) Insert(e *entryUint64, v uint64, val uint64, memoIdx int32) error

Insert updates the given entry with the provided hash value, payload value and memo index. The entry pointer must have been retrieved via lookup in order to actually insert properly.

func (*Uint64HashTable) Lookup

func (h *Uint64HashTable) Lookup(v uint64, cmp func(uint64) bool) (*entryUint64, bool)

Lookup retrieves the entry for a given hash value assuming it's payload value returns true when passed to the cmp func. Returns a pointer to the entry for the given hash value, and a boolean as to whether it was found. It is not safe to use the pointer if the bool is false.

func (*Uint64HashTable) Reset

func (h *Uint64HashTable) Reset(cap uint64)

Reset drops all of the values in this hash table and re-initializes it with the specified initial capacity as if by calling New, but without having to reallocate the object.

func (*Uint64HashTable) VisitEntries

func (h *Uint64HashTable) VisitEntries(visit func(*entryUint64))

VisitEntries will call the passed in function on each *valid* entry in the hash table, a valid entry being one which has had a value inserted into it.

func (*Uint64HashTable) WriteOut

func (h *Uint64HashTable) WriteOut(out []byte)

func (*Uint64HashTable) WriteOutSubset

func (h *Uint64HashTable) WriteOutSubset(start int, out []byte)

type Uint64MemoTable

type Uint64MemoTable struct {
	// contains filtered or unexported fields
}

Uint64MemoTable is a wrapper over the appropriate hashtable to provide an interface conforming to the MemoTable interface defined in the encoding package for general interactions regarding dictionaries.

func NewUint64MemoTable

func NewUint64MemoTable(num int64) *Uint64MemoTable

NewUint64MemoTable returns a new memotable with num entries pre-allocated to reduce further allocations when inserting.

func (*Uint64MemoTable) CopyValues

func (s *Uint64MemoTable) CopyValues(out interface{})

CopyValues will copy the values from the memo table out into the passed in slice which must be of the appropriate type.

func (*Uint64MemoTable) CopyValuesSubset

func (s *Uint64MemoTable) CopyValuesSubset(start int, out interface{})

CopyValuesSubset is like CopyValues but only copies a subset of values starting at the provided start index

func (*Uint64MemoTable) Get

func (s *Uint64MemoTable) Get(val interface{}) (int, bool)

Get returns the index of the requested value in the hash table or KeyNotFound along with a boolean indicating if it was found or not.

func (*Uint64MemoTable) GetNull

func (s *Uint64MemoTable) GetNull() (int, bool)

GetNull returns the index of an inserted null or KeyNotFound along with a bool that will be true if found and false if not.

func (*Uint64MemoTable) GetOrInsert

func (s *Uint64MemoTable) GetOrInsert(val interface{}) (idx int, found bool, err error)

GetOrInsert will return the index of the specified value in the table, or insert the value into the table and return the new index. found indicates whether or not it already existed in the table (true) or was inserted by this call (false).

func (*Uint64MemoTable) GetOrInsertNull

func (s *Uint64MemoTable) GetOrInsertNull() (idx int, found bool)

GetOrInsertNull will return the index of the null entry or insert a null entry if one currently doesn't exist. The found value will be true if there was already a null in the table, and false if it inserted one.

func (*Uint64MemoTable) Reset

func (s *Uint64MemoTable) Reset()

Reset allows this table to be re-used by dumping all the data currently in the table.

func (*Uint64MemoTable) Size

func (s *Uint64MemoTable) Size() int

Size returns the current number of inserted elements into the table including if a null has been inserted.

func (Uint64MemoTable) TypeTraits

func (Uint64MemoTable) TypeTraits() TypeTraits

func (*Uint64MemoTable) WriteOut

func (s *Uint64MemoTable) WriteOut(out []byte)

func (*Uint64MemoTable) WriteOutLE

func (s *Uint64MemoTable) WriteOutLE(out []byte)

func (*Uint64MemoTable) WriteOutSubset

func (s *Uint64MemoTable) WriteOutSubset(start int, out []byte)

func (*Uint64MemoTable) WriteOutSubsetLE

func (s *Uint64MemoTable) WriteOutSubsetLE(start int, out []byte)

type Uint8HashTable

type Uint8HashTable struct {
	// contains filtered or unexported fields
}

Uint8HashTable is a hashtable specifically for uint8 that is utilized with the MemoTable to generalize interactions for easier implementation of dictionaries without losing performance.

func NewUint8HashTable

func NewUint8HashTable(cap uint64) *Uint8HashTable

NewUint8HashTable returns a new hash table for uint8 values initialized with the passed in capacity or 32 whichever is larger.

func (*Uint8HashTable) CopyValues

func (h *Uint8HashTable) CopyValues(out []uint8)

CopyValues is used for copying the values out of the hash table into the passed in slice, in the order that they were first inserted

func (*Uint8HashTable) CopyValuesSubset

func (h *Uint8HashTable) CopyValuesSubset(start int, out []uint8)

CopyValuesSubset copies a subset of the values in the hashtable out, starting with the value at start, in the order that they were inserted.

func (*Uint8HashTable) Insert

func (h *Uint8HashTable) Insert(e *entryUint8, v uint64, val uint8, memoIdx int32) error

Insert updates the given entry with the provided hash value, payload value and memo index. The entry pointer must have been retrieved via lookup in order to actually insert properly.

func (*Uint8HashTable) Lookup

func (h *Uint8HashTable) Lookup(v uint64, cmp func(uint8) bool) (*entryUint8, bool)

Lookup retrieves the entry for a given hash value assuming it's payload value returns true when passed to the cmp func. Returns a pointer to the entry for the given hash value, and a boolean as to whether it was found. It is not safe to use the pointer if the bool is false.

func (*Uint8HashTable) Reset

func (h *Uint8HashTable) Reset(cap uint64)

Reset drops all of the values in this hash table and re-initializes it with the specified initial capacity as if by calling New, but without having to reallocate the object.

func (*Uint8HashTable) VisitEntries

func (h *Uint8HashTable) VisitEntries(visit func(*entryUint8))

VisitEntries will call the passed in function on each *valid* entry in the hash table, a valid entry being one which has had a value inserted into it.

func (*Uint8HashTable) WriteOut

func (h *Uint8HashTable) WriteOut(out []byte)

func (*Uint8HashTable) WriteOutSubset

func (h *Uint8HashTable) WriteOutSubset(start int, out []byte)

type Uint8MemoTable

type Uint8MemoTable struct {
	// contains filtered or unexported fields
}

Uint8MemoTable is a wrapper over the appropriate hashtable to provide an interface conforming to the MemoTable interface defined in the encoding package for general interactions regarding dictionaries.

func NewUint8MemoTable

func NewUint8MemoTable(num int64) *Uint8MemoTable

NewUint8MemoTable returns a new memotable with num entries pre-allocated to reduce further allocations when inserting.

func (*Uint8MemoTable) CopyValues

func (s *Uint8MemoTable) CopyValues(out interface{})

CopyValues will copy the values from the memo table out into the passed in slice which must be of the appropriate type.

func (*Uint8MemoTable) CopyValuesSubset

func (s *Uint8MemoTable) CopyValuesSubset(start int, out interface{})

CopyValuesSubset is like CopyValues but only copies a subset of values starting at the provided start index

func (*Uint8MemoTable) Get

func (s *Uint8MemoTable) Get(val interface{}) (int, bool)

Get returns the index of the requested value in the hash table or KeyNotFound along with a boolean indicating if it was found or not.

func (*Uint8MemoTable) GetNull

func (s *Uint8MemoTable) GetNull() (int, bool)

GetNull returns the index of an inserted null or KeyNotFound along with a bool that will be true if found and false if not.

func (*Uint8MemoTable) GetOrInsert

func (s *Uint8MemoTable) GetOrInsert(val interface{}) (idx int, found bool, err error)

GetOrInsert will return the index of the specified value in the table, or insert the value into the table and return the new index. found indicates whether or not it already existed in the table (true) or was inserted by this call (false).

func (*Uint8MemoTable) GetOrInsertNull

func (s *Uint8MemoTable) GetOrInsertNull() (idx int, found bool)

GetOrInsertNull will return the index of the null entry or insert a null entry if one currently doesn't exist. The found value will be true if there was already a null in the table, and false if it inserted one.

func (*Uint8MemoTable) Reset

func (s *Uint8MemoTable) Reset()

Reset allows this table to be re-used by dumping all the data currently in the table.

func (*Uint8MemoTable) Size

func (s *Uint8MemoTable) Size() int

Size returns the current number of inserted elements into the table including if a null has been inserted.

func (Uint8MemoTable) TypeTraits

func (Uint8MemoTable) TypeTraits() TypeTraits

func (*Uint8MemoTable) WriteOut

func (s *Uint8MemoTable) WriteOut(out []byte)

func (*Uint8MemoTable) WriteOutLE

func (s *Uint8MemoTable) WriteOutLE(out []byte)

func (*Uint8MemoTable) WriteOutSubset

func (s *Uint8MemoTable) WriteOutSubset(start int, out []byte)

func (*Uint8MemoTable) WriteOutSubsetLE

func (s *Uint8MemoTable) WriteOutSubsetLE(start int, out []byte)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL