Skip to content

Commit afceb44

Browse files
committed
fix size of GroupValuesPrimitive.
1 parent 6ce4857 commit afceb44

File tree

1 file changed

+37
-38
lines changed
  • datafusion/physical-plan/src/aggregates/group_values/single_group_by/primitive

1 file changed

+37
-38
lines changed

datafusion/physical-plan/src/aggregates/group_values/single_group_by/primitive/mod.rs

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
use crate::aggregates::group_values::GroupValues;
19+
use ahash::RandomState;
20+
use arrow::array::types::{IntervalDayTime, IntervalMonthDayNano};
21+
use arrow::array::{
22+
cast::AsArray, ArrayRef, ArrowNativeTypeOp, ArrowPrimitiveType, NullBufferBuilder,
23+
PrimitiveArray,
24+
};
25+
use arrow::datatypes::{i256, DataType};
26+
use arrow::record_batch::RecordBatch;
27+
use datafusion_common::Result;
28+
use datafusion_execution::memory_pool::proxy::VecAllocExt;
29+
use datafusion_expr::EmitTo;
30+
use half::f16;
31+
use hashbrown::hash_table::HashTable;
32+
use std::mem::size_of;
33+
use std::sync::Arc;
34+
35+
pub use large_primitive::GroupValuesLargePrimitive;
136
mod large_primitive;
237

338
/// A trait to allow hashing of floating point numbers
@@ -41,43 +76,6 @@ macro_rules! hash_float {
4176
}
4277

4378
hash_float!(f16, f32, f64);
44-
45-
// Licensed to the Apache Software Foundation (ASF) under one
46-
// or more contributor license agreements. See the NOTICE file
47-
// distributed with this work for additional information
48-
// regarding copyright ownership. The ASF licenses this file
49-
// to you under the Apache License, Version 2.0 (the
50-
// "License"); you may not use this file except in compliance
51-
// with the License. You may obtain a copy of the License at
52-
//
53-
// http://www.apache.org/licenses/LICENSE-2.0
54-
//
55-
// Unless required by applicable law or agreed to in writing,
56-
// software distributed under the License is distributed on an
57-
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
58-
// KIND, either express or implied. See the License for the
59-
// specific language governing permissions and limitations
60-
// under the License.
61-
62-
use crate::aggregates::group_values::GroupValues;
63-
use ahash::RandomState;
64-
use arrow::array::types::{IntervalDayTime, IntervalMonthDayNano};
65-
use arrow::array::{
66-
cast::AsArray, ArrayRef, ArrowNativeTypeOp, ArrowPrimitiveType, NullBufferBuilder,
67-
PrimitiveArray,
68-
};
69-
use arrow::datatypes::{i256, DataType};
70-
use arrow::record_batch::RecordBatch;
71-
use datafusion_common::Result;
72-
use datafusion_execution::memory_pool::proxy::VecAllocExt;
73-
use datafusion_expr::EmitTo;
74-
use half::f16;
75-
use hashbrown::hash_table::HashTable;
76-
use std::mem::size_of;
77-
use std::sync::Arc;
78-
79-
pub use large_primitive::GroupValuesLargePrimitive;
80-
8179
/// A [`GroupValues`] storing a single column of normal primitive values (bits <= 64)
8280
///
8381
/// This specialization is significantly faster than using the more general
@@ -155,7 +153,8 @@ where
155153
}
156154

157155
fn size(&self) -> usize {
158-
self.map.capacity() * size_of::<(usize, u64)>() + self.values.allocated_size()
156+
self.map.capacity() * size_of::<(usize, T::Native)>()
157+
+ self.values.allocated_size()
159158
}
160159

161160
fn is_empty(&self) -> bool {

0 commit comments

Comments
 (0)