This is an automated email from the ASF dual-hosted git repository.
jianliangqi pushed a commit to branch clucene-2.0
in repository https://gitbox.apache.org/repos/asf/doris-thirdparty.git
The following commit(s) were added to refs/heads/clucene-2.0 by this push:
new 5e4b4ca1b4 [fix](write)revert comparePostings due to write core (#195)
5e4b4ca1b4 is described below
commit 5e4b4ca1b4e307dc8d1f2415a98ae7286d956051
Author: qiye <[email protected]>
AuthorDate: Thu Mar 7 14:13:26 2024 +0800
[fix](write)revert comparePostings due to write core (#195)
revert https://github.com/apache/doris-thirdparty/pull/156
---
src/core/CLucene/index/SDocumentWriter.cpp | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/src/core/CLucene/index/SDocumentWriter.cpp
b/src/core/CLucene/index/SDocumentWriter.cpp
index d11e39bf10..c757ba1a42 100644
--- a/src/core/CLucene/index/SDocumentWriter.cpp
+++ b/src/core/CLucene/index/SDocumentWriter.cpp
@@ -743,15 +743,23 @@ void SDocumentsWriter<T>::ThreadState::resetPostings() {
template<typename T>
int32_t SDocumentsWriter<T>::ThreadState::comparePostings(Posting *p1, Posting
*p2) {
- if constexpr (std::is_same_v<T, char>) {
- auto n1 = p1->term_.size();
- auto n2 = p2->term_.size();
- auto min = std::min(n1, n2);
- auto s1 = p1->term_.data();
- auto s2 = p2->term_.data();
- return StringUtil::string_compare(s1, n1, s2, n2, min);
- } else {
- return p1->term_.compare(p2->term_);
+ const T *pos1 = scharPool->buffers[p1->textStart >> CHAR_BLOCK_SHIFT] +
(p1->textStart & CHAR_BLOCK_MASK);
+ const T *pos2 = scharPool->buffers[p2->textStart >> CHAR_BLOCK_SHIFT] +
(p2->textStart & CHAR_BLOCK_MASK);
+ while (true) {
+ const auto c1 = static_cast<typename
std::make_unsigned<T>::type>(*pos1++);
+ const auto c2 = static_cast<typename
std::make_unsigned<T>::type>(*pos2++);
+ if (c1 < c2)
+ if (CLUCENE_END_OF_WORD == c2)
+ return 1;
+ else
+ return -1;
+ else if (c2 < c1)
+ if (CLUCENE_END_OF_WORD == c1)
+ return -1;
+ else
+ return 1;
+ else if (CLUCENE_END_OF_WORD == c1)
+ return 0;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]