tbtree

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Copyright 2019-2020 vChain, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019-2020 vChain, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019-2020 vChain, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019-2020 vChain, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	InnerNodeType = iota
	LeafNodeType
)
View Source
const (
	MetaVersion        = "VERSION"
	MetaMaxNodeSize    = "MAX_NODE_SIZE"
	MetaKeyHistorySize = "KEY_HISTORY_SPACE"
)
View Source
const DefaultCacheSize = 10000
View Source
const DefaultFileMode = os.FileMode(0755)
View Source
const DefaultFileSize = 1 << 26 // 64Mb
View Source
const DefaultFlushThld = 100_000
View Source
const DefaultKeyHistorySpace = 32 // ts trace len per key, number of key updates traced within a same key and leaf node
View Source
const DefaultMaxActiveSnapshots = 100
View Source
const DefaultMaxNodeSize = 4096
View Source
const DefaultRenewSnapRootAfter = time.Duration(1000) * time.Millisecond
View Source
const MinCacheSize = 1
View Source
const MinNodeSize = 96
View Source
const Version = 1

Variables

View Source
var ErrAlreadyClosed = errors.New("already closed")
View Source
var ErrCorruptedCLog = errors.New("commit log is corrupted")
View Source
var ErrCorruptedFile = errors.New("file is corrupted")
View Source
var ErrIllegalArguments = errors.New("illegal arguments")
View Source
var ErrIllegalState = errors.New("illegal state")
View Source
var ErrKeyNotFound = errors.New("key not found")
View Source
var ErrNoMoreEntries = errors.New("no more entries")
View Source
var ErrReadersNotClosed = errors.New("readers not closed")
View Source
var ErrReadingFileContent = errors.New("error reading required file content")
View Source
var ErrSnapshotsNotClosed = errors.New("snapshots not closed")
View Source
var ErrorMaxKVLenExceeded = errors.New("max kv length exceeded")
View Source
var ErrorPathIsNotADirectory = errors.New("path is not a directory")
View Source
var ErrorToManyActiveSnapshots = errors.New("max active snapshots limit reached")

Functions

This section is empty.

Types

type KV

type KV struct {
	K []byte
	V []byte
}

type Options

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

func DefaultOptions

func DefaultOptions() *Options

func (*Options) WithCacheSize

func (opts *Options) WithCacheSize(cacheSize int) *Options

func (*Options) WithFileMode

func (opts *Options) WithFileMode(fileMode os.FileMode) *Options

func (*Options) WithFileSize

func (opts *Options) WithFileSize(fileSize int) *Options

func (*Options) WithFlushThld

func (opts *Options) WithFlushThld(flushThld int) *Options

func (*Options) WithKeyHistorySpace

func (opts *Options) WithKeyHistorySpace(keyHistorySpace int) *Options

func (*Options) WithMaxActiveSnapshots

func (opts *Options) WithMaxActiveSnapshots(maxActiveSnapshots int) *Options

func (*Options) WithMaxNodeSize

func (opts *Options) WithMaxNodeSize(maxNodeSize int) *Options

func (*Options) WithReadOnly

func (opts *Options) WithReadOnly(readOnly bool) *Options

func (*Options) WithRenewSnapRootAfter

func (opts *Options) WithRenewSnapRootAfter(renewSnapRootAfter time.Duration) *Options

func (*Options) WithSynced

func (opts *Options) WithSynced(synced bool) *Options

type Reader

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

func (*Reader) Close

func (r *Reader) Close() error

func (*Reader) Read

func (r *Reader) Read() (key []byte, value []byte, ts uint64, err error)

type ReaderSpec

type ReaderSpec struct {
	SeekKey       []byte
	Prefix        []byte
	InclusiveSeek bool
	DescOrder     bool
}

type Snapshot

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

func (*Snapshot) Close

func (s *Snapshot) Close() error

func (*Snapshot) Get

func (s *Snapshot) Get(key []byte) (value []byte, ts uint64, err error)

func (*Snapshot) GetTs

func (s *Snapshot) GetTs(key []byte, limit int64) (ts []uint64, err error)

func (*Snapshot) Reader

func (s *Snapshot) Reader(spec *ReaderSpec) (*Reader, error)

func (*Snapshot) Ts

func (s *Snapshot) Ts() uint64

func (*Snapshot) WriteTo

func (s *Snapshot) WriteTo(w io.Writer, writeOpts *WriteOpts) (off int64, tw int64, err error)

type TBtree

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

TBTree implements a timed-btree

func Open

func Open(path string, opts *Options) (*TBtree, error)

func OpenWith

func OpenWith(nLog, cLog appendable.Appendable, opts *Options) (*TBtree, error)

func (*TBtree) BulkInsert

func (t *TBtree) BulkInsert(kvs []*KV) error

func (*TBtree) Close

func (t *TBtree) Close() error

func (*TBtree) DumpTo

func (t *TBtree) DumpTo(path string, onlyMutated bool, fileSize int, fileMode os.FileMode) error

func (*TBtree) Flush

func (t *TBtree) Flush() (int64, error)

func (*TBtree) Get added in v0.9.0

func (t *TBtree) Get(key []byte) (value []byte, ts uint64, err error)

func (*TBtree) GetTs added in v0.9.0

func (t *TBtree) GetTs(key []byte, limit int64) (ts []uint64, err error)

func (*TBtree) Insert

func (t *TBtree) Insert(key []byte, value []byte) error

func (*TBtree) Snapshot

func (t *TBtree) Snapshot() (*Snapshot, error)

func (*TBtree) SnapshotSince added in v0.9.0

func (t *TBtree) SnapshotSince(ts uint64) (*Snapshot, error)

func (*TBtree) Sync

func (t *TBtree) Sync() error

func (*TBtree) Ts

func (t *TBtree) Ts() uint64

type WriteOpts

type WriteOpts struct {
	OnlyMutated bool
	BaseOffset  int64
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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