db

package
v0.0.0-...-c9d2d86 Latest Latest
Warning

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

Go to latest
Published: May 25, 2018 License: ISC Imports: 6 Imported by: 0

Documentation

Overview

Copyright (C) 2017, Zipper Team. All rights reserved.

This file is part of zipper

The zipper is free software: you can use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

The zipper is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ISC License for more details.

You should have received a copy of the ISC License along with this program. If not, see <https://opensource.org/licenses/isc>.

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(cfName string, prefix []byte) []*KeyValue

GetByPrefix for bulk reads

func (*BlockchainDB) GetByRange

func (blockchainDB *BlockchainDB) GetByRange(cfName string, startkey []byte, limitKey []byte) []*KeyValue

GetByRange Range query

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 KeyValue

type KeyValue struct {
	Key   []byte
	Value []byte
}

KeyValue key value

type WriteBatch

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

WriteBatch wrappers batch operation

func NewWriteBatch

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

NewWriteBatch returns a writebatch instance

Jump to

Keyboard shortcuts

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