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

Method GetBatch

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

Source from the content-addressed store, hash-verified

788
789template <typename T>
790auto RleBitPackedDecoder<T>::GetBatch(value_type* out,
791 rle_size_t batch_size) -> rle_size_t {
792 using ControlFlow = RleBitPackedParser::ControlFlow;
793
794 if (ARROW_PREDICT_FALSE(batch_size == 0 || exhausted())) {
795 return 0;
796 }
797
798 rle_size_t values_read = 0;
799
800 // Remaining from a previous call that would have left some unread data from a run.
801 if (ARROW_PREDICT_FALSE(run_remaining() > 0)) {
802 const auto read = RunGetBatch(out, batch_size);
803 values_read += read;
804 out += read;
805
806 // Either we fulfilled all the batch to be read or we finished remaining run.
807 if (ARROW_PREDICT_FALSE(values_read == batch_size)) {
808 return values_read;
809 }
810 ARROW_DCHECK(run_remaining() == 0);
811 }
812
813 parser_.ParseWithCallable([&](auto run) {
814 using RunDecoder =
815 typename RleBitPackedDecoderGetRunDecoder<value_type, decltype(run)>::type;
816
817 ARROW_DCHECK_LT(values_read, batch_size);
818 RunDecoder decoder(run, value_bit_width_);
819 const auto read = decoder.GetBatch(out, batch_size - values_read, value_bit_width_);
820 ARROW_DCHECK_LE(read, batch_size - values_read);
821 values_read += read;
822 out += read;
823
824 // Stop reading and store remaining decoder
825 if (ARROW_PREDICT_FALSE(values_read == batch_size || read == 0)) {
826 decoder_ = std::move(decoder);
827 return ControlFlow::Break;
828 }
829
830 return ControlFlow::Continue;
831 });
832
833 return values_read;
834}
835
836namespace internal {
837

Callers 2

RunGetBatchMethod · 0.45
RunGetSpacedFunction · 0.45

Calls 1

ParseWithCallableMethod · 0.80

Tested by

no test coverage detected