Skip to content

Commit 88de0b2

Browse files
committed
fix(cpp): add missing bracket in if condition and for loops
Signed-off-by: syaojun <libevent@yeah.net>
1 parent d535a43 commit 88de0b2

4 files changed

Lines changed: 58 additions & 29 deletions

File tree

cpp/src/graphar/arrow/chunk_writer.cc

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,13 @@ VertexPropertyWriter::VertexPropertyWriter(
126126
Status VertexPropertyWriter::validate(const IdType& count,
127127
ValidateLevel validate_level) const {
128128
// use the writer's validate level
129-
if (validate_level == ValidateLevel::default_validate)
129+
if (validate_level == ValidateLevel::default_validate) {
130130
validate_level = validate_level_;
131+
}
131132
// no validate
132-
if (validate_level == ValidateLevel::no_validate)
133+
if (validate_level == ValidateLevel::no_validate) {
133134
return Status::OK();
135+
}
134136
// weak & strong validate
135137
if (count < 0) {
136138
return Status::Invalid("The number of vertices is negative.");
@@ -143,11 +145,13 @@ Status VertexPropertyWriter::validate(
143145
const std::shared_ptr<PropertyGroup>& property_group, IdType chunk_index,
144146
ValidateLevel validate_level) const {
145147
// use the writer's validate level
146-
if (validate_level == ValidateLevel::default_validate)
148+
if (validate_level == ValidateLevel::default_validate) {
147149
validate_level = validate_level_;
150+
}
148151
// no validate
149-
if (validate_level == ValidateLevel::no_validate)
152+
if (validate_level == ValidateLevel::no_validate) {
150153
return Status::OK();
154+
}
151155
// weak & strong validate
152156
if (!vertex_info_->HasPropertyGroup(property_group)) {
153157
return Status::KeyError("The property group", " does not exist in ",
@@ -512,11 +516,13 @@ EdgeChunkWriter::EdgeChunkWriter(const std::shared_ptr<EdgeInfo>& edge_info,
512516
Status EdgeChunkWriter::validate(IdType count_or_index1, IdType count_or_index2,
513517
ValidateLevel validate_level) const {
514518
// use the writer's validate level
515-
if (validate_level == ValidateLevel::default_validate)
519+
if (validate_level == ValidateLevel::default_validate) {
516520
validate_level = validate_level_;
521+
}
517522
// no validate
518-
if (validate_level == ValidateLevel::no_validate)
523+
if (validate_level == ValidateLevel::no_validate) {
519524
return Status::OK();
525+
}
520526
// weak & strong validate for adj list type
521527
if (!edge_info_->HasAdjacentListType(adj_list_type_)) {
522528
return Status::KeyError(
@@ -538,11 +544,13 @@ Status EdgeChunkWriter::validate(
538544
IdType vertex_chunk_index, IdType chunk_index,
539545
ValidateLevel validate_level) const {
540546
// use the writer's validate level
541-
if (validate_level == ValidateLevel::default_validate)
547+
if (validate_level == ValidateLevel::default_validate) {
542548
validate_level = validate_level_;
549+
}
543550
// no validate
544-
if (validate_level == ValidateLevel::no_validate)
551+
if (validate_level == ValidateLevel::no_validate) {
545552
return Status::OK();
553+
}
546554
// validate for adj list type & index
547555
GAR_RETURN_NOT_OK(validate(vertex_chunk_index, chunk_index, validate_level));
548556
// weak & strong validate for property group
@@ -558,11 +566,13 @@ Status EdgeChunkWriter::validate(
558566
const std::shared_ptr<arrow::Table>& input_table, IdType vertex_chunk_index,
559567
ValidateLevel validate_level) const {
560568
// use the writer's validate level
561-
if (validate_level == ValidateLevel::default_validate)
569+
if (validate_level == ValidateLevel::default_validate) {
562570
validate_level = validate_level_;
571+
}
563572
// no validate
564-
if (validate_level == ValidateLevel::no_validate)
573+
if (validate_level == ValidateLevel::no_validate) {
565574
return Status::OK();
575+
}
566576
// validate for adj list type & index
567577
GAR_RETURN_NOT_OK(validate(vertex_chunk_index, 0, validate_level));
568578
// weak validate for the input table
@@ -613,11 +623,13 @@ Status EdgeChunkWriter::validate(
613623
const std::shared_ptr<arrow::Table>& input_table, IdType vertex_chunk_index,
614624
IdType chunk_index, ValidateLevel validate_level) const {
615625
// use the writer's validate level
616-
if (validate_level == ValidateLevel::default_validate)
626+
if (validate_level == ValidateLevel::default_validate) {
617627
validate_level = validate_level_;
628+
}
618629
// no validate
619-
if (validate_level == ValidateLevel::no_validate)
630+
if (validate_level == ValidateLevel::no_validate) {
620631
return Status::OK();
632+
}
621633
// validate for adj list type & index
622634
GAR_RETURN_NOT_OK(validate(vertex_chunk_index, chunk_index, validate_level));
623635
// weak validate for the input table
@@ -666,11 +678,13 @@ Status EdgeChunkWriter::validate(
666678
IdType vertex_chunk_index, IdType chunk_index,
667679
ValidateLevel validate_level) const {
668680
// use the writer's validate level
669-
if (validate_level == ValidateLevel::default_validate)
681+
if (validate_level == ValidateLevel::default_validate) {
670682
validate_level = validate_level_;
683+
}
671684
// no validate
672-
if (validate_level == ValidateLevel::no_validate)
685+
if (validate_level == ValidateLevel::no_validate) {
673686
return Status::OK();
687+
}
674688
// validate for property group, adj list type & index
675689
GAR_RETURN_NOT_OK(validate(property_group, vertex_chunk_index, chunk_index,
676690
validate_level));
@@ -970,12 +984,14 @@ Result<std::shared_ptr<arrow::Table>> EdgeChunkWriter::getOffsetTable(
970984
int64_t global_index = 0;
971985
for (IdType i = begin_index; i < end_index; i++) {
972986
while (true) {
973-
if (array_index >= column->num_chunks())
987+
if (array_index >= column->num_chunks()) {
974988
break;
989+
}
975990
if (index >= ids->length()) {
976991
array_index++;
977-
if (array_index == column->num_chunks())
992+
if (array_index == column->num_chunks()) {
978993
break;
994+
}
979995
ids = std::static_pointer_cast<arrow::Int64Array>(
980996
column->chunk(array_index));
981997
index = 0;

cpp/src/graphar/chunk_info_writer.cc

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ Status VertexChunkInfoWriter::validate(
4545
const std::shared_ptr<PropertyGroup>& property_group, IdType chunk_index,
4646
ValidateLevel validate_level) const {
4747
// use the writer's validate level
48-
if (validate_level == ValidateLevel::default_validate)
48+
if (validate_level == ValidateLevel::default_validate) {
4949
validate_level = validate_level_;
50+
}
5051
// no validate
51-
if (validate_level == ValidateLevel::no_validate)
52+
if (validate_level == ValidateLevel::no_validate) {
5253
return Status::OK();
54+
}
5355
// weak & strong validate
5456
if (!vertex_info_->HasPropertyGroup(property_group)) {
5557
return Status::KeyError("The property group", " does not exist in ",
@@ -108,11 +110,13 @@ Status EdgeChunkInfoWriter::validate(IdType count_or_index1,
108110
IdType count_or_index2,
109111
ValidateLevel validate_level) const {
110112
// use the writer's validate level
111-
if (validate_level == ValidateLevel::default_validate)
113+
if (validate_level == ValidateLevel::default_validate) {
112114
validate_level = validate_level_;
115+
}
113116
// no validate
114-
if (validate_level == ValidateLevel::no_validate)
117+
if (validate_level == ValidateLevel::no_validate) {
115118
return Status::OK();
119+
}
116120
// weak & strong validate for adj list type
117121
if (!edge_info_->HasAdjacentListType(adj_list_type_)) {
118122
return Status::KeyError(
@@ -134,11 +138,13 @@ Status EdgeChunkInfoWriter::validate(
134138
IdType vertex_chunk_index, IdType chunk_index,
135139
ValidateLevel validate_level) const {
136140
// use the writer's validate level
137-
if (validate_level == ValidateLevel::default_validate)
141+
if (validate_level == ValidateLevel::default_validate) {
138142
validate_level = validate_level_;
143+
}
139144
// no validate
140-
if (validate_level == ValidateLevel::no_validate)
145+
if (validate_level == ValidateLevel::no_validate) {
141146
return Status::OK();
147+
}
142148
// validate for adj list type & index
143149
GAR_RETURN_NOT_OK(validate(vertex_chunk_index, chunk_index, validate_level));
144150
// weak & strong validate for property group

cpp/src/graphar/high-level/edges_builder.cc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,24 @@ Status EdgesBuilder::Dump() {
3333
// construct empty edge collections for vertex chunks without edges
3434
IdType num_vertex_chunks =
3535
(num_vertices_ + vertex_chunk_size_ - 1) / vertex_chunk_size_;
36-
for (IdType i = 0; i < num_vertex_chunks; i++)
36+
for (IdType i = 0; i < num_vertex_chunks; i++) {
3737
if (edges_.find(i) == edges_.end()) {
3838
std::vector<Edge> empty_chunk_edges;
3939
edges_[i] = empty_chunk_edges;
4040
}
41+
}
4142
// dump the offsets
4243
if (adj_list_type_ == AdjListType::ordered_by_source ||
4344
adj_list_type_ == AdjListType::ordered_by_dest) {
4445
for (auto& chunk_edges : edges_) {
4546
IdType vertex_chunk_index = chunk_edges.first;
4647
// sort the edges
47-
if (adj_list_type_ == AdjListType::ordered_by_source)
48+
if (adj_list_type_ == AdjListType::ordered_by_source) {
4849
sort(chunk_edges.second.begin(), chunk_edges.second.end(), cmp_src);
49-
if (adj_list_type_ == AdjListType::ordered_by_dest)
50+
}
51+
if (adj_list_type_ == AdjListType::ordered_by_dest) {
5052
sort(chunk_edges.second.begin(), chunk_edges.second.end(), cmp_dst);
53+
}
5154
// construct and write offset chunk
5255
GAR_ASSIGN_OR_RAISE(
5356
auto offset_table,
@@ -86,11 +89,13 @@ Status EdgesBuilder::Dump() {
8689
Status EdgesBuilder::validate(const Edge& e,
8790
ValidateLevel validate_level) const {
8891
// use the builder's validate level
89-
if (validate_level == ValidateLevel::default_validate)
92+
if (validate_level == ValidateLevel::default_validate) {
9093
validate_level = validate_level_;
94+
}
9195
// no validate
92-
if (validate_level == ValidateLevel::no_validate)
96+
if (validate_level == ValidateLevel::no_validate) {
9397
return Status::OK();
98+
}
9499

95100
// weak validate
96101
// can not add new edges after dumping

cpp/src/graphar/high-level/vertices_builder.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ namespace graphar::builder {
3232
Status VerticesBuilder::validate(const Vertex& v, IdType index,
3333
ValidateLevel validate_level) const {
3434
// use the builder's validate level
35-
if (validate_level == ValidateLevel::default_validate)
35+
if (validate_level == ValidateLevel::default_validate) {
3636
validate_level = validate_level_;
37+
}
3738
// no validate
38-
if (validate_level == ValidateLevel::no_validate)
39+
if (validate_level == ValidateLevel::no_validate) {
3940
return Status::OK();
41+
}
4042

4143
// weak validate
4244
// can not add new vertices after dumping

0 commit comments

Comments
 (0)