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

Method executeInternal

src/processor/operator/persistent/node_batch_insert.cpp:529–572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

527}
528
529void NodeBatchInsert::executeInternal(ExecutionContext* context) {
530 const auto clientContext = context->clientContext;
531 std::optional<ProducerToken> token;
532 auto nodeLocalState = localState->ptrCast<NodeBatchInsertLocalState>();
533 const auto nodeSharedState =
534 dynamic_cast_checked<NodeBatchInsertSharedState*>(sharedState.get());
535 if (nodeLocalState->localIndexBuilder) {
536 token = nodeLocalState->localIndexBuilder->getProducerToken();
537 }
538 auto transaction = Transaction::Get(*clientContext);
539 while (children[0]->getNextTuple(context)) {
540 const auto originalSelVector = nodeLocalState->columnState->getSelVectorShared();
541 // Evaluate expressions if needed.
542 const auto numTuples = nodeLocalState->columnState->getSelVector().getSelSize();
543 evaluateExpressions(numTuples);
544 copyToNodeGroup(transaction, MemoryManager::Get(*clientContext)),
545 nodeLocalState->columnState->setSelVector(originalSelVector);
546 }
547 if (nodeLocalState->chunkedGroup->getNumRows() > 0) {
548 appendIncompleteNodeGroup(transaction, std::move(nodeLocalState->chunkedGroup),
549 nodeLocalState->localIndexBuilder, MemoryManager::Get(*context->clientContext));
550 }
551 if (nodeLocalState->localIndexBuilder) {
552 DASSERT(token);
553 token->quit();
554
555 DASSERT(nodeLocalState->errorHandler.has_value());
556 nodeLocalState->localIndexBuilder->finishedProducing(nodeLocalState->errorHandler.value());
557 nodeLocalState->errorHandler->flushStoredErrors();
558 }
559 const auto nodeInfo = info->ptrCast<NodeBatchInsertInfo>();
560 if (nodeInfo->skipDuplicatePK) {
561 std::lock_guard lck{nodeSharedState->duplicatePKSkipResult->mtx};
562 nodeSharedState->duplicatePKSkipResult->skippedCount +=
563 nodeLocalState->duplicatePKSkipResult.skippedCount;
564 nodeSharedState->duplicatePKSkipResult->pks.insert(
565 nodeSharedState->duplicatePKSkipResult->pks.end(),
566 std::make_move_iterator(nodeLocalState->duplicatePKSkipResult.pks.begin()),
567 std::make_move_iterator(nodeLocalState->duplicatePKSkipResult.pks.end()));
568 nodeLocalState->duplicatePKSkipResult.pks.clear();
569 }
570 sharedState->table->cast<NodeTable>().mergeStats(nodeInfo->insertColumnIDs,
571 nodeLocalState->stats);
572}
573
574void NodeBatchInsert::evaluateExpressions(uint64_t numTuples) const {
575 const auto nodeInfo = info->ptrCast<NodeBatchInsertInfo>();

Callers

nothing calls this directly

Calls 13

getProducerTokenMethod · 0.80
getNextTupleMethod · 0.80
getSelSizeMethod · 0.80
quitMethod · 0.80
finishedProducingMethod · 0.80
mergeStatsMethod · 0.80
getMethod · 0.45
getNumRowsMethod · 0.45
flushStoredErrorsMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected