db

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2017 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OperationPut represents put operation
	OperationPut uint = iota
	// OperationDelete represents delete operation
	OperationDelete
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockchainDB

type BlockchainDB struct {
	DB *gorocksdb.DB
	// contains filtered or unexported fields
}

BlockchainDB encapsulates rocksdb's structures

func GetDBInstance

func GetDBInstance() *BlockchainDB

GetDBInstance returns db instance

func NewDB

func NewDB(c *Config) *BlockchainDB

NewDB returns a basic db instance

func (*BlockchainDB) AtomicWrite

func (blockchainDB *BlockchainDB) AtomicWrite(writeBatchs []*WriteBatch) error

AtomicWrite writes batch

func (*BlockchainDB) Close

func (blockchainDB *BlockchainDB) Close()

Close releases all column family handles and closes rocksdb

func (*BlockchainDB) Delete

func (blockchainDB *BlockchainDB) Delete(cfName string, key []byte) error

Delete deletes the given key in the specified column family

func (*BlockchainDB) Get

func (blockchainDB *BlockchainDB) Get(cfName string, key []byte) ([]byte, error)

Get returns the value for the given column family and key

func (*BlockchainDB) GetByPrefix

func (blockchainDB *BlockchainDB) GetByPrefix(prefix []byte, resCh chan map[string][]byte)

GetByPrefix for bulk reads

func (*BlockchainDB) Put

func (blockchainDB *BlockchainDB) Put(cfName string, key []byte, value []byte) error

Put saves the key/value in the given column family

type CfHandlerMap

type CfHandlerMap map[string]*gorocksdb.ColumnFamilyHandle

CfHandlerMap is columnfamilies handler set

type Config

type Config struct {
	DbPath            string
	Columnfamilies    []string
	KeepLogFileNumber int
	MaxLogFileSize    int
	LogLevel          string
}

Config is the configuration of the gorocksdb

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig defines the default configuration of the rocksdb

type WriteBatch

type WriteBatch struct {
	CfName    string
	Operation uint
	Key       []byte
	Value     []byte
}

WriteBatch wrappers batch operation

func NewWriteBatch

func NewWriteBatch(cfName string, operation uint, key, value []byte) *WriteBatch

NewWriteBatch returns a writebatch instance

Jump to

Keyboard shortcuts

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