Class BaseKnnVectorsFormatTestCase

java.lang.Object
org.junit.Assert
org.apache.lucene.tests.util.LuceneTestCase
org.apache.lucene.tests.index.BaseKnnVectorsFormatTestCase

public abstract class BaseKnnVectorsFormatTestCase extends LuceneTestCase
Base class aiming at testing vectors formats. To test a new format, all you need is to register a new Codec which uses it and extend this class and override getCodec().
WARNING: This API is experimental and might change in incompatible ways in the next release.
  • Constructor Details

    • BaseKnnVectorsFormatTestCase

      public BaseKnnVectorsFormatTestCase()
  • Method Details

    • addRandomFields

      protected void addRandomFields(Document doc)
      Add random fields to the provided document.
    • testFieldConstructor

      public void testFieldConstructor()
    • testFieldConstructorExceptions

      public void testFieldConstructorExceptions()
    • testFieldSetValue

      public void testFieldSetValue()
    • testIllegalDimChangeTwoDocs

      public void testIllegalDimChangeTwoDocs() throws Exception
      Throws:
      Exception
    • testIllegalSimilarityFunctionChange

      public void testIllegalSimilarityFunctionChange() throws Exception
      Throws:
      Exception
    • testIllegalDimChangeTwoWriters

      public void testIllegalDimChangeTwoWriters() throws Exception
      Throws:
      Exception
    • testIllegalSimilarityFunctionChangeTwoWriters

      public void testIllegalSimilarityFunctionChangeTwoWriters() throws Exception
      Throws:
      Exception
    • testAddIndexesDirectory0

      public void testAddIndexesDirectory0() throws Exception
      Throws:
      Exception
    • testAddIndexesDirectory1

      public void testAddIndexesDirectory1() throws Exception
      Throws:
      Exception
    • testAddIndexesDirectory01

      public void testAddIndexesDirectory01() throws Exception
      Throws:
      Exception
    • testIllegalDimChangeViaAddIndexesDirectory

      public void testIllegalDimChangeViaAddIndexesDirectory() throws Exception
      Throws:
      Exception
    • testIllegalSimilarityFunctionChangeViaAddIndexesDirectory

      public void testIllegalSimilarityFunctionChangeViaAddIndexesDirectory() throws Exception
      Throws:
      Exception
    • testIllegalDimChangeViaAddIndexesCodecReader

      public void testIllegalDimChangeViaAddIndexesCodecReader() throws Exception
      Throws:
      Exception
    • testIllegalSimilarityFunctionChangeViaAddIndexesCodecReader

      public void testIllegalSimilarityFunctionChangeViaAddIndexesCodecReader() throws Exception
      Throws:
      Exception
    • testIllegalDimChangeViaAddIndexesSlowCodecReader

      public void testIllegalDimChangeViaAddIndexesSlowCodecReader() throws Exception
      Throws:
      Exception
    • testIllegalSimilarityFunctionChangeViaAddIndexesSlowCodecReader

      public void testIllegalSimilarityFunctionChangeViaAddIndexesSlowCodecReader() throws Exception
      Throws:
      Exception
    • testIllegalMultipleValues

      public void testIllegalMultipleValues() throws Exception
      Throws:
      Exception
    • testIllegalDimensionTooLarge

      public void testIllegalDimensionTooLarge() throws Exception
      Throws:
      Exception
    • testIllegalEmptyVector

      public void testIllegalEmptyVector() throws Exception
      Throws:
      Exception
    • testDifferentCodecs1

      public void testDifferentCodecs1() throws Exception
      Throws:
      Exception
    • testDifferentCodecs2

      public void testDifferentCodecs2() throws Exception
      Throws:
      Exception
    • testInvalidKnnVectorFieldUsage

      public void testInvalidKnnVectorFieldUsage()
    • testDeleteAllVectorDocs

      public void testDeleteAllVectorDocs() throws Exception
      Throws:
      Exception
    • testKnnVectorFieldMissingFromOneSegment

      public void testKnnVectorFieldMissingFromOneSegment() throws Exception
      Throws:
      Exception
    • testSparseVectors

      public void testSparseVectors() throws Exception
      Throws:
      Exception
    • testIndexedValueNotAliased

      public void testIndexedValueNotAliased() throws Exception
      Throws:
      Exception
    • testSortedIndex

      public void testSortedIndex() throws Exception
      Throws:
      Exception
    • testIndexMultipleKnnVectorFields

      public void testIndexMultipleKnnVectorFields() throws Exception
      Throws:
      Exception
    • testRandom

      public void testRandom() throws Exception
      Index random vectors, sometimes skipping documents, sometimes deleting a document, sometimes merging, sometimes sorting the index, and verify that the expected values can be read back consistently.
      Throws:
      Exception
    • testSearchWithVisitedLimit

      public void testSearchWithVisitedLimit() throws Exception
      Tests whether KnnVectorsReader.search(java.lang.String, float[], int, org.apache.lucene.util.Bits, int) implementations obey the limit on the number of visited vectors. This test is a best-effort attempt to capture the right behavior, and isn't meant to define a strict requirement on behavior.
      Throws:
      Exception
    • testRandomWithUpdatesAndGraph

      public void testRandomWithUpdatesAndGraph() throws Exception
      Index random vectors, sometimes skipping documents, sometimes updating a document, sometimes merging, sometimes sorting the index, using an HNSW similarity function so as to also produce a graph, and verify that the expected values can be read back consistently.
      Throws:
      Exception
    • testCheckIndexIncludesVectors

      public void testCheckIndexIncludesVectors() throws Exception
      Throws:
      Exception
    • testSimilarityFunctionIdentifiers

      public void testSimilarityFunctionIdentifiers()
    • testAdvance

      public void testAdvance() throws Exception
      Throws:
      Exception
    • testVectorValuesReportCorrectDocs

      public void testVectorValuesReportCorrectDocs() throws Exception
      Throws:
      Exception
    • getCodec

      protected abstract Codec getCodec()
      Returns the codec to run tests against
    • getCreatedVersionMajor

      protected int getCreatedVersionMajor()
      Returns the major version that this codec is compatible with.
    • applyCreatedVersionMajor

      protected final <D extends Directory> D applyCreatedVersionMajor(D d) throws IOException
      Set the created version of the given Directory and return it.
      Throws:
      IOException
    • setUp

      public void setUp() throws Exception
      Description copied from class: LuceneTestCase
      For subclasses to override. Overrides must call super.setUp().
      Overrides:
      setUp in class LuceneTestCase
      Throws:
      Exception
    • tearDown

      public void tearDown() throws Exception
      Description copied from class: LuceneTestCase
      For subclasses to override. Overrides must call super.tearDown().
      Overrides:
      tearDown in class LuceneTestCase
      Throws:
      Exception
    • excludedExtensionsFromByteCounts

      protected Collection<String> excludedExtensionsFromByteCounts()
      Return the list of extensions that should be excluded from byte counts when comparing indices that store the same content.
    • testMergeStability

      public void testMergeStability() throws Exception
      The purpose of this test is to make sure that bulk merge doesn't accumulate useless data over runs.
      Throws:
      Exception
    • mergeIsStable

      protected boolean mergeIsStable()
    • testMultiClose

      public void testMultiClose() throws IOException
      Calls close multiple times on closeable codec apis
      Throws:
      IOException
    • testRandomExceptions

      public void testRandomExceptions() throws Exception
      Tests exception handling on write and openInput/createOutput
      Throws:
      Exception
    • shouldTestMergeInstance

      protected boolean shouldTestMergeInstance()
      Returns false if only the regular fields reader should be tested, and true if only the merge instance should be tested.
    • maybeWrapWithMergingReader

      protected final DirectoryReader maybeWrapWithMergingReader(DirectoryReader r) throws IOException
      Throws:
      IOException
    • testCheckIntegrityReadsAllBytes

      public void testCheckIntegrityReadsAllBytes() throws Exception
      This test is a best effort at verifying that checkIntegrity doesn't miss any files. It tests that the combination of opening a reader and calling checkIntegrity on it reads all bytes of all files.
      Throws:
      Exception