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

Class MergedRunsIterator

cpp/src/arrow/util/ree_util.h:449–591  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

447/// of this iterator only hold references to the RunEndEncodedArraySpan inputs.
448template <typename Left, typename Right>
449class MergedRunsIterator {
450 private:
451 using LeftIterator = typename Left::Iterator;
452 using RightIterator = typename Right::Iterator;
453
454 MergedRunsIterator(LeftIterator left_it, RightIterator right_it,
455 int64_t common_logical_length, int64_t common_logical_pos)
456 : ree_iterators_{std::move(left_it), std::move(right_it)},
457 logical_length_(common_logical_length),
458 logical_pos_(common_logical_pos) {}
459
460 public:
461 /// \brief Construct a MergedRunsIterator positioned at logical position 0.
462 ///
463 /// Pre-condition: left.length() == right.length()
464 MergedRunsIterator(const Left& left, const Right& right)
465 : MergedRunsIterator(left.begin(), right.begin(), left.length(), 0) {
466 assert(left.length() == right.length());
467 }
468
469 static Result<MergedRunsIterator> MakeBegin(const Left& left, const Right& right) {
470 if (left.length() != right.length()) {
471 return Status::Invalid(
472 "MergedRunsIterator expects RunEndEncodedArraySpans of the same length");
473 }
474 return MergedRunsIterator(left, right);
475 }
476
477 static Result<MergedRunsIterator> MakeEnd(const Left& left, const Right& right) {
478 if (left.length() != right.length()) {
479 return Status::Invalid(
480 "MergedRunsIterator expects RunEndEncodedArraySpans of the same length");
481 }
482 return MergedRunsIterator(left.end(), right.end(), left.length(), left.length());
483 }
484
485 /// \brief Return the left RunEndEncodedArraySpan child
486 const Left& left() const { return std::get<0>(ree_iterators_).span; }
487
488 /// \brief Return the right RunEndEncodedArraySpan child
489 const Right& right() const { return std::get<1>(ree_iterators_).span; }
490
491 /// \brief Return the initial logical position of the run
492 ///
493 /// If is_end(), this is the same as length().
494 int64_t logical_position() const { return logical_pos_; }
495
496 /// \brief Whether the iterator is at logical position 0.
497 bool is_begin() const { return logical_pos_ == 0; }
498
499 /// \brief Whether the iterator has reached the end of both arrays
500 bool is_end() const { return logical_pos_ == logical_length_; }
501
502 /// \brief Return the logical position immediately after the run.
503 ///
504 /// Pre-condition: !is_end()
505 int64_t run_end() const {
506 const auto& left_it = std::get<0>(ree_iterators_);

Callers 4

CompareRunEndEncodedMethod · 0.85
TYPED_TEST_PFunction · 0.85
MakeBeginMethod · 0.85
MakeEndMethod · 0.85

Calls 2

run_endMethod · 0.45
logical_positionMethod · 0.45

Tested by 1

TYPED_TEST_PFunction · 0.68