Skip to content

Commit

Permalink
Fix getNextRowSequenceWithLength callsites that close (deephaven#5653)
Browse files Browse the repository at this point in the history
  • Loading branch information
devinrsmith authored Jun 22, 2024
1 parent ffec8b7 commit 5d1c519
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ public static void copyData(ChunkSource.WithPrev<? extends Values>[] sources, Ro
}

public static <T extends Values> void fillWithNullValue(ChunkSink<T> 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;
}
Expand All @@ -480,9 +480,8 @@ public static <T extends Values> void fillWithNullValue(ChunkSink<T> 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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Values> currentValues =
inputSources[cc].getChunk(getContextArray[cc], postChunkOk);
// noinspection unchecked
final Chunk<Values> 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<Values> currentValues =
inputSources[cc].getChunk(getContextArray[cc], postChunkOk);
// noinspection unchecked
final Chunk<Values> 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();
});
}
}

Expand Down

0 comments on commit 5d1c519

Please sign in to comment.