From 75d6e9829a4a29b1b2fe02d0f2ead3dd7ae9388d Mon Sep 17 00:00:00 2001 From: ValarDragon Date: Sun, 21 Nov 2021 19:21:47 -0500 Subject: [PATCH] Add some notes --- immutable_tree.go | 9 +++++++++ nodedb.go | 8 ++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/immutable_tree.go b/immutable_tree.go index f2c20298e..6a5e03bb5 100644 --- a/immutable_tree.go +++ b/immutable_tree.go @@ -145,10 +145,19 @@ func (t *ImmutableTree) Export() *Exporter { // Get returns the index and value of the specified key if it exists, or nil and the next index // otherwise. The returned value must not be modified, since it may point to data stored within // IAVL. +// TODO: Understand what is this index? Index on its own isn't well defined +// index across all leaves? func (t *ImmutableTree) Get(key []byte) (index int64, value []byte) { if t.root == nil { return 0, nil } + // IMPLEMENT FOLLOWING PSUEDOCODE + // value, version := t.nodeDb.fastGet(key) + // if value == nil { return t.root.get(t, key)} + // if version > t.version { return t.root.get(t, key)} + // else: return value + // TODO: Figure out what index is + return t.root.get(t, key) } diff --git a/nodedb.go b/nodedb.go index 8b62b8a47..0dabd15bf 100644 --- a/nodedb.go +++ b/nodedb.go @@ -34,8 +34,12 @@ var ( // and = version O was created at. orphanKeyFormat = NewKeyFormat('o', int64Size, int64Size, hashSize) // o - // - fastKeyFormat = NewKeyFormat('f', 0) // + // Key Format for making reads and iterates go through a data-locality preserving db. + // The value at an entry will list what version it was written to. + // Then to query values, you first query state via this fast method. + // If its present, then check the tree version. If tree version >= result_version, + // return result_version. Else, go through old (slow) IAVL get method that walks through tree. + fastKeyFormat = NewKeyFormat('f', 0) // f // Root nodes are indexed separately by their version rootKeyFormat = NewKeyFormat('r', int64Size) // r