diff --git a/vector/src/function/create_hnsw_index.cpp b/vector/src/function/create_hnsw_index.cpp index cb065cd..16d5f09 100644 --- a/vector/src/function/create_hnsw_index.cpp +++ b/vector/src/function/create_hnsw_index.cpp @@ -57,11 +57,11 @@ static std::unique_ptr createInMemHNSWBindFunc(main::ClientCo } const auto tableID = nodeTableEntry->getTableID(); HNSWIndexUtils::validateColumnType(*nodeTableEntry, columnName); - const auto& table = + auto& table = storage::StorageManager::Get(*context)->getTable(tableID)->cast(); auto propertyID = nodeTableEntry->getPropertyID(columnName); auto transaction = transaction::Transaction::Get(*context); - auto numNodes = table.getStats(transaction).getTableCard(); + auto numNodes = table.getNumTotalRows(transaction); return std::make_unique(context, indexName, nodeTableEntry, propertyID, numNodes, std::move(config)); } diff --git a/vector/src/index/hnsw_index.cpp b/vector/src/index/hnsw_index.cpp index 3fe9194..79fe88a 100644 --- a/vector/src/index/hnsw_index.cpp +++ b/vector/src/index/hnsw_index.cpp @@ -669,11 +669,11 @@ void OnDiskHNSWIndex::update(Transaction* transaction, const common::ValueVector void OnDiskHNSWIndex::finalize(main::ClientContext* context) { auto& hnswStorageInfo = storageInfo->cast(); - const auto numTotalRows = nodeTable.getNumTotalRows(&DUMMY_CHECKPOINT_TRANSACTION); + auto transaction = Transaction::Get(*context); + const auto numTotalRows = nodeTable.getNumTotalRows(transaction); if (numTotalRows == hnswStorageInfo.numCheckpointedNodes) { return; } - auto transaction = Transaction::Get(*context); auto [nodeTableEntry, upperRelTableEntry, lowerRelTableEntry] = getIndexTableCatalogEntries(catalog::Catalog::Get(*context), transaction, indexInfo); const auto embeddingDim = typeInfo.constPtrCast()->getNumElements(); diff --git a/vector/src/index/hnsw_rel_batch_insert.cpp b/vector/src/index/hnsw_rel_batch_insert.cpp index a2435c3..61d8a4f 100644 --- a/vector/src/index/hnsw_rel_batch_insert.cpp +++ b/vector/src/index/hnsw_rel_batch_insert.cpp @@ -125,6 +125,9 @@ void HNSWRelBatchInsert::writeToTable(processor::RelBatchInsertExecutionState& e common::idx_t neighbourIdx = 0; // write neighbour offset + unique rel ID for each rel for (const auto neighbourGraphOffset : neighbours) { + if (neighbourGraphOffset == common::INVALID_OFFSET) { + continue; + } const auto neighbourNodeOffset = selectionMap.graphToNodeOffset(neighbourGraphOffset); const auto relRowIdx = boundNodeCSROffset + neighbourIdx; const auto relID = startRelID + numRelsWritten;