Skip to content

Commit

Permalink
Rename MutableInt accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
niloc132 committed May 28, 2024
1 parent e43e89e commit 92cad0e
Show file tree
Hide file tree
Showing 178 changed files with 1,021 additions and 1,043 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private static String build(@NotNull final Collection<StackTraceElement[]> leaks
"Leaked " + leaks.size() + " resources (" + dupDetector.size() + " unique traces):\n");
final MutableInt i = new MutableInt();
dupDetector.entrySet().stream().limit(maxUniqueTraces).forEach(entry -> {
sb.append(" Leak #").append(i.intValue());
sb.append(" Leak #").append(i.get());
if (entry.getValue() > 0L) {
sb.append(", detected " + entry.getValue() + " times, was acquired:\n");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public boolean isEmpty() {
public int size() {
final MutableInt size = new MutableInt(0);
forEach((ref, source) -> size.increment());
return size.intValue();
return size.get();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions Util/src/main/java/io/deephaven/util/mutable/MutableInt.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public MutableInt(final int value) {
this.value = value;
}

public int intValue() {
public int get() {
return value;
}

public void setValue(int value) {
public void set(int value) {
this.value = value;
}

Expand All @@ -41,7 +41,7 @@ public int addAndGet(int addend) {
}

public int getAndAdd(int addend) {
int old = intValue();
int old = get();
value += addend;
return old;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public void testWithFactory() {
final SegmentedSoftPool<Integer> pool = new SegmentedSoftPool<>(10,
() -> {
counter.increment();
sumAllocated.add(counter.intValue());
return counter.intValue();
sumAllocated.add(counter.get());
return counter.get();
},
sumCleared::add);

Expand All @@ -64,7 +64,7 @@ public void testWithFactory() {

IntStream.range(0, 1000).boxed().forEach(II -> TestCase.assertEquals(II, pool.take()));
IntStream.range(0, 1000).boxed().forEach(pool::give);
TestCase.assertEquals(sumAllocated.intValue(), sumCleared.intValue());
TestCase.assertEquals(sumAllocated.get(), sumCleared.get());
}

private static final BitSet OUTSTANDING_INSTANCES = new BitSet(1_000_000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,35 +50,35 @@ public void testForEach() {
TestCase.assertNotNull(s);
counter.increment();
});
TestCase.assertEquals(0, counter.intValue());
TestCase.assertEquals(0, counter.get());

Arrays.stream(values).forEach(v -> TestCase.assertTrue(set.add(v)));
Arrays.stream(values).forEach(v -> TestCase.assertFalse(set.add(v)));

counter.setValue(0);
counter.set(0);
set.forEach(s -> {
TestCase.assertNotNull(s);
counter.increment();
});
TestCase.assertEquals(values.length, counter.intValue());
TestCase.assertEquals(values.length, counter.get());

set.clear();

counter.setValue(0);
counter.set(0);
set.forEach(s -> {
TestCase.assertNotNull(s);
counter.increment();
});
TestCase.assertEquals(0, counter.intValue());
TestCase.assertEquals(0, counter.get());

Arrays.stream(values).forEach(v -> TestCase.assertTrue(set.add(v)));
Arrays.stream(values).forEach(v -> TestCase.assertFalse(set.add(v)));

counter.setValue(0);
counter.set(0);
set.forEach(s -> {
TestCase.assertNotNull(s);
counter.increment();
});
TestCase.assertEquals(values.length, counter.intValue());
TestCase.assertEquals(values.length, counter.get());
}
}
22 changes: 11 additions & 11 deletions Util/src/test/java/io/deephaven/util/mutable/MutableIntTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,73 +11,73 @@ public class MutableIntTest {

@Test
public void intValue() {
assertEquals(123, new MutableInt(123).intValue());
assertEquals(123, new MutableInt(123).get());
}

@Test
public void setValue() {
MutableInt v = new MutableInt(321);
v.setValue(999);
assertEquals(999, v.intValue());
v.set(999);
assertEquals(999, v.get());
}

@Test
public void add() {
MutableInt v = new MutableInt(1000);
v.add(10);
assertEquals(1010, v.intValue());
assertEquals(1010, v.get());
}

@Test
public void addAndGet() {
MutableInt v = new MutableInt(1000);
int result = v.addAndGet(10);
assertEquals(1010, result);
assertEquals(1010, v.intValue());
assertEquals(1010, v.get());
}

@Test
public void getAndAdd() {
MutableInt v = new MutableInt(1000);
int result = v.getAndAdd(10);
assertEquals(1000, result);
assertEquals(1010, v.intValue());
assertEquals(1010, v.get());
}

@Test
public void getAndIncrement() {
MutableInt v = new MutableInt(1000);
int result = v.getAndIncrement();
assertEquals(1000, result);
assertEquals(1001, v.intValue());
assertEquals(1001, v.get());
}

@Test
public void increment() {
MutableInt v = new MutableInt(1000);
v.increment();
assertEquals(1001, v.intValue());
assertEquals(1001, v.get());
}

@Test
public void decrement() {
MutableInt v = new MutableInt(1000);
v.decrement();
assertEquals(999, v.intValue());
assertEquals(999, v.get());
}

@Test
public void incrementAndGet() {
MutableInt v = new MutableInt(1000);
int result = v.incrementAndGet();
assertEquals(1001, result);
assertEquals(1001, v.intValue());
assertEquals(1001, v.get());
}

@Test
public void subtract() {
MutableInt v = new MutableInt(1000);
v.subtract(10);
assertEquals(990, v.intValue());
assertEquals(990, v.get());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void testCharacterColumnIterators() {
.filter((final Character value) -> !(Objects.equals(value,
box(data.get(nextValueIndex.getAndIncrement())))))
.count());
nextValueIndex.setValue(0);
nextValueIndex.set(0);
assertEquals(0, chunked3.stream()
.filter((final Character value) -> !(Objects.equals(value,
box(data.get(nextValueIndex.getAndIncrement())))))
Expand Down Expand Up @@ -119,7 +119,7 @@ public void testByteColumnIterators() {
.filter((final Byte value) -> !(Objects.equals(value,
box(data.get(nextValueIndex.getAndIncrement())))))
.count());
nextValueIndex.setValue(0);
nextValueIndex.set(0);
assertEquals(0, chunked3.stream()
.filter((final Byte value) -> !(Objects.equals(value,
box(data.get(nextValueIndex.getAndIncrement())))))
Expand Down Expand Up @@ -157,7 +157,7 @@ public void testShortColumnIterators() {
.filter((final Short value) -> !(Objects.equals(value,
box(data.get(nextValueIndex.getAndIncrement())))))
.count());
nextValueIndex.setValue(0);
nextValueIndex.set(0);
assertEquals(0, chunked3.stream()
.filter((final Short value) -> !(Objects.equals(value,
box(data.get(nextValueIndex.getAndIncrement())))))
Expand Down Expand Up @@ -195,7 +195,7 @@ public void testIntegerColumnIterators() {
.filter((final Integer value) -> !(Objects.equals(value,
box(data.get(nextValueIndex.getAndIncrement())))))
.count());
nextValueIndex.setValue(0);
nextValueIndex.set(0);
assertEquals(0, chunked3.stream()
.filter((final Integer value) -> !(Objects.equals(value,
box(data.get(nextValueIndex.getAndIncrement())))))
Expand Down Expand Up @@ -233,7 +233,7 @@ public void testLongColumnIterators() {
.filter((final Long value) -> !(Objects.equals(value,
box(data.get(nextValueIndex.getAndIncrement())))))
.count());
nextValueIndex.setValue(0);
nextValueIndex.set(0);
assertEquals(0, chunked3.stream()
.filter((final Long value) -> !(Objects.equals(value,
box(data.get(nextValueIndex.getAndIncrement())))))
Expand Down Expand Up @@ -271,7 +271,7 @@ public void testFloatColumnIterators() {
.filter((final Float value) -> !(Objects.equals(value,
box(data.get(nextValueIndex.getAndIncrement())))))
.count());
nextValueIndex.setValue(0);
nextValueIndex.set(0);
assertEquals(0, chunked3.stream()
.filter((final Float value) -> !(Objects.equals(value,
box(data.get(nextValueIndex.getAndIncrement())))))
Expand Down Expand Up @@ -309,7 +309,7 @@ public void testDoubleColumnIterators() {
.filter((final Double value) -> !(Objects.equals(value,
box(data.get(nextValueIndex.getAndIncrement())))))
.count());
nextValueIndex.setValue(0);
nextValueIndex.set(0);
assertEquals(0, chunked3.stream()
.filter((final Double value) -> !(Objects.equals(value,
box(data.get(nextValueIndex.getAndIncrement())))))
Expand Down Expand Up @@ -343,7 +343,7 @@ public void testObjectColumnIteratorsOfBoolean() {
.filter((final Boolean value) -> !(Objects.equals(value,
data.get(nextValueIndex.getAndIncrement()))))
.count());
nextValueIndex.setValue(0);
nextValueIndex.set(0);
assertEquals(0, chunked2.stream()
.filter((final Boolean value) -> !(Objects.equals(value,
data.get(nextValueIndex.getAndIncrement()))))
Expand Down Expand Up @@ -377,7 +377,7 @@ public void testObjectColumnIteratorsOfString() {
.filter((final String value) -> !(Objects.equals(value,
data.get(nextValueIndex.getAndIncrement()))))
.count());
nextValueIndex.setValue(0);
nextValueIndex.set(0);
assertEquals(0, chunked2.stream()
.filter((final String value) -> !(Objects.equals(value,
data.get(nextValueIndex.getAndIncrement()))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void setupEnv(BenchmarkParams params) {

inputTable.getDefinition().getColumnNameSet().forEach(columnName -> {
if (!columnName.equals(sortCol)) {
sortColumns[ci.intValue()] = columnName;
sortColumns[ci.get()] = columnName;
ci.increment();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void close() {
public long rangesCountUpperBound() {
final MutableInt mi = new MutableInt(0);
wrappedOK.forAllRowKeyRanges((final long start, final long end) -> mi.increment());
return mi.intValue();
return mi.get();
}

private void shiftIndicesChunk(WritableLongChunk<? super OrderedRowKeys> chunkToFill) {
Expand Down
Loading

0 comments on commit 92cad0e

Please sign in to comment.