Skip to content

[8.19] Ensure single segment in test (#131077) #131276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.NoMergePolicy;
import org.apache.lucene.index.TieredMergePolicy;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.tests.index.RandomIndexWriter;
Expand Down Expand Up @@ -389,11 +390,11 @@ private IndexReader initIndex(Directory directory, int size, int commitEvery) th
return DirectoryReader.open(directory);
}

private IndexReader initIndexLongField(Directory directory, int size, int commitEvery) throws IOException {
private IndexReader initIndexLongField(Directory directory, int size, int commitEvery, boolean forceMerge) throws IOException {
try (
IndexWriter writer = new IndexWriter(
directory,
newIndexWriterConfig().setMergePolicy(NoMergePolicy.INSTANCE).setMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH)
newIndexWriterConfig().setMergePolicy(new TieredMergePolicy()).setMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH)
)
) {
for (int d = 0; d < size; d++) {
Expand All @@ -412,6 +413,10 @@ private IndexReader initIndexLongField(Directory directory, int size, int commit
writer.commit();
}
}

if (forceMerge) {
writer.forceMerge(1);
}
}
return DirectoryReader.open(directory);
}
Expand Down Expand Up @@ -923,7 +928,7 @@ private void testLoadLong(boolean shuffle, boolean manySegments) throws IOExcept
int numDocs = between(10, 500);
initMapping();
keyToTags.clear();
reader = initIndexLongField(directory, numDocs, manySegments ? commitEvery(numDocs) : numDocs);
reader = initIndexLongField(directory, numDocs, manySegments ? commitEvery(numDocs) : numDocs, manySegments == false);

DriverContext driverContext = driverContext();
List<Page> input = CannedSourceOperator.collectPages(sourceOperator(driverContext, numDocs));
Expand Down