Documentation ¶
Index ¶
- type Conf
- type DB
- func (dbInst *DB) Close()
- func (dbInst *DB) Delete(key []byte, sync bool) error
- func (dbInst *DB) Get(key []byte) ([]byte, error)
- func (dbInst *DB) GetIterator(startKey []byte, endKey []byte) iterator.Iterator
- func (dbInst *DB) IsEmpty() (bool, error)
- func (dbInst *DB) Open()
- func (dbInst *DB) Put(key []byte, value []byte, sync bool) error
- func (dbInst *DB) WriteBatch(batch *leveldb.Batch, sync bool) error
- type DBHandle
- func (h *DBHandle) Close()
- func (h *DBHandle) Delete(key []byte, sync bool) error
- func (h *DBHandle) Get(key []byte) ([]byte, error)
- func (h *DBHandle) GetIterator(startKey []byte, endKey []byte) (*Iterator, error)
- func (h *DBHandle) IsEmpty() (bool, error)
- func (h *DBHandle) NewUpdateBatch() *UpdateBatch
- func (h *DBHandle) Put(key []byte, value []byte, sync bool) error
- func (h *DBHandle) WriteBatch(batch *UpdateBatch, sync bool) error
- type DataFormatInfo
- type FileLock
- type Iterator
- type Provider
- type UpdateBatch
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conf ¶
Conf configuration for `Provider`
`ExpectedFormat` is the expected value of the format key in the internal database. At the time of opening the db, A check is performed that either the db is empty (i.e., opening for the first time) or the value of the formatVersionKey is equal to `ExpectedFormat`. Otherwise, an error is returned. A nil value for ExpectedFormat indicates that the format is never set and hence there is no such record.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB - a wrapper on an actual store
func (*DB) GetIterator ¶
GetIterator returns an iterator over key-value store. The iterator should be released after the use. The resultset contains all the keys that are present in the db between the startKey (inclusive) and the endKey (exclusive). A nil startKey represents the first available key and a nil endKey represent a logical key after the last available key
type DBHandle ¶
type DBHandle struct {
// contains filtered or unexported fields
}
DBHandle is an handle to a named db
func (*DBHandle) Close ¶
func (h *DBHandle) Close()
Close closes the DBHandle after its db data have been deleted
func (*DBHandle) GetIterator ¶
GetIterator gets an handle to iterator. The iterator should be released after the use. The resultset contains all the keys that are present in the db between the startKey (inclusive) and the endKey (exclusive). A nil startKey represents the first available key and a nil endKey represent a logical key after the last available key
func (*DBHandle) NewUpdateBatch ¶
func (h *DBHandle) NewUpdateBatch() *UpdateBatch
NewUpdateBatch returns a new UpdateBatch that can be used to update the db
func (*DBHandle) WriteBatch ¶
func (h *DBHandle) WriteBatch(batch *UpdateBatch, sync bool) error
WriteBatch writes a batch in an atomic way
type DataFormatInfo ¶
type DataFormatInfo struct { FormatVerison string // version of the data format IsDBEmpty bool // set to true if the db does not contain any data }
DataFormatInfo contains the information about the version of the data format
func RetrieveDataFormatInfo ¶
func RetrieveDataFormatInfo(dbPath string) (*DataFormatInfo, error)
RetrieveDataFormatInfo retrieves the DataFormatInfo for the db at the supplied `dbPath`
type FileLock ¶
type FileLock struct {
// contains filtered or unexported fields
}
FileLock encapsulate the DB that holds the file lock. As the FileLock to be used by a single process/goroutine, there is no need for the semaphore to synchronize the FileLock usage.
func NewFileLock ¶
NewFileLock returns a new file based lock manager.
func (*FileLock) Lock ¶
Lock acquire a file lock. We achieve this by opening a db for the given filePath. Internally, leveldb acquires a file lock while opening a db. If the db is opened again by the same or another process, error would be returned. When the db is closed or the owner process dies, the lock would be released and hence the other process can open the db. We exploit this leveldb functionality to acquire and release file lock as the leveldb supports this for Windows, Solaris, and Unix.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider enables to use a single leveldb as multiple logical leveldbs
func NewProvider ¶
NewProvider constructs a Provider
func (*Provider) GetDBHandle ¶
GetDBHandle returns a handle to a named db
func (*Provider) GetDataFormat ¶
GetDataFormat returns the format of the data
func (*Provider) SetDataFormat ¶
type UpdateBatch ¶
type UpdateBatch struct {
// contains filtered or unexported fields
}
UpdateBatch encloses the details of multiple `updates`
func (*UpdateBatch) Delete ¶
func (b *UpdateBatch) Delete(key []byte)
Delete deletes a Key and associated value
func (*UpdateBatch) Len ¶
func (b *UpdateBatch) Len() int
Len returns number of records in the batch
func (*UpdateBatch) Size ¶
func (b *UpdateBatch) Size() int
Size returns the current size of the batch