mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 17:48:29 +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)
|
std::unique_ptr<MmapFileRAII> mmap_file_raii = nullptr)
|
||||||
: Chunk(row_nums, data, size, nullable, std::move(mmap_file_raii)),
|
: Chunk(row_nums, data, size, nullable, std::move(mmap_file_raii)),
|
||||||
dim_(dim),
|
dim_(dim),
|
||||||
element_size_(element_size){};
|
element_size_(element_size) {};
|
||||||
|
|
||||||
milvus::SpanBase
|
milvus::SpanBase
|
||||||
Span() const {
|
Span() const {
|
||||||
@ -180,10 +180,12 @@ class StringChunk : public Chunk {
|
|||||||
while (left <= right) {
|
while (left <= right) {
|
||||||
int mid = left + (right - left) / 2;
|
int mid = left + (right - left) / 2;
|
||||||
std::string_view midString = (*this)[mid];
|
std::string_view midString = (*this)[mid];
|
||||||
if (midString == target) {
|
auto cmp = midString.compare(target);
|
||||||
|
|
||||||
|
if (cmp == 0) {
|
||||||
result = mid; // Store the index of match
|
result = mid; // Store the index of match
|
||||||
right = mid - 1; // Continue searching in the left half
|
right = mid - 1; // Continue searching in the left half
|
||||||
} else if (midString < target) {
|
} else if (cmp < 0) {
|
||||||
// midString < target
|
// midString < target
|
||||||
left = mid + 1;
|
left = mid + 1;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user