Skip to content

Commit

Permalink
Fix integer overflow in SortedRanges.invertOnNew. Fixes deephaven#666. (
Browse files Browse the repository at this point in the history
deephaven#667)

* Fix integer overflow in SortedRanges.invertOnNew.  Fixes deephaven#666.

* Fix another instance of an int pos that should have been long.

Co-authored-by: Cristian Ferretti <[email protected]>
  • Loading branch information
2 people authored and jmao-denver committed Nov 23, 2021
1 parent fab8ce0 commit f857a9a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2191,7 +2191,7 @@ static boolean removeLegacy(final MutableObject<SortedRanges> sarOut, final Inde
public final TreeIndexImpl invertRangeOnNew(final long start, final long end, final long maxPosition) {
final long packedStart = pack(start);
int i = 0;
int pos = 0;
long pos = 0;
long data = packedGet(i);
boolean neg = false;
long pendingStart = -1;
Expand Down Expand Up @@ -2260,7 +2260,7 @@ public final boolean invertOnNew(
long end = rit.currentRangeEnd();
long packedStart = pack(start);
int i = 0;
int pos = 0;
long pos = 0;
long data = packedGet(i);
boolean neg = false;
long pendingStart = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
import io.deephaven.db.v2.select.IncrementalReleaseFilter;
import org.junit.experimental.categories.Category;

import static io.deephaven.db.v2.TstUtils.getTable;
import static io.deephaven.db.v2.TstUtils.initColumnInfos;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import static io.deephaven.db.v2.TstUtils.assertTableEquals;

@Category(OutOfBandTest.class)
public class TestIncrementalReleaseFilter extends LiveTableTestCase {
public void testSimple() {
final Table source = TableTools.newTable(TableTools.intCol("Sentinel", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
Expand All @@ -37,6 +39,28 @@ public void testSimple() {
}
}

public void testBigTable() {
final Table sourcePart = TableTools.emptyTable(1_000_000_000L);
final List<Table> sourceParts = IntStream.range(0, 20).mapToObj(x -> sourcePart).collect(Collectors.toList());
final Table source = TableTools.merge(sourceParts);
TableTools.show(source);

final IncrementalReleaseFilter incrementalReleaseFilter = new IncrementalReleaseFilter(2, 10_000_000);
final Table filtered = source.where(incrementalReleaseFilter);
final Table flattened = filtered.flatten();

assertEquals(2, filtered.size());

int cycles = 0;
while (filtered.size() < source.size()) {
LiveTableMonitor.DEFAULT.runWithinUnitTestCycle(incrementalReleaseFilter::refresh);
cycles++;
}
assertTableEquals(source, filtered);
assertTableEquals(flattened, filtered);
System.out.println("Cycles: " + cycles);
}

static public <T> T sleepValue(long duration, T retVal) {
final Object blech = new Object();
//noinspection SynchronizationOnLocalVariableOrMethodParameter
Expand Down

0 comments on commit f857a9a

Please sign in to comment.