Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't reload hash index after copy #3377

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading