Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rok committed Nov 23, 2022
1 parent ade4266 commit 37077b0
Show file tree
Hide file tree
Showing 5 changed files with 783 additions and 22 deletions.
9 changes: 6 additions & 3 deletions cpp/src/arrow/util/bit_stream_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,10 @@ class BitReader {

inline bool BitWriter::PutValue(uint64_t v, int num_bits) {
// TODO: revisit this limit if necessary (can be raised to 64 by fixing some edge cases)
DCHECK_LE(num_bits, 32);
DCHECK_EQ(v >> num_bits, 0) << "v = " << v << ", num_bits = " << num_bits;
DCHECK_LE(num_bits, 64);
if (num_bits < 64) {
DCHECK_EQ(v >> num_bits, 0) << "v = " << v << ", num_bits = " << num_bits;
}

if (ARROW_PREDICT_FALSE(byte_offset_ * 8 + bit_offset_ + num_bits > max_bytes_ * 8))
return false;
Expand All @@ -220,7 +222,8 @@ inline bool BitWriter::PutValue(uint64_t v, int num_bits) {
buffered_values_ = 0;
byte_offset_ += 8;
bit_offset_ -= 64;
buffered_values_ = v >> (num_bits - bit_offset_);
buffered_values_ =
(num_bits - bit_offset_ == 64) ? 0 : (v >> (num_bits - bit_offset_));
}
DCHECK_LT(bit_offset_, 64);
return true;
Expand Down
Loading

0 comments on commit 37077b0

Please sign in to comment.