diff --git a/server/src/main/java/org/elasticsearch/lucene/util/MatchAllBitSet.java b/server/src/main/java/org/elasticsearch/lucene/util/MatchAllBitSet.java index 5a54a45a230f0..7cce67199a218 100644 --- a/server/src/main/java/org/elasticsearch/lucene/util/MatchAllBitSet.java +++ b/server/src/main/java/org/elasticsearch/lucene/util/MatchAllBitSet.java @@ -10,7 +10,6 @@ import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.util.BitSet; -import org.apache.lucene.util.FixedBitSet; import org.apache.lucene.util.RamUsageEstimator; import java.io.IOException; @@ -21,7 +20,6 @@ public final class MatchAllBitSet extends BitSet { private static final long RAM_BYTES_USED = RamUsageEstimator.shallowSizeOfInstance(MatchAllBitSet.class); - private FixedBitSet bits; private final int numBits; public MatchAllBitSet(int numBits) { @@ -30,89 +28,54 @@ public MatchAllBitSet(int numBits) { @Override public void set(int i) { - if (bits != null) { - bits.set(i); - } + } @Override public boolean getAndSet(int i) { - if (bits != null) { - return bits.getAndSet(i); - } else { - return true; - } - } - - private void initializeBitSet() { - bits = new FixedBitSet(numBits); - bits.set(0, bits.length()); + return true; } @Override public void clear(int i) { - if (bits == null) { - initializeBitSet(); - } - bits.clear(i); + assert false : "MatchAllBitSet doesn't support clear"; + throw new UnsupportedOperationException("MatchAllBitSet doesn't support clear"); } @Override public void clear(int startIndex, int endIndex) { - if (bits == null) { - initializeBitSet(); - } - bits.clear(startIndex, endIndex); + assert false : "MatchAllBitSet doesn't support clear"; + throw new UnsupportedOperationException("MatchAllBitSet doesn't support clear"); } @Override public int cardinality() { - if (bits != null) { - return bits.cardinality(); - } else { - return numBits; - } + return numBits; } @Override public int approximateCardinality() { - if (bits != null) { - return bits.approximateCardinality(); - } else { - return numBits; - } + return numBits; } @Override public int prevSetBit(int index) { - if (bits != null) { - return bits.prevSetBit(index); - } else { - return index; - } + return index; } @Override public int nextSetBit(int index) { - if (bits != null) { - return bits.nextSetBit(index); - } else { - return index; - } + return index; } @Override public long ramBytesUsed() { - return RAM_BYTES_USED + (bits != null ? bits.ramBytesUsed() : 0); + return RAM_BYTES_USED; } @Override public boolean get(int index) { - if (bits != null) { - return bits.get(index); - } else { - return true; - } + return true; } @Override @@ -122,8 +85,6 @@ public int length() { @Override public void or(DocIdSetIterator iter) throws IOException { - if (bits != null) { - bits.or(iter); - } + } }