From 6b5830a58a8210be766f22e58133ccdd0740ceb2 Mon Sep 17 00:00:00 2001 From: Vijayan Balasubramanian Date: Fri, 13 Sep 2024 14:53:03 -0700 Subject: [PATCH] Fix native engine vector format test (#2103) Previosuly we were not creating hnsw file on segment flush for faiss engine. After successfully integrating hnsw file creation, we forgot to update unit test. Here, we will confirm that required files are being created based on field type. Signed-off-by: Vijayan Balasubramanian (cherry picked from commit 8277bf0f57a045112dfa7098f64b26dac4b63652) --- .../NativeEngines990KnnVectorsFormatTests.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/test/java/org/opensearch/knn/index/codec/KNN990Codec/NativeEngines990KnnVectorsFormatTests.java b/src/test/java/org/opensearch/knn/index/codec/KNN990Codec/NativeEngines990KnnVectorsFormatTests.java index f1e48c3a1..90ed18d0d 100644 --- a/src/test/java/org/opensearch/knn/index/codec/KNN990Codec/NativeEngines990KnnVectorsFormatTests.java +++ b/src/test/java/org/opensearch/knn/index/codec/KNN990Codec/NativeEngines990KnnVectorsFormatTests.java @@ -81,9 +81,9 @@ public class NativeEngines990KnnVectorsFormatTests extends KNNTestCase { private static final Codec TESTING_CODEC = new UnitTestCodec(); private static final String FLAT_VECTOR_FILE_EXT = ".vec"; - private static final String HNSW_FILE_EXT = ".hnsw"; + private static final String FAISS_ENGINE_FILE_EXT = ".faiss"; private static final String FLOAT_VECTOR_FIELD = "float_field"; - private static final String FLOAT_VECTOR_FIELD_BINARY = "float_field_binary"; + private static final String FLOAT_VECTOR_FIELD_BINARY = "float_binary_field"; private static final String BYTE_VECTOR_FIELD = "byte_field"; private Directory dir; private RandomIndexWriter indexWriter; @@ -220,11 +220,11 @@ public void testNativeEngineVectorFormat_whenMultipleVectorFieldIndexed_thenSucc IndexSearcher searcher = new IndexSearcher(indexReader); final LeafReader leafReader = searcher.getLeafContexts().get(0).reader(); SegmentReader segmentReader = Lucene.segmentReader(leafReader); - final List hnswfiles = getFilesFromSegment(dir, HNSW_FILE_EXT); - // 0 hnsw files for now as we have not integrated graph creation here. - assertEquals(0, hnswfiles.size()); - assertEquals(hnswfiles.stream().filter(x -> x.contains(FLOAT_VECTOR_FIELD)).count(), 0); - assertEquals(hnswfiles.stream().filter(x -> x.contains(BYTE_VECTOR_FIELD)).count(), 0); + final List hnswfiles = getFilesFromSegment(dir, FAISS_ENGINE_FILE_EXT); + assertEquals(3, hnswfiles.size()); + assertEquals(hnswfiles.stream().filter(x -> x.contains(FLOAT_VECTOR_FIELD)).count(), 1); + assertEquals(hnswfiles.stream().filter(x -> x.contains(BYTE_VECTOR_FIELD)).count(), 1); + assertEquals(hnswfiles.stream().filter(x -> x.contains(FLOAT_VECTOR_FIELD_BINARY)).count(), 1); // Even setting IWC to not use compound file it still uses compound file, hence ensuring we don't check .vec // file in case segment uses compound format. use this seed once we fix this to validate everything is