Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
Fix other warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
MBkkt committed Dec 18, 2023
1 parent 3f451ce commit bc0f606
Show file tree
Hide file tree
Showing 53 changed files with 188 additions and 215 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Checks: '*,
-mpi-*,
-objc-*,
-openmp-*,
-fuchsia-trailing-return,
-fuchsia-default-arguments-*,
-fuchsia-overloaded-operator,
-readability-identifier-length,
Expand Down
5 changes: 3 additions & 2 deletions core/analysis/delimited_token_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ bool parse_vpack_options(const VPackSlice slice, std::string& delimiter) {
delimiter = delim_type_slice.stringView();
return true;
}
default: {
} // fall through
break;
default:
break;
}

IRS_LOG_ERROR(absl::StrCat(
Expand Down
2 changes: 1 addition & 1 deletion core/analysis/minhash_token_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static uint64_t HashLen0to16(const char* s, size_t len) {
uint8_t b = s[len >> 1];
uint8_t c = s[len - 1];
uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
uint32_t z = len + (static_cast<uint32_t>(c) << 2);
uint32_t z = static_cast<uint32_t>(len) + (static_cast<uint32_t>(c) << 2);
return ShiftMix(y * k2 ^ z * k0) * k2;
}
return k2;
Expand Down
2 changes: 1 addition & 1 deletion core/analysis/nearest_neighbors_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ bool nearest_neighbors_stream::reset(std::string_view data) {
std::istream ss{&buf};

model_dict_->getLine(ss, line_token_ids_, line_token_label_ids_);
n_tokens_ = line_token_ids_.size();
n_tokens_ = static_cast<int32_t>(line_token_ids_.size());
current_token_ind_ = 0;

neighbors_.clear();
Expand Down
4 changes: 2 additions & 2 deletions core/analysis/ngram_token_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ void ngram_token_stream_base::emit_original() noexcept {
: EmitOriginal::WithEndMarker;
inc.value = next_inc_val_;
break;
default:
IRS_ASSERT(false); // should not be called when None
case EmitOriginal::None:
IRS_ASSERT(false);
break;
}
next_inc_val_ = 0;
Expand Down
3 changes: 0 additions & 3 deletions core/analysis/segmentation_token_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,6 @@ bool accept_token(Iterator begin, Iterator end, word_break_t wb) {
return std::find_if_not(begin, end, utf8_utils::CharIsWhiteSpace) != end;
case word_break_t::ALPHA:
return std::find_if(begin, end, utf8_utils::CharIsAlphanumeric) != end;
default:
IRS_ASSERT(false);
return false;
}
}

Expand Down
6 changes: 3 additions & 3 deletions core/analysis/text_token_normalizing_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,9 @@ bool normalizing_token_stream::reset(std::string_view data) {
case UPPER:
state_->token.toUpper(state_->options.locale); // inplace case-conversion
break;
default: {
} // NOOP
};
case NONE:
break;
}

// collate value, e.g. remove accents
if (state_->transliterator) {
Expand Down
9 changes: 5 additions & 4 deletions core/analysis/text_token_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,9 @@ bool process_term(analysis::text_token_stream::state_t& state,
case analysis::text_token_stream::UPPER:
state.token.toUpper(state.options.locale); // inplace case-conversion
break;
default: {
} // NOOP
};
case analysis::text_token_stream::NONE:
break;
}

// collate value, e.g. remove accents
if (state.transliterator) {
Expand All @@ -399,7 +399,8 @@ bool process_term(analysis::text_token_stream::state_t& state,
const sb_symbol* value =
reinterpret_cast<const sb_symbol*>(word_utf8.c_str());

value = sb_stemmer_stem(state.stemmer.get(), value, (int)word_utf8.size());
value = sb_stemmer_stem(state.stemmer.get(), value,
static_cast<int>(word_utf8.size()));

if (value) {
static_assert(sizeof(byte_type) == sizeof(sb_symbol));
Expand Down
1 change: 0 additions & 1 deletion core/analysis/token_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class token_stream : public attribute_provider {
public:
using ptr = std::unique_ptr<token_stream>;

virtual ~token_stream() = default;
virtual bool next() = 0;
};

Expand Down
6 changes: 3 additions & 3 deletions core/error/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ enum class ErrorCode : uint32_t {
undefined_error
};

#define DECLARE_ERROR_CODE(class_name) \
static constexpr ErrorCode CODE = ErrorCode::class_name; \
::irs::ErrorCode code() const noexcept final { return CODE; }
#define DECLARE_ERROR_CODE(class_name) \
::irs::ErrorCode code() const noexcept final { return CODE; } \
static constexpr ErrorCode CODE = ErrorCode::class_name

//////////////////////////////////////////////////////////////////////////////
/// @struct error_base
Expand Down
8 changes: 3 additions & 5 deletions core/formats/columnstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ class writer final : public irs::columnstore_writer {
// do not take into account last block
const auto blocks_count = std::max(1U, column_index_.total());
avg_block_count_ = block_index_.flushed() / blocks_count;
avg_block_size_ = length_ / blocks_count;
avg_block_size_ = static_cast<uint32_t>(length_ / blocks_count);

// we don't care of tail block size
prev_block_size_ = block_buf_.size();
Expand Down Expand Up @@ -1104,7 +1104,7 @@ class dense_block : util::noncopyable {
return false;
}

value_ = base_ + std::distance(begin_, it_);
value_ = base_ + static_cast<uint32_t>(std::distance(begin_, it_));
next_value();

return true;
Expand Down Expand Up @@ -1173,7 +1173,7 @@ class dense_block : util::noncopyable {
encode::avg::visit_block_packed_tail(
in, size, reinterpret_cast<uint64_t*>(buf.data()),
[begin](uint64_t offset) mutable {
*begin = offset;
*begin = static_cast<uint32_t>(offset);
++begin;
});

Expand Down Expand Up @@ -1644,8 +1644,6 @@ class column : public irs::column_reader, private util::noncopyable {
explicit column(field_id id, ColumnProperty props) noexcept
: id_{id}, encrypted_(0 != (props & CP_COLUMN_ENCRYPT)) {}

virtual ~column() = default;

field_id id() const final { return id_; }

std::string_view name() const final {
Expand Down
14 changes: 7 additions & 7 deletions core/formats/columnstore2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ doc_iterator::ptr dense_fixed_length_column::iterator(ColumnHint hint) const {
payload_reader<encrypted_value_reader<false>> operator()(
index_input::ptr&& stream, encryption::stream& cipher) const {
return {ctx->data_, ctx->len_, std::move(stream), &cipher, ctx->data_};
};
}

payload_reader<value_reader<false>> operator()(
index_input::ptr&& stream) const {
Expand Down Expand Up @@ -966,7 +966,7 @@ doc_iterator::ptr fixed_length_column::iterator(ColumnHint hint) const {
index_input::ptr&& stream, encryption::stream& cipher) const {
return {ctx->blocks_.data(), ctx->len_, std::move(stream), &cipher,
ctx->len_};
};
}

payload_reader<value_reader<false>> operator()(
index_input::ptr&& stream) const {
Expand Down Expand Up @@ -1263,7 +1263,7 @@ doc_iterator::ptr sparse_column::iterator(ColumnHint hint) const {
payload_reader<encrypted_value_reader<true>> operator()(
index_input::ptr&& stream, encryption::stream& cipher) const {
return {ctx->blocks_.data(), std::move(stream), &cipher, size_t{0}};
};
}

payload_reader<value_reader<true>> operator()(
index_input::ptr&& stream) const {
Expand Down Expand Up @@ -1291,14 +1291,14 @@ constexpr column_factory_f kFactories[]{
&dense_fixed_length_column::read};

bool less(std::string_view lhs, std::string_view rhs) noexcept {
if (IsNull(lhs)) {
return !IsNull(rhs);
}

if (IsNull(rhs)) {
return false;
}

if (IsNull(lhs)) {
return true;
}

return lhs < rhs;
}

Expand Down
2 changes: 0 additions & 2 deletions core/formats/formats.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,6 @@ enum class ColumnHint : uint32_t {
ENABLE_BITMASK_ENUM(ColumnHint);

struct column_reader : public memory::Managed {
virtual ~column_reader() = default;

// Returns column id.
virtual field_id id() const = 0;

Expand Down
7 changes: 4 additions & 3 deletions core/formats/formats_10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,7 @@ class position final : public irs::position,
value_t seek(value_t target) final {
const uint32_t freq = *this->freq_;
if (this->pend_pos_ > freq) {
skip(this->pend_pos_ - freq);
skip(static_cast<uint32_t>(this->pend_pos_ - freq));
this->pend_pos_ = freq;
}
while (value_ < target && this->pend_pos_) {
Expand Down Expand Up @@ -1612,7 +1612,7 @@ class position final : public irs::position,
const uint32_t freq = *this->freq_;

if (this->pend_pos_ > freq) {
skip(this->pend_pos_ - freq);
skip(static_cast<uint32_t>(this->pend_pos_ - freq));
this->pend_pos_ = freq;
}

Expand Down Expand Up @@ -1948,6 +1948,7 @@ auto ResolveExtent(uint8_t extent, Func&& func) {
if constexpr (PossibleMin <= 0) {
return std::forward<Func>(func)(Extent<0>{});
}
[[fallthrough]];
default:
return std::forward<Func>(func)(DynamicExtent{extent});
}
Expand Down Expand Up @@ -4122,7 +4123,7 @@ template<bool Wand, uint32_t PosMin>
struct format_traits_sse4 {
using align_type = __m128i;

static constexpr bool wand() noexcept { return Wand; };
static constexpr bool wand() noexcept { return Wand; }
static constexpr uint32_t pos_min() noexcept { return PosMin; }
static constexpr uint32_t block_size() noexcept { return SIMDBlockSize; }
static_assert(block_size() <= doc_limits::eof());
Expand Down
8 changes: 5 additions & 3 deletions core/formats/formats_burst_trie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ class fst_buffer : public vector_byte_fst {
};

fst_buffer(IResourceManager& rm)
: vector_byte_fst(ManagedTypedAllocator<byte_arc>(rm)){};
: vector_byte_fst(ManagedTypedAllocator<byte_arc>(rm)) {}

using fst_byte_builder = fst_builder<byte_type, vector_byte_fst, fst_stats>;

Expand Down Expand Up @@ -1524,7 +1524,8 @@ void term_reader_base::prepare(burst_trie::Version version, index_input& in,
max_term_ = read_string<bstring>(in);

if (IndexFeatures::NONE != (field_.index_features & IndexFeatures::FREQ)) {
freq_.value = in.read_vlong();
// TODO(MBkkt) for what reason we store uint64_t if we read to uint32_t
freq_.value = static_cast<uint32_t>(in.read_vlong());
}

if (IRS_LIKELY(version >= burst_trie::Version::WAND)) {
Expand Down Expand Up @@ -3475,6 +3476,8 @@ irs::field_iterator::ptr field_reader::iterator() const {
fields_);
}

/*
// Implements generalized visitation logic for term dictionary
template<typename FST>
class term_reader_visitor {
Expand Down Expand Up @@ -3557,7 +3560,6 @@ class term_reader_visitor {
encryption::stream* terms_in_cipher_;
};
/*
// "Dumper" visitor for term_reader_visitor. Suitable for debugging needs.
class dumper : util::noncopyable {
public:
Expand Down
4 changes: 2 additions & 2 deletions core/formats/skip_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ void SkipReaderBase::Prepare(index_input::ptr&& in, doc_id_t left) {
};

// skip step of the level
size_t step =
skip_0_ * static_cast<size_t>(std::pow(skip_n_, --max_levels));
uint32_t step =
skip_0_ * static_cast<uint32_t>(std::pow(skip_n_, --max_levels));

// load levels from n down to 1
for (; max_levels; --max_levels) {
Expand Down
2 changes: 1 addition & 1 deletion core/formats/skip_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ doc_id_t SkipReader<Read>::Seek(doc_id_t target) {
}

auto& level_0 = levels_.back();
return level_0.left + level_0.step;
return static_cast<doc_id_t>(level_0.left + level_0.step);
}

} // namespace irs
7 changes: 4 additions & 3 deletions core/formats/sparse_bitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ struct container_iterator<BT_DENSE, false> {
}
}
ctx.popcnt = self->index_ + popcnt + std::popcount(ctx.word);
ctx.word_idx = word_idx;
ctx.word_idx = static_cast<int32_t>(word_idx);
}

uint32_t word_delta = target_word_idx - ctx.word_idx;
Expand Down Expand Up @@ -394,8 +394,9 @@ struct container_iterator<BT_DENSE, true> {
}
}

return self->block_ + (word_idx + 1) * bits_required<size_t>() -
std::countl_zero(word) - 1;
return self->block_ +
static_cast<doc_id_t>((word_idx + 1) * bits_required<size_t>() -
std::countl_zero(word) - 1);
}
};

Expand Down
2 changes: 1 addition & 1 deletion core/index/buffered_column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ bool BufferedColumn::FlushDense(column_output& writer, DocMapView docmap,
WriteValue(writer, new_value);
index_.emplace_back(new_value);
}
};
}

return true;
}
Expand Down
13 changes: 6 additions & 7 deletions core/index/directory_reader_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ DirectoryReaderImpl::Init::Init(const directory& dir,
const DirectoryMeta& meta) {
const bool has_segments_file = !meta.filename.empty();

auto& [file_refs, docs_count, live_docs_count] = *this;

file_refs.reserve(meta.index_meta.segments.size() +
size_t{has_segments_file});

Expand Down Expand Up @@ -211,16 +209,16 @@ DirectoryReaderImpl::DirectoryReaderImpl(Init&& init, const directory& dir,
std::shared_ptr<const DirectoryReaderImpl> DirectoryReaderImpl::Open(
const directory& dir, const IndexReaderOptions& opts, format::ptr codec,
const std::shared_ptr<const DirectoryReaderImpl>& cached) {
IndexMeta meta;
index_file_refs::ref_t meta_file_ref = LoadNewestIndexMeta(meta, dir, codec);
IndexMeta index_meta;
auto meta_file_ref = LoadNewestIndexMeta(index_meta, dir, codec);

if (!meta_file_ref) {
throw index_not_found{};
}

IRS_ASSERT(codec);

if (cached && cached->meta_.index_meta == meta) {
if (cached && cached->meta_.index_meta == index_meta) {
return cached; // no changes to refresh
}

Expand All @@ -241,7 +239,7 @@ std::shared_ptr<const DirectoryReaderImpl> DirectoryReaderImpl::Open(
}
}

const auto& segments = meta.segments;
const auto& segments = index_meta.segments;

ReadersType readers(segments.size());
auto reader = readers.begin();
Expand Down Expand Up @@ -272,7 +270,8 @@ std::shared_ptr<const DirectoryReaderImpl> DirectoryReaderImpl::Open(

return std::make_shared<DirectoryReaderImpl>(
dir, std::move(codec), opts,
DirectoryMeta{.filename = *meta_file_ref, .index_meta = std::move(meta)},
DirectoryMeta{.filename = *meta_file_ref,
.index_meta = std::move(index_meta)},
std::move(readers));
}

Expand Down
3 changes: 2 additions & 1 deletion core/index/merge_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,8 @@ bool MergeWriter::FlushSorted(TrackingDirectory& dir, SegmentMeta& segment,
// Handle empty values greater than the last document in sort column
for (auto it = itrs.begin(); auto& reader : readers_) {
if (!fill_doc_map(reader.doc_id_map, *it,
doc_limits::min() + reader.reader->docs_count())) {
doc_limits::min() +
static_cast<doc_id_t>(reader.reader->docs_count()))) {
return false; // progress callback requested termination
}
++it;
Expand Down
4 changes: 2 additions & 2 deletions core/index/norm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ bool Norm2ReaderContext::Reset(const ColumnProvider& reader, field_id column_id,
const auto hdr = Norm2Header::Read(header);
if (hdr.has_value()) {
auto& value = hdr.value();
num_bytes = value.NumBytes();
max_num_bytes = value.MaxNumBytes();
num_bytes = static_cast<uint32_t>(value.NumBytes());
max_num_bytes = static_cast<uint32_t>(value.MaxNumBytes());
return true;
}
}
Expand Down
Loading

0 comments on commit bc0f606

Please sign in to comment.