Closed digama0 closed 2 years ago
I see you have taken care to apply the SegmentId's special order in SegmentOrder::range()
, and that a SegmentIter
indeed iterates over slices of the ordered SegmentId's, so the obvious pitfall I could think of has been taken care of.
I also see how both SegmentIter
and StatementIter
implement a double ended iterator and can be used to go back along statement addresses, while taking care of the special segment ordering.
And I see how both are linked by flat_map
in the statement_range_address
API.
So this looks good to me! Sorry I have taken time to review this one.
The main breaking changes are:
db.segments()
is nowdb.segments(..)
and returns an iterator over segments instead of a vectordb.statement(bstr)
takes a byte string (&[u8]
) instead of a regular string (&str
). This is more convenient for looking up statements that have been retrieved elsewhere in the API, since these are usuallyToken
orTokenRef
which correspond to byte strings.db.statements_until(label)
has been replaced withdb.statements_range(..label)
.The main new feature is the addition of
db.statements_range()
which takes a range expression likelabel1..label2
or..label
orlabel..
or(Bound::Excluded(label1), Bound::Unbounded)
, and yields a double ended iterator. This can be used to find the next/previous statement from a given one, or iterate over statements in a range.