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 6c802a1a feat(C++): add -Werror=unused-variable flag and remove unused
variables (#841)
6c802a1a is described below
commit 6c802a1aa64d8a049366638eef4ecf8a1f8ebb19
Author: 姚军 <[email protected]>
AuthorDate: Mon Feb 9 20:55:37 2026 +0800
feat(C++): add -Werror=unused-variable flag and remove unused variables
(#841)
---
cpp/CMakeLists.txt | 2 +-
cpp/src/graphar/arrow/chunk_writer.cc | 1 -
cpp/src/graphar/filesystem.cc | 1 -
cpp/src/graphar/high-level/graph_reader.cc | 6 ------
cpp/src/graphar/high-level/graph_reader.h | 4 ++--
cpp/src/graphar/label.cc | 5 ++---
cpp/thirdparty/mini-yaml/yaml/Yaml.cpp | 1 -
7 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index d3acfb58..14b63df5 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -107,7 +107,7 @@ if(MSVC)
# Avoid GCC/Clang-specific flags on MSVC.
# C++17 is already enforced via CMAKE_CXX_STANDARD/target features.
else()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall
-Werror=unused-variable")
endif()
if (APPLE)
diff --git a/cpp/src/graphar/arrow/chunk_writer.cc
b/cpp/src/graphar/arrow/chunk_writer.cc
index eea62879..f299d1ed 100644
--- a/cpp/src/graphar/arrow/chunk_writer.cc
+++ b/cpp/src/graphar/arrow/chunk_writer.cc
@@ -333,7 +333,6 @@ Status VertexPropertyWriter::WriteLabelTable(
const std::shared_ptr<arrow::Table>& input_table, IdType start_chunk_index,
FileType file_type, ValidateLevel validate_level) const {
auto schema = input_table->schema();
- int indice = schema->GetFieldIndex(GeneralParams::kVertexIndexCol);
IdType chunk_size = vertex_info_->GetChunkSize();
int64_t length = input_table->num_rows();
IdType chunk_index = start_chunk_index;
diff --git a/cpp/src/graphar/filesystem.cc b/cpp/src/graphar/filesystem.cc
index 78472cc4..2edaf1e5 100644
--- a/cpp/src/graphar/filesystem.cc
+++ b/cpp/src/graphar/filesystem.cc
@@ -300,7 +300,6 @@ Status FileSystem::WriteLabelTableToFile(
GAR_RETURN_ON_ARROW_ERROR_AND_ASSIGN(auto output_stream,
arrow_fs_->OpenOutputStream(path));
auto schema = table->schema();
- auto column_num = schema->num_fields();
parquet::WriterProperties::Builder builder;
builder.compression(arrow::Compression::type::ZSTD); // enable compression
builder.encoding(parquet::Encoding::RLE);
diff --git a/cpp/src/graphar/high-level/graph_reader.cc
b/cpp/src/graphar/high-level/graph_reader.cc
index e02d9227..6b554565 100644
--- a/cpp/src/graphar/high-level/graph_reader.cc
+++ b/cpp/src/graphar/high-level/graph_reader.cc
@@ -172,7 +172,6 @@ Result<std::vector<IdType>> VerticesCollection::filter(
uint64_t* bitmap = new uint64_t[TOT_ROWS_NUM / 64 + 1];
memset(bitmap, 0, sizeof(uint64_t) * (TOT_ROWS_NUM / 64 + 1));
- int total_count = 0;
int row_num;
if (is_filtered_) {
@@ -226,8 +225,6 @@ Result<std::vector<IdType>>
VerticesCollection::filter_by_acero(
tested_label_ids.push_back(std::distance(labels_.begin(), it));
}
}
- int total_count = 0;
- int row_num;
std::vector<std::shared_ptr<Expression>> filters;
std::shared_ptr<Expression> combined_filter = nullptr;
@@ -251,7 +248,6 @@ Result<std::vector<IdType>>
VerticesCollection::filter_by_acero(
for (int chunk_idx = 0; chunk_idx * CHUNK_SIZE < TOT_ROWS_NUM; ++chunk_idx) {
auto filter_result = filter_reader->GetLabelChunk();
auto filter_table = filter_result.value();
- total_count += filter_table->num_rows();
filter_reader->next_chunk();
}
// std::cout << "Total valid count: " << total_count << std::endl;
@@ -271,7 +267,6 @@ Result<std::vector<IdType>> VerticesCollection::filter(
std::vector<int> indices;
const int TOT_ROWS_NUM = vertex_num_;
const int CHUNK_SIZE = vertex_info_->GetChunkSize();
- int total_count = 0;
auto property_group = vertex_info_->GetPropertyGroup(property_name);
auto maybe_filter_reader = graphar::VertexPropertyArrowChunkReader::Make(
vertex_info_, property_group, prefix_, {});
@@ -309,7 +304,6 @@ Result<std::vector<IdType>> VerticesCollection::filter(
auto filter_table = filter_result.value();
int count = filter_table->num_rows();
filter_reader->next_chunk();
- total_count += count;
if (count != 0) {
valid_chunk_.emplace_back(static_cast<IdType>(chunk_idx));
// TODO(elssky): record indices
diff --git a/cpp/src/graphar/high-level/graph_reader.h
b/cpp/src/graphar/high-level/graph_reader.h
index b8a7ad8e..88c94d0f 100644
--- a/cpp/src/graphar/high-level/graph_reader.h
+++ b/cpp/src/graphar/high-level/graph_reader.h
@@ -198,9 +198,9 @@ class VertexIter {
/** Copy constructor. */
VertexIter(const VertexIter& other)
: readers_(other.readers_),
- cur_offset_(other.cur_offset_),
- labels_(other.labels_),
label_reader_(other.label_reader_),
+ labels_(other.labels_),
+ cur_offset_(other.cur_offset_),
is_filtered_(other.is_filtered_),
filtered_ids_(other.filtered_ids_) {}
diff --git a/cpp/src/graphar/label.cc b/cpp/src/graphar/label.cc
index e8b23797..7e1074ac 100644
--- a/cpp/src/graphar/label.cc
+++ b/cpp/src/graphar/label.cc
@@ -85,15 +85,14 @@ int read_parquet_file_and_get_valid_indices(
}
}
}
- const int kTotLabelNum = tot_label_num;
- bool state[kTotLabelNum];
+ std::unique_ptr<bool[]> state(new bool[tot_label_num]);
int count = 0;
int offset = chunk_idx * chunk_size;
for (int i = 0; i < row_num; i++) {
for (int j = 0; j < tested_label_num; j++) {
state[j] = value[j][i];
}
- if (IsValid(state, tested_label_num)) {
+ if (IsValid(state.get(), tested_label_num)) {
count++;
if (query_type == QUERY_TYPE::INDEX)
diff --git a/cpp/thirdparty/mini-yaml/yaml/Yaml.cpp
b/cpp/thirdparty/mini-yaml/yaml/Yaml.cpp
index 70adec6f..9a84975e 100644
--- a/cpp/thirdparty/mini-yaml/yaml/Yaml.cpp
+++ b/cpp/thirdparty/mini-yaml/yaml/Yaml.cpp
@@ -50,7 +50,6 @@ namespace Yaml
static const std::string g_ErrorInvalidCharacter = "Invalid
character found.";
static const std::string g_ErrorKeyMissing = "Missing key.";
static const std::string g_ErrorKeyIncorrect = "Incorrect key.";
- static const std::string g_ErrorValueIncorrect = "Incorrect
value.";
static const std::string g_ErrorTabInOffset = "Tab found in
offset.";
static const std::string g_ErrorBlockSequenceNotAllowed = "Sequence
entries are not allowed in this context.";
static const std::string g_ErrorUnexpectedDocumentEnd = "Unexpected
document end.";
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]