models

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package models implements storage and retrieval of topic maps in a local key-value store using package kv.

Index

Constants

View Source
const (
	TopicMapInfoPrefix     kv.Component = 0x0001
	LiteralPrefix          kv.Component = 0x0002
	IIsPrefix              kv.Component = 0x0003
	SIsPrefix              kv.Component = 0x0004
	SLsPrefix              kv.Component = 0x0005
	TopicNamesPrefix       kv.Component = 0x0006
	TopicOccurrencesPrefix kv.Component = 0x0007
	NamePrefix             kv.Component = 0x0008
	OccurrencePrefix       kv.Component = 0x0009
	ValuePrefix            kv.Component = 0x000A
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IIs

type IIs []string

func (*IIs) Decode

func (iis *IIs) Decode(bs []byte) error

func (IIs) Encode

func (iis IIs) Encode() []byte

func (IIs) IndexLiteral

func (iis IIs) IndexLiteral() []kv.String

type Name

type Name struct{ pb.Name }

Name wraps pb.Name to implement kv.Encoder and kv.Decoder interfaces.

func (*Name) Decode

func (n *Name) Decode(src []byte) error

func (*Name) Encode

func (n *Name) Encode() []byte

func (*Name) IndexValue

func (n *Name) IndexValue() []kv.String

type Occurrence

type Occurrence struct{ pb.Occurrence }

Occurrence wraps pb.Names to implement kv.Encoder and kv.Decoder interfaces.

func (*Occurrence) Decode

func (o *Occurrence) Decode(src []byte) error

func (*Occurrence) Encode

func (o *Occurrence) Encode() []byte

func (*Occurrence) IndexValue

func (o *Occurrence) IndexValue() []kv.String

type SIs

type SIs []string

func (*SIs) Decode

func (sis *SIs) Decode(bs []byte) error

func (SIs) Encode

func (sis SIs) Encode() []byte

func (SIs) IndexLiteral

func (sis SIs) IndexLiteral() []kv.String

type SLs

type SLs []string

func (*SLs) Decode

func (sls *SLs) Decode(bs []byte) error

func (SLs) Encode

func (sls SLs) Encode() []byte

func (SLs) IndexLiteral

func (sls SLs) IndexLiteral() []kv.String

type TopicMapInfo

type TopicMapInfo struct{ pb.TopicMapInfo }

TopicMapInfo wraps pb.TopicMapInfo to implement kv.Encoder and kv.Decoder interfaces.

func (*TopicMapInfo) Decode

func (tmi *TopicMapInfo) Decode(src []byte) error

func (*TopicMapInfo) Encode

func (tmi *TopicMapInfo) Encode() []byte

type TopicNames

type TopicNames kv.EntitySlice

TopicNames holds a slice of all of a topic's names.

TopicNames is not sorted: names are ordered according to user preferences, and this is how that ordering is represented in kvmodels.

func (*TopicNames) Decode

func (tns *TopicNames) Decode(bs []byte) error

func (TopicNames) Encode

func (tns TopicNames) Encode() []byte

type TopicOccurrences

type TopicOccurrences kv.EntitySlice

TopicOccurrences holds a slice of all of a topic's occurrences.

TopicOccurrences is not sorted: occurrences are ordered according to user preferences, and this is how that ordering is represented in kvmodels.

func (*TopicOccurrences) Decode

func (tos *TopicOccurrences) Decode(bs []byte) error

func (TopicOccurrences) Encode

func (tos TopicOccurrences) Encode() []byte

type Txn

type Txn struct{ kv.Partitioned }

Txn provides entities, components, and indexes backed by a key-value store.

func New

func New(t kv.Txn) Txn

func (Txn) AllIIsEntities

func (s Txn) AllIIsEntities(start *kv.Entity, n int) (es []kv.Entity, err error)

AllIIsEntities returns the first n entities that have a IIs, beginning with the first entity greater than or equal to *start.

A nil start value will be interpreted as a pointer to zero.

A value of n less than or equal to zero will be interpretted as the largest possible value.

func (Txn) AllNameEntities

func (s Txn) AllNameEntities(start *kv.Entity, n int) (es []kv.Entity, err error)

AllNameEntities returns the first n entities that have a Name, beginning with the first entity greater than or equal to *start.

A nil start value will be interpreted as a pointer to zero.

A value of n less than or equal to zero will be interpretted as the largest possible value.

func (Txn) AllOccurrenceEntities

func (s Txn) AllOccurrenceEntities(start *kv.Entity, n int) (es []kv.Entity, err error)

AllOccurrenceEntities returns the first n entities that have a Occurrence, beginning with the first entity greater than or equal to *start.

A nil start value will be interpreted as a pointer to zero.

A value of n less than or equal to zero will be interpretted as the largest possible value.

func (Txn) AllSIsEntities

func (s Txn) AllSIsEntities(start *kv.Entity, n int) (es []kv.Entity, err error)

AllSIsEntities returns the first n entities that have a SIs, beginning with the first entity greater than or equal to *start.

A nil start value will be interpreted as a pointer to zero.

A value of n less than or equal to zero will be interpretted as the largest possible value.

func (Txn) AllSLsEntities

func (s Txn) AllSLsEntities(start *kv.Entity, n int) (es []kv.Entity, err error)

AllSLsEntities returns the first n entities that have a SLs, beginning with the first entity greater than or equal to *start.

A nil start value will be interpreted as a pointer to zero.

A value of n less than or equal to zero will be interpretted as the largest possible value.

func (Txn) AllTopicMapInfoEntities

func (s Txn) AllTopicMapInfoEntities(start *kv.Entity, n int) (es []kv.Entity, err error)

AllTopicMapInfoEntities returns the first n entities that have a TopicMapInfo, beginning with the first entity greater than or equal to *start.

A nil start value will be interpreted as a pointer to zero.

A value of n less than or equal to zero will be interpretted as the largest possible value.

func (Txn) AllTopicNamesEntities

func (s Txn) AllTopicNamesEntities(start *kv.Entity, n int) (es []kv.Entity, err error)

AllTopicNamesEntities returns the first n entities that have a TopicNames, beginning with the first entity greater than or equal to *start.

A nil start value will be interpreted as a pointer to zero.

A value of n less than or equal to zero will be interpretted as the largest possible value.

func (Txn) AllTopicOccurrencesEntities

func (s Txn) AllTopicOccurrencesEntities(start *kv.Entity, n int) (es []kv.Entity, err error)

AllTopicOccurrencesEntities returns the first n entities that have a TopicOccurrences, beginning with the first entity greater than or equal to *start.

A nil start value will be interpreted as a pointer to zero.

A value of n less than or equal to zero will be interpretted as the largest possible value.

func (Txn) DeleteIIs

func (s Txn) DeleteIIs(e kv.Entity) error

DeleteIIs deletes the IIs associated with e.

Corresponding indexes are updated.

func (Txn) DeleteName

func (s Txn) DeleteName(e kv.Entity) error

DeleteName deletes the Name associated with e.

Corresponding indexes are updated.

func (Txn) DeleteOccurrence

func (s Txn) DeleteOccurrence(e kv.Entity) error

DeleteOccurrence deletes the Occurrence associated with e.

Corresponding indexes are updated.

func (Txn) DeleteSIs

func (s Txn) DeleteSIs(e kv.Entity) error

DeleteSIs deletes the SIs associated with e.

Corresponding indexes are updated.

func (Txn) DeleteSLs

func (s Txn) DeleteSLs(e kv.Entity) error

DeleteSLs deletes the SLs associated with e.

Corresponding indexes are updated.

func (Txn) DeleteTopicMapInfo

func (s Txn) DeleteTopicMapInfo(e kv.Entity) error

DeleteTopicMapInfo deletes the TopicMapInfo associated with e.

Corresponding indexes are updated.

func (Txn) DeleteTopicNames

func (s Txn) DeleteTopicNames(e kv.Entity) error

DeleteTopicNames deletes the TopicNames associated with e.

Corresponding indexes are updated.

func (Txn) DeleteTopicOccurrences

func (s Txn) DeleteTopicOccurrences(e kv.Entity) error

DeleteTopicOccurrences deletes the TopicOccurrences associated with e.

Corresponding indexes are updated.

func (Txn) EntitiesByIIsLiteral

func (s Txn) EntitiesByIIsLiteral(cursor *kv.IndexCursor, n int) (es []kv.Entity, err error)

EntitiesByIIsLiteral returns entities with IIs values ordered by the kv.String values from their IndexLiteral method.

Reading begins at cursor, and ends when the length of the returned Entity slice is less than n. When reading is not complete, cursor is updated such that using it in a subequent call to ByLiteral would return next n entities.

func (Txn) EntitiesByNameValue

func (s Txn) EntitiesByNameValue(cursor *kv.IndexCursor, n int) (es []kv.Entity, err error)

EntitiesByNameValue returns entities with Name values ordered by the kv.String values from their IndexValue method.

Reading begins at cursor, and ends when the length of the returned Entity slice is less than n. When reading is not complete, cursor is updated such that using it in a subequent call to ByValue would return next n entities.

func (Txn) EntitiesByOccurrenceValue

func (s Txn) EntitiesByOccurrenceValue(cursor *kv.IndexCursor, n int) (es []kv.Entity, err error)

EntitiesByOccurrenceValue returns entities with Occurrence values ordered by the kv.String values from their IndexValue method.

Reading begins at cursor, and ends when the length of the returned Entity slice is less than n. When reading is not complete, cursor is updated such that using it in a subequent call to ByValue would return next n entities.

func (Txn) EntitiesBySIsLiteral

func (s Txn) EntitiesBySIsLiteral(cursor *kv.IndexCursor, n int) (es []kv.Entity, err error)

EntitiesBySIsLiteral returns entities with SIs values ordered by the kv.String values from their IndexLiteral method.

Reading begins at cursor, and ends when the length of the returned Entity slice is less than n. When reading is not complete, cursor is updated such that using it in a subequent call to ByLiteral would return next n entities.

func (Txn) EntitiesBySLsLiteral

func (s Txn) EntitiesBySLsLiteral(cursor *kv.IndexCursor, n int) (es []kv.Entity, err error)

EntitiesBySLsLiteral returns entities with SLs values ordered by the kv.String values from their IndexLiteral method.

Reading begins at cursor, and ends when the length of the returned Entity slice is less than n. When reading is not complete, cursor is updated such that using it in a subequent call to ByLiteral would return next n entities.

func (Txn) EntitiesMatchingIIsLiteral

func (s Txn) EntitiesMatchingIIsLiteral(v kv.String) (kv.EntitySlice, error)

EntitiesMatchingIIsLiteral returns entities with IIs values that return a matching kv.String from their IndexLiteral method.

The returned EntitySlice is already sorted.

func (Txn) EntitiesMatchingNameValue

func (s Txn) EntitiesMatchingNameValue(v kv.String) (kv.EntitySlice, error)

EntitiesMatchingNameValue returns entities with Name values that return a matching kv.String from their IndexValue method.

The returned EntitySlice is already sorted.

func (Txn) EntitiesMatchingOccurrenceValue

func (s Txn) EntitiesMatchingOccurrenceValue(v kv.String) (kv.EntitySlice, error)

EntitiesMatchingOccurrenceValue returns entities with Occurrence values that return a matching kv.String from their IndexValue method.

The returned EntitySlice is already sorted.

func (Txn) EntitiesMatchingSIsLiteral

func (s Txn) EntitiesMatchingSIsLiteral(v kv.String) (kv.EntitySlice, error)

EntitiesMatchingSIsLiteral returns entities with SIs values that return a matching kv.String from their IndexLiteral method.

The returned EntitySlice is already sorted.

func (Txn) EntitiesMatchingSLsLiteral

func (s Txn) EntitiesMatchingSLsLiteral(v kv.String) (kv.EntitySlice, error)

EntitiesMatchingSLsLiteral returns entities with SLs values that return a matching kv.String from their IndexLiteral method.

The returned EntitySlice is already sorted.

func (Txn) GetIIs

func (s Txn) GetIIs(e kv.Entity) (IIs, error)

GetIIs returns the IIs associated with e.

If no IIs has been explicitly set for e, and GetIIs will return the result of decoding a IIs from an empty slice of bytes.

func (Txn) GetIIsSlice

func (s Txn) GetIIsSlice(es []kv.Entity) ([]IIs, error)

GetIIsSlice returns a IIs for each entity in es.

If no IIs has been explicitly set for an entity, and the result will be a IIs that has been decoded from an empty slice of bytes.

func (Txn) GetName

func (s Txn) GetName(e kv.Entity) (Name, error)

GetName returns the Name associated with e.

If no Name has been explicitly set for e, and GetName will return the result of decoding a Name from an empty slice of bytes.

func (Txn) GetNameSlice

func (s Txn) GetNameSlice(es []kv.Entity) ([]Name, error)

GetNameSlice returns a Name for each entity in es.

If no Name has been explicitly set for an entity, and the result will be a Name that has been decoded from an empty slice of bytes.

func (Txn) GetOccurrence

func (s Txn) GetOccurrence(e kv.Entity) (Occurrence, error)

GetOccurrence returns the Occurrence associated with e.

If no Occurrence has been explicitly set for e, and GetOccurrence will return the result of decoding a Occurrence from an empty slice of bytes.

func (Txn) GetOccurrenceSlice

func (s Txn) GetOccurrenceSlice(es []kv.Entity) ([]Occurrence, error)

GetOccurrenceSlice returns a Occurrence for each entity in es.

If no Occurrence has been explicitly set for an entity, and the result will be a Occurrence that has been decoded from an empty slice of bytes.

func (Txn) GetSIs

func (s Txn) GetSIs(e kv.Entity) (SIs, error)

GetSIs returns the SIs associated with e.

If no SIs has been explicitly set for e, and GetSIs will return the result of decoding a SIs from an empty slice of bytes.

func (Txn) GetSIsSlice

func (s Txn) GetSIsSlice(es []kv.Entity) ([]SIs, error)

GetSIsSlice returns a SIs for each entity in es.

If no SIs has been explicitly set for an entity, and the result will be a SIs that has been decoded from an empty slice of bytes.

func (Txn) GetSLs

func (s Txn) GetSLs(e kv.Entity) (SLs, error)

GetSLs returns the SLs associated with e.

If no SLs has been explicitly set for e, and GetSLs will return the result of decoding a SLs from an empty slice of bytes.

func (Txn) GetSLsSlice

func (s Txn) GetSLsSlice(es []kv.Entity) ([]SLs, error)

GetSLsSlice returns a SLs for each entity in es.

If no SLs has been explicitly set for an entity, and the result will be a SLs that has been decoded from an empty slice of bytes.

func (Txn) GetTopicMapInfo

func (s Txn) GetTopicMapInfo(e kv.Entity) (TopicMapInfo, error)

GetTopicMapInfo returns the TopicMapInfo associated with e.

If no TopicMapInfo has been explicitly set for e, and GetTopicMapInfo will return the result of decoding a TopicMapInfo from an empty slice of bytes.

func (Txn) GetTopicMapInfoSlice

func (s Txn) GetTopicMapInfoSlice(es []kv.Entity) ([]TopicMapInfo, error)

GetTopicMapInfoSlice returns a TopicMapInfo for each entity in es.

If no TopicMapInfo has been explicitly set for an entity, and the result will be a TopicMapInfo that has been decoded from an empty slice of bytes.

func (Txn) GetTopicNames

func (s Txn) GetTopicNames(e kv.Entity) (TopicNames, error)

GetTopicNames returns the TopicNames associated with e.

If no TopicNames has been explicitly set for e, and GetTopicNames will return the result of decoding a TopicNames from an empty slice of bytes.

func (Txn) GetTopicNamesSlice

func (s Txn) GetTopicNamesSlice(es []kv.Entity) ([]TopicNames, error)

GetTopicNamesSlice returns a TopicNames for each entity in es.

If no TopicNames has been explicitly set for an entity, and the result will be a TopicNames that has been decoded from an empty slice of bytes.

func (Txn) GetTopicOccurrences

func (s Txn) GetTopicOccurrences(e kv.Entity) (TopicOccurrences, error)

GetTopicOccurrences returns the TopicOccurrences associated with e.

If no TopicOccurrences has been explicitly set for e, and GetTopicOccurrences will return the result of decoding a TopicOccurrences from an empty slice of bytes.

func (Txn) GetTopicOccurrencesSlice

func (s Txn) GetTopicOccurrencesSlice(es []kv.Entity) ([]TopicOccurrences, error)

GetTopicOccurrencesSlice returns a TopicOccurrences for each entity in es.

If no TopicOccurrences has been explicitly set for an entity, and the result will be a TopicOccurrences that has been decoded from an empty slice of bytes.

func (Txn) SetIIs

func (s Txn) SetIIs(e kv.Entity, v IIs) error

SetIIs sets the IIs associated with e to v.

Corresponding indexes are updated.

func (Txn) SetName

func (s Txn) SetName(e kv.Entity, v *Name) error

SetName sets the Name associated with e to v.

Corresponding indexes are updated.

func (Txn) SetOccurrence

func (s Txn) SetOccurrence(e kv.Entity, v *Occurrence) error

SetOccurrence sets the Occurrence associated with e to v.

Corresponding indexes are updated.

func (Txn) SetSIs

func (s Txn) SetSIs(e kv.Entity, v SIs) error

SetSIs sets the SIs associated with e to v.

Corresponding indexes are updated.

func (Txn) SetSLs

func (s Txn) SetSLs(e kv.Entity, v SLs) error

SetSLs sets the SLs associated with e to v.

Corresponding indexes are updated.

func (Txn) SetTopicMapInfo

func (s Txn) SetTopicMapInfo(e kv.Entity, v *TopicMapInfo) error

SetTopicMapInfo sets the TopicMapInfo associated with e to v.

Corresponding indexes are updated.

func (Txn) SetTopicNames

func (s Txn) SetTopicNames(e kv.Entity, v TopicNames) error

SetTopicNames sets the TopicNames associated with e to v.

Corresponding indexes are updated.

func (Txn) SetTopicOccurrences

func (s Txn) SetTopicOccurrences(e kv.Entity, v TopicOccurrences) error

SetTopicOccurrences sets the TopicOccurrences associated with e to v.

Corresponding indexes are updated.

type UnsupportedFormatError

type UnsupportedFormatError byte

UnsupportedFormatError indicates that a value was found in the key-value backing store with an unsupported format code, perhaps due to data corruption.

func (UnsupportedFormatError) Error

func (e UnsupportedFormatError) Error() string

Directories

Path Synopsis
internal
pb
Package pb includes protocol buffer message types.
Package pb includes protocol buffer message types.

Jump to

Keyboard shortcuts

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