Documentation ¶
Overview ¶
Copyright 2021 CodeNotary, Inc. All rights reserved.
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 2021 CodeNotary, Inc. All rights reserved.
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 2021 CodeNotary, Inc. All rights reserved.
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 2021 CodeNotary, Inc. All rights reserved.
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 2021 CodeNotary, Inc. All rights reserved.
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 AppFactoryFunc
- type HistoryReader
- type HistoryReaderSpec
- type KV
- type Options
- func (opts *Options) WithAppFactory(appFactory AppFactoryFunc) *Options
- func (opts *Options) WithCacheSize(cacheSize int) *Options
- func (opts *Options) WithCompactionThld(compactionThld int) *Options
- func (opts *Options) WithDelayDuringCompaction(delay time.Duration) *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) WithLog(log logger.Logger) *Options
- func (opts *Options) WithMaxActiveSnapshots(maxActiveSnapshots int) *Options
- func (opts *Options) WithMaxKeyLen(maxKeyLen 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) ExistKeyWith(prefix []byte, neq []byte) (bool, error)
- func (s *Snapshot) Get(key []byte) (value []byte, ts uint64, hc uint64, err error)
- func (s *Snapshot) History(key []byte, offset uint64, descOrder bool, limit int) (tss []uint64, err error)
- func (s *Snapshot) NewHistoryReader(spec *HistoryReaderSpec) (*HistoryReader, error)
- func (s *Snapshot) NewReader(spec *ReaderSpec) (r *Reader, err error)
- func (s *Snapshot) Set(key, value []byte) error
- func (s *Snapshot) Ts() uint64
- func (s *Snapshot) WriteTo(nw, hw io.Writer, writeOpts *WriteOpts) (nOff int64, wN, wH int64, err error)
- type TBtree
- func (t *TBtree) BulkInsert(kvs []*KV) error
- func (t *TBtree) Close() error
- func (t *TBtree) Compact() (uint64, error)
- func (t *TBtree) ExistKeyWith(prefix []byte, neq []byte) (bool, error)
- func (t *TBtree) Flush() (wN, wH int64, err error)
- func (t *TBtree) Get(key []byte) (value []byte, ts uint64, hc uint64, err error)
- func (t *TBtree) GetOptions() *Options
- func (t *TBtree) History(key []byte, offset uint64, descOrder bool, limit int) (tss []uint64, err error)
- func (t *TBtree) Insert(key []byte, value []byte) error
- func (t *TBtree) Snapshot() (*Snapshot, error)
- func (t *TBtree) SnapshotCount() (uint64, 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" )
const DefaultCacheSize = 100_000
const DefaultCompactionThld = 2
const DefaultFileMode = os.FileMode(0755)
const DefaultFileSize = 1 << 26 // 64Mb
const DefaultFlushThld = 100_000
const DefaultMaxActiveSnapshots = 100
const DefaultMaxKeyLen = 1024
const DefaultMaxNodeSize = 4096
const DefaultRenewSnapRootAfter = time.Duration(1000) * time.Millisecond
const MinCacheSize = 1
const MinNodeSize = 128
const Version = 1
Variables ¶
var ErrAlreadyClosed = errors.New("index already closed")
var ErrCompactAlreadyInProgress = errors.New("compact already in progress")
var ErrCompactionThresholdNotReached = errors.New("compaction threshold not yet reached")
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 ErrOffsetOutOfRange = errors.New("offset out of range")
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 AppFactoryFunc ¶ added in v1.0.5
type AppFactoryFunc func( rootPath string, subPath string, opts *multiapp.Options, ) (appendable.Appendable, error)
type HistoryReader ¶ added in v0.9.1
type HistoryReader struct {
// contains filtered or unexported fields
}
func (*HistoryReader) Close ¶ added in v0.9.1
func (r *HistoryReader) Close() error
func (*HistoryReader) Read ¶ added in v0.9.1
func (r *HistoryReader) Read() (tss []uint64, err error)
type HistoryReaderSpec ¶ added in v0.9.1
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
func DefaultOptions ¶
func DefaultOptions() *Options
func (*Options) WithAppFactory ¶ added in v1.0.5
func (opts *Options) WithAppFactory(appFactory AppFactoryFunc) *Options
func (*Options) WithCacheSize ¶
func (*Options) WithCompactionThld ¶ added in v0.9.2
func (*Options) WithDelayDuringCompaction ¶ added in v0.9.2
func (*Options) WithFileSize ¶
func (*Options) WithFlushThld ¶
func (*Options) WithMaxActiveSnapshots ¶
func (*Options) WithMaxKeyLen ¶ added in v0.9.1
func (*Options) WithMaxNodeSize ¶
func (*Options) WithReadOnly ¶
func (*Options) WithRenewSnapRootAfter ¶
func (*Options) WithSynced ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
func (*Reader) ReadAsBefore ¶ added in v1.0.0
type ReaderSpec ¶
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
func (*Snapshot) ExistKeyWith ¶ added in v1.2.0
func (*Snapshot) NewHistoryReader ¶ added in v0.9.1
func (s *Snapshot) NewHistoryReader(spec *HistoryReaderSpec) (*HistoryReader, error)
type TBtree ¶
type TBtree struct {
// contains filtered or unexported fields
}
TBTree implements a timed-btree
func OpenWith ¶
func OpenWith(path string, nLog, hLog, cLog appendable.Appendable, opts *Options) (*TBtree, error)
func (*TBtree) BulkInsert ¶
func (*TBtree) ExistKeyWith ¶ added in v1.0.0
func (*TBtree) GetOptions ¶ added in v0.9.1
func (*TBtree) SnapshotCount ¶ added in v1.0.5
SnapshotCount returns the number of stored snapshots Note: snapshotCount(compact(t)) = 1