Skip to content

Commit

Permalink
Use std::mem for size_of and size_of_val (#262)
Browse files Browse the repository at this point in the history
Looks like it depends on the Rust version so it fails in DQE
  • Loading branch information
joroKr21 committed Aug 26, 2024
1 parent c5bd7bc commit e3c300e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions datafusion-examples/examples/advanced_udaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use arrow_schema::{Field, Schema};
use datafusion::{arrow::datatypes::DataType, logical_expr::Volatility};
use datafusion_physical_expr::NullState;
use std::mem::{size_of, size_of_val};
use std::{any::Any, sync::Arc};

use arrow::{
Expand Down Expand Up @@ -92,7 +93,7 @@ impl AggregateUDFImpl for GeoMeanUdaf {
}

/// This is the description of the state. accumulator's state() must match the types here.
fn state_fields(&self, args: StateFieldsArgs) -> Result<Vec<arrow_schema::Field>> {
fn state_fields(&self, args: StateFieldsArgs) -> Result<Vec<Field>> {
Ok(vec![
Field::new("prod", args.return_type.clone(), true),
Field::new("n", DataType::UInt32, true),
Expand Down Expand Up @@ -193,7 +194,7 @@ impl Accumulator for GeometricMean {
}

fn size(&self) -> usize {
std::mem::size_of_val(self)
size_of_val(self)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// specific language governing permissions and limitations
// under the License.

use std::mem::size_of;
use std::sync::Arc;

use arrow::array::{ArrayRef, AsArray, BooleanArray, PrimitiveArray};
Expand Down
1 change: 1 addition & 0 deletions datafusion/physical-expr/src/aggregate/array_agg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ use datafusion_common::Result;
use datafusion_common::{internal_err, ScalarValue};
use datafusion_expr::{Accumulator, EmitTo, GroupsAccumulator};
use std::any::Any;
use std::mem::{size_of, size_of_val};
use std::sync::Arc;

/// ARRAY_AGG aggregate expression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use std::any::Any;
use std::collections::HashSet;
use std::fmt::Debug;
use std::mem::size_of_val;
use std::sync::Arc;

use arrow::array::ArrayRef;
Expand Down
5 changes: 3 additions & 2 deletions datafusion/physical-expr/src/aggregate/average.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use log::debug;

use std::any::Any;
use std::fmt::Debug;
use std::mem::{size_of, size_of_val};
use std::sync::Arc;

use crate::aggregate::groups_accumulator::accumulate::NullState;
Expand Down Expand Up @@ -284,7 +285,7 @@ impl Accumulator for AvgAccumulator {
}

fn size(&self) -> usize {
std::mem::size_of_val(self)
size_of_val(self)
}
}

Expand Down Expand Up @@ -377,7 +378,7 @@ impl<T: DecimalType + ArrowNumericType> Accumulator for DecimalAvgAccumulator<T>
}

fn size(&self) -> usize {
std::mem::size_of_val(self)
size_of_val(self)
}
}

Expand Down

0 comments on commit e3c300e

Please sign in to comment.