keys

package
v0.0.0-...-6719cd2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package keys provides support for building and parsing the DiskView's binary key format that facts are encoded into.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FactKeysEqualIgnoreIndex

func FactKeysEqualIgnoreIndex(a, b []byte) bool

FactKeysEqualIgnoreIndex returns true if the 2 supplied keys are for the same fact, ignoring the log index part of the key.

func KeyPrefixPredicate

func KeyPrefixPredicate(p uint64) []byte

KeyPrefixPredicate returns a byte key prefix containing the supplied predicate in the POS space.

func KeyPrefixPredicateObjectNoLang

func KeyPrefixPredicateObjectNoLang(p uint64, obj rpc.KGObject) []byte

KeyPrefixPredicateObjectNoLang returns a byte key prefix containing the supplied predicate and object value in the POS space. If the object value is of type string, the language identifier is not included in the returned key.

func KeyPrefixPredicateObjectType

func KeyPrefixPredicateObjectType(p uint64, obj rpc.KGObject) []byte

KeyPrefixPredicateObjectType returns a byte key prefix containing the supplied predicate and Object type in the POS space.

func KeyPrefixSubject

func KeyPrefixSubject(s uint64) []byte

KeyPrefixSubject returns a byte key prefix containing the supplied subject in the SPO space.

func KeyPrefixSubjectPredicate

func KeyPrefixSubjectPredicate(s, p uint64) []byte

KeyPrefixSubjectPredicate returns a byte key prefix containing the supplied subject and predicate in the SPO space.

func KeyPrefixSubjectPredicateObjectNoLang

func KeyPrefixSubjectPredicateObjectNoLang(s, p uint64, obj rpc.KGObject) []byte

KeyPrefixSubjectPredicateObjectNoLang returns a byte key prefix containing the supplied subject, predicate & object in the SPO space. If the Object is of type string, the Language identifier is not included in the returned key prefix.

func ParseIndex

func ParseIndex(key []byte) blog.Index

ParseIndex extracts the index from the provided key [if it has one] and returns it otherwise returns 0.

Types

type FactKey

type FactKey struct {
	Fact     *rpc.Fact
	Encoding rpc.FactKeyEncoding
}

FactKey can be used to generate a fully serialized Fact in the specified encoding

func (FactKey) Bytes

func (fk FactKey) Bytes() []byte

Bytes returns the fact encoded in the relevant.

type MetaKey

type MetaKey struct {
}

MetaKey represents the well known key for that contains the current diskview metadata.

func (MetaKey) Bytes

func (m MetaKey) Bytes() []byte

Bytes returns the byte key version of the MetaKey.

type Spec

type Spec interface {

	// Returns the raw bytes version of this key.
	Bytes() []byte
	// contains filtered or unexported methods
}

Spec is a common interface that all Key types implement.

func ParseKey

func ParseKey(key []byte) (Spec, error)

ParseKey will parse a serialized key and return a FactKey, MetaKey, StatsKey or nil/error

type StatsKey

type StatsKey struct {
}

StatsKey represents the static key that is used to store fact statistics.

func (StatsKey) Bytes

func (s StatsKey) Bytes() []byte

Bytes returns the key bytes for the StatsKey.

Jump to

Keyboard shortcuts

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