Documentation
¶
Index ¶
- Constants
- Variables
- func FindDbsInPath(path string) ([]string, error)
- func IngestSnapshot(conn *gosqlite.Conn, prefix string, version int64, ...) (*inode.Node, error)
- func NewIngestSnapshotConnection(snapshotDbPath string) (*gosqlite.Conn, error)
- func ToShardID(version int64) int64
- type BranchShardDelete
- type BranchShardInsert
- type BranchShardQuery
- type BranchShards
- type ConnPool
- type ConnectionType
- type DB
- func (sql *DB) Close() error
- func (sql *DB) DeleteVersionsTo(toVersion int64) error
- func (sql *DB) DeleteVersionsToSync(toVersion int64) error
- func (sql *DB) FinishImport() error
- func (sql *DB) GetConn() (db.ReadConn, error)
- func (sql *DB) GetHeightOneBranchesIteratorQuery(start, end int64) (stmt *gosqlite.Stmt, err error)
- func (sql *DB) GetLatestLeavesIterator(version int64, limit int) (*KVIterator, error)
- func (sql *DB) GetNode(nodePool *nodepool.NodePool, nodekey inode.NodeKey) (*inode.Node, error)
- func (sql *DB) GetValue(key []byte, version int64) ([]byte, error)
- func (sql *DB) HasRoot(version int64) (bool, error)
- func (sql *DB) ImportMostRecentSnapshot(targetVersion int64, traverseOrder constants.TraverseOrderType, ...) (*inode.Node, int64, error)
- func (sql *DB) ImportSnapshotFromTable(version int64, traverseOrder constants.TraverseOrderType, loadLeaves bool, ...) (*inode.Node, error)
- func (sql *DB) LatestVersion() (int64, error)
- func (sql *DB) LoadRoot(nodePool *nodepool.NodePool, version int64) (*inode.Node, error)
- func (sql *DB) Path() string
- func (sql *DB) PausePruning(pause bool)
- func (sql *DB) PrepareImport() error
- func (sql *DB) Readonly() db.ReadonlyDB
- func (sql *DB) Revert(toVersion int64) error
- func (sql *DB) SaveTree(version int64, root *inode.Node, updates *db.DirtyNodes) error
- func (sql *DB) Snapshot(ctx context.Context, tree ExpectedTree) error
- func (sql *DB) Type() db.Type
- func (sql *DB) WarmLeaves() error
- func (sql *DB) WriteBatch(importedNodes *db.DirtyNodes) error
- func (sql *DB) WriteSnapshot(ctx context.Context, version int64, nextFn func() (*SnapshotNode, error), ...) (*inode.Node, error)
- type ExpectedTree
- type IterPool
- type KVIterator
- type KVStore
- type Options
- type ReadConn
- func (c *ReadConn) Close() error
- func (c *ReadConn) Exec(stmt string, args ...any) error
- func (c *ReadConn) GetNode(pool *nodepool.NodePool, nodekey inode.NodeKey) (*inode.Node, error)
- func (c *ReadConn) GetValue(version int64, key []byte) ([]byte, error)
- func (c *ReadConn) IsBusy() bool
- func (c *ReadConn) Prepare(statement string, args ...any) (*gosqlite.Stmt, error)
- func (c *ReadConn) Refresh() error
- func (c *ReadConn) Release() error
- func (c *ReadConn) SetBusy()
- type ReadConnPool
- type SnapshotNode
- type SnapshotOptions
- type WriteBatch
- type WriteConn
- type WriteEventLoop
Constants ¶
View Source
const StmtCreateLeafTables = `` /* 318-byte string literal not displayed */
NOTE: we need leaf_idx, so we cannot use `WITHOUT ROWID` because leaf_idx must store the full PRIMARY KEY as their row reference
View Source
const StmtCreateTreeBranchShardTableFormat = `
CREATE TABLE tree_%d (version int, sequence int, bytes blob, orphaned bool, PRIMARY KEY (version, sequence)) WITHOUT ROWID;
`
NOTE: tree_%d should be filled
View Source
const StmtCreateTreeTables = `` /* 245-byte string literal not displayed */
Tables (two databases: branches and leaves)
View Source
const StmtInsertBranchOrphan = `
INSERT OR REPLACE INTO branch_orphan (version, sequence, at) VALUES (?, ?, ?)
`
View Source
const StmtInsertBranchShardFormat = `
INSERT OR REPLACE INTO tree_%d (version, sequence, bytes) VALUES (?, ?, ?)
`
NOTE: Every time we mutate node during balance/set/remove, touched branch nodes always get new node key. But Test_Replay will try to ingest nodes so we should allow REPLACE here.
View Source
const StmtInsertLeaf = `
INSERT OR REPLACE INTO leaf (version, sequence, key_hash, bytes) VALUES (?, ?, ?, ?)
`
View Source
const StmtInsertLeafOrphan = `
INSERT OR REPLACE INTO leaf_orphan (version, sequence, at) VALUES (?, ?, ?)
`
View Source
const StmtInsertRoot = `
INSERT OR REPLACE INTO root(version, node_version, node_sequence, bytes) VALUES (?, ?, ?, ?)
`
Insert
Variables ¶
View Source
var ErrorExportDone = errors.New("export done")
Functions ¶
func FindDbsInPath ¶
func IngestSnapshot ¶
Types ¶
type BranchShardDelete ¶
type BranchShardDelete struct {
// contains filtered or unexported fields
}
func PrepareBranchShardDelete ¶
func PrepareBranchShardDelete(_ *WriteConn, _ *BranchShards) (*BranchShardDelete, error)
func (*BranchShardDelete) Close ¶
func (sd *BranchShardDelete) Close() error
func (*BranchShardDelete) Exec ¶
func (sd *BranchShardDelete) Exec(version int64, sequence int) error
func (*BranchShardDelete) PrepareVersion ¶
func (sd *BranchShardDelete) PrepareVersion(sql *WriteConn, version int64) error
func (*BranchShardDelete) Reset ¶
func (sd *BranchShardDelete) Reset() error
type BranchShardInsert ¶
type BranchShardInsert struct {
// contains filtered or unexported fields
}
func PrepareBranchShardInsert ¶
func PrepareBranchShardInsert(sql *WriteConn, shards *BranchShards) (*BranchShardInsert, error)
func (*BranchShardInsert) Close ¶
func (ss *BranchShardInsert) Close() error
func (*BranchShardInsert) EnsureShardTable ¶
func (ss *BranchShardInsert) EnsureShardTable(sql *WriteConn, shardID int64) error
func (*BranchShardInsert) Exec ¶
func (ss *BranchShardInsert) Exec(version int64, sequence int, bz []byte) error
func (*BranchShardInsert) Reset ¶
func (ss *BranchShardInsert) Reset() error
type BranchShardQuery ¶
type BranchShardQuery struct {
// contains filtered or unexported fields
}
func PrepareBranchShardQuery ¶
func PrepareBranchShardQuery(_ *ReadConn) *BranchShardQuery
func (*BranchShardQuery) Close ¶
func (sq *BranchShardQuery) Close() error
func (*BranchShardQuery) PrepareVersion ¶
func (sq *BranchShardQuery) PrepareVersion(c *ReadConn, version int64) error
func (*BranchShardQuery) Reset ¶
func (sq *BranchShardQuery) Reset() error
type BranchShards ¶
type BranchShards struct {
// contains filtered or unexported fields
}
func NewBranchShards ¶
func NewBranchShards(sql *WriteConn) (*BranchShards, error)
type ConnectionType ¶
type ConnectionType int
const ( UseOption ConnectionType = iota ReadOnly Immutable )
NOTE: Immutable requires reconnect to see new data
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func NewInMemoryDB ¶
func (*DB) DeleteVersionsTo ¶
func (*DB) DeleteVersionsToSync ¶
func (*DB) FinishImport ¶
func (*DB) GetHeightOneBranchesIteratorQuery ¶
func (*DB) GetLatestLeavesIterator ¶
func (sql *DB) GetLatestLeavesIterator(version int64, limit int) (*KVIterator, error)
func (*DB) ImportMostRecentSnapshot ¶
func (*DB) ImportSnapshotFromTable ¶
func (*DB) LatestVersion ¶
func (*DB) PausePruning ¶
func (*DB) PrepareImport ¶
func (*DB) Readonly ¶
func (sql *DB) Readonly() db.ReadonlyDB
func (*DB) WarmLeaves ¶
func (*DB) WriteBatch ¶
func (sql *DB) WriteBatch(importedNodes *db.DirtyNodes) error
func (*DB) WriteSnapshot ¶
func (sql *DB) WriteSnapshot( ctx context.Context, version int64, nextFn func() (*SnapshotNode, error), opts SnapshotOptions, ) (*inode.Node, error)
type ExpectedTree ¶
type IterPool ¶
type IterPool struct {
// contains filtered or unexported fields
}
func NewIterPool ¶
type KVIterator ¶
type KVIterator struct {
IterPool *IterPool
// contains filtered or unexported fields
}
func (*KVIterator) Close ¶
func (i *KVIterator) Close() error
func (*KVIterator) Domain ¶
func (i *KVIterator) Domain() (start []byte, end []byte)
func (*KVIterator) Error ¶
func (i *KVIterator) Error() error
func (*KVIterator) Key ¶
func (i *KVIterator) Key() (key []byte)
func (*KVIterator) Next ¶
func (i *KVIterator) Next()
func (*KVIterator) Valid ¶
func (i *KVIterator) Valid() bool
func (*KVIterator) Value ¶
func (i *KVIterator) Value() (value []byte)
type KVStore ¶
type KVStore struct {
// contains filtered or unexported fields
}
KVStore is a generic KV store which uses sqlite as the backend and be used by applications to store and retrieve generic key-value pairs, probably for metadata.
func NewSqliteKVStore ¶
type Options ¶
type Options struct {
Path string
Mode int
MmapSize uint64
WalSize int
CacheSize int
ConnArgs string
TempStoreSize int
ShardTrees bool
MaxPoolSize int
BusyTimeout int
ThreadsCount int
StatementCache int
Logger logger.Logger
Metrics metrics.Proxy
OptimizeOnStart bool
// DisableOSThreadLocking disables OS thread locking for write loops
// Useful in CI environments where thread priority setting may not be available
DisableOSThreadLocking bool
// contains filtered or unexported fields
}
func DefaultOptions ¶
func (Options) EstimateMmapSize ¶
type ReadConn ¶
type ReadConn struct {
// contains filtered or unexported fields
}
type ReadConnPool ¶
type ReadConnPool struct {
// contains filtered or unexported fields
}
func NewReadConnPool ¶
func NewReadConnPool(opts *Options, maxPoolSize int) (*ReadConnPool, error)
NOTE: This pool is primary used for rpc query
func (*ReadConnPool) Close ¶
func (pool *ReadConnPool) Close() error
Close closes all connections in the pool
func (*ReadConnPool) CloseHangingIterators ¶
func (pool *ReadConnPool) CloseHangingIterators() error
func (*ReadConnPool) CloseKVIterstor ¶
func (pool *ReadConnPool) CloseKVIterstor(idx int) error
func (*ReadConnPool) GetConn ¶
func (pool *ReadConnPool) GetConn() (*ReadConn, error)
func (*ReadConnPool) SetSavingTree ¶
func (pool *ReadConnPool) SetSavingTree()
func (*ReadConnPool) UnsetSavingTree ¶
func (pool *ReadConnPool) UnsetSavingTree()
type SnapshotOptions ¶
type SnapshotOptions struct {
DontWriteSnapshot bool
TraverseOrder constants.TraverseOrderType
}
type WriteBatch ¶
type WriteBatch struct {
// contains filtered or unexported fields
}
type WriteConn ¶
type WriteConn struct {
// contains filtered or unexported fields
}
func NewWriteConn ¶
type WriteEventLoop ¶
type WriteEventLoop struct {
// contains filtered or unexported fields
}
func NewWriteEventLoop ¶
func NewWriteEventLoop(sql *WriteConn, logger logger.Logger, metrics metrics.Proxy) (*WriteEventLoop, context.CancelFunc)
func (*WriteEventLoop) SaveTree ¶
func (w *WriteEventLoop) SaveTree(root *inode.Node, version int64, updates *db.DirtyNodes) error
Click to show internal directories.
Click to hide internal directories.