Skip to content

Commit

Permalink
Add some notes
Browse files Browse the repository at this point in the history
  • Loading branch information
ValarDragon committed Nov 22, 2021
1 parent 71fd2ec commit 75d6e98
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 9 additions & 0 deletions immutable_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
8 changes: 6 additions & 2 deletions nodedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ var (
// and <first-version> = version O was created at.
orphanKeyFormat = NewKeyFormat('o', int64Size, int64Size, hashSize) // o<last-version><first-version><hash>

//
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<keystring>

// Root nodes are indexed separately by their version
rootKeyFormat = NewKeyFormat('r', int64Size) // r<version>
Expand Down

0 comments on commit 75d6e98

Please sign in to comment.