Skip to content

Commit

Permalink
address PR feedback. Signed-off by: Akash Shankaran <akash.shankaran@…
Browse files Browse the repository at this point in the history
…intel.com>

Signed-off-by: Akash Shankaran <[email protected]>
  • Loading branch information
akashsha1 committed Sep 18, 2024
1 parent 1eabadf commit e8e28a2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
20 changes: 6 additions & 14 deletions src/main/java/org/opensearch/knn/index/KNNSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -512,20 +512,12 @@ public static boolean isFaissAVX2Disabled() {
}
}

public static boolean isFaissAVX512Disabled() {
try {
return KNNSettings.state().getSettingValue(KNNSettings.KNN_FAISS_AVX512_DISABLED);
} catch (Exception e) {
// In some UTs we identified that cluster setting is not set properly an leads to NPE. This check will avoid
// those cases and will still return the default value.
log.warn(
"Unable to get setting value {} from cluster settings. Using default value as {}",
KNN_FAISS_AVX512_DISABLED,
KNN_DEFAULT_FAISS_AVX512_DISABLED_VALUE,
e
);
return KNN_DEFAULT_FAISS_AVX512_DISABLED_VALUE;
}
public static boolean isFaissAVX512Disabled() {
String sValue = KNNSettings.state().getSettingValue(KNNSettings.KNN_FAISS_AVX512_DISABLED);
if (sValue != null) {
return KNNSettings.state().getSettingValue(KNNSettings.KNN_FAISS_AVX512_DISABLED);
}
return KNN_DEFAULT_FAISS_AVX512_DISABLED_VALUE;
}

public static Integer getFilteredExactSearchThreshold(final String indexName) {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/opensearch/knn/jni/FaissService.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
* src/main/java/org/opensearch/knn/index/query/KNNQueryResult.java
* src/main/java/org/opensearch/knn/common/KNNConstants.java
*/
@SuppressWarnings("deprecation")
class FaissService {

static {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/opensearch/knn/jni/PlatformUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Arrays;
import java.util.Locale;
Expand Down Expand Up @@ -109,7 +110,7 @@ public static boolean isAVX512SupportedBySystem() {
return Arrays.stream(avx512).allMatch(flags::contains);
});

} catch (Exception e) {
} catch (PrivilegedActionException e) {
logger.error("[KNN] Error reading file [{}]. [{}]", fileName, e.getMessage(), e);
}
}
Expand Down

0 comments on commit e8e28a2

Please sign in to comment.