From 6c3d4b8c40b1837a431e802ebc47c0db5ecae3ec Mon Sep 17 00:00:00 2001 From: Ted Xu Date: Tue, 17 Dec 2024 19:18:31 +0800 Subject: [PATCH] enhance: eliminate compile warnings (part2) Signed-off-by: Ted Xu --- internal/core/CMakeLists.txt | 2 + internal/core/src/bitset/bitset.h | 22 +++++---- .../core/src/bitset/detail/element_wise.h | 3 -- internal/core/src/common/Array.h | 4 +- internal/core/src/common/BitsetView.h | 2 +- internal/core/src/common/Chunk.h | 2 +- internal/core/src/common/ChunkWriter.h | 2 +- internal/core/src/common/FieldData.h | 4 +- internal/core/src/common/FieldMeta.h | 33 +++++++------- internal/core/src/common/Span.h | 2 +- internal/core/src/common/Types.h | 3 ++ internal/core/src/exec/expression/EvalCtx.h | 5 +-- internal/core/src/mmap/ChunkedColumn.h | 7 +-- internal/core/src/mmap/Column.h | 14 +++--- .../src/segcore/ChunkedSegmentSealedImpl.h | 8 ++-- internal/core/src/segcore/ConcurrentVector.h | 22 ++++----- internal/core/src/segcore/DeletedRecord.h | 7 ++- internal/core/src/segcore/InsertRecord.h | 2 +- .../core/src/segcore/SegmentSealedImpl.cpp | 45 +++++++++---------- internal/core/src/segcore/SegmentSealedImpl.h | 8 ++-- internal/core/src/storage/DataCodec.cpp | 4 +- internal/core/src/storage/DataCodec.h | 7 +-- internal/core/src/storage/SafeQueue.h | 8 ++-- 23 files changed, 104 insertions(+), 112 deletions(-) diff --git a/internal/core/CMakeLists.txt b/internal/core/CMakeLists.txt index f86465758f435..ea31bbdb3571f 100644 --- a/internal/core/CMakeLists.txt +++ b/internal/core/CMakeLists.txt @@ -151,6 +151,8 @@ if ( APPLE ) "-Wall" "-Wno-gnu-zero-variadic-macro-arguments" "-Wno-variadic-macros" + "-Wno-reorder-ctor" + "-Wno-google-readability" "-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED=1" ) endif () diff --git a/internal/core/src/bitset/bitset.h b/internal/core/src/bitset/bitset.h index e5a82ac263305..0e739dc6a310c 100644 --- a/internal/core/src/bitset/bitset.h +++ b/internal/core/src/bitset/bitset.h @@ -987,22 +987,21 @@ class BitsetView : public BitsetBase; - 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 - BitsetView(BitsetBase& bitset) + explicit BitsetView(BitsetBase& bitset) : Data{bitset.data()}, Size{bitset.size()}, Offset{bitset.offset()} { } BitsetView(void* data, const size_t size) - : Data{reinterpret_cast(data)}, Size{size}, Offset{0} { + : Data{reinterpret_cast(data)}, Size{size} { } BitsetView(void* data, const size_t offset, const size_t size) @@ -1064,10 +1063,9 @@ class Bitset using range_checker = RangeChecker; // 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. @@ -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 - Bitset(const BitsetBase& other) { + explicit Bitset(const BitsetBase& other) { Data = container_type( get_required_size_in_container_elements(other.size())); Size = other.size(); diff --git a/internal/core/src/bitset/detail/element_wise.h b/internal/core/src/bitset/detail/element_wise.h index 3baf9c45affac..a738ef42e6a90 100644 --- a/internal/core/src/bitset/detail/element_wise.h +++ b/internal/core/src/bitset/detail/element_wise.h @@ -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]; @@ -764,7 +762,6 @@ struct ElementWiseBitsetPolicy { } start_element += 1; - extra_offset += data_bits - start_shift; } // process the middle diff --git a/internal/core/src/common/Array.h b/internal/core/src/common/Array.h index 705258c876c94..157fe78702818 100644 --- a/internal/core/src/common/Array.h +++ b/internal/core/src/common/Array.h @@ -449,8 +449,8 @@ class ArrayView { DataType element_type, std::vector&& 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(); diff --git a/internal/core/src/common/BitsetView.h b/internal/core/src/common/BitsetView.h index 3d1a75be6c92a..e7b298cdb33b5 100644 --- a/internal/core/src/common/BitsetView.h +++ b/internal/core/src/common/BitsetView.h @@ -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 diff --git a/internal/core/src/common/Chunk.h b/internal/core/src/common/Chunk.h index 7c26bdeba7710..8dd2e14039267 100644 --- a/internal/core/src/common/Chunk.h +++ b/internal/core/src/common/Chunk.h @@ -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++) { diff --git a/internal/core/src/common/ChunkWriter.h b/internal/core/src/common/ChunkWriter.h index 09225f44afa02..ab3769f39a51a 100644 --- a/internal/core/src/common/ChunkWriter.h +++ b/internal/core/src/common/ChunkWriter.h @@ -52,7 +52,7 @@ class ChunkWriterBase { }; template -class ChunkWriter : public ChunkWriterBase { +class ChunkWriter final : public ChunkWriterBase { public: ChunkWriter(int dim, bool nullable) : ChunkWriterBase(nullable), dim_(dim) { } diff --git a/internal/core/src/common/FieldData.h b/internal/core/src/common/FieldData.h index cdd2b735464a2..adec3f054b29d 100644 --- a/internal/core/src/common/FieldData.h +++ b/internal/core/src/common/FieldData.h @@ -97,8 +97,8 @@ class FieldData : public FieldDataImpl { 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); } diff --git a/internal/core/src/common/FieldMeta.h b/internal/core/src/common/FieldMeta.h index 92356b15724c2..e8b99341e39aa 100644 --- a/internal/core/src/common/FieldMeta.h +++ b/internal/core/src/common/FieldMeta.h @@ -19,6 +19,7 @@ #include #include #include +#include #include "common/EasyAssert.h" #include "common/Types.h" @@ -40,25 +41,25 @@ 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, @@ -66,21 +67,21 @@ class FieldMeta { bool enable_match, bool enable_analyzer, std::map& 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), @@ -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 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); } diff --git a/internal/core/src/common/Span.h b/internal/core/src/common/Span.h index 3334b8b44e72e..950e69e003a84 100644 --- a/internal/core/src/common/Span.h +++ b/internal/core/src/common/Span.h @@ -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) diff --git a/internal/core/src/common/Types.h b/internal/core/src/common/Types.h index d26d2ee2ed9dc..3dd85e271741d 100644 --- a/internal/core/src/common/Types.h +++ b/internal/core/src/common/Types.h @@ -680,6 +680,9 @@ struct fmt::formatter : formatter { 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::format(name, ctx); } diff --git a/internal/core/src/exec/expression/EvalCtx.h b/internal/core/src/exec/expression/EvalCtx.h index 244dbff6cf284..185c30c96dd1d 100644 --- a/internal/core/src/exec/expression/EvalCtx.h +++ b/internal/core/src/exec/expression/EvalCtx.h @@ -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* diff --git a/internal/core/src/mmap/ChunkedColumn.h b/internal/core/src/mmap/ChunkedColumn.h index 91b3f9530b4ea..0fd7a8684c904 100644 --- a/internal/core/src/mmap/ChunkedColumn.h +++ b/internal/core/src/mmap/ChunkedColumn.h @@ -53,15 +53,16 @@ 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"); } diff --git a/internal/core/src/mmap/Column.h b/internal/core/src/mmap/Column.h index 413bdcf89c8fa..0862f53b052de 100644 --- a/internal/core/src/mmap/Column.h +++ b/internal/core/src/mmap/Column.h @@ -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: @@ -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) { @@ -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_; } @@ -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_; } @@ -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); @@ -584,7 +582,7 @@ class SingleChunkSparseFloatColumn : public SingleChunkColumnBase { // returned pointer points at a list of knowhere::sparse::SparseRow const char* - Data(int chunk_id = 0) const override { + Data(int chunk_id) const override { return static_cast(static_cast(vec_.data())); } @@ -705,7 +703,7 @@ class SingleChunkVariableColumn : public SingleChunkColumnBase { } std::pair, FixedVector> - ViewsByOffsets(const FixedVector& offsets) const { + ViewsByOffsets(const FixedVector& offsets) const override { std::vector res; FixedVector valid; res.reserve(offsets.size()); diff --git a/internal/core/src/segcore/ChunkedSegmentSealedImpl.h b/internal/core/src/segcore/ChunkedSegmentSealedImpl.h index 0808857bde161..7f53f9d94a09d 100644 --- a/internal/core/src/segcore/ChunkedSegmentSealedImpl.h +++ b/internal/core/src/segcore/ChunkedSegmentSealedImpl.h @@ -119,10 +119,10 @@ class ChunkedSegmentSealedImpl : public SegmentSealed { get_schema() const override; std::vector - search_pk(const PkType& pk, Timestamp timestamp) const; + search_pk(const PkType& pk, Timestamp timestamp) const override; std::vector - search_pk(const PkType& pk, int64_t insert_barrier) const; + search_pk(const PkType& pk, int64_t insert_barrier) const override; template std::vector @@ -201,7 +201,7 @@ class ChunkedSegmentSealedImpl : public SegmentSealed { is_mmap_field(FieldId id) const override; void - ClearData(); + ClearData() override; protected: // blob and row_count @@ -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 diff --git a/internal/core/src/segcore/ConcurrentVector.h b/internal/core/src/segcore/ConcurrentVector.h index 484ff7d293c04..07a9625480a13 100644 --- a/internal/core/src/segcore/ConcurrentVector.h +++ b/internal/core/src/segcore/ConcurrentVector.h @@ -400,7 +400,7 @@ class ConcurrentVector int64_t size_per_chunk, storage::MmapChunkDescriptorPtr mmap_descriptor = nullptr) : ConcurrentVectorImpl::ConcurrentVectorImpl( - 1, size_per_chunk, mmap_descriptor) { + 1, size_per_chunk, std::move(mmap_descriptor)) { } std::string_view @@ -418,7 +418,7 @@ class ConcurrentVector : public ConcurrentVectorImpl { int64_t size_per_chunk, storage::MmapChunkDescriptorPtr mmap_descriptor = nullptr) : ConcurrentVectorImpl::ConcurrentVectorImpl( - 1, size_per_chunk, mmap_descriptor) { + 1, size_per_chunk, std::move(mmap_descriptor)) { } std::string_view @@ -437,7 +437,7 @@ class ConcurrentVector : public ConcurrentVectorImpl { int64_t size_per_chunk, storage::MmapChunkDescriptorPtr mmap_descriptor = nullptr) : ConcurrentVectorImpl::ConcurrentVectorImpl( - 1, size_per_chunk, mmap_descriptor) { + 1, size_per_chunk, std::move(mmap_descriptor)) { } ArrayView @@ -455,10 +455,9 @@ class ConcurrentVector explicit ConcurrentVector( int64_t size_per_chunk, storage::MmapChunkDescriptorPtr mmap_descriptor = nullptr) - : ConcurrentVectorImpl, - true>::ConcurrentVectorImpl(1, - size_per_chunk, - mmap_descriptor), + : ConcurrentVectorImpl, true>:: + ConcurrentVectorImpl( + 1, size_per_chunk, std::move(mmap_descriptor)), dim_(0) { } @@ -494,7 +493,7 @@ class ConcurrentVector int64_t size_per_chunk, storage::MmapChunkDescriptorPtr mmap_descriptor = nullptr) : ConcurrentVectorImpl::ConcurrentVectorImpl( - dim, size_per_chunk, mmap_descriptor) { + dim, size_per_chunk, std::move(mmap_descriptor)) { } }; @@ -506,7 +505,8 @@ class ConcurrentVector int64_t dim, int64_t size_per_chunk, storage::MmapChunkDescriptorPtr mmap_descriptor = nullptr) - : ConcurrentVectorImpl(dim / 8, size_per_chunk, mmap_descriptor) { + : ConcurrentVectorImpl( + dim / 8, size_per_chunk, std::move(mmap_descriptor)) { AssertInfo(dim % 8 == 0, fmt::format("dim is not a multiple of 8, dim={}", dim)); } @@ -520,7 +520,7 @@ class ConcurrentVector int64_t size_per_chunk, storage::MmapChunkDescriptorPtr mmap_descriptor = nullptr) : ConcurrentVectorImpl::ConcurrentVectorImpl( - dim, size_per_chunk, mmap_descriptor) { + dim, size_per_chunk, std::move(mmap_descriptor)) { } }; @@ -532,7 +532,7 @@ class ConcurrentVector int64_t size_per_chunk, storage::MmapChunkDescriptorPtr mmap_descriptor = nullptr) : ConcurrentVectorImpl::ConcurrentVectorImpl( - dim, size_per_chunk, mmap_descriptor) { + dim, size_per_chunk, std::move(mmap_descriptor)) { } }; diff --git a/internal/core/src/segcore/DeletedRecord.h b/internal/core/src/segcore/DeletedRecord.h index d56fab5ba4de8..8474fa0042b56 100644 --- a/internal/core/src/segcore/DeletedRecord.h +++ b/internal/core/src/segcore/DeletedRecord.h @@ -117,8 +117,7 @@ class DeletedRecord { auto deleted_ts = timestamps[i]; std::vector offsets; if (segment_) { - offsets = - std::move(segment_->search_pk(deleted_pk, deleted_ts)); + offsets = segment_->search_pk(deleted_pk, deleted_ts); } else { // only for testing offsets = std::move( @@ -267,7 +266,7 @@ class DeletedRecord { } else { // add new snapshot snapshots_.push_back( - std::make_pair(dump_ts, std::move(bitmap.clone()))); + std::make_pair(dump_ts, bitmap.clone())); Assert(it != accessor.end() && it.good()); snap_next_iter_.push_back(it); } @@ -313,7 +312,7 @@ class DeletedRecord { for (const auto& snap : snapshots_) { snapshots.emplace_back(snap.first, snap.second.clone()); } - return std::move(snapshots); + return snapshots; } public: diff --git a/internal/core/src/segcore/InsertRecord.h b/internal/core/src/segcore/InsertRecord.h index a009ca5e9d12a..3f8bb5a4d3738 100644 --- a/internal/core/src/segcore/InsertRecord.h +++ b/internal/core/src/segcore/InsertRecord.h @@ -535,7 +535,7 @@ struct InsertRecord { case DataType::INT64: { auto column = std::dynamic_pointer_cast(data); - auto pks = reinterpret_cast(column->Data()); + auto pks = reinterpret_cast(column->Data(0)); for (int i = 0; i < column->NumRows(); ++i) { pk2offset_->insert(pks[i], offset++); } diff --git a/internal/core/src/segcore/SegmentSealedImpl.cpp b/internal/core/src/segcore/SegmentSealedImpl.cpp index 3abede7800536..cc17593b77141 100644 --- a/internal/core/src/segcore/SegmentSealedImpl.cpp +++ b/internal/core/src/segcore/SegmentSealedImpl.cpp @@ -61,7 +61,6 @@ namespace milvus::segcore { case DataType::INT64: { \ auto col = \ std::dynamic_pointer_cast(column); \ - auto pks = reinterpret_cast(col->Data()); \ for (int i = 1; i < col->NumRows(); ++i) { \ assert(pks[i - 1] <= pks[i] && \ "INT64 Column is not ordered!"); \ @@ -122,7 +121,6 @@ void SegmentSealedImpl::LoadVecIndex(const LoadIndexInfo& info) { // NOTE: lock only when data is ready to avoid starvation auto field_id = FieldId(info.field_id); - auto& field_meta = schema_->operator[](field_id); AssertInfo(info.index_params.count("metric_type"), "Can't get metric_type in index_params"); @@ -712,7 +710,6 @@ SegmentSealedImpl::get_chunk_buffer(FieldId field_id, std::shared_lock lck(mutex_); AssertInfo(get_bit(field_data_ready_bitset_, field_id), "Can't get bitset element at " + std::to_string(field_id.get())); - auto& field_meta = schema_->operator[](field_id); if (auto it = fields_.find(field_id); it != fields_.end()) { auto& field_data = it->second; FixedVector valid_data; @@ -839,7 +836,7 @@ SegmentSealedImpl::search_sorted_pk(const PkType& pk, case DataType::INT64: { auto target = std::get(pk); // get int64 pks - auto src = reinterpret_cast(pk_column->Data()); + auto src = reinterpret_cast(pk_column->Data(0)); auto it = std::lower_bound(src, src + pk_column->NumRows(), @@ -950,7 +947,7 @@ SegmentSealedImpl::vector_search(SearchInfo& search_info, } query::SearchOnSealed(*schema_, - vec_data->Data(), + vec_data->Data(0), search_info, index_info, query_data, @@ -1069,8 +1066,8 @@ SegmentSealedImpl::get_vector(FieldId field_id, pool.Submit(ReadFromChunkCache, cc, data_path, mmap_descriptor_)); } - for (int i = 0; i < futures.size(); ++i) { - const auto& [data_path, column] = futures[i].get(); + for (auto& future : futures) { + const auto& [data_path, column] = future.get(); path_to_column[data_path] = column; } @@ -1091,7 +1088,7 @@ SegmentSealedImpl::get_vector(FieldId field_id, AssertInfo(sparse_column, "incorrect column created"); buf[i] = static_cast*>( static_cast( - sparse_column->Data()))[offset_in_binlog]; + sparse_column->Data(0)))[offset_in_binlog]; } return segcore::CreateVectorDataArrayFrom( buf.data(), count, field_meta); @@ -1112,7 +1109,7 @@ SegmentSealedImpl::get_vector(FieldId field_id, offset_in_binlog, column->NumRows(), data_path); - auto vector = &column->Data()[offset_in_binlog * row_bytes]; + auto vector = &column->Data(0)[offset_in_binlog * row_bytes]; std::memcpy(buf.data() + i * row_bytes, vector, row_bytes); } return segcore::CreateVectorDataArrayFrom( @@ -1133,7 +1130,6 @@ SegmentSealedImpl::DropFieldData(const FieldId field_id) { } lck.unlock(); } else { - auto& field_meta = schema_->operator[](field_id); std::unique_lock lck(mutex_); if (get_bit(field_data_ready_bitset_, field_id)) { fields_.erase(field_id); @@ -1379,7 +1375,7 @@ SegmentSealedImpl::get_raw_data(FieldId field_id, const FieldMeta& field_meta, const int64_t* seg_offsets, int64_t count) const { - // DO NOT directly access the column by map like: `fields_.at(field_id)->Data()`, + // DO NOT directly access the column by map like: `fields_.at(field_id)->Data(0)`, // we have to clone the shared pointer, // to make sure it won't get released if segment released auto column = fields_.at(field_id); @@ -1421,7 +1417,7 @@ SegmentSealedImpl::get_raw_data(FieldId field_id, } case DataType::BOOL: { - bulk_subscript_impl(column->Data(), + bulk_subscript_impl(column->Data(0), seg_offsets, count, ret->mutable_scalars() @@ -1431,7 +1427,7 @@ SegmentSealedImpl::get_raw_data(FieldId field_id, break; } case DataType::INT8: { - bulk_subscript_impl(column->Data(), + bulk_subscript_impl(column->Data(0), seg_offsets, count, ret->mutable_scalars() @@ -1441,7 +1437,7 @@ SegmentSealedImpl::get_raw_data(FieldId field_id, break; } case DataType::INT16: { - bulk_subscript_impl(column->Data(), + bulk_subscript_impl(column->Data(0), seg_offsets, count, ret->mutable_scalars() @@ -1451,7 +1447,7 @@ SegmentSealedImpl::get_raw_data(FieldId field_id, break; } case DataType::INT32: { - bulk_subscript_impl(column->Data(), + bulk_subscript_impl(column->Data(0), seg_offsets, count, ret->mutable_scalars() @@ -1461,7 +1457,7 @@ SegmentSealedImpl::get_raw_data(FieldId field_id, break; } case DataType::INT64: { - bulk_subscript_impl(column->Data(), + bulk_subscript_impl(column->Data(0), seg_offsets, count, ret->mutable_scalars() @@ -1471,7 +1467,7 @@ SegmentSealedImpl::get_raw_data(FieldId field_id, break; } case DataType::FLOAT: { - bulk_subscript_impl(column->Data(), + bulk_subscript_impl(column->Data(0), seg_offsets, count, ret->mutable_scalars() @@ -1481,7 +1477,7 @@ SegmentSealedImpl::get_raw_data(FieldId field_id, break; } case DataType::DOUBLE: { - bulk_subscript_impl(column->Data(), + bulk_subscript_impl(column->Data(0), seg_offsets, count, ret->mutable_scalars() @@ -1492,7 +1488,7 @@ SegmentSealedImpl::get_raw_data(FieldId field_id, } case DataType::VECTOR_FLOAT: { bulk_subscript_impl(field_meta.get_sizeof(), - column->Data(), + column->Data(0), seg_offsets, count, ret->mutable_vectors() @@ -1504,7 +1500,7 @@ SegmentSealedImpl::get_raw_data(FieldId field_id, case DataType::VECTOR_FLOAT16: { bulk_subscript_impl( field_meta.get_sizeof(), - column->Data(), + column->Data(0), seg_offsets, count, ret->mutable_vectors()->mutable_float16_vector()->data()); @@ -1513,7 +1509,7 @@ SegmentSealedImpl::get_raw_data(FieldId field_id, case DataType::VECTOR_BFLOAT16: { bulk_subscript_impl( field_meta.get_sizeof(), - column->Data(), + column->Data(0), seg_offsets, count, ret->mutable_vectors()->mutable_bfloat16_vector()->data()); @@ -1522,7 +1518,7 @@ SegmentSealedImpl::get_raw_data(FieldId field_id, case DataType::VECTOR_BINARY: { bulk_subscript_impl( field_meta.get_sizeof(), - column->Data(), + column->Data(0), seg_offsets, count, ret->mutable_vectors()->mutable_binary_vector()->data()); @@ -1530,7 +1526,7 @@ SegmentSealedImpl::get_raw_data(FieldId field_id, } case DataType::VECTOR_SPARSE_FLOAT: { auto rows = static_cast*>( - static_cast(column->Data())); + static_cast(column->Data(0))); auto dst = ret->mutable_vectors()->mutable_sparse_float_vector(); SparseRowsToProto( [&](size_t i) { @@ -1590,7 +1586,6 @@ SegmentSealedImpl::bulk_subscript( int64_t count, const std::vector& dynamic_field_names) const { Assert(!dynamic_field_names.empty()); - auto& field_meta = schema_->operator[](field_id); if (count == 0) { return fill_with_empty(field_id, 0); } @@ -1920,7 +1915,7 @@ SegmentSealedImpl::generate_interim_index(const FieldId field_id) { auto index_metric = field_binlog_config->GetMetricType(); auto dataset = - knowhere::GenDataSet(row_count, dim, (void*)vec_data->Data()); + knowhere::GenDataSet(row_count, dim, (void*)vec_data->Data(0)); dataset->SetIsOwner(false); dataset->SetIsSparse(is_sparse); diff --git a/internal/core/src/segcore/SegmentSealedImpl.h b/internal/core/src/segcore/SegmentSealedImpl.h index ab445bea56f15..03a33d014c9e5 100644 --- a/internal/core/src/segcore/SegmentSealedImpl.h +++ b/internal/core/src/segcore/SegmentSealedImpl.h @@ -91,7 +91,7 @@ class SegmentSealedImpl : public SegmentSealed { GetFieldDataType(FieldId fieldId) const override; void - RemoveFieldFile(const FieldId field_id); + RemoveFieldFile(const FieldId field_id) override; void CreateTextIndex(FieldId field_id) override; @@ -116,10 +116,10 @@ class SegmentSealedImpl : public SegmentSealed { get_schema() const override; std::vector - search_pk(const PkType& pk, Timestamp timestamp) const; + search_pk(const PkType& pk, Timestamp timestamp) const override; std::vector - search_pk(const PkType& pk, int64_t insert_barrier) const; + search_pk(const PkType& pk, int64_t insert_barrier) const override; template std::vector @@ -214,7 +214,7 @@ class SegmentSealedImpl : public SegmentSealed { is_mmap_field(FieldId id) const override; void - ClearData(); + ClearData() override; protected: // blob and row_count diff --git a/internal/core/src/storage/DataCodec.cpp b/internal/core/src/storage/DataCodec.cpp index 5035a07cd9d14..af77133485989 100644 --- a/internal/core/src/storage/DataCodec.cpp +++ b/internal/core/src/storage/DataCodec.cpp @@ -29,8 +29,8 @@ namespace milvus::storage { std::unique_ptr DeserializeRemoteFileData(BinlogReaderPtr reader, bool is_field_data) { DescriptorEvent descriptor_event(reader); - DataType data_type = - DataType(descriptor_event.event_data.fix_part.data_type); + auto data_type = + static_cast(descriptor_event.event_data.fix_part.data_type); auto& extras = descriptor_event.event_data.extras; bool nullable = (extras.find(NULLABLE) != extras.end()) ? std::any_cast(extras[NULLABLE]) diff --git a/internal/core/src/storage/DataCodec.h b/internal/core/src/storage/DataCodec.h index 51d11a9db5de6..b288c16f9a38c 100644 --- a/internal/core/src/storage/DataCodec.h +++ b/internal/core/src/storage/DataCodec.h @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -33,11 +34,11 @@ namespace milvus::storage { class DataCodec { public: explicit DataCodec(FieldDataPtr data, CodecType type) - : field_data_(std::move(data)), codec_type_(type) { + : codec_type_(type), field_data_(std::move(data)) { } explicit DataCodec(std::shared_ptr reader, CodecType type) - : payload_reader_(reader), codec_type_(type) { + : codec_type_(type), payload_reader_(std::move(reader)) { } virtual ~DataCodec() = default; @@ -87,7 +88,7 @@ class DataCodec { void SetData(std::shared_ptr data) { - data_ = data; + data_ = std::move(data); } protected: diff --git a/internal/core/src/storage/SafeQueue.h b/internal/core/src/storage/SafeQueue.h index 6d9dd6ef38749..4df729af7e824 100644 --- a/internal/core/src/storage/SafeQueue.h +++ b/internal/core/src/storage/SafeQueue.h @@ -14,7 +14,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#pragma +#pragma once #include #include @@ -25,10 +25,8 @@ namespace milvus { template class SafeQueue { public: - SafeQueue(void) { - } - ~SafeQueue() { - } + SafeQueue() = default; + ~SafeQueue() = default; bool empty() {