index

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNilReader = fmt.Errorf("%w: nil reader", Error)

ErrNilReader indicates error when nil writer specified to BinaryReadFrom.

View Source
var ErrNilWriter = fmt.Errorf("%w: nil writer", Error)

ErrNilWriter indicates error when nil writer specified to BinaryWriteTo.

View Source
var Error = errors.New("index")

Functions

This section is empty.

Types

type Child

type Child struct {
	Parent dag.ID
	ID     dag.ID
}

Child provides Child from parent to child and vise versa.

type ChildList

type ChildList []Child

ChildList stores Items children.

func (ChildList) Get

func (childrenList ChildList) Get(id dag.ID) *Child

func (ChildList) Len

func (childrenList ChildList) Len() int

Len returns length of ChildList. Implements sort.Interface.

func (ChildList) Less

func (childrenList ChildList) Less(i, j int) bool

Less reports whether the element with index i must sort before the element with index j. Implements sort.Interface.

func (ChildList) Sort

func (childrenList ChildList) Sort() chan<- Child

func (ChildList) Swap

func (childrenList ChildList) Swap(i, j int)

Swap swaps elements in i and j positions. Implements sort.Interface.

type CollectionIDList

type CollectionIDList []VariantID

func (CollectionIDList) Has

func (c CollectionIDList) Has(collectionID VariantID) bool

func (CollectionIDList) Len

func (c CollectionIDList) Len() int

func (CollectionIDList) Less

func (c CollectionIDList) Less(i, j int) bool

func (CollectionIDList) Swap

func (c CollectionIDList) Swap(i, j int)

type CollectionTableNumber

type CollectionTableNumber storage.ID16

CollectionTableNumber represents table number in VariantsIndex.

func (CollectionTableNumber) Add

func (collectionTableNumber CollectionTableNumber) Add(addition int) CollectionTableNumber

func (CollectionTableNumber) ID16

func (collectionTableNumber CollectionTableNumber) ID16() storage.ID16

func (CollectionTableNumber) VariantID

func (collectionTableNumber CollectionTableNumber) VariantID(indexInTable VariantSubID) VariantID

VariantID makes an VariantID from CollectionTableNumber using specified VariantSubID value.

type Index

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

Index implements main dictionary index.

func New

func New() *Index

New creates new empty list.

func (*Index) AddRunes

func (index *Index) AddRunes(runes []rune) (dag.Node, error)

AddRunes adds runes sequence into container. Returns final node filled with node data or error if add caused error.

func (*Index) AddString

func (index *Index) AddString(word string) (node dag.Node, err error)

AddString adds string word into index. Returns final node or error if add caused error.

func (*Index) AddToNode

func (index *Index) AddToNode(parentID dag.ID, runes []rune) (dag.Node, error)

func (*Index) BinaryReadFrom

func (index *Index) BinaryReadFrom(reader *binutils.BinaryReader) (err error)

BinaryReadFrom reads index data from specified binutils.BinaryReader. Implements binutils.BinaryReaderFrom.

func (*Index) BinaryWriteTo

func (index *Index) BinaryWriteTo(writer *binutils.BinaryWriter) (err error)

func (*Index) Children

func (index *Index) Children() dag.NodeMap

Children returns rootNode runes mapped to its nodes. Implements dag.Index.

func (*Index) FetchFromItem

func (index *Index) FetchFromItem(parentID dag.ID, runes []rune) (dag.Node, error)

func (*Index) FetchItemFromParent

func (index *Index) FetchItemFromParent(parentID dag.ID, runes []rune) (*Node, error)

func (*Index) FetchRunes

func (index *Index) FetchRunes(runes []rune) (dag.Node, error)

FetchRunes lookups runes sequence in container. If found returns final node or error if not found.

func (*Index) FetchString

func (index *Index) FetchString(word string) (dag.Node, error)

FetchString lookups string in container. If found returns final node or error if not found.

func (*Index) Get

func (index *Index) Get(nodeIdx dag.ID) (node dag.Node, err error)

Get returns node by its index or error if no such node found. Implements dag.Index.

func (*Index) GetChildrenIDMap

func (index *Index) GetChildrenIDMap(id dag.ID) (res dag.IdMap)

GetChildrenIDMap generates children nodes for Node specified by its ID.

func (*Index) GetChildrenMap

func (index *Index) GetChildrenMap(id dag.ID) dag.NodeMap

GetChildrenMap generates children nodes for Node specified by its ID.

func (*Index) GetItem

func (index *Index) GetItem(id dag.ID) *Node

GetItem generates Node instance runtime.

func (*Index) NodesCount

func (index *Index) NodesCount() int

NodesCount returns count of indexed nodes.

func (*Index) Optimize

func (index *Index) Optimize()

Optimize reduces index deleting unused tag set's and collections;

func (*Index) TagID

func (index *Index) TagID(name dag.TagName, parent dag.TagName) dag.TagID

TagID gets or creates tag in internal tag index and returns its ID.

func (*Index) TagSet

func (index *Index) TagSet(tagSet TagSet) (res dag.TagSet, err error)

func (*Index) TagSetIndex

func (index *Index) TagSetIndex() TagSetIndex

TagSetIndex returns internal TagSetIndex.

func (Index) Tags

func (index Index) Tags() dag.Idx

Tags returns internal tags index.

func (*Index) Variants

func (index *Index) Variants(id VariantID) (tagSetCollection TagSetIDCollection, err error)

Variants returns TagSet collection

func (*Index) WordsCount

func (index *Index) WordsCount() int

WordsCount returns count of indexed words.

type Item

type Item struct {
	Parent   dag.ID    // item Parent ID
	ID       dag.ID    // item own ID
	Letter   rune      // item rune
	Variants VariantID // TagSet VariantID
}

Item represents DAG index item.

func (*Item) BinaryReadFrom

func (i *Item) BinaryReadFrom(reader *binutils.BinaryReader) (err error)

BinaryReadFrom reads item data using supplied binutils.BinaryReader. Implements binutils.BinaryReaderFrom.

func (*Item) BinaryWriteTo

func (i *Item) BinaryWriteTo(writer *binutils.BinaryWriter) (err error)

BinaryWriteTo writes item data using binutils.BinaryWriter.

func (Item) String

func (i Item) String() string

String returns string representation of DAG=index item. Implements fmt.Stringer.

type Items

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

Items stores items ordered by their ID.

func NewItems

func NewItems() *Items

func (*Items) BinaryReadFrom

func (items *Items) BinaryReadFrom(reader *binutils.BinaryReader) (err error)

BinaryReadFrom reads ItemIndex data from specified binutils.BinaryReader instance. Implements binutils.BinaryReaderFrom.

func (Items) BinaryWriteTo

func (items Items) BinaryWriteTo(writer *binutils.BinaryWriter) (err error)

BinaryWriteTo writes ItemIndex data using supplied binutils.BinaryWriter. Implements binutils.BinaryWriterTo.

func (*Items) Extend

func (items *Items) Extend(count int)

Extend adds elements

func (*Items) Get

func (items *Items) Get(id dag.ID) *Item

Get gets item by its ID.

func (*Items) NewChild

func (items *Items) NewChild(parentID dag.ID, letter rune) Item

func (Items) NextID

func (items Items) NextID() dag.ID

NextID returns next ID to use when creating new Item.

type Letter

type Letter struct {
	ID     dag.ID
	Letter rune
}

Letter maps letter associated with item ID.

type Node

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

Node represents index node.

func (*Node) AddTagSet

func (node *Node) AddTagSet(newTagSet ...dag.TagName) error

func (*Node) Id

func (node *Node) Id() dag.ID

func (Node) Item

func (node Node) Item() Item

func (*Node) String

func (node *Node) String() string

String returns string representation of node. Implements fmt.Stringer.

func (*Node) TagSets

func (node *Node) TagSets() (res []dag.TagSet)

TagSets returns list of dag.TagSet. Implements dag.Node.

func (*Node) Word

func (node *Node) Word() string

Word returns sequence of characters from root upto current node wrapped into string.

type TagSet

type TagSet []dag.TagID

TagSet stores unique sorted ID8's ids sets. Requires external management to provide item-to-ID8 and vise-versa transitions.

func (*TagSet) BinaryReadFrom

func (tagSet *TagSet) BinaryReadFrom(reader *binutils.BinaryReader) (err error)

BinaryReadFrom reads TagSet data using specified binutils.BinaryReader instance. Returns error if happens or nil. Implements binutils.BinaryReaderFrom.

func (TagSet) BinaryWriteTo

func (tagSet TagSet) BinaryWriteTo(writer *binutils.BinaryWriter) (err error)

BinaryWriteTo writes TagSet data using specified binutils.BinaryWriter instance. Returns error if happens or nil. Implements binutils.BinaryWriterTo.

func (TagSet) EqualTo

func (tagSet TagSet) EqualTo(another TagSet) bool

EqualTo compares TagSet with another one. Returns true if both sets are contains the same ID8 elements or false otherwise. Note: both sets should be sorted before compare.

func (TagSet) Len

func (tagSet TagSet) Len() int

Len returns length of TagSet. Implements sort.Interface.

func (TagSet) Less

func (tagSet TagSet) Less(i, j int) bool

Less reports whether the element with index i must be placed before the element with index j. Implements sort.Interface.

func (*TagSet) ReadFrom

func (tagSet *TagSet) ReadFrom(r io.Reader) (totalBytesTaken int64, err error)

ReadFrom loads TagSet data from provided io.Reader until all data loaded or any error including EOF. Returns taken bytes count and error if occurs. Implements io.ReaderFrom.

func (TagSet) Sort

func (tagSet TagSet) Sort()

Sort is a convenience method: x.Sort() calls sort.Sort(x). Does inplace sorting of TagSet items.

func (TagSet) String

func (tagSet TagSet) String() string

String returns string representation of TagSet. Implements fmt.Stringer.

func (TagSet) Swap

func (tagSet TagSet) Swap(i, j int)

Swap swaps the elements with ids i and j. Implements sort.Interface.

func (TagSet) WriteTo

func (tagSet TagSet) WriteTo(w io.Writer) (n int64, err error)

WriteTo writes TagSet data into supplied io.Writer instance. Returns written bytes count and error if occurs. Implements io.WriterTo.

type TagSetID

type TagSetID storage.ID32

TagSetID provides unique 0-based TagSet ID in TagSetIndex.

func (TagSetID) TagSetSubID

func (tagSetID TagSetID) TagSetSubID() TagSetSubID

TagSetSubID returns lower uint16 part of TagSetID as TagSetSubID.

func (TagSetID) TagSetTableNumber

func (tagSetID TagSetID) TagSetTableNumber() TagSetTableNumber

TagSetTableNumber returns upper uint16 part of TagSetID as TagSetTableNumber.

type TagSetIDCollection

type TagSetIDCollection []TagSetID

TagSetIDCollection stores a list of TagSetID identifiers of TagSet stored in TagSetIndex.

func (TagSetIDCollection) Add

func (t TagSetIDCollection) Add(additionalTagSetID TagSetID) TagSetIDCollection

Add makes a new TagSetIDCollection having all TagSetID's from original plus specified additional TagSetID. Result is sorted and ready to place into VariantsIndex. If original TagSetIDCollection already contains specified element, resulting TagSetIDCollection will be the same as original one.

func (*TagSetIDCollection) BinaryReadFrom

func (t *TagSetIDCollection) BinaryReadFrom(reader *binutils.BinaryReader) (err error)

BinaryReadFrom reads TagSetIndex data using specified binutils.BinaryReader instance. Returns error if happens or nil. Implements binutils.BinaryReaderFrom.

func (TagSetIDCollection) BinaryWriteTo

func (t TagSetIDCollection) BinaryWriteTo(writer *binutils.BinaryWriter) (err error)

BinaryWriteTo writes TagSetIndex data using specified binutils.BinaryWriter instance. Returns error if happens or nil. Implements binutils.BinaryWriterTo.

func (TagSetIDCollection) EqualTo

func (t TagSetIDCollection) EqualTo(another TagSetIDCollection) bool

EqualTo compares TagSetIDCollection with another one. Returns true if both sets are contains the same ID8 elements or false otherwise. Note: both sets should be sorted before compare.

func (TagSetIDCollection) GoString

func (t TagSetIDCollection) GoString() string

func (TagSetIDCollection) Has

func (t TagSetIDCollection) Has(searchTagSetID TagSetID) bool

Has returns true if TagSetIDCollection contains specified TagSetID.

func (TagSetIDCollection) Len

func (t TagSetIDCollection) Len() int

Len returns length of TagSetIDCollection. Implements sort.Interface.

func (TagSetIDCollection) Less

func (t TagSetIDCollection) Less(i, j int) bool

Less returns true i-th element of TagSetIDCollection is fewer than j-th. Implements sort.Interface.

func (TagSetIDCollection) Swap

func (t TagSetIDCollection) Swap(i, j int)

Swap swaps i-th and j-th elements of array in place. Implements sort.Interface.

type TagSetIndex

type TagSetIndex []TagSetTable

TagSetIndex stores unique TagSet items organized in TagSetTable storages where each storage keeps sets of same sizes. Each TagSetIndex item is addressable by unique TagSetID value which consists of TagSetTableNumber internal table index and TagSetSubID element index in TagSetTable item.

func (*TagSetIndex) BinaryReadFrom

func (tagSetIndex *TagSetIndex) BinaryReadFrom(reader *binutils.BinaryReader) (err error)

BinaryReadFrom reads TagSetIndex data using specified binutils.BinaryReader instance. Returns error if happens or nil. Implements binutils.BinaryReaderFrom.

func (TagSetIndex) BinaryWriteTo

func (tagSetIndex TagSetIndex) BinaryWriteTo(writer *binutils.BinaryWriter) (err error)

BinaryWriteTo writes TagSetIndex data using specified binutils.BinaryWriter instance. Returns error if happens or nil. Implements binutils.BinaryWriterTo.

func (*TagSetIndex) Find

func (tagSetIndex *TagSetIndex) Find(item TagSet) (storageIdx TagSetID, found bool)

Find returns ID of specified TAgSet in index. If no such set found returns TagSetID=0 and false found indicator.

func (TagSetIndex) Get

func (tagSetIndex TagSetIndex) Get(storageIdx TagSetID) (TagSet, bool)

Get returns TagSet by its TagSetID value. If not found returns empty TagSet and false found indicator.

func (*TagSetIndex) Index

func (tagSetIndex *TagSetIndex) Index(item TagSet) (storageIdx TagSetID)

Index returns specified TagSet ID in index. If no such TagSet registered before, it will be indexed first. To check if TagSet present in index without registering use Find instead.

func (TagSetIndex) Size

func (tagSetIndex TagSetIndex) Size() (res int)

Size returns indexed elements count in TagSetIndex.

func (TagSetIndex) TableIDs

func (tagSetIndex TagSetIndex) TableIDs() (res []TagSetID)

TableIDs returns all known TagSet's identification list.

type TagSetSubID

type TagSetSubID storage.ID16

TagSetSubID represents 0-based ID of TagSet item in TagSetTable. It's a simple wrapper over storage.ID16 type.

func (TagSetSubID) ID16

func (tagSetID TagSetSubID) ID16() storage.ID16

ID16 returns TagSetSubID instance value as storage.ID16 value.

func (TagSetSubID) Int

func (tagSetID TagSetSubID) Int() int

Int returns TagSetSubID as integer value.

type TagSetTable

type TagSetTable []TagSet

TagSetTable stores unique TagSet lists having equal length. It Uses its own ID16 index to address target sets.set16 stack in addition to address element in stack. Used in TagSetIndex to store different sized sets organized into stacks of equal-sized sets.

func (*TagSetTable) BinaryReadFrom

func (tagSetTable *TagSetTable) BinaryReadFrom(reader *binutils.BinaryReader) (err error)

BinaryReadFrom reads TagSetTable data using specified binutils.BinaryReader instance. Returns error if happens or nil. Implements binutils.BinaryReaderFrom.

func (TagSetTable) BinaryWriteTo

func (tagSetTable TagSetTable) BinaryWriteTo(writer *binutils.BinaryWriter) (err error)

BinaryWriteTo writes TagSetTable data using specified binutils.BinaryWriter instance. Returns error if happens or nil. Implements binutils.BinaryWriterTo.

func (TagSetTable) Find

func (tagSetTable TagSetTable) Find(item TagSet) (storageIdx TagSetSubID, found bool)

Find returns 0-based index of ids.Set16 in Table16 storage. If no such set found returns 0 and false found indicator. It required sets.Set16 argument to be sorted before.

func (TagSetTable) Get

func (tagSetTable TagSetTable) Get(storageIdx TagSetSubID) (tagSet TagSet, found bool)

Get returns ids.Set16 by index if present or found indicator will be false.

func (*TagSetTable) Index

func (tagSetTable *TagSetTable) Index(item TagSet) (storageIdx TagSetSubID)

Index returns 0-based TagSetSubID index of ids.Set16 in Table16 instance. Returns index of existed item if found or of appended item. Panics if specified set empty.

func (TagSetTable) Len

func (tagSetTable TagSetTable) Len() int

Len returns length of TagSetTable in TagSet items.

func (TagSetTable) String

func (tagSetTable TagSetTable) String() string

String returns string representation of TagSetTable. Implements fmt.Stringer.

type TagSetTableNumber

type TagSetTableNumber storage.ID16

TagSetTableNumber provides 0-based TagSetTable number in TagSetIndex. It's a simple wrapper over storage.ID16 type.

func (TagSetTableNumber) Add

func (tagSetTableNumber TagSetTableNumber) Add(increment int) TagSetTableNumber

Add makes new TagSetTableNumber instance having value of original TagSetTableNumber incremented by specified value.

func (TagSetTableNumber) ID16

func (tagSetTableNumber TagSetTableNumber) ID16() storage.ID16

ID16 returns TagSetTableNumber instance value as storage.ID16 value.

func (TagSetTableNumber) Int

func (tagSetTableNumber TagSetTableNumber) Int() int

Int returns TagSetTableNumber instance value as int.

func (TagSetTableNumber) TagSetID

func (tagSetTableNumber TagSetTableNumber) TagSetID(id TagSetSubID) TagSetID

TagSetID generates TagSetID value TagSetTableNumber value as upper uint16 part and specified subID as lower.

type VariantID

type VariantID storage.ID32

VariantID represents TagSet collection ID in VariantsIndex.

func (VariantID) CollectionTableID

func (variantID VariantID) CollectionTableID() (res VariantSubID)

func (VariantID) TableNum

func (variantID VariantID) TableNum() (res CollectionTableNumber)

type VariantSubID

type VariantSubID storage.ID16

VariantSubID wraps storage.ID16 to represent TagSetIDCollection ID in VariantsTable.

func (VariantSubID) Add

func (variantSubID VariantSubID) Add(value int) VariantSubID

func (VariantSubID) ID16

func (variantSubID VariantSubID) ID16() storage.ID16

ID16 returns storage.ID16 of VariantSubID value. It's a simple wrapper over storage.ID16(VariantSubID).

type VariantsIndex

type VariantsIndex []VariantsTable

VariantsIndex stores index of all possible TagSetIDCollection.

func (*VariantsIndex) BinaryReadFrom

func (tagSetIndex *VariantsIndex) BinaryReadFrom(reader *binutils.BinaryReader) (err error)

BinaryReadFrom reads CollectionTable data using specified binutils.BinaryReader instance. Returns error if happens or nil. Implements binutils.BinaryReaderFrom.

func (VariantsIndex) BinaryWriteTo

func (tagSetIndex VariantsIndex) BinaryWriteTo(writer *binutils.BinaryWriter) (err error)

BinaryWriteTo writes CollectionTable data using specified binutils.BinaryWriter instance. Returns error if happens or nil. Implements binutils.BinaryWriterTo.

func (VariantsIndex) Find

func (tagSetIndex VariantsIndex) Find(item TagSetIDCollection) (storageIdx VariantID, found bool)

Find returns 0-based index of ids.Set16 item in TagSetIndex array. If no such set found returns 0 and false found flag.

func (VariantsIndex) Get

func (tagSetIndex VariantsIndex) Get(storageIdx VariantID) TagSetIDCollection

Get returns set by index.

func (*VariantsIndex) Index

func (tagSetIndex *VariantsIndex) Index(item TagSetIDCollection) (storageIdx VariantID)

Index returns 0-based index of set in Collection8x8 array.

func (VariantsIndex) KnownID

func (tagSetIndex VariantsIndex) KnownID() (res []VariantID)

func (VariantsIndex) Table

func (tagSetIndex VariantsIndex) Table(tableID CollectionTableNumber) VariantsTable

Table returns internal CollectionTable by its index.

func (VariantsIndex) Tables

func (tagSetIndex VariantsIndex) Tables() []VariantsTable

Tables returns internal variants tables.

type VariantsTable

type VariantsTable []TagSetIDCollection

VariantsTable stores a list of TagSetID.

func (*VariantsTable) BinaryReadFrom

func (variantsTable *VariantsTable) BinaryReadFrom(reader *binutils.BinaryReader) (err error)

BinaryReadFrom reads VariantsTable data using specified binutils.BinaryReader instance. Returns error if happens or nil. Implements binutils.BinaryReaderFrom.

func (VariantsTable) BinaryWriteTo

func (variantsTable VariantsTable) BinaryWriteTo(writer *binutils.BinaryWriter) (err error)

BinaryWriteTo writes VariantsTable data using specified binutils.BinaryWriter instance. Returns error if happens or nil. Implements binutils.BinaryWriterTo.

func (VariantsTable) Find

func (variantsTable VariantsTable) Find(item TagSetIDCollection) (storageIdx VariantSubID, found bool)

Find returns specified TagSetIDCollection instance ID in index. If no such variants set found returns VariantSubID=0 and false found indicator.

func (VariantsTable) Following

func (variantsTable VariantsTable) Following(storageIdx VariantSubID) (res []VariantSubID)

Following returns a list of VariantSubID having their VariantSubID above of specified.

func (VariantsTable) Get

func (variantsTable VariantsTable) Get(storageIdx VariantSubID) TagSetIDCollection

Get returns TagSetIDCollection by its VariantSubID.

func (*VariantsTable) Index

func (variantsTable *VariantsTable) Index(item TagSetIDCollection) (storageIdx VariantSubID)

Index returns specified TagSetIDCollection instance ID in index. If no such variants set found it will be registered before. Always return VariantSubID=0 if empty or nil TagSetIDCollection specified.

Jump to

Keyboard shortcuts

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