Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance: eliminate compile warnings #38420

Merged
Merged
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
4 changes: 3 additions & 1 deletion internal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ if ( APPLE )
"-DELPP_THREAD_SAFE"
"-fopenmp"
"-pedantic"
"-Wno-all"
"-Wall"
"-Wno-gnu-zero-variadic-macro-arguments"
"-Wno-variadic-macros"
"-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED=1"
)
endif ()
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 @@ -243,7 +243,7 @@ class SparseFloatVectorChunk : public Chunk {
for (int i = 0; i < row_nums; i++) {
vec_[i] = {(offsets_ptr[i + 1] - offsets_ptr[i]) /
knowhere::sparse::SparseRow<float>::element_size(),
(uint8_t*)(data + offsets_ptr[i]),
reinterpret_cast<uint8_t*>(data + offsets_ptr[i]),
false};
dim_ = std::max(dim_, vec_[i].dim());
}
Expand Down
13 changes: 7 additions & 6 deletions internal/core/src/common/ChunkWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "common/ChunkWriter.h"
#include <cstdint>
#include <memory>
#include <utility>
#include <vector>
#include "arrow/array/array_binary.h"
#include "arrow/array/array_primitive.h"
Expand Down Expand Up @@ -66,7 +67,7 @@
int offset_start_pos = target_->tell() + sizeof(uint64_t) * offset_num;
std::vector<uint64_t> offsets;

for (auto str : strs) {
for (const auto& str : strs) {
offsets.push_back(offset_start_pos);
offset_start_pos += str.size();
}
Expand Down Expand Up @@ -133,7 +134,7 @@
int offset_start_pos = target_->tell() + sizeof(uint64_t) * offset_num;
std::vector<uint64_t> offsets;

for (auto json : jsons) {
for (const auto& json : jsons) {

Check warning on line 137 in internal/core/src/common/ChunkWriter.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/common/ChunkWriter.cpp#L137

Added line #L137 was not covered by tests
offsets.push_back(offset_start_pos);
offset_start_pos += json.data().size();
}
Expand All @@ -142,7 +143,7 @@
target_->write(offsets.data(), offsets.size() * sizeof(uint64_t));

// write data
for (auto json : jsons) {
for (const auto& json : jsons) {

Check warning on line 146 in internal/core/src/common/ChunkWriter.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/common/ChunkWriter.cpp#L146

Added line #L146 was not covered by tests
target_->write(json.data().data(), json.data().size());
}
}
Expand Down Expand Up @@ -288,7 +289,7 @@
int offset_start_pos = target_->tell() + sizeof(uint64_t) * offset_num;
std::vector<uint64_t> offsets;

for (auto str : strs) {
for (const auto& str : strs) {
offsets.push_back(offset_start_pos);
offset_start_pos += str.size();
}
Expand Down Expand Up @@ -396,7 +397,7 @@
PanicInfo(Unsupported, "Unsupported data type");
}

w->write(r);
w->write(std::move(r));
return w->finish();
}

Expand Down Expand Up @@ -493,7 +494,7 @@
PanicInfo(Unsupported, "Unsupported data type");
}

w->write(r);
w->write(std::move(r));
return w->finish();
}

Expand Down
12 changes: 6 additions & 6 deletions internal/core/src/common/ChunkWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

auto batch_vec = data->ToRecordBatches().ValueOrDie();

for (auto batch : batch_vec) {
for (auto& batch : batch_vec) {
row_nums += batch->num_rows();
auto data = batch->column(0);
auto array = std::dynamic_pointer_cast<ArrowType>(data);
Expand All @@ -83,7 +83,7 @@
}

// chunk layout: nullbitmap, data1, data2, ..., datan
for (auto batch : batch_vec) {
for (auto& batch : batch_vec) {
auto data = batch->column(0);
auto null_bitmap = data->null_bitmap_data();
auto null_bitmap_n = (data->length() + 7) / 8;
Expand All @@ -95,7 +95,7 @@
}
}

for (auto batch : batch_vec) {
for (auto& batch : batch_vec) {
auto data = batch->column(0);
auto array = std::dynamic_pointer_cast<ArrowType>(data);
auto data_ptr = array->raw_values();
Expand All @@ -122,7 +122,7 @@
auto row_nums = 0;
auto batch_vec = data->ToRecordBatches().ValueOrDie();

for (auto batch : batch_vec) {
for (auto& batch : batch_vec) {

Check warning on line 125 in internal/core/src/common/ChunkWriter.h

View check run for this annotation

Codecov / codecov/patch

internal/core/src/common/ChunkWriter.h#L125

Added line #L125 was not covered by tests
row_nums += batch->num_rows();
auto data = batch->column(0);
auto array = std::dynamic_pointer_cast<arrow::BooleanArray>(data);
Expand All @@ -136,7 +136,7 @@
target_ = std::make_shared<MemChunkTarget>(size);
}
// chunk layout: nullbitmap, data1, data2, ..., datan
for (auto batch : batch_vec) {
for (auto& batch : batch_vec) {

Check warning on line 139 in internal/core/src/common/ChunkWriter.h

View check run for this annotation

Codecov / codecov/patch

internal/core/src/common/ChunkWriter.h#L139

Added line #L139 was not covered by tests
auto data = batch->column(0);
auto null_bitmap = data->null_bitmap_data();
auto null_bitmap_n = (data->length() + 7) / 8;
Expand All @@ -148,7 +148,7 @@
}
}

for (auto batch : batch_vec) {
for (auto& batch : batch_vec) {

Check warning on line 151 in internal/core/src/common/ChunkWriter.h

View check run for this annotation

Codecov / codecov/patch

internal/core/src/common/ChunkWriter.h#L151

Added line #L151 was not covered by tests
auto data = batch->column(0);
auto array = std::dynamic_pointer_cast<arrow::BooleanArray>(data);
for (int i = 0; i < array->length(); i++) {
Expand Down
7 changes: 5 additions & 2 deletions internal/core/src/common/FieldData.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <string>
#include <memory>
#include <utility>

#include <oneapi/tbb/concurrent_queue.h>

Expand Down Expand Up @@ -102,7 +103,7 @@ class FieldData<BinaryVector> : public FieldDataImpl<uint8_t, false> {
}

int64_t
get_dim() const {
get_dim() const override {
return binary_dim_;
}

Expand Down Expand Up @@ -149,7 +150,9 @@ struct ArrowDataWrapper {
ArrowDataWrapper(std::shared_ptr<arrow::RecordBatchReader> reader,
std::shared_ptr<parquet::arrow::FileReader> arrow_reader,
std::shared_ptr<uint8_t[]> file_data)
: reader(reader), arrow_reader(arrow_reader), file_data(file_data) {
: reader(std::move(reader)),
arrow_reader(std::move(arrow_reader)),
file_data(std::move(file_data)) {
}
std::shared_ptr<arrow::RecordBatchReader> reader;
// file reader must outlive the record batch reader
Expand Down
2 changes: 1 addition & 1 deletion internal/core/src/exec/expression/Expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ CompileExpression(const expr::TypedExprPtr& expr,
bool enable_constant_folding) {
ExprPtr result;

auto result_type = expr->type();
auto compiled_inputs = CompileInputs(expr, context, flatten_candidates);

auto GetTypes = [](const std::vector<ExprPtr>& exprs) {
std::vector<DataType> types;
types.reserve(exprs.size());
for (auto& expr : exprs) {
types.push_back(expr->type());
}
Expand Down
1 change: 0 additions & 1 deletion internal/core/src/exec/expression/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ class SegmentExpr : public Expr {
conditional_t<std::is_same_v<T, std::string_view>, std::string, T>
IndexInnerType;
using Index = index::ScalarIndex<IndexInnerType>;
int64_t processed_size = 0;
const Index& index =
segment_->chunk_scalar_index<IndexInnerType>(field_id_, 0);
auto* index_ptr = const_cast<Index*>(&index);
Expand Down
5 changes: 1 addition & 4 deletions internal/core/src/exec/expression/UnaryExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,6 @@ PhyUnaryRangeFilterExpr::Eval(EvalCtx& context, VectorPtr& result) {
template <typename ValueType>
VectorPtr
PhyUnaryRangeFilterExpr::ExecRangeVisitorImplArray(OffsetVector* input) {
using GetType = std::conditional_t<std::is_same_v<ValueType, std::string>,
std::string_view,
ValueType>;
auto real_batch_size =
has_offset_input_ ? input->size() : GetNextBatchSize();
if (real_batch_size == 0) {
Expand Down Expand Up @@ -896,7 +893,7 @@ template <typename T>
ColumnVectorPtr
PhyUnaryRangeFilterExpr::PreCheckOverflow(OffsetVector* input) {
if constexpr (std::is_integral_v<T> && !std::is_same_v<T, bool>) {
int64_t val = GetValueFromProto<int64_t>(expr_->val_);
auto val = GetValueFromProto<int64_t>(expr_->val_);

if (milvus::query::out_of_range<T>(val)) {
int64_t batch_size;
Expand Down
21 changes: 9 additions & 12 deletions internal/core/src/exec/expression/UnaryExpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ namespace exec {

template <typename T, FilterType filter_type>
struct UnaryElementFuncForMatch {
typedef std::
conditional_t<std::is_same_v<T, std::string_view>, std::string, T>
IndexInnerType;
using IndexInnerType =
std::conditional_t<std::is_same_v<T, std::string_view>, std::string, T>;

void
operator()(const T* src,

size_t size,
IndexInnerType val,
TargetBitmapView res,
Expand All @@ -60,9 +60,8 @@ struct UnaryElementFuncForMatch {

template <typename T, proto::plan::OpType op, FilterType filter_type>
struct UnaryElementFunc {
typedef std::
conditional_t<std::is_same_v<T, std::string_view>, std::string, T>
IndexInnerType;
using IndexInnerType =
std::conditional_t<std::is_same_v<T, std::string_view>, std::string, T>;

void
operator()(const T* src,
Expand Down Expand Up @@ -235,9 +234,8 @@ struct UnaryElementFuncForArray {

template <typename T>
struct UnaryIndexFuncForMatch {
typedef std::
conditional_t<std::is_same_v<T, std::string_view>, std::string, T>
IndexInnerType;
using IndexInnerType =
std::conditional_t<std::is_same_v<T, std::string_view>, std::string, T>;
using Index = index::ScalarIndex<IndexInnerType>;
TargetBitmap
operator()(Index* index, IndexInnerType val) {
Expand Down Expand Up @@ -275,9 +273,8 @@ struct UnaryIndexFuncForMatch {

template <typename T, proto::plan::OpType op>
struct UnaryIndexFunc {
typedef std::
conditional_t<std::is_same_v<T, std::string_view>, std::string, T>
IndexInnerType;
using IndexInnerType =
std::conditional_t<std::is_same_v<T, std::string_view>, std::string, T>;
using Index = index::ScalarIndex<IndexInnerType>;
TargetBitmap
operator()(Index* index, IndexInnerType val) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ template <typename T>
static const std::shared_ptr<DataGetter<T>>
GetDataGetter(const segcore::SegmentInternalInterface& segment,
FieldId fieldId) {
if (const segcore::SegmentGrowingImpl* growing_segment =
if (const auto* growing_segment =
dynamic_cast<const segcore::SegmentGrowingImpl*>(&segment)) {
return std::make_shared<GrowingDataGetter<T>>(*growing_segment,
fieldId);
} else if (const segcore::SegmentSealed* sealed_segment =
} else if (const auto* sealed_segment =
dynamic_cast<const segcore::SegmentSealed*>(&segment)) {
return std::make_shared<SealedDataGetter<T>>(*sealed_segment, fieldId);
} else {
Expand Down
4 changes: 0 additions & 4 deletions internal/core/src/mmap/ChunkData.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ VariableLengthChunk<std::string>::set(const std::string* src,
uint32_t begin,
uint32_t length) {
auto mcm = storage::MmapManager::GetInstance().GetMmapChunkManager();
milvus::ErrorCode err_code;
AssertInfo(
begin + length <= size_,
"failed to set a chunk with length: {} from beign {}, map_size={}",
Expand Down Expand Up @@ -126,7 +125,6 @@ VariableLengthChunk<knowhere::sparse::SparseRow<float>>::set(
uint32_t begin,
uint32_t length) {
auto mcm = storage::MmapManager::GetInstance().GetMmapChunkManager();
milvus::ErrorCode err_code;
AssertInfo(
begin + length <= size_,
"failed to set a chunk with length: {} from beign {}, map_size={}",
Expand Down Expand Up @@ -157,7 +155,6 @@ VariableLengthChunk<Json>::set(const Json* src,
uint32_t begin,
uint32_t length) {
auto mcm = storage::MmapManager::GetInstance().GetMmapChunkManager();
milvus::ErrorCode err_code;
AssertInfo(
begin + length <= size_,
"failed to set a chunk with length: {} from beign {}, map_size={}",
Expand Down Expand Up @@ -187,7 +184,6 @@ VariableLengthChunk<Array>::set(const Array* src,
uint32_t begin,
uint32_t length) {
auto mcm = storage::MmapManager::GetInstance().GetMmapChunkManager();
milvus::ErrorCode err_code;
AssertInfo(
begin + length <= size_,
"failed to set a chunk with length: {} from beign {}, map_size={}",
Expand Down
26 changes: 15 additions & 11 deletions internal/core/src/mmap/ChunkedColumn.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
PanicInfo(ErrorCode::Unsupported, "AppendBatch not supported");
}

virtual const char*
const char*
Data(int chunk_id) const override {
return chunks_[chunk_id]->Data();
}
Expand Down Expand Up @@ -125,7 +125,7 @@
chunks_.push_back(chunk);
}

virtual size_t
size_t
DataByteSize() const override {
auto size = 0;
for (auto& chunk : chunks_) {
Expand Down Expand Up @@ -236,18 +236,19 @@
public:
ChunkedColumn() = default;
// memory mode ctor
ChunkedColumn(const FieldMeta& field_meta) : ChunkedColumnBase(field_meta) {
explicit ChunkedColumn(const FieldMeta& field_meta)
: ChunkedColumnBase(field_meta) {
}

ChunkedColumn(std::vector<std::shared_ptr<Chunk>> chunks) {
explicit ChunkedColumn(const std::vector<std::shared_ptr<Chunk>>& chunks) {

Check warning on line 243 in internal/core/src/mmap/ChunkedColumn.h

View check run for this annotation

Codecov / codecov/patch

internal/core/src/mmap/ChunkedColumn.h#L243

Added line #L243 was not covered by tests
for (auto& chunk : chunks) {
AddChunk(chunk);
}
}

~ChunkedColumn() override = default;

virtual SpanBase
SpanBase
Span(int64_t chunk_id) const override {
return std::dynamic_pointer_cast<FixedWidthChunk>(chunks_[chunk_id])
->Span();
Expand All @@ -258,11 +259,12 @@
class ChunkedSparseFloatColumn : public ChunkedColumnBase {
public:
// memory mode ctor
ChunkedSparseFloatColumn(const FieldMeta& field_meta)
explicit ChunkedSparseFloatColumn(const FieldMeta& field_meta)
: ChunkedColumnBase(field_meta) {
}

ChunkedSparseFloatColumn(std::vector<std::shared_ptr<Chunk>> chunks) {
explicit ChunkedSparseFloatColumn(
const std::vector<std::shared_ptr<Chunk>>& chunks) {

Check warning on line 267 in internal/core/src/mmap/ChunkedColumn.h

View check run for this annotation

Codecov / codecov/patch

internal/core/src/mmap/ChunkedColumn.h#L266-L267

Added lines #L266 - L267 were not covered by tests
for (auto& chunk : chunks) {
AddChunk(chunk);
}
Expand Down Expand Up @@ -311,11 +313,12 @@
std::conditional_t<std::is_same_v<T, std::string>, std::string_view, T>;

// memory mode ctor
ChunkedVariableColumn(const FieldMeta& field_meta)
explicit ChunkedVariableColumn(const FieldMeta& field_meta)
: ChunkedColumnBase(field_meta) {
}

ChunkedVariableColumn(std::vector<std::shared_ptr<Chunk>> chunks) {
explicit ChunkedVariableColumn(
const std::vector<std::shared_ptr<Chunk>>& chunks) {

Check warning on line 321 in internal/core/src/mmap/ChunkedColumn.h

View check run for this annotation

Codecov / codecov/patch

internal/core/src/mmap/ChunkedColumn.h#L320-L321

Added lines #L320 - L321 were not covered by tests
for (auto& chunk : chunks) {
AddChunk(chunk);
}
Expand Down Expand Up @@ -388,11 +391,12 @@
class ChunkedArrayColumn : public ChunkedColumnBase {
public:
// memory mode ctor
ChunkedArrayColumn(const FieldMeta& field_meta)
explicit ChunkedArrayColumn(const FieldMeta& field_meta)
: ChunkedColumnBase(field_meta) {
}

ChunkedArrayColumn(std::vector<std::shared_ptr<Chunk>> chunks) {
explicit ChunkedArrayColumn(
const std::vector<std::shared_ptr<Chunk>>& chunks) {

Check warning on line 399 in internal/core/src/mmap/ChunkedColumn.h

View check run for this annotation

Codecov / codecov/patch

internal/core/src/mmap/ChunkedColumn.h#L398-L399

Added lines #L398 - L399 were not covered by tests
for (auto& chunk : chunks) {
AddChunk(chunk);
}
Expand Down
Loading
Loading