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 nested value iteration #1845

Merged
merged 4 commits into from
Jul 23, 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
30 changes: 14 additions & 16 deletions src/c_api/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,15 @@
}

uint64_t kuzu_value_get_list_size(kuzu_value* value) {
auto& list_val = static_cast<Value*>(value->_value)->getListValReference();
return list_val.size();
return NestedVal::getChildrenSize(static_cast<Value*>(value->_value));
}

kuzu_value* kuzu_value_get_list_element(kuzu_value* value, uint64_t index) {
auto& list_val = static_cast<Value*>(value->_value)->getListValReference();
if (index >= list_val.size()) {
auto listValue = static_cast<Value*>(value->_value);
if (index >= NestedVal::getChildrenSize(listValue)) {
return nullptr;
}
auto& list_element = list_val[index];
auto val = list_element.get();
auto val = NestedVal::getChildVal(listValue, index);
auto* c_value = (kuzu_value*)malloc(sizeof(kuzu_value));
c_value->_value = val;
c_value->_is_owned_by_cpp = true;
Expand Down Expand Up @@ -262,16 +260,16 @@
kuzu_value* kuzu_node_val_get_id_val(kuzu_value* node_val) {
auto id_val = NodeVal::getNodeIDVal(static_cast<Value*>(node_val->_value));
auto* c_value = (kuzu_value*)malloc(sizeof(kuzu_value));
c_value->_value = id_val.release();
c_value->_is_owned_by_cpp = false;
c_value->_value = id_val;
c_value->_is_owned_by_cpp = true;

Check warning on line 264 in src/c_api/value.cpp

View check run for this annotation

Codecov / codecov/patch

src/c_api/value.cpp#L263-L264

Added lines #L263 - L264 were not covered by tests
return c_value;
}

kuzu_value* kuzu_node_val_get_label_val(kuzu_value* node_val) {
auto label_val = NodeVal::getLabelVal(static_cast<Value*>(node_val->_value));
auto* c_value = (kuzu_value*)malloc(sizeof(kuzu_value));
c_value->_value = label_val.release();
c_value->_is_owned_by_cpp = false;
c_value->_value = label_val;
c_value->_is_owned_by_cpp = true;
return c_value;
}

Expand Down Expand Up @@ -302,7 +300,7 @@
}

kuzu_value* kuzu_node_val_get_property_value_at(kuzu_value* node_val, uint64_t index) {
auto value = NodeVal::getPropertyValueReference(static_cast<Value*>(node_val->_value), index);
auto value = NodeVal::getPropertyVal(static_cast<Value*>(node_val->_value), index);
auto* c_value = (kuzu_value*)malloc(sizeof(kuzu_value));
c_value->_value = value;
c_value->_is_owned_by_cpp = true;
Expand All @@ -319,16 +317,16 @@
kuzu_value* kuzu_rel_val_get_src_id_val(kuzu_value* rel_val) {
auto src_id_val = RelVal::getSrcNodeIDVal(static_cast<Value*>(rel_val->_value));
auto* c_value = (kuzu_value*)malloc(sizeof(kuzu_value));
c_value->_value = src_id_val.release();
c_value->_is_owned_by_cpp = false;
c_value->_value = src_id_val;
c_value->_is_owned_by_cpp = true;

Check warning on line 321 in src/c_api/value.cpp

View check run for this annotation

Codecov / codecov/patch

src/c_api/value.cpp#L320-L321

Added lines #L320 - L321 were not covered by tests
return c_value;
}

kuzu_value* kuzu_rel_val_get_dst_id_val(kuzu_value* rel_val) {
auto dst_id_val = RelVal::getDstNodeIDVal(static_cast<Value*>(rel_val->_value));
auto* c_value = (kuzu_value*)malloc(sizeof(kuzu_value));
c_value->_value = dst_id_val.release();
c_value->_is_owned_by_cpp = false;
c_value->_value = dst_id_val;
c_value->_is_owned_by_cpp = true;

Check warning on line 329 in src/c_api/value.cpp

View check run for this annotation

Codecov / codecov/patch

src/c_api/value.cpp#L328-L329

Added lines #L328 - L329 were not covered by tests
return c_value;
}

Expand Down Expand Up @@ -366,7 +364,7 @@
}

kuzu_value* kuzu_rel_val_get_property_value_at(kuzu_value* rel_val, uint64_t index) {
auto value = RelVal::getPropertyValueReference(static_cast<Value*>(rel_val->_value), index);
auto value = RelVal::getPropertyVal(static_cast<Value*>(rel_val->_value), index);
auto* c_value = (kuzu_value*)malloc(sizeof(kuzu_value));
c_value->_value = value;
c_value->_is_owned_by_cpp = true;
Expand Down
26 changes: 13 additions & 13 deletions src/common/arrow/arrow_row_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
ArrowVector* vector, const main::DataTypeInfo& typeInfo, Value* value, std::int64_t pos) {
vector->data.resize((pos + 2) * sizeof(std::uint32_t));
auto offsets = (std::uint32_t*)vector->data.data();
auto numElements = value->nestedTypeVal.size();
auto numElements = value->childrenSize;

Check warning on line 195 in src/common/arrow/arrow_row_batch.cpp

View check run for this annotation

Codecov / codecov/patch

src/common/arrow/arrow_row_batch.cpp#L195

Added line #L195 was not covered by tests
offsets[pos + 1] = offsets[pos] + numElements;
auto numChildElements = offsets[pos + 1] + 1;
auto currentNumBytesForChildValidity = vector->childData[0]->validity.size();
Expand All @@ -208,8 +208,8 @@
LogicalType{typeInfo.childrenTypesInfo[0]->typeID}));
}
for (auto i = 0u; i < numElements; i++) {
appendValue(vector->childData[0].get(), *typeInfo.childrenTypesInfo[0],
value->nestedTypeVal[i].get());
appendValue(
vector->childData[0].get(), *typeInfo.childrenTypesInfo[0], value->children[i].get());

Check warning on line 212 in src/common/arrow/arrow_row_batch.cpp

View check run for this annotation

Codecov / codecov/patch

src/common/arrow/arrow_row_batch.cpp#L211-L212

Added lines #L211 - L212 were not covered by tests
}
}

Expand All @@ -226,15 +226,15 @@
template<>
void ArrowRowBatch::templateCopyNonNullValue<LogicalTypeID::NODE>(
ArrowVector* vector, const main::DataTypeInfo& typeInfo, Value* value, std::int64_t pos) {
appendValue(vector->childData[0].get(), *typeInfo.childrenTypesInfo[0],
NodeVal::getNodeIDVal(value).get());
appendValue(vector->childData[1].get(), *typeInfo.childrenTypesInfo[1],
NodeVal::getLabelVal(value).get());
appendValue(

Check warning on line 229 in src/common/arrow/arrow_row_batch.cpp

View check run for this annotation

Codecov / codecov/patch

src/common/arrow/arrow_row_batch.cpp#L229

Added line #L229 was not covered by tests
vector->childData[0].get(), *typeInfo.childrenTypesInfo[0], NodeVal::getNodeIDVal(value));
appendValue(

Check warning on line 231 in src/common/arrow/arrow_row_batch.cpp

View check run for this annotation

Codecov / codecov/patch

src/common/arrow/arrow_row_batch.cpp#L231

Added line #L231 was not covered by tests
vector->childData[1].get(), *typeInfo.childrenTypesInfo[1], NodeVal::getLabelVal(value));
std::int64_t propertyId = 2;
auto numProperties = NodeVal::getNumProperties(value);
for (auto i = 0u; i < numProperties; i++) {
auto name = NodeVal::getPropertyName(value, i);
auto val = NodeVal::getPropertyValueReference(value, i);
auto val = NodeVal::getPropertyVal(value, i);

Check warning on line 237 in src/common/arrow/arrow_row_batch.cpp

View check run for this annotation

Codecov / codecov/patch

src/common/arrow/arrow_row_batch.cpp#L237

Added line #L237 was not covered by tests
appendValue(
vector->childData[propertyId].get(), *typeInfo.childrenTypesInfo[propertyId], val);
propertyId++;
Expand All @@ -244,15 +244,15 @@
template<>
void ArrowRowBatch::templateCopyNonNullValue<LogicalTypeID::REL>(
ArrowVector* vector, const main::DataTypeInfo& typeInfo, Value* value, std::int64_t pos) {
appendValue(vector->childData[0].get(), *typeInfo.childrenTypesInfo[0],
RelVal::getSrcNodeIDVal(value).get());
appendValue(vector->childData[1].get(), *typeInfo.childrenTypesInfo[1],
RelVal::getDstNodeIDVal(value).get());
appendValue(

Check warning on line 247 in src/common/arrow/arrow_row_batch.cpp

View check run for this annotation

Codecov / codecov/patch

src/common/arrow/arrow_row_batch.cpp#L247

Added line #L247 was not covered by tests
vector->childData[0].get(), *typeInfo.childrenTypesInfo[0], RelVal::getSrcNodeIDVal(value));
appendValue(

Check warning on line 249 in src/common/arrow/arrow_row_batch.cpp

View check run for this annotation

Codecov / codecov/patch

src/common/arrow/arrow_row_batch.cpp#L249

Added line #L249 was not covered by tests
vector->childData[1].get(), *typeInfo.childrenTypesInfo[1], RelVal::getDstNodeIDVal(value));
std::int64_t propertyId = 2;
auto numProperties = NodeVal::getNumProperties(value);
for (auto i = 0u; i < numProperties; i++) {
auto name = NodeVal::getPropertyName(value, i);
auto val = NodeVal::getPropertyValueReference(value, i);
auto val = NodeVal::getPropertyVal(value, i);

Check warning on line 255 in src/common/arrow/arrow_row_batch.cpp

View check run for this annotation

Codecov / codecov/patch

src/common/arrow/arrow_row_batch.cpp#L255

Added line #L255 was not covered by tests
appendValue(
vector->childData[propertyId].get(), *typeInfo.childrenTypesInfo[propertyId], val);
propertyId++;
Expand Down
Loading
Loading