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 b21da29e fix(cpp): add missing bracket in if condition and for loops
(#900)
b21da29e is described below
commit b21da29e2b55351f52b1d0f50abfa400e4d1d3fd
Author: Jason Yao <[email protected]>
AuthorDate: Tue Mar 10 20:52:48 2026 +0800
fix(cpp): add missing bracket in if condition and for loops (#900)
Signed-off-by: syaojun <[email protected]>
---
cpp/src/graphar/arrow/chunk_writer.cc | 48 +++++++++++++++++---------
cpp/src/graphar/chunk_info_writer.cc | 18 ++++++----
cpp/src/graphar/high-level/edges_builder.cc | 15 +++++---
cpp/src/graphar/high-level/vertices_builder.cc | 6 ++--
4 files changed, 58 insertions(+), 29 deletions(-)
diff --git a/cpp/src/graphar/arrow/chunk_writer.cc
b/cpp/src/graphar/arrow/chunk_writer.cc
index f299d1ed..0fd862b2 100644
--- a/cpp/src/graphar/arrow/chunk_writer.cc
+++ b/cpp/src/graphar/arrow/chunk_writer.cc
@@ -126,11 +126,13 @@ VertexPropertyWriter::VertexPropertyWriter(
Status VertexPropertyWriter::validate(const IdType& count,
ValidateLevel validate_level) const {
// use the writer's validate level
- if (validate_level == ValidateLevel::default_validate)
+ if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
+ }
// no validate
- if (validate_level == ValidateLevel::no_validate)
+ if (validate_level == ValidateLevel::no_validate) {
return Status::OK();
+ }
// weak & strong validate
if (count < 0) {
return Status::Invalid("The number of vertices is negative.");
@@ -143,11 +145,13 @@ Status VertexPropertyWriter::validate(
const std::shared_ptr<PropertyGroup>& property_group, IdType chunk_index,
ValidateLevel validate_level) const {
// use the writer's validate level
- if (validate_level == ValidateLevel::default_validate)
+ if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
+ }
// no validate
- if (validate_level == ValidateLevel::no_validate)
+ if (validate_level == ValidateLevel::no_validate) {
return Status::OK();
+ }
// weak & strong validate
if (!vertex_info_->HasPropertyGroup(property_group)) {
return Status::KeyError("The property group", " does not exist in ",
@@ -512,11 +516,13 @@ EdgeChunkWriter::EdgeChunkWriter(const
std::shared_ptr<EdgeInfo>& edge_info,
Status EdgeChunkWriter::validate(IdType count_or_index1, IdType
count_or_index2,
ValidateLevel validate_level) const {
// use the writer's validate level
- if (validate_level == ValidateLevel::default_validate)
+ if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
+ }
// no validate
- if (validate_level == ValidateLevel::no_validate)
+ if (validate_level == ValidateLevel::no_validate) {
return Status::OK();
+ }
// weak & strong validate for adj list type
if (!edge_info_->HasAdjacentListType(adj_list_type_)) {
return Status::KeyError(
@@ -538,11 +544,13 @@ Status EdgeChunkWriter::validate(
IdType vertex_chunk_index, IdType chunk_index,
ValidateLevel validate_level) const {
// use the writer's validate level
- if (validate_level == ValidateLevel::default_validate)
+ if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
+ }
// no validate
- if (validate_level == ValidateLevel::no_validate)
+ if (validate_level == ValidateLevel::no_validate) {
return Status::OK();
+ }
// validate for adj list type & index
GAR_RETURN_NOT_OK(validate(vertex_chunk_index, chunk_index, validate_level));
// weak & strong validate for property group
@@ -558,11 +566,13 @@ Status EdgeChunkWriter::validate(
const std::shared_ptr<arrow::Table>& input_table, IdType
vertex_chunk_index,
ValidateLevel validate_level) const {
// use the writer's validate level
- if (validate_level == ValidateLevel::default_validate)
+ if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
+ }
// no validate
- if (validate_level == ValidateLevel::no_validate)
+ if (validate_level == ValidateLevel::no_validate) {
return Status::OK();
+ }
// validate for adj list type & index
GAR_RETURN_NOT_OK(validate(vertex_chunk_index, 0, validate_level));
// weak validate for the input table
@@ -613,11 +623,13 @@ Status EdgeChunkWriter::validate(
const std::shared_ptr<arrow::Table>& input_table, IdType
vertex_chunk_index,
IdType chunk_index, ValidateLevel validate_level) const {
// use the writer's validate level
- if (validate_level == ValidateLevel::default_validate)
+ if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
+ }
// no validate
- if (validate_level == ValidateLevel::no_validate)
+ if (validate_level == ValidateLevel::no_validate) {
return Status::OK();
+ }
// validate for adj list type & index
GAR_RETURN_NOT_OK(validate(vertex_chunk_index, chunk_index, validate_level));
// weak validate for the input table
@@ -666,11 +678,13 @@ Status EdgeChunkWriter::validate(
IdType vertex_chunk_index, IdType chunk_index,
ValidateLevel validate_level) const {
// use the writer's validate level
- if (validate_level == ValidateLevel::default_validate)
+ if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
+ }
// no validate
- if (validate_level == ValidateLevel::no_validate)
+ if (validate_level == ValidateLevel::no_validate) {
return Status::OK();
+ }
// validate for property group, adj list type & index
GAR_RETURN_NOT_OK(validate(property_group, vertex_chunk_index, chunk_index,
validate_level));
@@ -970,12 +984,14 @@ Result<std::shared_ptr<arrow::Table>>
EdgeChunkWriter::getOffsetTable(
int64_t global_index = 0;
for (IdType i = begin_index; i < end_index; i++) {
while (true) {
- if (array_index >= column->num_chunks())
+ if (array_index >= column->num_chunks()) {
break;
+ }
if (index >= ids->length()) {
array_index++;
- if (array_index == column->num_chunks())
+ if (array_index == column->num_chunks()) {
break;
+ }
ids = std::static_pointer_cast<arrow::Int64Array>(
column->chunk(array_index));
index = 0;
diff --git a/cpp/src/graphar/chunk_info_writer.cc
b/cpp/src/graphar/chunk_info_writer.cc
index b832afe3..2e2a7a58 100644
--- a/cpp/src/graphar/chunk_info_writer.cc
+++ b/cpp/src/graphar/chunk_info_writer.cc
@@ -45,11 +45,13 @@ Status VertexChunkInfoWriter::validate(
const std::shared_ptr<PropertyGroup>& property_group, IdType chunk_index,
ValidateLevel validate_level) const {
// use the writer's validate level
- if (validate_level == ValidateLevel::default_validate)
+ if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
+ }
// no validate
- if (validate_level == ValidateLevel::no_validate)
+ if (validate_level == ValidateLevel::no_validate) {
return Status::OK();
+ }
// weak & strong validate
if (!vertex_info_->HasPropertyGroup(property_group)) {
return Status::KeyError("The property group", " does not exist in ",
@@ -108,11 +110,13 @@ Status EdgeChunkInfoWriter::validate(IdType
count_or_index1,
IdType count_or_index2,
ValidateLevel validate_level) const {
// use the writer's validate level
- if (validate_level == ValidateLevel::default_validate)
+ if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
+ }
// no validate
- if (validate_level == ValidateLevel::no_validate)
+ if (validate_level == ValidateLevel::no_validate) {
return Status::OK();
+ }
// weak & strong validate for adj list type
if (!edge_info_->HasAdjacentListType(adj_list_type_)) {
return Status::KeyError(
@@ -134,11 +138,13 @@ Status EdgeChunkInfoWriter::validate(
IdType vertex_chunk_index, IdType chunk_index,
ValidateLevel validate_level) const {
// use the writer's validate level
- if (validate_level == ValidateLevel::default_validate)
+ if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
+ }
// no validate
- if (validate_level == ValidateLevel::no_validate)
+ if (validate_level == ValidateLevel::no_validate) {
return Status::OK();
+ }
// validate for adj list type & index
GAR_RETURN_NOT_OK(validate(vertex_chunk_index, chunk_index, validate_level));
// weak & strong validate for property group
diff --git a/cpp/src/graphar/high-level/edges_builder.cc
b/cpp/src/graphar/high-level/edges_builder.cc
index 8227c098..5a5aa56d 100644
--- a/cpp/src/graphar/high-level/edges_builder.cc
+++ b/cpp/src/graphar/high-level/edges_builder.cc
@@ -33,21 +33,24 @@ Status EdgesBuilder::Dump() {
// construct empty edge collections for vertex chunks without edges
IdType num_vertex_chunks =
(num_vertices_ + vertex_chunk_size_ - 1) / vertex_chunk_size_;
- for (IdType i = 0; i < num_vertex_chunks; i++)
+ for (IdType i = 0; i < num_vertex_chunks; i++) {
if (edges_.find(i) == edges_.end()) {
std::vector<Edge> empty_chunk_edges;
edges_[i] = empty_chunk_edges;
}
+ }
// dump the offsets
if (adj_list_type_ == AdjListType::ordered_by_source ||
adj_list_type_ == AdjListType::ordered_by_dest) {
for (auto& chunk_edges : edges_) {
IdType vertex_chunk_index = chunk_edges.first;
// sort the edges
- if (adj_list_type_ == AdjListType::ordered_by_source)
+ if (adj_list_type_ == AdjListType::ordered_by_source) {
sort(chunk_edges.second.begin(), chunk_edges.second.end(), cmp_src);
- if (adj_list_type_ == AdjListType::ordered_by_dest)
+ }
+ if (adj_list_type_ == AdjListType::ordered_by_dest) {
sort(chunk_edges.second.begin(), chunk_edges.second.end(), cmp_dst);
+ }
// construct and write offset chunk
GAR_ASSIGN_OR_RAISE(
auto offset_table,
@@ -86,11 +89,13 @@ Status EdgesBuilder::Dump() {
Status EdgesBuilder::validate(const Edge& e,
ValidateLevel validate_level) const {
// use the builder's validate level
- if (validate_level == ValidateLevel::default_validate)
+ if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
+ }
// no validate
- if (validate_level == ValidateLevel::no_validate)
+ if (validate_level == ValidateLevel::no_validate) {
return Status::OK();
+ }
// weak validate
// can not add new edges after dumping
diff --git a/cpp/src/graphar/high-level/vertices_builder.cc
b/cpp/src/graphar/high-level/vertices_builder.cc
index fd0208be..00093831 100644
--- a/cpp/src/graphar/high-level/vertices_builder.cc
+++ b/cpp/src/graphar/high-level/vertices_builder.cc
@@ -32,11 +32,13 @@ namespace graphar::builder {
Status VerticesBuilder::validate(const Vertex& v, IdType index,
ValidateLevel validate_level) const {
// use the builder's validate level
- if (validate_level == ValidateLevel::default_validate)
+ if (validate_level == ValidateLevel::default_validate) {
validate_level = validate_level_;
+ }
// no validate
- if (validate_level == ValidateLevel::no_validate)
+ if (validate_level == ValidateLevel::no_validate) {
return Status::OK();
+ }
// weak validate
// can not add new vertices after dumping
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]