Skip to content

Commit

Permalink
Don't reload hash index after copy
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminwinger committed Apr 24, 2024
1 parent fa3afd7 commit 5f819ca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 26 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
14 changes: 9 additions & 5 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 Expand Up @@ -129,11 +137,7 @@ void InMemHashIndex<T>::splitSlot(HashIndexHeader& header) {

template<typename T>
size_t InMemHashIndex<T>::append(const IndexBuffer<BufferKeyType>& buffer) {
slot_id_t numRequiredEntries =
HashIndexUtils::getNumRequiredEntries(this->indexHeader.numEntries + buffer.size());
while (numRequiredEntries > pSlots->size() * getSlotCapacity<T>()) {
this->splitSlot(this->indexHeader);
}
reserve(this->indexHeader.numEntries + buffer.size());
// Do both searches after splitting. Returning early if the key already exists isn't a
// particular concern and doing both after splitting allows the slotID to be reused
common::hash_t hashes[BUFFER_SIZE];
Expand Down
17 changes: 1 addition & 16 deletions src/storage/wal_replayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,25 +220,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 5f819ca

Please sign in to comment.