Skip to content

Commit

Permalink
fix create_primitive_array (#4412)
Browse files Browse the repository at this point in the history
  • Loading branch information
ming08108 authored Jun 15, 2023
1 parent 9d09fe5 commit a57d718
Showing 1 changed file with 17 additions and 39 deletions.
56 changes: 17 additions & 39 deletions arrow-ipc/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,6 @@ fn create_primitive_array(
.null_bit_buffer(null_buffer)
.build()?
}
FixedSizeBinary(_) => {
// read 2 buffers: null buffer (optional) and data buffer
ArrayData::builder(data_type.clone())
.len(length)
.add_buffer(buffers[1].clone())
.null_bit_buffer(null_buffer)
.build()?
}
Int8
| Int16
| Int32
Expand All @@ -250,24 +242,23 @@ fn create_primitive_array(
| UInt32
| Time32(_)
| Date32
| Interval(IntervalUnit::YearMonth) => {
if buffers[1].len() / 8 == length && length != 1 {
// interpret as a signed i64, and cast appropriately
let data = ArrayData::builder(DataType::Int64)
.len(length)
.add_buffer(buffers[1].clone())
.null_bit_buffer(null_buffer)
.build()?;
let values = Arc::new(Int64Array::from(data)) as ArrayRef;
let casted = cast(&values, data_type)?;
casted.into_data()
} else {
ArrayData::builder(data_type.clone())
.len(length)
.add_buffer(buffers[1].clone())
.null_bit_buffer(null_buffer)
.build()?
}
| Interval(IntervalUnit::YearMonth)
| Interval(IntervalUnit::DayTime)
| FixedSizeBinary(_)
| Boolean
| Int64
| UInt64
| Float64
| Time64(_)
| Timestamp(_, _)
| Date64
| Duration(_) => {
// read 2 buffers: null buffer (optional) and data buffer
ArrayData::builder(data_type.clone())
.len(length)
.add_buffer(buffers[1].clone())
.null_bit_buffer(null_buffer)
.build()?
}
Float32 => {
if buffers[1].len() / 8 == length && length != 1 {
Expand All @@ -288,19 +279,6 @@ fn create_primitive_array(
.build()?
}
}
Boolean
| Int64
| UInt64
| Float64
| Time64(_)
| Timestamp(_, _)
| Date64
| Duration(_)
| Interval(IntervalUnit::DayTime) => ArrayData::builder(data_type.clone())
.len(length)
.add_buffer(buffers[1].clone())
.null_bit_buffer(null_buffer)
.build()?,
Interval(IntervalUnit::MonthDayNano) | Decimal128(_, _) => {
let buffer = get_aligned_buffer::<i128>(&buffers[1], length);

Expand Down

0 comments on commit a57d718

Please sign in to comment.