Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
andyfengHKU committed Jan 10, 2023
1 parent 8137ae2 commit 2e107ba
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 285 deletions.
2 changes: 2 additions & 0 deletions src/binder/bind/bind_projection_clause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ expression_vector Binder::rewriteNodeExpression(const kuzu::binder::Expression&
expression_vector Binder::rewriteRelExpression(const Expression& expression) {
expression_vector result;
auto& rel = (RelExpression&)expression;
result.push_back(rel.getSrcNode()->getInternalIDProperty());
result.push_back(rel.getDstNode()->getInternalIDProperty());
for (auto& property : rel.getPropertyExpressions()) {
result.push_back(property->copy());
}
Expand Down
1 change: 0 additions & 1 deletion src/function/built_in_vector_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "function/list/vector_list_operations.h"
#include "function/string/vector_string_operations.h"
#include "function/timestamp/vector_timestamp_operations.h"
#include "function/node/vector_node_operations.h"

namespace kuzu {
namespace function {
Expand Down
1 change: 0 additions & 1 deletion src/include/common/types/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ enum DataTypeID : uint8_t {

NODE_ID = 40,


// variable size types
STRING = 50,
LIST = 52,
Expand Down
7 changes: 7 additions & 0 deletions src/include/processor/result/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,14 @@ class NodeVal : public NodeOrRelVal {

class RelVal : public NodeOrRelVal {
public:
RelVal(unique_ptr<Value> srcNodeIDVal, unique_ptr<Value> dstNodeIDVal)
: srcNodeIDVal{std::move(srcNodeIDVal)}, dstNodeIDVal{std::move(dstNodeIDVal)} {}

string toString() const override;

private:
unique_ptr<Value> srcNodeIDVal;
unique_ptr<Value> dstNodeIDVal;
};

} // namespace processor
Expand Down
16 changes: 12 additions & 4 deletions src/main/query_result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,18 @@ void QueryResult::initResultTableAndIterator(
}
value->setNodeVal(std::move(nodeVal));
} else if (columnType.typeID == common::REL) {
auto relVal = make_unique<RelVal>();
for (auto& expression : expressionToCollectPerColumn[i]) {
assert(expression->expressionType == common::PROPERTY);
auto property = (PropertyExpression*)expression.get();
// first expression is src node ID.
assert(expressionsToCollect[0]->dataType.typeID == common::NODE_ID);
auto srcNodeIDVal = make_unique<Value>(DataType(NODE_ID));
valuesToCollect.push_back(srcNodeIDVal.get());
// second expression is dst node ID.
assert(expressionsToCollect[1]->dataType.typeID == common::NODE_ID);
auto dstNodeIDVal = make_unique<Value>(DataType(NODE_ID));
valuesToCollect.push_back(dstNodeIDVal.get());
auto relVal = make_unique<RelVal>(std::move(srcNodeIDVal), std::move(dstNodeIDVal));
for (auto j = 2u; j < expressionsToCollect.size(); ++j) {
assert(expressionsToCollect[j]->expressionType == common::PROPERTY);
auto property = (PropertyExpression*)expressionsToCollect[j].get();
auto propertyValue = make_unique<Value>(property->getDataType());
valuesToCollect.push_back(propertyValue.get());
relVal->addProperty(property->getPropertyName(), std::move(propertyValue));
Expand Down
7 changes: 4 additions & 3 deletions src/processor/result/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ string NodeVal::toString() const {
}

string RelVal::toString() const {
std::string result = "(";
result += propertiesToString();
result += ")";
std::string result;
result += "(" + srcNodeIDVal->toString() + ")";
result += "-[" + propertiesToString() + "]->";
result += "(" + dstNodeIDVal->toString() + ")";
return result;
}

Expand Down
250 changes: 0 additions & 250 deletions test/include/mock_catalog/mock_catalog.h

This file was deleted.

9 changes: 5 additions & 4 deletions test/runner/e2e_update_node_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,9 @@ TEST_F(TinySnbUpdateTest, InsertSingleNToNRelTest) {
"MATCH (a:person), (b:person) WHERE a.ID = 9 AND b.ID = 10 "
"CREATE (a)-[:knows {meetTime:timestamp('1976-12-23 11:21:42'), validInterval:interval('2 "
"years'), comments:['A', 'k'], date:date('1997-03-22')}]->(b);");
auto groundTruth = vector<string>{"9|10|({_id:40, date:1997-03-22, meetTime:1976-12-23 "
"11:21:42, validInterval:2 years, comments:[A,k]})|40"};
auto groundTruth =
vector<string>{"9|10|(0:6)-[{_id:40, date:1997-03-22, meetTime:1976-12-23 11:21:42, "
"validInterval:2 years, comments:[A,k]}]->(0:7)|40"};
auto result = conn->query(
"MATCH (a:person)-[e:knows]->(b:person) WHERE a.ID > 8 RETURN a.ID, b.ID, e, ID(e)");
ASSERT_EQ(TestHelper::convertResultToString(*result), groundTruth);
Expand All @@ -238,8 +239,8 @@ TEST_F(TinySnbUpdateTest, InsertSingleNTo1RelTest) {
conn->query("MATCH (a:person), (b:organisation) WHERE a.ID = 9 AND b.orgCode = 934 "
"CREATE (a)-[:studyAt {year:2022}]->(b);");
auto groundTruth = vector<string>{
"8|325|({_id:16, year:2020, places:[awndsnjwejwen,isuhuwennjnuhuhuwewe]})|16",
"9|934|({_id:40, year:2022, places:})|40"};
"8|325|(0:5)-[{_id:16, year:2020, places:[awndsnjwejwen,isuhuwennjnuhuhuwewe]}]->(1:0)|16",
"9|934|(0:6)-[{_id:40, year:2022, places:}]->(1:1)|40"};
auto result = conn->query("MATCH (a:person)-[e:studyAt]->(b:organisation) WHERE a.ID > 5 "
"RETURN a.ID, b.orgCode, e, ID(e)");
ASSERT_EQ(TestHelper::convertResultToString(*result), groundTruth);
Expand Down
24 changes: 12 additions & 12 deletions test/test_files/tinysnb/projection/multi_label.test
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@
-QUERY MATCH (a:person)-[e:mixed|:marries]->(b:person) RETURN e
-ENUMERATE
---- 10
({_id:27, year:1930, usedAddress:, note:})
({_id:28, year:1945, usedAddress:, note:})
({_id:29, year:2088, usedAddress:, note:})
({_id:30, year:2066, usedAddress:, note:})
({_id:31, year:2120, usedAddress:, note:})
({_id:32, year:2022, usedAddress:, note:})
({_id:33, year:2020, usedAddress:, note:})
({_id:37, year:, usedAddress:[toronto], note:})
({_id:38, year:, usedAddress:, note:long long long string})
({_id:39, year:, usedAddress:[vancouver], note:short str})
(0:0)-[{_id:27, year:1930, usedAddress:, note:}]->(0:1)
(0:0)-[{_id:37, year:, usedAddress:[toronto], note:}]->(0:1)
(0:1)-[{_id:28, year:1945, usedAddress:, note:}]->(0:3)
(0:2)-[{_id:29, year:2088, usedAddress:, note:}]->(0:4)
(0:2)-[{_id:38, year:, usedAddress:, note:long long long string}]->(0:3)
(0:4)-[{_id:30, year:2066, usedAddress:, note:}]->(0:2)
(0:4)-[{_id:39, year:, usedAddress:[vancouver], note:short str}]->(0:5)
(0:5)-[{_id:31, year:2120, usedAddress:, note:}]->(0:2)
(0:6)-[{_id:32, year:2022, usedAddress:, note:}]->(0:2)
(0:7)-[{_id:33, year:2020, usedAddress:, note:}]->(0:1)

-NAME MultiLabelReturnTest
-QUERY MATCH (a:person:organisation)-[e:mixed|:studyAt]->(b:person:organisation) WHERE a.fName='Alice' RETURN e, b.fName, b.name
-ENUMERATE
---- 2
({_id:14, year:2021, places:[wwAewsdndweusd,wek]})||ABFsUni
({_id:27, year:1930, places:})|Bob|
(0:0)-[{_id:14, year:2021, places:[wwAewsdndweusd,wek]}]->(1:0)||ABFsUni
(0:0)-[{_id:27, year:1930, places:}]->(0:1)|Bob|
Loading

0 comments on commit 2e107ba

Please sign in to comment.