Class BaseMergePolicyTestCase

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

public abstract class BaseMergePolicyTestCase extends LuceneTestCase
Base test case for MergePolicy.
  • Constructor Details

    • BaseMergePolicyTestCase

      public BaseMergePolicyTestCase()
  • Method Details

    • mergePolicy

      protected abstract MergePolicy mergePolicy()
      Create a new MergePolicy instance.
    • assertSegmentInfos

      protected abstract void assertSegmentInfos(MergePolicy policy, SegmentInfos infos) throws IOException
      Assert that the given segment infos match expectations of the merge policy, assuming segments that have only been either flushed or merged with this merge policy.
      Throws:
      IOException
    • assertMerge

      protected abstract void assertMerge(MergePolicy policy, MergePolicy.MergeSpecification merge) throws IOException
      Assert that the given merge matches expectations of the merge policy.
      Throws:
      IOException
    • testForceMergeNotNeeded

      public void testForceMergeNotNeeded() throws IOException
      Throws:
      IOException
    • testFindForcedDeletesMerges

      public void testFindForcedDeletesMerges() throws IOException
      Throws:
      IOException
    • makeSegmentCommitInfo

      protected static SegmentCommitInfo makeSegmentCommitInfo(String name, int maxDoc, int numDeletedDocs, double sizeMB, String source)
      Make a new SegmentCommitInfo with the given maxDoc, numDeletedDocs and sizeInBytes, which are usually the numbers that merge policies care about.
    • applyMerge

      protected static SegmentInfos applyMerge(SegmentInfos infos, MergePolicy.OneMerge merge, String mergedSegmentName, BaseMergePolicyTestCase.IOStats stats) throws IOException
      Apply a merge to a SegmentInfos instance, accumulating the number of written bytes into stats.
      Throws:
      IOException
    • applyDeletes

      protected static SegmentInfos applyDeletes(SegmentInfos infos, int numDeletes)
      Apply numDeletes uniformly across all segments of infos.
    • testSimulateAppendOnly

      public void testSimulateAppendOnly() throws IOException
      Simulate an append-only use-case, ie. there are no deletes.
      Throws:
      IOException
    • doTestSimulateAppendOnly

      protected void doTestSimulateAppendOnly(MergePolicy mergePolicy, int totalDocs, int maxDocsPerFlush) throws IOException
      Simulate an append-only use-case, ie. there are no deletes. totalDocs exist in the index in the end, and flushes contribute at most maxDocsPerFlush documents.
      Throws:
      IOException
    • testSimulateUpdates

      public void testSimulateUpdates() throws IOException
      Simulate an update use-case where documents are uniformly updated across segments.
      Throws:
      IOException
    • doTestSimulateUpdates

      protected void doTestSimulateUpdates(MergePolicy mergePolicy, int totalDocs, int maxDocsPerFlush) throws IOException
      Simulate an update use-case where documents are uniformly updated across segments. totalDocs exist in the index in the end, and flushes contribute at most maxDocsPerFlush documents.
      Throws:
      IOException