This function buffers input values 8 at a time. After seeing all 8 values, it decides whether they should be encoded as a literal or repeated run.
| 1496 | /// This function buffers input values 8 at a time. After seeing all 8 values, |
| 1497 | /// it decides whether they should be encoded as a literal or repeated run. |
| 1498 | inline bool RleBitPackedEncoder::Put(uint64_t value) { |
| 1499 | ARROW_DCHECK(bit_width_ == 64 || value < (1ULL << bit_width_)); |
| 1500 | if (ARROW_PREDICT_FALSE(buffer_full_)) return false; |
| 1501 | |
| 1502 | if (ARROW_PREDICT_TRUE(current_value_ == value)) { |
| 1503 | ++repeat_count_; |
| 1504 | if (repeat_count_ > 8) { |
| 1505 | // This is just a continuation of the current run, no need to buffer the |
| 1506 | // values. |
| 1507 | // Note that this is the fast path for long repeated runs. |
| 1508 | return true; |
| 1509 | } |
| 1510 | } else { |
| 1511 | if (repeat_count_ >= 8) { |
| 1512 | // We had a run that was long enough but it has ended. Flush the |
| 1513 | // current repeated run. |
| 1514 | ARROW_DCHECK_EQ(literal_count_, 0); |
| 1515 | FlushRepeatedRun(); |
| 1516 | } |
| 1517 | repeat_count_ = 1; |
| 1518 | current_value_ = value; |
| 1519 | } |
| 1520 | |
| 1521 | buffered_values_[num_buffered_values_] = value; |
| 1522 | if (++num_buffered_values_ == 8) { |
| 1523 | ARROW_DCHECK_EQ(literal_count_ % 8, 0); |
| 1524 | FlushBufferedValues(false); |
| 1525 | } |
| 1526 | return true; |
| 1527 | } |
| 1528 | |
| 1529 | inline void RleBitPackedEncoder::FlushLiteralRun(bool update_indicator_byte) { |
| 1530 | if (literal_indicator_byte_ == NULL) { |
no outgoing calls