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

Method finalize

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

Source from the content-addressed store, hash-verified

738}
739
740void NodeBatchInsert::finalize(ExecutionContext* context) {
741 DASSERT(localState == nullptr);
742 const auto nodeSharedState =
743 dynamic_cast_checked<NodeBatchInsertSharedState*>(sharedState.get());
744 auto errorHandler = createErrorHandler(context);
745 auto clientContext = context->clientContext;
746 auto transaction = Transaction::Get(*clientContext);
747 auto& pageAllocator = *transaction->getLocalStorage()->addOptimisticAllocator();
748 if (nodeSharedState->sharedNodeGroup) {
749 while (nodeSharedState->sharedNodeGroup->getNumRows() > 0) {
750 writeAndResetNodeGroup(transaction, nodeSharedState->sharedNodeGroup,
751 nodeSharedState->globalIndexBuilder, MemoryManager::Get(*clientContext),
752 errorHandler, pageAllocator);
753 }
754 }
755 if (nodeSharedState->globalIndexBuilder) {
756 nodeSharedState->globalIndexBuilder->finalize(context, errorHandler);
757 errorHandler.flushStoredErrors();
758 }
759 if (nodeSharedState->noIndexPKValidator) {
760 // Completes cross-chunk duplicate detection for the no-hash-index COPY path. Sorted runs
761 // spilled to disk during validate() are stream-merged here, so duplicates that span
762 // chunks are reported before the transaction commits.
763 nodeSharedState->noIndexPKValidator->finalize();
764 }
765
766 auto& nodeTable = nodeSharedState->table->cast<NodeTable>();
767 for (auto& index : nodeTable.getIndexes()) {
768 index.finalize(clientContext);
769 }
770 // we want to flush all index errors before children call finalize
771 // as the children (if they are table function calls) are responsible for populating the errors
772 // and sending it to the warning context
773 PhysicalOperator::finalize(context);
774
775 // if the child is a subquery it will not send the errors to the warning context
776 // sends any remaining warnings in this case
777 // if the child is a table function call it will have already sent the warnings so this line
778 // will do nothing
779 WarningContext::Get(*clientContext)->defaultPopulateAllWarnings(context->queryID);
780}
781
782void NodeBatchInsert::finalizeInternal(ExecutionContext* context) {
783 auto clientContext = context->clientContext;

Callers

nothing calls this directly

Calls 6

finalizeFunction · 0.50
getMethod · 0.45
getNumRowsMethod · 0.45
flushStoredErrorsMethod · 0.45

Tested by

no test coverage detected