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
- Variables
- type KV
- type Options
- func (opts *Options) WithCacheSize(cacheSize int) *Options
- func (opts *Options) WithFileMode(fileMode os.FileMode) *Options
- func (opts *Options) WithFileSize(fileSize int) *Options
- func (opts *Options) WithFlushThld(flushThld int) *Options
- func (opts *Options) WithKeyHistorySpace(keyHistorySpace int) *Options
- func (opts *Options) WithMaxActiveSnapshots(maxActiveSnapshots int) *Options
- func (opts *Options) WithMaxNodeSize(maxNodeSize int) *Options
- func (opts *Options) WithReadOnly(readOnly bool) *Options
- func (opts *Options) WithRenewSnapRootAfter(renewSnapRootAfter time.Duration) *Options
- func (opts *Options) WithSynced(synced bool) *Options
- type Reader
- type ReaderSpec
- type Snapshot
- func (s *Snapshot) Close() error
- func (s *Snapshot) Get(key []byte) (value []byte, ts uint64, err error)
- func (s *Snapshot) GetTs(key []byte, limit int64) (ts []uint64, err error)
- func (s *Snapshot) Reader(spec *ReaderSpec) (*Reader, error)
- func (s *Snapshot) Ts() uint64
- func (s *Snapshot) WriteTo(w io.Writer, writeOpts *WriteOpts) (off int64, tw int64, err error)
- type TBtree
- func (t *TBtree) BulkInsert(kvs []*KV) error
- func (t *TBtree) Close() error
- func (t *TBtree) DumpTo(path string, onlyMutated bool, fileSize int, fileMode os.FileMode) error
- func (t *TBtree) Flush() (int64, error)
- func (t *TBtree) Get(key []byte) (value []byte, ts uint64, err error)
- func (t *TBtree) GetTs(key []byte, limit int64) (ts []uint64, err error)
- func (t *TBtree) Insert(key []byte, value []byte) error
- func (t *TBtree) Snapshot() (*Snapshot, error)
- func (t *TBtree) SnapshotSince(ts uint64) (*Snapshot, error)
- func (t *TBtree) Sync() error
- func (t *TBtree) Ts() uint64
- type WriteOpts
Constants ¶
const ( InnerNodeType = iota LeafNodeType )
const ( MetaVersion = "VERSION" MetaMaxNodeSize = "MAX_NODE_SIZE" MetaKeyHistorySize = "KEY_HISTORY_SPACE" )
const DefaultCacheSize = 10000
const DefaultFileMode = os.FileMode(0755)
const DefaultFileSize = 1 << 26 // 64Mb
const DefaultFlushThld = 100_000
const DefaultKeyHistorySpace = 32 // ts trace len per key, number of key updates traced within a same key and leaf node
const DefaultMaxActiveSnapshots = 100
const DefaultMaxNodeSize = 4096
const DefaultRenewSnapRootAfter = time.Duration(1000) * time.Millisecond
const MinCacheSize = 1
const MinNodeSize = 96
const Version = 1
Variables ¶
var ErrAlreadyClosed = errors.New("already closed")
var ErrCorruptedCLog = errors.New("commit log is corrupted")
var ErrCorruptedFile = errors.New("file is corrupted")
var ErrIllegalArguments = errors.New("illegal arguments")
var ErrIllegalState = errors.New("illegal state")
var ErrKeyNotFound = errors.New("key not found")
var ErrNoMoreEntries = errors.New("no more entries")
var ErrReadersNotClosed = errors.New("readers not closed")
var ErrReadingFileContent = errors.New("error reading required file content")
var ErrSnapshotsNotClosed = errors.New("snapshots not closed")
var ErrorMaxKVLenExceeded = errors.New("max kv length exceeded")
var ErrorPathIsNotADirectory = errors.New("path is not a directory")
var ErrorToManyActiveSnapshots = errors.New("max active snapshots limit reached")
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
func DefaultOptions ¶
func DefaultOptions() *Options
func (*Options) WithCacheSize ¶
func (*Options) WithFileSize ¶
func (*Options) WithFlushThld ¶
func (*Options) WithKeyHistorySpace ¶
func (*Options) WithMaxActiveSnapshots ¶
func (*Options) WithMaxNodeSize ¶
func (*Options) WithReadOnly ¶
func (*Options) WithRenewSnapRootAfter ¶
func (*Options) WithSynced ¶
type ReaderSpec ¶
type TBtree ¶
type TBtree struct {
// contains filtered or unexported fields
}
TBTree implements a timed-btree
func OpenWith ¶
func OpenWith(nLog, cLog appendable.Appendable, opts *Options) (*TBtree, error)