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

ClockFilter on an empty Table causes NPE on next update cycle #5474

Merged
merged 1 commit into from
May 10, 2024
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 @@ -74,7 +74,7 @@ protected WritableRowSet initializeAndGetInitialIndex(@NotNull final RowSet sele
@Override
@Nullable
protected WritableRowSet updateAndGetAddedIndex() {
if (range.isEmpty()) {
if (range == null || range.isEmpty()) {
return null;
}
final RowSetBuilderRandom addedBuilder =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected WritableRowSet initializeAndGetInitialIndex(@NotNull final RowSet sele
@Override
@Nullable
protected WritableRowSet updateAndGetAddedIndex() {
if (rangesByNextTime.isEmpty()) {
if (rangesByNextTime == null || rangesByNextTime.isEmpty()) {
return null;
}
final long nowNanos = clock.currentTimeNanos();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
import io.deephaven.engine.table.impl.DataAccessHelpers;
import io.deephaven.engine.testutil.junit4.EngineCleanup;

import static io.deephaven.engine.util.TableTools.col;
import static io.deephaven.engine.util.TableTools.intCol;
import static io.deephaven.engine.util.TableTools.merge;
import static io.deephaven.engine.util.TableTools.newTable;
import static io.deephaven.engine.util.TableTools.*;
import static io.deephaven.time.DateTimeUtils.epochNanosToInstant;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;

import io.deephaven.engine.testutil.StepClock;
import io.deephaven.engine.util.TableTools;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -194,4 +193,38 @@ public void testUnsorted3() {
assertArrayEquals(new int[] {1, 2, 3, 1, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3},
(int[]) DataAccessHelpers.getColumn(result, "Int").getDirect());
}

@Test
public void testInitiallyEmptyUnsorted() {
clock.reset();
final UnsortedClockFilter filter = new UnsortedClockFilter("Timestamp", clock, true);

final Table testEmpty = TableTools.newTable(instantCol("Timestamp"), intCol("Int"));

final Table result = testEmpty.where(filter);

final ControlledUpdateGraph updateGraph = ExecutionContext.getContext().getUpdateGraph().cast();
updateGraph.runWithinUnitTestCycle(() -> {
clock.run();
filter.run();
});
assertEquals(0, result.size());
}

@Test
public void testInitiallyEmptySorted() {
clock.reset();
final UnsortedClockFilter filter = new UnsortedClockFilter("Timestamp", clock, true);

final Table testEmpty = TableTools.newTable(instantCol("Timestamp"), intCol("Int"));

final Table result = testEmpty.where(filter);

final ControlledUpdateGraph updateGraph = ExecutionContext.getContext().getUpdateGraph().cast();
updateGraph.runWithinUnitTestCycle(() -> {
clock.run();
filter.run();
});
assertEquals(0, result.size());
}
}
Loading