\ Aggregate Btree vandys
only extensions definitions
AgView -> subclass: AgBtree
\ AgBtree fetch vandys
AgBtree -> :method @ ( key self -- val T | F ) ag>list { key list }
list -> size 0 do i list -> @ { bt }
key bt -> @ if exit then loop false method;
\ AgBtree iteration vandys
AgBtree -> :method do { arg 'fn self -- }
0 begin self -> nextKey while { key }
key self -> @ drop { val } arg val key 'fn execute
repeat method;
\ Aggregate B-trees, testing vandys
false [if] \ Testing
Btree -> new constant bt1 Btree -> new constant bt2
AgBtree -> new constant ab
100 1 bt1 -> ! 200 2 bt2 -> ! 300 3 bt1 -> ! 300 3 bt2 -> !
bt1 ab -> add bt2 ab -> add
[then] \ Testing
AgBtree is an AgView of Btree's
:method @ Return value for this key from whichever B-tree first has it
:method do Iterate across all values in the B-tree. If a value is at
a given key in more than one layer, only the outermost one is seen
by the iterator function.
TBD: if this goes too slow, may need to maintain parallel indices
into the constituent B-trees rather than iteratively re-indexing
into each of them to find successive steps.