zdbpool

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const Prefix = "zdb"

Prefix is a string used as prefix in the filesystem volume used to storge 0-db namespaces

Variables

This section is empty.

Functions

func WriteHeader

func WriteHeader(w io.Writer, h Header) error

WriteHeader writes header data to writer

Types

type Header struct {
	Version  uint32
	Name     string
	Password string
	MaxSize  uint64
}

Header is the namespace header

func ReadHeader

func ReadHeader(r io.Reader) (header Header, err error)

ReadHeader reands namespace header

type IndexHeader

type IndexHeader struct {
	Magic   [4]byte   // four bytes magic bytes to recognize the file
	Version uint32    // file version, for possible upgrade compatibility
	Created uint64    // unix timestamp of creation time
	Opened  uint64    // unix timestamp of last opened time
	Fileid  uint16    // current index file id (sync with dataid)
	Mode    IndexMode // running mode when index was create
}

IndexHeader is the structure contains information about an index adapted from https://github.com/threefoldtech/0-db/blob/development/libzdb/index.h#L31

func ReadIndex

func ReadIndex(r io.Reader) (header IndexHeader, err error)

ReadIndex reads index header

type IndexMode

type IndexMode uint8

IndexMode represens the mode in which the 0-db is running Adapted from https://github.com/threefoldtech/0-db/blob/development/libzdb/index.h#L4

const (
	IndexModeKeyValue    IndexMode = 0
	IndexModeSequential  IndexMode = 1
	IndexModeDirectKey   IndexMode = 2
	IndexModeDirectBlock IndexMode = 3
)

Enum values for IndexMode

func (IndexMode) String

func (i IndexMode) String() string

type NSInfo

type NSInfo struct {
	Name string
	Size uint64
}

NSInfo is a struct containing information about a 0-db namespace

type ZDBPool

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

ZDBPool represent a part of a disk that is reserved to store 0-db data

func New

func New(path string) ZDBPool

New creates a ZDBPool with path

func (*ZDBPool) Create

func (p *ZDBPool) Create(name, password string, size uint64) error

Create a namespace. Note that this create only reserve the name space size (and create namespace descriptor) this must be followed by an actual zdb NSNEW call to create the database files.

func (*ZDBPool) Exists

func (p *ZDBPool) Exists(name string) bool

Exists checks if a namespace exists in the pool or not this method is way faster then using Namespaces cause it doesn't have to read any data

func (*ZDBPool) IndexMode

func (p *ZDBPool) IndexMode(name string) (mode IndexMode, err error)

IndexMode return the mode of the index of the namespace called name

func (*ZDBPool) Namespace

func (p *ZDBPool) Namespace(name string) (info NSInfo, err error)

Namespace gets a namespace info from pool

func (*ZDBPool) Namespaces

func (p *ZDBPool) Namespaces() ([]NSInfo, error)

Namespaces returns a list of NSinfo of all the namespace present in the pool

func (*ZDBPool) Reserved

func (p *ZDBPool) Reserved() (uint64, error)

Reserved return the amount of storage that has been reserved by all the namespace in the pool

Jump to

Keyboard shortcuts

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