diff --git a/lucene/core/src/java/org/apache/lucene/index/SoftDeletesDirectoryReaderWrapper.java b/lucene/core/src/java/org/apache/lucene/index/SoftDeletesDirectoryReaderWrapper.java index dc350115c19..cf3e437ab9f 100644 --- a/lucene/core/src/java/org/apache/lucene/index/SoftDeletesDirectoryReaderWrapper.java +++ b/lucene/core/src/java/org/apache/lucene/index/SoftDeletesDirectoryReaderWrapper.java @@ -109,7 +109,7 @@ public final class SoftDeletesDirectoryReaderWrapper extends FilterDirectoryRead Bits liveDocs = reader.getLiveDocs(); final FixedBitSet bits; if (liveDocs != null) { - bits = SoftDeletesRetentionMergePolicy.cloneLiveDocs(liveDocs); + bits = FixedBitSet.copyOf(liveDocs); } else { bits = new FixedBitSet(reader.maxDoc()); bits.set(0, reader.maxDoc()); diff --git a/lucene/core/src/java/org/apache/lucene/index/SoftDeletesRetentionMergePolicy.java b/lucene/core/src/java/org/apache/lucene/index/SoftDeletesRetentionMergePolicy.java index b6f9a57420b..a309b7a8bb2 100644 --- a/lucene/core/src/java/org/apache/lucene/index/SoftDeletesRetentionMergePolicy.java +++ b/lucene/core/src/java/org/apache/lucene/index/SoftDeletesRetentionMergePolicy.java @@ -105,7 +105,7 @@ public final class SoftDeletesRetentionMergePolicy extends OneMergeWrappingMerge builder.add(retentionQuery, BooleanClause.Occur.FILTER); Scorer scorer = getScorer(builder.build(), wrappedReader); if (scorer != null) { - FixedBitSet cloneLiveDocs = cloneLiveDocs(liveDocs); + FixedBitSet cloneLiveDocs = FixedBitSet.copyOf(liveDocs); DocIdSetIterator iterator = scorer.iterator(); int numExtraLiveDocs = 0; while (iterator.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) { @@ -121,23 +121,6 @@ public final class SoftDeletesRetentionMergePolicy extends OneMergeWrappingMerge } } - /** - * Clones the given live docs - */ - static FixedBitSet cloneLiveDocs(Bits liveDocs) { - if (liveDocs instanceof FixedBitSet) { - return ((FixedBitSet) liveDocs).clone(); - } else { // mainly if we have asserting codec - FixedBitSet mutableBits = new FixedBitSet(liveDocs.length()); - for (int i = 0; i < liveDocs.length(); i++) { - if (liveDocs.get(i)) { - mutableBits.set(i); - } - } - return mutableBits; - } - } - private static Scorer getScorer(Query query, CodecReader reader) throws IOException { IndexSearcher s = new IndexSearcher(reader); s.setQueryCache(null);