pub struct PartitionKeyCache { /* private fields */ }Expand description
Cross-row memoization of the decoded partition-key columns (Issue #1817).
Partition-key column VALUES are constant within a partition, but
build_row_from_scan historically re-decoded them from the raw key bytes
for EVERY row. Because a scan yields the rows of one partition consecutively
(token-ordered full scans, partition-targeted lookups, and the Flight k-way
merge all group a partition’s rows), memoizing the last partition’s decoded
columns makes the byte-parse + name-intern happen ONCE per partition
(O(partitions)) rather than once per row (O(rows)). The decoded values are
cloned into each row (an Arc ref-count bump for the name + a Value
clone — each row needs its own copy), so the materialized rows are
byte-identical to the prior per-row decode.
If the input is NOT partition-ordered the cache simply misses and re-decodes, so correctness never depends on ordering — only the decode COUNT does.
A cache hit also requires the requesting schema’s partition-key fingerprint to
match the cached one (roborev): PartitionKeyCache is publicly re-exported and
could be reused across tables whose partition keys share raw bytes but differ
in schema — matching the fingerprint makes any such difference a MISS so the
columns are never decoded for the wrong schema.