Get a batch of values into `out` and return the number of decoded elements. May write fewer elements to the output than requested if there are not enough values left.
| 120 | /// May write fewer elements to the output than requested if there are not |
| 121 | /// enough values left. |
| 122 | [[nodiscard]] rle_size_t GetBatch(BitmapSpanMut out, rle_size_t batch_size) { |
| 123 | const auto out_bit_offset = out.bit_start(); |
| 124 | ARROW_DCHECK_GE(out_bit_offset, 0); |
| 125 | ARROW_DCHECK_LT(out_bit_offset, 8); |
| 126 | |
| 127 | if (ARROW_PREDICT_FALSE(remaining() == 0 || batch_size == 0)) { |
| 128 | return 0; |
| 129 | } |
| 130 | |
| 131 | rle_size_t n_vals = 0; |
| 132 | |
| 133 | // HEADER: Writing inside the first byte if caller gives a non-aligned input |
| 134 | if (out_bit_offset != 0) { |
| 135 | n_vals = GetBatchInByte(out, batch_size); |
| 136 | } |
| 137 | |
| 138 | // Writing full bytes |
| 139 | n_vals += GetBatchFullBytes(out.NewStartingAt(n_vals), batch_size - n_vals); |
| 140 | |
| 141 | // TRAILER: Writing inside the last byte if caller asked for non multiple of 8 values |
| 142 | const auto n_last_vals = std::min(batch_size - n_vals, remaining()); |
| 143 | if (n_last_vals > 0) { |
| 144 | ARROW_DCHECK_LT(n_last_vals, 8); |
| 145 | n_vals += GetBatchInByte(out.NewStartingAt(n_vals), n_last_vals); |
| 146 | } |
| 147 | |
| 148 | return n_vals; |
| 149 | } |
| 150 | |
| 151 | private: |
| 152 | /// The byte pattern for 8 values (full ones or full zeros). |
nothing calls this directly
no test coverage detected