Documentation ¶
Overview ¶
Package storage provides a unified interface to a number of storage engines. Since each storage engine has different capabilities, this package defines a number of interfaces in addition to the core Engine interface, which all storage engines should satisfy.
Initially we are concentrating on key-value backends but expect to support graph and perhaps relational databases.
Each storage engine must implement the following package function:
func NewStore(path string, create bool, options *Options) (Engine, error)
Currently only one storage engine file is compiled through the use of build tags like "leveldb", "hyperleveldb", and "basholeveldb".
Index ¶
- Constants
- Variables
- func DataFromFile(filename string) ([]byte, error)
- func GenerateInode(dID dvid.DataLocalID, vID dvid.VersionLocalID, index dvid.Index) uint64
- func OpenFUSE(dir string, data Mountable, vinfo VersionInfo) error
- func Shutdown()
- func ShutdownFUSE()
- type Batch
- type Batcher
- type BulkIniter
- type BulkWriter
- type Chunk
- type ChunkOp
- type Data
- type Engine
- type FUSEDirer
- type FUSEFiler
- type FUSEHandler
- type FUSERooter
- type FUSEServer
- type Key
- type KeyType
- type KeyValue
- type KeyValueDB
- type KeyValueGetter
- type KeyValueSetter
- type KeyValues
- type Mount
- type MountDir
- type Mountable
- type Op
- type OrderedKeyValueDB
- type OrderedKeyValueGetter
- type OrderedKeyValueSetter
- type Requirements
- type VersionDir
- type VersionInfo
Constants ¶
const MonitorBuffer = 10000
Variables ¶
var ( // Number of bytes read in last second from storage engine. StoreKeyBytesReadPerSec int // Number of bytes written in last second to storage engine. StoreKeyBytesWrittenPerSec int // Number of bytes read in last second from storage engine. StoreValueBytesReadPerSec int // Number of bytes written in last second to storage engine. StoreValueBytesWrittenPerSec int // Number of bytes read in last second from file system. FileBytesReadPerSec int // Number of bytes written in last second to file system. FileBytesWrittenPerSec int // Number of key-value GET calls in last second. GetsPerSec int // Number of key-value PUT calls in last second. PutsPerSec int // Channel to notify bytes read from a storage engine. StoreKeyBytesRead chan int // Channel to notify bytes written to a storage engine. StoreKeyBytesWritten chan int // Channel to notify bytes read from a storage engine. StoreValueBytesRead chan int // Channel to notify bytes written to a storage engine. StoreValueBytesWritten chan int // Channel to notify bytes read from file system. FileBytesRead chan int // Channel to notify bytes written to file system. FileBytesWritten chan int )
Functions ¶
func DataFromFile ¶
DataFromFile returns data from a file.
func GenerateInode ¶
func GenerateInode(dID dvid.DataLocalID, vID dvid.VersionLocalID, index dvid.Index) uint64
Inode numbers are uint64 which are composed from most to least significant bits: 1) uint16 describing local data ID 2) uint16 describing local version ID 3) uint32 fnv hash of the filename/key.
Types ¶
type Batch ¶
type Batch interface { // Delete removes from the batch a put using the given key. Delete(k Key) // Put adds to the batch a put using the given key/value. Put(k Key, v []byte) // Commits a batch of operations and closes the write batch. Commit() error }
Batch groups operations into a transaction. Clear() and Close() were removed due to how other key-value stores implement batches. It's easier to implement cross-database handling of a simple write/delete batch that commits then closes rather than something that clears.
type Batcher ¶
type Batcher interface {
NewBatch() Batch
}
Batchers allow batching operations into an atomic update or transaction. For example: "Atomic Updates" in http://leveldb.googlecode.com/svn/trunk/doc/index.html
type BulkIniter ¶
type BulkIniter interface { }
BulkIniters can employ even more aggressive optimization in loading large data since they can assume an uninitialized blank database.
type BulkWriter ¶
type BulkWriter interface { }
BulkWriter employ some sort of optimization to efficiently write large amount of data. For some key-value databases, this requires keys to be presorted.
type Chunk ¶
Chunk is the unit passed down channels to chunk handlers. Chunks can be passed from lower-level database access functions to type-specific chunk processing.
type ChunkOp ¶
ChunkOp is a type-specific operation with an optional WaitGroup to sync mapping before reduce.
type Data ¶
type Data []Mountable
Data is a slice of mountable data services for a particular version.
type Engine ¶
Engine implementations can fulfill a variety of interfaces and can be checked by runtime cast checks, e.g., myGetter, ok := myEngine.(OrderedKeyValueGetter) Data types can throw a warning at init time if the backend doesn't support required interfaces, or they can choose to implement multiple ways of handling data.
type FUSEDirer ¶
type FUSEDirer interface { Attr() fuse.Attr Lookup(string, fs.Intr) (fs.Node, fuse.Error) ReadDir(fs.Intr) ([]fuse.Dirent, fuse.Error) }
FUSEDirer can return a type that implements FUSE directory functions.
type FUSEHandler ¶
type FUSEHandler interface {
FUSESystem() FUSERooter
}
type FUSEServer ¶
type FUSEServer struct {
// contains filtered or unexported fields
}
FUSEServer manages mounted UUIDs for specified data.
type KeyType ¶
type KeyType byte
KeyType is a portion of a serialized Key that partitions key space into distinct areas and makes sure keys don't conflict.
const ( // Key group that hold data for Datasets KeyDatasets KeyType = iota // Key group that holds Dataset structs. There can be many Dataset structs // persisted to a particular DVID datastore. KeyDataset // Key group that holds the Data. Each Datatype figures out how to partition // its own key space using some type-specific indexing scheme. KeyData // Key group that holds Sync links between Data. Sync key/value pairs designate // what values need to be updated when its linked data changes. KeySync )
type KeyValueDB ¶
type KeyValueDB interface { KeyValueGetter KeyValueSetter }
KeyValueDB provides an interface to the simplest storage API: a key/value store.
type KeyValueGetter ¶
type KeyValueSetter ¶
type KeyValues ¶
type KeyValues []KeyValue
KeyValues is a slice of key-value pairs that can be sorted.
type MountDir ¶
type MountDir struct{}
MountDir implements both Node and Handle for the root mount directory.
type Mountable ¶
type Mountable interface { // DataName returns the name of the data (e.g., grayscale data that is grayscale8 data type). DataName() dvid.DataString // LocalDataID returns the server-specific ID (fewer bytes) for this particular data. LocalID() dvid.DataLocalID // FUSEDir returns a data-specific implementation of a FUSE Directory FUSEDir(VersionInfo) FUSEDirer }
Mountable is an interface for data that can be mounted as FUSE Files.
type Op ¶
type Op uint8
Op enumerates the types of single key-value operations that can be performed for storage engines.
type OrderedKeyValueDB ¶
type OrderedKeyValueDB interface { OrderedKeyValueGetter OrderedKeyValueSetter }
OrderedKeyValueDB addes range queries and range puts to a base KeyValueDB.
type OrderedKeyValueGetter ¶
type OrderedKeyValueGetter interface { KeyValueGetter // GetRange returns a range of values spanning (kStart, kEnd) keys. GetRange(kStart, kEnd Key) (values []KeyValue, err error) // KeysInRange returns a range of keys spanning (kStart, kEnd). KeysInRange(kStart, kEnd Key) (keys []Key, err error) // ProcessRange sends a range of key/value pairs to type-specific chunk handlers, // allowing chunk processing to be concurrent with key/value sequential reads. // Since the chunks are typically sent during sequential read iteration, the // receiving function can be organized as a pool of chunk handling goroutines. // See datatype.voxels.ProcessChunk() for an example. ProcessRange(kStart, kEnd Key, op *ChunkOp, f func(*Chunk)) (err error) }
type OrderedKeyValueSetter ¶
type OrderedKeyValueSetter interface { KeyValueSetter // Put key-value pairs. Note that it could be more efficient to use the Batcher // interface so you don't have to create and keep a slice of KeyValue. Some // databases like leveldb will copy on batch put anyway. PutRange(values []KeyValue) error }
type Requirements ¶
Requirements lists required backend interfaces for a type.
type VersionDir ¶
type VersionDir struct {
Mount
}
VersionDir implements both Node and Handle for the version directories. Each directory is specific to one data in a dataset.
func (VersionDir) Attr ¶
func (v VersionDir) Attr() fuse.Attr
type VersionInfo ¶
type VersionInfo struct {
// contains filtered or unexported fields
}
VersionInfo holds both local and global IDs for a node.
func NewVersionInfo ¶
func NewVersionInfo(uuid dvid.UUID, dID dvid.DatasetLocalID, vID dvid.VersionLocalID) VersionInfo
func (VersionInfo) GetDatasetID ¶
func (v VersionInfo) GetDatasetID() dvid.DatasetLocalID
func (VersionInfo) GetUUID ¶
func (v VersionInfo) GetUUID() dvid.UUID
func (VersionInfo) GetVersionID ¶
func (v VersionInfo) GetVersionID() dvid.VersionLocalID