cube

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: 3 Imported by: 0

README

Cardinality Cube

Using as a data structure example

import (
	"github.com/bahadrix/cardinalitycube/cores"
	"github.com/bahadrix/cardinalitycube/cube"
)

func main() {

	hllCube := cube.CreateCube(cores.HLL, &cores.HLLOpts{
		With16Registers:false,
	})

	board := hllCube.GetBoard("sampleBoard", true)
	cell := board.GetCell("login_page", "hit", true)
	cell.Push([]byte("user_1"))

	println(cell.Count())
}

Documentation

Overview

Cardinality Data Structure for GO

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Board

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

Board is a table like data structure which consists of rows. It is of course thread safe.

func NewBoard

func NewBoard(cube *Cube) *Board

NewBoard creates a new board for given cube

func (*Board) CheckRowExists

func (b *Board) CheckRowExists(rowName string) bool

CheckRowExists return true if row exists in board.

func (*Board) DropRow

func (b *Board) DropRow(rowName string)

DropRow drops given row from board if it exists

func (*Board) Dump added in v0.3.0

func (b *Board) Dump() (*pb.BoardData, error)

func (*Board) GetCell

func (b *Board) GetCell(rowName string, cellName string, createIfNotExists bool) *Cell

GetCell returns cell that resides in given row. If row or cell not found function returns nil

func (*Board) GetCellCount added in v0.2.0

func (b *Board) GetCellCount(rowName string) int

GetCellCount returns cell count of row. Read blocking operation.

func (*Board) GetCellKeys added in v0.2.0

func (b *Board) GetCellKeys(rowName string) (keys []string)

GetCellKeys returns cell keys of row. Read blocking operation.

func (*Board) GetRowCount added in v0.2.0

func (b *Board) GetRowCount() int

GetRowCount returns roe count.

func (*Board) GetRowKeys added in v0.2.0

func (b *Board) GetRowKeys() []string

GetRowKeys returns row names. Read blocking operation.

func (*Board) GetRowSnapshot

func (b *Board) GetRowSnapshot(rowName string) *RowSnapshot

GetRowSnapshot Returns snapshot of given row. Blocks row while getting its snapshot

func (*Board) GetSnapshot

func (b *Board) GetSnapshot() *BoardSnapshot

GetSnapshot return board's snapshot. Blocks whole board while getting snapshot.

func (*Board) LoadData added in v0.3.0

func (b *Board) LoadData(data *pb.BoardData) error

type BoardSnapshot

type BoardSnapshot map[string]*RowSnapshot

A BoardSnapshot contains rows data of specific time

type Cell

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

Cell is constituent part of Cube. It holds values.

func (*Cell) Count

func (c *Cell) Count() uint64

Count does the accumulation at core and returns the result

func (*Cell) Dump added in v0.3.0

func (c *Cell) Dump() (*pb.CellData, error)

Dump returns protobuf object

func (*Cell) Push

func (c *Cell) Push(item []byte)

Push pushes item into core.

func (*Cell) Serialize added in v0.3.0

func (c *Cell) Serialize() ([]byte, error)

Serialized returns serialized core bytes

type Cube

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

Cube is a data structure consists of cells that allows thread safe parallel operations over them. A cube organizes it cells by holding them in maps called rows. Rows are also combined into a another map called board.

func NewCube

func NewCube(coreGenerator cores.CoreInitiator, coreOpts interface{}) *Cube

NewCube creates new cube in the type of give CoreInitiator

func (*Cube) DropBoard

func (c *Cube) DropBoard(boardName string)

DropBoard deletes board at given name.

func (*Cube) Dump added in v0.3.0

func (c *Cube) Dump() (*pb.CubeData, error)

func (*Cube) GetBoard

func (c *Cube) GetBoard(name string, createIfNotExists bool) *Board

GetBoard returns board at given key name. Returns nil if it not found or returns newly created one if createIfNotExists is set to true.

func (*Cube) GetBoardCount added in v0.2.0

func (c *Cube) GetBoardCount() int

GetBoardCount returns current board count in cube.

func (*Cube) GetBoardKeys added in v0.2.0

func (c *Cube) GetBoardKeys() []string

GetBoardKeys returns board names. Read blocking operation

func (*Cube) GetSnapshot

func (c *Cube) GetSnapshot() *Snapshot

GetSnapshot Returns snapshot of whole cube. Blocking operation.

func (*Cube) LoadData added in v0.3.0

func (c *Cube) LoadData(data *pb.CubeData) error

type Row

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

Row is a build block of board. It holds Cells.

func NewRow

func NewRow() *Row

NewRow creates empty row and returns it.

func (*Row) Dump added in v0.3.0

func (r *Row) Dump() (*pb.RowData, error)

func (*Row) GetCell

func (r *Row) GetCell(cellName string) *Cell

GetCell returns cell at given name. Returns nil if it not found.

func (*Row) GetCellCount added in v0.2.0

func (r *Row) GetCellCount() int

GetCellCount returns cell count of row.

func (*Row) GetCellKeys added in v0.2.0

func (r *Row) GetCellKeys() []string

GetCellKeys returns keys of cells. Read blocking operation.

func (*Row) GetSnapshot

func (r *Row) GetSnapshot() *RowSnapshot

GetSnapshot returns snapshot of row. Blocks row while getting snapshot.

func (*Row) SetCell

func (r *Row) SetCell(cellName string, cell *Cell)

SetCell sets the given cell to given name

type RowSnapshot

type RowSnapshot map[string]uint64

RowSnapshot contains cell names and their accumulated values.

type Snapshot

type Snapshot map[string]*BoardSnapshot

A Snapshot of cube is a map of board snapshots

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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