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 89c167a8 fix(c++): Fix unused header files and preallocate vector
capacity (#867)
89c167a8 is described below
commit 89c167a87956470715e82b8c668ac6caf464c99a
Author: Jason <[email protected]>
AuthorDate: Tue Feb 24 13:28:11 2026 +0800
fix(c++): Fix unused header files and preallocate vector capacity (#867)
* fix(c++): Fix unused header files and preallocate vector capacity
* fix: applied to the similar code pattern in the filter function
* fix: cpplint errors
---
cpp/src/graphar/high-level/graph_reader.cc | 19 +++++++++----------
cpp/src/graphar/label.cc | 3 ---
2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/cpp/src/graphar/high-level/graph_reader.cc
b/cpp/src/graphar/high-level/graph_reader.cc
index 7323e075..50050c4d 100644
--- a/cpp/src/graphar/high-level/graph_reader.cc
+++ b/cpp/src/graphar/high-level/graph_reader.cc
@@ -117,10 +117,11 @@ Result<bool> VertexIter::hasLabel(const std::string&
label) noexcept {
Result<std::vector<std::string>> VertexIter::label() noexcept {
std::shared_ptr<arrow::ChunkedArray> column(nullptr);
std::vector<std::string> vertex_label;
- if (is_filtered_)
+ if (is_filtered_) {
label_reader_.seek(filtered_ids_[cur_offset_]);
- else
+ } else {
label_reader_.seek(cur_offset_);
+ }
GAR_ASSIGN_OR_RAISE(auto chunk_table, label_reader_.GetLabelChunk());
for (auto label : labels_) {
column = util::GetArrowColumnByName(chunk_table, label);
@@ -202,10 +203,9 @@ Result<std::vector<IdType>> VerticesCollection::filter(
}
}
// std::cout << "Total valid count: " << total_count << std::endl;
- std::vector<int64_t> indices64;
-
- for (int value : indices) {
- indices64.push_back(static_cast<int64_t>(value));
+ std::vector<int64_t> indices64(indices.size());
+ for (size_t i = 0; i < indices.size(); ++i) {
+ indices64[i] = static_cast<int64_t>(indices[i]);
}
delete[] bitmap;
@@ -252,10 +252,9 @@ Result<std::vector<IdType>>
VerticesCollection::filter_by_acero(
filter_reader->next_chunk();
}
// std::cout << "Total valid count: " << total_count << std::endl;
- std::vector<int64_t> indices64;
-
- for (int value : indices) {
- indices64.push_back(static_cast<int64_t>(value));
+ std::vector<int64_t> indices64(indices.size());
+ for (size_t i = 0; i < indices.size(); ++i) {
+ indices64[i] = static_cast<int64_t>(indices[i]);
}
return indices64;
diff --git a/cpp/src/graphar/label.cc b/cpp/src/graphar/label.cc
index 28778022..64f3c1ab 100644
--- a/cpp/src/graphar/label.cc
+++ b/cpp/src/graphar/label.cc
@@ -21,10 +21,7 @@
#include <cassert>
#include <cstring>
-#include <fstream>
-#include <iostream>
#include <memory>
-#include <set>
/// Read a parquet file by ParquetReader & get valid indices
/// The first column_num labels are concerned.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]