MCPcopy Create free account
hub / github.com/apache/arrow / RleBitPackedDecoder

Class RleBitPackedDecoder

cpp/src/arrow/util/rle_encoding_internal.h:462–573  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

460/// Decoder class for Parquet RLE bit-packed data.
461template <typename T>
462class RleBitPackedDecoder {
463 public:
464 /// The type in which the data should be decoded.
465 using value_type = T;
466 using DynamicRun = RleBitPackedParser::dynamic_run_type;
467
468 RleBitPackedDecoder() noexcept = default;
469
470 /// Create a decoder object.
471 ///
472 /// data and data_size are the raw bytes to decode.
473 /// value_bit_width is the size in bits of each encoded value.
474 RleBitPackedDecoder(const uint8_t* data, rle_size_t data_size,
475 rle_size_t value_bit_width) noexcept {
476 Reset(data, data_size, value_bit_width);
477 }
478
479 void Reset(const uint8_t* data, rle_size_t data_size,
480 rle_size_t value_bit_width) noexcept {
481 ARROW_DCHECK_GE(value_bit_width, 0);
482 ARROW_DCHECK_LE(value_bit_width, 64);
483 parser_.Reset(data, data_size, value_bit_width);
484 decoder_ = {};
485 value_bit_width_ = value_bit_width;
486 }
487
488 /// Whether there is still runs to iterate over.
489 ///
490 /// WARN: Due to lack of proper error handling, iteration with Get methods could return
491 /// no data while the parser is not exhausted.
492 /// This is how one can check for errors.
493 bool exhausted() const { return (run_remaining() == 0) && parser_.exhausted(); }
494
495 /// Advance by as many values as provided or until exhaustion of the decoder.
496 /// Return the number of values skipped.
497 [[nodiscard]] rle_size_t Advance(rle_size_t batch_size);
498
499 /// Advance and count the number of occurrence of a values.
500 ///
501 /// The count is limited to at most the next `batch_size` items.
502 /// @return The matching value count and number of of element that were processed.
503 RleCountUpToResult CountUpTo(value_type value, rle_size_t batch_size);
504
505 /// Gets the next value or returns false if there are no more or an error occurred.
506 ///
507 /// NB: Because the encoding only supports literal runs with lengths
508 /// that are multiples of 8, RleEncoder sometimes pads the end of its
509 /// input with zeros. Since the encoding does not differentiate between
510 /// input values and padding, Get() returns true even for these padding
511 /// values.
512 [[nodiscard]] bool Get(value_type* val);
513
514 /// Get a batch of values return the number of decoded elements.
515 /// May write fewer elements to the output than requested if there are not enough values
516 /// left or if an error occurred.
517 [[nodiscard]] rle_size_t GetBatch(value_type* out, rle_size_t batch_size);
518
519 /// Like GetBatch but add spacing for null entries.

Callers 2

SetDataMethod · 0.85
SetDataV2Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected