MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / getNextTuplesInternal

Method getNextTuplesInternal

src/processor/operator/limit.cpp:12–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10}
11
12bool Limit::getNextTuplesInternal(ExecutionContext* context) {
13 // end of execution due to no more input
14 if (!children[0]->getNextTuple(context)) {
15 return false;
16 }
17 auto numTupleAvailable = resultSet->getNumTuples(dataChunksPosInScope);
18 auto numTupleProcessedBefore = counter->fetch_add(numTupleAvailable);
19 if (numTupleProcessedBefore + numTupleAvailable > limitNumber) {
20 int64_t numTupleToProcessInCurrentResultSet = limitNumber - numTupleProcessedBefore;
21 // end of execution due to limit has reached
22 if (numTupleToProcessInCurrentResultSet <= 0) {
23 return false;
24 } else {
25 // If all dataChunks are flat, numTupleAvailable = 1 which means numTupleProcessedBefore
26 // = limitNumber. So execution is terminated in above if statement.
27 auto& dataChunkToSelect = resultSet->dataChunks[dataChunkToSelectPos];
28 DASSERT(!dataChunkToSelect->state->isFlat());
29 dataChunkToSelect->state->getSelVectorUnsafe().setSelSize(
30 numTupleToProcessInCurrentResultSet);
31 metrics->numOutputTuple.increase(numTupleToProcessInCurrentResultSet);
32 }
33 } else {
34 metrics->numOutputTuple.increase(numTupleAvailable);
35 }
36 return true;
37}
38
39} // namespace processor
40} // namespace lbug

Callers

nothing calls this directly

Calls 5

getNextTupleMethod · 0.80
setSelSizeMethod · 0.80
getNumTuplesMethod · 0.45
isFlatMethod · 0.45
increaseMethod · 0.45

Tested by

no test coverage detected