acezen commented on code in PR #607:
URL: https://github.com/apache/incubator-graphar/pull/607#discussion_r1772657546


##########
cpp/examples/high_level_label_reader_example.cc:
##########
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <iostream>
+
+#include "arrow/api.h"
+#include "arrow/filesystem/api.h"
+
+#include "./config.h"
+#include "graphar/api/high_level_reader.h"
+
+void vertices_collection(
+    const std::shared_ptr<graphar::GraphInfo>& graph_info) {
+  std::string type = "organisation";
+  auto vertex_info = graph_info->GetVertexInfo("organisation");
+  auto labels = vertex_info->GetLabels();
+
+  std::cout << "Query vertices with a specific label" << std::endl;
+  std::cout << "--------------------------------------" << std::endl;
+
+  auto maybe_filter_vertices_collection =
+      graphar::VerticesCollection::verticesWithLabel(std::string("company"),
+                                                     graph_info, type);
+
+  ASSERT(!maybe_filter_vertices_collection.has_error());
+  auto filter_vertices = maybe_filter_vertices_collection.value();
+  std::cout << "valid vertices num: " << filter_vertices->size() << std::endl;
+
+  // for (auto it = filter_vertices->begin(); it != filter_vertices->end();
+  // ++it) {
+  //   // get a node's all labels
+  //   auto label_result = it.label();
+  //   std::cout<< "id: " << it.id()<<" ";
+  //   if (!label_result.has_error()) {
+  //       for (auto label : label_result.value()) {
+  //           std::cout << label << " ";
+  //       }
+  //   }
+  //   std::cout << "name: ";
+  //   auto property = it.property<std::string>("name").value();
+  //   std::cout << property << " ";
+  //   std::cout<<std::endl;
+  // }
+
+  std::cout << std::endl;
+  std::cout << "Query vertices with specific label in a filtered vertices set"
+            << std::endl;
+  std::cout << "--------------------------------------" << std::endl;
+
+  auto maybe_filter_vertices_collection_2 =
+      graphar::VerticesCollection::verticesWithLabel(std::string("public"),
+                                                     filter_vertices);
+  ASSERT(!maybe_filter_vertices_collection_2.has_error());
+  auto filter_vertices_2 = maybe_filter_vertices_collection_2.value();
+  std::cout << "valid vertices num: " << filter_vertices_2->size() << 
std::endl;
+
+  // for (auto it = filter_vertices_2->begin(); it != filter_vertices_2->end();

Review Comment:
   Ditto



##########
cpp/examples/high_level_label_reader_example.cc:
##########
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <iostream>
+
+#include "arrow/api.h"
+#include "arrow/filesystem/api.h"
+
+#include "./config.h"
+#include "graphar/api/high_level_reader.h"
+
+void vertices_collection(
+    const std::shared_ptr<graphar::GraphInfo>& graph_info) {
+  std::string type = "organisation";
+  auto vertex_info = graph_info->GetVertexInfo("organisation");
+  auto labels = vertex_info->GetLabels();
+
+  std::cout << "Query vertices with a specific label" << std::endl;
+  std::cout << "--------------------------------------" << std::endl;
+
+  auto maybe_filter_vertices_collection =
+      graphar::VerticesCollection::verticesWithLabel(std::string("company"),
+                                                     graph_info, type);
+
+  ASSERT(!maybe_filter_vertices_collection.has_error());
+  auto filter_vertices = maybe_filter_vertices_collection.value();
+  std::cout << "valid vertices num: " << filter_vertices->size() << std::endl;
+
+  // for (auto it = filter_vertices->begin(); it != filter_vertices->end();
+  // ++it) {
+  //   // get a node's all labels
+  //   auto label_result = it.label();
+  //   std::cout<< "id: " << it.id()<<" ";
+  //   if (!label_result.has_error()) {
+  //       for (auto label : label_result.value()) {
+  //           std::cout << label << " ";
+  //       }
+  //   }
+  //   std::cout << "name: ";
+  //   auto property = it.property<std::string>("name").value();
+  //   std::cout << property << " ";
+  //   std::cout<<std::endl;
+  // }
+
+  std::cout << std::endl;
+  std::cout << "Query vertices with specific label in a filtered vertices set"
+            << std::endl;
+  std::cout << "--------------------------------------" << std::endl;
+
+  auto maybe_filter_vertices_collection_2 =
+      graphar::VerticesCollection::verticesWithLabel(std::string("public"),
+                                                     filter_vertices);
+  ASSERT(!maybe_filter_vertices_collection_2.has_error());
+  auto filter_vertices_2 = maybe_filter_vertices_collection_2.value();
+  std::cout << "valid vertices num: " << filter_vertices_2->size() << 
std::endl;
+
+  // for (auto it = filter_vertices_2->begin(); it != filter_vertices_2->end();
+  // ++it) {
+  //     auto label_result = it.label();
+  //     std::cout<< "id: " << it.id()<<" ";
+  //     if (!label_result.has_error()) {
+  //         for (auto label : label_result.value()) {
+  //             std::cout << label << " ";
+  //         }
+  //     }
+  //     std::cout << "name: ";
+  //     auto property = it.property<std::string>("name").value();
+  //     std::cout << property << " ";
+  //     std::cout<<std::endl;
+  // }
+
+  std::cout << std::endl;
+  std::cout << "Test vertices with multi labels" << std::endl;
+  std::cout << "--------------------------------------" << std::endl;
+  auto maybe_filter_vertices_collection_3 =
+      graphar::VerticesCollection::verticesWithMultipleLabels(
+          {"company", "public"}, graph_info, type);
+  ASSERT(!maybe_filter_vertices_collection_3.has_error());
+  auto filter_vertices_3 = maybe_filter_vertices_collection_3.value();
+  std::cout << "valid vertices num: " << filter_vertices_3->size() << 
std::endl;
+
+  // for (auto it = filter_vertices_3->begin(); it != filter_vertices_3->end();

Review Comment:
   Ditto



##########
cpp/examples/high_level_label_reader_example.cc:
##########
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <iostream>
+
+#include "arrow/api.h"
+#include "arrow/filesystem/api.h"
+
+#include "./config.h"
+#include "graphar/api/high_level_reader.h"
+
+void vertices_collection(
+    const std::shared_ptr<graphar::GraphInfo>& graph_info) {
+  std::string type = "organisation";
+  auto vertex_info = graph_info->GetVertexInfo("organisation");
+  auto labels = vertex_info->GetLabels();
+
+  std::cout << "Query vertices with a specific label" << std::endl;
+  std::cout << "--------------------------------------" << std::endl;
+
+  auto maybe_filter_vertices_collection =
+      graphar::VerticesCollection::verticesWithLabel(std::string("company"),
+                                                     graph_info, type);
+
+  ASSERT(!maybe_filter_vertices_collection.has_error());
+  auto filter_vertices = maybe_filter_vertices_collection.value();
+  std::cout << "valid vertices num: " << filter_vertices->size() << std::endl;
+
+  // for (auto it = filter_vertices->begin(); it != filter_vertices->end();

Review Comment:
   you may uncomment the code  or remove it  before merge the PR.



##########
cpp/src/graphar/arrow/chunk_reader.cc:
##########
@@ -51,6 +51,18 @@ Result<std::shared_ptr<arrow::Schema>> PropertyGroupToSchema(
   return arrow::schema(fields);
 }
 
+Result<std::shared_ptr<arrow::Schema>> LabelToSchema(

Review Comment:
   What's the method for? can you add some document for the method?



##########
cpp/src/graphar/filesystem.cc:
##########
@@ -233,8 +234,14 @@ Status FileSystem::WriteTableToFile(const 
std::shared_ptr<arrow::Table>& table,
     break;
   }
   case FileType::PARQUET: {
+    auto schema = table->schema();
+    auto column_num = schema->num_fields();
     parquet::WriterProperties::Builder builder;
-    builder.compression(arrow::Compression::type::ZSTD);  // enable compression
+    // builder.compression(arrow::Compression::type::ZSTD);  // enable

Review Comment:
   why comment the compression code ?



-- 
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]

Reply via email to