Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use std::mem for size_of and size_of_val #262

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading