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

Fix empty list bug #1358

Merged
merged 1 commit into from
Mar 8, 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
2 changes: 1 addition & 1 deletion dataset/tinysnb/eMarries.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
0,2,"[toronto]","[4,5]",
3,5,,"[2,5]","long long long string"
7,8,"[vancouver]","[3,9]","short str"
7,8,"[]","[3,9]","short str"
4 changes: 4 additions & 0 deletions src/common/in_mem_overflow_buffer_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ void InMemOverflowBufferUtils::copyListNonRecursive(const uint8_t* srcValues, ku
void InMemOverflowBufferUtils::copyListRecursiveIfNested(const ku_list_t& src, ku_list_t& dest,
const DataType& dataType, InMemOverflowBuffer& inMemOverflowBuffer, uint32_t srcStartIdx,
uint32_t srcEndIdx) {
if (src.size == 0) {
dest.size = 0;
return;
}
if (srcEndIdx == UINT32_MAX) {
srcEndIdx = src.size - 1;
}
Expand Down
5 changes: 4 additions & 1 deletion src/common/types/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,11 @@ std::string Value::toString() const {
std::string result = "[";
for (auto i = 0u; i < listVal.size(); ++i) {
result += listVal[i]->toString();
result += (i == listVal.size() - 1 ? "]" : ",");
if (i != listVal.size() - 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually prefer for i =0, I < size - 1 and write an additional line after the loop which avoids unnecessary runtime if checking. But up to u.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the listVal.size() is 0, i think this code: for i =0, I < size - 1 will cause a bug.

result += ",";
}
}
result += "]";
return result;
}
case NODE:
Expand Down
2 changes: 1 addition & 1 deletion test/test_files/tinysnb/projection/single_label.test
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ Dan|Carol
---- 3
(0:0)-[label:marries, {_id:7:0, usedAddress:[toronto], address:[4,5], note:}]->(0:1)
(0:2)-[label:marries, {_id:7:1, usedAddress:, address:[2,5], note:long long long string}]->(0:3)
(0:4)-[label:marries, {_id:7:2, usedAddress:[vancouver], address:[3,9], note:short str}]->(0:5)
(0:4)-[label:marries, {_id:7:2, usedAddress:[], address:[3,9], note:short str}]->(0:5)

-NAME ReturnFixedListNodeProp
-QUERY MATCH (a:person) RETURN a.grades
Expand Down