Skip to content

Commit

Permalink
enhance: Update knowhere commit (#34223)
Browse files Browse the repository at this point in the history
Signed-off-by: Cai Yudong <yudong.cai@zilliz.com>
  • Loading branch information
cydrain committed Jun 27, 2024
1 parent f2107ad commit ad90360
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 40 deletions.
7 changes: 3 additions & 4 deletions internal/core/src/common/QueryResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct VectorIterator {
return !heap_.empty();
}
bool
AddIterator(std::shared_ptr<knowhere::IndexNode::iterator> iter) {
AddIterator(knowhere::IndexNode::IteratorPtr iter) {
if (!sealed && iter != nullptr) {
iterators_.emplace_back(iter);
return true;
Expand Down Expand Up @@ -130,7 +130,7 @@ struct VectorIterator {
}

private:
std::vector<std::shared_ptr<knowhere::IndexNode::iterator>> iterators_;
std::vector<knowhere::IndexNode::IteratorPtr> iterators_;
std::priority_queue<std::shared_ptr<OffsetDisPair>,
std::vector<std::shared_ptr<OffsetDisPair>>,
OffsetDisPairComparator>
Expand Down Expand Up @@ -161,8 +161,7 @@ struct SearchResult {
int64_t nq,
int chunk_count,
int64_t rows_per_chunk,
const std::vector<std::shared_ptr<knowhere::IndexNode::iterator>>&
kw_iterators) {
const std::vector<knowhere::IndexNode::IteratorPtr>& kw_iterators) {
AssertInfo(kw_iterators.size() == nq * chunk_count,
"kw_iterators count:{} is not equal to nq*chunk_count:{}, "
"wrong state",
Expand Down
10 changes: 5 additions & 5 deletions internal/core/src/index/VectorDiskIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ VectorDiskAnnIndex<T>::Query(const DatasetPtr dataset,
search_config[RANGE_FILTER],
GetMetricType());
}
auto res = index_.RangeSearch(*dataset, search_config, bitset);
auto res = index_.RangeSearch(dataset, search_config, bitset);

if (!res.has_value()) {
PanicInfo(ErrorCode::UnexpectedError,
Expand All @@ -386,7 +386,7 @@ VectorDiskAnnIndex<T>::Query(const DatasetPtr dataset,
return ReGenRangeSearchResult(
res.value(), topk, num_queries, GetMetricType());
} else {
auto res = index_.Search(*dataset, search_config, bitset);
auto res = index_.Search(dataset, search_config, bitset);
if (!res.has_value()) {
PanicInfo(ErrorCode::UnexpectedError,
fmt::format("failed to search: {}: {}",
Expand Down Expand Up @@ -419,11 +419,11 @@ VectorDiskAnnIndex<T>::Query(const DatasetPtr dataset,
}

template <typename T>
knowhere::expected<std::vector<std::shared_ptr<knowhere::IndexNode::iterator>>>
knowhere::expected<std::vector<knowhere::IndexNode::IteratorPtr>>
VectorDiskAnnIndex<T>::VectorIterators(const DatasetPtr dataset,
const knowhere::Json& conf,
const BitsetView& bitset) const {
return this->index_.AnnIterator(*dataset, conf, bitset);
return this->index_.AnnIterator(dataset, conf, bitset);
}

template <typename T>
Expand All @@ -440,7 +440,7 @@ VectorDiskAnnIndex<T>::GetVector(const DatasetPtr dataset) const {
PanicInfo(ErrorCode::UnexpectedError,
"failed to get vector, index is sparse");
}
auto res = index_.GetVectorByIds(*dataset);
auto res = index_.GetVectorByIds(dataset);
if (!res.has_value()) {
PanicInfo(ErrorCode::UnexpectedError,
fmt::format("failed to get vector: {}: {}",
Expand Down
3 changes: 1 addition & 2 deletions internal/core/src/index/VectorDiskIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ class VectorDiskAnnIndex : public VectorIndex {

void CleanLocalData() override;

knowhere::expected<
std::vector<std::shared_ptr<knowhere::IndexNode::iterator>>>
knowhere::expected<std::vector<knowhere::IndexNode::IteratorPtr>>
VectorIterators(const DatasetPtr dataset,
const knowhere::Json& json,
const BitsetView& bitset) const override;
Expand Down
3 changes: 1 addition & 2 deletions internal/core/src/index/VectorIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ class VectorIndex : public IndexBase {
const BitsetView& bitset,
SearchResult& search_result) const = 0;

virtual knowhere::expected<
std::vector<std::shared_ptr<knowhere::IndexNode::iterator>>>
virtual knowhere::expected<std::vector<knowhere::IndexNode::IteratorPtr>>
VectorIterators(const DatasetPtr dataset,
const knowhere::Json& json,
const BitsetView& bitset) const {
Expand Down
16 changes: 8 additions & 8 deletions internal/core/src/index/VectorMemIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ VectorMemIndex<T>::UploadV2(const Config& config) {
}

template <typename T>
knowhere::expected<std::vector<std::shared_ptr<knowhere::IndexNode::iterator>>>
knowhere::expected<std::vector<knowhere::IndexNode::IteratorPtr>>
VectorMemIndex<T>::VectorIterators(const milvus::DatasetPtr dataset,
const knowhere::Json& conf,
const milvus::BitsetView& bitset) const {
return this->index_.AnnIterator(*dataset, conf, bitset);
return this->index_.AnnIterator(dataset, conf, bitset);
}

template <typename T>
Expand Down Expand Up @@ -434,7 +434,7 @@ VectorMemIndex<T>::BuildWithDataset(const DatasetPtr& dataset,
SetDim(dataset->GetDim());

knowhere::TimeRecorder rc("BuildWithoutIds", 1);
auto stat = index_.Build(*dataset, index_config);
auto stat = index_.Build(dataset, index_config);
if (stat != knowhere::Status::success)
PanicInfo(ErrorCode::IndexBuildError,
"failed to build index, " + KnowhereStatusString(stat));
Expand Down Expand Up @@ -572,7 +572,7 @@ VectorMemIndex<T>::AddWithDataset(const DatasetPtr& dataset,
index_config.update(config);

knowhere::TimeRecorder rc("AddWithDataset", 1);
auto stat = index_.Add(*dataset, index_config);
auto stat = index_.Add(dataset, index_config);
if (stat != knowhere::Status::success)
PanicInfo(ErrorCode::IndexBuildError,
"failed to append index, " + KnowhereStatusString(stat));
Expand Down Expand Up @@ -601,7 +601,7 @@ VectorMemIndex<T>::Query(const DatasetPtr dataset,
GetMetricType());
}
milvus::tracer::AddEvent("start_knowhere_index_range_search");
auto res = index_.RangeSearch(*dataset, search_conf, bitset);
auto res = index_.RangeSearch(dataset, search_conf, bitset);
milvus::tracer::AddEvent("finish_knowhere_index_range_search");
if (!res.has_value()) {
PanicInfo(ErrorCode::UnexpectedError,
Expand All @@ -615,7 +615,7 @@ VectorMemIndex<T>::Query(const DatasetPtr dataset,
return result;
} else {
milvus::tracer::AddEvent("start_knowhere_index_search");
auto res = index_.Search(*dataset, search_conf, bitset);
auto res = index_.Search(dataset, search_conf, bitset);
milvus::tracer::AddEvent("finish_knowhere_index_search");
if (!res.has_value()) {
PanicInfo(ErrorCode::UnexpectedError,
Expand Down Expand Up @@ -662,7 +662,7 @@ VectorMemIndex<T>::GetVector(const DatasetPtr dataset) const {
"failed to get vector, index is sparse");
}

auto res = index_.GetVectorByIds(*dataset);
auto res = index_.GetVectorByIds(dataset);
if (!res.has_value()) {
PanicInfo(ErrorCode::UnexpectedError,
"failed to get vector, " + KnowhereStatusString(res.error()));
Expand All @@ -680,7 +680,7 @@ VectorMemIndex<T>::GetVector(const DatasetPtr dataset) const {
template <typename T>
std::unique_ptr<const knowhere::sparse::SparseRow<float>[]>
VectorMemIndex<T>::GetSparseVector(const DatasetPtr dataset) const {
auto res = index_.GetVectorByIds(*dataset);
auto res = index_.GetVectorByIds(dataset);
if (!res.has_value()) {
PanicInfo(ErrorCode::UnexpectedError,
"failed to get vector, " + KnowhereStatusString(res.error()));
Expand Down
3 changes: 1 addition & 2 deletions internal/core/src/index/VectorMemIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ class VectorMemIndex : public VectorIndex {
BinarySet
UploadV2(const Config& config = {}) override;

knowhere::expected<
std::vector<std::shared_ptr<knowhere::IndexNode::iterator>>>
knowhere::expected<std::vector<knowhere::IndexNode::IteratorPtr>>
VectorIterators(const DatasetPtr dataset,
const knowhere::Json& json,
const BitsetView& bitset) const override;
Expand Down
3 changes: 1 addition & 2 deletions internal/core/src/query/GroupByOperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ PrepareVectorIteratorsFromIndex(const SearchInfo& search_info,
if (search_info.group_by_field_id_.has_value()) {
try {
auto search_conf = search_info.search_params_;
knowhere::expected<
std::vector<std::shared_ptr<knowhere::IndexNode::iterator>>>
knowhere::expected<std::vector<knowhere::IndexNode::IteratorPtr>>
iterators_val =
index.VectorIterators(dataset, search_conf, bitset);
if (iterators_val.has_value()) {
Expand Down
3 changes: 1 addition & 2 deletions internal/core/src/query/SearchBruteForce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ BruteForceSearchIterators(const dataset::SearchDataset& dataset,
}
auto search_cfg = PrepareBFSearchParams(search_info);

knowhere::expected<
std::vector<std::shared_ptr<knowhere::IndexNode::iterator>>>
knowhere::expected<std::vector<knowhere::IndexNode::IteratorPtr>>
iterators_val;
switch (data_type) {
case DataType::VECTOR_FLOAT:
Expand Down
9 changes: 4 additions & 5 deletions internal/core/src/query/SubSearchResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class SubSearchResult {
int64_t topk,
const MetricType& metric_type,
int64_t round_decimal,
const std::vector<std::shared_ptr<knowhere::IndexNode::iterator>>&
iters)
const std::vector<knowhere::IndexNode::IteratorPtr>& iters)
: num_queries_(num_queries),
topk_(topk),
round_decimal_(round_decimal),
Expand All @@ -47,7 +46,7 @@ class SubSearchResult {
topk,
metric_type,
round_decimal,
std::vector<std::shared_ptr<knowhere::IndexNode::iterator>>{}) {
std::vector<knowhere::IndexNode::IteratorPtr>{}) {
}

SubSearchResult(SubSearchResult&& other) noexcept
Expand Down Expand Up @@ -114,7 +113,7 @@ class SubSearchResult {
void
merge(const SubSearchResult& other);

const std::vector<std::shared_ptr<knowhere::IndexNode::iterator>>&
const std::vector<knowhere::IndexNode::IteratorPtr>&
chunk_iterators() {
return this->chunk_iterators_;
}
Expand All @@ -131,7 +130,7 @@ class SubSearchResult {
knowhere::MetricType metric_type_;
std::vector<int64_t> seg_offsets_;
std::vector<float> distances_;
std::vector<std::shared_ptr<knowhere::IndexNode::iterator>>
std::vector<knowhere::IndexNode::IteratorPtr>
chunk_iterators_;
};

Expand Down
2 changes: 1 addition & 1 deletion internal/core/thirdparty/knowhere/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

# Update KNOWHERE_VERSION for the first occurrence
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES "")
set( KNOWHERE_VERSION d69e0f33 )
set( KNOWHERE_VERSION 6bd3ba4c )
set( GIT_REPOSITORY "https://github.com/zilliztech/knowhere.git")
message(STATUS "Knowhere repo: ${GIT_REPOSITORY}")
message(STATUS "Knowhere version: ${KNOWHERE_VERSION}")
Expand Down
10 changes: 5 additions & 5 deletions internal/core/unittest/test_c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1958,8 +1958,8 @@ TEST(CApiTest, LoadIndexInfo) {
{knowhere::indexparam::NPROBE, 4}};

auto database = knowhere::GenDataSet(N, DIM, raw_data.data());
indexing.Train(*database, conf);
indexing.Add(*database, conf);
indexing.Train(database, conf);
indexing.Add(database, conf);
EXPECT_EQ(indexing.Count(), N);
EXPECT_EQ(indexing.Dim(), DIM);
knowhere::BinarySet binary_set;
Expand Down Expand Up @@ -2009,8 +2009,8 @@ TEST(CApiTest, LoadIndexSearch) {
{knowhere::indexparam::NPROBE, 4}};

auto database = knowhere::GenDataSet(N, DIM, raw_data.data());
indexing.Train(*database, conf);
indexing.Add(*database, conf);
indexing.Train(database, conf);
indexing.Add(database, conf);

EXPECT_EQ(indexing.Count(), N);
EXPECT_EQ(indexing.Dim(), DIM);
Expand All @@ -2033,7 +2033,7 @@ TEST(CApiTest, LoadIndexSearch) {
auto query_dataset =
knowhere::GenDataSet(num_query, DIM, raw_data.data() + BIAS * DIM);

auto result = indexing.Search(*query_dataset, conf, nullptr);
auto result = indexing.Search(query_dataset, conf, nullptr);
}

TEST(CApiTest, Indexing_Without_Predicate) {
Expand Down
3 changes: 1 addition & 2 deletions internal/core/unittest/test_indexing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,7 @@ TEST(Indexing, Iterator) {
searchInfo.search_params_ = search_conf;
auto vec_index = dynamic_cast<index::VectorIndex*>(index.get());

knowhere::expected<
std::vector<std::shared_ptr<knowhere::IndexNode::iterator>>>
knowhere::expected<std::vector<knowhere::IndexNode::IteratorPtr>>
kw_iterators = vec_index->VectorIterators(
query_ds, searchInfo.search_params_, view);
ASSERT_TRUE(kw_iterators.has_value());
Expand Down

0 comments on commit ad90360

Please sign in to comment.