cdb

package
v0.0.0-...-5fbb372 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2019 License: LGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright (C) 2018 go-gamc authors

This file is part of the go-gamc library.

the go-gamc library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

the go-gamc library 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 GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the go-gamc library. If not, see <http://www.gnu.org/licenses/>.

This file is part of the go-gamc library.

the go-gamc library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

the go-gamc library 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 GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the go-gamc library. If not, see <http://www.gnu.org/licenses/>.

This file is part of the go-gamc library.

the go-gamc library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

the go-gamc library 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 GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the go-gamc library. If not, see <http://www.gnu.org/licenses/>.

This file is part of the go-gamc library.

the go-gamc library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

the go-gamc library 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 GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the go-gamc library. If not, see <http://www.gnu.org/licenses/>.

This file is part of the go-gamc library.

the go-gamc library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

the go-gamc library 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 GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the go-gamc library. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

View Source
const IdealBatchSize = 100 * 1024 //
View Source
const (
	TypeLevelDB = "levelDB"
)

Variables

View Source
var (
	ErrBucketNotExist = errors.New("bucket does not exist")
	ErrKeyNotExist    = errors.New("key does not exist")
)
View Source
var (
	ErrKeyNotFound = errors.New("not found")
)

Functions

func NewgamcDB

func NewgamcDB(filename string) (*gamcDB, error)

Types

type Batcher

type Batcher interface {
	ValueSize() int
	// EnableBatch enable batch write.
	EnableBatch()
	// DisableBatch disable batch write.
	DisableBatch()
	Flush() error
}

type Compacter

type Compacter interface {
	Compact(start []byte, limit []byte) error
}

type Database

type Database struct {
	Db Storage
}

func (*Database) Close

func (d *Database) Close() error

func (*Database) Delete

func (d *Database) Delete(key []byte) error

func (*Database) DisableBatch

func (d *Database) DisableBatch()

func (*Database) EnableBatch

func (d *Database) EnableBatch()

func (*Database) Flush

func (d *Database) Flush() error

func (*Database) Get

func (d *Database) Get(key []byte) ([]byte, error)

func (*Database) Has

func (d *Database) Has(key []byte) (bool, error)

func (*Database) Put

func (d *Database) Put(key, value []byte) error

func (*Database) ValueSize

func (d *Database) ValueSize() int

type DbConfig

type DbConfig struct {
	DbType      string `yaml:"db_type"`
	EnableBatch bool   `yaml:"enable_batch"`
	DbDir       string `yaml:"db_dir"`
}

func GetDbConfig

func GetDbConfig(config *config.Config) *DbConfig

func NewDefaultDbConfig

func NewDefaultDbConfig() *DbConfig

type Iteratee

type Iteratee interface {
	NewIterator() Iterator
	NewIteratorWithPrefix(prefix []byte) Iterator
}

type Iterator

type Iterator interface {
	Next() bool
	Error() error
	Key() []byte
	Value() []byte
	Release()
}

type LevelDB

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

func NewLevelDB

func NewLevelDB(dbcfg *DbConfig, cache int, handles int) (*LevelDB, error)

func (*LevelDB) Close

func (db *LevelDB) Close() error

func (*LevelDB) Compact

func (db *LevelDB) Compact(start []byte, limit []byte) error

func (*LevelDB) Delete

func (db *LevelDB) Delete(key []byte) error

func (*LevelDB) DisableBatch

func (db *LevelDB) DisableBatch()

func (*LevelDB) EnableBatch

func (db *LevelDB) EnableBatch()

func (*LevelDB) Flush

func (db *LevelDB) Flush() error

func (*LevelDB) Get

func (db *LevelDB) Get(key []byte) ([]byte, error)

func (*LevelDB) Has

func (db *LevelDB) Has(key []byte) (bool, error)

func (*LevelDB) NewIterator

func (db *LevelDB) NewIterator() Iterator

func (*LevelDB) NewIteratorWithPrefix

func (db *LevelDB) NewIteratorWithPrefix(prefix []byte) Iterator

func (*LevelDB) Put

func (db *LevelDB) Put(key, value []byte) error

func (*LevelDB) ValueSize

func (db *LevelDB) ValueSize() int

type MemoryBatch

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

MemoryBatch do batch task in memory storage

type MemoryDB

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

MemoryDB the nodes in trie.

func NewMemoryStorage

func NewMemoryStorage() (*MemoryDB, error)

NewMemoryStorage init a storage

func (*MemoryDB) Close

func (db *MemoryDB) Close() error

func (*MemoryDB) Del

func (db *MemoryDB) Del(key []byte) error

Del delete the key in Storage.

func (*MemoryDB) Delete

func (db *MemoryDB) Delete(key []byte) error

func (*MemoryDB) DisableBatch

func (db *MemoryDB) DisableBatch()

DisableBatch disable batch write.

func (*MemoryDB) EnableBatch

func (db *MemoryDB) EnableBatch()

EnableBatch enable batch write.

func (*MemoryDB) Flush

func (db *MemoryDB) Flush() error

Flush write and flush pending batch write.

func (*MemoryDB) Get

func (db *MemoryDB) Get(key []byte) ([]byte, error)

Get return value to the key in Storage

func (*MemoryDB) Has

func (db *MemoryDB) Has(key []byte) (bool, error)

func (*MemoryDB) Put

func (db *MemoryDB) Put(key []byte, value []byte) error

Put put the key-value entry to Storage

func (*MemoryDB) ValueSize

func (db *MemoryDB) ValueSize() int

type Reader

type Reader interface {
	Has(key []byte) (bool, error)
	Get(key []byte) ([]byte, error)
}

type Stater

type Stater interface {
	Stat(property string) (string, error)
}

type Storage

type Storage interface {
	Reader
	Writer
	Close() error
	Batcher
}

func NewDB

func NewDB(config *config.Config) (Storage, error)

type Writer

type Writer interface {
	Delete(key []byte) error
	Put(key, value []byte) error
}

Jump to

Keyboard shortcuts

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