Skip to content

Commit e33d853

Browse files
authored
Merge 145a1dc into 4bcc7a6
2 parents 4bcc7a6 + 145a1dc commit e33d853

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

parquet/src/encodings/decoding.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,6 @@ pub struct DeltaBitPackDecoder<T: DataType> {
433433
initialized: bool,
434434

435435
// Header info
436-
437436
/// The number of values in each block
438437
block_size: usize,
439438
/// The number of values that remain to be read in the current page
@@ -444,7 +443,6 @@ pub struct DeltaBitPackDecoder<T: DataType> {
444443
values_per_mini_block: usize,
445444

446445
// Per block info
447-
448446
/// The minimum delta in the block
449447
min_delta: T::T,
450448
/// The byte offset of the end of the current block
@@ -639,6 +637,7 @@ where
639637
self.last_value = value;
640638
buffer[0] = value;
641639
read += 1;
640+
self.values_left -= 1;
642641
}
643642

644643
while read != to_read {
@@ -668,9 +667,9 @@ where
668667

669668
read += batch_read;
670669
self.mini_block_remaining -= batch_read;
670+
self.values_left -= batch_read;
671671
}
672672

673-
self.values_left -= to_read;
674673
Ok(to_read)
675674
}
676675

parquet/src/encodings/encoding.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ impl<T: DataType> DeltaBitPackEncoder<T> {
565565
return Ok(());
566566
}
567567

568-
let mut min_delta = i64::max_value();
568+
let mut min_delta = i64::MAX;
569569
for i in 0..self.values_in_block {
570570
min_delta = cmp::min(min_delta, self.deltas[i]);
571571
}
@@ -581,6 +581,13 @@ impl<T: DataType> DeltaBitPackEncoder<T> {
581581
// values left
582582
let n = cmp::min(self.mini_block_size, self.values_in_block);
583583
if n == 0 {
584+
// Decoders should be agnostic to the padding value, we therefore use 0xFF
585+
// when running tests. However, not all implementations may handle this correctly
586+
// so pad with 0 when not running tests
587+
let pad_value = cfg!(test).then(|| 0xFF).unwrap_or(0);
588+
for j in i..self.num_mini_blocks {
589+
self.bit_writer.write_at(offset + j, pad_value);
590+
}
584591
break;
585592
}
586593

@@ -610,8 +617,8 @@ impl<T: DataType> DeltaBitPackEncoder<T> {
610617
self.values_in_block -= n;
611618
}
612619

613-
assert!(
614-
self.values_in_block == 0,
620+
assert_eq!(
621+
self.values_in_block, 0,
615622
"Expected 0 values in block, found {}",
616623
self.values_in_block
617624
);

0 commit comments

Comments
 (0)