forestdb

package
v0.0.0-...-b800c40 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2017 License: Apache-2.0, Apache-2.0 Imports: 9 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)

This file was generated by error.sh DO NOT EDIT FILE

Index

Constants

View Source
const (
	FdbUnkownFileVersion uint8 = iota
	FdbV1FileVersion
	FdbV2FileVersion
)
View Source
const FDB_UNKNOWN_FILE_FORMAT = "Unkown"
View Source
const FDB_V1_FILE_FORMAT = "ForestDB v1.x format"
View Source
const FDB_V2_FILE_FORMAT = "ForestDB v2.x format"
View Source
const RESULT_ITERATOR_FAIL = FDB_RESULT_ITERATOR_FAIL
View Source
const RESULT_SUCCESS C.fdb_status = C.FDB_RESULT_SUCCESS

Variables

This section is empty.

Functions

func BufferCacheUsed

func BufferCacheUsed() uint64

Buffer cache used by the forestdb global pool

func Destroy

func Destroy(filename string, config *Config) error

Destroy destroys all resources associated with a ForestDB file permanently

func FdbFileVersionToString

func FdbFileVersionToString(version uint8) string

func FdbStringToFileVersion

func FdbStringToFileVersion(versionStr string) uint8

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 CompactOpt

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

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) BlockReuseThreshold

func (c *Config) BlockReuseThreshold() uint8

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) NumKeepingHeaders

func (c *Config) NumKeepingHeaders() uint8

func (*Config) OpenFlags

func (c *Config) OpenFlags() OpenFlags

func (*Config) PurgingInterval

func (c *Config) PurgingInterval() uint32

func (*Config) SeqTreeOpt

func (c *Config) SeqTreeOpt() SeqTreeOpt

func (*Config) SetBlockReuseThreshold

func (c *Config) SetBlockReuseThreshold(s uint8)

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) 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) SetNumKeepingHeaders

func (c *Config) SetNumKeepingHeaders(s uint8)

func (*Config) SetOpenFlags

func (c *Config) SetOpenFlags(o OpenFlags)

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) BodyNoCopy

func (d *Doc) BodyNoCopy() (s []byte)

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) KeyNoCopy

func (d *Doc) KeyNoCopy() (s []byte)

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 (
	FDB_RESULT_AIO_GETEVENTS_FAIL         Error = C.FDB_RESULT_AIO_GETEVENTS_FAIL
	FDB_RESULT_AIO_INIT_FAIL              Error = C.FDB_RESULT_AIO_INIT_FAIL
	FDB_RESULT_AIO_NOT_SUPPORTED          Error = C.FDB_RESULT_AIO_NOT_SUPPORTED
	FDB_RESULT_AIO_SUBMIT_FAIL            Error = C.FDB_RESULT_AIO_SUBMIT_FAIL
	FDB_RESULT_ALLOC_FAIL                 Error = C.FDB_RESULT_ALLOC_FAIL
	FDB_RESULT_CHECKSUM_ERROR             Error = C.FDB_RESULT_CHECKSUM_ERROR
	FDB_RESULT_CLOSE_FAIL                 Error = C.FDB_RESULT_CLOSE_FAIL
	FDB_RESULT_COMMIT_FAIL                Error = C.FDB_RESULT_COMMIT_FAIL
	FDB_RESULT_COMPACTION_CANCELLATION    Error = C.FDB_RESULT_COMPACTION_CANCELLATION
	FDB_RESULT_COMPACTION_FAIL            Error = C.FDB_RESULT_COMPACTION_FAIL
	FDB_RESULT_COMPRESSION_FAIL           Error = C.FDB_RESULT_COMPRESSION_FAIL
	FDB_RESULT_CRYPTO_ERROR               Error = C.FDB_RESULT_CRYPTO_ERROR
	FDB_RESULT_EACCESS                    Error = C.FDB_RESULT_EACCESS
	FDB_RESULT_EAGAIN                     Error = C.FDB_RESULT_EAGAIN
	FDB_RESULT_EBADF                      Error = C.FDB_RESULT_EBADF
	FDB_RESULT_EEXIST                     Error = C.FDB_RESULT_EEXIST
	FDB_RESULT_EFAULT                     Error = C.FDB_RESULT_EFAULT
	FDB_RESULT_EFBIG                      Error = C.FDB_RESULT_EFBIG
	FDB_RESULT_EINVAL                     Error = C.FDB_RESULT_EINVAL
	FDB_RESULT_EIO                        Error = C.FDB_RESULT_EIO
	FDB_RESULT_EISDIR                     Error = C.FDB_RESULT_EISDIR
	FDB_RESULT_ELOOP                      Error = C.FDB_RESULT_ELOOP
	FDB_RESULT_EMFILE                     Error = C.FDB_RESULT_EMFILE
	FDB_RESULT_ENAMETOOLONG               Error = C.FDB_RESULT_ENAMETOOLONG
	FDB_RESULT_ENFILE                     Error = C.FDB_RESULT_ENFILE
	FDB_RESULT_ENOBUFS                    Error = C.FDB_RESULT_ENOBUFS
	FDB_RESULT_ENODEV                     Error = C.FDB_RESULT_ENODEV
	FDB_RESULT_ENOMEM                     Error = C.FDB_RESULT_ENOMEM
	FDB_RESULT_ENOSPC                     Error = C.FDB_RESULT_ENOSPC
	FDB_RESULT_ENOTDIR                    Error = C.FDB_RESULT_ENOTDIR
	FDB_RESULT_ENXIO                      Error = C.FDB_RESULT_ENXIO
	FDB_RESULT_EOPNOTSUPP                 Error = C.FDB_RESULT_EOPNOTSUPP
	FDB_RESULT_EOVERFLOW                  Error = C.FDB_RESULT_EOVERFLOW
	FDB_RESULT_EPERM                      Error = C.FDB_RESULT_EPERM
	FDB_RESULT_EROFS                      Error = C.FDB_RESULT_EROFS
	FDB_RESULT_FAIL_BY_COMPACTION         Error = C.FDB_RESULT_FAIL_BY_COMPACTION
	FDB_RESULT_FAIL_BY_ROLLBACK           Error = C.FDB_RESULT_FAIL_BY_ROLLBACK
	FDB_RESULT_FAIL_BY_TRANSACTION        Error = C.FDB_RESULT_FAIL_BY_TRANSACTION
	FDB_RESULT_FILE_CORRUPTION            Error = C.FDB_RESULT_FILE_CORRUPTION
	FDB_RESULT_FILE_IS_BUSY               Error = C.FDB_RESULT_FILE_IS_BUSY
	FDB_RESULT_FILE_NOT_OPEN              Error = C.FDB_RESULT_FILE_NOT_OPEN
	FDB_RESULT_FILE_REMOVE_FAIL           Error = C.FDB_RESULT_FILE_REMOVE_FAIL
	FDB_RESULT_FILE_RENAME_FAIL           Error = C.FDB_RESULT_FILE_RENAME_FAIL
	FDB_RESULT_FILE_VERSION_NOT_SUPPORTED Error = C.FDB_RESULT_FILE_VERSION_NOT_SUPPORTED
	FDB_RESULT_FSYNC_FAIL                 Error = C.FDB_RESULT_FSYNC_FAIL
	FDB_RESULT_HANDLE_BUSY                Error = C.FDB_RESULT_HANDLE_BUSY
	FDB_RESULT_INVALID_ARGS               Error = C.FDB_RESULT_INVALID_ARGS
	FDB_RESULT_INVALID_CMP_FUNCTION       Error = C.FDB_RESULT_INVALID_CMP_FUNCTION
	FDB_RESULT_INVALID_COMPACTION_MODE    Error = C.FDB_RESULT_INVALID_COMPACTION_MODE
	FDB_RESULT_INVALID_CONFIG             Error = C.FDB_RESULT_INVALID_CONFIG
	FDB_RESULT_INVALID_HANDLE             Error = C.FDB_RESULT_INVALID_HANDLE
	FDB_RESULT_INVALID_KV_INSTANCE_NAME   Error = C.FDB_RESULT_INVALID_KV_INSTANCE_NAME
	FDB_RESULT_IN_USE_BY_COMPACTOR        Error = C.FDB_RESULT_IN_USE_BY_COMPACTOR
	FDB_RESULT_ITERATOR_FAIL              Error = C.FDB_RESULT_ITERATOR_FAIL
	FDB_RESULT_KEY_NOT_FOUND              Error = C.FDB_RESULT_KEY_NOT_FOUND
	FDB_RESULT_KV_STORE_BUSY              Error = C.FDB_RESULT_KV_STORE_BUSY
	FDB_RESULT_KV_STORE_NOT_FOUND         Error = C.FDB_RESULT_KV_STORE_NOT_FOUND
	FDB_RESULT_MANUAL_COMPACTION_FAIL     Error = C.FDB_RESULT_MANUAL_COMPACTION_FAIL
	FDB_RESULT_NO_DB_HEADERS              Error = C.FDB_RESULT_NO_DB_HEADERS
	FDB_RESULT_NO_DB_INSTANCE             Error = C.FDB_RESULT_NO_DB_INSTANCE
	FDB_RESULT_NO_SUCH_FILE               Error = C.FDB_RESULT_NO_SUCH_FILE
	FDB_RESULT_OPEN_FAIL                  Error = C.FDB_RESULT_OPEN_FAIL
	FDB_RESULT_READ_FAIL                  Error = C.FDB_RESULT_READ_FAIL
	FDB_RESULT_RONLY_VIOLATION            Error = C.FDB_RESULT_RONLY_VIOLATION
	FDB_RESULT_SB_INIT_FAIL               Error = C.FDB_RESULT_SB_INIT_FAIL
	FDB_RESULT_SB_RACE_CONDITION          Error = C.FDB_RESULT_SB_RACE_CONDITION
	FDB_RESULT_SB_READ_FAIL               Error = C.FDB_RESULT_SB_READ_FAIL
	FDB_RESULT_SEEK_FAIL                  Error = C.FDB_RESULT_SEEK_FAIL
	FDB_RESULT_SUCCESS                    Error = C.FDB_RESULT_SUCCESS
	FDB_RESULT_TOO_BIG_BUFFER_CACHE       Error = C.FDB_RESULT_TOO_BIG_BUFFER_CACHE
	FDB_RESULT_TOO_LONG_FILENAME          Error = C.FDB_RESULT_TOO_LONG_FILENAME
	FDB_RESULT_TRANSACTION_FAIL           Error = C.FDB_RESULT_TRANSACTION_FAIL
	FDB_RESULT_WRITE_FAIL                 Error = C.FDB_RESULT_WRITE_FAIL
)

func (Error) Error

func (e Error) Error() string

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) CancelCompact

func (f *File) CancelCompact() error

CancelCompact cancels in-progress compaction

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) Destroy

func (l *File) Destroy()

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) GetFileVersion

func (f *File) GetFileVersion() uint8

func (*File) GetLatencyStats

func (f *File) GetLatencyStats() (string, error)

func (*File) Info

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

DbInfo returns the information about a given database handle

func (*File) Init

func (l *File) Init()

func (*File) Lock

func (l *File) Lock()

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) SetBlockReuseParams

func (f *File) SetBlockReuseParams(reuseThreshold uint8, numKeepHeaders uint8) error

This function will not hold advisory lock. According to Chiyoung, this simply sets the configs for a given file instance inside ForestDB, therefore: 1) it use the same file handle for writer 2) does not have to pause writer or compactor for reference: https://issues.couchbase.com/browse/MB-17384

func (*File) Unlock

func (l *File) Unlock()

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 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 KVStore

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

KVStore handle

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) Destroy

func (l *KVStore) Destroy()

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) Info

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

Info returns the information about a given kvstore

func (*KVStore) Init

func (l *KVStore) Init()

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) Lock

func (l *KVStore) Lock()

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) SnapshotClone

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

SnapshotClone clones a snapshot of a database file in ForestDB It is expected that the kvstore is only used for cloning so that it is possible not to retain lock.

func (*KVStore) SnapshotOpen

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

SnapshotOpen creates an snapshot of a database file in ForestDB

func (*KVStore) Unlock

func (l *KVStore) Unlock()

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 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) 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