shanhuuang commented on a change in pull request #10627:
URL: https://github.com/apache/arrow/pull/10627#discussion_r692095886
##########
File path: cpp/src/arrow/util/bit_stream_utils.h
##########
@@ -313,7 +337,18 @@ inline int BitReader::GetBatch(int num_bits, T* v, int
batch_size) {
reinterpret_cast<uint32_t*>(v + i), batch_size - i,
num_bits);
i += num_unpacked;
byte_offset += num_unpacked * num_bits / 8;
+ } else if (sizeof(T) == 8 && num_bits > 32) {
+ // Use unpack64 only if num_bits is larger then 32
Review comment:
Yes, I think it is just a performance issue. If num_bits is no larger
than 32, I guess that using unpack32 will achieve better performance with
function such as unpack32_avx2/unpack32_avx512.
The result of using unpack32 or unpack64 are the same if num_bits <= 32
##########
File path: cpp/src/parquet/encoding.cc
##########
@@ -2107,73 +2105,99 @@ class DeltaBitPackDecoder : public DecoderImpl, virtual
public TypedDecoder<DTyp
}
private:
- void InitBlock() {
- // The number of values per block.
- uint32_t block_size;
- if (!decoder_.GetVlqInt(&block_size)) ParquetException::EofException();
- if (!decoder_.GetVlqInt(&num_mini_blocks_))
ParquetException::EofException();
- if (!decoder_.GetVlqInt(&values_current_block_)) {
+ void InitHeader() {
+ if (!decoder_.GetVlqInt(&values_per_block_))
ParquetException::EofException();
+ if (!decoder_.GetVlqInt(&mini_blocks_per_block_))
ParquetException::EofException();
+ if (!decoder_.GetVlqInt(&total_value_count_)) {
ParquetException::EofException();
}
if (!decoder_.GetZigZagVlqInt(&last_value_))
ParquetException::EofException();
- delta_bit_widths_ = AllocateBuffer(pool_, num_mini_blocks_);
- uint8_t* bit_width_data = delta_bit_widths_->mutable_data();
+ delta_bit_widths_ = AllocateBuffer(pool_, mini_blocks_per_block_);
+ values_per_mini_block_ = values_per_block_ / mini_blocks_per_block_;
+ if (values_per_mini_block_ % 8 != 0) {
+ throw ParquetException("miniBlockSize must be multiple of 8, but it's " +
Review comment:
OK. I've opened a JIRA
[here](https://issues.apache.org/jira/browse/PARQUET-2077).
##########
File path: cpp/src/arrow/util/bit_util_test.cc
##########
@@ -1939,24 +1939,61 @@ TEST(BitUtil, RoundUpToPowerOf2) {
#undef U64
#undef S64
-static void TestZigZag(int32_t v) {
+static void TestZigZag(int32_t v, std::array<uint8_t, 5> buffer_expect) {
uint8_t buffer[BitUtil::BitReader::kMaxVlqByteLength] = {};
BitUtil::BitWriter writer(buffer, sizeof(buffer));
BitUtil::BitReader reader(buffer, sizeof(buffer));
writer.PutZigZagVlqInt(v);
+ EXPECT_EQ(buffer_expect[0], buffer[0]);
+ EXPECT_EQ(buffer_expect[1], buffer[1]);
+ EXPECT_EQ(buffer_expect[2], buffer[2]);
+ EXPECT_EQ(buffer_expect[3], buffer[3]);
+ EXPECT_EQ(buffer_expect[4], buffer[4]);
Review comment:
Got it! Thanks. :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]