Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix integer overflow in SortedRanges.invertOnNew. Fixes #666. #667

Merged
merged 2 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
rcaudy marked this conversation as resolved.
Show resolved Hide resolved
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