From 5d1c5196b373f4ecff50bcf117e3399f2b78e62f Mon Sep 17 00:00:00 2001 From: Devin Smith Date: Fri, 21 Jun 2024 17:55:28 -0700 Subject: [PATCH] Fix getNextRowSequenceWithLength callsites that close (#5653) --- .../engine/table/impl/util/ChunkUtils.java | 7 +-- .../deephaven/engine/util/TickSuppressor.java | 56 +++++++++---------- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/util/ChunkUtils.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/util/ChunkUtils.java index ce429aad6ad..412a61dbf47 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/util/ChunkUtils.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/util/ChunkUtils.java @@ -471,7 +471,7 @@ public static void copyData(ChunkSource.WithPrev[] sources, Ro } public static void fillWithNullValue(ChunkSink dest, RowSequence allKeys) { - final int minSize = Math.min(allKeys.intSize(), COPY_DATA_CHUNK_SIZE); + final int minSize = (int) Math.min(allKeys.size(), COPY_DATA_CHUNK_SIZE); if (minSize == 0) { return; } @@ -480,9 +480,8 @@ public static void fillWithNullValue(ChunkSink dest, RowSe final RowSequence.Iterator iter = allKeys.getRowSequenceIterator()) { chunk.fillWithNullValue(0, minSize); while (iter.hasMore()) { - try (final RowSequence nextKeys = iter.getNextRowSequenceWithLength(COPY_DATA_CHUNK_SIZE)) { - dest.fillFromChunk(destContext, chunk, nextKeys); - } + final RowSequence nextKeys = iter.getNextRowSequenceWithLength(COPY_DATA_CHUNK_SIZE); + dest.fillFromChunk(destContext, chunk, nextKeys); } } } diff --git a/engine/table/src/main/java/io/deephaven/engine/util/TickSuppressor.java b/engine/table/src/main/java/io/deephaven/engine/util/TickSuppressor.java index ec50df8eb30..156a4b66478 100644 --- a/engine/table/src/main/java/io/deephaven/engine/util/TickSuppressor.java +++ b/engine/table/src/main/java/io/deephaven/engine/util/TickSuppressor.java @@ -172,38 +172,36 @@ public void onUpdate(TableUpdate upstream) { } while (postRsIt.hasMore()) { - try (final RowSequence postChunkOk = postRsIt.getNextRowSequenceWithLength(chunkSize); - final RowSequence preChunkOk = - preRsIt.getNextRowSequenceWithLength(chunkSize)) { - currentSharedContext.reset(); - prevSharedContext.reset(); + final RowSequence postChunkOk = postRsIt.getNextRowSequenceWithLength(chunkSize); + final RowSequence preChunkOk = preRsIt.getNextRowSequenceWithLength(chunkSize); + currentSharedContext.reset(); + prevSharedContext.reset(); + + for (final int cc : changedColumnIndices) { + // noinspection unchecked + final Chunk currentValues = + inputSources[cc].getChunk(getContextArray[cc], postChunkOk); + // noinspection unchecked + final Chunk prevValues = + inputSources[cc].getPrevChunk(prevContextArray[cc], preChunkOk); + + // now we need to compare them + equalityKernel[cc].notEqual(currentValues, prevValues, changedCellsArray[cc]); + } + final MutableInt pos = new MutableInt(0); + postChunkOk.forAllRowKeys((idx) -> { + boolean idxChanged = false; for (final int cc : changedColumnIndices) { - // noinspection unchecked - final Chunk currentValues = - inputSources[cc].getChunk(getContextArray[cc], postChunkOk); - // noinspection unchecked - final Chunk prevValues = - inputSources[cc].getPrevChunk(prevContextArray[cc], preChunkOk); - - // now we need to compare them - equalityKernel[cc].notEqual(currentValues, prevValues, changedCellsArray[cc]); - } - - final MutableInt pos = new MutableInt(0); - postChunkOk.forAllRowKeys((idx) -> { - boolean idxChanged = false; - for (final int cc : changedColumnIndices) { - if (changedCellsArray[cc].get(pos.get())) { - idxChanged = changedColumns[cc] = true; - } - } - if (idxChanged) { - builder.appendKey(idx); + if (changedCellsArray[cc].get(pos.get())) { + idxChanged = changedColumns[cc] = true; } - pos.increment(); - }); - } + } + if (idxChanged) { + builder.appendKey(idx); + } + pos.increment(); + }); } }