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

Method ProcessValues

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

Source from the content-addressed store, hash-verified

917template <typename T>
918template <typename Callable>
919auto RleBitPackedDecoder<T>::ProcessValues(Callable&& func,
920 rle_size_t batch_size) -> rle_size_t {
921 using ControlFlow = RleBitPackedParser::ControlFlow;
922
923 if (ARROW_PREDICT_FALSE(batch_size == 0 || exhausted())) {
924 return 0;
925 }
926
927 rle_size_t values_processed = 0;
928
929 // Remaining from a previous call that would have left some unread data from a run.
930 if (ARROW_PREDICT_FALSE(run_remaining() > 0)) {
931 const auto processed =
932 std::visit([&](auto& decoder) { return func(decoder, batch_size); }, decoder_);
933 values_processed += processed;
934
935 // Either we fulfilled all the batch to be read or we finished remaining run.
936 if (ARROW_PREDICT_FALSE(values_processed == batch_size)) {
937 return values_processed;
938 }
939 ARROW_DCHECK(run_remaining() == 0);
940 }
941
942 parser_.ParseWithCallable([&](auto run) {
943 using RunDecoder =
944 typename RleBitPackedDecoderGetRunDecoder<value_type, decltype(run)>::type;
945
946 ARROW_DCHECK_LT(values_processed, batch_size);
947 // Local decoder to keep its type transparent to the compiler.
948 RunDecoder decoder(run, value_bit_width_);
949 const auto read = func(decoder, batch_size - values_processed);
950 ARROW_DCHECK_LE(read, batch_size - values_processed);
951 values_processed += read;
952
953 if (ARROW_PREDICT_FALSE(values_processed == batch_size || read == 0)) {
954 // Stop reading and store remaining decoder
955 decoder_ = std::move(decoder);
956 return ControlFlow::Break;
957 }
958 return ControlFlow::Continue;
959 });
960
961 return values_processed;
962}
963
964template <typename T>
965auto RleBitPackedDecoder<T>::Advance(rle_size_t batch_size) -> rle_size_t {

Callers

nothing calls this directly

Calls 2

ParseWithCallableMethod · 0.80
funcFunction · 0.50

Tested by

no test coverage detected