Skip to content

Commit 4d8b2c5

Browse files
committed
use cast instead of from(to_data)
1 parent c9fb728 commit 4d8b2c5

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

  • datafusion/physical-plan/src/aggregates/topk

‎datafusion/physical-plan/src/aggregates/topk/heap.rs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
2626
use arrow::array::types::{IntervalDayTime, IntervalMonthDayNano};
2727
use arrow::array::{
28-
Array, ArrayAccessor, ArrayRef, ArrowPrimitiveType, LargeStringArray, PrimitiveArray,
29-
StringArray, StringArrayType, StringViewArray, downcast_primitive,
28+
Array, ArrayAccessor, ArrayRef, ArrowPrimitiveType, AsArray, LargeStringArray, PrimitiveArray, StringArray, StringArrayType, StringViewArray, downcast_primitive,
3029
};
3130
use arrow::buffer::ScalarBuffer;
3231
use arrow::datatypes::{DataType, i256};
@@ -103,7 +102,7 @@ where
103102
<VAL as ArrowPrimitiveType>::Native: Comparable,
104103
{
105104
pub fn new(limit: usize, desc: bool) -> Self {
106-
let batch = PrimitiveArray::<VAL>::builder(0).finish();
105+
let batch = PrimitiveArray::<VAL>::new_null(0);
107106
Self {
108107
batch,
109108
heap: TopKHeap::new(limit, desc),
@@ -117,7 +116,7 @@ where
117116
<VAL as ArrowPrimitiveType>::Native: Comparable,
118117
{
119118
fn set_batch(&mut self, vals: ArrayRef) {
120-
self.batch = PrimitiveArray::from(vals.to_data());
119+
self.batch = vals.as_primitive().clone();
121120
}
122121

123122
fn is_worse(&self, row_idx: usize) -> bool {

0 commit comments

Comments
 (0)