#4563 adds RankScanBounds.includeRankAsValue(), which makes RankIndexMaintainer report each scanned entry's rank in the otherwise empty index entry value. The implementation there is deliberately the simple one: the scan is wrapped in a mapPipelined() that calls rankFor(indexEntry.getKey()) for every entry. That is one probe of the secondary (ranked set) subspace per entry, roughly O(log n) I/O each, where n is the number of elements in the grouping group. Cost scales with entries returned, not with the range asked for, and pipelining hides latency without reducing the work.
Entries in the primary subspace are already ordered by score, and score and rank are compatibly ordered, so the ranks of an ordered run can be derived from the rank of the first entry plus the scores that follow. Replace the mapPipelined() wrapper with a purpose-built cursor that resolves the first entry's rank with a single rankFor(), then carries (previousScore, previousRank) forward and computes the rest locally with no I/O beyond the underlying scan.
#4563 adds
RankScanBounds.includeRankAsValue(), which makesRankIndexMaintainerreport each scanned entry's rank in the otherwise empty index entry value. The implementation there is deliberately the simple one: the scan is wrapped in amapPipelined()that callsrankFor(indexEntry.getKey())for every entry. That is one probe of the secondary (ranked set) subspace per entry, roughlyO(log n)I/O each, wherenis the number of elements in the grouping group. Cost scales with entries returned, not with the range asked for, and pipelining hides latency without reducing the work.Entries in the primary subspace are already ordered by score, and score and rank are compatibly ordered, so the ranks of an ordered run can be derived from the rank of the first entry plus the scores that follow. Replace the
mapPipelined()wrapper with a purpose-built cursor that resolves the first entry's rank with a singlerankFor(), then carries(previousScore, previousRank)forward and computes the rest locally with no I/O beyond the underlying scan.