Skip to content

Commit

Permalink
enhance: eliminate compile warnings (#38420)
Browse files Browse the repository at this point in the history
See: #38435

---------

Signed-off-by: Ted Xu <[email protected]>
  • Loading branch information
tedxu authored Dec 16, 2024
1 parent c3edc85 commit 4919ccf
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 67 deletions.
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 @@ StringChunkWriter::write(std::shared_ptr<arrow::RecordBatchReader> data) {
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 @@ JSONChunkWriter::write(std::shared_ptr<arrow::RecordBatchReader> data) {
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) {
offsets.push_back(offset_start_pos);
offset_start_pos += json.data().size();
}
Expand All @@ -142,7 +143,7 @@ JSONChunkWriter::write(std::shared_ptr<arrow::RecordBatchReader> data) {
target_->write(offsets.data(), offsets.size() * sizeof(uint64_t));

// write data
for (auto json : jsons) {
for (const auto& json : jsons) {
target_->write(json.data().data(), json.data().size());
}
}
Expand Down Expand Up @@ -288,7 +289,7 @@ SparseFloatVectorChunkWriter::write(
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 @@ create_chunk(const FieldMeta& field_meta,
PanicInfo(Unsupported, "Unsupported data type");
}

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

Expand Down Expand Up @@ -493,7 +494,7 @@ create_chunk(const FieldMeta& field_meta,
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 @@ class ChunkWriter : public ChunkWriterBase {

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 @@ class ChunkWriter : public ChunkWriterBase {
}

// 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 @@ class ChunkWriter : public ChunkWriterBase {
}
}

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 @@ ChunkWriter<arrow::BooleanArray, bool>::write(
auto row_nums = 0;
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<arrow::BooleanArray>(data);
Expand All @@ -136,7 +136,7 @@ ChunkWriter<arrow::BooleanArray, bool>::write(
target_ = std::make_shared<MemChunkTarget>(size);
}
// 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 @@ -148,7 +148,7 @@ ChunkWriter<arrow::BooleanArray, bool>::write(
}
}

for (auto batch : batch_vec) {
for (auto& batch : batch_vec) {
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 @@ -118,11 +118,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 @@ class ChunkedColumnBase : public ColumnBase {
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 @@ class ChunkedColumnBase : public ColumnBase {
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 @@ class ChunkedColumn : public ChunkedColumnBase {
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) {
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 ChunkedColumn : public ChunkedColumnBase {
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) {
for (auto& chunk : chunks) {
AddChunk(chunk);
}
Expand Down Expand Up @@ -311,11 +313,12 @@ class ChunkedVariableColumn : public ChunkedColumnBase {
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) {
for (auto& chunk : chunks) {
AddChunk(chunk);
}
Expand Down Expand Up @@ -388,11 +391,12 @@ class ChunkedVariableColumn : public ChunkedColumnBase {
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) {
for (auto& chunk : chunks) {
AddChunk(chunk);
}
Expand Down
Loading

0 comments on commit 4919ccf

Please sign in to comment.