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

Method Advance

cpp/src/arrow/acero/sorted_merge_node.cc:169–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167 bool Finished() const { return batches_processed_ == total_batches_; }
168
169 void Advance(SingleRecordBatchSliceBuilder& builder) {
170 // Advance the row until a new time is encountered or the record batch
171 // ends. This will return a range of {-1, -1} and a nullptr if there is
172 // no input
173 bool active =
174 (latest_ref_row_ > 0 /*short circuit the lock on the queue*/) || !queue_.Empty();
175
176 if (!active) {
177 return;
178 }
179
180 row_index_t start = latest_ref_row_;
181 row_index_t end = latest_ref_row_;
182 time_unit_t startTime = GetLatestTime();
183 std::shared_ptr<arrow::RecordBatch> batch = queue_.Front();
184 auto rows_in_batch = (row_index_t)batch->num_rows();
185
186 while (GetLatestTime() == startTime) {
187 end = ++latest_ref_row_;
188 if (latest_ref_row_ >= rows_in_batch) {
189 // hit the end of the batch, need to get the next batch if
190 // possible.
191 ++batches_processed_;
192 latest_ref_row_ = 0;
193 active &= !queue_.TryPop();
194 if (active) {
195 DCHECK_GT(queue_.Front()->num_rows(),
196 0); // empty batches disallowed, sanity check
197 }
198 break;
199 }
200 }
201 builder.AddEntry(batch, start, end);
202 }
203
204 arrow::Status Push(const std::shared_ptr<arrow::RecordBatch>& rb) {
205 if (rb->num_rows() > 0) {

Callers 1

getNextBatchMethod · 0.45

Calls 4

AddEntryMethod · 0.80
EmptyMethod · 0.45
num_rowsMethod · 0.45
TryPopMethod · 0.45

Tested by

no test coverage detected