Skip to content

Commit bdd6bc7

Browse files
authored
Re-format cpp code (milvus-io#22513)
Signed-off-by: yah01 <[email protected]>
1 parent fa86de5 commit bdd6bc7

File tree

145 files changed

+3291
-1446
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+3291
-1446
lines changed

.clang-format

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# Below is copied from milvus project
1919
BasedOnStyle: Google
2020
DerivePointerAlignment: false
21-
ColumnLimit: 120
21+
ColumnLimit: 80
2222
IndentWidth: 4
2323
AccessModifierOffset: -3
2424
AlwaysBreakAfterReturnType: All
@@ -28,7 +28,9 @@ AllowShortIfStatementsOnASingleLine: false
2828
AlignTrailingComments: true
2929

3030
# Appended Options
31-
SortIncludes: false
31+
SortIncludes: false
3232
Standard: Latest
3333
AlignAfterOpenBracket: Align
3434
BinPackParameters: false
35+
BinPackArguments: false
36+
ReflowComments: false

internal/core/src/common/BitsetView.h

+11-4
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,17 @@ class BitsetView : public knowhere::BitsetView {
3232
BitsetView() = default;
3333
~BitsetView() = default;
3434

35-
BitsetView(const std::nullptr_t value) : knowhere::BitsetView(value) { // NOLINT
35+
BitsetView(const std::nullptr_t value)
36+
: knowhere::BitsetView(value) { // NOLINT
3637
}
3738

38-
BitsetView(const uint8_t* data, size_t num_bits) : knowhere::BitsetView(data, num_bits) { // NOLINT
39+
BitsetView(const uint8_t* data, size_t num_bits)
40+
: knowhere::BitsetView(data, num_bits) { // NOLINT
3941
}
4042

4143
BitsetView(const BitsetType& bitset) // NOLINT
42-
: BitsetView((uint8_t*)boost_ext::get_data(bitset), size_t(bitset.size())) {
44+
: BitsetView((uint8_t*)boost_ext::get_data(bitset),
45+
size_t(bitset.size())) {
4346
}
4447

4548
BitsetView(const BitsetTypePtr& bitset_ptr) { // NOLINT
@@ -56,7 +59,11 @@ class BitsetView : public knowhere::BitsetView {
5659

5760
AssertInfo((offset & 0x7) == 0, "offset is not divisible by 8");
5861
AssertInfo(offset + size <= this->size(),
59-
fmt::format("index out of range, offset={}, size={}, bitset.size={}", offset, size, this->size()));
62+
fmt::format(
63+
"index out of range, offset={}, size={}, bitset.size={}",
64+
offset,
65+
size,
66+
this->size()));
6067
return {data() + (offset >> 3), size};
6168
}
6269
};

internal/core/src/common/CDataType.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
namespace milvus {
1818

19-
template <typename T, typename = std::enable_if_t<std::is_fundamental_v<T> || std::is_same_v<T, std::string>>>
19+
template <typename T,
20+
typename = std::enable_if_t<std::is_fundamental_v<T> ||
21+
std::is_same_v<T, std::string>>>
2022
inline CDataType
2123
GetDType() {
2224
return None;

internal/core/src/common/Common.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ int cpu_num = DEFAULT_CPU_NUM;
2626
void
2727
SetIndexSliceSize(const int64_t size) {
2828
index_file_slice_size = size;
29-
LOG_SEGCORE_DEBUG_ << "set config index slice size: " << index_file_slice_size;
29+
LOG_SEGCORE_DEBUG_ << "set config index slice size: "
30+
<< index_file_slice_size;
3031
}
3132

3233
void
3334
SetThreadCoreCoefficient(const int64_t coefficient) {
3435
thread_core_coefficient = coefficient;
35-
LOG_SEGCORE_DEBUG_ << "set thread pool core coefficient: " << thread_core_coefficient;
36+
LOG_SEGCORE_DEBUG_ << "set thread pool core coefficient: "
37+
<< thread_core_coefficient;
3638
}
3739

3840
void

internal/core/src/common/FieldMeta.h

+25-9
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,17 @@ datatype_name(DataType data_type) {
8181
return "vector_binary";
8282
}
8383
default: {
84-
auto err_msg = "Unsupported DataType(" + std::to_string((int)data_type) + ")";
84+
auto err_msg =
85+
"Unsupported DataType(" + std::to_string((int)data_type) + ")";
8586
PanicInfo(err_msg);
8687
}
8788
}
8889
}
8990

9091
inline bool
9192
datatype_is_vector(DataType datatype) {
92-
return datatype == DataType::VECTOR_BINARY || datatype == DataType::VECTOR_FLOAT;
93+
return datatype == DataType::VECTOR_BINARY ||
94+
datatype == DataType::VECTOR_FLOAT;
9395
}
9496

9597
inline bool
@@ -148,25 +150,39 @@ class FieldMeta {
148150
FieldMeta&
149151
operator=(FieldMeta&&) = default;
150152

151-
FieldMeta(const FieldName& name, FieldId id, DataType type) : name_(name), id_(id), type_(type) {
153+
FieldMeta(const FieldName& name, FieldId id, DataType type)
154+
: name_(name), id_(id), type_(type) {
152155
Assert(!is_vector());
153156
}
154157

155-
FieldMeta(const FieldName& name, FieldId id, DataType type, int64_t max_length)
156-
: name_(name), id_(id), type_(type), string_info_(StringInfo{max_length}) {
158+
FieldMeta(const FieldName& name,
159+
FieldId id,
160+
DataType type,
161+
int64_t max_length)
162+
: name_(name),
163+
id_(id),
164+
type_(type),
165+
string_info_(StringInfo{max_length}) {
157166
Assert(is_string());
158167
}
159168

160-
FieldMeta(
161-
const FieldName& name, FieldId id, DataType type, int64_t dim, std::optional<knowhere::MetricType> metric_type)
162-
: name_(name), id_(id), type_(type), vector_info_(VectorInfo{dim, metric_type}) {
169+
FieldMeta(const FieldName& name,
170+
FieldId id,
171+
DataType type,
172+
int64_t dim,
173+
std::optional<knowhere::MetricType> metric_type)
174+
: name_(name),
175+
id_(id),
176+
type_(type),
177+
vector_info_(VectorInfo{dim, metric_type}) {
163178
Assert(is_vector());
164179
}
165180

166181
bool
167182
is_vector() const {
168183
Assert(type_ != DataType::NONE);
169-
return type_ == DataType::VECTOR_BINARY || type_ == DataType::VECTOR_FLOAT;
184+
return type_ == DataType::VECTOR_BINARY ||
185+
type_ == DataType::VECTOR_FLOAT;
170186
}
171187

172188
bool

internal/core/src/common/QueryResult.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ struct SearchResult {
3838
if (topk_per_nq_prefix_sum_.empty()) {
3939
return 0;
4040
}
41-
AssertInfo(topk_per_nq_prefix_sum_.size() == total_nq_ + 1, "wrong topk_per_nq_prefix_sum_ size");
41+
AssertInfo(topk_per_nq_prefix_sum_.size() == total_nq_ + 1,
42+
"wrong topk_per_nq_prefix_sum_ size");
4243
return topk_per_nq_prefix_sum_[total_nq_];
4344
}
4445

internal/core/src/common/RangeSearchHelper.cpp

+17-9
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,28 @@ namespace {
2020
using ResultPair = std::pair<float, int64_t>;
2121
}
2222
DatasetPtr
23-
SortRangeSearchResult(DatasetPtr data_set, int64_t topk, int64_t nq, std::string metric_type) {
23+
SortRangeSearchResult(DatasetPtr data_set,
24+
int64_t topk,
25+
int64_t nq,
26+
std::string metric_type) {
2427
/**
25-
* nq: number of querys;
26-
* lims: the size of lims is nq + 1, lims[i+1] - lims[i] refers to the size of RangeSearch result querys[i]
27-
* for example, the nq is 5. In the seleted range,
28+
* nq: number of queries;
29+
* lims: the size of lims is nq + 1, lims[i+1] - lims[i] refers to the size of RangeSearch result queries[i]
30+
* for example, the nq is 5. In the selected range,
2831
* the size of RangeSearch result for each nq is [1, 2, 3, 4, 5],
2932
* the lims will be [0, 1, 3, 6, 10, 15];
3033
* ids: the size of ids is lim[nq],
3134
* { i(0,0), i(0,1), …, i(0,k0-1),
3235
* i(1,0), i(1,1), …, i(1,k1-1),
3336
* …,
3437
* i(n-1,0), i(n-1,1), …, i(n-1,kn-1)},
35-
* i(0,0), i(0,1), …, i(0,k0-1) means the ids of RangeSearch result querys[0], k0 equals lim[1] - lim[0];
38+
* i(0,0), i(0,1), …, i(0,k0-1) means the ids of RangeSearch result queries[0], k0 equals lim[1] - lim[0];
3639
* dist: the size of ids is lim[nq],
3740
* { d(0,0), d(0,1), …, d(0,k0-1),
3841
* d(1,0), d(1,1), …, d(1,k1-1),
3942
* …,
4043
* d(n-1,0), d(n-1,1), …, d(n-1,kn-1)},
41-
* d(0,0), d(0,1), …, d(0,k0-1) means the distances of RangeSearch result querys[0], k0 equals lim[1] - lim[0];
44+
* d(0,0), d(0,1), …, d(0,k0-1) means the distances of RangeSearch result queries[0], k0 equals lim[1] - lim[0];
4245
*/
4346
auto lims = GetDatasetLims(data_set);
4447
auto id = GetDatasetIDs(data_set);
@@ -65,11 +68,14 @@ SortRangeSearchResult(DatasetPtr data_set, int64_t topk, int64_t nq, std::string
6568
* |------------+---------------| max_heap ascending_order
6669
*
6770
*/
68-
std::function<bool(const ResultPair&, const ResultPair&)> cmp = std::less<std::pair<float, int64_t>>();
71+
std::function<bool(const ResultPair&, const ResultPair&)> cmp =
72+
std::less<std::pair<float, int64_t>>();
6973
if (IsMetricType(metric_type, knowhere::metric::IP)) {
7074
cmp = std::greater<std::pair<float, int64_t>>();
7175
}
72-
std::priority_queue<std::pair<float, int64_t>, std::vector<std::pair<float, int64_t>>, decltype(cmp)>
76+
std::priority_queue<std::pair<float, int64_t>,
77+
std::vector<std::pair<float, int64_t>>,
78+
decltype(cmp)>
7379
sub_result(cmp);
7480

7581
for (int j = lims[i]; j < lims[i + 1]; j++) {
@@ -94,7 +100,9 @@ SortRangeSearchResult(DatasetPtr data_set, int64_t topk, int64_t nq, std::string
94100
}
95101

96102
void
97-
CheckRangeSearchParam(float radius, float range_filter, std::string metric_type) {
103+
CheckRangeSearchParam(float radius,
104+
float range_filter,
105+
std::string metric_type) {
98106
/*
99107
* IP: 1.0 range_filter radius
100108
* |------------+---------------| min_heap descending_order

internal/core/src/common/RangeSearchHelper.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@
1717
namespace milvus {
1818

1919
DatasetPtr
20-
SortRangeSearchResult(DatasetPtr data_set, int64_t topk, int64_t nq, std::string metric_type);
20+
SortRangeSearchResult(DatasetPtr data_set,
21+
int64_t topk,
22+
int64_t nq,
23+
std::string metric_type);
2124

2225
void
23-
CheckRangeSearchParam(float radius, float range_filter, std::string metric_type);
26+
CheckRangeSearchParam(float radius,
27+
float range_filter,
28+
std::string metric_type);
2429
} // namespace milvus

internal/core/src/common/Schema.cpp

+20-9
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ namespace milvus {
2626

2727
using std::string;
2828
static std::map<string, string>
29-
RepeatedKeyValToMap(const google::protobuf::RepeatedPtrField<proto::common::KeyValuePair>& kvs) {
29+
RepeatedKeyValToMap(
30+
const google::protobuf::RepeatedPtrField<proto::common::KeyValuePair>&
31+
kvs) {
3032
std::map<string, string> mapping;
3133
for (auto& kv : kvs) {
32-
AssertInfo(!mapping.count(kv.key()), "repeat key(" + kv.key() + ") in protobuf");
34+
AssertInfo(!mapping.count(kv.key()),
35+
"repeat key(" + kv.key() + ") in protobuf");
3336
mapping.emplace(kv.key(), kv.value());
3437
}
3538
return mapping;
@@ -42,15 +45,18 @@ Schema::ParseFrom(const milvus::proto::schema::CollectionSchema& schema_proto) {
4245

4346
// NOTE: only two system
4447

45-
for (const milvus::proto::schema::FieldSchema& child : schema_proto.fields()) {
48+
for (const milvus::proto::schema::FieldSchema& child :
49+
schema_proto.fields()) {
4650
auto field_id = FieldId(child.fieldid());
4751
auto name = FieldName(child.name());
4852

4953
if (field_id.get() < 100) {
5054
// system field id
51-
auto is_system = SystemProperty::Instance().SystemFieldVerify(name, field_id);
55+
auto is_system =
56+
SystemProperty::Instance().SystemFieldVerify(name, field_id);
5257
AssertInfo(is_system,
53-
"invalid system type: name(" + name.get() + "), id(" + std::to_string(field_id.get()) + ")");
58+
"invalid system type: name(" + name.get() + "), id(" +
59+
std::to_string(field_id.get()) + ")");
5460
continue;
5561
}
5662

@@ -71,23 +77,28 @@ Schema::ParseFrom(const milvus::proto::schema::CollectionSchema& schema_proto) {
7177
} else if (datatype_is_string(data_type)) {
7278
auto type_map = RepeatedKeyValToMap(child.type_params());
7379
AssertInfo(type_map.count(MAX_LENGTH), "max_length not found");
74-
auto max_len = boost::lexical_cast<int64_t>(type_map.at(MAX_LENGTH));
80+
auto max_len =
81+
boost::lexical_cast<int64_t>(type_map.at(MAX_LENGTH));
7582
schema->AddField(name, field_id, data_type, max_len);
7683
} else {
7784
schema->AddField(name, field_id, data_type);
7885
}
7986

8087
if (child.is_primary_key()) {
81-
AssertInfo(!schema->get_primary_field_id().has_value(), "repetitive primary key");
88+
AssertInfo(!schema->get_primary_field_id().has_value(),
89+
"repetitive primary key");
8290
schema->set_primary_field_id(field_id);
8391
}
8492
}
8593

86-
AssertInfo(schema->get_primary_field_id().has_value(), "primary key should be specified");
94+
AssertInfo(schema->get_primary_field_id().has_value(),
95+
"primary key should be specified");
8796

8897
return schema;
8998
}
9099

91-
const FieldMeta FieldMeta::RowIdMeta(FieldName("RowID"), RowFieldID, DataType::INT64);
100+
const FieldMeta FieldMeta::RowIdMeta(FieldName("RowID"),
101+
RowFieldID,
102+
DataType::INT64);
92103

93104
} // namespace milvus

internal/core/src/common/Schema.h

+10-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ class Schema {
4949
std::optional<knowhere::MetricType> metric_type) {
5050
auto field_id = FieldId(debug_id);
5151
debug_id++;
52-
auto field_meta = FieldMeta(FieldName(name), field_id, data_type, dim, metric_type);
52+
auto field_meta =
53+
FieldMeta(FieldName(name), field_id, data_type, dim, metric_type);
5354
this->AddField(std::move(field_meta));
5455
return field_id;
5556
}
@@ -63,7 +64,10 @@ class Schema {
6364

6465
// string type
6566
void
66-
AddField(const FieldName& name, const FieldId id, DataType data_type, int64_t max_length) {
67+
AddField(const FieldName& name,
68+
const FieldId id,
69+
DataType data_type,
70+
int64_t max_length) {
6771
auto field_meta = FieldMeta(name, id, data_type, max_length);
6872
this->AddField(std::move(field_meta));
6973
}
@@ -103,7 +107,8 @@ class Schema {
103107
operator[](FieldId field_id) const {
104108
Assert(field_id.get() >= 0);
105109
AssertInfo(fields_.find(field_id) != fields_.end(),
106-
"Cannot find field with field_id: " + std::to_string(field_id.get()));
110+
"Cannot find field with field_id: " +
111+
std::to_string(field_id.get()));
107112
return fields_.at(field_id);
108113
}
109114

@@ -131,7 +136,8 @@ class Schema {
131136
const FieldMeta&
132137
operator[](const FieldName& field_name) const {
133138
auto id_iter = name_ids_.find(field_name);
134-
AssertInfo(id_iter != name_ids_.end(), "Cannot find field with field_name: " + field_name.get());
139+
AssertInfo(id_iter != name_ids_.end(),
140+
"Cannot find field with field_name: " + field_name.get());
135141
return fields_.at(id_iter->second);
136142
}
137143

0 commit comments

Comments
 (0)