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 4d75b9c3 chore(c++): reduce copies in graph_reader.h (#777)
4d75b9c3 is described below

commit 4d75b9c34fc7ca942ffa8145d573fd8d3e6ae40c
Author: Jinye Wu <[email protected]>
AuthorDate: Sun Sep 28 10:17:27 2025 +0800

    chore(c++): reduce copies in graph_reader.h (#777)
---
 cpp/src/graphar/high-level/graph_reader.cc |  7 ++++---
 cpp/src/graphar/high-level/graph_reader.h  | 17 ++++++++---------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/cpp/src/graphar/high-level/graph_reader.cc 
b/cpp/src/graphar/high-level/graph_reader.cc
index 5460dfdd..e02d9227 100644
--- a/cpp/src/graphar/high-level/graph_reader.cc
+++ b/cpp/src/graphar/high-level/graph_reader.cc
@@ -150,7 +150,7 @@ static inline bool IsValid(bool* state, int column_number) {
 }
 
 Result<std::vector<IdType>> VerticesCollection::filter(
-    std::vector<std::string> filter_labels,
+    const std::vector<std::string>& filter_labels,
     std::vector<IdType>* new_valid_chunk) {
   std::vector<int> indices;
   const int TOT_ROWS_NUM = vertex_num_;
@@ -214,7 +214,7 @@ Result<std::vector<IdType>> VerticesCollection::filter(
 }
 
 Result<std::vector<IdType>> VerticesCollection::filter_by_acero(
-    std::vector<std::string> filter_labels) const {
+    const std::vector<std::string>& filter_labels) const {
   std::vector<int> indices;
   const int TOT_ROWS_NUM = vertex_num_;
   const int CHUNK_SIZE = vertex_info_->GetChunkSize();
@@ -265,7 +265,8 @@ Result<std::vector<IdType>> 
VerticesCollection::filter_by_acero(
 }
 
 Result<std::vector<IdType>> VerticesCollection::filter(
-    std::string property_name, std::shared_ptr<Expression> filter_expression,
+    const std::string& property_name,
+    std::shared_ptr<Expression> filter_expression,
     std::vector<IdType>* new_valid_chunk) {
   std::vector<int> indices;
   const int TOT_ROWS_NUM = vertex_num_;
diff --git a/cpp/src/graphar/high-level/graph_reader.h 
b/cpp/src/graphar/high-level/graph_reader.h
index 3cd36886..b8a7ad8e 100644
--- a/cpp/src/graphar/high-level/graph_reader.h
+++ b/cpp/src/graphar/high-level/graph_reader.h
@@ -330,12 +330,12 @@ class VerticesCollection {
   explicit VerticesCollection(const std::shared_ptr<VertexInfo>& vertex_info,
                               const std::string& prefix,
                               const bool is_filtered = false,
-                              const std::vector<IdType> filtered_ids = {})
-      : vertex_info_(std::move(vertex_info)),
+                              std::vector<IdType> filtered_ids = {})
+      : vertex_info_(vertex_info),
         prefix_(prefix),
         labels_(vertex_info->GetLabels()),
         is_filtered_(is_filtered),
-        filtered_ids_(filtered_ids) {
+        filtered_ids_(std::move(filtered_ids)) {
     // get the vertex num
     std::string base_dir;
     GAR_ASSIGN_OR_RAISE_ERROR(auto fs,
@@ -377,14 +377,15 @@ class VerticesCollection {
 
   /** The vertex id list that satisfies the label filter condition. */
   Result<std::vector<IdType>> filter(
-      std::vector<std::string> filter_labels,
+      const std::vector<std::string>& filter_labels,
       std::vector<IdType>* new_valid_chunk = nullptr);
 
   Result<std::vector<IdType>> filter_by_acero(
-      std::vector<std::string> filter_labels) const;
+      const std::vector<std::string>& filter_labels) const;
 
   Result<std::vector<IdType>> filter(
-      std::string property_name, std::shared_ptr<Expression> filter_expression,
+      const std::string& property_name,
+      std::shared_ptr<Expression> filter_expression,
       std::vector<IdType>* new_valid_chunk = nullptr);
 
   /**
@@ -905,9 +906,7 @@ class EdgesCollection {
   explicit EdgesCollection(const std::shared_ptr<EdgeInfo>& edge_info,
                            const std::string& prefix, IdType 
vertex_chunk_begin,
                            IdType vertex_chunk_end, AdjListType adj_list_type)
-      : edge_info_(std::move(edge_info)),
-        prefix_(prefix),
-        adj_list_type_(adj_list_type) {
+      : edge_info_(edge_info), prefix_(prefix), adj_list_type_(adj_list_type) {
     GAR_ASSIGN_OR_RAISE_ERROR(
         auto vertex_chunk_num,
         util::GetVertexChunkNum(prefix_, edge_info_, adj_list_type_));


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

Reply via email to