Skip to content

Commit 689500f

Browse files
authored
Rename function (#12654)
1 parent 4df83f5 commit 689500f

File tree

6 files changed

+17
-20
lines changed

6 files changed

+17
-20
lines changed

datafusion/common/src/utils/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub fn get_record_batch_at_indices(
9898
record_batch: &RecordBatch,
9999
indices: &PrimitiveArray<UInt32Type>,
100100
) -> Result<RecordBatch> {
101-
let new_columns = get_arrayref_at_indices(record_batch.columns(), indices)?;
101+
let new_columns = take_arrays(record_batch.columns(), indices)?;
102102
RecordBatch::try_new_with_options(
103103
record_batch.schema(),
104104
new_columns,
@@ -291,10 +291,7 @@ pub(crate) fn parse_identifiers(s: &str) -> Result<Vec<Ident>> {
291291
}
292292

293293
/// Construct a new [`Vec`] of [`ArrayRef`] from the rows of the `arrays` at the `indices`.
294-
pub fn get_arrayref_at_indices(
295-
arrays: &[ArrayRef],
296-
indices: &PrimitiveArray<UInt32Type>,
297-
) -> Result<Vec<ArrayRef>> {
294+
pub fn take_arrays(arrays: &[ArrayRef], indices: &dyn Array) -> Result<Vec<ArrayRef>> {
298295
arrays
299296
.iter()
300297
.map(|array| {
@@ -1023,8 +1020,9 @@ mod tests {
10231020
vec![2, 4],
10241021
];
10251022
for row_indices in row_indices_vec {
1026-
let indices = PrimitiveArray::from_iter_values(row_indices.iter().cloned());
1027-
let chunk = get_arrayref_at_indices(&arrays, &indices)?;
1023+
let indices: PrimitiveArray<UInt32Type> =
1024+
PrimitiveArray::from_iter_values(row_indices.iter().cloned());
1025+
let chunk = take_arrays(&arrays, &indices)?;
10281026
for (arr_orig, arr_chunk) in arrays.iter().zip(&chunk) {
10291027
for (idx, orig_idx) in row_indices.iter().enumerate() {
10301028
let res1 = ScalarValue::try_from_array(arr_orig, *orig_idx as usize)?;

datafusion/functions-aggregate-common/src/aggregate/groups_accumulator.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ use arrow::{
2929
datatypes::UInt32Type,
3030
};
3131
use datafusion_common::{
32-
arrow_datafusion_err, utils::get_arrayref_at_indices, DataFusionError, Result,
33-
ScalarValue,
32+
arrow_datafusion_err, utils::take_arrays, DataFusionError, Result, ScalarValue,
3433
};
3534
use datafusion_expr_common::accumulator::Accumulator;
3635
use datafusion_expr_common::groups_accumulator::{EmitTo, GroupsAccumulator};
@@ -239,7 +238,7 @@ impl GroupsAccumulatorAdapter {
239238
// reorder the values and opt_filter by batch_indices so that
240239
// all values for each group are contiguous, then invoke the
241240
// accumulator once per group with values
242-
let values = get_arrayref_at_indices(values, &batch_indices)?;
241+
let values = take_arrays(values, &batch_indices)?;
243242
let opt_filter = get_filter_at_indices(opt_filter, &batch_indices)?;
244243

245244
// invoke each accumulator with the appropriate rows, first

datafusion/functions-aggregate/src/first_last.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use std::sync::Arc;
2424
use arrow::array::{ArrayRef, AsArray, BooleanArray};
2525
use arrow::compute::{self, lexsort_to_indices, SortColumn};
2626
use arrow::datatypes::{DataType, Field};
27-
use datafusion_common::utils::{compare_rows, get_arrayref_at_indices, get_row_at_idx};
27+
use datafusion_common::utils::{compare_rows, get_row_at_idx, take_arrays};
2828
use datafusion_common::{
2929
arrow_datafusion_err, internal_err, DataFusionError, Result, ScalarValue,
3030
};
@@ -310,7 +310,7 @@ impl Accumulator for FirstValueAccumulator {
310310
filtered_states
311311
} else {
312312
let indices = lexsort_to_indices(&sort_cols, None)?;
313-
get_arrayref_at_indices(&filtered_states, &indices)?
313+
take_arrays(&filtered_states, &indices)?
314314
};
315315
if !ordered_states[0].is_empty() {
316316
let first_row = get_row_at_idx(&ordered_states, 0)?;
@@ -613,7 +613,7 @@ impl Accumulator for LastValueAccumulator {
613613
filtered_states
614614
} else {
615615
let indices = lexsort_to_indices(&sort_cols, None)?;
616-
get_arrayref_at_indices(&filtered_states, &indices)?
616+
take_arrays(&filtered_states, &indices)?
617617
};
618618

619619
if !ordered_states[0].is_empty() {

datafusion/physical-plan/src/sorts/partial_sort.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl PartialSortExec {
104104
input: Arc<dyn ExecutionPlan>,
105105
common_prefix_length: usize,
106106
) -> Self {
107-
assert!(common_prefix_length > 0);
107+
debug_assert!(common_prefix_length > 0);
108108
let preserve_partitioning = false;
109109
let cache = Self::compute_properties(&input, expr.clone(), preserve_partitioning);
110110
Self {
@@ -289,7 +289,7 @@ impl ExecutionPlan for PartialSortExec {
289289

290290
// Make sure common prefix length is larger than 0
291291
// Otherwise, we should use SortExec.
292-
assert!(self.common_prefix_length > 0);
292+
debug_assert!(self.common_prefix_length > 0);
293293

294294
Ok(Box::pin(PartialSortStream {
295295
input,

datafusion/physical-plan/src/sorts/sort.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use arrow::record_batch::RecordBatch;
4646
use arrow::row::{RowConverter, SortField};
4747
use arrow_array::{Array, RecordBatchOptions, UInt32Array};
4848
use arrow_schema::DataType;
49-
use datafusion_common::utils::get_arrayref_at_indices;
49+
use datafusion_common::utils::take_arrays;
5050
use datafusion_common::{internal_err, Result};
5151
use datafusion_execution::disk_manager::RefCountedTempFile;
5252
use datafusion_execution::memory_pool::{MemoryConsumer, MemoryReservation};
@@ -617,7 +617,7 @@ pub fn sort_batch(
617617
lexsort_to_indices(&sort_columns, fetch)?
618618
};
619619

620-
let columns = get_arrayref_at_indices(batch.columns(), &indices)?;
620+
let columns = take_arrays(batch.columns(), &indices)?;
621621

622622
let options = RecordBatchOptions::new().with_row_count(Some(indices.len()));
623623
Ok(RecordBatch::try_new_with_options(

datafusion/physical-plan/src/windows/bounded_window_agg_exec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ use arrow::{
4949
use datafusion_common::hash_utils::create_hashes;
5050
use datafusion_common::stats::Precision;
5151
use datafusion_common::utils::{
52-
evaluate_partition_ranges, get_arrayref_at_indices, get_at_indices,
53-
get_record_batch_at_indices, get_row_at_idx,
52+
evaluate_partition_ranges, get_at_indices, get_record_batch_at_indices,
53+
get_row_at_idx, take_arrays,
5454
};
5555
use datafusion_common::{arrow_datafusion_err, exec_err, DataFusionError, Result};
5656
use datafusion_execution::TaskContext;
@@ -542,7 +542,7 @@ impl PartitionSearcher for LinearSearch {
542542
// We should emit columns according to row index ordering.
543543
let sorted_indices = sort_to_indices(&all_indices, None, None)?;
544544
// Construct new column according to row ordering. This fixes ordering
545-
get_arrayref_at_indices(&new_columns, &sorted_indices).map(Some)
545+
take_arrays(&new_columns, &sorted_indices).map(Some)
546546
}
547547

548548
fn evaluate_partition_batches(

0 commit comments

Comments
 (0)