-
Notifications
You must be signed in to change notification settings - Fork 0
SQLiteNodeStorage
This implementation keeps one version in memory and stores committed version to disk in an SQLite database
self.version
contains the current version which still needs to be committed to the database
public final class SQLiteNodeStorage<Key: Comparable & Codable & DataProtocol & InitialisableProtocol, Value: Codable & DataProtocol & InitialisableProtocol, Hasher: HasherProtocol>: NodeStorageProtocol
public typealias Key = Key
public typealias Value = Value
public typealias Hasher = Hasher
public typealias Hash = Hasher.Hash
public typealias Node = SQLiteNode<Key, Value, Hasher>
Create a new SQLiteNodeStorage from a db file If the db is not provided, creates an in memory database
public init(_ path: String? = nil) throws
var roots
var orphans: [Hash]
var version: Int64
var versions: [Int64]
Contains all new nodes created in memory not yet saved to the database.
Flushed after calls to commit()
or rollback()
var newNodes: [Node]
var dbQueue: DatabaseQueue
Contains all nodes which have been loaded from the database or created in memory
var nodeCache: [Hash: Node]
var description: String
public func root(at _: Int64) -> Node?
public func rollback()
@discardableResult public func set(key: Key, value: Value) throws -> Bool
@discardableResult public func remove(key: Key) -> (Value?, Bool)
public func commit() throws
public func makeEmpty() -> Node
public func makeLeaf(key: Key, value: Value) -> Node
public func makeInner(key: Key, left: Node, right: Node) -> Node
public func deleteLast() throws
public func deleteAll(from _: Int64) throws
private func loadOrphans(from: Int64) throws
private func loadRoot(from: Int64) throws
Load the node with given hash
from the database
if lazy
is set to true will only load a single node
if lazy
is set to false, will load the full tree below the node
fileprivate func loadNode(from hash: Hash, lazy _: Bool = true) throws -> Node?
Load the node with given hash
from the database and all nodes below to a maximum depth of depth
if depth
== 0, only load the node
fileprivate func loadNode(from _: Hash, depth _: UInt8) -> Node?
private func save() throws
Generated at 2021-04-20T11:34:45+0000 using swift-doc 1.0.0-beta.5.