Skip to content

Commit

Permalink
Merge branch 'main' into sm-airlift-up
Browse files Browse the repository at this point in the history
  • Loading branch information
malhotrashivam committed Jun 4, 2024
2 parents e77c791 + 0d99969 commit 56519c7
Show file tree
Hide file tree
Showing 396 changed files with 2,916 additions and 2,146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import io.deephaven.util.QueryConstants;
import io.deephaven.chunk.Chunk;
import io.deephaven.chunk.LongChunk;
import org.apache.commons.lang3.mutable.MutableLong;
import io.deephaven.util.mutable.MutableLong;

import java.util.Arrays;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -224,24 +224,24 @@ public RowSet makeRowSet() {
RowSetUtils.forAllInvertedLongRanges(rowSet, nullsForCol, (first, last) -> {
if (first > 0) {
// Advance to (first - 1)
keysIterator.getNextRowSequenceWithLength(first - 1 - position.longValue());
keysIterator.getNextRowSequenceWithLength(first - 1 - position.get());
build.addKey(keysIterator.peekNextKey());
// Advance to first
keysIterator.getNextRowSequenceWithLength(1);
build.addKey(keysIterator.peekNextKey());

position.setValue(first);
position.set(first);
}

if (last < indexSize - 1) {
// Advance to last
keysIterator.getNextRowSequenceWithLength(last - position.longValue());
keysIterator.getNextRowSequenceWithLength(last - position.get());
build.addKey(keysIterator.peekNextKey());
// Advance to (last + 1)
keysIterator.getNextRowSequenceWithLength(1);
build.addKey(keysIterator.peekNextKey());

position.setValue(last + 1);
position.set(last + 1);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io.deephaven.engine.testutil.testcase.RefreshingTableTestCase;
import io.deephaven.engine.util.TableTools;
import io.deephaven.engine.table.ColumnSource;
import org.apache.commons.lang3.mutable.MutableLong;
import io.deephaven.util.mutable.MutableLong;
import org.jetbrains.annotations.NotNull;

import java.util.concurrent.CountDownLatch;
Expand Down Expand Up @@ -192,7 +192,7 @@ public Long uniqueIdPrev(long index) {
@Override
public void loadData(MutableLong data, long index, boolean usePrev) {
final ColumnSource<Long> columnSource = table().getColumnSource("Value", long.class);
data.setValue(usePrev ? columnSource.getPrevLong(index) : columnSource.getLong(index));
data.set(usePrev ? columnSource.getPrevLong(index) : columnSource.getLong(index));
}
},
nKeys);
Expand Down
4 changes: 2 additions & 2 deletions R/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def rClientDoc = Docker.registerDockerTask(project, 'rClientDoc') {
''')
runCommand('''echo "status = tryCatch(" \
" {" \
" install.packages('roxygen2', repos='http://cran.us.r-project.org'); " \
" install.packages('roxygen2', repos='https://cran.r-project.org'); " \
" 0" \
" }," \
" error=function(e) 1," \
Expand Down Expand Up @@ -179,7 +179,7 @@ def rClientSite = Docker.registerDockerTask(project, 'rClientSite') {
runCommand("mkdir -p ${prefix}/src/rdeephaven/docs")
runCommand('''echo "status = tryCatch(" \
" {" \
" install.packages('pkgdown', repos='http://cran.us.r-project.org'); " \
" install.packages('pkgdown', repos='https://cran.r-project.org'); " \
" 0" \
" }," \
" error=function(e) 1," \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package io.deephaven.util.datastructures;

import io.deephaven.configuration.Configuration;
import org.apache.commons.lang3.mutable.MutableInt;
import io.deephaven.util.mutable.MutableInt;
import org.jetbrains.annotations.NotNull;

import java.lang.ref.ReferenceQueue;
Expand Down 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 @@ -4,7 +4,7 @@
package io.deephaven.util.datastructures;

import io.deephaven.base.reference.SimpleReference;
import org.apache.commons.lang3.mutable.MutableInt;
import io.deephaven.util.mutable.MutableInt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down 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
68 changes: 68 additions & 0 deletions Util/src/main/java/io/deephaven/util/mutable/MutableInt.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
package io.deephaven.util.mutable;

/**
* Minimal mutable wrapper for an {@code int} value. Loosely based on
* {@code org.apache.commons.lang3.mutable.MutableInt}, but without inheriting from {@link Number}, or providing any
* overloads that accept {@code Number} or any boxed types.
* <p>
* Deliberately does not extend {@code Number}, does not implement {@code toString()}/{@code equals}/{@code hashcode()},
* or implement {@code Comparable}.
*/

public class MutableInt {
private int value;

public MutableInt() {

}

public MutableInt(final int value) {
this.value = value;
}

public int get() {
return value;
}

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

public void add(int addend) {
this.value += addend;
}

public int addAndGet(int addend) {
value += addend;
return value;
}

public int getAndAdd(int addend) {
int old = value;
value += addend;
return old;
}

public int getAndIncrement() {
return value++;
}

public void increment() {
value++;
}

public void decrement() {
value--;
}

public int incrementAndGet() {
return ++value;
}

public void subtract(final int subtrahend) {
this.value -= subtrahend;
}
}
67 changes: 67 additions & 0 deletions Util/src/main/java/io/deephaven/util/mutable/MutableLong.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
package io.deephaven.util.mutable;

/**
* Minimal mutable wrapper for a {@code long} value. Loosely based on
* {@code org.apache.commons.lang3.mutable.MutableLong}, but without inheriting from {@link Number}, or providing any
* overloads that accept {@code Number} or any boxed types.
* <p>
* Deliberately does not extend {@code Number}, does not implement {@code toString()}/{@code equals}/{@code hashcode()},
* or implement {@code Comparable}.
*/
public class MutableLong {
private long value;

public MutableLong() {

}

public MutableLong(final long value) {
this.value = value;
}

public long get() {
return value;
}

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

public void add(long addend) {
this.value += addend;
}

public long addAndGet(long addend) {
value += addend;
return value;
}

public long getAndAdd(long addend) {
long old = value;
value += addend;
return old;
}

public long getAndIncrement() {
return value++;
}

public void increment() {
value++;
}

public void decrement() {
value--;
}

public long incrementAndGet() {
return ++value;
}

public void subtract(final long subtrahend) {
this.value -= subtrahend;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
package io.deephaven.util.datastructures;

import io.deephaven.util.annotations.ReferentialIntegrity;
import io.deephaven.util.mutable.MutableInt;
import junit.framework.TestCase;
import org.apache.commons.lang3.mutable.MutableInt;
import org.jetbrains.annotations.NotNull;
import org.junit.Assume;
import org.junit.Test;
Expand Down Expand Up @@ -51,8 +51,8 @@ public void testWithFactory() {
final SegmentedSoftPool<Integer> pool = new SegmentedSoftPool<>(10,
() -> {
counter.increment();
sumAllocated.add(counter);
return counter.toInteger();
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, sumCleared);
TestCase.assertEquals(sumAllocated.get(), sumCleared.get());
}

private static final BitSet OUTSTANDING_INSTANCES = new BitSet(1_000_000);
Expand Down
Loading

0 comments on commit 56519c7

Please sign in to comment.