Skip to content

Commit

Permalink
enhance: eliminate compile warnings (part2) (milvus-io#38535)
Browse files Browse the repository at this point in the history
See milvus-io#38435

---------

Signed-off-by: Ted Xu <[email protected]>
  • Loading branch information
tedxu authored and NicoYuan1986 committed Dec 26, 2024
1 parent 6a2975f commit cc056e5
Show file tree
Hide file tree
Showing 24 changed files with 106 additions and 116 deletions.
1 change: 1 addition & 0 deletions internal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ if ( APPLE )
"-D_DARWIN_C_SOURCE"
"-Wno-gnu-zero-variadic-macro-arguments"
"-Wno-variadic-macros"
"-Wno-reorder-ctor"
"-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED=1"
)
endif ()
Expand Down
22 changes: 10 additions & 12 deletions internal/core/src/bitset/bitset.h
Original file line number Diff line number Diff line change
Expand Up @@ -987,22 +987,21 @@ class BitsetView : public BitsetBase<PolicyT,

using range_checker = RangeChecker<IsRangeCheckEnabled>;

BitsetView() {
}
BitsetView() = default;
BitsetView(const BitsetView&) = default;
BitsetView(BitsetView&&) = default;
BitsetView(BitsetView&&) noexcept = default;
BitsetView&
operator=(const BitsetView&) = default;
BitsetView&
operator=(BitsetView&&) = default;
operator=(BitsetView&&) noexcept = default;

template <typename ImplT, bool R>
BitsetView(BitsetBase<PolicyT, ImplT, R>& bitset)
explicit BitsetView(BitsetBase<PolicyT, ImplT, R>& bitset)
: Data{bitset.data()}, Size{bitset.size()}, Offset{bitset.offset()} {
}

BitsetView(void* data, const size_t size)
: Data{reinterpret_cast<data_type*>(data)}, Size{size}, Offset{0} {
: Data{reinterpret_cast<data_type*>(data)}, Size{size} {
}

BitsetView(void* data, const size_t offset, const size_t size)
Expand Down Expand Up @@ -1064,10 +1063,9 @@ class Bitset
using range_checker = RangeChecker<IsRangeCheckEnabled>;

// Allocate an empty one.
Bitset() {
}
Bitset() = default;
// Allocate the given number of bits.
Bitset(const size_t size)
explicit Bitset(const size_t size)
: Data(get_required_size_in_container_elements(size)), Size{size} {
}
// Allocate the given number of bits, initialize with a given value.
Expand All @@ -1079,16 +1077,16 @@ class Bitset
// Do not allow implicit copies (Rust style).
Bitset(const Bitset&) = delete;
// Allow default move.
Bitset(Bitset&&) = default;
Bitset(Bitset&&) noexcept = default;
// Do not allow implicit copies (Rust style).
Bitset&
operator=(const Bitset&) = delete;
// Allow default move.
Bitset&
operator=(Bitset&&) = default;
operator=(Bitset&&) noexcept = default;

template <typename C, bool R>
Bitset(const BitsetBase<PolicyT, C, R>& other) {
explicit Bitset(const BitsetBase<PolicyT, C, R>& other) {
Data = container_type(
get_required_size_in_container_elements(other.size()));
Size = other.size();
Expand Down
3 changes: 0 additions & 3 deletions internal/core/src/bitset/detail/element_wise.h
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,6 @@ struct ElementWiseBitsetPolicy {
const auto start_shift = get_shift(start + starting_idx);
const auto end_shift = get_shift(start + size);

size_t extra_offset = 0;

// same element?
if (start_element == end_element) {
const data_type existing_v = data[start_element];
Expand Down Expand Up @@ -764,7 +762,6 @@ struct ElementWiseBitsetPolicy {
}

start_element += 1;
extra_offset += data_bits - start_shift;
}

// process the middle
Expand Down
4 changes: 2 additions & 2 deletions internal/core/src/common/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ class ArrayView {
DataType element_type,
std::vector<uint64_t>&& element_offsets)
: size_(size),
element_type_(element_type),
offsets_(std::move(element_offsets)) {
offsets_(std::move(element_offsets)),
element_type_(element_type) {
data_ = data;
if (IsVariableDataType(element_type_)) {
length_ = offsets_.size();
Expand Down
2 changes: 1 addition & 1 deletion internal/core/src/common/BitsetView.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class BitsetView : public knowhere::BitsetView {
}

BitsetView(const BitsetType& bitset) // NOLINT
: BitsetView((uint8_t*)(bitset.data()), size_t(bitset.size())) {
: BitsetView((uint8_t*)(bitset.data()), bitset.size()) {
}

BitsetView(const BitsetTypePtr& bitset_ptr) { // NOLINT
Expand Down
2 changes: 1 addition & 1 deletion internal/core/src/common/Chunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Chunk {
public:
Chunk() = default;
Chunk(int64_t row_nums, char* data, uint64_t size, bool nullable)
: row_nums_(row_nums), data_(data), size_(size), nullable_(nullable) {
: data_(data), row_nums_(row_nums), size_(size), nullable_(nullable) {
if (nullable) {
valid_.reserve(row_nums);
for (int i = 0; i < row_nums; i++) {
Expand Down
2 changes: 1 addition & 1 deletion internal/core/src/common/ChunkWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ChunkWriterBase {
};

template <typename ArrowType, typename T>
class ChunkWriter : public ChunkWriterBase {
class ChunkWriter final : public ChunkWriterBase {
public:
ChunkWriter(int dim, bool nullable) : ChunkWriterBase(nullable), dim_(dim) {
}
Expand Down
4 changes: 2 additions & 2 deletions internal/core/src/common/FieldData.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ class FieldData<BinaryVector> : public FieldDataImpl<uint8_t, false> {
explicit FieldData(int64_t dim,
DataType data_type,
int64_t buffered_num_rows = 0)
: binary_dim_(dim),
FieldDataImpl(dim / 8, data_type, false, buffered_num_rows) {
: FieldDataImpl(dim / 8, data_type, false, buffered_num_rows),
binary_dim_(dim) {
Assert(dim % 8 == 0);
}

Expand Down
33 changes: 17 additions & 16 deletions internal/core/src/common/FieldMeta.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <optional>
#include <stdexcept>
#include <string>
#include <utility>

#include "common/EasyAssert.h"
#include "common/Types.h"
Expand All @@ -40,47 +41,47 @@ class FieldMeta {
FieldMeta&
operator=(FieldMeta&&) = default;

FieldMeta(const FieldName& name, FieldId id, DataType type, bool nullable)
: name_(name), id_(id), type_(type), nullable_(nullable) {
FieldMeta(FieldName name, FieldId id, DataType type, bool nullable)
: name_(std::move(name)), id_(id), type_(type), nullable_(nullable) {
Assert(!IsVectorDataType(type_));
}

FieldMeta(const FieldName& name,
FieldMeta(FieldName name,
FieldId id,
DataType type,
int64_t max_length,
bool nullable)
: name_(name),
: name_(std::move(name)),
id_(id),
type_(type),
string_info_(StringInfo{max_length}),
nullable_(nullable) {
nullable_(nullable),
string_info_(StringInfo{max_length}) {
Assert(IsStringDataType(type_));
}

FieldMeta(const FieldName& name,
FieldMeta(FieldName name,
FieldId id,
DataType type,
int64_t max_length,
bool nullable,
bool enable_match,
bool enable_analyzer,
std::map<std::string, std::string>& params)
: name_(name),
: name_(std::move(name)),
id_(id),
type_(type),
nullable_(nullable),
string_info_(StringInfo{
max_length, enable_match, enable_analyzer, std::move(params)}),
nullable_(nullable) {
max_length, enable_match, enable_analyzer, std::move(params)}) {
Assert(IsStringDataType(type_));
}

FieldMeta(const FieldName& name,
FieldMeta(FieldName name,
FieldId id,
DataType type,
DataType element_type,
bool nullable)
: name_(name),
: name_(std::move(name)),
id_(id),
type_(type),
element_type_(element_type),
Expand All @@ -90,17 +91,17 @@ class FieldMeta {

// pass in any value for dim for sparse vector is ok as it'll never be used:
// get_dim() not allowed to be invoked on a sparse vector field.
FieldMeta(const FieldName& name,
FieldMeta(FieldName name,
FieldId id,
DataType type,
int64_t dim,
std::optional<knowhere::MetricType> metric_type,
bool nullable)
: name_(name),
: name_(std::move(name)),
id_(id),
type_(type),
vector_info_(VectorInfo{dim, std::move(metric_type)}),
nullable_(nullable) {
nullable_(nullable),
vector_info_(VectorInfo{dim, std::move(metric_type)}) {
Assert(IsVectorDataType(type_));
Assert(!nullable);
}
Expand Down
2 changes: 1 addition & 1 deletion internal/core/src/common/Span.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class Span<
using embedded_type = typename VectorType::embedded_type;

Span(const embedded_type* data, int64_t row_count, int64_t element_sizeof)
: row_count_(row_count), data_(data), element_sizeof_(element_sizeof) {
: data_(data), row_count_(row_count), element_sizeof_(element_sizeof) {
}

explicit Span(const SpanBase& base)
Expand Down
3 changes: 3 additions & 0 deletions internal/core/src/common/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,9 @@ struct fmt::formatter<milvus::OpType> : formatter<string_view> {
case milvus::OpType::OpType_INT_MAX_SENTINEL_DO_NOT_USE_:
name = "OpType_INT_MAX_SENTINEL_DO_NOT_USE";
break;
case milvus::OpType::TextMatch:
name = "TextMatch";
break;
}
return formatter<string_view>::format(name, ctx);
}
Expand Down
5 changes: 2 additions & 3 deletions internal/core/src/exec/expression/EvalCtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ class EvalCtx {
}

explicit EvalCtx(ExecContext* exec_ctx, ExprSet* expr_set)
: exec_ctx_(exec_ctx), expr_set_(expr_set), offset_input_(nullptr) {
: exec_ctx_(exec_ctx), expr_set_(expr_set) {
}

explicit EvalCtx(ExecContext* exec_ctx)
: exec_ctx_(exec_ctx), expr_set_(nullptr), offset_input_(nullptr) {
explicit EvalCtx(ExecContext* exec_ctx) : exec_ctx_(exec_ctx) {
}

ExecContext*
Expand Down
6 changes: 3 additions & 3 deletions internal/core/src/mmap/ChunkedColumn.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ class ChunkedColumnBase : public ColumnBase {
public:
ChunkedColumnBase() = default;
// memory mode ctor
ChunkedColumnBase(const FieldMeta& field_meta) {
explicit ChunkedColumnBase(const FieldMeta& field_meta) {
if (field_meta.is_nullable()) {
nullable_ = true;
}
}

virtual ~ChunkedColumnBase(){};
virtual ~ChunkedColumnBase() = default;

virtual void
void
AppendBatch(const FieldDataPtr data) override {
PanicInfo(ErrorCode::Unsupported, "AppendBatch not supported");
}
Expand Down
14 changes: 6 additions & 8 deletions internal/core/src/mmap/Column.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class ColumnBase {
AppendBatch(const FieldDataPtr data) = 0;

virtual const char*
Data(int chunk_id = 0) const = 0;
Data(int chunk_id) const = 0;
};
class SingleChunkColumnBase : public ColumnBase {
public:
Expand Down Expand Up @@ -183,8 +183,6 @@ class SingleChunkColumnBase : public ColumnBase {
bool nullable)
: mcm_(mcm),
mmap_descriptor_(descriptor),
num_rows_(0),
data_size_(0),
data_cap_size_(reserve),
mapping_type_(MappingType::MAP_WITH_MANAGER),
nullable_(nullable) {
Expand Down Expand Up @@ -267,7 +265,7 @@ class SingleChunkColumnBase : public ColumnBase {

// Data() points at an addr that contains the elements
virtual const char*
Data(int chunk_id = 0) const override {
Data(int chunk_id) const override {
return data_;
}

Expand Down Expand Up @@ -297,7 +295,7 @@ class SingleChunkColumnBase : public ColumnBase {

// returns the number of bytes used to store actual data
size_t
DataByteSize() const {
DataByteSize() const override {
return data_size_;
}

Expand Down Expand Up @@ -330,7 +328,7 @@ class SingleChunkColumnBase : public ColumnBase {
}

virtual void
AppendBatch(const FieldDataPtr data) {
AppendBatch(const FieldDataPtr data) override {
size_t required_size = data_size_ + data->DataSize();
if (required_size > data_cap_size_) {
ExpandData(required_size * 2);
Expand Down Expand Up @@ -584,7 +582,7 @@ class SingleChunkSparseFloatColumn : public SingleChunkColumnBase {

// returned pointer points at a list of knowhere::sparse::SparseRow<float>
const char*
Data(int chunk_id = 0) const override {
Data(int chunk_id) const override {
return static_cast<const char*>(static_cast<const void*>(vec_.data()));
}

Expand Down Expand Up @@ -705,7 +703,7 @@ class SingleChunkVariableColumn : public SingleChunkColumnBase {
}

std::pair<std::vector<std::string_view>, FixedVector<bool>>
ViewsByOffsets(const FixedVector<int32_t>& offsets) const {
ViewsByOffsets(const FixedVector<int32_t>& offsets) const override {
std::vector<std::string_view> res;
FixedVector<bool> valid;
res.reserve(offsets.size());
Expand Down
8 changes: 4 additions & 4 deletions internal/core/src/segcore/ChunkedSegmentSealedImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ class ChunkedSegmentSealedImpl : public SegmentSealed {
get_schema() const override;

std::vector<SegOffset>
search_pk(const PkType& pk, Timestamp timestamp) const;
search_pk(const PkType& pk, Timestamp timestamp) const override;

std::vector<SegOffset>
search_pk(const PkType& pk, int64_t insert_barrier) const;
search_pk(const PkType& pk, int64_t insert_barrier) const override;

template <typename Condition>
std::vector<SegOffset>
Expand Down Expand Up @@ -201,7 +201,7 @@ class ChunkedSegmentSealedImpl : public SegmentSealed {
is_mmap_field(FieldId id) const override;

void
ClearData();
ClearData() override;

protected:
// blob and row_count
Expand Down Expand Up @@ -340,7 +340,7 @@ class ChunkedSegmentSealedImpl : public SegmentSealed {
void
LoadScalarIndex(const LoadIndexInfo& info);

virtual void
void
WarmupChunkCache(const FieldId field_id, bool mmap_enabled) override;

bool
Expand Down
Loading

0 comments on commit cc056e5

Please sign in to comment.