Skip to content

Commit

Permalink
Fix native engine vector format test (#2103)
Browse files Browse the repository at this point in the history
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 <balasvij@amazon.com>
  • Loading branch information
VijayanB committed Sep 13, 2024
1 parent 0df0613 commit 8277bf0
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String> 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<String> 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
Expand Down

0 comments on commit 8277bf0

Please sign in to comment.