This is an automated email from the ASF dual-hosted git repository.

lixueclaire 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 0961b643 feat(c++): add  parameter 'label' for createinfos (#634)
0961b643 is described below

commit 0961b643871d74147a853cd25bd57451ca900163
Author: Elssky <[email protected]>
AuthorDate: Mon Oct 28 11:10:22 2024 +0800

    feat(c++): add  parameter 'label' for createinfos (#634)
---
 cpp/examples/bgl_example.cc             |  2 +-
 cpp/examples/construct_info_example.cc  |  4 +-
 cpp/examples/snap_dataset_to_graphar.cc |  6 +--
 cpp/src/graphar/filesystem.cc           |  4 ++
 cpp/src/graphar/fwd.h                   |  7 ++-
 cpp/src/graphar/general_params.h        |  1 +
 cpp/src/graphar/graph_info.cc           | 91 +++++++++++++++++++++++++--------
 cpp/src/graphar/graph_info.h            | 18 ++++++-
 cpp/src/graphar/util.cc                 |  3 ++
 cpp/test/test_info.cc                   | 85 +++++++++++++++---------------
 10 files changed, 148 insertions(+), 73 deletions(-)

diff --git a/cpp/examples/bgl_example.cc b/cpp/examples/bgl_example.cc
index d8231c6f..6cbb574d 100644
--- a/cpp/examples/bgl_example.cc
+++ b/cpp/examples/bgl_example.cc
@@ -112,7 +112,7 @@ int main(int argc, char* argv[]) {
   int chunk_size = 100;
   auto version = graphar::InfoVersion::Parse("gar/v1").value();
   auto new_info = graphar::CreateVertexInfo(vertex_type, chunk_size, {group},
-                                            vertex_prefix, version);
+                                            {}, vertex_prefix, version);
   // dump new vertex info
   ASSERT(new_info->IsValidated());
   ASSERT(new_info->Dump().status().ok());
diff --git a/cpp/examples/construct_info_example.cc 
b/cpp/examples/construct_info_example.cc
index d5b390b7..b9c0a276 100644
--- a/cpp/examples/construct_info_example.cc
+++ b/cpp/examples/construct_info_example.cc
@@ -43,7 +43,7 @@ int main(int argc, char* argv[]) {
       graphar::CreatePropertyGroup(property_vector_2, graphar::FileType::ORC);
 
   // create vertex info
-  auto vertex_info = graphar::CreateVertexInfo(type, chunk_size, {group1},
+  auto vertex_info = graphar::CreateVertexInfo(type, chunk_size, {group1}, {},
                                                vertex_prefix, version);
 
   ASSERT(vertex_info != nullptr);
@@ -150,7 +150,7 @@ int main(int argc, char* argv[]) {
 
   // create graph info
   auto graph_info = graphar::CreateGraphInfo(name, {vertex_info}, {edge_info},
-                                             prefix, version);
+                                             {}, prefix, version);
   ASSERT(graph_info->GetName() == name);
   ASSERT(graph_info->GetPrefix() == prefix);
   ASSERT(graph_info->GetVertexInfos().size() == 1);
diff --git a/cpp/examples/snap_dataset_to_graphar.cc 
b/cpp/examples/snap_dataset_to_graphar.cc
index 29bc442a..ad74cb11 100644
--- a/cpp/examples/snap_dataset_to_graphar.cc
+++ b/cpp/examples/snap_dataset_to_graphar.cc
@@ -49,7 +49,7 @@ int main(int argc, char* argv[]) {
   std::string type = "node", vertex_prefix = "vertex/node/";
 
   // create vertex info
-  auto vertex_info = graphar::CreateVertexInfo(type, VERTEX_CHUNK_SIZE, {},
+  auto vertex_info = graphar::CreateVertexInfo(type, VERTEX_CHUNK_SIZE, {}, {},
                                                vertex_prefix, version);
 
   // save & dump
@@ -75,8 +75,8 @@ int main(int argc, char* argv[]) {
 
   /*------------------construct graph info------------------*/
   // create graph info
-  auto graph_info = graphar::CreateGraphInfo(graph_name, {vertex_info},
-                                             {edge_info}, save_path, version);
+  auto graph_info = graphar::CreateGraphInfo(
+      graph_name, {vertex_info}, {edge_info}, {}, save_path, version);
   // save & dump
   ASSERT(!graph_info->Dump().has_error());
   ASSERT(graph_info->Save(save_path + graph_name + ".graph.yml").ok());
diff --git a/cpp/src/graphar/filesystem.cc b/cpp/src/graphar/filesystem.cc
index 62b9ab2e..92bd55c3 100644
--- a/cpp/src/graphar/filesystem.cc
+++ b/cpp/src/graphar/filesystem.cc
@@ -35,6 +35,7 @@
 #include "graphar/expression.h"
 #include "graphar/filesystem.h"
 #include "graphar/fwd.h"
+#include "graphar/general_params.h"
 
 namespace graphar::detail {
 template <typename U, typename T>
@@ -233,8 +234,11 @@ 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.encoding(graphar::GeneralParams::kLabelCol, 
parquet::Encoding::RLE);
     RETURN_NOT_ARROW_OK(parquet::arrow::WriteTable(
         *table, arrow::default_memory_pool(), output_stream, 64 * 1024 * 1024,
         builder.build(), parquet::default_arrow_writer_properties()));
diff --git a/cpp/src/graphar/fwd.h b/cpp/src/graphar/fwd.h
index 0c019039..236f0798 100644
--- a/cpp/src/graphar/fwd.h
+++ b/cpp/src/graphar/fwd.h
@@ -133,7 +133,8 @@ std::shared_ptr<AdjacentList> CreateAdjacentList(
  */
 std::shared_ptr<VertexInfo> CreateVertexInfo(
     const std::string& type, IdType chunk_size,
-    const PropertyGroupVector& property_groups, const std::string& prefix = "",
+    const PropertyGroupVector& property_groups,
+    const std::vector<std::string>& labels = {}, const std::string& prefix = 
"",
     std::shared_ptr<const InfoVersion> version = nullptr);
 
 /**
@@ -167,6 +168,7 @@ std::shared_ptr<EdgeInfo> CreateEdgeInfo(
  * @param name The name of the graph
  * @param vertex_infos The vertex info vector of the graph
  * @param edge_infos The edge info vector of the graph
+ * @param labels The vertex labels of the graph.
  * @param prefix The absolute path prefix to store chunk files of the graph.
  *               Defaults to "./"
  * @param version The version of the graph info
@@ -175,7 +177,8 @@ std::shared_ptr<EdgeInfo> CreateEdgeInfo(
  */
 std::shared_ptr<GraphInfo> CreateGraphInfo(
     const std::string& name, const VertexInfoVector& vertex_infos,
-    const EdgeInfoVector& edge_infos, const std::string& prefix,
+    const EdgeInfoVector& edge_infos, const std::vector<std::string>& labels,
+    const std::string& prefix,
     std::shared_ptr<const InfoVersion> version = nullptr,
     const std::unordered_map<std::string, std::string>& extra_info = {});
 
diff --git a/cpp/src/graphar/general_params.h b/cpp/src/graphar/general_params.h
index 55db90fb..71572193 100644
--- a/cpp/src/graphar/general_params.h
+++ b/cpp/src/graphar/general_params.h
@@ -27,6 +27,7 @@ struct GeneralParams {
   static constexpr const char* kDstIndexCol = "_graphArDstIndex";
   static constexpr const char* kOffsetCol = "_graphArOffset";
   static constexpr const char* kPrimaryCol = "_graphArPrimary";
+  static constexpr const char* kLabelCol = "_graphArLabel";
 };
 
 }  // namespace graphar
diff --git a/cpp/src/graphar/graph_info.cc b/cpp/src/graphar/graph_info.cc
index 8c8aa3c2..81d1bba7 100644
--- a/cpp/src/graphar/graph_info.cc
+++ b/cpp/src/graphar/graph_info.cc
@@ -191,10 +191,12 @@ class VertexInfo::Impl {
  public:
   Impl(const std::string& type, IdType chunk_size, const std::string& prefix,
        const PropertyGroupVector& property_groups,
+       const std::vector<std::string>& labels,
        std::shared_ptr<const InfoVersion> version)
       : type_(type),
         chunk_size_(chunk_size),
         property_groups_(std::move(property_groups)),
+        labels_(labels),
         prefix_(prefix),
         version_(std::move(version)) {
     if (prefix_.empty()) {
@@ -241,6 +243,7 @@ class VertexInfo::Impl {
   std::string type_;
   IdType chunk_size_;
   PropertyGroupVector property_groups_;
+  std::vector<std::string> labels_;
   std::string prefix_;
   std::shared_ptr<const InfoVersion> version_;
   std::unordered_map<std::string, int> property_name_to_index_;
@@ -252,9 +255,11 @@ class VertexInfo::Impl {
 
 VertexInfo::VertexInfo(const std::string& type, IdType chunk_size,
                        const PropertyGroupVector& property_groups,
+                       const std::vector<std::string>& labels,
                        const std::string& prefix,
                        std::shared_ptr<const InfoVersion> version)
-    : impl_(new Impl(type, chunk_size, prefix, property_groups, version)) {}
+    : impl_(new Impl(type, chunk_size, prefix, property_groups, labels,
+                     version)) {}
 
 VertexInfo::~VertexInfo() = default;
 
@@ -264,6 +269,10 @@ IdType VertexInfo::GetChunkSize() const { return 
impl_->chunk_size_; }
 
 const std::string& VertexInfo::GetPrefix() const { return impl_->prefix_; }
 
+const std::vector<std::string>& VertexInfo::GetLabels() const {
+  return impl_->labels_;
+}
+
 const std::shared_ptr<const InfoVersion>& VertexInfo::version() const {
   return impl_->version_;
 }
@@ -367,21 +376,22 @@ Result<std::shared_ptr<VertexInfo>> 
VertexInfo::AddPropertyGroup(
   }
   return std::make_shared<VertexInfo>(
       impl_->type_, impl_->chunk_size_,
-      AddVectorElement(impl_->property_groups_, property_group), 
impl_->prefix_,
-      impl_->version_);
+      AddVectorElement(impl_->property_groups_, property_group), 
impl_->labels_,
+      impl_->prefix_, impl_->version_);
 }
 
 bool VertexInfo::IsValidated() const { return impl_->is_validated(); }
 
 std::shared_ptr<VertexInfo> CreateVertexInfo(
     const std::string& type, IdType chunk_size,
-    const PropertyGroupVector& property_groups, const std::string& prefix,
+    const PropertyGroupVector& property_groups,
+    const std::vector<std::string>& labels, const std::string& prefix,
     std::shared_ptr<const InfoVersion> version) {
   if (type.empty() || chunk_size <= 0) {
     return nullptr;
   }
-  return std::make_shared<VertexInfo>(type, chunk_size, property_groups, 
prefix,
-                                      version);
+  return std::make_shared<VertexInfo>(type, chunk_size, property_groups, 
labels,
+                                      prefix, version);
 }
 
 Result<std::shared_ptr<VertexInfo>> VertexInfo::Load(
@@ -396,6 +406,13 @@ Result<std::shared_ptr<VertexInfo>> VertexInfo::Load(
   if (!yaml->operator[]("prefix").IsNone()) {
     prefix = yaml->operator[]("prefix").As<std::string>();
   }
+  std::vector<std::string> labels;
+  const auto& labels_node = yaml->operator[]("labels");
+  if (labels_node.IsSequence()) {
+    for (auto it = labels_node.Begin(); it != labels_node.End(); it++) {
+      labels.push_back((*it).second.As<std::string>());
+    }
+  }
   std::shared_ptr<const InfoVersion> version = nullptr;
   if (!yaml->operator[]("version").IsNone()) {
     GAR_ASSIGN_OR_RAISE(
@@ -430,8 +447,8 @@ Result<std::shared_ptr<VertexInfo>> VertexInfo::Load(
           std::make_shared<PropertyGroup>(property_vec, file_type, pg_prefix));
     }
   }
-  return std::make_shared<VertexInfo>(type, chunk_size, property_groups, 
prefix,
-                                      version);
+  return std::make_shared<VertexInfo>(type, chunk_size, property_groups, 
labels,
+                                      prefix, version);
 }
 
 Result<std::shared_ptr<VertexInfo>> VertexInfo::Load(const std::string& input) 
{
@@ -449,6 +466,13 @@ Result<std::string> VertexInfo::Dump() const noexcept {
     node["type"] = impl_->type_;
     node["chunk_size"] = std::to_string(impl_->chunk_size_);
     node["prefix"] = impl_->prefix_;
+    if (impl_->labels_.size() > 0) {
+      node["labels"];
+      for (const auto& label : impl_->labels_) {
+        node["labels"].PushBack();
+        node["labels"][node["labels"].Size() - 1] = label;
+      }
+    }
     for (const auto& pg : impl_->property_groups_) {
       ::Yaml::Node pg_node;
       if (!pg->GetPrefix().empty()) {
@@ -1042,8 +1066,18 @@ static Result<std::shared_ptr<GraphInfo>> 
ConstructGraphInfo(
       edge_infos.push_back(edge_info);
     }
   }
-  return std::make_shared<GraphInfo>(name, vertex_infos, edge_infos, prefix,
-                                     version, extra_info);
+
+  std::vector<std::string> labels;
+  if (!graph_meta->operator[]("labels").IsNone()) {
+    const auto& labels_node = graph_meta->operator[]("labels");
+    if (labels_node.IsSequence()) {
+      for (auto it = labels_node.Begin(); it != labels_node.End(); it++) {
+        labels.push_back((*it).second.As<std::string>());
+      }
+    }
+  }
+  return std::make_shared<GraphInfo>(name, vertex_infos, edge_infos, labels,
+                                     prefix, version, extra_info);
 }
 
 }  // namespace
@@ -1051,12 +1085,13 @@ static Result<std::shared_ptr<GraphInfo>> 
ConstructGraphInfo(
 class GraphInfo::Impl {
  public:
   Impl(const std::string& graph_name, VertexInfoVector vertex_infos,
-       EdgeInfoVector edge_infos, const std::string& prefix,
-       std::shared_ptr<const InfoVersion> version,
+       EdgeInfoVector edge_infos, const std::vector<std::string>& labels,
+       const std::string& prefix, std::shared_ptr<const InfoVersion> version,
        const std::unordered_map<std::string, std::string>& extra_info)
       : name_(graph_name),
         vertex_infos_(std::move(vertex_infos)),
         edge_infos_(std::move(edge_infos)),
+        labels_(labels),
         prefix_(prefix),
         version_(std::move(version)),
         extra_info_(extra_info) {
@@ -1099,6 +1134,7 @@ class GraphInfo::Impl {
   std::string name_;
   VertexInfoVector vertex_infos_;
   EdgeInfoVector edge_infos_;
+  std::vector<std::string> labels_;
   std::string prefix_;
   std::shared_ptr<const InfoVersion> version_;
   std::unordered_map<std::string, std::string> extra_info_;
@@ -1108,16 +1144,20 @@ class GraphInfo::Impl {
 
 GraphInfo::GraphInfo(
     const std::string& graph_name, VertexInfoVector vertex_infos,
-    EdgeInfoVector edge_infos, const std::string& prefix,
-    std::shared_ptr<const InfoVersion> version,
+    EdgeInfoVector edge_infos, const std::vector<std::string>& labels,
+    const std::string& prefix, std::shared_ptr<const InfoVersion> version,
     const std::unordered_map<std::string, std::string>& extra_info)
     : impl_(new Impl(graph_name, std::move(vertex_infos), 
std::move(edge_infos),
-                     prefix, version, extra_info)) {}
+                     labels, prefix, version, extra_info)) {}
 
 GraphInfo::~GraphInfo() = default;
 
 const std::string& GraphInfo::GetName() const { return impl_->name_; }
 
+const std::vector<std::string>& GraphInfo::GetLabels() const {
+  return impl_->labels_;
+}
+
 const std::string& GraphInfo::GetPrefix() const { return impl_->prefix_; }
 
 const std::shared_ptr<const InfoVersion>& GraphInfo::version() const {
@@ -1196,7 +1236,7 @@ Result<std::shared_ptr<GraphInfo>> GraphInfo::AddVertex(
   }
   return std::make_shared<GraphInfo>(
       impl_->name_, AddVectorElement(impl_->vertex_infos_, vertex_info),
-      impl_->edge_infos_, impl_->prefix_, impl_->version_);
+      impl_->edge_infos_, impl_->labels_, impl_->prefix_, impl_->version_);
 }
 
 Result<std::shared_ptr<GraphInfo>> GraphInfo::AddEdge(
@@ -1210,20 +1250,20 @@ Result<std::shared_ptr<GraphInfo>> GraphInfo::AddEdge(
   }
   return std::make_shared<GraphInfo>(
       impl_->name_, impl_->vertex_infos_,
-      AddVectorElement(impl_->edge_infos_, edge_info), impl_->prefix_,
-      impl_->version_);
+      AddVectorElement(impl_->edge_infos_, edge_info), impl_->labels_,
+      impl_->prefix_, impl_->version_);
 }
 
 std::shared_ptr<GraphInfo> CreateGraphInfo(
     const std::string& name, const VertexInfoVector& vertex_infos,
-    const EdgeInfoVector& edge_infos, const std::string& prefix,
-    std::shared_ptr<const InfoVersion> version,
+    const EdgeInfoVector& edge_infos, const std::vector<std::string>& labels,
+    const std::string& prefix, std::shared_ptr<const InfoVersion> version,
     const std::unordered_map<std::string, std::string>& extra_info) {
   if (name.empty()) {
     return nullptr;
   }
-  return std::make_shared<GraphInfo>(name, vertex_infos, edge_infos, prefix,
-                                     version, extra_info);
+  return std::make_shared<GraphInfo>(name, vertex_infos, edge_infos, labels,
+                                     prefix, version, extra_info);
 }
 
 Result<std::shared_ptr<GraphInfo>> GraphInfo::Load(const std::string& path) {
@@ -1275,6 +1315,13 @@ Result<std::string> GraphInfo::Dump() const {
                            edge->GetDstType()) +
           ".edge.yaml";
     }
+    if (impl_->labels_.size() > 0) {
+      node["labels"];
+      for (const auto& label : impl_->labels_) {
+        node["labels"].PushBack();
+        node["labels"][node["labels"].Size() - 1] = label;
+      }
+    }
     if (impl_->version_ != nullptr) {
       node["version"] = impl_->version_->ToString();
     }
diff --git a/cpp/src/graphar/graph_info.h b/cpp/src/graphar/graph_info.h
index f6d08696..b2b372b0 100644
--- a/cpp/src/graphar/graph_info.h
+++ b/cpp/src/graphar/graph_info.h
@@ -180,12 +180,14 @@ class VertexInfo {
    * @param type The type of the vertex.
    * @param chunk_size The number of vertices in each vertex chunk.
    * @param property_groups The property group vector of the vertex.
+   * @param labels The labels of the vertex.
    * @param prefix The prefix of the vertex info. If left empty, the default
    *        prefix will be set to the type of the vertex.
    * @param version The format version of the vertex info.
    */
   explicit VertexInfo(const std::string& type, IdType chunk_size,
                       const PropertyGroupVector& property_groups,
+                      const std::vector<std::string>& labels = {},
                       const std::string& prefix = "",
                       std::shared_ptr<const InfoVersion> version = nullptr);
 
@@ -227,6 +229,12 @@ class VertexInfo {
    */
   const std::shared_ptr<const InfoVersion>& version() const;
 
+  /**
+   * Get the labels of the vertex.
+   * @return The labels of the vertex.
+   */
+  const std::vector<std::string>& GetLabels() const;
+
   /**
    * Get the number of property groups of the vertex.
    *
@@ -694,6 +702,7 @@ class GraphInfo {
    * @param graph_name The name of the graph.
    * @param vertex_infos The vertex info vector of the graph.
    * @param edge_infos The edge info vector of the graph.
+   * @param labels The vertex labels of the graph.
    * @param prefix The absolute path prefix to store chunk files of the graph.
    *               Defaults to "./".
    * @param version The version of the graph info.
@@ -701,7 +710,8 @@ class GraphInfo {
    */
   explicit GraphInfo(
       const std::string& graph_name, VertexInfoVector vertex_infos,
-      EdgeInfoVector edge_infos, const std::string& prefix = "./",
+      EdgeInfoVector edge_infos, const std::vector<std::string>& labels = {},
+      const std::string& prefix = "./",
       std::shared_ptr<const InfoVersion> version = nullptr,
       const std::unordered_map<std::string, std::string>& extra_info = {});
 
@@ -753,6 +763,12 @@ class GraphInfo {
    */
   const std::string& GetName() const;
 
+  /**
+   * @brief Get the vertex labels of the graph.
+   * @return The vertex labels of the graph.
+   */
+  const std::vector<std::string>& GetLabels() const;
+
   /**
    * @brief Get the absolute path prefix of the chunk files.
    * @return The absolute path prefix of the chunk files.
diff --git a/cpp/src/graphar/util.cc b/cpp/src/graphar/util.cc
index e477188d..7a3b1a82 100644
--- a/cpp/src/graphar/util.cc
+++ b/cpp/src/graphar/util.cc
@@ -86,6 +86,9 @@ Result<const void*> GetArrowArrayData(
   } else if (array->type()->Equals(arrow::null())) {
     return reinterpret_cast<const void*>(
         std::dynamic_pointer_cast<arrow::NullArray>(array).get());
+  } else if (array->type()->Equals(arrow::boolean())) {
+    return reinterpret_cast<const void*>(
+        std::dynamic_pointer_cast<arrow::BooleanArray>(array).get());
   } else {
     return Status::TypeError("Array type - ", array->type()->ToString(),
                              " is not supported yet...");
diff --git a/cpp/test/test_info.cc b/cpp/test/test_info.cc
index c0349ee0..82d839e3 100644
--- a/cpp/test/test_info.cc
+++ b/cpp/test/test_info.cc
@@ -183,7 +183,7 @@ TEST_CASE_METHOD(GlobalFixture, "VertexInfo") {
       {Property("p0", int32(), true), Property("p1", string(), false)},
       FileType::CSV, "p0_p1/");
   auto vertex_info =
-      CreateVertexInfo(type, chunk_size, {pg}, "test_vertex", version);
+      CreateVertexInfo(type, chunk_size, {pg}, {}, "test_vertex", version);
 
   SECTION("Basics") {
     REQUIRE(vertex_info->GetType() == type);
@@ -224,24 +224,25 @@ TEST_CASE_METHOD(GlobalFixture, "VertexInfo") {
     auto invalid_pg =
         CreatePropertyGroup({Property("p0", nullptr, true)}, FileType::CSV);
     auto invalid_vertex_info0 = CreateVertexInfo(type, chunk_size, 
{invalid_pg},
-                                                 "test_vertex/", version);
+                                                 {}, "test_vertex/", version);
     REQUIRE(invalid_vertex_info0->IsValidated() == false);
-    VertexInfo invalid_vertex_info1("", chunk_size, {pg}, "test_vertex/",
+    VertexInfo invalid_vertex_info1("", chunk_size, {pg}, {}, "test_vertex/",
                                     version);
     REQUIRE(invalid_vertex_info1.IsValidated() == false);
-    VertexInfo invalid_vertex_info2(type, 0, {pg}, "test_vertex/", version);
+    VertexInfo invalid_vertex_info2(type, 0, {pg}, {}, "test_vertex/", 
version);
     REQUIRE(invalid_vertex_info2.IsValidated() == false);
     // check if prefix empty
     auto vertex_info_empty_prefix =
-        CreateVertexInfo(type, chunk_size, {pg}, "", version);
+        CreateVertexInfo(type, chunk_size, {pg}, {}, "", version);
     REQUIRE(vertex_info_empty_prefix->IsValidated() == true);
   }
 
   SECTION("CreateVertexInfo") {
-    auto vertex_info3 = CreateVertexInfo("", chunk_size, {pg}, "test_vertex/");
+    auto vertex_info3 =
+        CreateVertexInfo("", chunk_size, {pg}, {}, "test_vertex/");
     REQUIRE(vertex_info3 == nullptr);
 
-    auto vertex_info4 = CreateVertexInfo(type, 0, {pg}, "test_vertex/");
+    auto vertex_info4 = CreateVertexInfo(type, 0, {pg}, {}, "test_vertex/");
     REQUIRE(vertex_info4 == nullptr);
   }
 
@@ -267,7 +268,7 @@ version: gar/v1
 )";
     REQUIRE(dump_result.value() == expected);
     auto vertex_info_empty_version =
-        CreateVertexInfo(type, chunk_size, {pg}, "test_vertex/");
+        CreateVertexInfo(type, chunk_size, {pg}, {}, "test_vertex/");
     REQUIRE(vertex_info_empty_version->Dump().status().ok());
   }
 
@@ -521,7 +522,7 @@ TEST_CASE_METHOD(GlobalFixture, "GraphInfo") {
       {Property("p0", int32(), true), Property("p1", string(), false)},
       FileType::CSV, "p0_p1/");
   auto vertex_info =
-      CreateVertexInfo("test_vertex", 100, {pg}, "test_vertex/", version);
+      CreateVertexInfo("test_vertex", 100, {pg}, {}, "test_vertex/", version);
   std::unordered_map<std::string, std::string> extra_info = {
       {"category", "test graph"}};
   auto edge_info =
@@ -529,7 +530,7 @@ TEST_CASE_METHOD(GlobalFixture, "GraphInfo") {
                      {CreateAdjacentList(AdjListType::ordered_by_source,
                                          FileType::CSV, "adj_list/")},
                      {pg}, "test_edge/", version);
-  auto graph_info = CreateGraphInfo(name, {vertex_info}, {edge_info},
+  auto graph_info = CreateGraphInfo(name, {vertex_info}, {edge_info}, {},
                                     "test_graph/", version, extra_info);
 
   SECTION("Basics") {
@@ -544,7 +545,7 @@ TEST_CASE_METHOD(GlobalFixture, "GraphInfo") {
 
   SECTION("ExtraInfo") {
     auto graph_info_with_extra_info =
-        CreateGraphInfo(name, {vertex_info}, {edge_info}, "test_graph/",
+        CreateGraphInfo(name, {vertex_info}, {edge_info}, {}, "test_graph/",
                         version, {{"key1", "value1"}, {"key2", "value2"}});
     const auto& extra_info = graph_info_with_extra_info->GetExtraInfo();
     REQUIRE(extra_info.size() == 2);
@@ -580,9 +581,9 @@ TEST_CASE_METHOD(GlobalFixture, "GraphInfo") {
   SECTION("IsValidated") {
     REQUIRE(graph_info->IsValidated() == true);
     auto invalid_vertex_info =
-        CreateVertexInfo("", 100, {pg}, "test_vertex/", version);
+        CreateVertexInfo("", 100, {pg}, {}, "test_vertex/", version);
     auto invalid_graph_info0 = CreateGraphInfo(
-        name, {invalid_vertex_info}, {edge_info}, "test_graph/", version);
+        name, {invalid_vertex_info}, {edge_info}, {}, "test_graph/", version);
     REQUIRE(invalid_graph_info0->IsValidated() == false);
     auto invalid_edge_info =
         CreateEdgeInfo("", "knows", "person", 1024, 100, 100, true,
@@ -590,23 +591,23 @@ TEST_CASE_METHOD(GlobalFixture, "GraphInfo") {
                                            FileType::CSV, "adj_list/")},
                        {pg}, "test_edge/", version);
     auto invalid_graph_info1 = CreateGraphInfo(
-        name, {vertex_info}, {invalid_edge_info}, "test_graph/", version);
+        name, {vertex_info}, {invalid_edge_info}, {}, "test_graph/", version);
     REQUIRE(invalid_graph_info1->IsValidated() == false);
-    GraphInfo invalid_graph_info2("", {vertex_info}, {edge_info}, 
"test_graph/",
-                                  version);
+    GraphInfo invalid_graph_info2("", {vertex_info}, {edge_info}, {},
+                                  "test_graph/", version);
     REQUIRE(invalid_graph_info2.IsValidated() == false);
-    GraphInfo invalid_graph_info3(name, {vertex_info}, {edge_info}, "",
+    GraphInfo invalid_graph_info3(name, {vertex_info}, {edge_info}, {}, "",
                                   version);
     REQUIRE(invalid_graph_info3.IsValidated() == false);
     // check if prefix empty, graph_info with empty prefix is invalid
     auto graph_info_with_empty_prefix =
-        CreateGraphInfo(name, {vertex_info}, {edge_info}, "", version);
+        CreateGraphInfo(name, {vertex_info}, {edge_info}, {}, "", version);
     REQUIRE(graph_info_with_empty_prefix->IsValidated() == false);
   }
 
   SECTION("CreateGraphInfo") {
     auto graph_info_empty_name =
-        CreateGraphInfo("", {vertex_info}, {edge_info}, "test_graph/");
+        CreateGraphInfo("", {vertex_info}, {edge_info}, {}, "test_graph/");
     REQUIRE(graph_info_empty_name == nullptr);
   }
 
@@ -626,7 +627,7 @@ vertices:
 )";
     REQUIRE(dump_result.value() == expected);
     auto graph_info_empty_version =
-        CreateGraphInfo(name, {vertex_info}, {edge_info}, "test_graph/");
+        CreateGraphInfo(name, {vertex_info}, {edge_info}, {}, "test_graph/");
     REQUIRE(graph_info_empty_version->Dump().status().ok());
   }
 
@@ -638,8 +639,8 @@ vertices:
   }
 
   SECTION("AddVertex") {
-    auto vertex_info2 =
-        CreateVertexInfo("test_vertex2", 100, {pg}, "test_vertex2/", version);
+    auto vertex_info2 = CreateVertexInfo("test_vertex2", 100, {pg}, {},
+                                         "test_vertex2/", version);
     auto maybe_extend_info = graph_info->AddVertex(vertex_info2);
     REQUIRE(maybe_extend_info.status().ok());
     auto extend_info = maybe_extend_info.value();
@@ -778,25 +779,25 @@ extra_info:
 /*
 TODO(acezen): need to mock S3 server to test this case, this private
 service is not available for public access.
-
-TEST_CASE_METHOD(GlobalFixture, "LoadFromS3") {
-  // explicitly call InitS3 to initialize S3 APIs before using
-  // S3 file system.
-  InitializeS3();
-  std::string path =
-      "s3://graphscope/graphar/ldbc/ldbc.graph.yml"
-      "?endpoint_override=graphscope.oss-cn-beijing.aliyuncs.com";
-  auto graph_info_result = GraphInfo::Load(path);
-  std::cout << graph_info_result.status().message() << std::endl;
-  REQUIRE(!graph_info_result.has_error());
-  auto graph_info = graph_info_result.value();
-  REQUIRE(graph_info->GetName() == "ldbc");
-  const auto& vertex_infos = graph_info->GetVertexInfos();
-  const auto& edge_infos = graph_info->GetEdgeInfos();
-  REQUIRE(vertex_infos.size() == 8);
-  REQUIRE(edge_infos.size() == 23);
-  // explicitly call FinalizeS3 to avoid memory leak
-  FinalizeS3();
-}
 */
+// TEST_CASE_METHOD(GlobalFixture, "LoadFromS3") {
+//   // explicitly call InitS3 to initialize S3 APIs before using
+//   // S3 file system.
+//   InitializeS3();
+//   std::string path =
+//       "s3://graphar/ldbc/ldbc.graph.yml"
+//       "?endpoint_override=graphscope.oss-cn-beijing.aliyuncs.com";
+//   auto graph_info_result = GraphInfo::Load(path);
+//   std::cout << graph_info_result.status().message() << std::endl;
+//   REQUIRE(!graph_info_result.has_error());
+//   auto graph_info = graph_info_result.value();
+//   REQUIRE(graph_info->GetName() == "ldbc");
+//   const auto& vertex_infos = graph_info->GetVertexInfos();
+//   const auto& edge_infos = graph_info->GetEdgeInfos();
+//   REQUIRE(vertex_infos.size() == 8);
+//   REQUIRE(edge_infos.size() == 23);
+//   // explicitly call FinalizeS3 to avoid memory leak
+//   FinalizeS3();
+// }
+
 }  // namespace graphar


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to