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.
| 1343 | /// This function buffers input values 8 at a time. After seeing all 8 values, |
| 1344 | /// it decides whether they should be encoded as a literal or repeated run. |
| 1345 | inline bool RleBitPackedEncoder::Put(uint64_t value) { |
| 1346 | ARROW_DCHECK(bit_width_ == 64 || value < (1ULL << bit_width_)); |
| 1347 | if (ARROW_PREDICT_FALSE(buffer_full_)) return false; |
| 1348 | |
| 1349 | if (ARROW_PREDICT_TRUE(current_value_ == value)) { |
| 1350 | ++repeat_count_; |
| 1351 | if (repeat_count_ > 8) { |
| 1352 | // This is just a continuation of the current run, no need to buffer the |
| 1353 | // values. |
| 1354 | // Note that this is the fast path for long repeated runs. |
| 1355 | return true; |
| 1356 | } |
| 1357 | } else { |
| 1358 | if (repeat_count_ >= 8) { |
| 1359 | // We had a run that was long enough but it has ended. Flush the |
| 1360 | // current repeated run. |
| 1361 | ARROW_DCHECK_EQ(literal_count_, 0); |
| 1362 | FlushRepeatedRun(); |
| 1363 | } |
| 1364 | repeat_count_ = 1; |
| 1365 | current_value_ = value; |
| 1366 | } |
| 1367 | |
| 1368 | buffered_values_[num_buffered_values_] = value; |
| 1369 | if (++num_buffered_values_ == 8) { |
| 1370 | ARROW_DCHECK_EQ(literal_count_ % 8, 0); |
| 1371 | FlushBufferedValues(false); |
| 1372 | } |
| 1373 | return true; |
| 1374 | } |
| 1375 | |
| 1376 | inline void RleBitPackedEncoder::FlushLiteralRun(bool update_indicator_byte) { |
| 1377 | if (literal_indicator_byte_ == NULL) { |
no outgoing calls