cores

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: MIT Imports: 4 Imported by: 0

README

Cell Cores for Cardinality Cube

Implement Core interface and CoreInitiator functions to create custom cores. You can see examples like basic set (basicset.go) or hyperloglog (hll.go). And don't forget to add tests.

Documentation

Overview

Custom Core implementation for Cardinality Cube

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicSetCore

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

BasicSetCore is a very basic core that counts exact distinct items. There is no approximation in this approach but memory usage is inefficient.

func (BasicSetCore) Count

func (b BasicSetCore) Count() uint64

Count returns item count in the set

func (BasicSetCore) Push

func (b BasicSetCore) Push(item []byte)

Push pushes item into set

func (BasicSetCore) Serialize added in v0.3.0

func (b BasicSetCore) Serialize() ([]byte, error)

type Core

type Core interface {
	// Push adds item to store to count. Thread safe supplied by caller.
	Push(item []byte)
	// Count returns unique item count in the store. Not thread safe.
	Count() uint64
	// Serialize core into bytes
	Serialize() ([]byte, error)
}

Core is an abstraction of basic functionality of a Cube cell. Different implementations of a core result in different cubes.

func BasicSet

func BasicSet(opts interface{}, serializedBytes []byte) (Core, error)

BasicSet is a CoreInitiator

func HLL

func HLL(opts interface{}, serializedBytes []byte) (Core, error)

HLL is a CoreInitiator implementation

type CoreInitiator

type CoreInitiator func(opts interface{}, serializedBytes []byte) (Core, error)

CoreInitiator defines a function that initializes the cell core. The function will be called lazily whenever new cell is needed or at the deserialization phase. Use nil value for each argument to create new core with default options. If serializedBytes is not nil deserialization will be initiated.

type HLLCore

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

HLLCore is a Core implementation that uses HyperLogLog. It is highly memory efficient with trade off against approximation.

func (HLLCore) Count

func (c HLLCore) Count() uint64

Count returns unique item count in the store.

func (HLLCore) Push

func (c HLLCore) Push(item []byte)

Push adds item to store to count.

func (HLLCore) Serialize added in v0.3.0

func (c HLLCore) Serialize() ([]byte, error)

Serialize returns serialized bytes of current core state

type HLLOpts

type HLLOpts struct {
	With16Registers bool // True for 16 Registers, False for 14 Registers
}

HLLOpts is options for HyperLogLog core

Jump to

Keyboard shortcuts

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