lex

package module
v0.0.0-...-51ee1bb Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2017 License: MIT Imports: 0 Imported by: 2

README

Lex-go

This is an extract from FoundationDB (RIP) client library. It allows to compose lexicographic keys and manipulate them.

See LICENSE file for the license

Documentation

Overview

Package lex contains functions to compose and manipulate lexicographically sortable keys. It is forked from FoundationDB API libs (RIP).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExactRange

type ExactRange interface {
	// LexRangeKeys returns a pair of keys that describe the beginning and end
	// of a range.
	LexRangeKeys() (begin, end KeyConvertible)

	// An object that implements ExactRange must also implement Range
	// (logically, by returning FirstGreaterOrEqual of the keys returned by
	// LexRangeKeys).
	Range
}

An ExactRange describes all keys between a begin (inclusive) and end (exclusive) key. If you need to specify an ExactRange and you have only a Range, you must resolve the selectors returned by (Range).LexRangeKeySelectors to keys using the (Transaction).GetKey method.

Any object that implements ExactRange also implements Range, and may be used accordingly.

type Key

type Key []byte

Key represents a lexicographically-ordered sequence of bytes. Key implements the KeyConvertible interface.

func (Key) LexKey

func (k Key) LexKey() Key

LexKey allows Key to (trivially) satisfy the KeyConvertible interface.

type KeyConvertible

type KeyConvertible interface {
	LexKey() Key
}

A KeyConvertible can be converted to a lexicographic Key.

type KeyRange

type KeyRange struct {
	Begin, End KeyConvertible
}

KeyRange is an ExactRange constructed from a pair of KeyConvertibles. Note that the default zero-value of KeyRange specifies an empty range before all keys in the database.

func (KeyRange) LexRangeKeySelectors

func (kr KeyRange) LexRangeKeySelectors() (Selectable, Selectable)

LexRangeKeySelectors allows KeyRange to satisfy the Range interface.

func (KeyRange) LexRangeKeys

func (kr KeyRange) LexRangeKeys() (KeyConvertible, KeyConvertible)

LexRangeKeys allows KeyRange to satisfy the ExactRange interface.

type KeySelector

type KeySelector struct {
	Key     KeyConvertible
	OrEqual bool
	Offset  int
}

KeySelector represents a description of a key in a FoundationDB database. A KeySelector may be resolved to a specific key with the GetKey method, or used as the endpoints of a SelectorRange to be used with a GetRange function.

The most common key selectors are constructed with the functions documented below. For details of how KeySelectors are specified and resolved, see https://foundationdb.com/documentation/developer-guide.html#key-selectors.

func FirstGreaterOrEqual

func FirstGreaterOrEqual(key KeyConvertible) KeySelector

FirstGreaterOrEqual returns the KeySelector specifying the lexigraphically least key present in the database which is lexigraphically greater than or equal to the given key.

func FirstGreaterThan

func FirstGreaterThan(key KeyConvertible) KeySelector

FirstGreaterThan returns the KeySelector specifying the lexigraphically least key present in the database which is lexigraphically strictly greater than the given key.

func LastLessOrEqual

func LastLessOrEqual(key KeyConvertible) KeySelector

LastLessOrEqual returns the KeySelector specifying the lexigraphically greatest key present in the database which is lexigraphically less than or equal to the given key.

func LastLessThan

func LastLessThan(key KeyConvertible) KeySelector

LastLessThan returns the KeySelector specifying the lexigraphically greatest key present in the database which is lexigraphically strictly less than the given key.

func (KeySelector) LexKeySelector

func (ks KeySelector) LexKeySelector() KeySelector

LexKeySelector is a dummy method

type Range

type Range interface {
	// LexRangeKeySelectors returns a pair of key selectors that describe the
	// beginning and end of a range.
	LexRangeKeySelectors() (begin, end Selectable)
}

A Range describes all keys between a begin (inclusive) and end (exclusive) key selector.

type Selectable

type Selectable interface {
	LexKeySelector() KeySelector
}

A Selectable can be converted to a FoundationDB KeySelector. All functions in the FoundationDB API that resolve a key selector to a key accept Selectable.

type SelectorRange

type SelectorRange struct {
	Begin, End Selectable
}

SelectorRange is a Range constructed directly from a pair of Selectable objects. Note that the default zero-value of SelectorRange specifies an empty range before all keys in the database.

func (SelectorRange) LexRangeKeySelectors

func (sr SelectorRange) LexRangeKeySelectors() (Selectable, Selectable)

LexRangeKeySelectors allows SelectorRange to satisfy the Range interface.

Directories

Path Synopsis
Package subspace provides a convenient way to use FoundationDB tuples to define namespaces for different categories of data.
Package subspace provides a convenient way to use FoundationDB tuples to define namespaces for different categories of data.
Package tuple provides a layer for encoding and decoding multi-element tuples into keys usable by FoundationDB.
Package tuple provides a layer for encoding and decoding multi-element tuples into keys usable by FoundationDB.

Jump to

Keyboard shortcuts

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