-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2020 from kuzudb/refactor-catalog
Split catalog table schemas
- Loading branch information
Showing
45 changed files
with
569 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "catalog/node_table_schema.h" | ||
|
||
#include "common/ser_deser.h" | ||
|
||
using namespace kuzu::common; | ||
|
||
namespace kuzu { | ||
namespace catalog { | ||
|
||
void NodeTableSchema::serializeInternal(FileInfo* fileInfo, uint64_t& offset) { | ||
SerDeser::serializeValue(primaryKeyPropertyID, fileInfo, offset); | ||
SerDeser::serializeUnorderedSet(fwdRelTableIDSet, fileInfo, offset); | ||
SerDeser::serializeUnorderedSet(bwdRelTableIDSet, fileInfo, offset); | ||
} | ||
|
||
std::unique_ptr<NodeTableSchema> NodeTableSchema::deserialize( | ||
FileInfo* fileInfo, uint64_t& offset) { | ||
property_id_t primaryKeyPropertyID; | ||
std::unordered_set<table_id_t> fwdRelTableIDSet; | ||
std::unordered_set<table_id_t> bwdRelTableIDSet; | ||
SerDeser::deserializeValue(primaryKeyPropertyID, fileInfo, offset); | ||
SerDeser::deserializeUnorderedSet(fwdRelTableIDSet, fileInfo, offset); | ||
SerDeser::deserializeUnorderedSet(bwdRelTableIDSet, fileInfo, offset); | ||
return std::make_unique<NodeTableSchema>( | ||
primaryKeyPropertyID, fwdRelTableIDSet, bwdRelTableIDSet); | ||
} | ||
|
||
} // namespace catalog | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "catalog/rdf_graph_schema.h" | ||
|
||
#include "common/ser_deser.h" | ||
|
||
using namespace kuzu::common; | ||
|
||
namespace kuzu { | ||
namespace catalog { | ||
|
||
void RdfGraphSchema::serializeInternal(FileInfo* fileInfo, uint64_t& offset) { | ||
SerDeser::serializeValue(nodeTableID, fileInfo, offset); | ||
SerDeser::serializeValue(relTableID, fileInfo, offset); | ||
} | ||
|
||
std::unique_ptr<RdfGraphSchema> RdfGraphSchema::deserialize(FileInfo* fileInfo, uint64_t& offset) { | ||
table_id_t nodeTableID; | ||
table_id_t relTableID; | ||
SerDeser::deserializeValue(nodeTableID, fileInfo, offset); | ||
SerDeser::deserializeValue(relTableID, fileInfo, offset); | ||
return std::make_unique<RdfGraphSchema>(nodeTableID, relTableID); | ||
} | ||
|
||
} // namespace catalog | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include "catalog/rel_table_schema.h" | ||
|
||
#include "common/exception.h" | ||
#include "common/ser_deser.h" | ||
|
||
using namespace kuzu::common; | ||
|
||
namespace kuzu { | ||
namespace catalog { | ||
|
||
RelMultiplicity getRelMultiplicityFromString(const std::string& relMultiplicityString) { | ||
if ("ONE_ONE" == relMultiplicityString) { | ||
return RelMultiplicity::ONE_ONE; | ||
} else if ("MANY_ONE" == relMultiplicityString) { | ||
return RelMultiplicity::MANY_ONE; | ||
} else if ("ONE_MANY" == relMultiplicityString) { | ||
return RelMultiplicity::ONE_MANY; | ||
} else if ("MANY_MANY" == relMultiplicityString) { | ||
return RelMultiplicity::MANY_MANY; | ||
} | ||
throw CatalogException("Invalid relMultiplicity string '" + relMultiplicityString + "'."); | ||
} | ||
|
||
std::string getRelMultiplicityAsString(RelMultiplicity relMultiplicity) { | ||
switch (relMultiplicity) { | ||
case RelMultiplicity::MANY_MANY: { | ||
return "MANY_MANY"; | ||
} | ||
case RelMultiplicity::MANY_ONE: { | ||
return "MANY_ONE"; | ||
} | ||
case RelMultiplicity::ONE_ONE: { | ||
return "ONE_ONE"; | ||
} | ||
case RelMultiplicity::ONE_MANY: { | ||
return "ONE_MANY"; | ||
} | ||
default: | ||
throw CatalogException("Cannot convert rel multiplicity to std::string."); | ||
} | ||
} | ||
|
||
void RelTableSchema::serializeInternal(FileInfo* fileInfo, uint64_t& offset) { | ||
SerDeser::serializeValue(relMultiplicity, fileInfo, offset); | ||
SerDeser::serializeValue(srcTableID, fileInfo, offset); | ||
SerDeser::serializeValue(dstTableID, fileInfo, offset); | ||
srcPKDataType->serialize(fileInfo, offset); | ||
dstPKDataType->serialize(fileInfo, offset); | ||
} | ||
|
||
std::unique_ptr<RelTableSchema> RelTableSchema::deserialize(FileInfo* fileInfo, uint64_t& offset) { | ||
RelMultiplicity relMultiplicity; | ||
table_id_t srcTableID; | ||
table_id_t dstTableID; | ||
SerDeser::deserializeValue(relMultiplicity, fileInfo, offset); | ||
SerDeser::deserializeValue(srcTableID, fileInfo, offset); | ||
SerDeser::deserializeValue(dstTableID, fileInfo, offset); | ||
auto srcPKDataType = LogicalType::deserialize(fileInfo, offset); | ||
auto dstPKDataType = LogicalType::deserialize(fileInfo, offset); | ||
return std::make_unique<RelTableSchema>(relMultiplicity, srcTableID, dstTableID, | ||
std::move(srcPKDataType), std::move(dstPKDataType)); | ||
} | ||
|
||
} // namespace catalog | ||
} // namespace kuzu |
Oops, something went wrong.