| 773 | |
| 774 | template <typename T> |
| 775 | auto RleBitPackedDecoder<T>::GetBatch(value_type* out, |
| 776 | rle_size_t batch_size) -> rle_size_t { |
| 777 | using ControlFlow = RleBitPackedParser::ControlFlow; |
| 778 | |
| 779 | rle_size_t values_read = 0; |
| 780 | |
| 781 | // Remaining from a previous call that would have left some unread data from a run. |
| 782 | if (ARROW_PREDICT_FALSE(run_remaining() > 0)) { |
| 783 | const auto read = RunGetBatch(out, batch_size); |
| 784 | values_read += read; |
| 785 | out += read; |
| 786 | |
| 787 | // Either we fulfilled all the batch to be read or we finished remaining run. |
| 788 | if (ARROW_PREDICT_FALSE(values_read == batch_size)) { |
| 789 | return values_read; |
| 790 | } |
| 791 | ARROW_DCHECK(run_remaining() == 0); |
| 792 | } |
| 793 | |
| 794 | ParseWithCallable([&](auto run) { |
| 795 | using RunDecoder = typename decltype(run)::template DecoderType<value_type>; |
| 796 | |
| 797 | ARROW_DCHECK_LT(values_read, batch_size); |
| 798 | RunDecoder decoder(run, value_bit_width_); |
| 799 | const auto read = decoder.GetBatch(out, batch_size - values_read, value_bit_width_); |
| 800 | ARROW_DCHECK_LE(read, batch_size - values_read); |
| 801 | values_read += read; |
| 802 | out += read; |
| 803 | |
| 804 | // Stop reading and store remaining decoder |
| 805 | if (ARROW_PREDICT_FALSE(values_read == batch_size || read == 0)) { |
| 806 | decoder_ = std::move(decoder); |
| 807 | return ControlFlow::Break; |
| 808 | } |
| 809 | |
| 810 | return ControlFlow::Continue; |
| 811 | }); |
| 812 | |
| 813 | return values_read; |
| 814 | } |
| 815 | |
| 816 | namespace internal { |
| 817 |
no outgoing calls