Packed sketch ranks #
Guard extraction and multiplication count all simultaneous comparisons. Complementing the sketches reverses the comparison to obtain inclusive ranks. None of these operations assumes a most-significant-bit primitive. Node constants must be precomputed and loaded separately.
Main definitions #
guardMask,guardFlags,countGuards: extract one zero-or-one digit from each guarded comparison and sum the set guards through one multiplication.upperRankExpr: inclusive rank using complemented sketches.RankProgram.query,RankProgram.node,RankProgram.copies,RankProgram.guards,RankProgram.bits,RankProgram.middle,RankProgram.base,RankProgram.maximum,RankProgram.temp,RankProgram.out: named registers of the rank program.RankProgram.code,RankProgram.result: the eight-instruction rank program and its final data state.
Main results #
guardFlags_eq: exact packed Boolean comparison digits.countGuards_fits: every intermediate word of the guard count fits a half-filled word.upperRankExpr_eq_card: the resulting inclusive rank.RankProgram.exec: eight actual checked instructions return the inclusive rank.
References #
One guard bit per field, with all other bits zero.
Every intermediate word of the eight-instruction guard count fits when the packed node occupies at most half the word: the replicated query, the packed difference, its guards, the extracted flags, the count product, its middle digit, and the count.
The expression returns the number of sketches at or below the query. Sortedness is unnecessary for the arithmetic identity; a tree uses sorted sketches to interpret the rank.
Query sketch.
Packed guarded complements of the stored sketches.
Replication multiplier.
Mask selecting all guard bits.
Number of payload bits per field.
Power selecting the count product's middle digit.
Field radix.
Largest possible payload.
Replicated complemented query.
Scratch register and final inclusive rank.
Eight standard instructions compute the complete inclusive sketch rank. All eight input registers and all memory are preserved. The precomputed constants are supplied by the caller.
The exact final data, retaining the intermediate temporary register.
Checked execution of the full inclusive rank in eight instructions. The packed word occupies at most half the physical width, making the count multiplication legal too. Construction/loading of the node constants and compressed query remain separate.