Skip to content

Derive ranks incrementally when scanning a rank index instead of one ranked-set probe per entry #4608

Description

@hatyo

#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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions