Documentation ¶
Index ¶
- Variables
- func Marshal(obj interface{}) ([]byte, error)
- func MarshalStream(wrt io.Writer, obj interface{}) error
- func SExprAt[T any](s *SExpr, n int) (v T, ok bool)
- func Unmarshal(obj interface{}, data []byte) error
- func UnmarshalStream(rdr io.Reader, obj interface{}, pending int) error
- type BloomFilter
- type BloomFilterBase
- type CountingBloomFilter
- func (bf *CountingBloomFilter) Add(entry []byte)
- func (bf *CountingBloomFilter) Combine(bf2 *CountingBloomFilter) *CountingBloomFilter
- func (bf *CountingBloomFilter) Contains(entry []byte) bool
- func (bf *CountingBloomFilter) Remove(entry []byte) bool
- func (bf *CountingBloomFilter) SameKind(bf2 *CountingBloomFilter) bool
- func (bf *CountingBloomFilter) Size() uint
- type Generator
- type GeneratorChannel
- type GeneratorFunction
- type IntStack
- type Permutation
- type SExpr
- type SaltedBloomFilter
- type Stack
- type Vector
Constants ¶
This section is empty.
Variables ¶
var ( ErrMarshalNil = errors.New("object is nil") ErrMarshalInvalid = errors.New("object is invalid") ErrMarshalType = errors.New("invalid object type") ErrMarshalNoSize = errors.New("missing/invalid size tag on field") ErrMarshalNoOpt = errors.New("missing/invalid opt tag on field") ErrMarshalSizeMismatch = errors.New("size mismatch during unmarshal") ErrMarshalEmptyIntf = errors.New("can't handle empty interface") ErrMarshalUnknownType = errors.New("unknown field type") ErrMarshalMthdMissing = errors.New("missing method") ErrMarshalFieldRef = errors.New("field reference invalid") ErrMarshalMthdNumArg = errors.New("method has more than one argument") ErrMarshalMthdArgType = errors.New("method argument not a string") ErrMarshalMthdResult = errors.New("invalid method result") ErrMarshalParentMissing = errors.New("parent missing") )
Errors
Functions ¶
func MarshalStream ¶ added in v1.2.15
MarshalStream writes an object to stream
Types ¶
type BloomFilter ¶
type BloomFilter struct { BloomFilterBase Bits []byte `size:"(BitsSize)" json:"bits"` // bit storage }
A BloomFilter is a space/time efficient set of unique entries. It can not enumerate its elements, but can check if an entry is contained in the set. The check always succeeds for a contained entry, but can create "false-positives" (entries not contained in the map give a positive result). By adjusting the number of bits in the BloomFilter and the number of indices generated for an entry, a BloomFilter can handle a given number of entries with a desired upper-bound for the false-positive rate.
func NewBloomFilter ¶
func NewBloomFilter(numExpected int, falsePositiveRate float64) *BloomFilter
NewBloomFilter creates a new BloomFilter based on the upper-bounds for the number of entries and the "false-positive" rate.
func NewBloomFilterDirect ¶
func NewBloomFilterDirect(numBits, numIdx int) *BloomFilter
NewBloomFilterDirect creates a new BloomFilter based on the number of bits in the filter and the number of indices to be used.
func (*BloomFilter) BitsSize ¶ added in v1.2.20
func (bf *BloomFilter) BitsSize() uint
BitsSize returns the size of the byte array representing the filter bits.
func (*BloomFilter) Combine ¶ added in v1.1.1
func (bf *BloomFilter) Combine(bf2 *BloomFilter) *BloomFilter
Combine merges two BloomFilters (of same kind) into a new one.
func (*BloomFilter) Contains ¶
func (bf *BloomFilter) Contains(entry []byte) bool
Contains returns true if the BloomFilter contains the given entry, and false otherwise. If an entry was added to the set, this function will always return 'true'. It can return 'true' for entries not in the set ("false-positives").
func (*BloomFilter) SameKind ¶ added in v1.1.1
func (bf *BloomFilter) SameKind(bf2 *BloomFilter) bool
SameKind checks if two BloomFilter have the same parameters.
func (*BloomFilter) Size ¶ added in v1.2.20
func (bf *BloomFilter) Size() uint
Size returns the size of the binary representation
type BloomFilterBase ¶ added in v1.2.23
type BloomFilterBase struct { NumBits uint32 `size:"big" json:"numBits"` // number of bits in filter NumIdx uint8 `size:"big" json:"numIdx"` // number of indices NumIdxBits uint8 `json:"numIdxBits"` // number of bits per index NumHash uint8 `json:"numHash"` // number of SHA256 hashes needed }
BloomFilterBase for custom bloom filter implementations (e.g. simple, salted, counting, ...)
type CountingBloomFilter ¶ added in v1.2.23
type CountingBloomFilter struct { BloomFilterBase Counts []uint32 `size:"(NumBits)" json:"bits"` // counter storage }
CountingBloomFilter is an extension of a generic bloomfilter that keeps a count instead of a single bit for masking. This allows the deletion of entries for the cost of 32x emory increase.
func NewCountingBloomFilter ¶ added in v1.2.23
func NewCountingBloomFilter(numExpected int, falsePositiveRate float64) *CountingBloomFilter
NewCoutingBloomFilter creates a new BloomFilter based on the upper-bounds for the number of entries and the "false-positive" rate.
func NewCountingBloomFilterDirect ¶ added in v1.2.23
func NewCountingBloomFilterDirect(numBits, numIdx int) *CountingBloomFilter
NewCoutingBloomFilterDirect creates a new BloomFilter based on the number of bits in the filter and the number of indices to be used.
func (*CountingBloomFilter) Add ¶ added in v1.2.23
func (bf *CountingBloomFilter) Add(entry []byte)
Add an entry to the BloomFilter.
func (*CountingBloomFilter) Combine ¶ added in v1.2.23
func (bf *CountingBloomFilter) Combine(bf2 *CountingBloomFilter) *CountingBloomFilter
Combine merges two BloomFilters (of same kind) into a new one.
func (*CountingBloomFilter) Contains ¶ added in v1.2.23
func (bf *CountingBloomFilter) Contains(entry []byte) bool
Contains returns true if the BloomFilter contains the given entry, and false otherwise. If an entry was added to the set, this function will always return 'true'. It can return 'true' for entries not in the set ("false-positives").
func (*CountingBloomFilter) Remove ¶ added in v1.2.23
func (bf *CountingBloomFilter) Remove(entry []byte) bool
Remove an entry from the bloomfilter
func (*CountingBloomFilter) SameKind ¶ added in v1.2.23
func (bf *CountingBloomFilter) SameKind(bf2 *CountingBloomFilter) bool
SameKind checks if two BloomFilter have the same parameters.
func (*CountingBloomFilter) Size ¶ added in v1.2.23
func (bf *CountingBloomFilter) Size() uint
Size returns the size of the binary representation
type Generator ¶ added in v1.2.28
type Generator[T any] struct { // contains filtered or unexported fields }
Generator for elements of given type. A generator object only handles the boilerplate on behalf of a generator function.
Example:
g := NewGenerator(gen) for s := range g.Run() { : if ??? { g.Stop() break } }
func NewGenerator ¶ added in v1.2.28
func NewGenerator[T any](gen GeneratorFunction[T]) *Generator[T]
NewGenerator runs the generator function in a go-routine. Calling the Run() method on an instance returns a channel of given type where values can be retrieved. To terminate a running generator, call the Stop() method. After a generator has finished (either by itself or because it was stopped), it cannot be restarted.
type GeneratorChannel ¶ added in v1.2.28
type GeneratorChannel[T any] chan T
GeneratorChannel is used as a link between the generator boilerplate and a generator function.
func (GeneratorChannel[T]) Done ¶ added in v1.2.28
func (g GeneratorChannel[T]) Done()
Done with this generator - no more values can be generated.
func (GeneratorChannel[T]) Yield ¶ added in v1.2.28
func (g GeneratorChannel[T]) Yield(val T) (ok bool)
Yield a value (computed in a generator function) for a consumer. If the return value is false, the consumer indicates no more values are expected - so the generator function can terminate immediately.
type GeneratorFunction ¶ added in v1.2.28
type GeneratorFunction[T any] func(GeneratorChannel[T])
GeneratorFunction generates objects of given type and "yields" them to a channel. If the generator reaches end-of-output, it closes the channel. If yield returns false, the consumer has closed the channel to indicate it doesn't want any new objects.
Example:
func gen(out GeneratorChannel[string]) { for i := 0; i < 100; i++ { val := fmt.Sprintf("%d", i+1) if !out.Yield(val) { return } } out.Done() }
type IntStack ¶
type IntStack struct {
// contains filtered or unexported fields
}
IntStack is an Integer-based Stack type and implementation.
func NewIntStack ¶
func NewIntStack() *IntStack
NewIntStack instantiates a new integer-based Stack object.
type Permutation ¶ added in v1.2.29
type Permutation[T any] struct { // contains filtered or unexported fields }
Permutation of array elements
func NewPermutation ¶ added in v1.2.29
func NewPermutation[T any](in []T) *Permutation[T]
NewPermutation creates a shuffler for an array of elements
func (*Permutation[T]) Next ¶ added in v1.2.29
func (p *Permutation[T]) Next() (out []T, done bool)
type SExpr ¶ added in v1.2.28
type SExpr struct {
// contains filtered or unexported fields
}
SExpr is a node in a S-expression tree
func ParseCSExpr ¶ added in v1.2.28
ParseCSecpr parses a canonical S-expression into a tree of nodes.
func ParseSExpr ¶ added in v1.2.28
ParseSExpr parses a text-only S-expression into a tree of nodes.
type SaltedBloomFilter ¶ added in v1.2.20
type SaltedBloomFilter struct { Salt []byte `size:"4"` // salt value BloomFilter }
SaltedBloomFilter is a bloom filter where each entr is "salted" with a uint32 salt value before processing. As each filter have different salts, the same set of entries added to the filter will result in a different bit pattern for the filter resulting in different false- positives for the same set. Useful if a filter is repeatedly generated for the same (or similar) set of entries.
func NewSaltedBloomFilter ¶ added in v1.2.20
func NewSaltedBloomFilter(salt uint32, numExpected int, falsePositiveRate float64) *SaltedBloomFilter
NewSaltedBloomFilter creates a new salted BloomFilter based on the upper-bounds for the number of entries and the "false-positive" rate.
func NewSaltedBloomFilterDirect ¶ added in v1.2.20
func NewSaltedBloomFilterDirect(salt uint32, numBits, numIdx int) *SaltedBloomFilter
NewSaltedBloomFilterDirect creates a new salted BloomFilter based on the number of bits in the filter and the number of indices to be used.
func (*SaltedBloomFilter) Add ¶ added in v1.2.20
func (bf *SaltedBloomFilter) Add(entry []byte)
Add an entry to the BloomFilter.
func (*SaltedBloomFilter) Combine ¶ added in v1.2.20
func (bf *SaltedBloomFilter) Combine(bf2 *SaltedBloomFilter) *SaltedBloomFilter
Combine merges two salted BloomFilters (of same kind) into a new one.
func (*SaltedBloomFilter) Contains ¶ added in v1.2.20
func (bf *SaltedBloomFilter) Contains(entry []byte) bool
Contains returns true if the salted BloomFilter contains the given entry, and false otherwise. If an entry was added to the set, this function will always return 'true'. It can return 'true' for entries not in the set ("false-positives").
func (*SaltedBloomFilter) Size ¶ added in v1.2.20
func (bf *SaltedBloomFilter) Size() uint
Size returns the size of the binary representation
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack for generic data types.
func (*Stack) Peek ¶
func (s *Stack) Peek() (v interface{})
Peek at the last element pushed to stack without dropping it.
type Vector ¶
type Vector struct {
// contains filtered or unexported fields
}
Vector data structure
func (*Vector) Drop ¶
func (vec *Vector) Drop() (v interface{})
Drop the last element from the vector.