table

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxKeyLength   = 256
	MetadataLength = 29
)
View Source
const (
	ReadWriteState = State(iota + 1)
	ReadOnlyState
	RecycledState
)

Variables

View Source
var (
	ErrNotEnoughSpace = errors.New("not enough space")
	ErrHKeyNotFound   = errors.New("hkey not found")
)

Functions

func Encode

func Encode(t *Table) ([]byte, error)

Types

type Pack

type Pack struct {
	Offset      uint64
	Allocated   uint64
	Inuse       uint64
	Garbage     uint64
	RecycledAt  int64
	State       State
	HKeys       map[uint64]uint64
	OffsetIndex []byte
	Memory      []byte
}

type State

type State uint8

type Stats

type Stats struct {
	Allocated  uint64
	Inuse      uint64
	Garbage    uint64
	Length     int
	RecycledAt int64
}

type Table

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

func Decode

func Decode(data []byte) (*Table, error)

func New

func New(size uint64) *Table

func (*Table) Check

func (t *Table) Check(hkey uint64) bool

func (*Table) Coefficient

func (t *Table) Coefficient() uint64

func (*Table) Delete

func (t *Table) Delete(hkey uint64) error

func (*Table) Get

func (t *Table) Get(hkey uint64) (storage.Entry, error)

func (*Table) GetKey

func (t *Table) GetKey(hkey uint64) (string, error)

func (*Table) GetLastAccess

func (t *Table) GetLastAccess(hkey uint64) (int64, error)

func (*Table) GetRaw

func (t *Table) GetRaw(hkey uint64) ([]byte, error)

func (*Table) GetRawKey

func (t *Table) GetRawKey(hkey uint64) ([]byte, error)

func (*Table) GetTTL

func (t *Table) GetTTL(hkey uint64) (int64, error)

func (*Table) Put

func (t *Table) Put(hkey uint64, value storage.Entry) error

In-memory layout for entry:

KEY-LENGTH(uint8) | KEY(bytes) | TTL(uint64) | TIMESTAMP(uint64) | LASTACCESS(uint64) | VALUE-LENGTH(uint64) | VALUE(bytes)

func (*Table) PutRaw

func (t *Table) PutRaw(hkey uint64, value []byte) error

func (*Table) Range

func (t *Table) Range(f func(hkey uint64, e storage.Entry) bool)

func (*Table) RangeHKey

func (t *Table) RangeHKey(f func(hkey uint64) bool)

func (*Table) Reset

func (t *Table) Reset()

func (*Table) Scan

func (t *Table) Scan(cursor uint64, count int, f func(e storage.Entry) bool) (uint64, error)

func (*Table) ScanRegexMatch

func (t *Table) ScanRegexMatch(cursor uint64, expr string, count int, f func(e storage.Entry) bool) (uint64, error)

func (*Table) SetCoefficient

func (t *Table) SetCoefficient(cf uint64)

func (*Table) SetState

func (t *Table) SetState(s State)

func (*Table) State

func (t *Table) State() State

func (*Table) Stats

func (t *Table) Stats() Stats

func (*Table) UpdateTTL

func (t *Table) UpdateTTL(hkey uint64, value storage.Entry) error

Jump to

Keyboard shortcuts

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