forestdb

package module
v0.0.0-...-0b50122 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

README

goforestdb

Go bindings for ForestDB

Building

  1. Obtain and build forestdb: https://github.com/couchbaselabs/forestdb (run make install to install the library)
  2. Install header files to system location
  3. On Ubuntu 14.04: cd <forestdb_project_dir> && mkdir /usr/local/include/libforestdb && cp include/libforestdb/* /usr/local/include/libforestdb
  4. go get -u -v -t github.com/couchbase/goforestdb

Documentation

See godocs

Sample usage (without proper error handling):

// Open a database
db, _ := Open("test", nil)

// Close it properly when we're done
defer db.Close()

// Store the document
doc, _ := NewDoc([]byte("key"), nil, []byte("value"))
defer doc.Close()
db.Set(doc)

// Lookup the document
doc2, _ := NewDoc([]byte("key"), nil, nil)
defer doc2.Close()
db.Get(doc2)

// Delete the document
doc3, _ := NewDoc([]byte("key"), nil, nil)
defer doc3.Close()
db.Delete(doc3)

Documentation

Overview

ForestDB bindings for go

Sample usage (without proper error handling):

// Open a database
db, _ := Open("test", nil)

// Close it properly when we're done
defer db.Close()

// Store the document
doc, _ := NewDoc([]byte("key"), nil, []byte("value"))
defer doc.Close()
db.Set(doc)

// Lookup the document
doc2, _ := NewDoc([]byte("key"), nil, nil)
defer doc2.Close()
db.Get(doc2)

// Delete the document
doc3, _ := NewDoc([]byte("key"), nil, nil)
defer doc3.Close()
db.Delete(doc3)

Index

Constants

View Source
const SnapshotInmem = 1<<64 - 1

SnapshotInmem is the magic sequence number to request an in-memory snapshot be created. We cannot reference C.FDB_SNAPSHOT_INMEM because Go compiler complains about overflowing int.

Variables

View Source
var PoolClosed = fmt.Errorf("pool already closed")

Functions

func CloseFileKVStore

func CloseFileKVStore(kvs *KVStore) error

CloseFileKVStore closes the KVStore and its associated forestdb file db.

func CompactionCallbackInternal

func CompactionCallbackInternal(handle *C.fdb_file_handle, status C.int, kv_store *C.char, document *C.fdb_doc,
	last_oldfile_offset C.size_t, last_newfile_offset C.size_t, ctx unsafe.Pointer) C.fdb_compact_decision

func Destroy

func Destroy(filename string, config *Config) error

Destroy destroys all resources associated with a ForestDB file permanently

func FatalErrorCallbackInternal

func FatalErrorCallbackInternal()

func Init

func Init(config *Config) error

Init initializes forestdb library

func LogCallbackInternal

func LogCallbackInternal(errCode C.int, msg *C.char, ctx *C.char)

func LoggingLogCallback

func LoggingLogCallback(name string, errCode int, msg string, ctx interface{})

func SetFatalErrorCallback

func SetFatalErrorCallback(callback FatalErrorCallback)

func Shutdown

func Shutdown() error

Shutdown destroys all the resources (e.g., buffer cache, in-memory WAL indexes, daemon compaction thread, etc.) and then shutdown the ForestDB engine

Types

type CommitMarker

type CommitMarker C.fdb_kvs_commit_marker_t

func (*CommitMarker) GetKvStoreName

func (c *CommitMarker) GetKvStoreName() string

func (*CommitMarker) GetSeqNum

func (c *CommitMarker) GetSeqNum() SeqNum

type CommitOpt

type CommitOpt uint8

Options to be passed to Commit()

const (
	// Perform commit without any options.
	COMMIT_NORMAL CommitOpt = 0x00
	// Manually flush WAL entries even though it doesn't reach the configured threshol
	COMMIT_MANUAL_WAL_FLUSH CommitOpt = 0x01
)

type CompactDecision

type CompactDecision uint32
const (
	COMPACT_DECISION_KEEP CompactDecision = 0x0
	COMPACT_DECISION_DROP CompactDecision = 0x1
)

type CompactOpt

type CompactOpt uint8
const (
	COMPACT_MANUAL CompactOpt = 0
	COMPACT_AUTO   CompactOpt = 1
)

type CompactionCallback

type CompactionCallback interface {
	Callback(db *File, status CompactionStatus, kv_store_name string, doc *Doc,
		last_oldfile_offset, last_newfile_offset uint64) CompactDecision
	Name() string
}

type CompactionStatus

type CompactionStatus uint32
const (
	COMPACT_STATUS_BEGIN      CompactionStatus = 0x1
	COMPACT_STATUS_MOVE_DOC   CompactionStatus = 0x2
	COMPACT_STATUS_BATCH_MOVE CompactionStatus = 0x4
	COMPACT_STATUS_FLUSH_WAL  CompactionStatus = 0x8
	COMPACT_STATUS_END        CompactionStatus = 0x10
	COMPACT_STATUS_COMPLETE   CompactionStatus = 0x20
)

type Config

type Config struct {
	// contains filtered or unexported fields
}

ForestDB config options

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig gets the default ForestDB config

func (*Config) AutoCommit

func (c *Config) AutoCommit() bool

func (*Config) BlockSize

func (c *Config) BlockSize() uint32

func (*Config) BufferCacheSize

func (c *Config) BufferCacheSize() uint64

func (*Config) ChunkSize

func (c *Config) ChunkSize() uint16

func (*Config) CleanupCacheOnClose

func (c *Config) CleanupCacheOnClose() bool

func (*Config) CompactionBufferSizeMax

func (c *Config) CompactionBufferSizeMax() uint32

func (*Config) CompactionMinimumFilesize

func (c *Config) CompactionMinimumFilesize() uint64

func (*Config) CompactionMode

func (c *Config) CompactionMode() CompactOpt

func (*Config) CompactionThreshold

func (c *Config) CompactionThreshold() uint8

func (*Config) CompactorSleepDuration

func (c *Config) CompactorSleepDuration() uint64

func (*Config) CompressDocumentBody

func (c *Config) CompressDocumentBody() bool

func (*Config) DurabilityOpt

func (c *Config) DurabilityOpt() DurabilityOpt

func (*Config) MaxWriterLockProb

func (c *Config) MaxWriterLockProb() uint8

func (*Config) MultiKVInstances

func (c *Config) MultiKVInstances() bool

func (*Config) NumBcachePartitions

func (c *Config) NumBcachePartitions() uint16

func (*Config) NumBgflusherThreads

func (c *Config) NumBgflusherThreads() int

func (*Config) NumBlockReusingThreshold

func (c *Config) NumBlockReusingThreshold() int

func (*Config) NumCompactorThreads

func (c *Config) NumCompactorThreads() int

func (*Config) NumKeepingHeaders

func (c *Config) NumKeepingHeaders() int

func (*Config) NumWalPartitions

func (c *Config) NumWalPartitions() uint16

func (*Config) OpenFlags

func (c *Config) OpenFlags() OpenFlags

func (*Config) PrefetchDuration

func (c *Config) PrefetchDuration() uint64

func (*Config) PurgingInterval

func (c *Config) PurgingInterval() uint32

func (*Config) SeqTreeOpt

func (c *Config) SeqTreeOpt() SeqTreeOpt

func (*Config) SetAutoCommit

func (c *Config) SetAutoCommit(b bool)

func (*Config) SetBlockSize

func (c *Config) SetBlockSize(s uint32)

func (*Config) SetBufferCacheSize

func (c *Config) SetBufferCacheSize(s uint64)

func (*Config) SetChunkSize

func (c *Config) SetChunkSize(s uint16)

func (*Config) SetCleanupCacheOnClose

func (c *Config) SetCleanupCacheOnClose(b bool)

func (*Config) SetCompactionBufferSizeMax

func (c *Config) SetCompactionBufferSizeMax(s uint32)

func (*Config) SetCompactionCallback

func (c *Config) SetCompactionCallback(callback CompactionCallback)

func (*Config) SetCompactionCallbackMask

func (c *Config) SetCompactionCallbackMask(s CompactionStatus)

func (*Config) SetCompactionMinimumFilesize

func (c *Config) SetCompactionMinimumFilesize(s uint64)

func (*Config) SetCompactionMode

func (c *Config) SetCompactionMode(o CompactOpt)

func (*Config) SetCompactionThreshold

func (c *Config) SetCompactionThreshold(s uint8)

func (*Config) SetCompactorSleepDuration

func (c *Config) SetCompactorSleepDuration(s uint64)

func (*Config) SetCompressDocumentBody

func (c *Config) SetCompressDocumentBody(b bool)

func (*Config) SetDurabilityOpt

func (c *Config) SetDurabilityOpt(o DurabilityOpt)

func (*Config) SetMaxWriterLockProb

func (c *Config) SetMaxWriterLockProb(s uint8)

func (*Config) SetMultiKVInstances

func (c *Config) SetMultiKVInstances(multi bool)

func (*Config) SetNumBcachePartitions

func (c *Config) SetNumBcachePartitions(s uint16)

func (*Config) SetNumBgflusherThreads

func (c *Config) SetNumBgflusherThreads(s int)

func (*Config) SetNumBlockReusingThreshold

func (c *Config) SetNumBlockReusingThreshold(s int)

func (*Config) SetNumCompactorThreads

func (c *Config) SetNumCompactorThreads(s int)

func (*Config) SetNumKeepingHeaders

func (c *Config) SetNumKeepingHeaders(s int)

func (*Config) SetNumWalPartitions

func (c *Config) SetNumWalPartitions(s uint16)

func (*Config) SetOpenFlags

func (c *Config) SetOpenFlags(o OpenFlags)

func (*Config) SetPrefetchDuration

func (c *Config) SetPrefetchDuration(s uint64)

func (*Config) SetPurgingInterval

func (c *Config) SetPurgingInterval(s uint32)

func (*Config) SetSeqTreeOpt

func (c *Config) SetSeqTreeOpt(o SeqTreeOpt)

func (*Config) SetWalFlushBeforeCommit

func (c *Config) SetWalFlushBeforeCommit(b bool)

func (*Config) SetWalThreshold

func (c *Config) SetWalThreshold(s uint64)

func (*Config) WalFlushBeforeCommit

func (c *Config) WalFlushBeforeCommit() bool

func (*Config) WalThreshold

func (c *Config) WalThreshold() uint64

type Doc

type Doc struct {
	// contains filtered or unexported fields
}

ForestDB doc structure definition

func NewDoc

func NewDoc(key, meta, body []byte) (*Doc, error)

NewDoc creates a new FDB_DOC instance on heap with a given key, its metadata, and its doc body

func (*Doc) Body

func (d *Doc) Body() []byte

Body returns the document body

func (*Doc) Close

func (d *Doc) Close() error

Close releases resources allocated to this document

func (*Doc) Deleted

func (d *Doc) Deleted() bool

Deleted returns whether or not this document has been deleted

func (*Doc) Key

func (d *Doc) Key() []byte

Key returns the document key

func (*Doc) Meta

func (d *Doc) Meta() []byte

Meta returns the document metadata

func (*Doc) Offset

func (d *Doc) Offset() uint64

Offset returns the offset position on disk

func (*Doc) SeqNum

func (d *Doc) SeqNum() SeqNum

SeqNum returns the document sequence number

func (*Doc) SetSeqNum

func (d *Doc) SetSeqNum(sn SeqNum)

SetSeqNum sets the document sequence number NOTE: only to be used when initiating a sequence number lookup

func (*Doc) Update

func (d *Doc) Update(meta, body []byte) error

Update a FDB_DOC instance with a given metadata and body NOTE: does not update the database, just the in memory structure

type Dummy

type Dummy struct {
}

func (*Dummy) Debugf

func (*Dummy) Debugf(_ string, _ ...interface{})

func (*Dummy) Errorf

func (*Dummy) Errorf(_ string, _ ...interface{})

func (*Dummy) Fatalf

func (*Dummy) Fatalf(_ string, _ ...interface{})

func (*Dummy) Infof

func (*Dummy) Infof(_ string, _ ...interface{})

func (*Dummy) Tracef

func (*Dummy) Tracef(_ string, _ ...interface{})

func (*Dummy) Warnf

func (*Dummy) Warnf(_ string, _ ...interface{})

type DurabilityOpt

type DurabilityOpt uint8
const (
	DRB_NONE          DurabilityOpt = 0
	DRB_ODIRECT       DurabilityOpt = 0x1
	DRB_ASYNC         DurabilityOpt = 0x2
	DRB_ODIRECT_ASYNC DurabilityOpt = 0x3
)

type Error

type Error int
const (
	RESULT_SUCCESS                  C.fdb_status = 0
	RESULT_INVALID_ARGS             Error        = -1
	RESULT_OPEN_FAIL                Error        = -2
	RESULT_NO_SUCH_FILE             Error        = -3
	RESULT_WRITE_FAIL               Error        = -4
	RESULT_READ_FAIL                Error        = -5
	RESULT_CLOSE_FAIL               Error        = -6
	RESULT_COMMIT_FAIL              Error        = -7
	RESULT_ALLOC_FAIL               Error        = -8
	RESULT_KEY_NOT_FOUND            Error        = -9
	RESULT_RONLY_VIOLATION          Error        = -10
	RESULT_COMPACTION_FAIL          Error        = -11
	RESULT_ITERATOR_FAIL            Error        = -12
	RESULT_SEEK_FAIL                Error        = -13
	RESULT_FSYNC_FAIL               Error        = -14
	RESULT_CHECKSUM_ERROR           Error        = -15
	RESULT_FILE_CORRUPTION          Error        = -16
	RESULT_COMPRESSION_FAIL         Error        = -17
	RESULT_NO_DB_INSTANCE           Error        = -18
	RESULT_FAIL_BY_ROLLBACK         Error        = -19
	RESULT_INVALID_CONFIG           Error        = -20
	RESULT_MANUAL_COMPACTION_FAIL   Error        = -21
	RESULT_INVALID_COMPACTION_MODE  Error        = -22
	RESULT_FILE_IS_BUSY             Error        = -23
	RESULT_FILE_REMOVE_FAIL         Error        = -24
	RESULT_FILE_RENAME_FAIL         Error        = -25
	RESULT_TRANSACTION_FAIL         Error        = -26
	RESULT_FAIL_BY_TRANSACTION      Error        = -27
	RESULT_FAIL_BY_COMPACTION       Error        = -28
	RESULT_TOO_LONG_FILENAME        Error        = -29
	RESULT_INVALID_HANDLE           Error        = -30
	RESULT_KV_STORE_NOT_FOUND       Error        = -31
	RESULT_KV_STORE_BUSY            Error        = -32
	RESULT_INVALID_KV_INSTANCE_NAME Error        = -33
	RESULT_INVALID_CMP_FUNCTION     Error        = -34
	RESULT_IN_USE_BY_COMPACTOR      Error        = -35
	RESULT_FILE_NOT_OPEN            Error        = -36
	RESULT_TOO_BIG_BUFFER_CACHE     Error        = -37
	RESULT_NO_DB_HEADERS            Error        = -38
	RESULT_HANDLE_BUSY              Error        = -39
	RESULT_AIO_NOT_SUPPORTED        Error        = -40
	RESULT_AIO_INIT_FAIL            Error        = -41
	RESULT_AIO_SUBMIT_FAIL          Error        = -42
	RESULT_AIO_GETEVENTS_FAIL       Error        = -43
	RESULT_CRYPTO_ERROR             Error        = -44
	RESULT_FAIL                     Error        = -100
)

func (Error) Error

func (e Error) Error() string

type FatalErrorCallback

type FatalErrorCallback func()

type File

type File struct {
	// contains filtered or unexported fields
}

Database handle

func Open

func Open(filename string, config *Config) (*File, error)

Open opens the database with a given file name

func (*File) AbortTransaction

func (f *File) AbortTransaction() error

func (*File) BeginTransaction

func (f *File) BeginTransaction(level IsolationLevel) error

func (*File) Close

func (f *File) Close() error

Close the database file

func (*File) Commit

func (f *File) Commit(opt CommitOpt) error

Commit all pending changes into disk.

func (*File) Compact

func (f *File) Compact(newfilename string) error

Compact the current database file and create a new compacted file

func (*File) CompactUpto

func (f *File) CompactUpto(newfilename string, sm *SnapMarker) error

CompactUpto compacts the current database file upto given snapshot marker and creates a new compacted file

func (*File) EndTransaction

func (f *File) EndTransaction(opt CommitOpt) error

func (*File) EstimateSpaceUsed

func (f *File) EstimateSpaceUsed() int

EstimateSpaceUsed returns the overall disk space actively used by the current database file

func (*File) GetAllSnapMarkers

func (f *File) GetAllSnapMarkers() (*SnapInfos, error)

func (*File) GetKVStoreNames

func (f *File) GetKVStoreNames() ([]string, error)

func (*File) Info

func (f *File) Info() (*FileInfo, error)

DbInfo returns the information about a given database handle

func (*File) OpenKVStore

func (f *File) OpenKVStore(name string, config *KVStoreConfig) (*KVStore, error)

OpenKVStore opens the named KVStore within the File using the provided KVStoreConfig. If config is nil the DefaultKVStoreConfig() will be used.

func (*File) OpenKVStoreDefault

func (f *File) OpenKVStoreDefault(config *KVStoreConfig) (*KVStore, error)

OpenKVStore opens the default KVStore within the File using the provided KVStoreConfig. If config is nil the DefaultKVStoreConfig() will be used.

func (*File) SwitchCompactionMode

func (f *File) SwitchCompactionMode(mode CompactOpt, threshold int) error

SwitchCompactionMode changes the compaction mode of a ForestDB file if the mode is changed to COMPACT_AUTO the compaction threshold is set to the threshold passed to this API

type FileInfo

type FileInfo struct {
	// contains filtered or unexported fields
}

FileInfo stores information about a given file

func (*FileInfo) DocCount

func (i *FileInfo) DocCount() uint64

func (*FileInfo) FileSize

func (i *FileInfo) FileSize() uint64

func (*FileInfo) Filename

func (i *FileInfo) Filename() string

func (*FileInfo) NewFilename

func (i *FileInfo) NewFilename() string

func (*FileInfo) SpaceUsed

func (i *FileInfo) SpaceUsed() uint64

func (*FileInfo) String

func (i *FileInfo) String() string

type IsolationLevel

type IsolationLevel uint8

IsolationLevel is the Transaction Isolation Level

const (
	//ISOLATION_SERIALIZABLE IsolationLevel = 0x00
	//ISOLATION_REPEATABLE_READ IsolationLevel = 0x01
	ISOLATION_READ_COMMITTED   IsolationLevel = 0x02
	ISOLATION_READ_UNCOMMITTED IsolationLevel = 0x03
)

type Iterator

type Iterator struct {
	// contains filtered or unexported fields
}

Iterator handle

func (*Iterator) Close

func (i *Iterator) Close() error

Close the iterator and free its associated resources

func (*Iterator) Get

func (i *Iterator) Get() (*Doc, error)

Get gets the current item (key, metadata, doc body) from the iterator

func (*Iterator) GetMetaOnly

func (i *Iterator) GetMetaOnly() (*Doc, error)

GetMetaOnly gets the current item (key, metadata, offset to doc body) from the iterator

func (*Iterator) GetPreAlloc

func (i *Iterator) GetPreAlloc(rv *Doc) error

GetPreAlloc gets the current item (key, metadata, doc body) from the iterator but uses the pre-allocated memory for the Doc

func (*Iterator) Next

func (i *Iterator) Next() error

Next advances the iterator forward

func (*Iterator) Prev

func (i *Iterator) Prev() error

Prev advances the iterator backwards

func (*Iterator) Seek

func (i *Iterator) Seek(seekKey []byte, dir SeekOpt) error

Seek fast forward / backward an iterator to return documents starting from the given seek_key. If the seek key does not exist, the iterator is positioned based on the specified dir (either before or after).

func (*Iterator) SeekMax

func (i *Iterator) SeekMax() error

SeekMax moves iterator to the largest key of the iteration

func (*Iterator) SeekMin

func (i *Iterator) SeekMin() error

SeekMin moves iterator to the smallest key of the iteration

type IteratorOpt

type IteratorOpt uint16

ForestDB iterator options

const (
	// Return both key and value through iterator
	ITR_NONE IteratorOpt = 0x00
	// Return only non-deleted items through iterator
	ITR_NO_DELETES IteratorOpt = 0x02
	// The lowest key specified will not be returned by the iterator
	FDB_ITR_SKIP_MIN_KEY IteratorOpt = 0x04
	//The highest key specified will not be returned by the iterator
	FDB_ITR_SKIP_MAX_KEY IteratorOpt = 0x08
)

type KVBatch

type KVBatch struct {
	// contains filtered or unexported fields
}

func NewKVBatch

func NewKVBatch() *KVBatch

func (*KVBatch) Delete

func (b *KVBatch) Delete(k []byte)

func (*KVBatch) Reset

func (b *KVBatch) Reset()

func (*KVBatch) Set

func (b *KVBatch) Set(k, v []byte)

type KVPool

type KVPool struct {
	// contains filtered or unexported fields
}

KVPool is a structure representing a pool of KVStores inside a file. Each has been opened with it's own File handle, so they can be used concurrently safely.

func NewKVPool

func NewKVPool(filename string, config *Config, kvstore string, kvconfig *KVStoreConfig, size int) (*KVPool, error)

func (*KVPool) Close

func (p *KVPool) Close() (rverr error)

func (*KVPool) Get

func (p *KVPool) Get() (*KVStore, error)

func (*KVPool) Return

func (p *KVPool) Return(kvs *KVStore) error

type KVSOpsInfo

type KVSOpsInfo struct {
	// contains filtered or unexported fields
}

func (*KVSOpsInfo) NumCommits

func (i *KVSOpsInfo) NumCommits() uint64

func (*KVSOpsInfo) NumCompacts

func (i *KVSOpsInfo) NumCompacts() uint64

func (*KVSOpsInfo) NumDels

func (i *KVSOpsInfo) NumDels() uint64

func (*KVSOpsInfo) NumGets

func (i *KVSOpsInfo) NumGets() uint64

func (*KVSOpsInfo) NumIteratorGets

func (i *KVSOpsInfo) NumIteratorGets() uint64

func (*KVSOpsInfo) NumIteratorMoves

func (i *KVSOpsInfo) NumIteratorMoves() uint64

func (*KVSOpsInfo) NumSets

func (i *KVSOpsInfo) NumSets() uint64

type KVStore

type KVStore struct {
	// contains filtered or unexported fields
}

KVStore handle

func OpenFileKVStore

func OpenFileKVStore(fileName string, config *Config,
	kvstoreName string, kvstoreConfig *KVStoreConfig) (
	*KVStore, error)

OpenFileKVStore opens up a forestdb file db and a single KVStore inside that file/db.

func (*KVStore) Close

func (k *KVStore) Close() error

Close the KVStore and release related resources.

func (*KVStore) Delete

func (k *KVStore) Delete(doc *Doc) error

Delete deletes a key, its metadata and value

func (*KVStore) DeleteKV

func (k *KVStore) DeleteKV(key []byte) error

DeleteKV simplified API for key/value access to Delete()

func (*KVStore) ExecuteBatch

func (k *KVStore) ExecuteBatch(b *KVBatch, opt CommitOpt) (err error)

func (*KVStore) File

func (k *KVStore) File() *File

File returns the File containing this KVStore

func (*KVStore) Get

func (k *KVStore) Get(doc *Doc) error

Get retrieves the metadata and doc body for a given key

func (*KVStore) GetByOffset

func (k *KVStore) GetByOffset(doc *Doc) error

GetByOffset retrieves a doc's metadata and body with a given doc offset in the database file

func (*KVStore) GetBySeq

func (k *KVStore) GetBySeq(doc *Doc) error

GetBySeq retrieves the metadata and doc body for a given sequence number

func (*KVStore) GetKV

func (k *KVStore) GetKV(key []byte) ([]byte, error)

GetKV simplified API for key/value access to Get()

func (*KVStore) GetMetaOnly

func (k *KVStore) GetMetaOnly(doc *Doc) error

GetMetaOnly retrieves the metadata for a given key

func (*KVStore) GetMetaOnlyBySeq

func (k *KVStore) GetMetaOnlyBySeq(doc *Doc) error

GetMetaOnlyBySeq retrieves the metadata for a given sequence number

func (*KVStore) Handle

func (k *KVStore) Handle() *C.fdb_kvs_handle

Handle returns the underlying fdb_kvs_handle for advanced uses.

func (*KVStore) Info

func (k *KVStore) Info() (*KVStoreInfo, error)

Info returns the information about a given kvstore

func (*KVStore) IteratorInit

func (k *KVStore) IteratorInit(startKey, endKey []byte, opt IteratorOpt) (*Iterator, error)

IteratorInit creates an iterator to traverse a ForestDB snapshot by key range

func (*KVStore) IteratorSequenceInit

func (k *KVStore) IteratorSequenceInit(startSeq, endSeq SeqNum, opt IteratorOpt) (*Iterator, error)

IteratorSequenceInit create an iterator to traverse a ForestDB snapshot by sequence number range

func (*KVStore) OpsInfo

func (k *KVStore) OpsInfo() (*KVSOpsInfo, error)

OpsInfo returns the information about the ops on given kvstore

func (*KVStore) Rollback

func (k *KVStore) Rollback(sn SeqNum) error

Rollback a database to a specified point represented by the sequence number

func (*KVStore) Set

func (k *KVStore) Set(doc *Doc) error

Set update the metadata and doc body for a given key

func (*KVStore) SetKV

func (k *KVStore) SetKV(key, value []byte) error

SetKV simplified API for key/value access to Set()

func (*KVStore) SetLogCallback

func (k *KVStore) SetLogCallback(l LogCallback, userCtx interface{})

func (*KVStore) SnapshotOpen

func (k *KVStore) SnapshotOpen(sn SeqNum) (*KVStore, error)

SnapshotOpen creates an snapshot of a database file in ForestDB

type KVStoreConfig

type KVStoreConfig struct {
	// contains filtered or unexported fields
}

ForestDB KVStore config options

func DefaultKVStoreConfig

func DefaultKVStoreConfig() *KVStoreConfig

DefaultConfig gets the default ForestDB config

func (*KVStoreConfig) CreateIfMissing

func (c *KVStoreConfig) CreateIfMissing() bool

func (*KVStoreConfig) SetCreateIfMissing

func (c *KVStoreConfig) SetCreateIfMissing(b bool)

func (*KVStoreConfig) SetCustomCompare

func (c *KVStoreConfig) SetCustomCompare(comparator unsafe.Pointer)

type KVStoreInfo

type KVStoreInfo struct {
	// contains filtered or unexported fields
}

KVStoreInfo stores information about a given kvstore

func (*KVStoreInfo) DocCount

func (i *KVStoreInfo) DocCount() uint64

func (*KVStoreInfo) LastSeqNum

func (i *KVStoreInfo) LastSeqNum() SeqNum

func (*KVStoreInfo) Name

func (i *KVStoreInfo) Name() string

func (*KVStoreInfo) String

func (i *KVStoreInfo) String() string

type LeveledLog

type LeveledLog struct {
	// contains filtered or unexported fields
}

func NewLeveledLog

func NewLeveledLog(level LogLevel) *LeveledLog

func (*LeveledLog) Debugf

func (l *LeveledLog) Debugf(format string, a ...interface{})

func (*LeveledLog) Errorf

func (l *LeveledLog) Errorf(format string, a ...interface{})

func (*LeveledLog) Fatalf

func (l *LeveledLog) Fatalf(format string, a ...interface{})

func (*LeveledLog) Infof

func (l *LeveledLog) Infof(format string, a ...interface{})

func (*LeveledLog) Tracef

func (l *LeveledLog) Tracef(format string, a ...interface{})

func (*LeveledLog) Warnf

func (l *LeveledLog) Warnf(format string, a ...interface{})

type LogCallback

type LogCallback func(name string, errCode int, msg string, ctx interface{})

type LogLevel

type LogLevel int
const (
	LogFatal LogLevel = iota
	LogError
	LogWarn
	LogInfo
	LogDebug
	LogTrace
)

type Logger

type Logger interface {
	// Warnings, logged by default.
	Warnf(format string, v ...interface{})
	// Errors, logged by default.
	Errorf(format string, v ...interface{})
	// Fatal errors. Will not terminate execution.
	Fatalf(format string, v ...interface{})
	// Informational messages.
	Infof(format string, v ...interface{})
	// Timing utility
	Debugf(format string, v ...interface{})
	// Program execution tracing. Not logged by default
	Tracef(format string, v ...interface{})
}

Logger interface

var Log Logger = &Dummy{}

Logger to use

type OpenFlags

type OpenFlags uint32
const (
	OPEN_FLAG_CREATE OpenFlags = 1
	OPEN_FLAG_RDONLY OpenFlags = 2
)

type SeekOpt

type SeekOpt uint8

ForestDB seek options

const (
	// If seek_key does not exist return the next sorted key higher than it
	FDB_ITR_SEEK_HIGHER SeekOpt = 0x00
	// If seek_key does not exist return the previous sorted key lower than it
	FDB_ITR_SEEK_LOWER SeekOpt = 0x01
)

type SeqNum

type SeqNum uint64

type SeqTreeOpt

type SeqTreeOpt uint8
const (
	SEQTREE_NOT_USE SeqTreeOpt = 0
	SEQTREE_USE     SeqTreeOpt = 1
)

type SnapInfo

type SnapInfo C.fdb_snapshot_info_t

func (*SnapInfo) CommitMarkerForKvStore

func (si *SnapInfo) CommitMarkerForKvStore(name string) (rv *CommitMarker)

CommitMarkerForKvStore returns a *CommitMarker corresponding to the named KV store which matches the provided argument. Returns nil if no CommitMarker with the specified name is a part of this SnapInfo.

func (*SnapInfo) GetKvsCommitMarkers

func (si *SnapInfo) GetKvsCommitMarkers() []CommitMarker

func (*SnapInfo) GetNumKvsMarkers

func (si *SnapInfo) GetNumKvsMarkers() int64

func (*SnapInfo) GetSnapMarker

func (si *SnapInfo) GetSnapMarker() *SnapMarker

type SnapInfos

type SnapInfos struct {
	// contains filtered or unexported fields
}

func (*SnapInfos) FreeSnapMarkers

func (s *SnapInfos) FreeSnapMarkers() error

func (*SnapInfos) SnapInfoList

func (s *SnapInfos) SnapInfoList() []SnapInfo

type SnapMarker

type SnapMarker struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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