Skip to content

Commit 47be719

Browse files
committed
avoid copy
1 parent f4e519f commit 47be719

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

datafusion/core/src/datasource/physical_plan/arrow_file.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use crate::physical_plan::{
3131
DisplayAs, DisplayFormatType, ExecutionPlan, Partitioning, SendableRecordBatchStream,
3232
};
3333

34+
use arrow::buffer::Buffer;
3435
use arrow_ipc::reader::FileDecoder;
3536
use arrow_schema::SchemaRef;
3637
use datafusion_common::config::ConfigOptions;
@@ -296,7 +297,7 @@ impl FileOpener for ArrowOpener {
296297
for (dict_block, dict_result) in
297298
footer.dictionaries().iter().flatten().zip(dict_results)
298299
{
299-
decoder.read_dictionary(dict_block, &dict_result.into())?;
300+
decoder.read_dictionary(dict_block, &Buffer::from_bytes(dict_result.into()))?;
300301
}
301302

302303
// filter recordbatches according to range
@@ -331,7 +332,7 @@ impl FileOpener for ArrowOpener {
331332
.into_iter()
332333
.zip(recordbatch_results)
333334
.filter_map(move |(block, data)| {
334-
match decoder.read_record_batch(&block, &data.into()) {
335+
match decoder.read_record_batch(&block, &Buffer::from_bytes(data.into())) {
335336
Ok(Some(record_batch)) => Some(Ok(record_batch)),
336337
Ok(None) => None,
337338
Err(err) => Some(Err(err)),

datafusion/proto-common/src/from_proto/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ impl TryFrom<&protobuf::ScalarValue> for ScalarValue {
408408
"Error IPC message while deserializing ScalarValue::List: {e}"
409409
))
410410
})?;
411-
let buffer = Buffer::from(arrow_data);
411+
let buffer = Buffer::from(arrow_data.as_slice());
412412

413413
let ipc_batch = message.header_as_record_batch().ok_or_else(|| {
414414
Error::General(
@@ -423,7 +423,7 @@ impl TryFrom<&protobuf::ScalarValue> for ScalarValue {
423423
"Error IPC message while deserializing ScalarValue::List dictionary message: {e}"
424424
))
425425
})?;
426-
let buffer = Buffer::from(arrow_data);
426+
let buffer = Buffer::from(arrow_data.as_slice());
427427

428428
let dict_batch = message.header_as_dictionary_batch().ok_or_else(|| {
429429
Error::General(

0 commit comments

Comments
 (0)