Documentation ¶
Overview ¶
Package dagstore provides a branched versioned store of data where committed versions can be stored in a distributed fashion.
Index ¶
- Constants
- Variables
- func Shutdown()
- type Config
- type DAGStore
- func (ds *DAGStore) Commit(version UUID, data ...UUID) error
- func (ds *DAGStore) Delete(id ID, key []byte) error
- func (ds *DAGStore) Exists(id ID, key []byte) (bool, error)
- func (ds *DAGStore) Get(id ID, key []byte) (*KVwithFlags, error)
- func (ds *DAGStore) GetBranches() map[string]UUID
- func (ds *DAGStore) GetRange(ctx context.Context, id ID, keyStart, keyEnd []byte) ([]*KVwithFlags, error)
- func (ds *DAGStore) GetTaggedVersion(tag string) UUID
- func (ds *DAGStore) NewData(spec *DataSpec, parentGroup UUID) error
- func (ds *DAGStore) NewVersion(parent, child UUID, branch string) (UUID, error)
- func (ds *DAGStore) Put(id ID, kv KVwithFlags) error
- func (ds *DAGStore) StreamAll(ctx context.Context, id ID, keysOnly bool, out chan *KVwithFlags) error
- func (ds *DAGStore) StreamRange(ctx context.Context, id ID, keyStart, keyEnd []byte, ordered, keysOnly bool, ...) error
- func (ds *DAGStore) TagVersion(version UUID, tag string) error
- type DataSpec
- type DataSpecType
- type Flags
- type ID
- type KV
- type KVwithFlags
- type KVwithVersion
- type RawUUID
- type UUID
- type UUIDType
Constants ¶
const ( // DirMutableStore is the name of the mutable store subdirectory within the // DAGStore directory. DirMutableStore = "mutable" // DirImmutableStore is the name of the immutable store subdirectory within // the DAGStore directory. DirImmutableStore = "immutable" // FnameVersions is the file name of the JSON versions (DAG + local ids). // This is typically stored in the root directory. FnameVersions = "versions.json" // FnameDataCatalog is the file name of the JSON data catalog (inc. local ids). // This is typically stored in the root directory. FnameDataCatalog = "data_catalog.json" )
const ( FlagTombstone = 0x01 FlagValueEmpty = 0x02 FlagValueNil = 0x04 )
const ( // DirImmutableIndex is the name of the index subdirectory within // the immutable store subdirectory. DirImmutableIndex = "index" )
const (
// FnameMetadata is the file name of the persisted JSON for each data's metadata.
FnameMetadata = "metadata.json"
)
const NilUUID = UUID("")
NilUUID is an invalid UUID.
Variables ¶
var (
ErrBadUserFlags = errors.New("user flags must be first 5 bits of a byte")
)
Functions ¶
Types ¶
type DAGStore ¶
type DAGStore struct {
// contains filtered or unexported fields
}
DAGStore is a store for branched versioning of large-scale data.
func Initialize ¶
Initialize creates a DAGStore from the given configuration.
func (*DAGStore) Commit ¶
Commit marks a set of data as committed for the given version. TODO: See what people think of this approach
func (*DAGStore) Delete ¶
Delete removes a key-value pair at this version by placing a tombstone. Prior committed values for the key can still be retrieved.
func (*DAGStore) Get ¶
func (ds *DAGStore) Get(id ID, key []byte) (*KVwithFlags, error)
Get returns the value and flags associated with a key at the given version.
func (*DAGStore) GetBranches ¶
GetBranches returns branches and their HEAD version.
func (*DAGStore) GetRange ¶
func (ds *DAGStore) GetRange(ctx context.Context, id ID, keyStart, keyEnd []byte) ([]*KVwithFlags, error)
GetRange returns the key-value pairs at given version within a range of keys.
func (*DAGStore) GetTaggedVersion ¶
GetTaggedVersion returns the version associated with a tag.
func (*DAGStore) NewData ¶
NewData creates a new Group with given parent. If a UUID is not specified in the DataID parameter, a new UUID is assigned. The metadata parameter is optional and can be an empty string.
func (*DAGStore) NewVersion ¶
NewVersion extends the DAG so the given branch has a new uncommitted node.
func (*DAGStore) Put ¶
func (ds *DAGStore) Put(id ID, kv KVwithFlags) error
Put writes a value with given key.
func (*DAGStore) StreamAll ¶
func (ds *DAGStore) StreamAll(ctx context.Context, id ID, keysOnly bool, out chan *KVwithFlags) error
StreamAll sends all keys and optionally values for a given dataset and version.
func (*DAGStore) StreamRange ¶
func (ds *DAGStore) StreamRange(ctx context.Context, id ID, keyStart, keyEnd []byte, ordered, keysOnly bool, out chan *KVwithFlags) error
StreamRange sends keys and optionally values at a given version within a range of keys.
type DataSpec ¶
type DataSpec struct { // Name should be human-friendly and can be altered Name string // GlobalID provides a unique identifier even in distributed systems. GlobalID UUID // Datatype specifies either a Group or a supported storage type like KeyValue. Datatype DataSpecType // Optional metadata that can be left as empty value Metadata string }
type DataSpecType ¶
type DataSpecType uint8
const ( // DataUnknown is default empty value that signifies the type was not set. DataUnknown DataSpecType = iota // DataGroup can contain other Groups or datasets of various type. DataGroup // DataKeyValue supports storage and range reads of key-value pairs. DataKeyValue // DataLog supports storage of logs DataLog // DataND supports storage and range reads of n-dimensional data chunks. DataND )
type Flags ¶
type Flags struct {
// contains filtered or unexported fields
}
Flags can specify tombstones, 0 byte values, and 5-bit user field.
func (Flags) GetUserBits ¶
func (Flags) IsEmptyValue ¶
func (Flags) IsTombstone ¶
func (*Flags) SetUserBits ¶
type KVwithFlags ¶
KVwithFlags is a key-value pair with tombstone, empty value, and optional 6-bit user flags.
type KVwithVersion ¶
KVwithVersion is a key-value pair with KeyFlags and version. This is useful for low-level transmission of data, like importing DAGStore versioned data into an alternative datastore.
type RawUUID ¶
type RawUUID [16]byte
RawUUID is the 16-byte RFC4122 UUID, thereby 2x smaller than the hex string version.
type UUID ¶
type UUID string
UUID is a 32 character hexidecimal string (a RFC4122 version 4 UUID) that uniquely identifies nodes in a DAG. We need universally unique identifiers to prevent collisions when distributed DAGStores create new versions: http://en.wikipedia.org/wiki/Universally_unique_identifier
func StringToUUID ¶
StringToUUID converts a string to a UUID, checking to make sure it is a 32 character hex string. If it isn't a valid UUID, a NilUUID is returned.