This is an automated email from the ASF dual-hosted git repository. panxiaolei pushed a commit to branch clucene in repository https://gitbox.apache.org/repos/asf/doris-thirdparty.git
The following commit(s) were added to refs/heads/clucene by this push: new c5ba0a26e9 fix some implicit conversion (#197) c5ba0a26e9 is described below commit c5ba0a26e9cab11a85dc3c5854e9ad258fa4fdf5 Author: Pxl <pxl...@qq.com> AuthorDate: Fri Mar 8 18:02:28 2024 +0800 fix some implicit conversion (#197) --- src/core/CLucene/analysis/AnalysisHeader.h | 8 ++++---- src/core/CLucene/util/CLStreams.h | 2 +- src/core/CLucene/util/PriorityQueue.h | 2 +- src/core/CLucene/util/bkd/bkd_docid_iterator.h | 8 ++++---- src/core/CLucene/util/stringUtil.h | 17 +++++++++-------- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/core/CLucene/analysis/AnalysisHeader.h b/src/core/CLucene/analysis/AnalysisHeader.h index 578d8e0061..a98e26e4ab 100644 --- a/src/core/CLucene/analysis/AnalysisHeader.h +++ b/src/core/CLucene/analysis/AnalysisHeader.h @@ -219,15 +219,15 @@ public: template <> inline size_t Token::termLength<char>(){ if ( _termTextLen == -1 ) //it was invalidated by growBuffer - _termTextLen = strlen((char*)_buffer); - return _termTextLen; + _termTextLen = (int32_t)strlen((char*)_buffer); + return (size_t)_termTextLen; }; template <> inline size_t Token::termLength<TCHAR>(){ if ( _termTextLen == -1 ) //it was invalidated by growBuffer - _termTextLen = wcslen((TCHAR*)_buffer); - return _termTextLen; + _termTextLen = (int32_t)wcslen((TCHAR*)_buffer); + return (size_t)_termTextLen; }; class CLUCENE_EXPORT TokenStream { diff --git a/src/core/CLucene/util/CLStreams.h b/src/core/CLucene/util/CLStreams.h index 121f272539..3f60f2d97a 100644 --- a/src/core/CLucene/util/CLStreams.h +++ b/src/core/CLucene/util/CLStreams.h @@ -196,7 +196,7 @@ public: this->init(_value, _length, copyData); } void init(const void *_value, int32_t _length, bool copyData = true) override { - const size_t length = _length; + const size_t length = (size_t)_length; this->pos = 0; if (copyData) { T *tmp = (T *) this->value; diff --git a/src/core/CLucene/util/PriorityQueue.h b/src/core/CLucene/util/PriorityQueue.h index 16b2bbac66..59cb0a8d31 100644 --- a/src/core/CLucene/util/PriorityQueue.h +++ b/src/core/CLucene/util/PriorityQueue.h @@ -39,7 +39,7 @@ class CLUCENE_INLINE_EXPORT PriorityQueue { int32_t j = ((uint32_t)i) >> 1; while (j > 0 && lessThan(node,heap[j])) { heap[i] = heap[j]; // shift parents down - i = j; + i = (size_t)j; j = ((uint32_t)j) >> 1; } heap[i] = node; // install saved node diff --git a/src/core/CLucene/util/bkd/bkd_docid_iterator.h b/src/core/CLucene/util/bkd/bkd_docid_iterator.h index 491d3c4c5a..412228ad97 100644 --- a/src/core/CLucene/util/bkd/bkd_docid_iterator.h +++ b/src/core/CLucene/util/bkd/bkd_docid_iterator.h @@ -12,7 +12,7 @@ class bkd_docid_set{ public: static const int NO_MORE_DOCS = std::numeric_limits<int32_t>::max(); - explicit bkd_docid_set(int32_t size) { + explicit bkd_docid_set(size_t size) { docids.resize(size); } int32_t length() const { @@ -22,7 +22,7 @@ public: if (_idx == _length) { _docid = NO_MORE_DOCS; } else { - _docid = docids[_offset + _idx]; + _docid = docids[size_t(_offset + _idx)]; _idx++; } return _docid; @@ -48,7 +48,7 @@ public: explicit bkd_docid_bitmap_set(int32_t size) {} ~bkd_docid_bitmap_set() = default; void add(std::vector<char>&& r, int pos) { - docids[pos] = r; + docids[size_t(pos)] = r; _offset++; } void add(std::vector<char>&& r) { @@ -66,7 +66,7 @@ public: if (_idx == _length) { _docid = std::vector<char>(0); } else { - _docid = docids[_offset + _idx]; + _docid = docids[size_t(_offset + _idx)]; _idx++; } return _docid; diff --git a/src/core/CLucene/util/stringUtil.h b/src/core/CLucene/util/stringUtil.h index 4a022e3e24..e7d41e1d83 100644 --- a/src/core/CLucene/util/stringUtil.h +++ b/src/core/CLucene/util/stringUtil.h @@ -41,7 +41,7 @@ public: #if defined(__SSE2__) || defined(__aarch64__) const auto bytes_sse = sizeof(__m128i); - const auto src_end_sse = src_end - (src_end - src) % bytes_sse; + const auto src_end_sse = src_end - size_t(src_end - src) % bytes_sse; const auto v_not_case_lower_bound = _mm_set1_epi8(not_case_lower_bound - 1); const auto v_not_case_upper_bound = _mm_set1_epi8(not_case_upper_bound + 1); @@ -243,7 +243,7 @@ public: } } - return n1 - n2; + return int(n1 - n2); } static inline int32_t utf8_byte_count(uint8_t c) { @@ -275,10 +275,11 @@ public: int32_t bytes_in_char = 0; int32_t surplus_bytes = 0; uint32_t codepoint = 0; - for (uint8_t c : str) { + for (auto cc : str) { + char c = (char)cc; if (bytes_in_char == 0) { if ((c & 0x80) == 0) { - codepoint = c; + codepoint = (uint32_t)c; continue; } else if ((c & 0xE0) == 0xC0) { codepoint = c & 0x1F; @@ -313,10 +314,10 @@ public: size_t i = 0; while (i < utf8_str.size()) { wchar_t wc = utf8_str[i]; - int32_t n = utf8_byte_count(utf8_str[i]); + int32_t n = utf8_byte_count((uint8_t)utf8_str[i]); if ((n >= 1 && n <= 4) && - (i + n <= utf8_str.size()) && - validate_utf8(std::string_view(utf8_str.data() + i, n)) == 0) { + (i + (size_t)n <= utf8_str.size()) && + validate_utf8(std::string_view(utf8_str.data() + i, (size_t)n)) == 0) { if (n == 2) { wc = ((utf8_str[i] & 0x1F) << 6) | (utf8_str[i + 1] & 0x3F); } else if (n == 3) { @@ -324,7 +325,7 @@ public: } else if (n == 4) { wc = ((utf8_str[i] & 0x07) << 18) | ((utf8_str[i + 1] & 0x3F) << 12) | ((utf8_str[i + 2] & 0x3F) << 6) | (utf8_str[i + 3] & 0x3F); } - i += n; + i += (size_t)n; } else { i += 1; } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org