93bf68c84b
The main thing to note is that traversal here != iteration. Thanks to the right-leaning nature of our btrees, iteration is already provided by lfsr_btree_lookupnext, using the bid as the current iteration state. What btree traversal provides is traversal over every rbyd + entries used in the btree, include the inner btree nodes. This is useful for things like garbage collection and error detection that need to operate on the raw rbyds. Note that both btree traversal and iteration are still O(n log_b(n)). We can't do any better than that without recursion. One non-intuitive implementation detail, we return a tag describing each entry, but instead of returning an on-disk data reference for inner btree nodes, we return a pointer to a temporarily decoded rbyd struct. This simplifies root handling, and we probably want the decoded version anyways: - tag=LFSR_TAG_BTREE => lfsr_rbyd_t - tag=anything else => lfsr_data_t The reason for making btree traversal incremental, and not just use a callback like we've done previously, is to eventually use this as a part of high-level incremental garbage-collection/error-correction. For this to work, all of the lower-levels also need to be incremental.