-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate FSDirectory dependency and FileWatcher.
Signed-off-by: Dooyong Kim <[email protected]>
- Loading branch information
Dooyong Kim
committed
Oct 17, 2024
1 parent
f383f82
commit 94058d3
Showing
14 changed files
with
164 additions
and
121 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
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
37 changes: 37 additions & 0 deletions
37
src/main/java/org/opensearch/knn/index/codec/util/NativeMemoryCacheKeyHelper.java
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,37 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.knn.index.codec.util; | ||
|
||
import org.apache.lucene.index.SegmentInfo; | ||
|
||
import java.util.Base64; | ||
|
||
public final class NativeMemoryCacheKeyHelper { | ||
private NativeMemoryCacheKeyHelper() {} | ||
|
||
/** | ||
* Construct a unique cache key for look-up operation in {@link org.opensearch.knn.index.memory.NativeMemoryCacheManager} | ||
* | ||
* @param vectorIndexFileName Vector index file name. Ex: _0_165_test_field.faiss. | ||
* @param segmentInfo Segment info object representing a logical segment unit containing a vector index. | ||
* @return Unique cache key that can be used for look-up and invalidating in | ||
* {@link org.opensearch.knn.index.memory.NativeMemoryCacheManager} | ||
*/ | ||
public static String constructCacheKey(final String vectorIndexFileName, final SegmentInfo segmentInfo) { | ||
final String segmentId = Base64.getEncoder().encodeToString(segmentInfo.getId()); | ||
final String cacheKey = vectorIndexFileName + "@" + segmentId; | ||
return cacheKey; | ||
} | ||
|
||
public static String extractVectorIndexFileName(final String cacheKey) { | ||
final int indexOfDelimiter = cacheKey.indexOf('@'); | ||
if (indexOfDelimiter != -1) { | ||
final String vectorFileName = cacheKey.substring(0, indexOfDelimiter); | ||
return vectorFileName; | ||
} | ||
return null; | ||
} | ||
} |
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
Oops, something went wrong.