Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ Checks: >
-readability-identifier-length,
-readability-magic-numbers,
-readability-function-cognitive-complexity, # enable after fix all
-readability-redundant-access-specifiers
-readability-redundant-access-specifiers,
-readability-avoid-nested-conditional-operator


HeaderFilterRegex: ''
WarningsAsErrors: "*"
AnalyzeTemporaryDtors: true
# AnalyzeTemporaryDtors: true

CheckOptions:
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/brute_force.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BruteForce : public InnerIndexInterface {
explicit BruteForce(const BruteForceParameterPtr& param, const IndexCommonParam& common_param);

explicit BruteForce(const ParamPtr& param, const IndexCommonParam& common_param)
: BruteForce(std::dynamic_pointer_cast<BruteForceParameter>(param), common_param){};
: BruteForce(std::dynamic_pointer_cast<BruteForceParameter>(param), common_param) {};

~BruteForce() override = default;

Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/hgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ HGraph::build_by_odescent(const DatasetPtr& data) {
if (level >= 0) {
if (level >= static_cast<int>(route_graph_ids.size()) || route_graph_ids.empty()) {
for (auto k = static_cast<int>(route_graph_ids.size()); k <= level; ++k) {
route_graph_ids.emplace_back(Vector<InnerIdType>(allocator_));
route_graph_ids.emplace_back(allocator_);
}
entry_point_id_ = inner_id;
}
Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/hgraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class HGraph : public InnerIndexInterface {
HGraph(const HGraphParameterPtr& param, const IndexCommonParam& common_param);

HGraph(const ParamPtr& param, const IndexCommonParam& common_param)
: HGraph(std::dynamic_pointer_cast<HGraphParameter>(param), common_param){};
: HGraph(std::dynamic_pointer_cast<HGraphParameter>(param), common_param) {};

~HGraph() override = default;

Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/hnswlib/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Checks: >

HeaderFilterRegex: ''
WarningsAsErrors: "*"
AnalyzeTemporaryDtors: true
# AnalyzeTemporaryDtors: true

CheckOptions:
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
2 changes: 1 addition & 1 deletion src/algorithm/inner_index_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class InnerIndexInterface {

public:
virtual void
Train(const DatasetPtr& base){};
Train(const DatasetPtr& base) {};

virtual std::vector<int64_t>
Build(const DatasetPtr& base);
Expand Down
3 changes: 1 addition & 2 deletions src/algorithm/ivf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,8 +939,7 @@ IVF::fill_location_map() {
if (ids[j] >= this->total_elements_ * buckets_per_data_) {
throw VsagException(ErrorType::INTERNAL_ERROR, "invalid inner_id");
}
this->location_map_[ids[j]] =
(static_cast<uint64_t>(i) << LOCATION_SPLIT_BIT) | static_cast<uint64_t>(j);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Removing static_cast for j may introduce type mismatch if j is not uint64_t.

Please verify that j is always a uint64_t, or retain the cast to prevent type issues.

this->location_map_[ids[j]] = (static_cast<uint64_t>(i) << LOCATION_SPLIT_BIT) | j;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/ivf.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class IVF : public InnerIndexInterface {
explicit IVF(const IVFParameterPtr& param, const IndexCommonParam& common_param);

explicit IVF(const ParamPtr& param, const IndexCommonParam& common_param)
: IVF(std::dynamic_pointer_cast<IVFParameter>(param), common_param){};
: IVF(std::dynamic_pointer_cast<IVFParameter>(param), common_param) {};

~IVF() override = default;

Expand Down
4 changes: 2 additions & 2 deletions src/algorithm/ivf_parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ IVFParameter::FromJson(const JsonType& json) {

if (this->ivf_partition_strategy_parameter->partition_strategy_type ==
IVFPartitionStrategyType::GNO_IMI) {
this->bucket_param->buckets_count = static_cast<BucketIdType>(
this->bucket_param->buckets_count = (static_cast<int64_t>(
this->ivf_partition_strategy_parameter->gnoimi_param->first_order_buckets_count *
this->ivf_partition_strategy_parameter->gnoimi_param->second_order_buckets_count);
this->ivf_partition_strategy_parameter->gnoimi_param->second_order_buckets_count));
}

if (json.contains(BUCKET_PER_DATA_KEY)) {
Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/ivf_partition/ivf_partition_strategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class IVFPartitionStrategy {
thread_pool_(common_param.thread_pool_),
bucket_count_(bucket_count),
dim_(common_param.dim_),
metric_type_(common_param.metric_){};
metric_type_(common_param.metric_) {};

virtual void
Train(const DatasetPtr dataset) = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/pyramid.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class Pyramid : public InnerIndexInterface {
}

explicit Pyramid(const ParamPtr& param, const IndexCommonParam& common_param)
: Pyramid(std::dynamic_pointer_cast<PyramidParameters>(param), common_param){};
: Pyramid(std::dynamic_pointer_cast<PyramidParameters>(param), common_param) {};

std::string
GetName() const override {
Expand Down
4 changes: 2 additions & 2 deletions src/algorithm/sindi/sindi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ SINDI::search_impl(const SparseTermComputerPtr& computer,
if constexpr (mode == KNN_SEARCH) {
// fill up to k
while (heap.size() < k) {
heap.push(
{std::numeric_limits<float>::max(), 0}); // TODO(ZXY): replace with random points
heap.emplace(std::numeric_limits<float>::max(),
0); // TODO(ZXY): replace with random points
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/sindi/sindi.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SINDI : public InnerIndexInterface {
explicit SINDI(const SINDIParameterPtr& param, const IndexCommonParam& common_param);

SINDI(const ParamPtr& param, const IndexCommonParam& common_param)
: SINDI(std::dynamic_pointer_cast<SINDIParameter>(param), common_param){};
: SINDI(std::dynamic_pointer_cast<SINDIParameter>(param), common_param) {};

~SINDI() = default;

Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/sparse_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SparseIndex : public InnerIndexInterface {
}

SparseIndex(const ParamPtr& param, const IndexCommonParam& common_param)
: SparseIndex(std::dynamic_pointer_cast<SparseIndexParameters>(param), common_param){};
: SparseIndex(std::dynamic_pointer_cast<SparseIndexParameters>(param), common_param) {};

~SparseIndex() override {
for (auto& data : datas_) {
Expand Down
4 changes: 2 additions & 2 deletions src/attr/executor/executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Executor {
: expr_(expression),
attr_index_(attr_index),
allocator_(allocator),
bitset_type_(attr_index->GetBitsetType()){};
bitset_type_(attr_index->GetBitsetType()) {};

virtual ~Executor() {
if (this->own_bitset_) {
Expand All @@ -54,7 +54,7 @@ class Executor {
};

virtual void
Init(){};
Init() {};

virtual Filter*
Run(BucketIdType bucket_id) = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/attr/expression_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ string_view_split(std::string_view str, char delim) {
result.emplace_back(str.substr(start));
return result;
}
FCExpressionVisitor::FCExpressionVisitor(AttrTypeSchema* schema) : schema_(schema){};
FCExpressionVisitor::FCExpressionVisitor(AttrTypeSchema* schema) : schema_(schema) {};

std::any
FCExpressionVisitor::visitFilter_condition(FCParser::Filter_conditionContext* ctx) {
Expand Down
2 changes: 1 addition & 1 deletion src/data_cell/attribute_bucket_inverted_datacell.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AttributeBucketInvertedDataCell : public AttributeInvertedInterface {
public:
AttributeBucketInvertedDataCell(
Allocator* allocator, ComputableBitsetType bitset_type = ComputableBitsetType::FastBitset)
: AttributeInvertedInterface(allocator, bitset_type), field_2_value_map_(allocator){};
: AttributeInvertedInterface(allocator, bitset_type), field_2_value_map_(allocator) {};

~AttributeBucketInvertedDataCell() override = default;

Expand Down
2 changes: 1 addition & 1 deletion src/data_cell/attribute_inverted_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AttributeInvertedInterface {

public:
AttributeInvertedInterface(Allocator* allocator, ComputableBitsetType bitset_type)
: allocator_(allocator), field_type_map_(allocator), bitset_type_(bitset_type){};
: allocator_(allocator), field_type_map_(allocator), bitset_type_(bitset_type) {};

virtual ~AttributeInvertedInterface() = default;

Expand Down
2 changes: 1 addition & 1 deletion src/data_cell/bucket_datacell_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace vsag {
class BucketInterfaceTest {
public:
BucketInterfaceTest(BucketInterfacePtr bucket, MetricType metric)
: bucket_(std::move(bucket)), metric_(metric){};
: bucket_(std::move(bucket)), metric_(metric) {};

void
BasicTest(int64_t dim, uint64_t base_count, float error = 1e-5f);
Expand Down
4 changes: 2 additions & 2 deletions src/data_cell/bucket_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ class BucketInterface {
}

virtual void
Package(){};
Package() {};

virtual void
Unpack(){};
Unpack() {};

public:
BucketIdType bucket_count_{0};
Expand Down
4 changes: 2 additions & 2 deletions src/data_cell/extra_info_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ class ExtraInfoInterface {
InMemory() const = 0;

virtual void
EnableForceInMemory(){};
EnableForceInMemory() {};

virtual void
DisableForceInMemory(){};
DisableForceInMemory() {};

public:
InnerIdType total_count_{0};
Expand Down
2 changes: 1 addition & 1 deletion src/data_cell/flatten_interface_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace vsag {
class FlattenInterfaceTest {
public:
FlattenInterfaceTest(FlattenInterfacePtr flatten, MetricType metric)
: flatten_(flatten), metric_(metric){};
: flatten_(flatten), metric_(metric) {};

void
BasicTest(int64_t dim, uint64_t base_count, float error = 1e-5f);
Expand Down
2 changes: 1 addition & 1 deletion src/data_cell/graph_interface_parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GraphInterfaceParameter : public Parameter {

protected:
explicit GraphInterfaceParameter(GraphStorageTypes graph_type)
: graph_storage_type_(graph_type){};
: graph_storage_type_(graph_type) {};
};

} // namespace vsag
2 changes: 1 addition & 1 deletion src/data_cell/sparse_graph_datacell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ SparseGraphDataCell::Deserialize(StreamReader& reader) {
}

void
SparseGraphDataCell::Resize(InnerIdType new_size){};
SparseGraphDataCell::Resize(InnerIdType new_size) {};

void
SparseGraphDataCell::DeleteNeighborsById(vsag::InnerIdType id) {
Expand Down
2 changes: 1 addition & 1 deletion src/data_cell/sparse_vector_datacell.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class SparseVectorDataCell : public FlattenInterface {
}

void
Prefetch(InnerIdType id) override{};
Prefetch(InnerIdType id) override {};

void
ExportModel(const FlattenInterfacePtr& other) const override {
Expand Down
2 changes: 1 addition & 1 deletion src/impl/allocator/safe_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SafeAllocator : public Allocator {
}

public:
explicit SafeAllocator(Allocator* raw_allocator) : SafeAllocator(raw_allocator, false){};
explicit SafeAllocator(Allocator* raw_allocator) : SafeAllocator(raw_allocator, false) {};

explicit SafeAllocator(Allocator* raw_allocator, bool owned)
: raw_allocator_(raw_allocator), owned_(owned) {
Expand Down
2 changes: 1 addition & 1 deletion src/impl/basic_searcher_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using namespace vsag;

class AdaptGraphDataCell : public GraphInterface {
public:
AdaptGraphDataCell(std::shared_ptr<hnswlib::HierarchicalNSW> alg_hnsw) : alg_hnsw_(alg_hnsw){};
AdaptGraphDataCell(std::shared_ptr<hnswlib::HierarchicalNSW> alg_hnsw) : alg_hnsw_(alg_hnsw) {};

void
InsertNeighborsById(InnerIdType id, const Vector<InnerIdType>& neighbor_ids) override {
Expand Down
2 changes: 1 addition & 1 deletion src/impl/bitset/fast_bitset.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace vsag {
class FastBitset : public ComputableBitset {
public:
explicit FastBitset(Allocator* allocator)
: ComputableBitset(), data_(nullptr), size_(0), capacity_(0){};
: ComputableBitset(), data_(nullptr), size_(0), capacity_(0) {};

~FastBitset() override {
delete[] data_;
Expand Down
2 changes: 1 addition & 1 deletion src/impl/bitset/sparse_bitset.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SparseBitset : public ComputableBitset {

~SparseBitset() override = default;

explicit SparseBitset(Allocator* allocator) : SparseBitset(){};
explicit SparseBitset(Allocator* allocator) : SparseBitset() {};

SparseBitset(const SparseBitset&) = delete;
SparseBitset&
Expand Down
6 changes: 3 additions & 3 deletions src/impl/filter/black_list_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ namespace vsag {
class BlackListFilter : public Filter {
public:
explicit BlackListFilter(const IdFilterFuncType& fallback_func)
: fallback_func_(fallback_func), is_bitset_filter_(false), bitset_(nullptr){};
: fallback_func_(fallback_func), is_bitset_filter_(false), bitset_(nullptr) {};

explicit BlackListFilter(const BitsetPtr& bitset)
: bitset_(bitset.get()), is_bitset_filter_(true){};
: bitset_(bitset.get()), is_bitset_filter_(true) {};

explicit BlackListFilter(const Bitset* bitset) : bitset_(bitset), is_bitset_filter_(true){};
explicit BlackListFilter(const Bitset* bitset) : bitset_(bitset), is_bitset_filter_(true) {};

bool
CheckValid(int64_t id) const override;
Expand Down
2 changes: 1 addition & 1 deletion src/impl/filter/extrainfo_wrapper_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace vsag {
class ExtraInfoWrapperFilter : public Filter {
public:
ExtraInfoWrapperFilter(const FilterPtr filter_impl, const ExtraInfoInterfacePtr& extra_infos)
: filter_impl_(filter_impl), extra_infos_(extra_infos){};
: filter_impl_(filter_impl), extra_infos_(extra_infos) {};

[[nodiscard]] bool
CheckValid(int64_t inner_id) const override;
Expand Down
2 changes: 1 addition & 1 deletion src/impl/filter/inner_id_wrapper_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace vsag {
class InnerIdWrapperFilter : public Filter {
public:
InnerIdWrapperFilter(const FilterPtr filter_impl, const LabelTable& label_table)
: filter_impl_(filter_impl), label_table_(label_table){};
: filter_impl_(filter_impl), label_table_(label_table) {};

[[nodiscard]] bool
CheckValid(int64_t inner_id) const override {
Expand Down
6 changes: 3 additions & 3 deletions src/impl/filter/white_list_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ namespace vsag {
class WhiteListFilter : public Filter {
public:
explicit WhiteListFilter(const IdFilterFuncType& fallback_func)
: fallback_func_(fallback_func), is_bitset_filter_(false), bitset_(nullptr){};
: fallback_func_(fallback_func), is_bitset_filter_(false), bitset_(nullptr) {};

explicit WhiteListFilter(const BitsetPtr& bitset)
: bitset_(bitset.get()), is_bitset_filter_(true){};
: bitset_(bitset.get()), is_bitset_filter_(true) {};

explicit WhiteListFilter(const Bitset* bitset) : bitset_(bitset), is_bitset_filter_(true){};
explicit WhiteListFilter(const Bitset* bitset) : bitset_(bitset), is_bitset_filter_(true) {};

bool
CheckValid(int64_t id) const override;
Expand Down
6 changes: 3 additions & 3 deletions src/impl/heap/distance_heap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ DistanceHeap::MakeInstanceBySize<false, true>(Allocator* allocator, int64_t max_
template DistHeapPtr
DistanceHeap::MakeInstanceBySize<false, false>(Allocator* allocator, int64_t max_size);

DistanceHeap::DistanceHeap(Allocator* allocator) : DistanceHeap(allocator, -1){};
DistanceHeap::DistanceHeap(Allocator* allocator) : DistanceHeap(allocator, -1) {};

DistanceHeap::DistanceHeap(Allocator* allocator, int64_t max_size)
: allocator_(allocator), max_size_(max_size){};
: allocator_(allocator), max_size_(max_size) {};

void
DistanceHeap::Push(const DistanceRecord& record) {
return this->Push(record.first, record.second);
this->Push(record.first, record.second);
}
} // namespace vsag
2 changes: 1 addition & 1 deletion src/impl/heap/memmove_heap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ MemmoveHeap<max_heap, fixed_size>::MemmoveHeap(Allocator* allocator, int64_t max
template <bool max_heap, bool fixed_size>
void
MemmoveHeap<max_heap, fixed_size>::Push(float dist, InnerIdType id) {
using CompareType = typename std::conditional<max_heap, CompareMax, CompareMin>::type;
using CompareType = std::conditional_t<max_heap, CompareMax, CompareMin>;
if constexpr (fixed_size) {
if (this->Size() < max_size_ or (dist < this->Top().first) == max_heap) {
DistanceRecord record = {dist, id};
Expand Down
2 changes: 1 addition & 1 deletion src/impl/odescent_graph_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ODescent::Build(const Vector<InnerIdType>& ids_sequence, const GraphInterfacePtr
"ODescent cannot build a graph with data_num less than 0");
}
if (data_num_ == 1) {
graph_.push_back(Linklist(allocator_));
graph_.emplace_back(allocator_);
return true;
}
Vector<std::mutex>(data_num_, allocator_).swap(points_lock_);
Expand Down
Loading
Loading