Skip to content

Commit

Permalink
Don't reload hash index after copy (#3377)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminwinger committed Apr 25, 2024
1 parent a121cd4 commit 2a8a68a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
6 changes: 1 addition & 5 deletions src/include/storage/index/in_mem_hash_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,7 @@ class InMemHashIndex final {

uint64_t size() { return this->indexHeader.numEntries; }

inline void clear() {
indexHeader = HashIndexHeader();
pSlots = std::make_unique<InMemDiskArrayBuilder<Slot<T>>>(dummy, 0, 0, true);
oSlots = std::make_unique<InMemDiskArrayBuilder<Slot<T>>>(dummy, 0, 1, true);
}
void clear();

struct SlotIterator {
explicit SlotIterator(slot_id_t newSlotId, InMemHashIndex<T>* builder)
Expand Down
8 changes: 8 additions & 0 deletions src/storage/index/in_mem_hash_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ InMemHashIndex<T>::InMemHashIndex(OverflowFileHandle* overflowFileHandle)
allocateSlots(BufferPoolConstants::PAGE_4KB_SIZE / pSlots->getAlignedElementSize());
}

template<typename T>
void InMemHashIndex<T>::clear() {
indexHeader = HashIndexHeader(TypeUtils::getPhysicalTypeIDForType<T>());
pSlots = std::make_unique<InMemDiskArrayBuilder<Slot<T>>>(dummy, 0, 0, true);
oSlots = std::make_unique<InMemDiskArrayBuilder<Slot<T>>>(dummy, 0, 1, true);
allocateSlots(BufferPoolConstants::PAGE_4KB_SIZE / pSlots->getAlignedElementSize());
}

template<typename T>
void InMemHashIndex<T>::allocateSlots(uint32_t newNumSlots) {
auto numSlotsOfCurrentLevel = 1u << this->indexHeader.currentLevel;
Expand Down
19 changes: 1 addition & 18 deletions src/storage/wal_replayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

#include <unordered_map>

#include "catalog/catalog_entry/node_table_catalog_entry.h"
#include "common/exception/storage.h"
#include "common/file_system/file_info.h"
#include "common/serializer/buffered_file.h"
#include "storage/storage_manager.h"
#include "storage/storage_utils.h"
#include "storage/store/node_table.h"
#include "storage/wal/wal_record.h"
#include "storage/wal_replayer_utils.h"
#include "transaction/transaction.h"
Expand Down Expand Up @@ -220,25 +218,10 @@ void WALReplayer::replayRdfGraphRecord(const WALRecord& walRecord) {
replayCreateTableRecord(*rdfGraphRecord.literalTripleTableRecord);
}

void WALReplayer::replayCopyTableRecord(const WALRecord& walRecord) {
auto& copyTableRecord = ku_dynamic_cast<const WALRecord&, const CopyTableRecord&>(walRecord);
auto tableID = copyTableRecord.tableID;
void WALReplayer::replayCopyTableRecord(const WALRecord& /*walRecord*/) {
if (isCheckpoint) {
if (!isRecovering) {
// CHECKPOINT.
// If we are not recovering, i.e., we are checkpointing during normal execution,
// then we need to update the nodeTable because the actual columns and lists
// files have been changed during checkpoint. So the in memory
// fileHandles are obsolete and should be reconstructed (e.g. since the numPages
// have likely changed they need to reconstruct their page locks).
auto catalogEntry = catalog->getTableCatalogEntry(&DUMMY_READ_TRANSACTION, tableID);
if (catalogEntry->getType() == CatalogEntryType::NODE_TABLE_ENTRY) {
auto nodeTableEntry =
ku_dynamic_cast<TableCatalogEntry*, NodeTableCatalogEntry*>(catalogEntry);
auto nodeTable =
ku_dynamic_cast<Table*, NodeTable*>(storageManager->getTable(tableID));
nodeTable->initializePKIndex(nodeTableEntry, false /* readOnly */, vfs);
}
} else {
// RECOVERY.
if (wal->isLastLoggedRecordCommit()) {
Expand Down

0 comments on commit 2a8a68a

Please sign in to comment.