Skip to content

Commit ba814c8

Browse files
committed
refactor(cpp): change FilterOptions parameter to be moved instead of const reference
Signed-off-by: syaojun <libevent@yeah.net>
1 parent d535a43 commit ba814c8

4 files changed

Lines changed: 30 additions & 28 deletions

File tree

cpp/src/graphar/arrow/chunk_reader.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,23 +154,23 @@ Status CastTableWithSchema(const std::shared_ptr<arrow::Table>& table,
154154
VertexPropertyArrowChunkReader::VertexPropertyArrowChunkReader(
155155
const std::shared_ptr<VertexInfo>& vertex_info,
156156
const std::shared_ptr<PropertyGroup>& property_group,
157-
const std::string& prefix, const util::FilterOptions& options)
157+
const std::string& prefix, util::FilterOptions options)
158158
: VertexPropertyArrowChunkReader(vertex_info, property_group, {}, prefix,
159-
options) {}
159+
std::move(options)) {}
160160

161161
VertexPropertyArrowChunkReader::VertexPropertyArrowChunkReader(
162162
const std::shared_ptr<VertexInfo>& vertex_info,
163163
const std::shared_ptr<PropertyGroup>& property_group,
164164
const std::vector<std::string>& property_names, const std::string& prefix,
165-
const util::FilterOptions& options)
165+
util::FilterOptions options)
166166
: vertex_info_(std::move(vertex_info)),
167167
property_group_(std::move(property_group)),
168168
property_names_(std::move(property_names)),
169169
chunk_index_(0),
170170
seek_id_(0),
171171
schema_(nullptr),
172172
chunk_table_(nullptr),
173-
filter_options_(options) {
173+
filter_options_(std::move(options)) {
174174
GAR_ASSIGN_OR_RAISE_ERROR(fs_, FileSystemFromUriOrPath(prefix, &prefix_));
175175
GAR_ASSIGN_OR_RAISE_ERROR(auto pg_path_prefix,
176176
vertex_info->GetPathPrefix(property_group));
@@ -187,14 +187,14 @@ VertexPropertyArrowChunkReader::VertexPropertyArrowChunkReader(
187187
VertexPropertyArrowChunkReader::VertexPropertyArrowChunkReader(
188188
const std::shared_ptr<VertexInfo>& vertex_info,
189189
const std::vector<std::string>& labels, const std::string& prefix,
190-
const util::FilterOptions& options)
190+
util::FilterOptions options)
191191
: vertex_info_(std::move(vertex_info)),
192192
labels_(labels),
193193
chunk_index_(0),
194194
seek_id_(0),
195195
schema_(nullptr),
196196
chunk_table_(nullptr),
197-
filter_options_(options) {
197+
filter_options_(std::move(options)) {
198198
GAR_ASSIGN_OR_RAISE_ERROR(fs_, FileSystemFromUriOrPath(prefix, &prefix_));
199199

200200
std::string base_dir = prefix_ + vertex_info_->GetPrefix() + "labels/chunk" +
@@ -855,7 +855,7 @@ AdjListPropertyArrowChunkReader::AdjListPropertyArrowChunkReader(
855855
const std::shared_ptr<EdgeInfo>& edge_info,
856856
const std::shared_ptr<PropertyGroup>& property_group,
857857
AdjListType adj_list_type, const std::string prefix,
858-
const util::FilterOptions& options)
858+
util::FilterOptions options)
859859
: edge_info_(std::move(edge_info)),
860860
property_group_(std::move(property_group)),
861861
adj_list_type_(adj_list_type),
@@ -865,7 +865,7 @@ AdjListPropertyArrowChunkReader::AdjListPropertyArrowChunkReader(
865865
seek_offset_(0),
866866
schema_(nullptr),
867867
chunk_table_(nullptr),
868-
filter_options_(options),
868+
filter_options_(std::move(options)),
869869
chunk_num_(-1) /* -1 means uninitialized */ {
870870
GAR_ASSIGN_OR_RAISE_ERROR(fs_, FileSystemFromUriOrPath(prefix, &prefix_));
871871
GAR_ASSIGN_OR_RAISE_ERROR(

cpp/src/graphar/arrow/chunk_reader.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class VertexPropertyArrowChunkReader {
5252
VertexPropertyArrowChunkReader(
5353
const std::shared_ptr<VertexInfo>& vertex_info,
5454
const std::shared_ptr<PropertyGroup>& property_group,
55-
const std::string& prefix, const util::FilterOptions& options = {});
55+
const std::string& prefix, util::FilterOptions options = {});
5656
/**
5757
* @brief Initialize the VertexPropertyArrowChunkReader.
5858
*
@@ -65,7 +65,7 @@ class VertexPropertyArrowChunkReader {
6565
const std::shared_ptr<VertexInfo>& vertex_info,
6666
const std::shared_ptr<PropertyGroup>& property_group,
6767
const std::vector<std::string>& property_names, const std::string& prefix,
68-
const util::FilterOptions& options = {});
68+
util::FilterOptions options = {});
6969

7070
VertexPropertyArrowChunkReader() : vertex_info_(nullptr), prefix_("") {}
7171

@@ -79,7 +79,7 @@ class VertexPropertyArrowChunkReader {
7979
VertexPropertyArrowChunkReader(const std::shared_ptr<VertexInfo>& vertex_info,
8080
const std::vector<std::string>& labels,
8181
const std::string& prefix,
82-
const util::FilterOptions& options = {});
82+
util::FilterOptions options = {});
8383
/**
8484
* @brief Sets chunk position indicator for reader by internal vertex id.
8585
* If internal vertex id is not found, will return Status::IndexError
@@ -492,7 +492,7 @@ class AdjListPropertyArrowChunkReader {
492492
const std::shared_ptr<EdgeInfo>& edge_info,
493493
const std::shared_ptr<PropertyGroup>& property_group,
494494
AdjListType adj_list_type, const std::string prefix,
495-
const util::FilterOptions& options = {});
495+
util::FilterOptions options = {});
496496

497497
/**
498498
* @brief Copy constructor.

cpp/src/graphar/graph_info.cc

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ bool operator==(const Property& lhs, const Property& rhs) {
108108
}
109109

110110
PropertyGroup::PropertyGroup(const std::vector<Property>& properties,
111-
FileType file_type, const std::string& prefix)
112-
: properties_(properties), file_type_(file_type), prefix_(prefix) {
111+
FileType file_type, std::string prefix)
112+
: properties_(properties),
113+
file_type_(file_type),
114+
prefix_(std::move(prefix)) {
113115
if (prefix_.empty() && !properties_.empty()) {
114116
for (const auto& p : properties_) {
115117
prefix_ += p.name + REGULAR_SEPARATOR;
@@ -182,8 +184,8 @@ bool operator==(const PropertyGroup& lhs, const PropertyGroup& rhs) {
182184
}
183185

184186
AdjacentList::AdjacentList(AdjListType type, FileType file_type,
185-
const std::string& prefix)
186-
: type_(type), file_type_(file_type), prefix_(prefix) {
187+
std::string prefix)
188+
: type_(type), file_type_(file_type), prefix_(std::move(prefix)) {
187189
if (prefix_.empty()) {
188190
prefix_ = std::string(AdjListTypeToString(type_)) + "/";
189191
}
@@ -212,15 +214,15 @@ std::shared_ptr<AdjacentList> CreateAdjacentList(AdjListType type,
212214

213215
class VertexInfo::Impl {
214216
public:
215-
Impl(const std::string& type, IdType chunk_size, const std::string& prefix,
217+
Impl(std::string type, IdType chunk_size, std::string prefix,
216218
const PropertyGroupVector& property_groups,
217219
const std::vector<std::string>& labels,
218220
std::shared_ptr<const InfoVersion> version)
219-
: type_(type),
221+
: type_(std::move(type)),
220222
chunk_size_(chunk_size),
221223
property_groups_(std::move(property_groups)),
222224
labels_(labels),
223-
prefix_(prefix),
225+
prefix_(std::move(prefix)),
224226
version_(std::move(version)) {
225227
if (prefix_.empty()) {
226228
prefix_ = type_ + "/"; // default prefix
@@ -568,20 +570,20 @@ Status VertexInfo::Save(const std::string& path) const {
568570

569571
class EdgeInfo::Impl {
570572
public:
571-
Impl(const std::string& src_type, const std::string& edge_type,
572-
const std::string& dst_type, IdType chunk_size, IdType src_chunk_size,
573-
IdType dst_chunk_size, bool directed, const std::string& prefix,
573+
Impl(std::string src_type, std::string edge_type, std::string dst_type,
574+
IdType chunk_size, IdType src_chunk_size, IdType dst_chunk_size,
575+
bool directed, std::string prefix,
574576
const AdjacentListVector& adjacent_lists,
575577
const PropertyGroupVector& property_groups,
576578
std::shared_ptr<const InfoVersion> version)
577-
: src_type_(src_type),
578-
edge_type_(edge_type),
579-
dst_type_(dst_type),
579+
: src_type_(std::move(src_type)),
580+
edge_type_(std::move(edge_type)),
581+
dst_type_(std::move(dst_type)),
580582
chunk_size_(chunk_size),
581583
src_chunk_size_(src_chunk_size),
582584
dst_chunk_size_(dst_chunk_size),
583585
directed_(directed),
584-
prefix_(prefix),
586+
prefix_(std::move(prefix)),
585587
adjacent_lists_(std::move(adjacent_lists)),
586588
property_groups_(std::move(property_groups)),
587589
version_(std::move(version)) {

cpp/src/graphar/graph_info.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class PropertyGroup {
7575
* prefix is the concatenation of property names with '_' as separator
7676
*/
7777
explicit PropertyGroup(const std::vector<Property>& properties,
78-
FileType file_type, const std::string& prefix = "");
78+
FileType file_type, std::string prefix = "");
7979

8080
/**
8181
* Get the property list of group.
@@ -137,7 +137,7 @@ class AdjacentList {
137137
* prefix will be set the type name of adjacent list
138138
*/
139139
explicit AdjacentList(AdjListType type, FileType file_type,
140-
const std::string& prefix = "");
140+
std::string prefix = "");
141141

142142
/**
143143
* @brief Get the type of adjacent list

0 commit comments

Comments
 (0)