Skip to content

Commit

Permalink
fix: Only update the redir index on the first column (#5659)
Browse files Browse the repository at this point in the history
JS API full table subscriptions currently spend more time than they
should updating redirection indexes for large snapshots. This patch
is a small step to reduce the work done when receiving these large
payloads.

Fixes #5658
  • Loading branch information
niloc132 committed Jun 25, 2024
1 parent f647f1a commit c2e2424
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public TableData handleSnapshot(TableSnapshot snapshot) {

long includedRowCount = snapshot.getIncludedRows().size();
RangeSet destination = freeRows(includedRowCount);
boolean indexUpdated = false;

for (int index = 0; index < dataColumns.length; index++) {
ColumnData dataColumn = dataColumns[index];
Expand All @@ -89,10 +90,14 @@ public TableData handleSnapshot(TableSnapshot snapshot) {
while (indexIter.hasNext()) {
assert destIter.hasNext();
long dest = destIter.nextLong();
redirectedIndexes.put(indexIter.nextLong(), dest);
long nextIndex = indexIter.nextLong();
if (!indexUpdated) {
redirectedIndexes.put(nextIndex, dest);
}
arrayCopy.copyTo(localCopy, dest, dataColumn.getData(), j++);
}
assert !destIter.hasNext();
indexUpdated = true;
}

return notifyUpdates(index, RangeSet.empty(), RangeSet.empty());
Expand Down

0 comments on commit c2e2424

Please sign in to comment.