mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 17:18:35 +08:00
enhance: optimize the performance of binary_search_string (#44470)
pr: #44469 Signed-off-by: sunby <sunbingyi1992@gmail.com>
This commit is contained in:
parent
8b0bfe4cd8
commit
c5a7845531
@ -113,7 +113,7 @@ class FixedWidthChunk : public Chunk {
|
||||
std::unique_ptr<MmapFileRAII> mmap_file_raii = nullptr)
|
||||
: Chunk(row_nums, data, size, nullable, std::move(mmap_file_raii)),
|
||||
dim_(dim),
|
||||
element_size_(element_size){};
|
||||
element_size_(element_size) {};
|
||||
|
||||
milvus::SpanBase
|
||||
Span() const {
|
||||
@ -180,10 +180,12 @@ class StringChunk : public Chunk {
|
||||
while (left <= right) {
|
||||
int mid = left + (right - left) / 2;
|
||||
std::string_view midString = (*this)[mid];
|
||||
if (midString == target) {
|
||||
auto cmp = midString.compare(target);
|
||||
|
||||
if (cmp == 0) {
|
||||
result = mid; // Store the index of match
|
||||
right = mid - 1; // Continue searching in the left half
|
||||
} else if (midString < target) {
|
||||
} else if (cmp < 0) {
|
||||
// midString < target
|
||||
left = mid + 1;
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user