UBarney commented on code in PR #21090: URL: https://github.com/apache/datafusion/pull/21090#discussion_r3009855893
########## datafusion/functions-aggregate/src/first_last/state.rs: ########## @@ -0,0 +1,439 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use std::mem::size_of; +use std::sync::Arc; + +use arrow::array::{ + Array, ArrayRef, ArrowPrimitiveType, AsArray, BinaryBuilder, BinaryViewBuilder, + BooleanBufferBuilder, LargeBinaryBuilder, LargeStringBuilder, PrimitiveArray, + StringBuilder, StringViewBuilder, +}; +use arrow::buffer::{BooleanBuffer, NullBuffer}; +use arrow::datatypes::DataType; +use datafusion_common::{Result, internal_err}; +use datafusion_expr::EmitTo; + +pub(crate) trait ValueState: Send + Sync { + /// Resizes the state to accommodate `new_size` groups. + fn resize(&mut self, new_size: usize); + /// Updates the state for the specified `group_idx` using the value at `idx` from the provided `array`. + /// + /// Note: While this is not a batch interface, it is not a performance bottleneck. + /// In heavy aggregation benchmarks, the overhead of this method is typically less than 1%. + /// + /// Benchmarked queries with < 1% `update` overhead: Review Comment: Done. I've simplified this and removed the extra details to keep it concise. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
