From 0b96f39013c433803186c0a23ed602aa38e81d6a Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Sun, 26 Nov 2017 18:43:53 -0500 Subject: [PATCH 1/7] Simplify MultiSnapshot#SeqNoSet Today, we maintain two sets in a SeqNoSet: ongoing sets and completed sets. We can remove the completed sets by releasing the internal bitset of a CountedBitSet when all its bits are set. Relates #27268 --- .../index/translog/MultiSnapshot.java | 59 ++++++++++--------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/index/translog/MultiSnapshot.java b/core/src/main/java/org/elasticsearch/index/translog/MultiSnapshot.java index cc9dbdeb63f1d..8aa9fedbe9d46 100644 --- a/core/src/main/java/org/elasticsearch/index/translog/MultiSnapshot.java +++ b/core/src/main/java/org/elasticsearch/index/translog/MultiSnapshot.java @@ -19,9 +19,8 @@ package org.elasticsearch.index.translog; -import com.carrotsearch.hppc.LongHashSet; import com.carrotsearch.hppc.LongObjectHashMap; -import com.carrotsearch.hppc.LongSet; +import com.carrotsearch.hppc.cursors.ObjectCursor; import org.apache.lucene.util.FixedBitSet; import org.elasticsearch.index.seqno.SequenceNumbers; @@ -85,11 +84,13 @@ public void close() throws IOException { } /** - * A wrapper of {@link FixedBitSet} but allows to check if all bits are set in O(1). + * A {@link CountedBitSet} wraps a {@link FixedBitSet} but automatically releases the internal bitset + * when all bits are set to reduce memory usage. This structure can work well for sequence numbers + * from translog as these numbers are likely to form contiguous ranges (eg. filling all bits). */ private static final class CountedBitSet { - private short onBits; - private final FixedBitSet bitset; + private short onBits; // Number of bits are set. + private FixedBitSet bitset; CountedBitSet(short numBits) { assert numBits > 0; @@ -99,26 +100,33 @@ private static final class CountedBitSet { boolean getAndSet(int index) { assert index >= 0; + assert bitset == null || onBits < bitset.length() : "Bitset should be cleared when all bits are set"; + + // A null bitset means all bits are set. + if (bitset == null) { + return true; + } + boolean wasOn = bitset.getAndSet(index); if (wasOn == false) { onBits++; + // Once all bits are set, we can simply just return YES for all indexes. + // This allows us to clear the internal bitset and use null check as the guard. + if (onBits == bitset.length()) { + bitset = null; + } } return wasOn; } boolean hasAllBitsOn() { - return onBits == bitset.length(); + return bitset == null; } } - /** - * Sequence numbers from translog are likely to form contiguous ranges, - * thus collapsing a completed bitset into a single entry will reduce memory usage. - */ static final class SeqNoSet { static final short BIT_SET_SIZE = 1024; - private final LongSet completedSets = new LongHashSet(); - private final LongObjectHashMap ongoingSets = new LongObjectHashMap<>(); + private final LongObjectHashMap bitSets = new LongObjectHashMap<>(); /** * Marks this sequence number and returns true if it is seen before. @@ -126,33 +134,28 @@ static final class SeqNoSet { boolean getAndSet(long value) { assert value >= 0; final long key = value / BIT_SET_SIZE; - - if (completedSets.contains(key)) { - return true; - } - - CountedBitSet bitset = ongoingSets.get(key); + CountedBitSet bitset = bitSets.get(key); if (bitset == null) { bitset = new CountedBitSet(BIT_SET_SIZE); - ongoingSets.put(key, bitset); - } - - final boolean wasOn = bitset.getAndSet(Math.toIntExact(value % BIT_SET_SIZE)); - if (bitset.hasAllBitsOn()) { - ongoingSets.remove(key); - completedSets.add(key); + bitSets.put(key, bitset); } - return wasOn; + return bitset.getAndSet(Math.toIntExact(value % BIT_SET_SIZE)); } // For testing long completeSetsSize() { - return completedSets.size(); + int completedBitSets = 0; + for (ObjectCursor bitset : bitSets.values()) { + if (bitset.value.hasAllBitsOn()) { + completedBitSets++; + } + } + return completedBitSets; } // For testing long ongoingSetsSize() { - return ongoingSets.size(); + return bitSets.size() - completeSetsSize(); } } } From d5c91424e90613037bccda5266e3dabbe414a280 Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Thu, 30 Nov 2017 17:23:07 -0500 Subject: [PATCH 2/7] move bitset to common --- .../common/util/CountedBitSet.java | 106 ++++++++++++++++++ .../index/translog/MultiSnapshot.java | 57 ++-------- .../common/util/CountedBitSetTests.java | 97 ++++++++++++++++ 3 files changed, 213 insertions(+), 47 deletions(-) create mode 100644 core/src/main/java/org/elasticsearch/common/util/CountedBitSet.java create mode 100644 core/src/test/java/org/elasticsearch/common/util/CountedBitSetTests.java diff --git a/core/src/main/java/org/elasticsearch/common/util/CountedBitSet.java b/core/src/main/java/org/elasticsearch/common/util/CountedBitSet.java new file mode 100644 index 0000000000000..21c44d83f3858 --- /dev/null +++ b/core/src/main/java/org/elasticsearch/common/util/CountedBitSet.java @@ -0,0 +1,106 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.common.util; + +import org.apache.lucene.util.BitSet; +import org.apache.lucene.util.FixedBitSet; + +/** + * A {@link CountedBitSet} wraps a {@link FixedBitSet} but automatically releases the internal bitset + * when all bits are set to reduce memory usage. This structure can work well for sequence numbers + * from translog as these numbers are likely to form contiguous ranges (eg. filling all bits). + */ +public final class CountedBitSet extends BitSet { + private short onBits; // Number of bits are set. + private FixedBitSet bitset; + + public CountedBitSet(short numBits) { + assert numBits > 0; + this.onBits = 0; + this.bitset = new FixedBitSet(numBits); + } + + @Override + public boolean get(int index) { + assert index >= 0; + assert bitset == null || onBits < bitset.length() : "Bitset should be released when all bits are set"; + + return bitset == null ? true : bitset.get(index); + } + + @Override + public void set(int index) { + assert index >= 0; + assert bitset == null || onBits < bitset.length() : "Bitset should be released when all bits are set"; + + // Ignore set when bitset is full. + if (bitset != null) { + boolean wasOn = bitset.getAndSet(index); + if (wasOn == false) { + onBits++; + // Once all bits are set, we can simply just return YES for all indexes. + // This allows us to clear the internal bitset and use null check as the guard. + if (onBits == bitset.length()) { + bitset = null; + } + } + } + } + + @Override + public void clear(int startIndex, int endIndex) { + throw new UnsupportedOperationException("Not implemented yet"); + } + + @Override + public void clear(int index) { + throw new UnsupportedOperationException("Not implemented yet"); + } + + @Override + public int cardinality() { + return onBits; + } + + @Override + public int length() { + return bitset == null ? onBits : bitset.length(); + } + + @Override + public int prevSetBit(int index) { + throw new UnsupportedOperationException("Not implemented yet"); + } + + @Override + public int nextSetBit(int index) { + throw new UnsupportedOperationException("Not implemented yet"); + } + + @Override + public long ramBytesUsed() { + throw new UnsupportedOperationException("Not implemented yet"); + } + + // Exposed for testing + boolean isInternalBitsetReleased() { + return bitset == null; + } +} diff --git a/core/src/main/java/org/elasticsearch/index/translog/MultiSnapshot.java b/core/src/main/java/org/elasticsearch/index/translog/MultiSnapshot.java index 8aa9fedbe9d46..e162e2d35aca3 100644 --- a/core/src/main/java/org/elasticsearch/index/translog/MultiSnapshot.java +++ b/core/src/main/java/org/elasticsearch/index/translog/MultiSnapshot.java @@ -21,7 +21,8 @@ import com.carrotsearch.hppc.LongObjectHashMap; import com.carrotsearch.hppc.cursors.ObjectCursor; -import org.apache.lucene.util.FixedBitSet; +import org.apache.lucene.util.BitSet; +import org.elasticsearch.common.util.CountedBitSet; import org.elasticsearch.index.seqno.SequenceNumbers; import java.io.Closeable; @@ -83,50 +84,9 @@ public void close() throws IOException { onClose.close(); } - /** - * A {@link CountedBitSet} wraps a {@link FixedBitSet} but automatically releases the internal bitset - * when all bits are set to reduce memory usage. This structure can work well for sequence numbers - * from translog as these numbers are likely to form contiguous ranges (eg. filling all bits). - */ - private static final class CountedBitSet { - private short onBits; // Number of bits are set. - private FixedBitSet bitset; - - CountedBitSet(short numBits) { - assert numBits > 0; - this.onBits = 0; - this.bitset = new FixedBitSet(numBits); - } - - boolean getAndSet(int index) { - assert index >= 0; - assert bitset == null || onBits < bitset.length() : "Bitset should be cleared when all bits are set"; - - // A null bitset means all bits are set. - if (bitset == null) { - return true; - } - - boolean wasOn = bitset.getAndSet(index); - if (wasOn == false) { - onBits++; - // Once all bits are set, we can simply just return YES for all indexes. - // This allows us to clear the internal bitset and use null check as the guard. - if (onBits == bitset.length()) { - bitset = null; - } - } - return wasOn; - } - - boolean hasAllBitsOn() { - return bitset == null; - } - } - static final class SeqNoSet { static final short BIT_SET_SIZE = 1024; - private final LongObjectHashMap bitSets = new LongObjectHashMap<>(); + private final LongObjectHashMap bitSets = new LongObjectHashMap<>(); /** * Marks this sequence number and returns true if it is seen before. @@ -134,19 +94,22 @@ static final class SeqNoSet { boolean getAndSet(long value) { assert value >= 0; final long key = value / BIT_SET_SIZE; - CountedBitSet bitset = bitSets.get(key); + BitSet bitset = bitSets.get(key); if (bitset == null) { bitset = new CountedBitSet(BIT_SET_SIZE); bitSets.put(key, bitset); } - return bitset.getAndSet(Math.toIntExact(value % BIT_SET_SIZE)); + final int index = Math.toIntExact(value % BIT_SET_SIZE); + final boolean wasOn = bitset.get(index); + bitset.set(index); + return wasOn; } // For testing long completeSetsSize() { int completedBitSets = 0; - for (ObjectCursor bitset : bitSets.values()) { - if (bitset.value.hasAllBitsOn()) { + for (ObjectCursor bitset : bitSets.values()) { + if (bitset.value.cardinality() == bitset.value.length()) { completedBitSets++; } } diff --git a/core/src/test/java/org/elasticsearch/common/util/CountedBitSetTests.java b/core/src/test/java/org/elasticsearch/common/util/CountedBitSetTests.java new file mode 100644 index 0000000000000..7a80ebb55b073 --- /dev/null +++ b/core/src/test/java/org/elasticsearch/common/util/CountedBitSetTests.java @@ -0,0 +1,97 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.common.util; + +import org.apache.lucene.util.FixedBitSet; +import org.elasticsearch.test.ESTestCase; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import static org.hamcrest.Matchers.equalTo; + +public class CountedBitSetTests extends ESTestCase { + + public void testCompareToFixedBitset() { + int numBits = (short) randomIntBetween(8, 4096); + final FixedBitSet fixedBitSet = new FixedBitSet(numBits); + final CountedBitSet countedBitSet = new CountedBitSet((short) numBits); + + final int iterations = iterations(1000, 20000); + for (int i = 0; i < iterations; i++) { + final int key = randomInt(numBits - 1); + assertThat(countedBitSet.get(key), equalTo(fixedBitSet.get(key))); + if (frequently()) { + countedBitSet.set(key); + fixedBitSet.set(key); + assertThat(countedBitSet.get(key), equalTo(fixedBitSet.get(key))); + assertThat(countedBitSet.length(), equalTo(fixedBitSet.length())); + assertThat(countedBitSet.cardinality(), equalTo(fixedBitSet.cardinality())); + } + } + } + + public void testReleaseInternalBitSet() { + int numBits = (short) randomIntBetween(8, 4096); + final CountedBitSet countedBitSet = new CountedBitSet((short) numBits); + final List values = IntStream.range(0, numBits).boxed().collect(Collectors.toList()); + + for (int i = 1; i < numBits; i++) { + final int value = values.get(i); + assertThat(countedBitSet.get(value), equalTo(false)); + assertThat(countedBitSet.isInternalBitsetReleased(), equalTo(false)); + + countedBitSet.set(value); + + assertThat(countedBitSet.get(value), equalTo(true)); + assertThat(countedBitSet.isInternalBitsetReleased(), equalTo(false)); + assertThat(countedBitSet.length(), equalTo(numBits)); + assertThat(countedBitSet.cardinality(), equalTo(i)); + } + + // The missing piece to fill all bits. + { + final int value = values.get(0); + assertThat(countedBitSet.get(value), equalTo(false)); + assertThat(countedBitSet.isInternalBitsetReleased(), equalTo(false)); + + countedBitSet.set(value); + + assertThat(countedBitSet.get(value), equalTo(true)); + assertThat(countedBitSet.isInternalBitsetReleased(), equalTo(true)); + assertThat(countedBitSet.length(), equalTo(numBits)); + assertThat(countedBitSet.cardinality(), equalTo(numBits)); + } + + // Tests with released internal bitset. + final int iterations = iterations(1000, 10000); + for (int i = 0; i < iterations; i++) { + final int value = randomInt(numBits - 1); + assertThat(countedBitSet.get(value), equalTo(true)); + assertThat(countedBitSet.isInternalBitsetReleased(), equalTo(true)); + assertThat(countedBitSet.length(), equalTo(numBits)); + assertThat(countedBitSet.cardinality(), equalTo(numBits)); + if (frequently()) { + assertThat(countedBitSet.get(value), equalTo(true)); + } + } + } +} From c9a4901a0f8d42ad6ce71f994ef602355e5950b2 Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Fri, 1 Dec 2017 10:02:13 -0500 Subject: [PATCH 3/7] assert index --- .../java/org/elasticsearch/common/util/CountedBitSet.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/common/util/CountedBitSet.java b/core/src/main/java/org/elasticsearch/common/util/CountedBitSet.java index 21c44d83f3858..f4692b2b9ffd4 100644 --- a/core/src/main/java/org/elasticsearch/common/util/CountedBitSet.java +++ b/core/src/main/java/org/elasticsearch/common/util/CountedBitSet.java @@ -39,7 +39,7 @@ public CountedBitSet(short numBits) { @Override public boolean get(int index) { - assert index >= 0; + assert 0 <= index && index < this.length(); assert bitset == null || onBits < bitset.length() : "Bitset should be released when all bits are set"; return bitset == null ? true : bitset.get(index); @@ -47,7 +47,7 @@ public boolean get(int index) { @Override public void set(int index) { - assert index >= 0; + assert 0 <= index && index < this.length(); assert bitset == null || onBits < bitset.length() : "Bitset should be released when all bits are set"; // Ignore set when bitset is full. From 14aca62e03990e71fc98bbc4b97e9bca9d7d9567 Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Sat, 2 Dec 2017 20:54:49 -0500 Subject: [PATCH 4/7] remove size tests --- .../index/translog/MultiSnapshot.java | 17 ----------------- .../index/translog/MultiSnapshotTests.java | 16 ---------------- 2 files changed, 33 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/index/translog/MultiSnapshot.java b/core/src/main/java/org/elasticsearch/index/translog/MultiSnapshot.java index e162e2d35aca3..ad9d93843717f 100644 --- a/core/src/main/java/org/elasticsearch/index/translog/MultiSnapshot.java +++ b/core/src/main/java/org/elasticsearch/index/translog/MultiSnapshot.java @@ -20,7 +20,6 @@ package org.elasticsearch.index.translog; import com.carrotsearch.hppc.LongObjectHashMap; -import com.carrotsearch.hppc.cursors.ObjectCursor; import org.apache.lucene.util.BitSet; import org.elasticsearch.common.util.CountedBitSet; import org.elasticsearch.index.seqno.SequenceNumbers; @@ -104,21 +103,5 @@ boolean getAndSet(long value) { bitset.set(index); return wasOn; } - - // For testing - long completeSetsSize() { - int completedBitSets = 0; - for (ObjectCursor bitset : bitSets.values()) { - if (bitset.value.cardinality() == bitset.value.length()) { - completedBitSets++; - } - } - return completedBitSets; - } - - // For testing - long ongoingSetsSize() { - return bitSets.size() - completeSetsSize(); - } } } diff --git a/core/src/test/java/org/elasticsearch/index/translog/MultiSnapshotTests.java b/core/src/test/java/org/elasticsearch/index/translog/MultiSnapshotTests.java index 7ee2a6c3366e3..31dda2cb921ec 100644 --- a/core/src/test/java/org/elasticsearch/index/translog/MultiSnapshotTests.java +++ b/core/src/test/java/org/elasticsearch/index/translog/MultiSnapshotTests.java @@ -30,7 +30,6 @@ import java.util.stream.LongStream; import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.Matchers.lessThanOrEqualTo; public class MultiSnapshotTests extends ESTestCase { @@ -40,14 +39,8 @@ public void testTrackSeqNoSimpleRange() throws Exception { Randomness.shuffle(values); for (int i = 0; i < 1023; i++) { assertThat(bitSet.getAndSet(values.get(i)), equalTo(false)); - assertThat(bitSet.ongoingSetsSize(), equalTo(1L)); - assertThat(bitSet.completeSetsSize(), equalTo(0L)); } - assertThat(bitSet.getAndSet(values.get(1023)), equalTo(false)); - assertThat(bitSet.ongoingSetsSize(), equalTo(0L)); - assertThat(bitSet.completeSetsSize(), equalTo(1L)); - assertThat(bitSet.getAndSet(between(0, 1023)), equalTo(true)); assertThat(bitSet.getAndSet(between(1024, Integer.MAX_VALUE)), equalTo(false)); } @@ -59,7 +52,6 @@ public void testTrackSeqNoDenseRanges() throws Exception { long seq = between(0, 5000); boolean existed = normalSet.add(seq) == false; assertThat("SeqNoSet != Set" + seq, bitSet.getAndSet(seq), equalTo(existed)); - assertThat(bitSet.ongoingSetsSize() + bitSet.completeSetsSize(), lessThanOrEqualTo(5L)); }); } @@ -78,12 +70,8 @@ public void testTrackSeqNoMimicTranslogRanges() throws Exception { final LongSet normalSet = new LongHashSet(); long currentSeq = between(10_000_000, 1_000_000_000); final int iterations = scaledRandomIntBetween(100, 2000); - assertThat(bitSet.completeSetsSize(), equalTo(0L)); - assertThat(bitSet.ongoingSetsSize(), equalTo(0L)); - long totalDocs = 0; for (long i = 0; i < iterations; i++) { int batchSize = between(1, 1500); - totalDocs += batchSize; currentSeq -= batchSize; List batch = LongStream.range(currentSeq, currentSeq + batchSize) .boxed() @@ -92,11 +80,7 @@ public void testTrackSeqNoMimicTranslogRanges() throws Exception { batch.forEach(seq -> { boolean existed = normalSet.add(seq) == false; assertThat("SeqNoSet != Set", bitSet.getAndSet(seq), equalTo(existed)); - assertThat(bitSet.ongoingSetsSize(), lessThanOrEqualTo(4L)); }); - assertThat(bitSet.ongoingSetsSize(), lessThanOrEqualTo(2L)); } - assertThat(bitSet.completeSetsSize(), lessThanOrEqualTo(totalDocs / 1024)); - assertThat(bitSet.ongoingSetsSize(), lessThanOrEqualTo(2L)); } } From 0e6a31ef894a1a64595c144e1172ae91517138a3 Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Sat, 2 Dec 2017 20:57:56 -0500 Subject: [PATCH 5/7] simplify bitset tests --- .../common/util/CountedBitSetTests.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/common/util/CountedBitSetTests.java b/core/src/test/java/org/elasticsearch/common/util/CountedBitSetTests.java index 7a80ebb55b073..dcfb0ff516414 100644 --- a/core/src/test/java/org/elasticsearch/common/util/CountedBitSetTests.java +++ b/core/src/test/java/org/elasticsearch/common/util/CountedBitSetTests.java @@ -35,17 +35,17 @@ public void testCompareToFixedBitset() { final FixedBitSet fixedBitSet = new FixedBitSet(numBits); final CountedBitSet countedBitSet = new CountedBitSet((short) numBits); - final int iterations = iterations(1000, 20000); - for (int i = 0; i < iterations; i++) { - final int key = randomInt(numBits - 1); - assertThat(countedBitSet.get(key), equalTo(fixedBitSet.get(key))); - if (frequently()) { - countedBitSet.set(key); - fixedBitSet.set(key); - assertThat(countedBitSet.get(key), equalTo(fixedBitSet.get(key))); - assertThat(countedBitSet.length(), equalTo(fixedBitSet.length())); - assertThat(countedBitSet.cardinality(), equalTo(fixedBitSet.cardinality())); + for (int i = 0; i < numBits; i++) { + if (randomBoolean()) { + fixedBitSet.set(i); + countedBitSet.set(i); } + assertThat(countedBitSet.cardinality(), equalTo(fixedBitSet.cardinality())); + assertThat(countedBitSet.length(), equalTo(fixedBitSet.length())); + } + + for (int i = 0; i < numBits; i++) { + assertThat(countedBitSet.get(i), equalTo(fixedBitSet.get(i))); } } From 0df047404b95ba99ce6fbcc0cf9c760053de0de8 Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Sun, 3 Dec 2017 10:50:28 -0500 Subject: [PATCH 6/7] move CountedBitSet back to translog package --- .../{common/util => index/translog}/CountedBitSet.java | 4 ++-- .../java/org/elasticsearch/index/translog/MultiSnapshot.java | 1 - .../{common/util => index/translog}/CountedBitSetTests.java | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) rename core/src/main/java/org/elasticsearch/{common/util => index/translog}/CountedBitSet.java (97%) rename core/src/test/java/org/elasticsearch/{common/util => index/translog}/CountedBitSetTests.java (98%) diff --git a/core/src/main/java/org/elasticsearch/common/util/CountedBitSet.java b/core/src/main/java/org/elasticsearch/index/translog/CountedBitSet.java similarity index 97% rename from core/src/main/java/org/elasticsearch/common/util/CountedBitSet.java rename to core/src/main/java/org/elasticsearch/index/translog/CountedBitSet.java index f4692b2b9ffd4..8a7987f6084a3 100644 --- a/core/src/main/java/org/elasticsearch/common/util/CountedBitSet.java +++ b/core/src/main/java/org/elasticsearch/index/translog/CountedBitSet.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.common.util; +package org.elasticsearch.index.translog; import org.apache.lucene.util.BitSet; import org.apache.lucene.util.FixedBitSet; @@ -27,7 +27,7 @@ * when all bits are set to reduce memory usage. This structure can work well for sequence numbers * from translog as these numbers are likely to form contiguous ranges (eg. filling all bits). */ -public final class CountedBitSet extends BitSet { +final class CountedBitSet extends BitSet { private short onBits; // Number of bits are set. private FixedBitSet bitset; diff --git a/core/src/main/java/org/elasticsearch/index/translog/MultiSnapshot.java b/core/src/main/java/org/elasticsearch/index/translog/MultiSnapshot.java index ad9d93843717f..e4bfbdcd42e4c 100644 --- a/core/src/main/java/org/elasticsearch/index/translog/MultiSnapshot.java +++ b/core/src/main/java/org/elasticsearch/index/translog/MultiSnapshot.java @@ -21,7 +21,6 @@ import com.carrotsearch.hppc.LongObjectHashMap; import org.apache.lucene.util.BitSet; -import org.elasticsearch.common.util.CountedBitSet; import org.elasticsearch.index.seqno.SequenceNumbers; import java.io.Closeable; diff --git a/core/src/test/java/org/elasticsearch/common/util/CountedBitSetTests.java b/core/src/test/java/org/elasticsearch/index/translog/CountedBitSetTests.java similarity index 98% rename from core/src/test/java/org/elasticsearch/common/util/CountedBitSetTests.java rename to core/src/test/java/org/elasticsearch/index/translog/CountedBitSetTests.java index dcfb0ff516414..5174d1755bed3 100644 --- a/core/src/test/java/org/elasticsearch/common/util/CountedBitSetTests.java +++ b/core/src/test/java/org/elasticsearch/index/translog/CountedBitSetTests.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.common.util; +package org.elasticsearch.index.translog; import org.apache.lucene.util.FixedBitSet; import org.elasticsearch.test.ESTestCase; From 55e041d13ae2c3a6545c21bc5344d14e0821b1ef Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Sun, 3 Dec 2017 11:09:14 -0500 Subject: [PATCH 7/7] stylecheck --- .../java/org/elasticsearch/index/translog/CountedBitSet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/elasticsearch/index/translog/CountedBitSet.java b/core/src/main/java/org/elasticsearch/index/translog/CountedBitSet.java index 8a7987f6084a3..9fac230c9a8f2 100644 --- a/core/src/main/java/org/elasticsearch/index/translog/CountedBitSet.java +++ b/core/src/main/java/org/elasticsearch/index/translog/CountedBitSet.java @@ -31,7 +31,7 @@ final class CountedBitSet extends BitSet { private short onBits; // Number of bits are set. private FixedBitSet bitset; - public CountedBitSet(short numBits) { + CountedBitSet(short numBits) { assert numBits > 0; this.onBits = 0; this.bitset = new FixedBitSet(numBits);