diff --git a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/BigDecimalChunkWriter.java b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/BigDecimalChunkWriter.java index 6f27a1c1c85..e86179a3f0b 100644 --- a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/BigDecimalChunkWriter.java +++ b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/BigDecimalChunkWriter.java @@ -6,6 +6,7 @@ import io.deephaven.UncheckedDeephavenException; import io.deephaven.base.verify.Assert; import io.deephaven.chunk.Chunk; +import io.deephaven.chunk.ObjectChunk; import io.deephaven.chunk.attributes.Values; import io.deephaven.engine.rowset.RowSequence; import io.deephaven.util.mutable.MutableInt; @@ -42,8 +43,9 @@ protected int computeNullCount( @NotNull final Context context, @NotNull final RowSequence subset) { final MutableInt nullCount = new MutableInt(0); + final ObjectChunk objectChunk = context.getChunk().asObjectChunk(); subset.forAllRowKeys(row -> { - if (context.getChunk().asObjectChunk().isNull((int) row)) { + if (objectChunk.isNull((int) row)) { nullCount.increment(); } }); @@ -55,9 +57,8 @@ protected void writeValidityBufferInternal( @NotNull final Context context, @NotNull final RowSequence subset, @NotNull final SerContext serContext) { - subset.forAllRowKeys(row -> { - serContext.setNextIsNull(context.getChunk().asObjectChunk().isNull((int) row)); - }); + final ObjectChunk objectChunk = context.getChunk().asObjectChunk(); + subset.forAllRowKeys(row -> serContext.setNextIsNull(objectChunk.isNull((int) row))); } @Override @@ -73,9 +74,10 @@ protected void writePayload( .subtract(BigInteger.ONE) .negate(); + final ObjectChunk objectChunk = context.getChunk().asObjectChunk(); subset.forAllRowKeys(rowKey -> { try { - BigDecimal value = context.getChunk().asObjectChunk().get((int) rowKey); + BigDecimal value = objectChunk.get((int) rowKey); if (value.scale() != scale) { value = value.setScale(decimalType.getScale(), RoundingMode.HALF_UP); diff --git a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/BooleanChunkWriter.java b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/BooleanChunkWriter.java index ebb2c38ffa0..645500f8d1d 100644 --- a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/BooleanChunkWriter.java +++ b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/BooleanChunkWriter.java @@ -42,8 +42,9 @@ public DrainableColumn getInputStream( @Override protected int computeNullCount(@NotNull Context context, @NotNull RowSequence subset) { final MutableInt nullCount = new MutableInt(0); + final ByteChunk byteChunk = context.getChunk().asByteChunk(); subset.forAllRowKeys(row -> { - if (context.getChunk().asByteChunk().isNull((int) row)) { + if (byteChunk.isNull((int) row)) { nullCount.increment(); } }); @@ -53,9 +54,8 @@ protected int computeNullCount(@NotNull Context context, @NotNull RowSequence su @Override protected void writeValidityBufferInternal(@NotNull Context context, @NotNull RowSequence subset, @NotNull SerContext serContext) { - subset.forAllRowKeys(row -> { - serContext.setNextIsNull(context.getChunk().asByteChunk().isNull((int) row)); - }); + final ByteChunk byteChunk = context.getChunk().asByteChunk(); + subset.forAllRowKeys(row -> serContext.setNextIsNull(byteChunk.isNull((int) row))); } private class BooleanChunkInputStream extends BaseChunkInputStream { @@ -106,8 +106,9 @@ public int drainTo(final OutputStream outputStream) throws IOException { // write the payload buffer // we cheat and re-use validity buffer serialization code try (final SerContext serContext = new SerContext(dos)) { + final ByteChunk byteChunk = context.getChunk().asByteChunk(); subset.forAllRowKeys(row -> serContext.setNextIsNull( - context.getChunk().asByteChunk().get((int) row) != BooleanUtils.TRUE_BOOLEAN_AS_BYTE)); + byteChunk.get((int) row) != BooleanUtils.TRUE_BOOLEAN_AS_BYTE)); } bytesWritten += getNumLongsForBitPackOfSize(subset.intSize(DEBUG_NAME)) * (long) Long.BYTES; diff --git a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/ByteChunkWriter.java b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/ByteChunkWriter.java index 626aaa14dcd..9dcd3e42578 100644 --- a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/ByteChunkWriter.java +++ b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/ByteChunkWriter.java @@ -67,8 +67,9 @@ protected int computeNullCount( @NotNull final Context context, @NotNull final RowSequence subset) { final MutableInt nullCount = new MutableInt(0); + final ByteChunk byteChunk = context.getChunk().asByteChunk(); subset.forAllRowKeys(row -> { - if (context.getChunk().asByteChunk().isNull((int) row)) { + if (byteChunk.isNull((int) row)) { nullCount.increment(); } }); @@ -80,9 +81,8 @@ protected void writeValidityBufferInternal( @NotNull final Context context, @NotNull final RowSequence subset, @NotNull final SerContext serContext) { - subset.forAllRowKeys(row -> { - serContext.setNextIsNull(context.getChunk().asByteChunk().isNull((int) row)); - }); + final ByteChunk byteChunk = context.getChunk().asByteChunk(); + subset.forAllRowKeys(row -> serContext.setNextIsNull(byteChunk.isNull((int) row))); } private class ByteChunkInputStream extends BaseChunkInputStream { @@ -120,9 +120,10 @@ public int drainTo(final OutputStream outputStream) throws IOException { bytesWritten += writeValidityBuffer(dos); // write the payload buffer + final ByteChunk byteChunk = context.getChunk().asByteChunk(); subset.forAllRowKeys(row -> { try { - dos.writeByte(context.getChunk().asByteChunk().get((int) row)); + dos.writeByte(byteChunk.get((int) row)); } catch (final IOException e) { throw new UncheckedDeephavenException( "Unexpected exception while draining data to OutputStream: ", e); diff --git a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/CharChunkWriter.java b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/CharChunkWriter.java index a53f07a15be..aaf1912642d 100644 --- a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/CharChunkWriter.java +++ b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/CharChunkWriter.java @@ -63,8 +63,9 @@ protected int computeNullCount( @NotNull final Context context, @NotNull final RowSequence subset) { final MutableInt nullCount = new MutableInt(0); + final CharChunk charChunk = context.getChunk().asCharChunk(); subset.forAllRowKeys(row -> { - if (context.getChunk().asCharChunk().isNull((int) row)) { + if (charChunk.isNull((int) row)) { nullCount.increment(); } }); @@ -76,9 +77,8 @@ protected void writeValidityBufferInternal( @NotNull final Context context, @NotNull final RowSequence subset, @NotNull final SerContext serContext) { - subset.forAllRowKeys(row -> { - serContext.setNextIsNull(context.getChunk().asCharChunk().isNull((int) row)); - }); + final CharChunk charChunk = context.getChunk().asCharChunk(); + subset.forAllRowKeys(row -> serContext.setNextIsNull(charChunk.isNull((int) row))); } private class CharChunkInputStream extends BaseChunkInputStream { @@ -116,9 +116,10 @@ public int drainTo(final OutputStream outputStream) throws IOException { bytesWritten += writeValidityBuffer(dos); // write the payload buffer + final CharChunk charChunk = context.getChunk().asCharChunk(); subset.forAllRowKeys(row -> { try { - dos.writeChar(context.getChunk().asCharChunk().get((int) row)); + dos.writeChar(charChunk.get((int) row)); } catch (final IOException e) { throw new UncheckedDeephavenException( "Unexpected exception while draining data to OutputStream: ", e); diff --git a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/DefaultChunkWriterFactory.java b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/DefaultChunkWriterFactory.java index f3cf9ea748b..ec6dedcbed6 100644 --- a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/DefaultChunkWriterFactory.java +++ b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/DefaultChunkWriterFactory.java @@ -1157,8 +1157,9 @@ protected void writePayload( @NotNull final Context context, @NotNull final DataOutput dos, @NotNull final RowSequence subset) { + final ObjectChunk objectChunk = context.getChunk().asObjectChunk(); subset.forAllRowKeys(row -> { - final byte[] data = context.getChunk().asObjectChunk().get((int) row); + final byte[] data = objectChunk.get((int) row); if (data.length != elementWidth) { throw new IllegalArgumentException(String.format( "Expected fixed size binary of %d bytes, but got %d bytes when serializing %s", @@ -1235,8 +1236,9 @@ protected void writePayload( @NotNull final Context context, @NotNull final DataOutput dos, @NotNull final RowSequence subset) { + final ObjectChunk objectChunk = context.getChunk().asObjectChunk(); subset.forAllRowKeys(row -> { - final Duration value = context.getChunk().asObjectChunk().get((int) row); + final Duration value = objectChunk.get((int) row); try { if (value == null) { dos.writeInt(0); @@ -1304,8 +1306,9 @@ protected void writePayload( @NotNull final Context context, @NotNull final DataOutput dos, @NotNull final RowSequence subset) { + final ObjectChunk objectChunk = context.getChunk().asObjectChunk(); subset.forAllRowKeys(row -> { - final Period value = context.getChunk().asObjectChunk().get((int) row); + final Period value = objectChunk.get((int) row); try { if (value == null) { dos.writeInt(0); @@ -1331,8 +1334,9 @@ protected void writePayload( @NotNull final Context context, @NotNull final DataOutput dos, @NotNull final RowSequence subset) { + final ObjectChunk objectChunk = context.getChunk().asObjectChunk(); subset.forAllRowKeys(row -> { - final Period value = context.getChunk().asObjectChunk().get((int) row); + final Period value = objectChunk.get((int) row); try { if (value == null) { dos.writeInt(0); @@ -1381,9 +1385,10 @@ protected void writePayload( @NotNull final Context context, @NotNull final DataOutput dos, @NotNull final RowSequence subset) { + final ObjectChunk objectChunk = context.getChunk().asObjectChunk(); subset.forAllRowKeys(row -> { final PeriodDuration value = - context.getChunk().asObjectChunk().get((int) row); + objectChunk.get((int) row); try { if (value == null) { dos.writeInt(0); @@ -1409,9 +1414,9 @@ protected void writePayload( @NotNull final Context context, @NotNull final DataOutput dos, @NotNull final RowSequence subset) { + final ObjectChunk objectChunk = context.getChunk().asObjectChunk(); subset.forAllRowKeys(row -> { - final PeriodDuration value = - context.getChunk().asObjectChunk().get((int) row); + final PeriodDuration value = objectChunk.get((int) row); try { if (value == null) { dos.writeInt(0); diff --git a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/DoubleChunkWriter.java b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/DoubleChunkWriter.java index 8b5dfb5672b..f37b5ca4eec 100644 --- a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/DoubleChunkWriter.java +++ b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/DoubleChunkWriter.java @@ -67,8 +67,9 @@ protected int computeNullCount( @NotNull final Context context, @NotNull final RowSequence subset) { final MutableInt nullCount = new MutableInt(0); + final DoubleChunk doubleChunk = context.getChunk().asDoubleChunk(); subset.forAllRowKeys(row -> { - if (context.getChunk().asDoubleChunk().isNull((int) row)) { + if (doubleChunk.isNull((int) row)) { nullCount.increment(); } }); @@ -80,9 +81,8 @@ protected void writeValidityBufferInternal( @NotNull final Context context, @NotNull final RowSequence subset, @NotNull final SerContext serContext) { - subset.forAllRowKeys(row -> { - serContext.setNextIsNull(context.getChunk().asDoubleChunk().isNull((int) row)); - }); + final DoubleChunk doubleChunk = context.getChunk().asDoubleChunk(); + subset.forAllRowKeys(row -> serContext.setNextIsNull(doubleChunk.isNull((int) row))); } private class DoubleChunkInputStream extends BaseChunkInputStream { @@ -120,9 +120,10 @@ public int drainTo(final OutputStream outputStream) throws IOException { bytesWritten += writeValidityBuffer(dos); // write the payload buffer + final DoubleChunk doubleChunk = context.getChunk().asDoubleChunk(); subset.forAllRowKeys(row -> { try { - dos.writeDouble(context.getChunk().asDoubleChunk().get((int) row)); + dos.writeDouble(doubleChunk.get((int) row)); } catch (final IOException e) { throw new UncheckedDeephavenException( "Unexpected exception while draining data to OutputStream: ", e); diff --git a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/FixedWidthObjectChunkWriter.java b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/FixedWidthObjectChunkWriter.java index 398b9bb4941..6491f841bfc 100644 --- a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/FixedWidthObjectChunkWriter.java +++ b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/FixedWidthObjectChunkWriter.java @@ -23,8 +23,9 @@ protected int computeNullCount( @NotNull final BaseChunkWriter.Context context, @NotNull final RowSequence subset) { final MutableInt nullCount = new MutableInt(0); + final ObjectChunk objectChunk = context.getChunk().asObjectChunk(); subset.forAllRowKeys(row -> { - if (context.getChunk().asObjectChunk().isNull((int) row)) { + if (objectChunk.isNull((int) row)) { nullCount.increment(); } }); @@ -36,8 +37,7 @@ protected void writeValidityBufferInternal( @NotNull final BaseChunkWriter.Context context, @NotNull final RowSequence subset, @NotNull final SerContext serContext) { - subset.forAllRowKeys(row -> { - serContext.setNextIsNull(context.getChunk().asObjectChunk().isNull((int) row)); - }); + final ObjectChunk objectChunk = context.getChunk().asObjectChunk(); + subset.forAllRowKeys(row -> serContext.setNextIsNull(objectChunk.isNull((int) row))); } } diff --git a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/FloatChunkWriter.java b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/FloatChunkWriter.java index dc2101994c9..227a9925fc8 100644 --- a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/FloatChunkWriter.java +++ b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/FloatChunkWriter.java @@ -67,8 +67,9 @@ protected int computeNullCount( @NotNull final Context context, @NotNull final RowSequence subset) { final MutableInt nullCount = new MutableInt(0); + final FloatChunk floatChunk = context.getChunk().asFloatChunk(); subset.forAllRowKeys(row -> { - if (context.getChunk().asFloatChunk().isNull((int) row)) { + if (floatChunk.isNull((int) row)) { nullCount.increment(); } }); @@ -80,9 +81,8 @@ protected void writeValidityBufferInternal( @NotNull final Context context, @NotNull final RowSequence subset, @NotNull final SerContext serContext) { - subset.forAllRowKeys(row -> { - serContext.setNextIsNull(context.getChunk().asFloatChunk().isNull((int) row)); - }); + final FloatChunk floatChunk = context.getChunk().asFloatChunk(); + subset.forAllRowKeys(row -> serContext.setNextIsNull(floatChunk.isNull((int) row))); } private class FloatChunkInputStream extends BaseChunkInputStream { @@ -120,9 +120,10 @@ public int drainTo(final OutputStream outputStream) throws IOException { bytesWritten += writeValidityBuffer(dos); // write the payload buffer + final FloatChunk floatChunk = context.getChunk().asFloatChunk(); subset.forAllRowKeys(row -> { try { - dos.writeFloat(context.getChunk().asFloatChunk().get((int) row)); + dos.writeFloat(floatChunk.get((int) row)); } catch (final IOException e) { throw new UncheckedDeephavenException( "Unexpected exception while draining data to OutputStream: ", e); diff --git a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/IntChunkWriter.java b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/IntChunkWriter.java index 61aef4df3ae..44cd4482c5e 100644 --- a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/IntChunkWriter.java +++ b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/IntChunkWriter.java @@ -67,8 +67,9 @@ protected int computeNullCount( @NotNull final Context context, @NotNull final RowSequence subset) { final MutableInt nullCount = new MutableInt(0); + final IntChunk intChunk = context.getChunk().asIntChunk(); subset.forAllRowKeys(row -> { - if (context.getChunk().asIntChunk().isNull((int) row)) { + if (intChunk.isNull((int) row)) { nullCount.increment(); } }); @@ -80,9 +81,8 @@ protected void writeValidityBufferInternal( @NotNull final Context context, @NotNull final RowSequence subset, @NotNull final SerContext serContext) { - subset.forAllRowKeys(row -> { - serContext.setNextIsNull(context.getChunk().asIntChunk().isNull((int) row)); - }); + final IntChunk intChunk = context.getChunk().asIntChunk(); + subset.forAllRowKeys(row -> serContext.setNextIsNull(intChunk.isNull((int) row))); } private class IntChunkInputStream extends BaseChunkInputStream { @@ -120,9 +120,10 @@ public int drainTo(final OutputStream outputStream) throws IOException { bytesWritten += writeValidityBuffer(dos); // write the payload buffer + final IntChunk intChunk = context.getChunk().asIntChunk(); subset.forAllRowKeys(row -> { try { - dos.writeInt(context.getChunk().asIntChunk().get((int) row)); + dos.writeInt(intChunk.get((int) row)); } catch (final IOException e) { throw new UncheckedDeephavenException( "Unexpected exception while draining data to OutputStream: ", e); diff --git a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/ListChunkWriter.java b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/ListChunkWriter.java index 1df45065ea4..baaa414647d 100644 --- a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/ListChunkWriter.java +++ b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/ListChunkWriter.java @@ -49,8 +49,9 @@ protected int computeNullCount( @NotNull final ChunkWriter.Context context, @NotNull final RowSequence subset) { final MutableInt nullCount = new MutableInt(0); + final ObjectChunk objectChunk = context.getChunk().asObjectChunk(); subset.forAllRowKeys(row -> { - if (context.getChunk().asObjectChunk().isNull((int) row)) { + if (objectChunk.isNull((int) row)) { nullCount.increment(); } }); @@ -62,9 +63,8 @@ protected void writeValidityBufferInternal( @NotNull final ChunkWriter.Context context, @NotNull final RowSequence subset, @NotNull final SerContext serContext) { - subset.forAllRowKeys(row -> { - serContext.setNextIsNull(context.getChunk().asObjectChunk().isNull((int) row)); - }); + final ObjectChunk objectChunk = context.getChunk().asObjectChunk(); + subset.forAllRowKeys(row -> serContext.setNextIsNull(objectChunk.isNull((int) row))); } @Override diff --git a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/LongChunkWriter.java b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/LongChunkWriter.java index 9d6f49899d5..f4f54e546be 100644 --- a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/LongChunkWriter.java +++ b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/LongChunkWriter.java @@ -67,8 +67,9 @@ protected int computeNullCount( @NotNull final Context context, @NotNull final RowSequence subset) { final MutableInt nullCount = new MutableInt(0); + final LongChunk longChunk = context.getChunk().asLongChunk(); subset.forAllRowKeys(row -> { - if (context.getChunk().asLongChunk().isNull((int) row)) { + if (longChunk.isNull((int) row)) { nullCount.increment(); } }); @@ -80,9 +81,8 @@ protected void writeValidityBufferInternal( @NotNull final Context context, @NotNull final RowSequence subset, @NotNull final SerContext serContext) { - subset.forAllRowKeys(row -> { - serContext.setNextIsNull(context.getChunk().asLongChunk().isNull((int) row)); - }); + final LongChunk longChunk = context.getChunk().asLongChunk(); + subset.forAllRowKeys(row -> serContext.setNextIsNull(longChunk.isNull((int) row))); } private class LongChunkInputStream extends BaseChunkInputStream { @@ -120,9 +120,10 @@ public int drainTo(final OutputStream outputStream) throws IOException { bytesWritten += writeValidityBuffer(dos); // write the payload buffer + final LongChunk longChunk = context.getChunk().asLongChunk(); subset.forAllRowKeys(row -> { try { - dos.writeLong(context.getChunk().asLongChunk().get((int) row)); + dos.writeLong(longChunk.get((int) row)); } catch (final IOException e) { throw new UncheckedDeephavenException( "Unexpected exception while draining data to OutputStream: ", e); diff --git a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/MapChunkWriter.java b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/MapChunkWriter.java index 14edd16a31d..902bc8effb1 100644 --- a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/MapChunkWriter.java +++ b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/MapChunkWriter.java @@ -61,8 +61,9 @@ protected int computeNullCount( @NotNull final BaseChunkWriter.Context context, @NotNull final RowSequence subset) { final MutableInt nullCount = new MutableInt(0); + final ObjectChunk objectChunk = context.getChunk().asObjectChunk(); subset.forAllRowKeys(row -> { - if (context.getChunk().asObjectChunk().isNull((int) row)) { + if (objectChunk.isNull((int) row)) { nullCount.increment(); } }); @@ -74,9 +75,8 @@ protected void writeValidityBufferInternal( @NotNull final BaseChunkWriter.Context context, @NotNull final RowSequence subset, @NotNull final SerContext serContext) { - subset.forAllRowKeys(row -> { - serContext.setNextIsNull(context.getChunk().asObjectChunk().isNull((int) row)); - }); + final ObjectChunk objectChunk = context.getChunk().asObjectChunk(); + subset.forAllRowKeys(row -> serContext.setNextIsNull(objectChunk.isNull((int) row))); } public final class Context extends ChunkWriter.Context { diff --git a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/ShortChunkWriter.java b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/ShortChunkWriter.java index f15200ef09b..b8adb87bdfa 100644 --- a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/ShortChunkWriter.java +++ b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/ShortChunkWriter.java @@ -67,8 +67,9 @@ protected int computeNullCount( @NotNull final Context context, @NotNull final RowSequence subset) { final MutableInt nullCount = new MutableInt(0); + final ShortChunk shortChunk = context.getChunk().asShortChunk(); subset.forAllRowKeys(row -> { - if (context.getChunk().asShortChunk().isNull((int) row)) { + if (shortChunk.isNull((int) row)) { nullCount.increment(); } }); @@ -80,9 +81,8 @@ protected void writeValidityBufferInternal( @NotNull final Context context, @NotNull final RowSequence subset, @NotNull final SerContext serContext) { - subset.forAllRowKeys(row -> { - serContext.setNextIsNull(context.getChunk().asShortChunk().isNull((int) row)); - }); + final ShortChunk shortChunk = context.getChunk().asShortChunk(); + subset.forAllRowKeys(row -> serContext.setNextIsNull(shortChunk.isNull((int) row))); } private class ShortChunkInputStream extends BaseChunkInputStream { @@ -120,9 +120,10 @@ public int drainTo(final OutputStream outputStream) throws IOException { bytesWritten += writeValidityBuffer(dos); // write the payload buffer + final ShortChunk shortChunk = context.getChunk().asShortChunk(); subset.forAllRowKeys(row -> { try { - dos.writeShort(context.getChunk().asShortChunk().get((int) row)); + dos.writeShort(shortChunk.get((int) row)); } catch (final IOException e) { throw new UncheckedDeephavenException( "Unexpected exception while draining data to OutputStream: ", e); diff --git a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/UnionChunkWriter.java b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/UnionChunkWriter.java index 2d3cb86e35f..a5e706db253 100644 --- a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/UnionChunkWriter.java +++ b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/UnionChunkWriter.java @@ -63,8 +63,9 @@ protected int computeNullCount( @NotNull final ChunkWriter.Context context, @NotNull final RowSequence subset) { final MutableInt nullCount = new MutableInt(0); + final ObjectChunk objectChunk = context.getChunk().asObjectChunk(); subset.forAllRowKeys(row -> { - if (context.getChunk().asObjectChunk().isNull((int) row)) { + if (objectChunk.isNull((int) row)) { nullCount.increment(); } }); @@ -76,9 +77,8 @@ protected void writeValidityBufferInternal( @NotNull final ChunkWriter.Context context, @NotNull final RowSequence subset, @NotNull final SerContext serContext) { - subset.forAllRowKeys(row -> { - serContext.setNextIsNull(context.getChunk().asCharChunk().isNull((int) row)); - }); + final ObjectChunk objectChunk = context.getChunk().asObjectChunk(); + subset.forAllRowKeys(row -> serContext.setNextIsNull(objectChunk.isNull((int) row))); } public final class Context extends ChunkWriter.Context { @@ -123,17 +123,20 @@ private UnionChunkInputStream( // noinspection resource columnOfInterest = WritableByteChunk.makeWritableChunk(chunk.size()); // noinspection unchecked - final SizedChunk[] innerChunks = new SizedChunk[numColumns]; + final SizedChunk[] innerSizedChunks = new SizedChunk[numColumns]; + // noinspection unchecked + final WritableObjectChunk[] innerChunks = new WritableObjectChunk[numColumns]; for (int ii = 0; ii < numColumns; ++ii) { // noinspection resource - innerChunks[ii] = new SizedChunk<>(ChunkType.Object); + innerSizedChunks[ii] = new SizedChunk<>(ChunkType.Object); if (mode == UnionChunkReader.Mode.Sparse) { - innerChunks[ii].ensureCapacity(chunk.size()); - innerChunks[ii].get().fillWithNullValue(0, chunk.size()); + innerSizedChunks[ii].ensureCapacity(chunk.size()); + innerSizedChunks[ii].get().fillWithNullValue(0, chunk.size()); } else { - innerChunks[ii].ensureCapacity(0); + innerSizedChunks[ii].ensureCapacity(0); } + innerChunks[ii] = innerSizedChunks[ii].get().asWritableObjectChunk(); } for (int ii = 0; ii < chunk.size(); ++ii) { final Object value = chunk.get(ii); @@ -142,16 +145,17 @@ private UnionChunkInputStream( if (value.getClass().isAssignableFrom(classMatchers.get(jj))) { if (mode == UnionChunkReader.Mode.Sparse) { columnOfInterest.set(ii, (byte) jj); - innerChunks[jj].get().asWritableObjectChunk().set(ii, value); + innerChunks[jj].set(ii, value); } else { columnOfInterest.set(ii, (byte) jj); - int size = innerChunks[jj].get().size(); + int size = innerChunks[jj].size(); columnOffset.set(ii, size); - if (innerChunks[jj].get().capacity() <= size) { + if (innerChunks[jj].capacity() <= size) { int newSize = Math.max(16, size * 2); - innerChunks[jj].ensureCapacityPreserve(newSize); + innerSizedChunks[jj].ensureCapacityPreserve(newSize); + innerChunks[jj] = innerSizedChunks[jj].get().asWritableObjectChunk(); } - innerChunks[jj].get().asWritableObjectChunk().add(value); + innerChunks[jj].add(value); } break; } @@ -168,7 +172,7 @@ private UnionChunkInputStream( for (int ii = 0; ii < numColumns; ++ii) { final ChunkType chunkType = writerChunkTypes.get(ii); final ChunkWriter> writer = writers.get(ii); - final WritableObjectChunk innerChunk = innerChunks[ii].get().asWritableObjectChunk(); + final WritableObjectChunk innerChunk = innerChunks[ii]; if (classMatchers.get(ii) == Boolean.class) { // do a quick conversion to byte since the boolean unboxer expects bytes diff --git a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/VarBinaryChunkWriter.java b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/VarBinaryChunkWriter.java index ce14c54cd06..7e54c162e43 100644 --- a/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/VarBinaryChunkWriter.java +++ b/extensions/barrage/src/main/java/io/deephaven/extensions/barrage/chunk/VarBinaryChunkWriter.java @@ -61,8 +61,9 @@ protected int computeNullCount( @NotNull final ChunkWriter.Context context, @NotNull final RowSequence subset) { final MutableInt nullCount = new MutableInt(0); + final ObjectChunk objectChunk = context.getChunk().asObjectChunk(); subset.forAllRowKeys(row -> { - if (context.getChunk().asObjectChunk().isNull((int) row)) { + if (objectChunk.isNull((int) row)) { nullCount.increment(); } }); @@ -72,9 +73,8 @@ protected int computeNullCount( @Override protected void writeValidityBufferInternal(ChunkWriter.@NotNull Context context, @NotNull RowSequence subset, @NotNull SerContext serContext) { - subset.forAllRowKeys(row -> { - serContext.setNextIsNull(context.getChunk().asObjectChunk().isNull((int) row)); - }); + final ObjectChunk objectChunk = context.getChunk().asObjectChunk(); + subset.forAllRowKeys(row -> serContext.setNextIsNull(objectChunk.isNull((int) row))); } public final class Context extends ChunkWriter.Context { diff --git a/server/jetty/src/test/java/io/deephaven/server/jetty/JettyBarrageChunkFactoryTest.java b/server/jetty/src/test/java/io/deephaven/server/jetty/JettyBarrageChunkFactoryTest.java index ade04d7ec4d..515a0ea1ace 100644 --- a/server/jetty/src/test/java/io/deephaven/server/jetty/JettyBarrageChunkFactoryTest.java +++ b/server/jetty/src/test/java/io/deephaven/server/jetty/JettyBarrageChunkFactoryTest.java @@ -575,8 +575,7 @@ public Schema newSchema(boolean isNullable) { @Override public int initializeRoot(@NotNull UInt2Vector source) { int start = setAll(source::set, - (char) 6784, - QueryConstants.MIN_CHAR, QueryConstants.MAX_CHAR, (char) 1); + QueryConstants.MIN_CHAR, QueryConstants.MAX_CHAR, (char) 1); for (int ii = start; ii < NUM_ROWS; ++ii) { char value = (char) rnd.nextInt(); source.set(ii, value); @@ -626,7 +625,9 @@ private static int setAll(BiConsumer setter, T... values) { return values.length; } - protected enum NullMode { ALL, NONE, SOME, NOT_NULLABLE } + protected enum NullMode { + ALL, NONE, SOME, NOT_NULLABLE + } private abstract class RoundTripTest { protected final Random rnd = new Random(RANDOM_SEED); protected Class dhType; @@ -642,7 +643,9 @@ public RoundTripTest(@NotNull final Class dhType, @Nullable final Class co } public abstract Schema newSchema(boolean isNullable); + public abstract int initializeRoot(@NotNull final T source); + public abstract void validate(@NotNull final T source, @NotNull final T dest); public void doTest() throws Exception {