Skip to content

Commit

Permalink
Revert formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jefffrey committed Nov 7, 2023
1 parent 40f3e5f commit 3a8bec0
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 68 deletions.
37 changes: 25 additions & 12 deletions parquet/src/arrow/array_reader/fixed_len_byte_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,11 @@ impl ArrayReader for FixedLenByteArrayReader {
fn consume_batch(&mut self) -> Result<ArrayRef> {
let record_data = self.record_reader.consume_record_data();

let array_data = ArrayDataBuilder::new(ArrowType::FixedSizeBinary(self.byte_length as i32))
.len(self.record_reader.num_values())
.add_buffer(record_data)
.null_bit_buffer(self.record_reader.consume_bitmap_buffer());
let array_data =
ArrayDataBuilder::new(ArrowType::FixedSizeBinary(self.byte_length as i32))
.len(self.record_reader.num_values())
.add_buffer(record_data)
.null_bit_buffer(self.record_reader.consume_bitmap_buffer());

let binary = FixedSizeBinaryArray::from(unsafe { array_data.build_unchecked() });

Expand Down Expand Up @@ -196,13 +197,19 @@ impl ArrayReader for FixedLenByteArrayReader {
IntervalUnit::YearMonth => Arc::new(
binary
.iter()
.map(|o| o.map(|b| i32::from_le_bytes(b[0..4].try_into().unwrap())))
.map(|o| {
o.map(|b| i32::from_le_bytes(b[0..4].try_into().unwrap()))
})
.collect::<IntervalYearMonthArray>(),
) as ArrayRef,
IntervalUnit::DayTime => Arc::new(
binary
.iter()
.map(|o| o.map(|b| i64::from_le_bytes(b[4..12].try_into().unwrap())))
.map(|o| {
o.map(|b| {
i64::from_le_bytes(b[4..12].try_into().unwrap())
})
})
.collect::<IntervalDayTimeArray>(),
) as ArrayRef,
IntervalUnit::MonthDayNano => {
Expand Down Expand Up @@ -286,7 +293,9 @@ impl ValuesBuffer for FixedLenByteArrayBuffer {
let slice = self.buffer.as_slice_mut();

let values_range = read_offset..read_offset + values_read;
for (value_pos, level_pos) in values_range.rev().zip(iter_set_bits_rev(valid_mask)) {
for (value_pos, level_pos) in
values_range.rev().zip(iter_set_bits_rev(valid_mask))
{
debug_assert!(level_pos >= value_pos);
if level_pos <= value_pos {
break;
Expand Down Expand Up @@ -382,7 +391,8 @@ impl ColumnValueDecoder for ValueDecoder {
let len = range.end - range.start;
match self.decoder.as_mut().unwrap() {
Decoder::Plain { offset, buf } => {
let to_read = (len * self.byte_length).min(buf.len() - *offset) / self.byte_length;
let to_read =
(len * self.byte_length).min(buf.len() - *offset) / self.byte_length;
let end_offset = *offset + to_read * self.byte_length;
out.buffer
.extend_from_slice(&buf.as_ref()[*offset..end_offset]);
Expand Down Expand Up @@ -475,12 +485,15 @@ mod tests {
.build()
.unwrap();

let written =
RecordBatch::try_from_iter([("list", Arc::new(ListArray::from(data)) as ArrayRef)])
.unwrap();
let written = RecordBatch::try_from_iter([(
"list",
Arc::new(ListArray::from(data)) as ArrayRef,
)])
.unwrap();

let mut buffer = Vec::with_capacity(1024);
let mut writer = ArrowWriter::try_new(&mut buffer, written.schema(), None).unwrap();
let mut writer =
ArrowWriter::try_new(&mut buffer, written.schema(), None).unwrap();
writer.write(&written).unwrap();
writer.close().unwrap();

Expand Down
Loading

0 comments on commit 3a8bec0

Please sign in to comment.