forked from opensearch-project/k-NN
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into optimize-exact-search
Signed-off-by: Junqiu Lei <[email protected]>
- Loading branch information
Showing
11 changed files
with
255 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
jni/patches/nmslib/0003-Adding-two-apis-using-stream-to-load-save-in-Hnsw.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
From 7e099ec111e5c9db4b243da249c73f0ecc206281 Mon Sep 17 00:00:00 2001 | ||
From: Dooyong Kim <[email protected]> | ||
Date: Thu, 26 Sep 2024 15:20:53 -0700 | ||
Subject: [PATCH] Adding two apis using stream to load/save in Hnsw. | ||
|
||
Signed-off-by: Dooyong Kim <[email protected]> | ||
--- | ||
similarity_search/include/method/hnsw.h | 4 +++ | ||
similarity_search/src/method/hnsw.cc | 44 +++++++++++++++++++++++++ | ||
2 files changed, 48 insertions(+) | ||
|
||
diff --git a/similarity_search/include/method/hnsw.h b/similarity_search/include/method/hnsw.h | ||
index 57d99d0..7ff3f3d 100644 | ||
--- a/similarity_search/include/method/hnsw.h | ||
+++ b/similarity_search/include/method/hnsw.h | ||
@@ -455,8 +455,12 @@ namespace similarity { | ||
public: | ||
virtual void SaveIndex(const string &location) override; | ||
|
||
+ void SaveIndexWithStream(std::ostream& output); | ||
+ | ||
virtual void LoadIndex(const string &location) override; | ||
|
||
+ void LoadIndexWithStream(std::istream& in); | ||
+ | ||
Hnsw(bool PrintProgress, const Space<dist_t> &space, const ObjectVector &data); | ||
void CreateIndex(const AnyParams &IndexParams) override; | ||
|
||
diff --git a/similarity_search/src/method/hnsw.cc b/similarity_search/src/method/hnsw.cc | ||
index 35b372c..e7a2c9e 100644 | ||
--- a/similarity_search/src/method/hnsw.cc | ||
+++ b/similarity_search/src/method/hnsw.cc | ||
@@ -771,6 +771,25 @@ namespace similarity { | ||
output.close(); | ||
} | ||
|
||
+ template <typename dist_t> | ||
+ void Hnsw<dist_t>::SaveIndexWithStream(std::ostream &output) { | ||
+ output.exceptions(ios::badbit | ios::failbit); | ||
+ | ||
+ unsigned int optimIndexFlag = data_level0_memory_ != nullptr; | ||
+ | ||
+ writeBinaryPOD(output, optimIndexFlag); | ||
+ | ||
+ if (!optimIndexFlag) { | ||
+#if USE_TEXT_REGULAR_INDEX | ||
+ SaveRegularIndexText(output); | ||
+#else | ||
+ SaveRegularIndexBin(output); | ||
+#endif | ||
+ } else { | ||
+ SaveOptimizedIndex(output); | ||
+ } | ||
+ } | ||
+ | ||
template <typename dist_t> | ||
void | ||
Hnsw<dist_t>::SaveOptimizedIndex(std::ostream& output) { | ||
@@ -1021,6 +1040,31 @@ namespace similarity { | ||
|
||
} | ||
|
||
+ template <typename dist_t> | ||
+ void Hnsw<dist_t>::LoadIndexWithStream(std::istream& input) { | ||
+ LOG(LIB_INFO) << "Loading index from an input stream."; | ||
+ CHECK_MSG(input, "Cannot open file for reading with an input stream"); | ||
+ | ||
+ input.exceptions(ios::badbit | ios::failbit); | ||
+ | ||
+#if USE_TEXT_REGULAR_INDEX | ||
+ LoadRegularIndexText(input); | ||
+#else | ||
+ unsigned int optimIndexFlag= 0; | ||
+ | ||
+ readBinaryPOD(input, optimIndexFlag); | ||
+ | ||
+ if (!optimIndexFlag) { | ||
+ LoadRegularIndexBin(input); | ||
+ } else { | ||
+ LoadOptimizedIndex(input); | ||
+ } | ||
+#endif | ||
+ | ||
+ LOG(LIB_INFO) << "Finished loading index"; | ||
+ visitedlistpool = new VisitedListPool(1, totalElementsStored_); | ||
+ } | ||
+ | ||
|
||
template <typename dist_t> | ||
void | ||
-- | ||
2.39.5 (Apple Git-154) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## Version 2.17.1.0 Release Notes | ||
|
||
Compatible with OpenSearch 2.17.1 | ||
|
||
### Enhancements | ||
* Adds concurrent segment search support for mode auto [#2111](https://github.com/opensearch-project/k-NN/pull/2111) | ||
### Bug Fixes | ||
* Change min oversample to 1 [#2117](https://github.com/opensearch-project/k-NN/pull/2117) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters