diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/TableViewportSubscription.java b/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/TableViewportSubscription.java index 043ec165e5f..2087542f90e 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/TableViewportSubscription.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/TableViewportSubscription.java @@ -21,7 +21,6 @@ import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageMessageWrapper; import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageSnapshotOptions; import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageSnapshotRequest; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageSubscriptionRequest; import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageUpdateMetadata; import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.ColumnConversionMode; import io.deephaven.web.client.api.Callbacks; @@ -36,6 +35,7 @@ import io.deephaven.web.client.api.barrage.stream.BiDiStream; import io.deephaven.web.client.fu.JsLog; import io.deephaven.web.client.state.ClientTableState; +import io.deephaven.web.shared.data.Range; import io.deephaven.web.shared.data.TableSnapshot; import jsinterop.annotations.JsMethod; import jsinterop.annotations.JsNullable; @@ -45,6 +45,7 @@ import java.util.Arrays; import java.util.BitSet; import java.util.Collections; +import java.util.Iterator; import static io.deephaven.web.client.api.barrage.WebBarrageUtils.makeUint8ArrayFromBitset; import static io.deephaven.web.client.api.barrage.WebBarrageUtils.serializeRanges; @@ -320,14 +321,14 @@ public Promise<TableData> snapshot(JsRangeSet rows, Column[] columns) { new FlightData()); Builder doGetRequest = new Builder(1024); - double columnsOffset = BarrageSubscriptionRequest.createColumnsVector(doGetRequest, + double columnsOffset = BarrageSnapshotRequest.createColumnsVector(doGetRequest, makeUint8ArrayFromBitset(columnBitset)); - double viewportOffset = BarrageSubscriptionRequest.createViewportVector(doGetRequest, serializeRanges( + double viewportOffset = BarrageSnapshotRequest.createViewportVector(doGetRequest, serializeRanges( Collections.singleton(rows.getRange()))); double serializationOptionsOffset = BarrageSnapshotOptions .createBarrageSnapshotOptions(doGetRequest, ColumnConversionMode.Stringify, true, 0, 0); double tableTicketOffset = - BarrageSubscriptionRequest.createTicketVector(doGetRequest, state.getHandle().getTicket()); + BarrageSnapshotRequest.createTicketVector(doGetRequest, state.getHandle().getTicket()); BarrageSnapshotRequest.startBarrageSnapshotRequest(doGetRequest); BarrageSnapshotRequest.addTicket(doGetRequest, tableTicketOffset); BarrageSnapshotRequest.addColumns(doGetRequest, columnsOffset); @@ -365,7 +366,24 @@ public Promise<TableData> snapshot(JsRangeSet rows, Column[] columns) { WebBarrageUtils.typedArrayToLittleEndianByteBuffer(flightData.getDataBody_asU8()), update, true, columnTypes); - callback.onSuccess(snapshot); + + // TODO deephaven-core(#188) this check no longer makes sense + Iterator<Range> rangeIterator = rows.getRange().rangeIterator(); + long expectedCount = 0; + while (rangeIterator.hasNext()) { + Range range = rangeIterator.next(); + if (range.getFirst() >= snapshot.getTableSize()) { + break; + } + long end = Math.min(range.getLast(), snapshot.getTableSize()); + expectedCount += end - range.getFirst() + 1; + } + if (expectedCount != snapshot.getIncludedRows().size()) { + callback.onFailure("Server did not send expected number of rows, expected " + expectedCount + + ", actual " + snapshot.getIncludedRows().size()); + } else { + callback.onSuccess(snapshot); + } }); stream.onStatus(status -> { if (!status.isOk()) {