Skip to content

Commit dda2e61

Browse files
frankmcsherryclaude
andcommitted
compute: form the min/max hierarchy's stage keys by byte slicing
The initial map rebuilt the values row datum by datum and packed (hash, key) by iterating the key's datums. The values are the row's leading datums and the key goes behind the hash unchanged, so copy both as bytes. Skip the row hash when the hint leaves only the final stage, whose modulus is 1. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 6cef38c commit dda2e61

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

src/compute/src/render/reduce.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -871,17 +871,25 @@ impl<'scope, T: RenderTimestamp> Context<'scope, T> {
871871
let first_mod = buckets.get(0).copied().unwrap_or(1);
872872
let aggregations = aggr_funcs.len();
873873

874-
// Gather the relevant keys with their hashes along with values ordered by aggregation_index.
874+
// Gather the relevant keys with their hashes along with values ordered by
875+
// aggregation_index. The values are the row's leading datums and the key goes
876+
// behind the hash unchanged, so both are byte copies rather than datum round
877+
// trips.
875878
let mut stage = input.map(move |(key, row)| {
876-
let mut row_builder = SharedRow::get();
877-
let mut row_packer = row_builder.packer();
878-
row_packer.extend(row.iter().take(aggregations));
879-
let values = row_builder.clone();
880-
881-
// Apply the initial mod here.
882-
let hash = values.hashed() % first_mod;
883-
let hash_key =
884-
row_builder.pack_using(std::iter::once(Datum::from(hash)).chain(&key));
879+
let (values, _) = row.split_at_datum(aggregations);
880+
let values = values.to_owned();
881+
882+
// Apply the initial mod here; a lone final stage keys everything by zero
883+
// and need not hash at all.
884+
let hash = if first_mod == 1 {
885+
0
886+
} else {
887+
values.hashed() % first_mod
888+
};
889+
let mut hash_key = Row::default();
890+
let mut packer = hash_key.packer();
891+
packer.push(Datum::from(hash));
892+
packer.extend_by_row_ref(&key);
885893
(hash_key, values)
886894
});
887895

0 commit comments

Comments
 (0)