This is an automated email from the ASF dual-hosted git repository.
xiaokang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-graphar.git
The following commit(s) were added to refs/heads/main by this push:
new bfa6ec75 fix(c++): keep property readers in sync when crossing full
edge-chunk boundaries in EdgeIter::operator++ (#736)
bfa6ec75 is described below
commit bfa6ec751a409f0b87f5bf74986d246869b740f3
Author: Gary <[email protected]>
AuthorDate: Mon Aug 25 13:46:34 2025 +0800
fix(c++): keep property readers in sync when crossing full edge-chunk
boundaries in EdgeIter::operator++ (#736)
* fix: EdgeIter readers need to be updated at the boundaries of chunks of
size chunk_size
* add EdgeIter relevant test
* fix format
* fix format (clang-format-8)
---
cpp/src/graphar/high-level/graph_reader.h | 5 ++
cpp/test/test_graph.cc | 77 +++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+)
diff --git a/cpp/src/graphar/high-level/graph_reader.h
b/cpp/src/graphar/high-level/graph_reader.h
index e9f76e41..3cd36886 100644
--- a/cpp/src/graphar/high-level/graph_reader.h
+++ b/cpp/src/graphar/high-level/graph_reader.h
@@ -609,6 +609,11 @@ class EdgeIter {
GAR_ASSIGN_OR_RAISE_ERROR(num_row_of_chunk_,
adj_list_reader_.GetRowNumOfChunk());
++global_chunk_index_;
+ // The reader also need to be updated at the boundaries of chunks of size
+ // chunk_size.
+ for (auto& reader : property_readers_) {
+ reader.next_chunk();
+ }
}
if (st.IsKeyError()) {
st = adj_list_reader_.next_chunk();
diff --git a/cpp/test/test_graph.cc b/cpp/test/test_graph.cc
index a2afe89f..0cd211d1 100644
--- a/cpp/test/test_graph.cc
+++ b/cpp/test/test_graph.cc
@@ -221,5 +221,82 @@ TEST_CASE_METHOD(GlobalFixture, "Graph") {
auto last_invalid_vertex = *(vertices->end() + -1);
REQUIRE(last_invalid_vertex.property<int64_t>(property).has_error());
}
+
+ SECTION("EdgeIterator") {
+ std::string src_type = "person", edge_type = "knows", dst_type = "person";
+ auto expect =
+ EdgesCollection::Make(graph_info, src_type, edge_type, dst_type,
+ AdjListType::ordered_by_source);
+ REQUIRE(!expect.has_error());
+ auto edges = expect.value();
+
+ // Test iterator functionality
+ auto begin = edges->begin();
+ auto end = edges->end();
+ size_t count = 0;
+
+ // Iterate through first 2000 edges
+ for (auto it = begin; it != end; ++it) {
+ if (count >= 2000) {
+ break;
+ }
+ count++;
+ REQUIRE(it.source() >= 0);
+ REQUIRE(it.destination() >= 0);
+ REQUIRE(it.property<std::string>("creationDate").has_value());
+ }
+ REQUIRE(count == 2000);
+
+ // Test skipping and iterating next 2000 edges
+ auto begin2 = edges->begin();
+ size_t i = 0;
+ for (auto it = begin2; it != end; ++it, i++) {
+ if (i < 2000) {
+ continue;
+ }
+ if (i >= 4000) {
+ break;
+ }
+ count++;
+ REQUIRE(it.source() >= 0);
+ REQUIRE(it.destination() >= 0);
+ REQUIRE(it.property<std::string>("creationDate").has_value());
+ }
+ REQUIRE(count == 4000);
+
+ // Test skipping and iterating next 2000 edges
+ auto begin3 = edges->begin();
+ size_t j = 0;
+ for (auto it = begin3; it != end; ++it, j++) {
+ if (j < 4000) {
+ continue;
+ }
+ if (j >= 6000) {
+ break;
+ }
+ count++;
+ REQUIRE(it.source() >= 0);
+ REQUIRE(it.destination() >= 0);
+ REQUIRE(it.property<std::string>("creationDate").has_value());
+ }
+ REQUIRE(count == 6000);
+
+ // Test iterating remaining edges
+ auto begin4 = edges->begin();
+ size_t k = 0;
+ for (auto it = begin4; it != end; ++it, k++) {
+ if (k < 6000) {
+ continue;
+ }
+ count++;
+ REQUIRE(it.source() >= 0);
+ REQUIRE(it.destination() >= 0);
+ REQUIRE(it.property<std::string>("creationDate").has_value());
+ }
+
+ // Verify total count matches collection size
+ REQUIRE(count == edges->size());
+ std::cout << "Total edge_count=" << count << std::endl;
+ }
}
} // namespace graphar
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]