| 429 | } |
| 430 | |
| 431 | void 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 | |
| 470 | void NodeBatchInsert::initGlobalStateInternal(ExecutionContext* context) { |
| 471 | auto clientContext = context->clientContext; |
no test coverage detected