Skip to content

Commit 39057b1

Browse files
committed
move impl
1 parent 72f837c commit 39057b1

1 file changed

Lines changed: 53 additions & 53 deletions

File tree

  • src/aggregation/bucket/multi_terms

src/aggregation/bucket/multi_terms/mod.rs

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,59 @@ impl MultiTermsPacking for U64ArrayKeyPacking {
311311
}
312312
}
313313

314+
impl MultiTermsPacking for PackedU64KeyPacking {
315+
type PackingType = u64;
316+
317+
fn new_packing(&self) -> Self::PackingType {
318+
0
319+
}
320+
321+
fn clear_packing(&self, key: &mut Self::PackingType) {
322+
*key = 0;
323+
}
324+
325+
fn push(&self, key: &mut Self::PackingType, field_idx: usize, value: u64) {
326+
let pack = self.packs[field_idx];
327+
let offset = value
328+
.checked_sub(pack.min_value)
329+
.expect("packed value is not below the field minimum");
330+
debug_assert!(offset <= pack.max_offset);
331+
*key |= shift_packed_bits(offset, pack.shift);
332+
}
333+
334+
fn pop(&self, key: &mut Self::PackingType, field_idx: usize) {
335+
let pack = self.packs[field_idx];
336+
*key &= !shift_packed_bits(pack.mask, pack.shift);
337+
}
338+
339+
#[inline]
340+
fn push_full_values<I>(&self, keys: &mut [Self::PackingType], field_idx: usize, values: I)
341+
where I: IntoIterator<Item = u64> {
342+
let pack = self.packs[field_idx];
343+
for (key, val) in keys.iter_mut().zip(values) {
344+
let offset = val - pack.min_value;
345+
debug_assert!(offset <= pack.max_offset);
346+
*key |= shift_packed_bits(offset, pack.shift);
347+
}
348+
}
349+
350+
fn unpack(
351+
&self,
352+
key: &Self::PackingType,
353+
req_data: &MultiTermsAggReqData,
354+
) -> crate::Result<Vec<IntermediateKey>> {
355+
self.packs
356+
.iter()
357+
.zip(req_data.fields.iter())
358+
.zip(req_data.missing_accessors.iter())
359+
.map(|((pack, field), missing)| {
360+
let offset = key.checked_shr(pack.shift).unwrap_or(0) & pack.mask;
361+
resolve_key_value(offset + pack.min_value, field, missing.as_ref())
362+
})
363+
.collect()
364+
}
365+
}
366+
314367
#[derive(Debug)]
315368
struct MultiTermsBucketEntry<K, B> {
316369
key: K,
@@ -959,59 +1012,6 @@ struct PackedU64KeyPacking {
9591012
packs: Vec<FieldPack>,
9601013
}
9611014

962-
impl MultiTermsPacking for PackedU64KeyPacking {
963-
type PackingType = u64;
964-
965-
fn new_packing(&self) -> Self::PackingType {
966-
0
967-
}
968-
969-
fn clear_packing(&self, key: &mut Self::PackingType) {
970-
*key = 0;
971-
}
972-
973-
fn push(&self, key: &mut Self::PackingType, field_idx: usize, value: u64) {
974-
let pack = self.packs[field_idx];
975-
let offset = value
976-
.checked_sub(pack.min_value)
977-
.expect("packed value is not below the field minimum");
978-
debug_assert!(offset <= pack.max_offset);
979-
*key |= shift_packed_bits(offset, pack.shift);
980-
}
981-
982-
fn pop(&self, key: &mut Self::PackingType, field_idx: usize) {
983-
let pack = self.packs[field_idx];
984-
*key &= !shift_packed_bits(pack.mask, pack.shift);
985-
}
986-
987-
#[inline]
988-
fn push_full_values<I>(&self, keys: &mut [Self::PackingType], field_idx: usize, values: I)
989-
where I: IntoIterator<Item = u64> {
990-
let pack = self.packs[field_idx];
991-
for (key, val) in keys.iter_mut().zip(values) {
992-
let offset = val - pack.min_value;
993-
debug_assert!(offset <= pack.max_offset);
994-
*key |= shift_packed_bits(offset, pack.shift);
995-
}
996-
}
997-
998-
fn unpack(
999-
&self,
1000-
key: &Self::PackingType,
1001-
req_data: &MultiTermsAggReqData,
1002-
) -> crate::Result<Vec<IntermediateKey>> {
1003-
self.packs
1004-
.iter()
1005-
.zip(req_data.fields.iter())
1006-
.zip(req_data.missing_accessors.iter())
1007-
.map(|((pack, field), missing)| {
1008-
let offset = key.checked_shr(pack.shift).unwrap_or(0) & pack.mask;
1009-
resolve_key_value(offset + pack.min_value, field, missing.as_ref())
1010-
})
1011-
.collect()
1012-
}
1013-
}
1014-
10151015
/// Selects the key packing and bucket storage, then boxes the concrete collector.
10161016
fn build_multi_terms_collector<BucketSlot: BucketIdSlot>(
10171017
req: &mut AggregationsSegmentCtx,

0 commit comments

Comments
 (0)