| 495 | } |
| 496 | |
| 497 | void NodeTable::update(Transaction* transaction, TableUpdateState& updateState) { |
| 498 | // NOTE: We assume all inputs are flattened now. This is to simplify the implementation. |
| 499 | // We should optimize this to take unflattened input later. |
| 500 | auto& nodeUpdateState = updateState.constCast<NodeTableUpdateState>(); |
| 501 | DASSERT(nodeUpdateState.nodeIDVector.state->getSelVector().getSelSize() == 1 && |
| 502 | nodeUpdateState.propertyVector.state->getSelVector().getSelSize() == 1); |
| 503 | const auto pos = nodeUpdateState.nodeIDVector.state->getSelVector()[0]; |
| 504 | if (nodeUpdateState.nodeIDVector.isNull(pos)) { |
| 505 | return; |
| 506 | } |
| 507 | if (nodeUpdateState.columnID == pkColumnID) { |
| 508 | throw RuntimeException("Cannot update pk."); |
| 509 | } |
| 510 | const auto nodeOffset = nodeUpdateState.nodeIDVector.readNodeOffset(pos); |
| 511 | for (auto i = 0u; i < indexes.size(); i++) { |
| 512 | auto index = indexes[i].getIndex(); |
| 513 | if (!nodeUpdateState.needToUpdateIndex(i)) { |
| 514 | continue; |
| 515 | } |
| 516 | index->update(transaction, nodeUpdateState.nodeIDVector, nodeUpdateState.propertyVector, |
| 517 | *nodeUpdateState.indexUpdateState[i]); |
| 518 | } |
| 519 | if (transaction->isUnCommitted(tableID, nodeOffset)) { |
| 520 | const auto localTable = transaction->getLocalStorage()->getLocalTable(tableID); |
| 521 | DASSERT(localTable); |
| 522 | localTable->update(&DUMMY_TRANSACTION, updateState); |
| 523 | } else { |
| 524 | const auto nodeGroupIdx = StorageUtils::getNodeGroupIdx(nodeOffset); |
| 525 | const auto rowIdxInGroup = |
| 526 | nodeOffset - StorageUtils::getStartOffsetOfNodeGroup(nodeGroupIdx); |
| 527 | nodeGroups->getNodeGroup(nodeGroupIdx) |
| 528 | ->update(transaction, rowIdxInGroup, nodeUpdateState.columnID, |
| 529 | nodeUpdateState.propertyVector); |
| 530 | } |
| 531 | if (updateState.logToWAL && transaction->shouldLogToWAL()) { |
| 532 | DASSERT(transaction->isWriteTransaction()); |
| 533 | auto& wal = transaction->getLocalWAL(); |
| 534 | wal.logNodeUpdate(tableID, nodeUpdateState.columnID, nodeOffset, |
| 535 | &nodeUpdateState.propertyVector); |
| 536 | } |
| 537 | setHasChanges(); |
| 538 | } |
| 539 | |
| 540 | bool NodeTable::delete_(Transaction* transaction, TableDeleteState& deleteState) { |
| 541 | const auto& nodeDeleteState = dynamic_cast_checked<NodeTableDeleteState&>(deleteState); |
nothing calls this directly
no test coverage detected