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 b4bc86cf refactor(C++): change FilterOptions parameter to be moved
instead of const reference (#891)
b4bc86cf is described below
commit b4bc86cfe93d0ee60cbcdddd1a32272ecb4b7cae
Author: Jason Yao <[email protected]>
AuthorDate: Wed Mar 4 15:07:14 2026 +0800
refactor(C++): change FilterOptions parameter to be moved instead of const
reference (#891)
* refactor(cpp): change FilterOptions parameter to be moved instead of
const reference
Signed-off-by: syaojun <[email protected]>
* Update cpp/src/graphar/graph_info.cc
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Jason Yao <[email protected]>
* Update cpp/src/graphar/graph_info.cc
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Jason Yao <[email protected]>
---------
Signed-off-by: syaojun <[email protected]>
Signed-off-by: Jason Yao <[email protected]>
Co-authored-by: Copilot <[email protected]>
---
cpp/src/graphar/arrow/chunk_reader.cc | 16 ++++++++--------
cpp/src/graphar/arrow/chunk_reader.h | 8 ++++----
cpp/src/graphar/graph_info.cc | 36 ++++++++++++++++++-----------------
cpp/src/graphar/graph_info.h | 4 ++--
4 files changed, 33 insertions(+), 31 deletions(-)
diff --git a/cpp/src/graphar/arrow/chunk_reader.cc
b/cpp/src/graphar/arrow/chunk_reader.cc
index 030d595d..7499936f 100644
--- a/cpp/src/graphar/arrow/chunk_reader.cc
+++ b/cpp/src/graphar/arrow/chunk_reader.cc
@@ -154,15 +154,15 @@ Status CastTableWithSchema(const
std::shared_ptr<arrow::Table>& table,
VertexPropertyArrowChunkReader::VertexPropertyArrowChunkReader(
const std::shared_ptr<VertexInfo>& vertex_info,
const std::shared_ptr<PropertyGroup>& property_group,
- const std::string& prefix, const util::FilterOptions& options)
+ const std::string& prefix, util::FilterOptions options)
: VertexPropertyArrowChunkReader(vertex_info, property_group, {}, prefix,
- options) {}
+ std::move(options)) {}
VertexPropertyArrowChunkReader::VertexPropertyArrowChunkReader(
const std::shared_ptr<VertexInfo>& vertex_info,
const std::shared_ptr<PropertyGroup>& property_group,
const std::vector<std::string>& property_names, const std::string& prefix,
- const util::FilterOptions& options)
+ util::FilterOptions options)
: vertex_info_(std::move(vertex_info)),
property_group_(std::move(property_group)),
property_names_(std::move(property_names)),
@@ -170,7 +170,7 @@
VertexPropertyArrowChunkReader::VertexPropertyArrowChunkReader(
seek_id_(0),
schema_(nullptr),
chunk_table_(nullptr),
- filter_options_(options) {
+ filter_options_(std::move(options)) {
GAR_ASSIGN_OR_RAISE_ERROR(fs_, FileSystemFromUriOrPath(prefix, &prefix_));
GAR_ASSIGN_OR_RAISE_ERROR(auto pg_path_prefix,
vertex_info->GetPathPrefix(property_group));
@@ -187,14 +187,14 @@
VertexPropertyArrowChunkReader::VertexPropertyArrowChunkReader(
VertexPropertyArrowChunkReader::VertexPropertyArrowChunkReader(
const std::shared_ptr<VertexInfo>& vertex_info,
const std::vector<std::string>& labels, const std::string& prefix,
- const util::FilterOptions& options)
+ util::FilterOptions options)
: vertex_info_(std::move(vertex_info)),
labels_(labels),
chunk_index_(0),
seek_id_(0),
schema_(nullptr),
chunk_table_(nullptr),
- filter_options_(options) {
+ filter_options_(std::move(options)) {
GAR_ASSIGN_OR_RAISE_ERROR(fs_, FileSystemFromUriOrPath(prefix, &prefix_));
std::string base_dir = prefix_ + vertex_info_->GetPrefix() + "labels/chunk" +
@@ -855,7 +855,7 @@
AdjListPropertyArrowChunkReader::AdjListPropertyArrowChunkReader(
const std::shared_ptr<EdgeInfo>& edge_info,
const std::shared_ptr<PropertyGroup>& property_group,
AdjListType adj_list_type, const std::string prefix,
- const util::FilterOptions& options)
+ util::FilterOptions options)
: edge_info_(std::move(edge_info)),
property_group_(std::move(property_group)),
adj_list_type_(adj_list_type),
@@ -865,7 +865,7 @@
AdjListPropertyArrowChunkReader::AdjListPropertyArrowChunkReader(
seek_offset_(0),
schema_(nullptr),
chunk_table_(nullptr),
- filter_options_(options),
+ filter_options_(std::move(options)),
chunk_num_(-1) /* -1 means uninitialized */ {
GAR_ASSIGN_OR_RAISE_ERROR(fs_, FileSystemFromUriOrPath(prefix, &prefix_));
GAR_ASSIGN_OR_RAISE_ERROR(
diff --git a/cpp/src/graphar/arrow/chunk_reader.h
b/cpp/src/graphar/arrow/chunk_reader.h
index 779f8596..84131eb8 100644
--- a/cpp/src/graphar/arrow/chunk_reader.h
+++ b/cpp/src/graphar/arrow/chunk_reader.h
@@ -52,7 +52,7 @@ class VertexPropertyArrowChunkReader {
VertexPropertyArrowChunkReader(
const std::shared_ptr<VertexInfo>& vertex_info,
const std::shared_ptr<PropertyGroup>& property_group,
- const std::string& prefix, const util::FilterOptions& options = {});
+ const std::string& prefix, util::FilterOptions options = {});
/**
* @brief Initialize the VertexPropertyArrowChunkReader.
*
@@ -65,7 +65,7 @@ class VertexPropertyArrowChunkReader {
const std::shared_ptr<VertexInfo>& vertex_info,
const std::shared_ptr<PropertyGroup>& property_group,
const std::vector<std::string>& property_names, const std::string&
prefix,
- const util::FilterOptions& options = {});
+ util::FilterOptions options = {});
VertexPropertyArrowChunkReader() : vertex_info_(nullptr), prefix_("") {}
@@ -79,7 +79,7 @@ class VertexPropertyArrowChunkReader {
VertexPropertyArrowChunkReader(const std::shared_ptr<VertexInfo>&
vertex_info,
const std::vector<std::string>& labels,
const std::string& prefix,
- const util::FilterOptions& options = {});
+ util::FilterOptions options = {});
/**
* @brief Sets chunk position indicator for reader by internal vertex id.
* If internal vertex id is not found, will return Status::IndexError
@@ -492,7 +492,7 @@ class AdjListPropertyArrowChunkReader {
const std::shared_ptr<EdgeInfo>& edge_info,
const std::shared_ptr<PropertyGroup>& property_group,
AdjListType adj_list_type, const std::string prefix,
- const util::FilterOptions& options = {});
+ util::FilterOptions options = {});
/**
* @brief Copy constructor.
diff --git a/cpp/src/graphar/graph_info.cc b/cpp/src/graphar/graph_info.cc
index 3ec666e4..84f39518 100644
--- a/cpp/src/graphar/graph_info.cc
+++ b/cpp/src/graphar/graph_info.cc
@@ -108,8 +108,10 @@ bool operator==(const Property& lhs, const Property& rhs) {
}
PropertyGroup::PropertyGroup(const std::vector<Property>& properties,
- FileType file_type, const std::string& prefix)
- : properties_(properties), file_type_(file_type), prefix_(prefix) {
+ FileType file_type, std::string prefix)
+ : properties_(properties),
+ file_type_(file_type),
+ prefix_(std::move(prefix)) {
if (prefix_.empty() && !properties_.empty()) {
for (const auto& p : properties_) {
prefix_ += p.name + REGULAR_SEPARATOR;
@@ -182,8 +184,8 @@ bool operator==(const PropertyGroup& lhs, const
PropertyGroup& rhs) {
}
AdjacentList::AdjacentList(AdjListType type, FileType file_type,
- const std::string& prefix)
- : type_(type), file_type_(file_type), prefix_(prefix) {
+ std::string prefix)
+ : type_(type), file_type_(file_type), prefix_(std::move(prefix)) {
if (prefix_.empty()) {
prefix_ = std::string(AdjListTypeToString(type_)) + "/";
}
@@ -212,15 +214,15 @@ std::shared_ptr<AdjacentList>
CreateAdjacentList(AdjListType type,
class VertexInfo::Impl {
public:
- Impl(const std::string& type, IdType chunk_size, const std::string& prefix,
+ Impl(std::string type, IdType chunk_size, std::string prefix,
const PropertyGroupVector& property_groups,
const std::vector<std::string>& labels,
std::shared_ptr<const InfoVersion> version)
- : type_(type),
+ : type_(std::move(type)),
chunk_size_(chunk_size),
- property_groups_(std::move(property_groups)),
+ property_groups_(property_groups),
labels_(labels),
- prefix_(prefix),
+ prefix_(std::move(prefix)),
version_(std::move(version)) {
if (prefix_.empty()) {
prefix_ = type_ + "/"; // default prefix
@@ -568,22 +570,22 @@ Status VertexInfo::Save(const std::string& path) const {
class EdgeInfo::Impl {
public:
- Impl(const std::string& src_type, const std::string& edge_type,
- const std::string& dst_type, IdType chunk_size, IdType src_chunk_size,
- IdType dst_chunk_size, bool directed, const std::string& prefix,
+ Impl(std::string src_type, std::string edge_type, std::string dst_type,
+ IdType chunk_size, IdType src_chunk_size, IdType dst_chunk_size,
+ bool directed, std::string prefix,
const AdjacentListVector& adjacent_lists,
const PropertyGroupVector& property_groups,
std::shared_ptr<const InfoVersion> version)
- : src_type_(src_type),
- edge_type_(edge_type),
- dst_type_(dst_type),
+ : src_type_(std::move(src_type)),
+ edge_type_(std::move(edge_type)),
+ dst_type_(std::move(dst_type)),
chunk_size_(chunk_size),
src_chunk_size_(src_chunk_size),
dst_chunk_size_(dst_chunk_size),
directed_(directed),
- prefix_(prefix),
- adjacent_lists_(std::move(adjacent_lists)),
- property_groups_(std::move(property_groups)),
+ prefix_(std::move(prefix)),
+ adjacent_lists_(adjacent_lists),
+ property_groups_(property_groups),
version_(std::move(version)) {
if (prefix_.empty()) {
prefix_ = src_type_ + REGULAR_SEPARATOR + edge_type_ + REGULAR_SEPARATOR
+
diff --git a/cpp/src/graphar/graph_info.h b/cpp/src/graphar/graph_info.h
index d5f6d66b..13f52679 100644
--- a/cpp/src/graphar/graph_info.h
+++ b/cpp/src/graphar/graph_info.h
@@ -75,7 +75,7 @@ class PropertyGroup {
* prefix is the concatenation of property names with '_' as separator
*/
explicit PropertyGroup(const std::vector<Property>& properties,
- FileType file_type, const std::string& prefix = "");
+ FileType file_type, std::string prefix = "");
/**
* Get the property list of group.
@@ -137,7 +137,7 @@ class AdjacentList {
* prefix will be set the type name of adjacent list
*/
explicit AdjacentList(AdjListType type, FileType file_type,
- const std::string& prefix = "");
+ std::string prefix = "");
/**
* @brief Get the type of adjacent list
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]