From a3994f86d84790051df796868f9fa99ca19a63b6 Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Wed, 22 Nov 2017 09:19:07 -0500 Subject: [PATCH] SeqNum -> SeqNo --- .../index/translog/MultiSnapshot.java | 6 ++--- .../index/translog/MultiSnapshotTests.java | 22 +++++++++---------- 2 files changed, 14 insertions(+), 14 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 21dbee5720b7c..cc9dbdeb63f1d 100644 --- a/core/src/main/java/org/elasticsearch/index/translog/MultiSnapshot.java +++ b/core/src/main/java/org/elasticsearch/index/translog/MultiSnapshot.java @@ -39,7 +39,7 @@ final class MultiSnapshot implements Translog.Snapshot { private int overriddenOperations; private final Closeable onClose; private int index; - private final SeqNumSet seenSeqNo; + private final SeqNoSet seenSeqNo; /** * Creates a new point in time snapshot of the given snapshots. Those snapshots are always iterated in-order. @@ -49,7 +49,7 @@ final class MultiSnapshot implements Translog.Snapshot { this.totalOperations = Arrays.stream(translogs).mapToInt(TranslogSnapshot::totalOperations).sum(); this.overriddenOperations = 0; this.onClose = onClose; - this.seenSeqNo = new SeqNumSet(); + this.seenSeqNo = new SeqNoSet(); this.index = translogs.length - 1; } @@ -115,7 +115,7 @@ boolean hasAllBitsOn() { * 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 SeqNumSet { + static final class SeqNoSet { static final short BIT_SET_SIZE = 1024; private final LongSet completedSets = new LongHashSet(); private final LongObjectHashMap ongoingSets = new LongObjectHashMap<>(); 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 a7fcdd46f0289..7ee2a6c3366e3 100644 --- a/core/src/test/java/org/elasticsearch/index/translog/MultiSnapshotTests.java +++ b/core/src/test/java/org/elasticsearch/index/translog/MultiSnapshotTests.java @@ -34,8 +34,8 @@ public class MultiSnapshotTests extends ESTestCase { - public void testTrackSimpleSeqNoRanges() throws Exception { - final MultiSnapshot.SeqNumSet bitSet = new MultiSnapshot.SeqNumSet(); + public void testTrackSeqNoSimpleRange() throws Exception { + final MultiSnapshot.SeqNoSet bitSet = new MultiSnapshot.SeqNoSet(); final List values = LongStream.range(0, 1024).boxed().collect(Collectors.toList()); Randomness.shuffle(values); for (int i = 0; i < 1023; i++) { @@ -52,29 +52,29 @@ public void testTrackSimpleSeqNoRanges() throws Exception { assertThat(bitSet.getAndSet(between(1024, Integer.MAX_VALUE)), equalTo(false)); } - public void testTrackSeqNumDenseRanges() throws Exception { - final MultiSnapshot.SeqNumSet bitSet = new MultiSnapshot.SeqNumSet(); + public void testTrackSeqNoDenseRanges() throws Exception { + final MultiSnapshot.SeqNoSet bitSet = new MultiSnapshot.SeqNoSet(); final LongSet normalSet = new LongHashSet(); IntStream.range(0, scaledRandomIntBetween(5_000, 10_000)).forEach(i -> { long seq = between(0, 5000); boolean existed = normalSet.add(seq) == false; - assertThat("SeqNumSet != Set" + seq, bitSet.getAndSet(seq), equalTo(existed)); + assertThat("SeqNoSet != Set" + seq, bitSet.getAndSet(seq), equalTo(existed)); assertThat(bitSet.ongoingSetsSize() + bitSet.completeSetsSize(), lessThanOrEqualTo(5L)); }); } - public void testTrackSeqNumSparseRanges() throws Exception { - final MultiSnapshot.SeqNumSet bitSet = new MultiSnapshot.SeqNumSet(); + public void testTrackSeqNoSparseRanges() throws Exception { + final MultiSnapshot.SeqNoSet bitSet = new MultiSnapshot.SeqNoSet(); final LongSet normalSet = new LongHashSet(); IntStream.range(0, scaledRandomIntBetween(5_000, 10_000)).forEach(i -> { long seq = between(i * 10_000, i * 30_000); boolean existed = normalSet.add(seq) == false; - assertThat("SeqNumSet != Set", bitSet.getAndSet(seq), equalTo(existed)); + assertThat("SeqNoSet != Set", bitSet.getAndSet(seq), equalTo(existed)); }); } - public void testSequenceNumMimicTranslog() throws Exception { - final MultiSnapshot.SeqNumSet bitSet = new MultiSnapshot.SeqNumSet(); + public void testTrackSeqNoMimicTranslogRanges() throws Exception { + final MultiSnapshot.SeqNoSet bitSet = new MultiSnapshot.SeqNoSet(); final LongSet normalSet = new LongHashSet(); long currentSeq = between(10_000_000, 1_000_000_000); final int iterations = scaledRandomIntBetween(100, 2000); @@ -91,7 +91,7 @@ public void testSequenceNumMimicTranslog() throws Exception { Randomness.shuffle(batch); batch.forEach(seq -> { boolean existed = normalSet.add(seq) == false; - assertThat("SeqNumSet != Set", bitSet.getAndSet(seq), equalTo(existed)); + assertThat("SeqNoSet != Set", bitSet.getAndSet(seq), equalTo(existed)); assertThat(bitSet.ongoingSetsSize(), lessThanOrEqualTo(4L)); }); assertThat(bitSet.ongoingSetsSize(), lessThanOrEqualTo(2L));