acezen commented on code in PR #518:
URL: https://github.com/apache/incubator-graphar/pull/518#discussion_r1642355642
##########
cpp/test/test_arrow_chunk_reader.cc:
##########
@@ -462,4 +462,434 @@ TEST_CASE_METHOD(GlobalFixture, "ArrowChunkReader") {
REQUIRE(reader->seek(1024).IsIndexError());
}
}
+
+TEST_CASE_METHOD(GlobalFixture, "JSON_TEST") {
+ // read file and construct graph info
+ std::string path = test_data_dir + "/ldbc_sample/json/LdbcSample.graph.yml";
+ std::string src_label = "person", edge_label = "knows", dst_label = "person";
+ std::string vertex_property_name = "id";
+ std::string edge_property_name = "creationDate";
+ auto maybe_graph_info = GraphInfo::Load(path);
+ REQUIRE(maybe_graph_info.status().ok());
+ auto graph_info = maybe_graph_info.value();
+ auto vertex_info = graph_info->GetVertexInfo(src_label);
+ REQUIRE(vertex_info != nullptr);
+ auto v_pg = vertex_info->GetPropertyGroup(vertex_property_name);
+ REQUIRE(v_pg != nullptr);
+ auto edge_info = graph_info->GetEdgeInfo(src_label, edge_label, dst_label);
+ REQUIRE(edge_info != nullptr);
+ auto e_pg = edge_info->GetPropertyGroup(edge_property_name);
+ REQUIRE(e_pg != nullptr);
+
+ SECTION("VertexPropertyArrowChunkReader") {
+ auto maybe_reader = VertexPropertyArrowChunkReader::Make(
+ graph_info, src_label, vertex_property_name);
+ REQUIRE(maybe_reader.status().ok());
+ auto reader = maybe_reader.value();
+ REQUIRE(reader->GetChunkNum() == 10);
+
+ SECTION("Basics") {
+ auto result = reader->GetChunk();
+ REQUIRE(!result.has_error());
+ auto table = result.value();
+ REQUIRE(table->num_rows() == 100);
+ REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
+ nullptr);
+
+ // seek
+ REQUIRE(reader->seek(100).ok());
+ result = reader->GetChunk();
+ REQUIRE(!result.has_error());
+ table = result.value();
+ REQUIRE(table->num_rows() == 100);
+ REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
+ nullptr);
+ REQUIRE(reader->next_chunk().ok());
+ result = reader->GetChunk();
+ REQUIRE(!result.has_error());
+ table = result.value();
+ REQUIRE(table->num_rows() == 100);
+ REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
+ nullptr);
+ REQUIRE(reader->seek(900).ok());
+ result = reader->GetChunk();
+ REQUIRE(!result.has_error());
+ table = result.value();
+ REQUIRE(table->num_rows() == 3);
+ REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
+ nullptr);
+ REQUIRE(reader->GetChunkNum() == 10);
+ REQUIRE(reader->next_chunk().IsIndexError());
+
+ REQUIRE(reader->seek(1024).IsIndexError());
+ }
+
+ SECTION("CastDataType") {
+ std::string vertex_info_path =
+ test_data_dir + "ldbc_sample/json/Person.vertex.yml";
+ std::cout << "Vertex info path: " << vertex_info_path << std::endl;
+ auto fs = FileSystemFromUriOrPath(prefix).value();
+ auto yaml_content =
+ fs->ReadFileToValue<std::string>(vertex_info_path).value();
+ std::cout << yaml_content << std::endl;
+ auto maybe_vertex_info = VertexInfo::Load(yaml_content);
+ REQUIRE(maybe_vertex_info.status().ok());
+ auto vertex_info = maybe_vertex_info.value();
+ std::cout << vertex_info->Dump().value() << std::endl;
+ auto pg = vertex_info->GetPropertyGroup("id");
+ REQUIRE(pg != nullptr);
+ REQUIRE(pg->GetProperties().size() == 1);
+ auto origin_property = pg->GetProperties()[0];
+ REQUIRE(origin_property.type->Equals(int64()));
+
+ // change to int32_t
+ Property new_property("id", int32(), origin_property.is_primary,
+ origin_property.is_nullable);
+ auto new_pg = CreatePropertyGroup({new_property}, pg->GetFileType(),
+ pg->GetPrefix());
+ auto maybe_reader =
+ VertexPropertyArrowChunkReader::Make(vertex_info, new_pg, prefix);
Review Comment:
Ditto, see
[report](https://github.com/apache/incubator-graphar/actions/runs/9485693706/job/26138343424?pr=518)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]