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

Method ProcessInner

cpp/src/arrow/acero/asof_join_node.cc:979–1027  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

977 }
978
979 Result<std::shared_ptr<RecordBatch>> ProcessInner() {
980 DCHECK(!state_.empty());
981 auto& lhs = *state_.at(0);
982
983 // Construct new target table if needed
984 CompositeTableBuilder<MAX_JOIN_TABLES> dst(state_, output_schema_,
985 plan()->query_context()->memory_pool(),
986 DEBUG_ADD(state_.size(), this));
987
988 // Generate rows into the dst table until we either run out of data or hit the row
989 // limit, or run out of input
990 for (;;) {
991 // If LHS is finished or empty then there's nothing we can do here
992 if (lhs.Finished() || lhs.Empty()) break;
993
994 ARROW_ASSIGN_OR_RAISE(auto rhs_update_state, UpdateRhs());
995
996 // If we have received enough inputs to produce the next output batch
997 // (decided by IsUpToDateWithLhsRow), we will perform the join and
998 // materialize the output batch. The join is done by advancing through
999 // the LHS and adding joined row to rows_ (done by Emplace). Finally,
1000 // input batches that are no longer needed are removed to free up memory.
1001 if (rhs_update_state.all_up_to_date_with_lhs) {
1002 dst.Emplace(state_, tolerance_);
1003 ARROW_ASSIGN_OR_RAISE(bool advanced, lhs.Advance());
1004 if (!advanced) break; // if we can't advance LHS, we're done for this batch
1005 } else {
1006 if (!rhs_update_state.any_advanced) break; // need to wait for new data
1007 }
1008 }
1009
1010 // Prune memo entries that have expired (to bound memory consumption)
1011 if (!lhs.Empty()) {
1012 for (size_t i = 1; i < state_.size(); ++i) {
1013 OnType ts = tolerance_.Expiry(lhs.GetLatestTime());
1014 if (ts != TolType::kMinValue) {
1015 state_[i]->RemoveMemoEntriesWithLesserTime(ts);
1016 }
1017 }
1018 }
1019
1020 // Emit the batch
1021 if (dst.empty()) {
1022 return NULLPTR;
1023 } else {
1024 ARROW_ASSIGN_OR_RAISE(auto out, dst.Materialize());
1025 return out.has_value() ? out.value() : NULLPTR;
1026 }
1027 }
1028
1029#ifdef ARROW_ENABLE_THREADING
1030

Callers

nothing calls this directly

Calls 12

planFunction · 0.85
query_contextMethod · 0.80
ExpiryMethod · 0.80
emptyMethod · 0.45
memory_poolMethod · 0.45
sizeMethod · 0.45
FinishedMethod · 0.45
EmptyMethod · 0.45
EmplaceMethod · 0.45
GetLatestTimeMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected