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

refactor: move large WAL operators to source file #2146

Merged
merged 1 commit into from
Oct 4, 2023
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
109 changes: 4 additions & 105 deletions src/include/storage/wal/wal_record.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,7 @@ struct ListFileID {
: listType{ListType::REL_PROPERTY_LISTS}, listFileType{listFileType},
relPropertyListID{relPropertyListID} {}

inline bool operator==(const ListFileID& rhs) const {
if (listType != rhs.listType || listFileType != rhs.listFileType) {
return false;
}
switch (listType) {
case ListType::ADJ_LISTS: {
return adjListsID == rhs.adjListsID;
}
case ListType::REL_PROPERTY_LISTS: {
return relPropertyListID == rhs.relPropertyListID;
}
default: {
throw common::NotImplementedException("ListFileID::operator()==");
}
}
}
bool operator==(const ListFileID& rhs) const;
};

struct NodePropertyColumnID {
Expand Down Expand Up @@ -164,25 +149,7 @@ struct ColumnFileID {
explicit ColumnFileID(RelPropertyColumnID relPropertyColumnID)
: columnType{ColumnType::REL_PROPERTY_COLUMN}, relPropertyColumnID{relPropertyColumnID} {}

inline bool operator==(const ColumnFileID& rhs) const {
if (columnType != rhs.columnType) {
return false;
}
switch (columnType) {
case ColumnType::NODE_PROPERTY_COLUMN: {
return nodePropertyColumnID == rhs.nodePropertyColumnID;
}
case ColumnType::ADJ_COLUMN: {
return adjColumnID == rhs.adjColumnID;
}
case ColumnType::REL_PROPERTY_COLUMN: {
return relPropertyColumnID == rhs.relPropertyColumnID;
}
default: {
assert(false);
}
}
}
bool operator==(const ColumnFileID& rhs) const;
};

struct NodeIndexID {
Expand Down Expand Up @@ -218,25 +185,7 @@ struct StorageStructureID {
NodeIndexID nodeIndexID;
};

inline bool operator==(const StorageStructureID& rhs) const {
if (storageStructureType != rhs.storageStructureType || isOverflow != rhs.isOverflow) {
return false;
}
switch (storageStructureType) {
case StorageStructureType::COLUMN: {
return columnFileID == rhs.columnFileID;
}
case StorageStructureType::LISTS: {
return listFileID == rhs.listFileID;
}
case StorageStructureType::NODE_INDEX: {
return nodeIndexID == rhs.nodeIndexID;
}
default: {
throw common::NotImplementedException("StorageStructureID::operator==");
}
}
}
bool operator==(const StorageStructureID& rhs) const;

static StorageStructureID newDataID();
static StorageStructureID newMetadataID();
Expand Down Expand Up @@ -455,57 +404,7 @@ struct WALRecord {
AddPropertyRecord addPropertyRecord;
};

bool operator==(const WALRecord& rhs) const {
if (recordType != rhs.recordType) {
return false;
}
switch (recordType) {
case WALRecordType::PAGE_UPDATE_OR_INSERT_RECORD: {
return pageInsertOrUpdateRecord == rhs.pageInsertOrUpdateRecord;
}
case WALRecordType::COMMIT_RECORD: {
return commitRecord == rhs.commitRecord;
}
case WALRecordType::TABLE_STATISTICS_RECORD: {
return tableStatisticsRecord == rhs.tableStatisticsRecord;
}
case WALRecordType::CATALOG_RECORD: {
// CatalogRecords are empty so are always equal
return true;
}
case WALRecordType::NODE_TABLE_RECORD: {
return nodeTableRecord == rhs.nodeTableRecord;
}
case WALRecordType::REL_TABLE_RECORD: {
return relTableRecord == rhs.relTableRecord;
}
case WALRecordType::RDF_GRAPH_RECORD: {
return rdfGraphRecord == rhs.rdfGraphRecord;
}
case WALRecordType::OVERFLOW_FILE_NEXT_BYTE_POS_RECORD: {
return diskOverflowFileNextBytePosRecord == rhs.diskOverflowFileNextBytePosRecord;
}
case WALRecordType::COPY_NODE_RECORD: {
return copyNodeRecord == rhs.copyNodeRecord;
}
case WALRecordType::COPY_REL_RECORD: {
return copyRelRecord == rhs.copyRelRecord;
}
case WALRecordType::DROP_TABLE_RECORD: {
return dropTableRecord == rhs.dropTableRecord;
}
case WALRecordType::DROP_PROPERTY_RECORD: {
return dropPropertyRecord == rhs.dropPropertyRecord;
}
case WALRecordType::ADD_PROPERTY_RECORD: {
return addPropertyRecord == rhs.addPropertyRecord;
}
default: {
throw common::RuntimeException("Unrecognized WAL record type inside ==. recordType: " +
walRecordTypeToString(recordType));
}
}
}
bool operator==(const WALRecord& rhs) const;

static WALRecord newPageUpdateRecord(StorageStructureID storageStructureID_,
uint64_t pageIdxInOriginalFile, uint64_t pageIdxInWAL);
Expand Down
110 changes: 110 additions & 0 deletions src/storage/wal/wal_record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,64 @@
namespace kuzu {
namespace storage {

bool ListFileID::operator==(const ListFileID& rhs) const {

Check warning on line 8 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L8

Added line #L8 was not covered by tests

if (listType != rhs.listType || listFileType != rhs.listFileType) {

Check warning on line 10 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L10

Added line #L10 was not covered by tests
return false;
}
switch (listType) {
case ListType::ADJ_LISTS: {

Check warning on line 14 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L13-L14

Added lines #L13 - L14 were not covered by tests
return adjListsID == rhs.adjListsID;
}
case ListType::REL_PROPERTY_LISTS: {

Check warning on line 17 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L17

Added line #L17 was not covered by tests
return relPropertyListID == rhs.relPropertyListID;
}
default: {
throw common::NotImplementedException("ListFileID::operator()==");

Check warning on line 21 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L20-L21

Added lines #L20 - L21 were not covered by tests
}
}
}

bool ColumnFileID::operator==(const ColumnFileID& rhs) const {
if (columnType != rhs.columnType) {
return false;
}
switch (columnType) {
case ColumnType::NODE_PROPERTY_COLUMN: {
return nodePropertyColumnID == rhs.nodePropertyColumnID;
}
case ColumnType::ADJ_COLUMN: {

Check warning on line 34 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L34

Added line #L34 was not covered by tests
return adjColumnID == rhs.adjColumnID;
}
case ColumnType::REL_PROPERTY_COLUMN: {

Check warning on line 37 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L37

Added line #L37 was not covered by tests
return relPropertyColumnID == rhs.relPropertyColumnID;
}
default: {
throw common::NotImplementedException("ColumnFileID::operator()==");

Check warning on line 41 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L40-L41

Added lines #L40 - L41 were not covered by tests
}
}
}

bool StorageStructureID::operator==(const StorageStructureID& rhs) const {
if (storageStructureType != rhs.storageStructureType || isOverflow != rhs.isOverflow) {
return false;
}
switch (storageStructureType) {
case StorageStructureType::COLUMN: {
return columnFileID == rhs.columnFileID;
}
case StorageStructureType::LISTS: {
return listFileID == rhs.listFileID;

Check warning on line 55 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L54-L55

Added lines #L54 - L55 were not covered by tests
}
case StorageStructureType::NODE_INDEX: {
return nodeIndexID == rhs.nodeIndexID;

Check warning on line 58 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L57-L58

Added lines #L57 - L58 were not covered by tests
}
default: {
throw common::NotImplementedException("StorageStructureID::operator==");

Check warning on line 61 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L60-L61

Added lines #L60 - L61 were not covered by tests
}
}
}

std::string storageStructureTypeToString(StorageStructureType storageStructureType) {
switch (storageStructureType) {
case StorageStructureType::COLUMN: {
Expand Down Expand Up @@ -98,6 +156,58 @@
return retVal;
}

bool WALRecord::operator==(const WALRecord& rhs) const {
if (recordType != rhs.recordType) {
return false;
}
switch (recordType) {
case WALRecordType::PAGE_UPDATE_OR_INSERT_RECORD: {
return pageInsertOrUpdateRecord == rhs.pageInsertOrUpdateRecord;
}
case WALRecordType::COMMIT_RECORD: {
return commitRecord == rhs.commitRecord;
}
case WALRecordType::TABLE_STATISTICS_RECORD: {
return tableStatisticsRecord == rhs.tableStatisticsRecord;

Check warning on line 171 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L170-L171

Added lines #L170 - L171 were not covered by tests
}
case WALRecordType::CATALOG_RECORD: {
// CatalogRecords are empty so are always equal
return true;
}
case WALRecordType::NODE_TABLE_RECORD: {
return nodeTableRecord == rhs.nodeTableRecord;

Check warning on line 178 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L177-L178

Added lines #L177 - L178 were not covered by tests
}
case WALRecordType::REL_TABLE_RECORD: {
return relTableRecord == rhs.relTableRecord;

Check warning on line 181 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L180-L181

Added lines #L180 - L181 were not covered by tests
}
case WALRecordType::RDF_GRAPH_RECORD: {

Check warning on line 183 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L183

Added line #L183 was not covered by tests
return rdfGraphRecord == rhs.rdfGraphRecord;
}
case WALRecordType::OVERFLOW_FILE_NEXT_BYTE_POS_RECORD: {

Check warning on line 186 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L186

Added line #L186 was not covered by tests
return diskOverflowFileNextBytePosRecord == rhs.diskOverflowFileNextBytePosRecord;
}
case WALRecordType::COPY_NODE_RECORD: {

Check warning on line 189 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L189

Added line #L189 was not covered by tests
return copyNodeRecord == rhs.copyNodeRecord;
}
case WALRecordType::COPY_REL_RECORD: {
return copyRelRecord == rhs.copyRelRecord;

Check warning on line 193 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L192-L193

Added lines #L192 - L193 were not covered by tests
}
case WALRecordType::DROP_TABLE_RECORD: {
return dropTableRecord == rhs.dropTableRecord;

Check warning on line 196 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L195-L196

Added lines #L195 - L196 were not covered by tests
}
case WALRecordType::DROP_PROPERTY_RECORD: {

Check warning on line 198 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L198

Added line #L198 was not covered by tests
return dropPropertyRecord == rhs.dropPropertyRecord;
}
case WALRecordType::ADD_PROPERTY_RECORD: {

Check warning on line 201 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L201

Added line #L201 was not covered by tests
return addPropertyRecord == rhs.addPropertyRecord;
}
default: {
throw common::RuntimeException("Unrecognized WAL record type inside ==. recordType: " +
walRecordTypeToString(recordType));

Check warning on line 206 in src/storage/wal/wal_record.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/wal/wal_record.cpp#L204-L206

Added lines #L204 - L206 were not covered by tests
}
}
}

std::string walRecordTypeToString(WALRecordType walRecordType) {
switch (walRecordType) {
case WALRecordType::PAGE_UPDATE_OR_INSERT_RECORD: {
Expand Down