This is an automated email from the ASF dual-hosted git repository.
yangxk1 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 c979f4b0 feat(test): add property filter test for VerticesCollection
(#916)
c979f4b0 is described below
commit c979f4b011b1f4ba05c1935779cf3f2067f03542
Author: Jason <[email protected]>
AuthorDate: Mon May 11 12:54:35 2026 +0800
feat(test): add property filter test for VerticesCollection (#916)
Signed-off-by: Jason <[email protected]>
---
cpp/test/test_graph.cc | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/cpp/test/test_graph.cc b/cpp/test/test_graph.cc
index 6c83f163..ed81fb8d 100644
--- a/cpp/test/test_graph.cc
+++ b/cpp/test/test_graph.cc
@@ -21,10 +21,14 @@
#include "./util.h"
#include "graphar/api/high_level_reader.h"
+#include "graphar/expression.h"
#include <catch2/catch_test_macros.hpp>
namespace graphar {
+constexpr size_t expectedFemaleCount = 454;
+constexpr size_t expectedMaleCount = 449;
+constexpr size_t expectedTotalCount = 903;
TEST_CASE_METHOD(GlobalFixture, "Graph") {
// read file and construct graph info
std::string path =
@@ -113,6 +117,41 @@ TEST_CASE_METHOD(GlobalFixture, "Graph") {
}
}
+ SECTION("VerticesCollectionFilterByProperty") {
+ auto vertex_info = graph_info->GetVertexInfo("person");
+ REQUIRE(vertex_info != nullptr);
+
+ auto vertices = std::make_shared<VerticesCollection>(
+ vertex_info, graph_info->GetPrefix());
+ REQUIRE(vertices->size() == expectedTotalCount);
+ std::cout << "total size " << vertices->size() << std::endl;
+ // filter female vertices
+ auto filter_female =
+ _Equal(_Property("gender"), _Literal(std::string("female")));
+ std::vector<IdType> new_valid_chunk;
+ auto maybe_filtered_female_ids =
+ vertices->filter("gender", filter_female, &new_valid_chunk);
+ REQUIRE(maybe_filtered_female_ids.status().ok());
+ auto filtered_female_ids = maybe_filtered_female_ids.value();
+ // filter male vertices
+ auto filter_male =
+ _Equal(_Property("gender"), _Literal(std::string("male")));
+ auto maybe_filtered_male_ids =
+ vertices->filter("gender", filter_male, &new_valid_chunk);
+ REQUIRE(maybe_filtered_male_ids.status().ok());
+ auto filtered_male_ids = maybe_filtered_male_ids.value();
+
+ std::cout << "Filtered " << filtered_female_ids.size()
+ << " vertices with gender='female'" << std::endl;
+ std::cout << "Filtered " << filtered_male_ids.size()
+ << " vertices with gender='male'" << std::endl;
+
+ REQUIRE(filtered_female_ids.size() == expectedFemaleCount);
+ REQUIRE(filtered_male_ids.size() == expectedMaleCount);
+ REQUIRE(filtered_male_ids.size() + filtered_female_ids.size() ==
+ expectedTotalCount);
+ }
+
SECTION("ListProperty") {
// read file and construct graph info
std::string path =
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]