tiedb

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: BSD-3-Clause Imports: 16 Imported by: 6

README

tiedb

Golang package to associate and relate bytes/strings using a trie and red-black-trees.

Documentation

Index

Constants

View Source
const (
	ENTRY_SIZE = SIZE_DATATYPE +
		SIZE_LEVEL +
		SIZE_ID +
		SIZE_PARENTID +
		SIZE_VALUE

	SIZE_DATATYPE = 2
	SIZE_LEVEL    = 8
	SIZE_ID       = 8
	SIZE_PARENTID = SIZE_ID
	SIZE_VALUE    = 24 // 6 * 8 - 3 * 8

	MaxFreespace = 1000000

	FILE_ADD    = 0
	FILE_DELETE = 1

	// These values get written to the db files
	TYPE_DELETE      = 10
	TYPE_ENTRY       = 11
	TYPE_ASSOCIATION = 12
)

Variables

This section is empty.

Functions

func AssociationComparator

func AssociationComparator(o1, o2 interface{}) int

func Debug

func Debug(value string)

func Info

func Info(value string)

func KeyComparator

func KeyComparator(o1, o2 interface{}) int

func PointerValueComparator

func PointerValueComparator(o1, o2 interface{}) int

func StringComparator

func StringComparator(o1, o2 interface{}) int

func UInt64Comparator

func UInt64Comparator(o1, o2 interface{}) int

func UniqueAssociationComparator

func UniqueAssociationComparator(o1, o2 interface{}) int

func UniqueValueComparator

func UniqueValueComparator(o1, o2 interface{}) int

func ValueComparator

func ValueComparator(o1, o2 interface{}) int

Types

type Collection

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

func (*Collection) Add

func (ic *Collection) Add(key string, value1 string, value2 string)

func (*Collection) Delete

func (ic *Collection) Delete(key string, value1 string, value2 string) (string, bool)

func (*Collection) Get

func (ic *Collection) Get(key string, value1 string) (TripleSet, bool)

func (*Collection) GetAssociations

func (ic *Collection) GetAssociations(value string) (*TieTree, bool)

func (*Collection) GetReverseAssociations added in v0.3.2

func (ic *Collection) GetReverseAssociations(value string) (*TieTree, bool)

func (*Collection) GetTotalEntries

func (ic *Collection) GetTotalEntries() uint64

func (*Collection) GetTripleSet added in v0.1.8

func (ic *Collection) GetTripleSet(s *TieTree, value1Filter string, o SortOptions) (result TripleSet, totalCount int)

func (*Collection) GetValue2Trees added in v0.3.2

func (ic *Collection) GetValue2Trees(s *TieTree, value1Filter string) (value2Trees map[string]*TieTree)

func (*Collection) SimpleUpdate

func (ic *Collection) SimpleUpdate(key string, value1 string, newValue2 string, addOnFail bool) (string, bool)

Update first occurence of a value2. More expensive SimpleUpdateUsingSet - use that if udating many values

func (*Collection) Sort added in v0.3.2

func (ic *Collection) Sort(tree *TieTree, value1Filter string, o SortOptions) (sorted []StringTriple, totalCount int)

func (*Collection) SortByNextLevelOne added in v0.3.2

func (ic *Collection) SortByNextLevelOne(tree *TieTree, value1Filter string, o SortOptions) (sorted []StringTriple)

func (*Collection) Sync added in v0.3.0

func (ic *Collection) Sync()

func (*Collection) Update

func (ic *Collection) Update(key string, value1 string, value2 string, newValue2 string) (string, bool)

func (*Collection) UpdateAdd

func (ic *Collection) UpdateAdd(key string, value1 string, value2 string, newValue2 string) (string, bool)

Try to update value2 to newvalue2. Add if unsuccessful. TODO: Add error checking

func (*Collection) WriteRandomDB

func (t *Collection) WriteRandomDB(filename string)

Used for testing worst-case scenario

type CollectionKey

type CollectionKey struct {
	Database   string
	Collection string
}

type Entry

type Entry struct {
	Id          uint64
	UniqueValue *UniqueValue
}

type FileIndexer

type FileIndexer interface {
	// contains filtered or unexported methods
}

type FileMod

type FileMod struct {
	Mode        int
	Level       int
	EntryType   int
	Position    int64
	Association *Triple
	Entry       *Entry
}

type RawDataEntry added in v0.3.0

type RawDataEntry struct {
	Position int64
	Data     []byte
}

type ReadRequest added in v0.3.0

type ReadRequest struct {
	Position  int64
	ReplyChan chan Triple
}

type Set

type Set map[string]map[string]map[string]bool

type SortOptions added in v0.3.2

type SortOptions struct {
	Offset int
	Limit  int
	SortBy string // Value1 to sort by
}

type StringTriple added in v0.3.2

type StringTriple struct {
	Key    string
	Value1 string
	Value2 string
}

type TieTree

type TieTree struct {
	*rbt.Tree
	// contains filtered or unexported fields
}

func NewDB

func NewDB(writeToDisk bool) *TieTree

func NewTreeWith

func NewTreeWith(comparator utils.Comparator) *TieTree

func (*TieTree) Combine added in v0.3.2

func (t *TieTree) Combine(tree *TieTree) (out *TieTree)

func (*TieTree) Delete

func (tree *TieTree) Delete(key interface{})

func (*TieTree) Exclude added in v0.3.2

func (t *TieTree) Exclude(tree *TieTree) (out *TieTree)

func (*TieTree) Get

func (tree *TieTree) Get(key interface{}) (value interface{}, found bool)

func (*TieTree) GetCollection

func (db *TieTree) GetCollection(key CollectionKey) *Collection

func (*TieTree) Intersect added in v0.3.2

func (t *TieTree) Intersect(tree *TieTree) (out *TieTree)

func (*TieTree) Put

func (tree *TieTree) Put(key interface{}, value interface{})

type Triple added in v0.3.0

type Triple struct {
	Level       int
	Key         uint64
	Value1Level int
	Value1      uint64
	Value2Level int
	Value2      uint64
}

type TripleSet

type TripleSet map[string]Value1

func (TripleSet) ForEachKey

func (s TripleSet) ForEachKey(do func(key string))

func (TripleSet) ForEachValue1

func (s TripleSet) ForEachValue1(do func(key, value1 string))

func (TripleSet) ForEachValue2

func (s TripleSet) ForEachValue2(do func(key, value1, value2 string))

func (TripleSet) Has

func (s TripleSet) Has(key string) bool

type UniqueAssociation

type UniqueAssociation struct {
	AssociateTo uint64
	Relation    uint64
}

type UniqueValue

type UniqueValue struct {
	ParentId uint64
	Value    [SIZE_VALUE]byte
}

type Unit

type Unit struct{}

type Value1

type Value1 map[string]Value2

func (Value1) ForEach

func (s Value1) ForEach(do func(value1 string))

func (Value1) ForEachValue2

func (s Value1) ForEachValue2(do func(value1, value2 string))

func (Value1) Has

func (s Value1) Has(value1 string) bool

type Value2

type Value2 map[string]Unit

func (Value2) ForEach

func (s Value2) ForEach(do func(value2 string))

func (Value2) Has

func (s Value2) Has(value2 string) bool

func (Value2) One

func (s Value2) One() (string, bool)

There must exist exactly 1 value2 for the provided value1! Otherwise it will return (empty string, false)")

Jump to

Keyboard shortcuts

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