-
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.
This file was recompiled the most in the entire project.
- Loading branch information
Showing
52 changed files
with
526 additions
and
347 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
add_library(kuzu_common_types_value | ||
OBJECT | ||
nested.cpp | ||
node.cpp | ||
recursive_rel.cpp | ||
rel.cpp | ||
value.cpp) | ||
|
||
set(ALL_OBJECT_FILES | ||
${ALL_OBJECT_FILES} $<TARGET_OBJECTS:kuzu_common_types_value> | ||
PARENT_SCOPE) |
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,21 @@ | ||
#include "common/types/value/nested.h" | ||
|
||
#include "common/exception/runtime.h" | ||
#include "common/types/value/value.h" | ||
|
||
namespace kuzu { | ||
namespace common { | ||
|
||
uint32_t NestedVal::getChildrenSize(const Value* val) { | ||
return val->childrenSize; | ||
} | ||
|
||
Value* NestedVal::getChildVal(const Value* val, uint32_t idx) { | ||
if (idx > val->childrenSize) { | ||
throw RuntimeException("NestedVal::getChildPointer index out of bound."); | ||
} | ||
return val->children[idx].get(); | ||
} | ||
|
||
} // namespace common | ||
} // 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,87 @@ | ||
#include "common/types/value/node.h" | ||
|
||
#include "common/constants.h" | ||
#include "common/types/types.h" | ||
#include "common/types/value/value.h" | ||
#include "spdlog/fmt/fmt.h" | ||
|
||
namespace kuzu { | ||
namespace common { | ||
|
||
std::vector<std::pair<std::string, std::unique_ptr<Value>>> NodeVal::getProperties( | ||
const Value* val) { | ||
throwIfNotNode(val); | ||
std::vector<std::pair<std::string, std::unique_ptr<Value>>> properties; | ||
auto fieldNames = StructType::getFieldNames(val->dataType.get()); | ||
for (auto i = 0u; i < val->childrenSize; ++i) { | ||
auto currKey = fieldNames[i]; | ||
if (currKey == InternalKeyword::ID || currKey == InternalKeyword::LABEL) { | ||
continue; | ||
} | ||
properties.emplace_back(currKey, val->children[i]->copy()); | ||
} | ||
return properties; | ||
} | ||
|
||
uint64_t NodeVal::getNumProperties(const Value* val) { | ||
throwIfNotNode(val); | ||
auto fieldNames = StructType::getFieldNames(val->dataType.get()); | ||
return fieldNames.size() - OFFSET; | ||
} | ||
|
||
std::string NodeVal::getPropertyName(const Value* val, uint64_t index) { | ||
throwIfNotNode(val); | ||
auto fieldNames = StructType::getFieldNames(val->dataType.get()); | ||
if (index >= fieldNames.size() - OFFSET) { | ||
return ""; | ||
} | ||
return fieldNames[index + OFFSET]; | ||
} | ||
|
||
Value* NodeVal::getPropertyVal(const Value* val, uint64_t index) { | ||
throwIfNotNode(val); | ||
auto fieldNames = StructType::getFieldNames(val->dataType.get()); | ||
if (index >= fieldNames.size() - OFFSET) { | ||
return nullptr; | ||
} | ||
return val->children[index + OFFSET].get(); | ||
} | ||
|
||
Value* NodeVal::getNodeIDVal(const Value* val) { | ||
throwIfNotNode(val); | ||
auto fieldIdx = StructType::getFieldIdx(val->dataType.get(), InternalKeyword::ID); | ||
return val->children[fieldIdx].get(); | ||
} | ||
|
||
Value* NodeVal::getLabelVal(const Value* val) { | ||
throwIfNotNode(val); | ||
auto fieldIdx = StructType::getFieldIdx(val->dataType.get(), InternalKeyword::LABEL); | ||
return val->children[fieldIdx].get(); | ||
} | ||
|
||
nodeID_t NodeVal::getNodeID(const Value* val) { | ||
throwIfNotNode(val); | ||
auto nodeIDVal = getNodeIDVal(val); | ||
return nodeIDVal->getValue<nodeID_t>(); | ||
} | ||
|
||
std::string NodeVal::getLabelName(const Value* val) { | ||
throwIfNotNode(val); | ||
auto labelVal = getLabelVal(val); | ||
return labelVal->getValue<std::string>(); | ||
} | ||
|
||
std::string NodeVal::toString(const Value* val) { | ||
throwIfNotNode(val); | ||
return val->toString(); | ||
} | ||
|
||
void NodeVal::throwIfNotNode(const Value* val) { | ||
if (val->dataType->getLogicalTypeID() != LogicalTypeID::NODE) { | ||
auto actualType = LogicalTypeUtils::dataTypeToString(val->dataType->getLogicalTypeID()); | ||
throw Exception(fmt::format("Expected NODE type, but got {} type", actualType)); | ||
} | ||
} | ||
|
||
} // namespace common | ||
} // 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,29 @@ | ||
#include "common/types/value/recursive_rel.h" | ||
|
||
#include "common/exception/exception.h" | ||
#include "common/types/types.h" | ||
#include "common/types/value/value.h" | ||
#include "spdlog/fmt/fmt.h" | ||
|
||
namespace kuzu { | ||
namespace common { | ||
|
||
Value* RecursiveRelVal::getNodes(const Value* val) { | ||
throwIfNotRecursiveRel(val); | ||
return val->children[0].get(); | ||
} | ||
|
||
Value* RecursiveRelVal::getRels(const Value* val) { | ||
throwIfNotRecursiveRel(val); | ||
return val->children[1].get(); | ||
} | ||
|
||
void RecursiveRelVal::throwIfNotRecursiveRel(const Value* val) { | ||
if (val->dataType->getLogicalTypeID() != LogicalTypeID::RECURSIVE_REL) { | ||
auto actualType = LogicalTypeUtils::dataTypeToString(val->dataType->getLogicalTypeID()); | ||
throw Exception(fmt::format("Expected RECURSIVE_REL type, but got {} type", actualType)); | ||
} | ||
} | ||
|
||
} // namespace common | ||
} // 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,91 @@ | ||
#include "common/types/value/rel.h" | ||
|
||
#include "common/constants.h" | ||
#include "common/types/value/value.h" | ||
#include "spdlog/fmt/fmt.h" | ||
|
||
namespace kuzu { | ||
namespace common { | ||
|
||
std::vector<std::pair<std::string, std::unique_ptr<Value>>> RelVal::getProperties( | ||
const Value* val) { | ||
throwIfNotRel(val); | ||
std::vector<std::pair<std::string, std::unique_ptr<Value>>> properties; | ||
auto fieldNames = StructType::getFieldNames(val->dataType.get()); | ||
for (auto i = 0u; i < val->childrenSize; ++i) { | ||
auto currKey = fieldNames[i]; | ||
if (currKey == InternalKeyword::ID || currKey == InternalKeyword::LABEL || | ||
currKey == InternalKeyword::SRC || currKey == InternalKeyword::DST) { | ||
continue; | ||
} | ||
auto currVal = val->children[i]->copy(); | ||
properties.emplace_back(currKey, std::move(currVal)); | ||
} | ||
return properties; | ||
} | ||
|
||
uint64_t RelVal::getNumProperties(const Value* val) { | ||
throwIfNotRel(val); | ||
auto fieldNames = StructType::getFieldNames(val->dataType.get()); | ||
return fieldNames.size() - OFFSET; | ||
} | ||
|
||
std::string RelVal::getPropertyName(const Value* val, uint64_t index) { | ||
throwIfNotRel(val); | ||
auto fieldNames = StructType::getFieldNames(val->dataType.get()); | ||
if (index >= fieldNames.size() - OFFSET) { | ||
return ""; | ||
} | ||
return fieldNames[index + OFFSET]; | ||
} | ||
|
||
Value* RelVal::getPropertyVal(const Value* val, uint64_t index) { | ||
throwIfNotRel(val); | ||
auto fieldNames = StructType::getFieldNames(val->dataType.get()); | ||
if (index >= fieldNames.size() - OFFSET) { | ||
return nullptr; | ||
} | ||
return val->children[index + OFFSET].get(); | ||
} | ||
|
||
Value* RelVal::getSrcNodeIDVal(const Value* val) { | ||
auto fieldIdx = StructType::getFieldIdx(val->dataType.get(), InternalKeyword::SRC); | ||
return val->children[fieldIdx].get(); | ||
} | ||
|
||
Value* RelVal::getDstNodeIDVal(const Value* val) { | ||
auto fieldIdx = StructType::getFieldIdx(val->dataType.get(), InternalKeyword::DST); | ||
return val->children[fieldIdx].get(); | ||
} | ||
|
||
nodeID_t RelVal::getSrcNodeID(const Value* val) { | ||
throwIfNotRel(val); | ||
auto srcNodeIDVal = getSrcNodeIDVal(val); | ||
return srcNodeIDVal->getValue<nodeID_t>(); | ||
} | ||
|
||
nodeID_t RelVal::getDstNodeID(const Value* val) { | ||
throwIfNotRel(val); | ||
auto dstNodeIDVal = getDstNodeIDVal(val); | ||
return dstNodeIDVal->getValue<nodeID_t>(); | ||
} | ||
|
||
std::string RelVal::getLabelName(const Value* val) { | ||
auto fieldIdx = StructType::getFieldIdx(val->dataType.get(), InternalKeyword::LABEL); | ||
return val->children[fieldIdx]->getValue<std::string>(); | ||
} | ||
|
||
std::string RelVal::toString(const Value* val) { | ||
throwIfNotRel(val); | ||
return val->toString(); | ||
} | ||
|
||
void RelVal::throwIfNotRel(const Value* val) { | ||
if (val->dataType->getLogicalTypeID() != LogicalTypeID::REL) { | ||
auto actualType = LogicalTypeUtils::dataTypeToString(val->dataType->getLogicalTypeID()); | ||
throw Exception(fmt::format("Expected REL type, but got {} type", actualType)); | ||
} | ||
} | ||
|
||
} // namespace common | ||
} // namespace kuzu |
Oops, something went wrong.