store

package
v0.0.0-...-7f70f2e Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MaxSegmentSize = 1024 * 1024 * 1024 * 1024

Variables

View Source
var BlockTypeNameMap = map[BlockType]string{
	TypeUndefined: "Undefined",
	TypeCommit:    "Commit",
	TypeDataLeaf:  "DataLeaf",
	TypeDataNode:  "DataNode",
	TypeBTreeNode: "BTreeNode",
}
View Source
var ErrBlockNotFound = errors.New("block not found")

Functions

This section is empty.

Types

type Address

type Address uint64
const NilAddress Address = 0

type BlockReader

type BlockReader []byte

func NewBlockReader

func NewBlockReader(data []byte) (BlockReader, error)

func (BlockReader) BlockSize

func (s BlockReader) BlockSize() uint64

func (BlockReader) GetChildAddress

func (s BlockReader) GetChildAddress(i int) Address

func (BlockReader) GetData

func (s BlockReader) GetData() []byte

func (BlockReader) GetLowestDescendentAddress

func (s BlockReader) GetLowestDescendentAddress() Address

func (BlockReader) GetUsedDataSize

func (s BlockReader) GetUsedDataSize() uint64

func (BlockReader) NumberOfChildren

func (s BlockReader) NumberOfChildren() int

func (BlockReader) String

func (s BlockReader) String() string

func (BlockReader) Type

func (s BlockReader) Type() BlockType

type BlockType

type BlockType byte
const (
	TypeUndefined BlockType = iota
	TypeCommit
	TypeDataLeaf
	TypeDataNode
	TypeBTreeNode
)

func (BlockType) String

func (s BlockType) String() string

type BlockWriter

type BlockWriter struct {
	BlockReader
	Data []byte
	Address
	// contains filtered or unexported fields
}

func (BlockWriter) SetChild

func (w BlockWriter) SetChild(i int, addr Address) error

type ReadTransaction

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

func (*ReadTransaction) GetBlock

func (r *ReadTransaction) GetBlock(a Address) (BlockReader, error)

type Reader

type Reader interface {
	GetBlock(a Address) (BlockReader, error)
}

type ReaderWriter

type ReaderWriter interface {
	Reader
	Writer
}

type Store

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

func Open

func Open(dir string) (*Store, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) GetBlock

func (s *Store) GetBlock(a Address) (BlockReader, error)

func (*Store) NewReadTransaction

func (s *Store) NewReadTransaction() *ReadTransaction

func (*Store) NewWriteTransaction

func (s *Store) NewWriteTransaction(ctx context.Context) (*WriteTransaction, Address, error)

func (*Store) PrintStats

func (s *Store) PrintStats()

type WriteTransaction

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

func (*WriteTransaction) AppendBlock

func (w *WriteTransaction) AppendBlock(blockType BlockType, numberOfChildren int, dataSize int) (BlockWriter, error)

func (*WriteTransaction) Commit

func (w *WriteTransaction) Commit(a Address) (newRoot Address, err error)

func (*WriteTransaction) GetBlock

func (w *WriteTransaction) GetBlock(a Address) (BlockReader, error)

func (*WriteTransaction) Rollback

func (w *WriteTransaction) Rollback() error

type Writer

type Writer interface {
	AppendBlock(blockType BlockType, numberOfChildren int, dataSize int) (BlockWriter, error)
}

Jump to

Keyboard shortcuts

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