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

Method initPKIndex

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

Source from the content-addressed store, hash-verified

429}
430
431void NodeBatchInsertSharedState::initPKIndex(const ExecutionContext* context) {
432 auto* nodeTable = dynamic_cast_checked<NodeTable*>(table);
433 auto* pkIndex = nodeTable->tryGetPKIndex();
434 if (!pkIndex) {
435 if (nodeTable->tryGetPrimaryKeyIndex() != nullptr) {
436 if (skipDuplicatePK) {
437 throw RuntimeException(
438 "IGNORE_ERRORS=true (DUPLICATE_PK_ONLY) is only supported for node tables "
439 "with a primary-key hash index.");
440 }
441 globalIndexBuilder.reset();
442 noIndexPKValidator.reset();
443 usePrimaryKeyIndexCommitInsert = true;
444 return;
445 }
446 if (nodeTable->getNumTotalRows(Transaction::Get(*context->clientContext)) != 0) {
447 throw RuntimeException(
448 "COPY into a non-empty primary-key node table without a hash index is not "
449 "supported.");
450 }
451 if (skipDuplicatePK) {
452 throw RuntimeException(
453 "IGNORE_ERRORS=true (DUPLICATE_PK_ONLY) is only supported for node tables with "
454 "a primary-key hash index.");
455 }
456 globalIndexBuilder.reset();
457 noIndexPKValidator = createNoIndexPKValidator(pkType, context->clientContext);
458 usePrimaryKeyIndexCommitInsert = false;
459 if (!noIndexPKValidator) {
460 throw RuntimeException(ExceptionMessage::invalidPKType(pkType.toString()));
461 }
462 return;
463 }
464 noIndexPKValidator.reset();
465 usePrimaryKeyIndexCommitInsert = false;
466 globalIndexBuilder = IndexBuilder(std::make_shared<IndexBuilderSharedState>(
467 Transaction::Get(*context->clientContext), nodeTable));
468}
469
470void NodeBatchInsert::initGlobalStateInternal(ExecutionContext* context) {
471 auto clientContext = context->clientContext;

Callers 1

Calls 7

createNoIndexPKValidatorFunction · 0.85
IndexBuilderClass · 0.85
tryGetPKIndexMethod · 0.80
tryGetPrimaryKeyIndexMethod · 0.80
resetMethod · 0.45
getNumTotalRowsMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected