From e0f2166fc7d3b0dd03abf8384944b6f1f77dcce7 Mon Sep 17 00:00:00 2001 From: Ryan Caudy Date: Thu, 22 Jul 2021 12:13:46 -0400 Subject: [PATCH] Support arbitrary types in partitioning columns (#885) --- .../db/tables/utils/ParquetTools.java | 5 +- .../db/v2/PartitionAwareSourceTable.java | 16 +- .../locations/impl/TableLocationFactory.java | 2 +- .../local/DeephavenNestedPartitionLayout.java | 2 +- .../db/v2/sources/chunk/page/Page.java | 58 +++--- .../db/v2/sources/regioned/ColumnRegion.java | 21 ++- .../v2/sources/regioned/ColumnRegionByte.java | 45 ++++- .../v2/sources/regioned/ColumnRegionChar.java | 37 +++- .../sources/regioned/ColumnRegionDouble.java | 37 +++- .../sources/regioned/ColumnRegionFloat.java | 37 +++- .../v2/sources/regioned/ColumnRegionInt.java | 37 +++- .../v2/sources/regioned/ColumnRegionLong.java | 37 +++- .../sources/regioned/ColumnRegionObject.java | 49 ++++- .../sources/regioned/ColumnRegionShort.java | 37 +++- .../regioned/ParquetColumnRegionBase.java | 27 ++- .../regioned/ParquetColumnRegionByte.java | 16 +- .../regioned/ParquetColumnRegionChar.java | 1 - .../regioned/ParquetColumnRegionDouble.java | 10 +- .../regioned/ParquetColumnRegionFloat.java | 10 +- .../regioned/ParquetColumnRegionInt.java | 10 +- .../regioned/ParquetColumnRegionLong.java | 10 +- .../regioned/ParquetColumnRegionShort.java | 10 +- .../regioned/PartitioningSourceFactory.java | 37 ++++ .../regioned/RegionedColumnSourceByte.java | 63 +++++-- .../regioned/RegionedColumnSourceChar.java | 47 +++-- .../regioned/RegionedColumnSourceDouble.java | 63 +++++-- .../regioned/RegionedColumnSourceFloat.java | 63 +++++-- .../regioned/RegionedColumnSourceInt.java | 63 +++++-- .../regioned/RegionedColumnSourceLong.java | 63 +++++-- .../regioned/RegionedColumnSourceObject.java | 54 ++++-- .../RegionedColumnSourcePartitioning.java | 58 ------ .../regioned/RegionedColumnSourceShort.java | 63 +++++-- .../RegionedColumnSourceStringSet.java | 7 - .../sources/regioned/RegionedPageStore.java | 26 +-- .../RegionedTableComponentFactoryImpl.java | 6 +- .../db/tables/utils/TestParquetTools.java | 18 +- .../db/v2/TestPartitioningColumns.java | 175 ++++++++++++++++++ .../datastructures/util/CollectionUtil.json | 25 +++ .../datastructures/util/HashCodeUtil.json | 10 + .../datastructures/util/SmartKey.json | 14 ++ .../db/v2/sources/chunk/page/Page.json | 2 +- .../sources/chunk/page/Page/WithDefaults.json | 1 + .../Page/WithDefaultsForRepeatingValues.json | 2 +- .../regioned/ColumnRegionByte/Constant.json | 10 + .../regioned/ColumnRegionChar/Constant.json | 9 + .../regioned/ColumnRegionDouble/Constant.json | 9 + .../regioned/ColumnRegionFloat/Constant.json | 9 + .../regioned/ColumnRegionInt/Constant.json | 9 + .../regioned/ColumnRegionLong/Constant.json | 9 + .../sources/regioned/ColumnRegionObject.json | 4 +- .../regioned/ColumnRegionObject/Constant.json | 10 + .../regioned/ColumnRegionObject/Null.json | 4 +- .../regioned/ColumnRegionShort/Constant.json | 9 + 53 files changed, 1069 insertions(+), 387 deletions(-) create mode 100644 DB/src/main/java/io/deephaven/db/v2/sources/regioned/PartitioningSourceFactory.java delete mode 100644 DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourcePartitioning.java create mode 100644 DB/src/test/java/io/deephaven/db/v2/TestPartitioningColumns.java create mode 100644 Integrations/python/deephaven/doc/io/deephaven/datastructures/util/CollectionUtil.json create mode 100644 Integrations/python/deephaven/doc/io/deephaven/datastructures/util/HashCodeUtil.json create mode 100644 Integrations/python/deephaven/doc/io/deephaven/datastructures/util/SmartKey.json create mode 100644 Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionByte/Constant.json create mode 100644 Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionChar/Constant.json create mode 100644 Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionDouble/Constant.json create mode 100644 Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionFloat/Constant.json create mode 100644 Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionInt/Constant.json create mode 100644 Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionLong/Constant.json create mode 100644 Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionObject/Constant.json create mode 100644 Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionShort/Constant.json diff --git a/DB/src/main/java/io/deephaven/db/tables/utils/ParquetTools.java b/DB/src/main/java/io/deephaven/db/tables/utils/ParquetTools.java index ff3c0bcde20..173c1f72c85 100644 --- a/DB/src/main/java/io/deephaven/db/tables/utils/ParquetTools.java +++ b/DB/src/main/java/io/deephaven/db/tables/utils/ParquetTools.java @@ -32,10 +32,12 @@ import io.deephaven.db.v2.sources.regioned.RegionedTableComponentFactoryImpl; import io.deephaven.internal.log.LoggerFactory; import io.deephaven.util.annotations.VisibleForTesting; +import io.deephaven.util.type.TypeUtils; import org.apache.commons.lang3.mutable.MutableObject; import org.jetbrains.annotations.NotNull; import static io.deephaven.db.v2.parquet.ParquetTableWriter.PARQUET_FILE_EXTENSION; +import static io.deephaven.util.type.TypeUtils.getUnboxedTypeIfBoxed; import java.io.File; import java.io.IOException; @@ -433,7 +435,8 @@ public static Table readMultiFileTable( if (partitionValue == null) { throw new IllegalArgumentException("First location key " + firstKey + " has null partition value at partition key " + partitionKey); } - allColumns.add(ColumnDefinition.fromGenericType(partitionKey, partitionValue.getClass(), ColumnDefinition.COLUMNTYPE_PARTITIONING, null)); + //noinspection unchecked + allColumns.add(ColumnDefinition.fromGenericType(partitionKey, getUnboxedTypeIfBoxed(partitionValue.getClass()), ColumnDefinition.COLUMNTYPE_PARTITIONING, null)); } allColumns.addAll(schemaInfo.getFirst()); return readMultiFileTable(recordingLocationKeyFinder, schemaInfo.getSecond(), new TableDefinition(allColumns)); diff --git a/DB/src/main/java/io/deephaven/db/v2/PartitionAwareSourceTable.java b/DB/src/main/java/io/deephaven/db/v2/PartitionAwareSourceTable.java index 253f89575c7..fe3c7a2fd39 100644 --- a/DB/src/main/java/io/deephaven/db/v2/PartitionAwareSourceTable.java +++ b/DB/src/main/java/io/deephaven/db/v2/PartitionAwareSourceTable.java @@ -18,10 +18,11 @@ import io.deephaven.db.v2.select.*; import io.deephaven.db.v2.sources.ArrayBackedColumnSource; import io.deephaven.db.v2.sources.ColumnSource; +import io.deephaven.db.v2.sources.WritableSource; +import org.apache.commons.lang3.mutable.MutableLong; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.lang.reflect.Array; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -194,10 +195,13 @@ protected final Table redefine(TableDefinition newDefinitionExternal, TableDefin @SuppressWarnings("unchecked") private static ColumnSource makePartitionSource(@NotNull final ColumnDefinition columnDefinition, @NotNull final Collection locationKeys) { final Class dataType = columnDefinition.getDataType(); - final T[] partitionValues = locationKeys.stream() - .map(lk -> (T) lk.getPartitionValue(columnDefinition.getName())) - .toArray(sz -> (T[]) Array.newInstance(dataType, sz)); - return ArrayBackedColumnSource.getMemoryColumnSource(partitionValues, dataType, columnDefinition.getComponentType()); + final String partitionKey = columnDefinition.getName(); + final WritableSource result = ArrayBackedColumnSource.getMemoryColumnSource(locationKeys.size(), dataType, null); + final MutableLong nextIndex = new MutableLong(0L); + locationKeys.stream() + .map(lk -> (T) lk.getPartitionValue(partitionKey)) + .forEach((final T partitionValue) -> result.set(nextIndex.getAndIncrement(), partitionValue)); + return result; } @Override @@ -261,7 +265,7 @@ public final Table where(SelectFilter... filters) { return deferredViewTable; } - SelectFilter[] partitionFilterArray = partitionFilters.toArray(new SelectFilter[partitionFilters.size()]); + SelectFilter[] partitionFilterArray = partitionFilters.toArray(SelectFilter.ZERO_LENGTH_SELECT_FILTER_ARRAY); final String filteredTableDescription = "getFilteredTable(" + Arrays.toString(partitionFilterArray) + ")"; SourceTable filteredTable = QueryPerformanceRecorder.withNugget(filteredTableDescription, () -> getFilteredTable(partitionFilterArray)); diff --git a/DB/src/main/java/io/deephaven/db/v2/locations/impl/TableLocationFactory.java b/DB/src/main/java/io/deephaven/db/v2/locations/impl/TableLocationFactory.java index 39575a172c4..06d8e306055 100644 --- a/DB/src/main/java/io/deephaven/db/v2/locations/impl/TableLocationFactory.java +++ b/DB/src/main/java/io/deephaven/db/v2/locations/impl/TableLocationFactory.java @@ -23,5 +23,5 @@ public interface TableLocationFactory locationKeyObserver) { boolean needToUpdateInternalPartitionValue = true; try (final DirectoryStream columnPartitionStream = Files.newDirectoryStream(internalPartition, Files::isDirectory)) { for (final Path columnPartition : columnPartitionStream) { - partitions.put(columnPartitionKey, columnPartition.getFileName().toFile()); + partitions.put(columnPartitionKey, columnPartition.getFileName().toString()); if (needToUpdateInternalPartitionValue) { // Partition order dictates comparison priority, so we need to insert the internal partition after the column partition. partitions.put(INTERNAL_PARTITION_KEY, internalPartitionValue); diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/chunk/page/Page.java b/DB/src/main/java/io/deephaven/db/v2/sources/chunk/page/Page.java index 07c0e97fd48..bd63e6cf67c 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/chunk/page/Page.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/chunk/page/Page.java @@ -1,8 +1,8 @@ package io.deephaven.db.v2.sources.chunk.page; import io.deephaven.db.util.LongSizedDataStructure; +import io.deephaven.db.v2.sources.chunk.Attributes.Any; import io.deephaven.db.v2.sources.chunk.ChunkSource; -import io.deephaven.db.v2.sources.chunk.Attributes; import io.deephaven.db.v2.sources.chunk.DefaultChunkSource; import io.deephaven.db.v2.sources.chunk.WritableChunk; import io.deephaven.db.v2.utils.OrderedKeys; @@ -12,27 +12,27 @@ /** * This provides the {@link ChunkSource} interface to a contiguous block of data from * the range [{@link #firstRowOffset()},{@link #firstRowOffset()} + {@link #length()}). - * + *

* Non overlapping pages can be collected together in a {@link PageStore}, which provides the {@link ChunkSource} * interface to the collection of all of its Pages. - * + *

* There are two distinct use cases/types of pages. The first use case are {@code Page}s which always have a * length() > 0. These store length() values, which can be assessed via the {@link ChunkSource} methods. * Valid {@link OrderedKeys} passed to those methods will have their offset in the range * [firstRowOffset(), firstRowOffset() + length()). Passing OrderKeys with offsets outside of this range will have * undefined results. - * + *

* The second use case will always have length() == 0 and firstRowOffset() == 0. These represent "Null" regions * which return a fixed value, typically a null value, for every {@link OrderedKeys} passed into the * {@link ChunkSource} methods. In order to have this use case, override {@code length} and override {@code lastRow} * as {@code maxRow}. - * + *

* Though the {@link ChunkSource} methods ignore the non-offset portion of the rows in the {@link OrderedKeys}, * then can assume they are identical for all the passed in elements of the {@link OrderedKeys}. For instance, * they can use the simple difference between the complete row value to determine a length. */ -public interface Page extends PagingChunkSource { +public interface Page extends PagingChunkSource { /** * @return the first row of this page, after applying the {@link #mask()}, which refers to the first row of this @@ -45,7 +45,7 @@ public interface Page extends PagingChunkSource extends Page, DefaultChunkSource { + /** + * Helper defaults for general pages. + */ + interface WithDefaults extends Page, DefaultChunkSource { - @Override @FinalDefault - default void fillChunkAppend(@NotNull FillContext context, @NotNull WritableChunk destination, @NotNull OrderedKeys.Iterator orderedKeysIterator) { - fillChunkAppend(context, destination, orderedKeysIterator.getNextOrderedKeysThrough(maxRow(orderedKeysIterator.peekNextKey()))); + @Override + @FinalDefault + default void fillChunkAppend(@NotNull final FillContext context, @NotNull final WritableChunk destination, @NotNull final OrderedKeys.Iterator orderedKeysIterator) { + fillChunkAppend(context, destination, orderedKeysIterator.getNextOrderedKeysThrough(maxRow(orderedKeysIterator.peekNextKey()))); } - @Override @FinalDefault - default void fillChunk(@NotNull FillContext context, @NotNull WritableChunk destination, @NotNull OrderedKeys orderedKeys) { + @Override + @FinalDefault + default void fillChunk(@NotNull final FillContext context, @NotNull final WritableChunk destination, @NotNull final OrderedKeys orderedKeys) { destination.setSize(0); fillChunkAppend(context, destination, orderedKeys); } @@ -95,29 +100,32 @@ default void fillChunk(@NotNull FillContext context, @NotNull WritableChunk extends Page, DefaultChunkSource { - interface WithDefaultsForRepeatingValues extends Page, DefaultChunkSource { - - @Override @FinalDefault + @Override + @FinalDefault default long length() { return 0; } - @Override @FinalDefault - default long lastRow(long row) { + @Override + @FinalDefault + default long lastRow(final long row) { return maxRow(row); } - @Override @FinalDefault - default void fillChunkAppend(@NotNull FillContext context, @NotNull WritableChunk destination, @NotNull OrderedKeys.Iterator orderedKeysIterator) { + @Override + @FinalDefault + default void fillChunkAppend(@NotNull final FillContext context, @NotNull final WritableChunk destination, @NotNull final OrderedKeys.Iterator orderedKeysIterator) { fillChunkAppend(context, destination, LongSizedDataStructure.intSize("fillChunkAppend", - orderedKeysIterator.advanceAndGetPositionDistance(maxRow(orderedKeysIterator.peekNextKey())))); + orderedKeysIterator.advanceAndGetPositionDistance(maxRow(orderedKeysIterator.peekNextKey())))); } - @Override @FinalDefault - default void fillChunk(@NotNull FillContext context, @NotNull WritableChunk destination, @NotNull OrderedKeys orderedKeys) { + @Override + @FinalDefault + default void fillChunk(@NotNull final FillContext context, @NotNull final WritableChunk destination, @NotNull final OrderedKeys orderedKeys) { destination.setSize(0); fillChunkAppend(context, destination, orderedKeys.intSize()); } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegion.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegion.java index 7ee18881cce..1bcc2c593b6 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegion.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegion.java @@ -1,37 +1,40 @@ package io.deephaven.db.v2.sources.regioned; import io.deephaven.db.v2.sources.Releasable; -import io.deephaven.db.v2.sources.chunk.Attributes; +import io.deephaven.db.v2.sources.chunk.Attributes.Any; import io.deephaven.db.v2.sources.chunk.WritableChunk; import io.deephaven.db.v2.sources.chunk.page.Page; import io.deephaven.util.annotations.FinalDefault; import org.jetbrains.annotations.NotNull; -public interface ColumnRegion extends Page, Releasable { +public interface ColumnRegion extends Page, Releasable { + long REGION_MASK = RegionedPageStore.REGION_MASK; - @Override @FinalDefault + @Override + @FinalDefault default long mask() { return REGION_MASK; } - @Override @FinalDefault + @Override + @FinalDefault default long firstRowOffset() { return 0; } - abstract class Null + abstract class Null implements ColumnRegion, WithDefaultsForRepeatingValues { - Null() {} + Null() { + } @Override - public void fillChunkAppend(@NotNull FillContext context, @NotNull WritableChunk destination, int length) { - int offset = destination.size(); + public void fillChunkAppend(@NotNull final FillContext context, @NotNull final WritableChunk destination, final int length) { + final int offset = destination.size(); destination.fillWithNullValue(offset, length); destination.setSize(offset + length); } } - } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionByte.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionByte.java index 70b27cfdf0f..ab40e7d7c53 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionByte.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionByte.java @@ -1,7 +1,8 @@ package io.deephaven.db.v2.sources.regioned; +import io.deephaven.db.v2.sources.chunk.Attributes.Any; +import io.deephaven.db.v2.sources.chunk.WritableChunk; import io.deephaven.util.QueryConstants; -import io.deephaven.db.v2.sources.chunk.Attributes; import org.jetbrains.annotations.NotNull; import java.util.Arrays; @@ -9,7 +10,7 @@ /** * Column region interface for regions that support fetching primitive bytes. */ -public interface ColumnRegionByte extends ColumnRegion { +public interface ColumnRegionByte extends ColumnRegion { /** * Get a single byte from this region. @@ -27,7 +28,7 @@ public interface ColumnRegionByte extends ColumnReg * @param elementIndex Element (byte) index in the table's address space * @return The byte value at the specified element (byte) index */ - default byte getByte(@NotNull FillContext context, long elementIndex) { + default byte getByte(@NotNull final FillContext context, final long elementIndex) { return getByte(elementIndex); } @@ -52,26 +53,54 @@ default Class getNativeType() { return byte.class; } - static ColumnRegionByte.Null createNull() { + static ColumnRegionByte.Null createNull() { //noinspection unchecked return Null.INSTANCE; } - final class Null extends ColumnRegion.Null implements ColumnRegionByte { + final class Null extends ColumnRegion.Null implements ColumnRegionByte { @SuppressWarnings("rawtypes") private static final ColumnRegionByte.Null INSTANCE = new ColumnRegionByte.Null(); - private Null() {} + private Null() { + } @Override - public byte getByte(long elementIndex) { + public byte getByte(final long elementIndex) { return QueryConstants.NULL_BYTE; } @Override - public byte[] getBytes(long firstElementIndex, @NotNull byte[] destination, int destinationOffset, int length) { + public byte[] getBytes(final long firstElementIndex, @NotNull final byte[] destination, final int destinationOffset, final int length) { Arrays.fill(destination, destinationOffset, destinationOffset + length, QueryConstants.NULL_BYTE); return destination; } } + + final class Constant implements ColumnRegionByte, WithDefaultsForRepeatingValues { + + private final byte value; + + public Constant(final byte value) { + this.value = value; + } + + @Override + public byte getByte(final long elementIndex) { + return value; + } + + @Override + public void fillChunkAppend(@NotNull final FillContext context, @NotNull final WritableChunk destination, final int length) { + final int offset = destination.size(); + destination.asWritableByteChunk().fillWithValue(offset, length, value); + destination.setSize(offset + length); + } + + @Override + public byte[] getBytes(final long firstElementIndex, @NotNull final byte[] destination, final int destinationOffset, final int length) { + Arrays.fill(destination, destinationOffset, destinationOffset + length, value); + return destination; + } + } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionChar.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionChar.java index 544aaf59eb7..01c0ed58d59 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionChar.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionChar.java @@ -1,13 +1,14 @@ package io.deephaven.db.v2.sources.regioned; +import io.deephaven.db.v2.sources.chunk.Attributes.Any; +import io.deephaven.db.v2.sources.chunk.WritableChunk; import io.deephaven.util.QueryConstants; -import io.deephaven.db.v2.sources.chunk.Attributes; import org.jetbrains.annotations.NotNull; /** * Column region interface for regions that support fetching primitive chars. */ -public interface ColumnRegionChar extends ColumnRegion { +public interface ColumnRegionChar extends ColumnRegion { /** * Get a single char from this region. @@ -25,7 +26,7 @@ public interface ColumnRegionChar extends ColumnReg * @param elementIndex Element (char) index in the table's address space * @return The char value at the specified element (char) index */ - default char getChar(@NotNull FillContext context, long elementIndex) { + default char getChar(@NotNull final FillContext context, final long elementIndex) { return getChar(elementIndex); } @@ -34,20 +35,42 @@ default Class getNativeType() { return char.class; } - static ColumnRegionChar.Null createNull() { + static ColumnRegionChar.Null createNull() { //noinspection unchecked return Null.INSTANCE; } - final class Null extends ColumnRegion.Null implements ColumnRegionChar { + final class Null extends ColumnRegion.Null implements ColumnRegionChar { @SuppressWarnings("rawtypes") private static final ColumnRegionChar.Null INSTANCE = new ColumnRegionChar.Null(); - private Null() {} + private Null() { + } @Override - public char getChar(long elementIndex) { + public char getChar(final long elementIndex) { return QueryConstants.NULL_CHAR; } } + + final class Constant implements ColumnRegionChar, WithDefaultsForRepeatingValues { + + private final char value; + + public Constant(final char value) { + this.value = value; + } + + @Override + public char getChar(final long elementIndex) { + return value; + } + + @Override + public void fillChunkAppend(@NotNull final FillContext context, @NotNull final WritableChunk destination, final int length) { + final int offset = destination.size(); + destination.asWritableCharChunk().fillWithValue(offset, length, value); + destination.setSize(offset + length); + } + } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionDouble.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionDouble.java index 1ea1b8e2572..1377b9e849d 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionDouble.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionDouble.java @@ -3,14 +3,15 @@ * ------------------------------------------------------------------------------------------------------------------ */ package io.deephaven.db.v2.sources.regioned; +import io.deephaven.db.v2.sources.chunk.Attributes.Any; +import io.deephaven.db.v2.sources.chunk.WritableChunk; import io.deephaven.util.QueryConstants; -import io.deephaven.db.v2.sources.chunk.Attributes; import org.jetbrains.annotations.NotNull; /** * Column region interface for regions that support fetching primitive doubles. */ -public interface ColumnRegionDouble extends ColumnRegion { +public interface ColumnRegionDouble extends ColumnRegion { /** * Get a single double from this region. @@ -28,7 +29,7 @@ public interface ColumnRegionDouble extends ColumnR * @param elementIndex Element (double) index in the table's address space * @return The double value at the specified element (double) index */ - default double getDouble(@NotNull FillContext context, long elementIndex) { + default double getDouble(@NotNull final FillContext context, final long elementIndex) { return getDouble(elementIndex); } @@ -37,20 +38,42 @@ default Class getNativeType() { return double.class; } - static ColumnRegionDouble.Null createNull() { + static ColumnRegionDouble.Null createNull() { //noinspection unchecked return Null.INSTANCE; } - final class Null extends ColumnRegion.Null implements ColumnRegionDouble { + final class Null extends ColumnRegion.Null implements ColumnRegionDouble { @SuppressWarnings("rawtypes") private static final ColumnRegionDouble.Null INSTANCE = new ColumnRegionDouble.Null(); - private Null() {} + private Null() { + } @Override - public double getDouble(long elementIndex) { + public double getDouble(final long elementIndex) { return QueryConstants.NULL_DOUBLE; } } + + final class Constant implements ColumnRegionDouble, WithDefaultsForRepeatingValues { + + private final double value; + + public Constant(final double value) { + this.value = value; + } + + @Override + public double getDouble(final long elementIndex) { + return value; + } + + @Override + public void fillChunkAppend(@NotNull final FillContext context, @NotNull final WritableChunk destination, final int length) { + final int offset = destination.size(); + destination.asWritableDoubleChunk().fillWithValue(offset, length, value); + destination.setSize(offset + length); + } + } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionFloat.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionFloat.java index beab9a49f15..81915370ac3 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionFloat.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionFloat.java @@ -3,14 +3,15 @@ * ------------------------------------------------------------------------------------------------------------------ */ package io.deephaven.db.v2.sources.regioned; +import io.deephaven.db.v2.sources.chunk.Attributes.Any; +import io.deephaven.db.v2.sources.chunk.WritableChunk; import io.deephaven.util.QueryConstants; -import io.deephaven.db.v2.sources.chunk.Attributes; import org.jetbrains.annotations.NotNull; /** * Column region interface for regions that support fetching primitive floats. */ -public interface ColumnRegionFloat extends ColumnRegion { +public interface ColumnRegionFloat extends ColumnRegion { /** * Get a single float from this region. @@ -28,7 +29,7 @@ public interface ColumnRegionFloat extends ColumnRe * @param elementIndex Element (float) index in the table's address space * @return The float value at the specified element (float) index */ - default float getFloat(@NotNull FillContext context, long elementIndex) { + default float getFloat(@NotNull final FillContext context, final long elementIndex) { return getFloat(elementIndex); } @@ -37,20 +38,42 @@ default Class getNativeType() { return float.class; } - static ColumnRegionFloat.Null createNull() { + static ColumnRegionFloat.Null createNull() { //noinspection unchecked return Null.INSTANCE; } - final class Null extends ColumnRegion.Null implements ColumnRegionFloat { + final class Null extends ColumnRegion.Null implements ColumnRegionFloat { @SuppressWarnings("rawtypes") private static final ColumnRegionFloat.Null INSTANCE = new ColumnRegionFloat.Null(); - private Null() {} + private Null() { + } @Override - public float getFloat(long elementIndex) { + public float getFloat(final long elementIndex) { return QueryConstants.NULL_FLOAT; } } + + final class Constant implements ColumnRegionFloat, WithDefaultsForRepeatingValues { + + private final float value; + + public Constant(final float value) { + this.value = value; + } + + @Override + public float getFloat(final long elementIndex) { + return value; + } + + @Override + public void fillChunkAppend(@NotNull final FillContext context, @NotNull final WritableChunk destination, final int length) { + final int offset = destination.size(); + destination.asWritableFloatChunk().fillWithValue(offset, length, value); + destination.setSize(offset + length); + } + } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionInt.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionInt.java index ae4e93db20f..79d2704dc84 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionInt.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionInt.java @@ -3,14 +3,15 @@ * ------------------------------------------------------------------------------------------------------------------ */ package io.deephaven.db.v2.sources.regioned; +import io.deephaven.db.v2.sources.chunk.Attributes.Any; +import io.deephaven.db.v2.sources.chunk.WritableChunk; import io.deephaven.util.QueryConstants; -import io.deephaven.db.v2.sources.chunk.Attributes; import org.jetbrains.annotations.NotNull; /** * Column region interface for regions that support fetching primitive ints. */ -public interface ColumnRegionInt extends ColumnRegion { +public interface ColumnRegionInt extends ColumnRegion { /** * Get a single int from this region. @@ -28,7 +29,7 @@ public interface ColumnRegionInt extends ColumnRegi * @param elementIndex Element (int) index in the table's address space * @return The int value at the specified element (int) index */ - default int getInt(@NotNull FillContext context, long elementIndex) { + default int getInt(@NotNull final FillContext context, final long elementIndex) { return getInt(elementIndex); } @@ -37,20 +38,42 @@ default Class getNativeType() { return int.class; } - static ColumnRegionInt.Null createNull() { + static ColumnRegionInt.Null createNull() { //noinspection unchecked return Null.INSTANCE; } - final class Null extends ColumnRegion.Null implements ColumnRegionInt { + final class Null extends ColumnRegion.Null implements ColumnRegionInt { @SuppressWarnings("rawtypes") private static final ColumnRegionInt.Null INSTANCE = new ColumnRegionInt.Null(); - private Null() {} + private Null() { + } @Override - public int getInt(long elementIndex) { + public int getInt(final long elementIndex) { return QueryConstants.NULL_INT; } } + + final class Constant implements ColumnRegionInt, WithDefaultsForRepeatingValues { + + private final int value; + + public Constant(final int value) { + this.value = value; + } + + @Override + public int getInt(final long elementIndex) { + return value; + } + + @Override + public void fillChunkAppend(@NotNull final FillContext context, @NotNull final WritableChunk destination, final int length) { + final int offset = destination.size(); + destination.asWritableIntChunk().fillWithValue(offset, length, value); + destination.setSize(offset + length); + } + } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionLong.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionLong.java index 30456923753..d41e57e51b8 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionLong.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionLong.java @@ -3,14 +3,15 @@ * ------------------------------------------------------------------------------------------------------------------ */ package io.deephaven.db.v2.sources.regioned; +import io.deephaven.db.v2.sources.chunk.Attributes.Any; +import io.deephaven.db.v2.sources.chunk.WritableChunk; import io.deephaven.util.QueryConstants; -import io.deephaven.db.v2.sources.chunk.Attributes; import org.jetbrains.annotations.NotNull; /** * Column region interface for regions that support fetching primitive longs. */ -public interface ColumnRegionLong extends ColumnRegion { +public interface ColumnRegionLong extends ColumnRegion { /** * Get a single long from this region. @@ -28,7 +29,7 @@ public interface ColumnRegionLong extends ColumnReg * @param elementIndex Element (long) index in the table's address space * @return The long value at the specified element (long) index */ - default long getLong(@NotNull FillContext context, long elementIndex) { + default long getLong(@NotNull final FillContext context, final long elementIndex) { return getLong(elementIndex); } @@ -37,20 +38,42 @@ default Class getNativeType() { return long.class; } - static ColumnRegionLong.Null createNull() { + static ColumnRegionLong.Null createNull() { //noinspection unchecked return Null.INSTANCE; } - final class Null extends ColumnRegion.Null implements ColumnRegionLong { + final class Null extends ColumnRegion.Null implements ColumnRegionLong { @SuppressWarnings("rawtypes") private static final ColumnRegionLong.Null INSTANCE = new ColumnRegionLong.Null(); - private Null() {} + private Null() { + } @Override - public long getLong(long elementIndex) { + public long getLong(final long elementIndex) { return QueryConstants.NULL_LONG; } } + + final class Constant implements ColumnRegionLong, WithDefaultsForRepeatingValues { + + private final long value; + + public Constant(final long value) { + this.value = value; + } + + @Override + public long getLong(final long elementIndex) { + return value; + } + + @Override + public void fillChunkAppend(@NotNull final FillContext context, @NotNull final WritableChunk destination, final int length) { + final int offset = destination.size(); + destination.asWritableLongChunk().fillWithValue(offset, length, value); + destination.setSize(offset + length); + } + } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionObject.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionObject.java index 3a5c72d276d..41fc53fd192 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionObject.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionObject.java @@ -1,12 +1,13 @@ package io.deephaven.db.v2.sources.regioned; -import io.deephaven.db.v2.sources.chunk.Attributes; +import io.deephaven.db.v2.sources.chunk.Attributes.Any; +import io.deephaven.db.v2.sources.chunk.WritableChunk; import org.jetbrains.annotations.NotNull; /** * Column region interface for regions that support fetching objects. */ -public interface ColumnRegionObject extends ColumnRegion { +public interface ColumnRegionObject extends ColumnRegion { /** * Get a single object from this region. @@ -14,7 +15,7 @@ public interface ColumnRegionObject extends Colu * @param elementIndex Element (object) index in the table's address space * @return The object value at the specified element (object) index */ - T getObject(long elementIndex); + DATA_TYPE getObject(long elementIndex); /** * Get a single object from this region. @@ -24,30 +25,32 @@ public interface ColumnRegionObject extends Colu * @param elementIndex Element (object) index in the table's address space * @return The object value at the specified element (object) index */ - default T getObject(@NotNull FillContext context, long elementIndex) { + default DATA_TYPE getObject(@NotNull final FillContext context, final long elementIndex) { return getObject(elementIndex); } - default ColumnRegionObject skipCache() { + default ColumnRegionObject skipCache() { return this; } @Override Class getNativeType(); - static ColumnRegionObject.Null createNull() { + static ColumnRegionObject.Null createNull() { //noinspection unchecked return Null.INSTANCE; } - class Null extends ColumnRegion.Null implements ColumnRegionObject { + class Null extends ColumnRegion.Null implements ColumnRegionObject { + @SuppressWarnings("rawtypes") private static final ColumnRegionObject.Null INSTANCE = new ColumnRegionObject.Null(); - Null() {} + Null() { + } @Override - public T getObject(long elementIndex) { + public DATA_TYPE getObject(final long elementIndex) { return null; } @@ -56,8 +59,34 @@ public T getObject(long elementIndex) { * @implNote This is never called, so we just return null so this class can remain a singleton. */ @Override - public Class getNativeType() { + public Class getNativeType() { return null; } } + + final class Constant implements ColumnRegionObject, WithDefaultsForRepeatingValues { + + private final DATA_TYPE value; + + public Constant(final DATA_TYPE value) { + this.value = value; + } + + @Override + public Class getNativeType() { + return value.getClass(); + } + + @Override + public DATA_TYPE getObject(final long elementIndex) { + return value; + } + + @Override + public void fillChunkAppend(@NotNull final FillContext context, @NotNull final WritableChunk destination, final int length) { + final int offset = destination.size(); + destination.asWritableObjectChunk().fillWithValue(offset, length, value); + destination.setSize(offset + length); + } + } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionShort.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionShort.java index c3d69a36019..2aaed1f7fea 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionShort.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ColumnRegionShort.java @@ -3,14 +3,15 @@ * ------------------------------------------------------------------------------------------------------------------ */ package io.deephaven.db.v2.sources.regioned; +import io.deephaven.db.v2.sources.chunk.Attributes.Any; +import io.deephaven.db.v2.sources.chunk.WritableChunk; import io.deephaven.util.QueryConstants; -import io.deephaven.db.v2.sources.chunk.Attributes; import org.jetbrains.annotations.NotNull; /** * Column region interface for regions that support fetching primitive shorts. */ -public interface ColumnRegionShort extends ColumnRegion { +public interface ColumnRegionShort extends ColumnRegion { /** * Get a single short from this region. @@ -28,7 +29,7 @@ public interface ColumnRegionShort extends ColumnRe * @param elementIndex Element (short) index in the table's address space * @return The short value at the specified element (short) index */ - default short getShort(@NotNull FillContext context, long elementIndex) { + default short getShort(@NotNull final FillContext context, final long elementIndex) { return getShort(elementIndex); } @@ -37,20 +38,42 @@ default Class getNativeType() { return short.class; } - static ColumnRegionShort.Null createNull() { + static ColumnRegionShort.Null createNull() { //noinspection unchecked return Null.INSTANCE; } - final class Null extends ColumnRegion.Null implements ColumnRegionShort { + final class Null extends ColumnRegion.Null implements ColumnRegionShort { @SuppressWarnings("rawtypes") private static final ColumnRegionShort.Null INSTANCE = new ColumnRegionShort.Null(); - private Null() {} + private Null() { + } @Override - public short getShort(long elementIndex) { + public short getShort(final long elementIndex) { return QueryConstants.NULL_SHORT; } } + + final class Constant implements ColumnRegionShort, WithDefaultsForRepeatingValues { + + private final short value; + + public Constant(final short value) { + this.value = value; + } + + @Override + public short getShort(final long elementIndex) { + return value; + } + + @Override + public void fillChunkAppend(@NotNull final FillContext context, @NotNull final WritableChunk destination, final int length) { + final int offset = destination.size(); + destination.asWritableShortChunk().fillWithValue(offset, length, value); + destination.setSize(offset + length); + } + } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionBase.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionBase.java index 110cd419404..0c43a9ae5dc 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionBase.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionBase.java @@ -1,9 +1,8 @@ package io.deephaven.db.v2.sources.regioned; import io.deephaven.base.verify.Require; -import javax.annotation.OverridingMethodsMustInvokeSuper; import io.deephaven.db.v2.locations.parquet.ColumnChunkPageStore; -import io.deephaven.db.v2.sources.chunk.Attributes; +import io.deephaven.db.v2.sources.chunk.Attributes.Any; import io.deephaven.db.v2.sources.chunk.Chunk; import io.deephaven.db.v2.sources.chunk.SharedContext; import io.deephaven.db.v2.sources.chunk.WritableChunk; @@ -11,12 +10,13 @@ import io.deephaven.db.v2.utils.OrderedKeys; import org.jetbrains.annotations.NotNull; -public class ParquetColumnRegionBase implements ParquetColumnRegion { +import javax.annotation.OverridingMethodsMustInvokeSuper; + +public class ParquetColumnRegionBase implements ParquetColumnRegion { - @NotNull private final ColumnChunkPageStore columnChunkPageStore; - ParquetColumnRegionBase(@NotNull ColumnChunkPageStore columnChunkPageStore) { + ParquetColumnRegionBase(@NotNull final ColumnChunkPageStore columnChunkPageStore) { this.columnChunkPageStore = Require.neqNull(columnChunkPageStore, "columnChunkPageStore"); // We are making the following assumptions, so these basic functions are inlined rather than virtual calls. @@ -36,27 +36,27 @@ final public Class getNativeType() { } @Override - public Chunk getChunk(@NotNull GetContext context, @NotNull OrderedKeys orderedKeys) { + public Chunk getChunk(@NotNull final GetContext context, @NotNull final OrderedKeys orderedKeys) { return columnChunkPageStore.getChunk(context, orderedKeys); } @Override - public Chunk getChunk(@NotNull GetContext context, long firstKey, long lastKey) { + public Chunk getChunk(@NotNull final GetContext context, final long firstKey, final long lastKey) { return columnChunkPageStore.getChunk(context, firstKey, lastKey); } @Override - public void fillChunk(@NotNull FillContext context, @NotNull WritableChunk destination, @NotNull OrderedKeys orderedKeys) { + public void fillChunk(@NotNull final FillContext context, @NotNull final WritableChunk destination, @NotNull final OrderedKeys orderedKeys) { columnChunkPageStore.fillChunk(context, destination, orderedKeys); } @Override - public void fillChunkAppend(@NotNull FillContext context, @NotNull WritableChunk destination, @NotNull OrderedKeys.Iterator orderedKeysIterator) { + public void fillChunkAppend(@NotNull final FillContext context, @NotNull final WritableChunk destination, @NotNull final OrderedKeys.Iterator orderedKeysIterator) { columnChunkPageStore.fillChunkAppend(context, destination, orderedKeysIterator); } @Override - final public ChunkPage getChunkPageContaining(long elementIndex) { + final public ChunkPage getChunkPageContaining(final long elementIndex) { return columnChunkPageStore.getPageContaining(elementIndex); } @@ -68,15 +68,12 @@ public void releaseCachedResources() { } @Override - public FillContext makeFillContext(int chunkCapacity, SharedContext sharedContext) { + public FillContext makeFillContext(final int chunkCapacity, final SharedContext sharedContext) { return columnChunkPageStore.makeFillContext(chunkCapacity, sharedContext); } @Override - public GetContext makeGetContext(int chunkCapacity, SharedContext sharedContext) { + public GetContext makeGetContext(final int chunkCapacity, final SharedContext sharedContext) { return columnChunkPageStore.makeGetContext(chunkCapacity, sharedContext); } - } - - diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionByte.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionByte.java index 1ee971c2662..fc8ae87c5d4 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionByte.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionByte.java @@ -14,17 +14,17 @@ * {@link ColumnChunkPageStore}. */ public final class ParquetColumnRegionByte extends ParquetColumnRegionBase - implements ColumnRegionByte { + implements ColumnRegionByte { - public ParquetColumnRegionByte(@NotNull ColumnChunkPageStore columnChunkPageStore) { + public ParquetColumnRegionByte(@NotNull final ColumnChunkPageStore columnChunkPageStore) { super(columnChunkPageStore); } public byte[] getBytes( - long firstElementIndex, - @NotNull byte[] destination, - int destinationOffset, - int length + final long firstElementIndex, + @NotNull final byte[] destination, + final int destinationOffset, + final int length ) { final WritableChunk byteChunk = WritableByteChunk.writableChunkWrap(destination, destinationOffset, length); try (OrderedKeys orderedKeys = OrderedKeys.forRange(firstElementIndex, firstElementIndex + length - 1)) { @@ -42,7 +42,7 @@ public byte getByte(final long elementIndex) { return page.asByteChunk().get(page.getChunkOffset(elementIndex)); } catch (Exception e) { throw new TableDataException("Error retrieving byte at table byte index " + elementIndex - + ", from a parquet table.", e); + + ", from a parquet table", e); } } @@ -54,7 +54,7 @@ public byte getByte(@NotNull final FillContext context, final long elementIndex) return page.asByteChunk().get(page.getChunkOffset(elementIndex)); } catch (Exception e) { throw new TableDataException("Error retrieving byte at table byte index " + elementIndex - + ", from a parquet table.", e); + + ", from a parquet table", e); } } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionChar.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionChar.java index 2cf934f6c87..0ad48afbcb3 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionChar.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionChar.java @@ -2,7 +2,6 @@ import io.deephaven.db.v2.locations.TableDataException; import io.deephaven.db.v2.locations.parquet.ColumnChunkPageStore; -import io.deephaven.db.v2.sources.chunk.Attributes; import io.deephaven.db.v2.sources.chunk.Attributes.Any; import io.deephaven.db.v2.sources.chunk.page.ChunkPage; import org.jetbrains.annotations.NotNull; diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionDouble.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionDouble.java index c97ee38d5aa..be5791e8dce 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionDouble.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionDouble.java @@ -5,7 +5,7 @@ import io.deephaven.db.v2.locations.TableDataException; import io.deephaven.db.v2.locations.parquet.ColumnChunkPageStore; -import io.deephaven.db.v2.sources.chunk.Attributes; +import io.deephaven.db.v2.sources.chunk.Attributes.Any; import io.deephaven.db.v2.sources.chunk.page.ChunkPage; import org.jetbrains.annotations.NotNull; @@ -13,10 +13,10 @@ * {@link ColumnRegionDouble} implementation for regions that support fetching primitive doubles from a * {@link ColumnChunkPageStore}. */ -public final class ParquetColumnRegionDouble extends ParquetColumnRegionBase +public final class ParquetColumnRegionDouble extends ParquetColumnRegionBase implements ColumnRegionDouble, ParquetColumnRegion { - public ParquetColumnRegionDouble(@NotNull ColumnChunkPageStore columnChunkPageStore) { + public ParquetColumnRegionDouble(@NotNull final ColumnChunkPageStore columnChunkPageStore) { super(columnChunkPageStore); } @@ -28,7 +28,7 @@ public double getDouble(final long elementIndex) { return page.asDoubleChunk().get(page.getChunkOffset(elementIndex)); } catch (Exception e) { throw new TableDataException("Error retrieving double at table double index " + elementIndex - + ", from a parquet table.", e); + + ", from a parquet table", e); } } @@ -40,7 +40,7 @@ public double getDouble(@NotNull final FillContext context, final long elementIn return page.asDoubleChunk().get(page.getChunkOffset(elementIndex)); } catch (Exception e) { throw new TableDataException("Error retrieving double at table double index " + elementIndex - + ", from a parquet table.", e); + + ", from a parquet table", e); } } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionFloat.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionFloat.java index 1907c1fcded..36d776519b9 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionFloat.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionFloat.java @@ -5,7 +5,7 @@ import io.deephaven.db.v2.locations.TableDataException; import io.deephaven.db.v2.locations.parquet.ColumnChunkPageStore; -import io.deephaven.db.v2.sources.chunk.Attributes; +import io.deephaven.db.v2.sources.chunk.Attributes.Any; import io.deephaven.db.v2.sources.chunk.page.ChunkPage; import org.jetbrains.annotations.NotNull; @@ -13,10 +13,10 @@ * {@link ColumnRegionFloat} implementation for regions that support fetching primitive floats from a * {@link ColumnChunkPageStore}. */ -public final class ParquetColumnRegionFloat extends ParquetColumnRegionBase +public final class ParquetColumnRegionFloat extends ParquetColumnRegionBase implements ColumnRegionFloat, ParquetColumnRegion { - public ParquetColumnRegionFloat(@NotNull ColumnChunkPageStore columnChunkPageStore) { + public ParquetColumnRegionFloat(@NotNull final ColumnChunkPageStore columnChunkPageStore) { super(columnChunkPageStore); } @@ -28,7 +28,7 @@ public float getFloat(final long elementIndex) { return page.asFloatChunk().get(page.getChunkOffset(elementIndex)); } catch (Exception e) { throw new TableDataException("Error retrieving float at table float index " + elementIndex - + ", from a parquet table.", e); + + ", from a parquet table", e); } } @@ -40,7 +40,7 @@ public float getFloat(@NotNull final FillContext context, final long elementInde return page.asFloatChunk().get(page.getChunkOffset(elementIndex)); } catch (Exception e) { throw new TableDataException("Error retrieving float at table float index " + elementIndex - + ", from a parquet table.", e); + + ", from a parquet table", e); } } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionInt.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionInt.java index 9e071c6c947..a3adb2331ba 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionInt.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionInt.java @@ -5,7 +5,7 @@ import io.deephaven.db.v2.locations.TableDataException; import io.deephaven.db.v2.locations.parquet.ColumnChunkPageStore; -import io.deephaven.db.v2.sources.chunk.Attributes; +import io.deephaven.db.v2.sources.chunk.Attributes.Any; import io.deephaven.db.v2.sources.chunk.page.ChunkPage; import org.jetbrains.annotations.NotNull; @@ -13,10 +13,10 @@ * {@link ColumnRegionInt} implementation for regions that support fetching primitive ints from a * {@link ColumnChunkPageStore}. */ -public final class ParquetColumnRegionInt extends ParquetColumnRegionBase +public final class ParquetColumnRegionInt extends ParquetColumnRegionBase implements ColumnRegionInt, ParquetColumnRegion { - public ParquetColumnRegionInt(@NotNull ColumnChunkPageStore columnChunkPageStore) { + public ParquetColumnRegionInt(@NotNull final ColumnChunkPageStore columnChunkPageStore) { super(columnChunkPageStore); } @@ -28,7 +28,7 @@ public int getInt(final long elementIndex) { return page.asIntChunk().get(page.getChunkOffset(elementIndex)); } catch (Exception e) { throw new TableDataException("Error retrieving int at table int index " + elementIndex - + ", from a parquet table.", e); + + ", from a parquet table", e); } } @@ -40,7 +40,7 @@ public int getInt(@NotNull final FillContext context, final long elementIndex) { return page.asIntChunk().get(page.getChunkOffset(elementIndex)); } catch (Exception e) { throw new TableDataException("Error retrieving int at table int index " + elementIndex - + ", from a parquet table.", e); + + ", from a parquet table", e); } } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionLong.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionLong.java index 77f9303942b..36a51b61110 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionLong.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionLong.java @@ -5,7 +5,7 @@ import io.deephaven.db.v2.locations.TableDataException; import io.deephaven.db.v2.locations.parquet.ColumnChunkPageStore; -import io.deephaven.db.v2.sources.chunk.Attributes; +import io.deephaven.db.v2.sources.chunk.Attributes.Any; import io.deephaven.db.v2.sources.chunk.page.ChunkPage; import org.jetbrains.annotations.NotNull; @@ -13,10 +13,10 @@ * {@link ColumnRegionLong} implementation for regions that support fetching primitive longs from a * {@link ColumnChunkPageStore}. */ -public final class ParquetColumnRegionLong extends ParquetColumnRegionBase +public final class ParquetColumnRegionLong extends ParquetColumnRegionBase implements ColumnRegionLong, ParquetColumnRegion { - public ParquetColumnRegionLong(@NotNull ColumnChunkPageStore columnChunkPageStore) { + public ParquetColumnRegionLong(@NotNull final ColumnChunkPageStore columnChunkPageStore) { super(columnChunkPageStore); } @@ -28,7 +28,7 @@ public long getLong(final long elementIndex) { return page.asLongChunk().get(page.getChunkOffset(elementIndex)); } catch (Exception e) { throw new TableDataException("Error retrieving long at table long index " + elementIndex - + ", from a parquet table.", e); + + ", from a parquet table", e); } } @@ -40,7 +40,7 @@ public long getLong(@NotNull final FillContext context, final long elementIndex) return page.asLongChunk().get(page.getChunkOffset(elementIndex)); } catch (Exception e) { throw new TableDataException("Error retrieving long at table long index " + elementIndex - + ", from a parquet table.", e); + + ", from a parquet table", e); } } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionShort.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionShort.java index 2e5f0e760a0..25d4290405d 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionShort.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/ParquetColumnRegionShort.java @@ -5,7 +5,7 @@ import io.deephaven.db.v2.locations.TableDataException; import io.deephaven.db.v2.locations.parquet.ColumnChunkPageStore; -import io.deephaven.db.v2.sources.chunk.Attributes; +import io.deephaven.db.v2.sources.chunk.Attributes.Any; import io.deephaven.db.v2.sources.chunk.page.ChunkPage; import org.jetbrains.annotations.NotNull; @@ -13,10 +13,10 @@ * {@link ColumnRegionShort} implementation for regions that support fetching primitive shorts from a * {@link ColumnChunkPageStore}. */ -public final class ParquetColumnRegionShort extends ParquetColumnRegionBase +public final class ParquetColumnRegionShort extends ParquetColumnRegionBase implements ColumnRegionShort, ParquetColumnRegion { - public ParquetColumnRegionShort(@NotNull ColumnChunkPageStore columnChunkPageStore) { + public ParquetColumnRegionShort(@NotNull final ColumnChunkPageStore columnChunkPageStore) { super(columnChunkPageStore); } @@ -28,7 +28,7 @@ public short getShort(final long elementIndex) { return page.asShortChunk().get(page.getChunkOffset(elementIndex)); } catch (Exception e) { throw new TableDataException("Error retrieving short at table short index " + elementIndex - + ", from a parquet table.", e); + + ", from a parquet table", e); } } @@ -40,7 +40,7 @@ public short getShort(@NotNull final FillContext context, final long elementInde return page.asShortChunk().get(page.getChunkOffset(elementIndex)); } catch (Exception e) { throw new TableDataException("Error retrieving short at table short index " + elementIndex - + ", from a parquet table.", e); + + ", from a parquet table", e); } } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/PartitioningSourceFactory.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/PartitioningSourceFactory.java new file mode 100644 index 00000000000..cd647d05ee4 --- /dev/null +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/PartitioningSourceFactory.java @@ -0,0 +1,37 @@ +package io.deephaven.db.v2.sources.regioned; + +import org.jetbrains.annotations.NotNull; + +class PartitioningSourceFactory { + + /** + * Get a partitioning {@link RegionedColumnSource} for the supplied {@code dataType}. + * + * @param dataType The data type expected for partition values + * @return A new partitioning {@link RegionedColumnSource} + */ + static RegionedColumnSource makePartitioningSource(@NotNull final Class dataType) { + final RegionedColumnSource result; + if (dataType == boolean.class || dataType == Boolean.class) { + result = new RegionedColumnSourceObject.Partitioning<>(dataType); + } else if (dataType == char.class || dataType == Character.class) { + result = new RegionedColumnSourceChar.Partitioning(); + } else if (dataType == byte.class || dataType == Byte.class) { + result = new RegionedColumnSourceByte.Partitioning(); + } else if (dataType == short.class || dataType == Short.class) { + result = new RegionedColumnSourceShort.Partitioning(); + } else if (dataType == int.class || dataType == Integer.class) { + result = new RegionedColumnSourceInt.Partitioning(); + } else if (dataType == long.class || dataType == Long.class) { + result = new RegionedColumnSourceLong.Partitioning(); + } else if (dataType == float.class || dataType == Float.class) { + result = new RegionedColumnSourceFloat.Partitioning(); + } else if (dataType == double.class || dataType == Double.class) { + result = new RegionedColumnSourceDouble.Partitioning(); + } else { + result = new RegionedColumnSourceObject.Partitioning<>(dataType); + } + //noinspection unchecked + return (RegionedColumnSource) result; + } +} diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceByte.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceByte.java index fb43b4762f1..1fd80a49f83 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceByte.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceByte.java @@ -5,44 +5,49 @@ import io.deephaven.db.tables.ColumnDefinition; import io.deephaven.db.v2.locations.ColumnLocation; +import io.deephaven.db.v2.locations.TableDataException; +import io.deephaven.db.v2.locations.TableLocationKey; import io.deephaven.db.v2.sources.ColumnSourceGetDefaults; -import io.deephaven.db.v2.sources.chunk.Attributes; +import io.deephaven.db.v2.sources.chunk.Attributes.Values; import org.jetbrains.annotations.NotNull; +import java.util.function.Supplier; + import static io.deephaven.db.v2.utils.ReadOnlyIndex.NULL_KEY; +import static io.deephaven.util.type.TypeUtils.unbox; /** * Regioned column source implementation for columns of bytes. */ -abstract class RegionedColumnSourceByte +abstract class RegionedColumnSourceByte extends RegionedColumnSourceArray> implements ColumnSourceGetDefaults.ForByte { - RegionedColumnSourceByte(ColumnRegionByte nullRegion) { - super(nullRegion, byte.class, DeferredColumnRegionByte::new); + RegionedColumnSourceByte(@NotNull final ColumnRegionByte nullRegion, + @NotNull final MakeDeferred> makeDeferred) { + super(nullRegion, byte.class, makeDeferred); } @Override - public byte getByte(long elementIndex) { + public byte getByte(final long elementIndex) { return (elementIndex == NULL_KEY ? getNullRegion() : lookupRegion(elementIndex)).getByte(elementIndex); } - interface MakeRegionDefault extends MakeRegion> { + interface MakeRegionDefault extends MakeRegion> { @Override - default ColumnRegionByte makeRegion(@NotNull final ColumnDefinition columnDefinition, - @NotNull final ColumnLocation columnLocation, - final int regionIndex) { + default ColumnRegionByte makeRegion(@NotNull final ColumnDefinition columnDefinition, + @NotNull final ColumnLocation columnLocation, + final int regionIndex) { if (columnLocation.exists()) { return columnLocation.makeColumnRegionByte(columnDefinition); } - return null; } } - public static final class AsValues extends RegionedColumnSourceByte implements MakeRegionDefault { - public AsValues() { - super(ColumnRegionByte.createNull()); + static final class AsValues extends RegionedColumnSourceByte implements MakeRegionDefault { + AsValues() { + super(ColumnRegionByte.createNull(), DeferredColumnRegionByte::new); } } @@ -51,26 +56,46 @@ public AsValues() { * not hold an array of regions, but rather derives from {@link RegionedColumnSourceBase}, accessing its * regions by looking into the delegate instance's region array. */ - @SuppressWarnings("unused") - static abstract class NativeType + static abstract class NativeType extends RegionedColumnSourceReferencing.NativeColumnSource> implements ColumnSourceGetDefaults.ForByte { - NativeType(RegionedColumnSourceBase>> outerColumnSource) { + NativeType(@NotNull final RegionedColumnSourceBase>> outerColumnSource) { super(Byte.class, outerColumnSource); } @Override - public byte getByte(long elementIndex) { + public byte getByte(final long elementIndex) { return (elementIndex == NULL_KEY ? getNullRegion() : lookupRegion(elementIndex)).getByte(elementIndex); } - static final class AsValues extends NativeType implements MakeRegionDefault { - AsValues(RegionedColumnSourceBase>> outerColumnSource) { + static final class AsValues extends NativeType implements MakeRegionDefault { + AsValues(@NotNull final RegionedColumnSourceBase>> outerColumnSource) { super(outerColumnSource); } } } + static final class Partitioning extends RegionedColumnSourceByte { + + Partitioning() { + super(ColumnRegionByte.createNull(), + Supplier::get // No need to interpose a deferred region in this case + ); + } + + @Override + public ColumnRegionByte makeRegion(@NotNull final ColumnDefinition columnDefinition, + @NotNull final ColumnLocation columnLocation, + final int regionIndex) { + final TableLocationKey locationKey = columnLocation.getTableLocation().getKey(); + final Object partitioningColumnValue = locationKey.getPartitionValue(columnDefinition.getName()); + if (partitioningColumnValue != null && !Byte.class.isAssignableFrom(partitioningColumnValue.getClass())) { + throw new TableDataException("Unexpected partitioning column value type for " + columnDefinition.getName() + + ": " + partitioningColumnValue + " is not a Byte at location " + locationKey); + } + return new ColumnRegionByte.Constant<>(unbox((Byte) partitioningColumnValue)); + } + } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceChar.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceChar.java index f88d0db7ce0..cb7f756a4b6 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceChar.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceChar.java @@ -2,11 +2,16 @@ import io.deephaven.db.tables.ColumnDefinition; import io.deephaven.db.v2.locations.ColumnLocation; +import io.deephaven.db.v2.locations.TableDataException; +import io.deephaven.db.v2.locations.TableLocationKey; import io.deephaven.db.v2.sources.ColumnSourceGetDefaults; import io.deephaven.db.v2.sources.chunk.Attributes.Values; import org.jetbrains.annotations.NotNull; +import java.util.function.Supplier; + import static io.deephaven.db.v2.utils.ReadOnlyIndex.NULL_KEY; +import static io.deephaven.util.type.TypeUtils.unbox; /** * Regioned column source implementation for columns of chars. @@ -15,12 +20,13 @@ abstract class RegionedColumnSourceChar extends RegionedColumnSourceArray> implements ColumnSourceGetDefaults.ForChar { - RegionedColumnSourceChar(ColumnRegionChar nullRegion) { - super(nullRegion, char.class, DeferredColumnRegionChar::new); + RegionedColumnSourceChar(@NotNull final ColumnRegionChar nullRegion, + @NotNull final MakeDeferred> makeDeferred) { + super(nullRegion, char.class, makeDeferred); } @Override - public char getChar(long elementIndex) { + public char getChar(final long elementIndex) { return (elementIndex == NULL_KEY ? getNullRegion() : lookupRegion(elementIndex)).getChar(elementIndex); } @@ -32,14 +38,13 @@ default ColumnRegionChar makeRegion(@NotNull final ColumnDefinition c if (columnLocation.exists()) { return columnLocation.makeColumnRegionChar(columnDefinition); } - return null; } } - public static final class AsValues extends RegionedColumnSourceChar implements MakeRegionDefault { - public AsValues() { - super(ColumnRegionChar.createNull()); + static final class AsValues extends RegionedColumnSourceChar implements MakeRegionDefault { + AsValues() { + super(ColumnRegionChar.createNull(), DeferredColumnRegionChar::new); } } @@ -48,26 +53,46 @@ public AsValues() { * not hold an array of regions, but rather derives from {@link RegionedColumnSourceBase}, accessing its * regions by looking into the delegate instance's region array. */ - @SuppressWarnings("unused") static abstract class NativeType extends RegionedColumnSourceReferencing.NativeColumnSource> implements ColumnSourceGetDefaults.ForChar { - NativeType(RegionedColumnSourceBase>> outerColumnSource) { + NativeType(@NotNull final RegionedColumnSourceBase>> outerColumnSource) { super(Character.class, outerColumnSource); } @Override - public char getChar(long elementIndex) { + public char getChar(final long elementIndex) { return (elementIndex == NULL_KEY ? getNullRegion() : lookupRegion(elementIndex)).getChar(elementIndex); } static final class AsValues extends NativeType implements MakeRegionDefault { - AsValues(RegionedColumnSourceBase>> outerColumnSource) { + AsValues(@NotNull final RegionedColumnSourceBase>> outerColumnSource) { super(outerColumnSource); } } } + static final class Partitioning extends RegionedColumnSourceChar { + + Partitioning() { + super(ColumnRegionChar.createNull(), + Supplier::get // No need to interpose a deferred region in this case + ); + } + + @Override + public ColumnRegionChar makeRegion(@NotNull final ColumnDefinition columnDefinition, + @NotNull final ColumnLocation columnLocation, + final int regionIndex) { + final TableLocationKey locationKey = columnLocation.getTableLocation().getKey(); + final Object partitioningColumnValue = locationKey.getPartitionValue(columnDefinition.getName()); + if (partitioningColumnValue != null && !Character.class.isAssignableFrom(partitioningColumnValue.getClass())) { + throw new TableDataException("Unexpected partitioning column value type for " + columnDefinition.getName() + + ": " + partitioningColumnValue + " is not a Character at location " + locationKey); + } + return new ColumnRegionChar.Constant<>(unbox((Character) partitioningColumnValue)); + } + } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceDouble.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceDouble.java index 7f2930fd04a..91c48de9f4c 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceDouble.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceDouble.java @@ -5,44 +5,49 @@ import io.deephaven.db.tables.ColumnDefinition; import io.deephaven.db.v2.locations.ColumnLocation; +import io.deephaven.db.v2.locations.TableDataException; +import io.deephaven.db.v2.locations.TableLocationKey; import io.deephaven.db.v2.sources.ColumnSourceGetDefaults; -import io.deephaven.db.v2.sources.chunk.Attributes; +import io.deephaven.db.v2.sources.chunk.Attributes.Values; import org.jetbrains.annotations.NotNull; +import java.util.function.Supplier; + import static io.deephaven.db.v2.utils.ReadOnlyIndex.NULL_KEY; +import static io.deephaven.util.type.TypeUtils.unbox; /** * Regioned column source implementation for columns of doubles. */ -abstract class RegionedColumnSourceDouble +abstract class RegionedColumnSourceDouble extends RegionedColumnSourceArray> implements ColumnSourceGetDefaults.ForDouble { - RegionedColumnSourceDouble(ColumnRegionDouble nullRegion) { - super(nullRegion, double.class, DeferredColumnRegionDouble::new); + RegionedColumnSourceDouble(@NotNull final ColumnRegionDouble nullRegion, + @NotNull final MakeDeferred> makeDeferred) { + super(nullRegion, double.class, makeDeferred); } @Override - public double getDouble(long elementIndex) { + public double getDouble(final long elementIndex) { return (elementIndex == NULL_KEY ? getNullRegion() : lookupRegion(elementIndex)).getDouble(elementIndex); } - interface MakeRegionDefault extends MakeRegion> { + interface MakeRegionDefault extends MakeRegion> { @Override - default ColumnRegionDouble makeRegion(@NotNull final ColumnDefinition columnDefinition, - @NotNull final ColumnLocation columnLocation, - final int regionIndex) { + default ColumnRegionDouble makeRegion(@NotNull final ColumnDefinition columnDefinition, + @NotNull final ColumnLocation columnLocation, + final int regionIndex) { if (columnLocation.exists()) { return columnLocation.makeColumnRegionDouble(columnDefinition); } - return null; } } - public static final class AsValues extends RegionedColumnSourceDouble implements MakeRegionDefault { - public AsValues() { - super(ColumnRegionDouble.createNull()); + static final class AsValues extends RegionedColumnSourceDouble implements MakeRegionDefault { + AsValues() { + super(ColumnRegionDouble.createNull(), DeferredColumnRegionDouble::new); } } @@ -51,26 +56,46 @@ public AsValues() { * not hold an array of regions, but rather derives from {@link RegionedColumnSourceBase}, accessing its * regions by looking into the delegate instance's region array. */ - @SuppressWarnings("unused") - static abstract class NativeType + static abstract class NativeType extends RegionedColumnSourceReferencing.NativeColumnSource> implements ColumnSourceGetDefaults.ForDouble { - NativeType(RegionedColumnSourceBase>> outerColumnSource) { + NativeType(@NotNull final RegionedColumnSourceBase>> outerColumnSource) { super(Double.class, outerColumnSource); } @Override - public double getDouble(long elementIndex) { + public double getDouble(final long elementIndex) { return (elementIndex == NULL_KEY ? getNullRegion() : lookupRegion(elementIndex)).getDouble(elementIndex); } - static final class AsValues extends NativeType implements MakeRegionDefault { - AsValues(RegionedColumnSourceBase>> outerColumnSource) { + static final class AsValues extends NativeType implements MakeRegionDefault { + AsValues(@NotNull final RegionedColumnSourceBase>> outerColumnSource) { super(outerColumnSource); } } } + static final class Partitioning extends RegionedColumnSourceDouble { + + Partitioning() { + super(ColumnRegionDouble.createNull(), + Supplier::get // No need to interpose a deferred region in this case + ); + } + + @Override + public ColumnRegionDouble makeRegion(@NotNull final ColumnDefinition columnDefinition, + @NotNull final ColumnLocation columnLocation, + final int regionIndex) { + final TableLocationKey locationKey = columnLocation.getTableLocation().getKey(); + final Object partitioningColumnValue = locationKey.getPartitionValue(columnDefinition.getName()); + if (partitioningColumnValue != null && !Double.class.isAssignableFrom(partitioningColumnValue.getClass())) { + throw new TableDataException("Unexpected partitioning column value type for " + columnDefinition.getName() + + ": " + partitioningColumnValue + " is not a Double at location " + locationKey); + } + return new ColumnRegionDouble.Constant<>(unbox((Double) partitioningColumnValue)); + } + } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceFloat.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceFloat.java index dbf8ab1d8fe..866d248f3e6 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceFloat.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceFloat.java @@ -5,44 +5,49 @@ import io.deephaven.db.tables.ColumnDefinition; import io.deephaven.db.v2.locations.ColumnLocation; +import io.deephaven.db.v2.locations.TableDataException; +import io.deephaven.db.v2.locations.TableLocationKey; import io.deephaven.db.v2.sources.ColumnSourceGetDefaults; -import io.deephaven.db.v2.sources.chunk.Attributes; +import io.deephaven.db.v2.sources.chunk.Attributes.Values; import org.jetbrains.annotations.NotNull; +import java.util.function.Supplier; + import static io.deephaven.db.v2.utils.ReadOnlyIndex.NULL_KEY; +import static io.deephaven.util.type.TypeUtils.unbox; /** * Regioned column source implementation for columns of floats. */ -abstract class RegionedColumnSourceFloat +abstract class RegionedColumnSourceFloat extends RegionedColumnSourceArray> implements ColumnSourceGetDefaults.ForFloat { - RegionedColumnSourceFloat(ColumnRegionFloat nullRegion) { - super(nullRegion, float.class, DeferredColumnRegionFloat::new); + RegionedColumnSourceFloat(@NotNull final ColumnRegionFloat nullRegion, + @NotNull final MakeDeferred> makeDeferred) { + super(nullRegion, float.class, makeDeferred); } @Override - public float getFloat(long elementIndex) { + public float getFloat(final long elementIndex) { return (elementIndex == NULL_KEY ? getNullRegion() : lookupRegion(elementIndex)).getFloat(elementIndex); } - interface MakeRegionDefault extends MakeRegion> { + interface MakeRegionDefault extends MakeRegion> { @Override - default ColumnRegionFloat makeRegion(@NotNull ColumnDefinition columnDefinition, - @NotNull ColumnLocation columnLocation, - int regionIndex) { + default ColumnRegionFloat makeRegion(@NotNull final ColumnDefinition columnDefinition, + @NotNull final ColumnLocation columnLocation, + final int regionIndex) { if (columnLocation.exists()) { return columnLocation.makeColumnRegionFloat(columnDefinition); } - return null; } } - public static final class AsValues extends RegionedColumnSourceFloat implements MakeRegionDefault { - public AsValues() { - super(ColumnRegionFloat.createNull()); + static final class AsValues extends RegionedColumnSourceFloat implements MakeRegionDefault { + AsValues() { + super(ColumnRegionFloat.createNull(), DeferredColumnRegionFloat::new); } } @@ -51,26 +56,46 @@ public AsValues() { * not hold an array of regions, but rather derives from {@link RegionedColumnSourceBase}, accessing its * regions by looking into the delegate instance's region array. */ - @SuppressWarnings("unused") - static abstract class NativeType + static abstract class NativeType extends RegionedColumnSourceReferencing.NativeColumnSource> implements ColumnSourceGetDefaults.ForFloat { - NativeType(RegionedColumnSourceBase>> outerColumnSource) { + NativeType(@NotNull final RegionedColumnSourceBase>> outerColumnSource) { super(Float.class, outerColumnSource); } @Override - public float getFloat(long elementIndex) { + public float getFloat(final long elementIndex) { return (elementIndex == NULL_KEY ? getNullRegion() : lookupRegion(elementIndex)).getFloat(elementIndex); } - static final class AsValues extends NativeType implements MakeRegionDefault { - AsValues(RegionedColumnSourceBase>> outerColumnSource) { + static final class AsValues extends NativeType implements MakeRegionDefault { + AsValues(@NotNull final RegionedColumnSourceBase>> outerColumnSource) { super(outerColumnSource); } } } + static final class Partitioning extends RegionedColumnSourceFloat { + + Partitioning() { + super(ColumnRegionFloat.createNull(), + Supplier::get // No need to interpose a deferred region in this case + ); + } + + @Override + public ColumnRegionFloat makeRegion(@NotNull final ColumnDefinition columnDefinition, + @NotNull final ColumnLocation columnLocation, + final int regionIndex) { + final TableLocationKey locationKey = columnLocation.getTableLocation().getKey(); + final Object partitioningColumnValue = locationKey.getPartitionValue(columnDefinition.getName()); + if (partitioningColumnValue != null && !Float.class.isAssignableFrom(partitioningColumnValue.getClass())) { + throw new TableDataException("Unexpected partitioning column value type for " + columnDefinition.getName() + + ": " + partitioningColumnValue + " is not a Float at location " + locationKey); + } + return new ColumnRegionFloat.Constant<>(unbox((Float) partitioningColumnValue)); + } + } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceInt.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceInt.java index de7be22afa5..84d83a7f2dc 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceInt.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceInt.java @@ -5,44 +5,49 @@ import io.deephaven.db.tables.ColumnDefinition; import io.deephaven.db.v2.locations.ColumnLocation; +import io.deephaven.db.v2.locations.TableDataException; +import io.deephaven.db.v2.locations.TableLocationKey; import io.deephaven.db.v2.sources.ColumnSourceGetDefaults; -import io.deephaven.db.v2.sources.chunk.Attributes; +import io.deephaven.db.v2.sources.chunk.Attributes.Values; import org.jetbrains.annotations.NotNull; +import java.util.function.Supplier; + import static io.deephaven.db.v2.utils.ReadOnlyIndex.NULL_KEY; +import static io.deephaven.util.type.TypeUtils.unbox; /** * Regioned column source implementation for columns of ints. */ -abstract class RegionedColumnSourceInt +abstract class RegionedColumnSourceInt extends RegionedColumnSourceArray> implements ColumnSourceGetDefaults.ForInt { - RegionedColumnSourceInt(ColumnRegionInt nullRegion) { - super(nullRegion, int.class, DeferredColumnRegionInt::new); + RegionedColumnSourceInt(@NotNull final ColumnRegionInt nullRegion, + @NotNull final MakeDeferred> makeDeferred) { + super(nullRegion, int.class, makeDeferred); } @Override - public int getInt(long elementIndex) { + public int getInt(final long elementIndex) { return (elementIndex == NULL_KEY ? getNullRegion() : lookupRegion(elementIndex)).getInt(elementIndex); } - interface MakeRegionDefault extends MakeRegion> { + interface MakeRegionDefault extends MakeRegion> { @Override - default ColumnRegionInt makeRegion(@NotNull ColumnDefinition columnDefinition, - @NotNull ColumnLocation columnLocation, - int regionIndex) { + default ColumnRegionInt makeRegion(@NotNull final ColumnDefinition columnDefinition, + @NotNull final ColumnLocation columnLocation, + final int regionIndex) { if (columnLocation.exists()) { return columnLocation.makeColumnRegionInt(columnDefinition); } - return null; } } - public static final class AsValues extends RegionedColumnSourceInt implements MakeRegionDefault { - public AsValues() { - super(ColumnRegionInt.createNull()); + static final class AsValues extends RegionedColumnSourceInt implements MakeRegionDefault { + AsValues() { + super(ColumnRegionInt.createNull(), DeferredColumnRegionInt::new); } } @@ -51,26 +56,46 @@ public AsValues() { * not hold an array of regions, but rather derives from {@link RegionedColumnSourceBase}, accessing its * regions by looking into the delegate instance's region array. */ - @SuppressWarnings("unused") - static abstract class NativeType + static abstract class NativeType extends RegionedColumnSourceReferencing.NativeColumnSource> implements ColumnSourceGetDefaults.ForInt { - NativeType(RegionedColumnSourceBase>> outerColumnSource) { + NativeType(@NotNull final RegionedColumnSourceBase>> outerColumnSource) { super(Integer.class, outerColumnSource); } @Override - public int getInt(long elementIndex) { + public int getInt(final long elementIndex) { return (elementIndex == NULL_KEY ? getNullRegion() : lookupRegion(elementIndex)).getInt(elementIndex); } - static final class AsValues extends NativeType implements MakeRegionDefault { - AsValues(RegionedColumnSourceBase>> outerColumnSource) { + static final class AsValues extends NativeType implements MakeRegionDefault { + AsValues(@NotNull final RegionedColumnSourceBase>> outerColumnSource) { super(outerColumnSource); } } } + static final class Partitioning extends RegionedColumnSourceInt { + + Partitioning() { + super(ColumnRegionInt.createNull(), + Supplier::get // No need to interpose a deferred region in this case + ); + } + + @Override + public ColumnRegionInt makeRegion(@NotNull final ColumnDefinition columnDefinition, + @NotNull final ColumnLocation columnLocation, + final int regionIndex) { + final TableLocationKey locationKey = columnLocation.getTableLocation().getKey(); + final Object partitioningColumnValue = locationKey.getPartitionValue(columnDefinition.getName()); + if (partitioningColumnValue != null && !Integer.class.isAssignableFrom(partitioningColumnValue.getClass())) { + throw new TableDataException("Unexpected partitioning column value type for " + columnDefinition.getName() + + ": " + partitioningColumnValue + " is not a Integer at location " + locationKey); + } + return new ColumnRegionInt.Constant<>(unbox((Integer) partitioningColumnValue)); + } + } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceLong.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceLong.java index 891678e24c5..ed38222dbfe 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceLong.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceLong.java @@ -5,44 +5,49 @@ import io.deephaven.db.tables.ColumnDefinition; import io.deephaven.db.v2.locations.ColumnLocation; +import io.deephaven.db.v2.locations.TableDataException; +import io.deephaven.db.v2.locations.TableLocationKey; import io.deephaven.db.v2.sources.ColumnSourceGetDefaults; -import io.deephaven.db.v2.sources.chunk.Attributes; +import io.deephaven.db.v2.sources.chunk.Attributes.Values; import org.jetbrains.annotations.NotNull; +import java.util.function.Supplier; + import static io.deephaven.db.v2.utils.ReadOnlyIndex.NULL_KEY; +import static io.deephaven.util.type.TypeUtils.unbox; /** * Regioned column source implementation for columns of longs. */ -abstract class RegionedColumnSourceLong +abstract class RegionedColumnSourceLong extends RegionedColumnSourceArray> implements ColumnSourceGetDefaults.ForLong { - RegionedColumnSourceLong(ColumnRegionLong nullRegion) { - super(nullRegion, long.class, DeferredColumnRegionLong::new); + RegionedColumnSourceLong(@NotNull final ColumnRegionLong nullRegion, + @NotNull final MakeDeferred> makeDeferred) { + super(nullRegion, long.class, makeDeferred); } @Override - public long getLong(long elementIndex) { + public long getLong(final long elementIndex) { return (elementIndex == NULL_KEY ? getNullRegion() : lookupRegion(elementIndex)).getLong(elementIndex); } - interface MakeRegionDefault extends MakeRegion> { + interface MakeRegionDefault extends MakeRegion> { @Override - default ColumnRegionLong makeRegion(@NotNull ColumnDefinition columnDefinition, - @NotNull ColumnLocation columnLocation, - int regionIndex) { + default ColumnRegionLong makeRegion(@NotNull final ColumnDefinition columnDefinition, + @NotNull final ColumnLocation columnLocation, + final int regionIndex) { if (columnLocation.exists()) { return columnLocation.makeColumnRegionLong(columnDefinition); } - return null; } } - public static final class AsValues extends RegionedColumnSourceLong implements MakeRegionDefault { - public AsValues() { - super(ColumnRegionLong.createNull()); + static final class AsValues extends RegionedColumnSourceLong implements MakeRegionDefault { + AsValues() { + super(ColumnRegionLong.createNull(), DeferredColumnRegionLong::new); } } @@ -51,26 +56,46 @@ public AsValues() { * not hold an array of regions, but rather derives from {@link RegionedColumnSourceBase}, accessing its * regions by looking into the delegate instance's region array. */ - @SuppressWarnings("unused") - static abstract class NativeType + static abstract class NativeType extends RegionedColumnSourceReferencing.NativeColumnSource> implements ColumnSourceGetDefaults.ForLong { - NativeType(RegionedColumnSourceBase>> outerColumnSource) { + NativeType(@NotNull final RegionedColumnSourceBase>> outerColumnSource) { super(Long.class, outerColumnSource); } @Override - public long getLong(long elementIndex) { + public long getLong(final long elementIndex) { return (elementIndex == NULL_KEY ? getNullRegion() : lookupRegion(elementIndex)).getLong(elementIndex); } - static final class AsValues extends NativeType implements MakeRegionDefault { - AsValues(RegionedColumnSourceBase>> outerColumnSource) { + static final class AsValues extends NativeType implements MakeRegionDefault { + AsValues(@NotNull final RegionedColumnSourceBase>> outerColumnSource) { super(outerColumnSource); } } } + static final class Partitioning extends RegionedColumnSourceLong { + + Partitioning() { + super(ColumnRegionLong.createNull(), + Supplier::get // No need to interpose a deferred region in this case + ); + } + + @Override + public ColumnRegionLong makeRegion(@NotNull final ColumnDefinition columnDefinition, + @NotNull final ColumnLocation columnLocation, + final int regionIndex) { + final TableLocationKey locationKey = columnLocation.getTableLocation().getKey(); + final Object partitioningColumnValue = locationKey.getPartitionValue(columnDefinition.getName()); + if (partitioningColumnValue != null && !Long.class.isAssignableFrom(partitioningColumnValue.getClass())) { + throw new TableDataException("Unexpected partitioning column value type for " + columnDefinition.getName() + + ": " + partitioningColumnValue + " is not a Long at location " + locationKey); + } + return new ColumnRegionLong.Constant<>(unbox((Long) partitioningColumnValue)); + } + } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceObject.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceObject.java index 51887c7702f..ec2ce129423 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceObject.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceObject.java @@ -2,6 +2,8 @@ import io.deephaven.db.tables.ColumnDefinition; import io.deephaven.db.v2.locations.ColumnLocation; +import io.deephaven.db.v2.locations.TableDataException; +import io.deephaven.db.v2.locations.TableLocationKey; import io.deephaven.db.v2.sources.ColumnSourceGetDefaults; import io.deephaven.db.v2.sources.chunk.Attributes.Values; import io.deephaven.db.v2.sources.chunk.SharedContext; @@ -9,6 +11,7 @@ import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; +import java.util.function.Supplier; import static io.deephaven.db.v2.utils.ReadOnlyIndex.NULL_KEY; @@ -16,33 +19,34 @@ abstract class RegionedColumnSourceObject extend implements ColumnSourceGetDefaults.ForObject { private RegionedColumnSourceObject(@NotNull final ColumnRegionObject nullRegion, - @NotNull final Class type, - @Nullable final Class componentType) { - super(nullRegion, type, componentType, DeferredColumnRegionObject::new); + @NotNull final Class dataType, + @Nullable final Class componentType, + @NotNull final MakeDeferred> makeDeferred) { + super(nullRegion, dataType, componentType, makeDeferred); } RegionedColumnSourceObject(@NotNull final Class type) { - this(ColumnRegionObject.createNull(), type, null); + this(ColumnRegionObject.createNull(), type, null, DeferredColumnRegionObject::new); + } + + @Override + public final DATA_TYPE get(final long elementIndex) { + return (elementIndex == NULL_KEY ? getNullRegion() : lookupRegion(elementIndex)).getObject(elementIndex); } public static class AsValues extends RegionedColumnSourceObject { private final ObjectDecoder decoder; - public AsValues(@NotNull final Class type, @NotNull final ObjectDecoder decoder) { - this(type, null, decoder); + public AsValues(@NotNull final Class dataType, @NotNull final ObjectDecoder decoder) { + this(dataType, null, decoder); } - public AsValues(@NotNull final Class type, @Nullable final Class componentType, @NotNull final ObjectDecoder decoder) { - super(ColumnRegionObject.createNull(), type, componentType); + public AsValues(@NotNull final Class dataType, @Nullable final Class componentType, @NotNull final ObjectDecoder decoder) { + super(ColumnRegionObject.createNull(), dataType, componentType, DeferredColumnRegionObject::new); this.decoder = decoder; } - @Override - public DATA_TYPE get(final long elementIndex) { - return (elementIndex == NULL_KEY ? getNullRegion() : lookupRegion(elementIndex)).getObject(elementIndex); - } - public ColumnRegionObject makeRegion(@NotNull final ColumnDefinition columnDefinition, @NotNull final ColumnLocation columnLocation, final int regionIndex) { @@ -50,7 +54,6 @@ public ColumnRegionObject makeRegion(@NotNull final ColumnDef //noinspection unchecked return (ColumnRegionObject) columnLocation.makeColumnRegionObject(columnDefinition); } - return null; } @@ -67,4 +70,27 @@ public FillContext makeFillContext(final int chunkCapacity, @Nullable final Shar } } } + + static final class Partitioning extends RegionedColumnSourceObject { + + Partitioning(@NotNull final Class dataType) { + super(ColumnRegionObject.createNull(), dataType, null, + Supplier::get // No need to interpose a deferred region in this case + ); + } + + @Override + public ColumnRegionObject makeRegion(@NotNull final ColumnDefinition columnDefinition, + @NotNull final ColumnLocation columnLocation, + final int regionIndex) { + final TableLocationKey locationKey = columnLocation.getTableLocation().getKey(); + final Object partitioningColumnValue = locationKey.getPartitionValue(columnDefinition.getName()); + if (partitioningColumnValue != null && !getType().isAssignableFrom(partitioningColumnValue.getClass())) { + throw new TableDataException("Unexpected partitioning column value type for " + columnDefinition.getName() + + ": " + partitioningColumnValue + " is not a " + getType() + " at location " + locationKey); + } + //noinspection unchecked + return new ColumnRegionObject.Constant<>((DATA_TYPE) partitioningColumnValue); + } + } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourcePartitioning.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourcePartitioning.java deleted file mode 100644 index 2654a6abe8d..00000000000 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourcePartitioning.java +++ /dev/null @@ -1,58 +0,0 @@ -package io.deephaven.db.v2.sources.regioned; - -import io.deephaven.db.tables.ColumnDefinition; -import io.deephaven.db.v2.locations.ColumnLocation; -import io.deephaven.db.v2.sources.ColumnSourceGetDefaults; -import io.deephaven.db.v2.sources.chunk.Attributes; -import io.deephaven.db.v2.sources.chunk.WritableChunk; -import io.deephaven.db.v2.sources.chunk.page.Page; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Supplier; - -class RegionedColumnSourcePartitioning - extends RegionedColumnSourceArray> - implements ColumnSourceGetDefaults.ForObject { - - RegionedColumnSourcePartitioning() { - // There's no reason to have deferred columns, Supplier::get will just use the column that's made immediately. - super(ColumnRegionObject.createNull(), String.class, Supplier::get); - } - - @Override - public String get(long elementIndex) { - return lookupRegion(elementIndex).getObject(elementIndex); - } - - @Override - public ColumnRegionObject makeRegion(@NotNull ColumnDefinition columnDefinition, @NotNull ColumnLocation columnLocation, int regionIndex) { - return new Constant(columnLocation.getTableLocation().getKey().getPartitionValue(columnDefinition.getName()).toString()); - } - - static final class Constant implements ColumnRegionObject, Page.WithDefaultsForRepeatingValues { - - private final String string; - - Constant(String string) { - this.string = string; - } - - @Override - public String getObject(long elementIndex) { - return string; - } - - @Override - public void fillChunkAppend(@NotNull FillContext context, @NotNull WritableChunk destination, int length) { - int size = destination.size(); - - destination.asWritableObjectChunk().fillWithValue(size, length, string); - destination.setSize(size + length); - } - - @Override - public Class getNativeType() { - return String.class; - } - } -} diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceShort.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceShort.java index 34d2dc8788a..ffbd9c8762b 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceShort.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceShort.java @@ -5,44 +5,49 @@ import io.deephaven.db.tables.ColumnDefinition; import io.deephaven.db.v2.locations.ColumnLocation; +import io.deephaven.db.v2.locations.TableDataException; +import io.deephaven.db.v2.locations.TableLocationKey; import io.deephaven.db.v2.sources.ColumnSourceGetDefaults; -import io.deephaven.db.v2.sources.chunk.Attributes; +import io.deephaven.db.v2.sources.chunk.Attributes.Values; import org.jetbrains.annotations.NotNull; +import java.util.function.Supplier; + import static io.deephaven.db.v2.utils.ReadOnlyIndex.NULL_KEY; +import static io.deephaven.util.type.TypeUtils.unbox; /** * Regioned column source implementation for columns of shorts. */ -abstract class RegionedColumnSourceShort +abstract class RegionedColumnSourceShort extends RegionedColumnSourceArray> implements ColumnSourceGetDefaults.ForShort { - RegionedColumnSourceShort(ColumnRegionShort nullRegion) { - super(nullRegion, short.class, DeferredColumnRegionShort::new); + RegionedColumnSourceShort(@NotNull final ColumnRegionShort nullRegion, + @NotNull final MakeDeferred> makeDeferred) { + super(nullRegion, short.class, makeDeferred); } @Override - public short getShort(long elementIndex) { + public short getShort(final long elementIndex) { return (elementIndex == NULL_KEY ? getNullRegion() : lookupRegion(elementIndex)).getShort(elementIndex); } - interface MakeRegionDefault extends MakeRegion> { + interface MakeRegionDefault extends MakeRegion> { @Override - default ColumnRegionShort makeRegion(@NotNull ColumnDefinition columnDefinition, - @NotNull ColumnLocation columnLocation, - int regionIndex) { + default ColumnRegionShort makeRegion(@NotNull final ColumnDefinition columnDefinition, + @NotNull final ColumnLocation columnLocation, + final int regionIndex) { if (columnLocation.exists()) { return columnLocation.makeColumnRegionShort(columnDefinition); } - return null; } } - public static final class AsValues extends RegionedColumnSourceShort implements MakeRegionDefault { - public AsValues() { - super(ColumnRegionShort.createNull()); + static final class AsValues extends RegionedColumnSourceShort implements MakeRegionDefault { + AsValues() { + super(ColumnRegionShort.createNull(), DeferredColumnRegionShort::new); } } @@ -51,26 +56,46 @@ public AsValues() { * not hold an array of regions, but rather derives from {@link RegionedColumnSourceBase}, accessing its * regions by looking into the delegate instance's region array. */ - @SuppressWarnings("unused") - static abstract class NativeType + static abstract class NativeType extends RegionedColumnSourceReferencing.NativeColumnSource> implements ColumnSourceGetDefaults.ForShort { - NativeType(RegionedColumnSourceBase>> outerColumnSource) { + NativeType(@NotNull final RegionedColumnSourceBase>> outerColumnSource) { super(Short.class, outerColumnSource); } @Override - public short getShort(long elementIndex) { + public short getShort(final long elementIndex) { return (elementIndex == NULL_KEY ? getNullRegion() : lookupRegion(elementIndex)).getShort(elementIndex); } - static final class AsValues extends NativeType implements MakeRegionDefault { - AsValues(RegionedColumnSourceBase>> outerColumnSource) { + static final class AsValues extends NativeType implements MakeRegionDefault { + AsValues(@NotNull final RegionedColumnSourceBase>> outerColumnSource) { super(outerColumnSource); } } } + static final class Partitioning extends RegionedColumnSourceShort { + + Partitioning() { + super(ColumnRegionShort.createNull(), + Supplier::get // No need to interpose a deferred region in this case + ); + } + + @Override + public ColumnRegionShort makeRegion(@NotNull final ColumnDefinition columnDefinition, + @NotNull final ColumnLocation columnLocation, + final int regionIndex) { + final TableLocationKey locationKey = columnLocation.getTableLocation().getKey(); + final Object partitioningColumnValue = locationKey.getPartitionValue(columnDefinition.getName()); + if (partitioningColumnValue != null && !Short.class.isAssignableFrom(partitioningColumnValue.getClass())) { + throw new TableDataException("Unexpected partitioning column value type for " + columnDefinition.getName() + + ": " + partitioningColumnValue + " is not a Short at location " + locationKey); + } + return new ColumnRegionShort.Constant<>(unbox((Short) partitioningColumnValue)); + } + } } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceStringSet.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceStringSet.java index 9ce4d10ff96..52113fb771f 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceStringSet.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedColumnSourceStringSet.java @@ -10,19 +10,12 @@ import io.deephaven.util.datastructures.cache.ReverseOffsetLookupCache; import org.jetbrains.annotations.NotNull; -import static io.deephaven.db.v2.utils.ReadOnlyIndex.NULL_KEY; - class RegionedColumnSourceStringSet extends RegionedColumnSourceObject { RegionedColumnSourceStringSet() { super(StringSet.class); } - @Override - public StringSet get(long elementIndex) { - return (elementIndex == NULL_KEY ? getNullRegion() : lookupRegion(elementIndex)).getObject(elementIndex); - } - @Override public ColumnRegionObject makeRegion(@NotNull final ColumnDefinition columnDefinition, @NotNull final ColumnLocation columnLocation, diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedPageStore.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedPageStore.java index d621bdfcec2..0d6a0d1efa6 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedPageStore.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedPageStore.java @@ -3,7 +3,7 @@ import io.deephaven.base.MathUtil; import io.deephaven.base.verify.Require; import io.deephaven.db.util.LongSizedDataStructure; -import io.deephaven.db.v2.sources.chunk.Attributes; +import io.deephaven.db.v2.sources.chunk.Attributes.Any; import io.deephaven.db.v2.sources.chunk.SharedContext; import io.deephaven.db.v2.sources.chunk.page.Page; import io.deephaven.db.v2.sources.chunk.page.PageStore; @@ -12,7 +12,7 @@ import static io.deephaven.db.v2.sources.regioned.RegionedColumnSource.ELEMENT_INDEX_TO_SUB_REGION_ELEMENT_INDEX_MASK; -public interface RegionedPageStore> +public interface RegionedPageStore> extends PageStore, LongSizedDataStructure { long REGION_MASK = ELEMENT_INDEX_TO_SUB_REGION_ELEMENT_INDEX_MASK; @@ -20,11 +20,9 @@ public interface RegionedPageStore> REGION_MASK_NUM_BITS); } /** * Get the first element index. + * * @return the first element index for a region index. */ - static long getFirstElementIndex(int regionIndex) { + static long getFirstElementIndex(final int regionIndex) { return (long) regionIndex << REGION_MASK_NUM_BITS; } /** * Get the last element index. + * * @return the last element index for a region index. */ - static long getLastElementIndex(int regionIndex) { + static long getLastElementIndex(final int regionIndex) { return (long) regionIndex << REGION_MASK_NUM_BITS | REGION_MASK; } /** * Get the element index. + * * @return the element index for a particular region offset of a region index. */ - static long getElementIndex(int regionIndex, long regionOffset) { + static long getElementIndex(final int regionIndex, final long regionOffset) { return (long) regionIndex << REGION_MASK_NUM_BITS | regionOffset; } /** * Get the number of regions. + * * @return The number of regions that have been added */ int getRegionCount(); @@ -94,9 +97,10 @@ default REGION_TYPE lookupRegion(final long elementIndex) { return getRegion(getRegionIndex(elementIndex)); } - @Override @NotNull + @Override + @NotNull @FinalDefault - default REGION_TYPE getPageContaining(FillContext fillContext, long row) { + default REGION_TYPE getPageContaining(final FillContext fillContext, final long row) { return lookupRegion(row); } @@ -113,7 +117,7 @@ default FillContext makeFillContext(final int chunkCapacity, final SharedContext class Helper { static long getNumBitsOfMask() { - long numBits = MathUtil.ceilLog2(REGION_MASK); + final long numBits = MathUtil.ceilLog2(REGION_MASK); Require.eq(REGION_MASK + 1, "MAX_REGION_SIZE", 1L << numBits, "1 << RIGHT_SHIFT"); return numBits; } diff --git a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedTableComponentFactoryImpl.java b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedTableComponentFactoryImpl.java index dd3a9ebbdda..5a09551d785 100644 --- a/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedTableComponentFactoryImpl.java +++ b/DB/src/main/java/io/deephaven/db/v2/sources/regioned/RegionedTableComponentFactoryImpl.java @@ -4,7 +4,6 @@ package io.deephaven.db.v2.sources.regioned; -import io.deephaven.base.verify.Require; import io.deephaven.db.tables.CodecLookup; import io.deephaven.db.tables.ColumnDefinition; import io.deephaven.db.tables.libs.StringSet; @@ -72,10 +71,7 @@ public RegionedColumnSource createRegionedColumnSource( Class dataType = TypeUtils.getBoxedType(columnDefinition.getDataType()); if (columnDefinition.isPartitioning()) { - // TODO (https://github.com/deephaven/deephaven-core/issues/878): Support non-String partitioning columns - Require.eq(dataType, "dataType", String.class); - Require.eqFalse(columnDefinition.hasSymbolTable(), "columnDefinition.hasSymbolTable()"); - return (RegionedColumnSource) new RegionedColumnSourcePartitioning(); + return PartitioningSourceFactory.makePartitioningSource(dataType); } final Supplier> simpleImplementationSupplier = SIMPLE_DATA_TYPE_TO_REGIONED_COLUMN_SOURCE_SUPPLIER.get(dataType); diff --git a/DB/src/test/java/io/deephaven/db/tables/utils/TestParquetTools.java b/DB/src/test/java/io/deephaven/db/tables/utils/TestParquetTools.java index f8d43787744..fec7c757a2a 100644 --- a/DB/src/test/java/io/deephaven/db/tables/utils/TestParquetTools.java +++ b/DB/src/test/java/io/deephaven/db/tables/utils/TestParquetTools.java @@ -270,7 +270,7 @@ private Table getAggregatedResultTable() { final double [] bid = new double[size]; final double [] bidSize = new double[size]; for (int ii = 0; ii < size; ++ii) { - symbol[ii] = (ii < 8) ? "ABC" : "XYZ"; + symbol[ii] = (ii < 8) ? "Num" : "XYZ"; bid[ii] = (ii < 15) ? 98 : 99; bidSize[ii] = ii; } @@ -326,23 +326,23 @@ public void testParquetGzipCompressionCodec() { @Test public void testPartitionedRead() { - ParquetTools.writeTable(table1, new File(testRootFile, "Date=2021-07-20" + File.separator + "ABC=B" + File.separator + "file1.parquet")); - ParquetTools.writeTable(table1, new File(testRootFile, "Date=2021-07-20" + File.separator + "ABC=A" + File.separator + "file2.parquet")); - ParquetTools.writeTable(table1, new File(testRootFile, "Date=2021-07-21" + File.separator + "ABC=C" + File.separator + "file3.parquet")); + ParquetTools.writeTable(table1, new File(testRootFile, "Date=2021-07-20" + File.separator + "Num=200" + File.separator + "file1.parquet")); + ParquetTools.writeTable(table1, new File(testRootFile, "Date=2021-07-20" + File.separator + "Num=100" + File.separator + "file2.parquet")); + ParquetTools.writeTable(table1, new File(testRootFile, "Date=2021-07-21" + File.separator + "Num=300" + File.separator + "file3.parquet")); final List allColumns = new ArrayList<>(); allColumns.add(ColumnDefinition.fromGenericType("Date", String.class, ColumnDefinition.COLUMNTYPE_PARTITIONING, null)); - allColumns.add(ColumnDefinition.fromGenericType("ABC", String.class, ColumnDefinition.COLUMNTYPE_PARTITIONING, null)); + allColumns.add(ColumnDefinition.fromGenericType("Num", int.class, ColumnDefinition.COLUMNTYPE_PARTITIONING, null)); allColumns.addAll(table1.getDefinition().getColumnList()); final TableDefinition partitionedDefinition = new TableDefinition(allColumns); final Table result = ParquetTools.readMultiFileTable(KeyValuePartitionLayout.forParquet(testRootFile, 2), ParquetInstructions.EMPTY); TestCase.assertEquals(partitionedDefinition, result.getDefinition()); final Table expected = TableTools.merge( - table1.updateView("Date=`2021-07-20`", "ABC=`A`"), - table1.updateView("Date=`2021-07-20`", "ABC=`B`"), - table1.updateView("Date=`2021-07-21`", "ABC=`C`") - ).moveUpColumns("Date", "ABC"); + table1.updateView("Date=`2021-07-20`", "Num=100"), + table1.updateView("Date=`2021-07-20`", "Num=200"), + table1.updateView("Date=`2021-07-21`", "Num=300") + ).moveUpColumns("Date", "Num"); TstUtils.assertTableEquals(expected, result); } } diff --git a/DB/src/test/java/io/deephaven/db/v2/TestPartitioningColumns.java b/DB/src/test/java/io/deephaven/db/v2/TestPartitioningColumns.java new file mode 100644 index 00000000000..5d3296b3e3d --- /dev/null +++ b/DB/src/test/java/io/deephaven/db/v2/TestPartitioningColumns.java @@ -0,0 +1,175 @@ +package io.deephaven.db.v2; + +import io.deephaven.db.tables.ColumnDefinition; +import io.deephaven.db.tables.Table; +import io.deephaven.db.tables.TableDefinition; +import io.deephaven.db.tables.utils.DBDateTime; +import io.deephaven.db.tables.utils.DBTimeUtils; +import io.deephaven.db.v2.locations.ColumnLocation; +import io.deephaven.db.v2.locations.TableKey; +import io.deephaven.db.v2.locations.TableLocation; +import io.deephaven.db.v2.locations.TableLocationKey; +import io.deephaven.db.v2.locations.impl.*; +import io.deephaven.db.v2.select.MatchFilter; +import io.deephaven.db.v2.select.SelectFilter; +import io.deephaven.db.v2.sources.ColumnSource; +import io.deephaven.db.v2.sources.chunk.Attributes; +import io.deephaven.db.v2.sources.regioned.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.junit.Test; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.stream.Collectors; + +import static io.deephaven.db.tables.utils.TableTools.*; + +/** + * Unit tests for {@link PartitionAwareSourceTable} with many partition types. + */ +public class TestPartitioningColumns { + + @Test + public void testEverything() { + final Table input = newTable( + charCol("Ch", 'C', 'A', 'B'), + byteCol("By", (byte) 1, (byte) 2, (byte) 3), + shortCol("Sh", (short) 1, (short) 2, (short) 3), + intCol("In", 1 << 20, 2 << 20, 3 << 20), + longCol("Lo", 1L << 36, 2L << 36, 3L << 36), + floatCol("Fl", 0.1f, 0.2f, 0.3f), + doubleCol("Do", 0.1, 0.2, 0.3), + dateTimeCol("DT", DBDateTime.now(), DBTimeUtils.plus(DBDateTime.now(), 1), DBTimeUtils.plus(DBDateTime.now(), 2)), + stringCol("St", "ABC", "DEF", "GHI"), + col("Bo", Boolean.TRUE, Boolean.FALSE, Boolean.TRUE) + ); + + final RecordingLocationKeyFinder recordingLocationKeyFinder = new RecordingLocationKeyFinder<>(); + final Map> partitions = new LinkedHashMap<>(); + final String[] partitionKeys = input.getDefinition().getColumnNamesArray(); + //noinspection unchecked + final ColumnSource>[] partitionValueSources = input.getColumnSources().toArray(ColumnSource.ZERO_LENGTH_COLUMN_SOURCE_ARRAY); + final int numColumns = partitionValueSources.length; + input.getIndex().forAllLongs((final long indexKey) -> { + for (int ci = 0; ci < numColumns; ++ci) { + partitions.put(partitionKeys[ci], partitionValueSources[ci].get(indexKey)); + } + recordingLocationKeyFinder.accept(new SimpleTableLocationKey(partitions)); + }); + + final TableDefinition resultDefinition = new TableDefinition(input.getDefinition().getColumnStream().map(ColumnDefinition::withPartitioning).collect(Collectors.toList())); + final Table result = new PartitionAwareSourceTable(resultDefinition, "TestPartitioningColumns", + RegionedTableComponentFactoryImpl.INSTANCE, + new PollingTableLocationProvider<>( + StandaloneTableKey.getInstance(), + recordingLocationKeyFinder, + (tk, tlk, rs) -> { + final DummyTableLocation tl = new DummyTableLocation(tk, tlk); + tl.handleUpdate(1, 1L); + return tl; + }, + null), + null); + + final Table expected = input.sort(input.getDefinition().getColumnNamesArray()); + + TstUtils.assertTableEquals(expected, result); + + final SelectFilter[] filters = input.getDefinition().getColumnStream().map(cd -> new MatchFilter(cd.getName(), (Object) null)).toArray(SelectFilter[]::new); + TstUtils.assertTableEquals(expected.where(filters), result.where(filters)); + + TstUtils.assertTableEquals(expected.selectDistinct(), result.selectDistinct()); + } + + private static final class DummyTableLocation extends AbstractTableLocation { + + protected DummyTableLocation(@NotNull final TableKey tableKey, @NotNull final TableLocationKey tableLocationKey) { + super(tableKey, tableLocationKey, false); + } + + @Override + public void refresh() { + + } + + @NotNull + @Override + protected ColumnLocation makeColumnLocation(@NotNull String name) { + return new ColumnLocation() { + @NotNull + @Override + public TableLocation getTableLocation() { + return DummyTableLocation.this; + } + + @NotNull + @Override + public String getName() { + return name; + } + + @Override + public boolean exists() { + throw new UnsupportedOperationException(); + } + + @Nullable + @Override + public METADATA_TYPE getMetadata(@NotNull ColumnDefinition columnDefinition) { + throw new UnsupportedOperationException(); + } + + @Override + public ColumnRegionChar makeColumnRegionChar(@NotNull ColumnDefinition columnDefinition) { + throw new UnsupportedOperationException(); + } + + @Override + public ColumnRegionByte makeColumnRegionByte(@NotNull ColumnDefinition columnDefinition) { + throw new UnsupportedOperationException(); + } + + @Override + public ColumnRegionShort makeColumnRegionShort(@NotNull ColumnDefinition columnDefinition) { + throw new UnsupportedOperationException(); + } + + @Override + public ColumnRegionInt makeColumnRegionInt(@NotNull ColumnDefinition columnDefinition) { + throw new UnsupportedOperationException(); + } + + @Override + public ColumnRegionLong makeColumnRegionLong(@NotNull ColumnDefinition columnDefinition) { + throw new UnsupportedOperationException(); + } + + @Override + public ColumnRegionFloat makeColumnRegionFloat(@NotNull ColumnDefinition columnDefinition) { + throw new UnsupportedOperationException(); + } + + @Override + public ColumnRegionDouble makeColumnRegionDouble(@NotNull ColumnDefinition columnDefinition) { + throw new UnsupportedOperationException(); + } + + @Override + public ColumnRegionObject makeColumnRegionObject(@NotNull ColumnDefinition columnDefinition) { + throw new UnsupportedOperationException(); + } + + @Override + public ColumnRegionInt makeDictionaryKeysRegion(@NotNull ColumnDefinition columnDefinition) { + throw new UnsupportedOperationException(); + } + + @Override + public ColumnRegionObject makeDictionaryRegion(@NotNull ColumnDefinition columnDefinition) { + throw new UnsupportedOperationException(); + } + }; + } + } +} diff --git a/Integrations/python/deephaven/doc/io/deephaven/datastructures/util/CollectionUtil.json b/Integrations/python/deephaven/doc/io/deephaven/datastructures/util/CollectionUtil.json new file mode 100644 index 00000000000..93d829cf4da --- /dev/null +++ b/Integrations/python/deephaven/doc/io/deephaven/datastructures/util/CollectionUtil.json @@ -0,0 +1,25 @@ +{ + "className": "io.deephaven.datastructures.util.CollectionUtil", + "methods": { + "containsNull": "Determines if an array contains a null.\n\nNote: Java generics information - \n\n:param elems: E[]\n:return: boolean", + "convertDoublesToPrimitiveArray": "Converts a List of Doubles to an array of doubles.\n\n:param collection: java.util.Collection\n:return: double[]", + "convertIntegersToPrimitiveArray": "Converts a Collection of Integers to an array of ints.\n\n:param collection: java.util.Collection\n:return: int[]", + "convertLongsToPrimitiveArray": "Converts a Collection of Integers to an array of ints.\n\n:param collection: java.util.Collection\n:return: long[]", + "invertMap": "Note: Java generics information - \n\n:param sourceMap: java.util.Map\n:return: java.util.Map", + "listFromArray": "Note: Java generics information - \n\n:param data: E...\n:return: java.util.List", + "mapFromArray": "*Overload 1* \n Note: Java generics information - \n \n :param typeK: java.lang.Class\n :param typeV: java.lang.Class\n :param data: java.lang.Object...\n :return: java.util.Map\n \n*Overload 2* \n Note: Java generics information - \n \n :param typeK: java.lang.Class\n :param typeV: java.lang.Class\n :param allowDuplicateKeys: boolean\n :param data: java.lang.Object...\n :return: java.util.Map", + "newSizedHashMap": "Returns an empty HashMap with a big enough capacity\n such that the given number of entries can be added without\n resizing.\n\nNote: Java generics information - \n\n:param nEntries: int\n:return: java.util.Map", + "newSizedHashSet": "Returns an empty HashSet with a big enough capacity\n such that the given number of entries can be added without\n resizing.\n\nNote: Java generics information - \n\n:param nEntries: int\n:return: java.util.Set", + "newSizedLinkedHashMap": "Returns an empty LinkedHashMap with a big enough\n capacity such that the given number of entries can be added\n without resizing.\n\nNote: Java generics information - \n\n:param nEntries: int\n:return: java.util.Map", + "newSizedLinkedHashSet": "Returns an empty LinkedHashSet with a big enough capacity\n such that the given number of entries can be added without\n resizing.\n\nNote: Java generics information - \n\n:param nEntries: int\n:return: java.util.Set", + "setFromArray": "*Overload 1* \n Note: Java generics information - \n \n :param data: E...\n :return: java.util.Set\n \n*Overload 2* \n Note: Java generics information - \n \n :param type: java.lang.Class\n :param data: java.lang.Object...\n :return: java.util.Set", + "shuffle": "Shuffles the elements in an array.\n\nNote: Java generics information - \n\n:param elems: E[]\n:param random: java.util.Random", + "universalSet": "Returns the universal set (immutable). This set is serializable.\n\nNote: Java generics information - \n\n:return: java.util.Set", + "unmodifiableInvertMap": "Note: Java generics information - \n\n:param sourceMap: java.util.Map\n:return: java.util.Map", + "unmodifiableMapFromArray": "Note: Java generics information - \n\n:param typeK: java.lang.Class\n:param typeV: java.lang.Class\n:param data: java.lang.Object...\n:return: java.util.Map", + "unmodifiableSetFromArray": "Note: Java generics information - \n\n:param data: E...\n:return: java.util.Set" + }, + "path": "io.deephaven.datastructures.util.CollectionUtil", + "text": "Utility methods for creating collections.", + "typeName": "class" +} \ No newline at end of file diff --git a/Integrations/python/deephaven/doc/io/deephaven/datastructures/util/HashCodeUtil.json b/Integrations/python/deephaven/doc/io/deephaven/datastructures/util/HashCodeUtil.json new file mode 100644 index 00000000000..e4944f2f6da --- /dev/null +++ b/Integrations/python/deephaven/doc/io/deephaven/datastructures/util/HashCodeUtil.json @@ -0,0 +1,10 @@ +{ + "className": "io.deephaven.datastructures.util.HashCodeUtil", + "methods": { + "combineHashCodes": ":param values: java.lang.Object...\n:return: int", + "createHashCode": ":param values: java.lang.Object[]\n:return: int", + "toHashCode": "*Overload 1* \n :param val: double\n :return: int\n \n*Overload 2* \n :param val: long\n :return: int\n \n*Overload 3* \n :param obj: java.lang.Object\n :return: int" + }, + "path": "io.deephaven.datastructures.util.HashCodeUtil", + "typeName": "class" +} \ No newline at end of file diff --git a/Integrations/python/deephaven/doc/io/deephaven/datastructures/util/SmartKey.json b/Integrations/python/deephaven/doc/io/deephaven/datastructures/util/SmartKey.json new file mode 100644 index 00000000000..c33805af876 --- /dev/null +++ b/Integrations/python/deephaven/doc/io/deephaven/datastructures/util/SmartKey.json @@ -0,0 +1,14 @@ +{ + "className": "io.deephaven.datastructures.util.SmartKey", + "methods": { + "compareTo": ":param o: java.lang.Object\n:return: int", + "equals": ":param obj: java.lang.Object\n:return: boolean", + "get": ":param position: int\n:return: java.lang.Object", + "hashCode": ":return: int", + "size": ":return: int", + "subKey": ":param positions: int...\n:return: io.deephaven.datastructures.util.SmartKey", + "toString": ":return: java.lang.String" + }, + "path": "io.deephaven.datastructures.util.SmartKey", + "typeName": "class" +} \ No newline at end of file diff --git a/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/chunk/page/Page.json b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/chunk/page/Page.json index 33e727b4733..258f2c80b9e 100644 --- a/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/chunk/page/Page.json +++ b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/chunk/page/Page.json @@ -8,6 +8,6 @@ "length": ":return: (long) the length of this page." }, "path": "io.deephaven.db.v2.sources.chunk.page.Page", - "text": "This provides the ChunkSource interface to a contiguous block of data from\n the range [firstRowOffset(),firstRowOffset() + length()).\n\n Non overlapping pages can be collected together in a PageStore, which provides the ChunkSource\n interface to the collection of all of its Pages.\n\n There are two distinct use cases/types of pages. The first use case are Pages which always have a\n length() > 0. These store length() values, which can be assessed via the ChunkSource methods.\n Valid OrderedKeys passed to those methods will have their offset in the range\n [firstRowOffset(), firstRowOffset() + length()). Passing OrderKeys with offsets outside of this range will have\n undefined results.\n\n The second use case will always have length() == 0 and firstRowOffset() == 0. These represent \"Null\" regions\n which return a fixed value, typically a null value, for every OrderedKeys passed into the\n ChunkSource methods. In order to have this use case, override length and override lastRow\n as maxRow.\n\n Though the ChunkSource methods ignore the non-offset portion of the rows in the OrderedKeys,\n then can assume they are identical for all the passed in elements of the OrderedKeys. For instance,\n they can use the simple difference between the complete row value to determine a length.", + "text": "This provides the ChunkSource interface to a contiguous block of data from\n the range [firstRowOffset(),firstRowOffset() + length()).\n \n Non overlapping pages can be collected together in a PageStore, which provides the ChunkSource\n interface to the collection of all of its Pages.\n \n There are two distinct use cases/types of pages. The first use case are Pages which always have a\n length() > 0. These store length() values, which can be assessed via the ChunkSource methods.\n Valid OrderedKeys passed to those methods will have their offset in the range\n [firstRowOffset(), firstRowOffset() + length()). Passing OrderKeys with offsets outside of this range will have\n undefined results.\n \n The second use case will always have length() == 0 and firstRowOffset() == 0. These represent \"Null\" regions\n which return a fixed value, typically a null value, for every OrderedKeys passed into the\n ChunkSource methods. In order to have this use case, override length and override lastRow\n as maxRow.\n \n Though the ChunkSource methods ignore the non-offset portion of the rows in the OrderedKeys,\n then can assume they are identical for all the passed in elements of the OrderedKeys. For instance,\n they can use the simple difference between the complete row value to determine a length.", "typeName": "interface" } \ No newline at end of file diff --git a/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/chunk/page/Page/WithDefaults.json b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/chunk/page/Page/WithDefaults.json index d5b5cadc40f..b148dc1b21e 100644 --- a/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/chunk/page/Page/WithDefaults.json +++ b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/chunk/page/Page/WithDefaults.json @@ -5,5 +5,6 @@ "fillChunkAppend": "**Incompatible overloads text - text from the first overload:**\n\nAppends the values referenced by orderKeys onto destination. orderKeys are assumed\n to be entirely contained on this Page.\n\n*Overload 1* \n :param context: (io.deephaven.db.v2.sources.chunk.ChunkSource.FillContext) - A context containing all mutable/state related data used in retrieving the Chunk.\n In particular, the Context may be used to provide a Chunk data pool\n :param destination: (io.deephaven.db.v2.sources.chunk.WritableChunk) - The chunk to append the results to.\n :param orderedKeysIterator: (io.deephaven.db.v2.utils.OrderedKeys.Iterator) - The iterator to the ordered keys, which contain at least the keys to extract from\n this ChunkSource. The keys to extract will be at the beginning of iteration\n order.\n \n*Overload 2* \n :param context: io.deephaven.db.v2.sources.chunk.ChunkSource.FillContext\n :param destination: io.deephaven.db.v2.sources.chunk.WritableChunk\n :param orderedKeys: io.deephaven.db.v2.utils.OrderedKeys" }, "path": "io.deephaven.db.v2.sources.chunk.page.Page.WithDefaults", + "text": "Helper defaults for general pages.", "typeName": "interface" } \ No newline at end of file diff --git a/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/chunk/page/Page/WithDefaultsForRepeatingValues.json b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/chunk/page/Page/WithDefaultsForRepeatingValues.json index 9dbbe1a5c5e..75462bb454b 100644 --- a/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/chunk/page/Page/WithDefaultsForRepeatingValues.json +++ b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/chunk/page/Page/WithDefaultsForRepeatingValues.json @@ -7,6 +7,6 @@ "length": ":return: (long) the length of this page." }, "path": "io.deephaven.db.v2.sources.chunk.page.Page.WithDefaultsForRepeatingValues", - "text": "This has helper defaults for columns that just represent a repeating value (such as null or partition columns).", + "text": "Helper defaults for pages that represent a repeating value, e.g. null or partitioning column regions.", "typeName": "interface" } \ No newline at end of file diff --git a/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionByte/Constant.json b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionByte/Constant.json new file mode 100644 index 00000000000..3b7febbca6c --- /dev/null +++ b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionByte/Constant.json @@ -0,0 +1,10 @@ +{ + "className": "io.deephaven.db.v2.sources.regioned.ColumnRegionByte$Constant", + "methods": { + "fillChunkAppend": "Appends the values repeating value length times to destination.\n\n:param context: io.deephaven.db.v2.sources.chunk.ChunkSource.FillContext\n:param destination: io.deephaven.db.v2.sources.chunk.WritableChunk\n:param length: int", + "getByte": "Get a single byte from this region.\n\n:param elementIndex: (long) - Element (byte) index in the table's address space\n:return: (byte) The byte value at the specified element (byte) index", + "getBytes": "Get a range of bytes from this region. Implementations are not required to verify that the range specified is\n meaningful.\n\n:param firstElementIndex: (long) - First element (byte) index in the table's address space\n:param destination: (byte[]) - Array to store results\n:param destinationOffset: (int) - Offset into destination to begin storing at\n:param length: (int) - Number of bytes to get\n:return: (byte[]) destination, to enable method chaining" + }, + "path": "io.deephaven.db.v2.sources.regioned.ColumnRegionByte.Constant", + "typeName": "class" +} \ No newline at end of file diff --git a/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionChar/Constant.json b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionChar/Constant.json new file mode 100644 index 00000000000..ee8e1d2c86c --- /dev/null +++ b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionChar/Constant.json @@ -0,0 +1,9 @@ +{ + "className": "io.deephaven.db.v2.sources.regioned.ColumnRegionChar$Constant", + "methods": { + "fillChunkAppend": "Appends the values repeating value length times to destination.\n\n:param context: io.deephaven.db.v2.sources.chunk.ChunkSource.FillContext\n:param destination: io.deephaven.db.v2.sources.chunk.WritableChunk\n:param length: int", + "getChar": "Get a single char from this region.\n\n:param elementIndex: (long) - Element (char) index in the table's address space\n:return: (char) The char value at the specified element (char) index" + }, + "path": "io.deephaven.db.v2.sources.regioned.ColumnRegionChar.Constant", + "typeName": "class" +} \ No newline at end of file diff --git a/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionDouble/Constant.json b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionDouble/Constant.json new file mode 100644 index 00000000000..170e6233dda --- /dev/null +++ b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionDouble/Constant.json @@ -0,0 +1,9 @@ +{ + "className": "io.deephaven.db.v2.sources.regioned.ColumnRegionDouble$Constant", + "methods": { + "fillChunkAppend": "Appends the values repeating value length times to destination.\n\n:param context: io.deephaven.db.v2.sources.chunk.ChunkSource.FillContext\n:param destination: io.deephaven.db.v2.sources.chunk.WritableChunk\n:param length: int", + "getDouble": "Get a single double from this region.\n\n:param elementIndex: (long) - Element (double) index in the table's address space\n:return: (double) The double value at the specified element (double) index" + }, + "path": "io.deephaven.db.v2.sources.regioned.ColumnRegionDouble.Constant", + "typeName": "class" +} \ No newline at end of file diff --git a/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionFloat/Constant.json b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionFloat/Constant.json new file mode 100644 index 00000000000..fa139d4194c --- /dev/null +++ b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionFloat/Constant.json @@ -0,0 +1,9 @@ +{ + "className": "io.deephaven.db.v2.sources.regioned.ColumnRegionFloat$Constant", + "methods": { + "fillChunkAppend": "Appends the values repeating value length times to destination.\n\n:param context: io.deephaven.db.v2.sources.chunk.ChunkSource.FillContext\n:param destination: io.deephaven.db.v2.sources.chunk.WritableChunk\n:param length: int", + "getFloat": "Get a single float from this region.\n\n:param elementIndex: (long) - Element (float) index in the table's address space\n:return: (float) The float value at the specified element (float) index" + }, + "path": "io.deephaven.db.v2.sources.regioned.ColumnRegionFloat.Constant", + "typeName": "class" +} \ No newline at end of file diff --git a/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionInt/Constant.json b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionInt/Constant.json new file mode 100644 index 00000000000..b96f0647c3d --- /dev/null +++ b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionInt/Constant.json @@ -0,0 +1,9 @@ +{ + "className": "io.deephaven.db.v2.sources.regioned.ColumnRegionInt$Constant", + "methods": { + "fillChunkAppend": "Appends the values repeating value length times to destination.\n\n:param context: io.deephaven.db.v2.sources.chunk.ChunkSource.FillContext\n:param destination: io.deephaven.db.v2.sources.chunk.WritableChunk\n:param length: int", + "getInt": "Get a single int from this region.\n\n:param elementIndex: (long) - Element (int) index in the table's address space\n:return: (int) The int value at the specified element (int) index" + }, + "path": "io.deephaven.db.v2.sources.regioned.ColumnRegionInt.Constant", + "typeName": "class" +} \ No newline at end of file diff --git a/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionLong/Constant.json b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionLong/Constant.json new file mode 100644 index 00000000000..12671a7f685 --- /dev/null +++ b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionLong/Constant.json @@ -0,0 +1,9 @@ +{ + "className": "io.deephaven.db.v2.sources.regioned.ColumnRegionLong$Constant", + "methods": { + "fillChunkAppend": "Appends the values repeating value length times to destination.\n\n:param context: io.deephaven.db.v2.sources.chunk.ChunkSource.FillContext\n:param destination: io.deephaven.db.v2.sources.chunk.WritableChunk\n:param length: int", + "getLong": "Get a single long from this region.\n\n:param elementIndex: (long) - Element (long) index in the table's address space\n:return: (long) The long value at the specified element (long) index" + }, + "path": "io.deephaven.db.v2.sources.regioned.ColumnRegionLong.Constant", + "typeName": "class" +} \ No newline at end of file diff --git a/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionObject.json b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionObject.json index 8421d26b3fb..d76fec20426 100644 --- a/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionObject.json +++ b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionObject.json @@ -3,8 +3,8 @@ "methods": { "createNull": "Note: Java generics information - \n\n:return: io.deephaven.db.v2.sources.regioned.ColumnRegionObject.Null", "getNativeType": ":return: java.lang.Class", - "getObject": "Get a single object from this region.\n\n*Overload 1* \n :param elementIndex: (long) - Element (object) index in the table's address space\n :return: (ColumnRegionObject.T) The object value at the specified element (object) index\n \n*Overload 2* \n :param context: (io.deephaven.db.v2.sources.chunk.ChunkSource.FillContext) - A ColumnRegionFillContext to enable resource caching where suitable, with current\n region index pointing to this region\n :param elementIndex: (long) - Element (object) index in the table's address space\n :return: (ColumnRegionObject.T) The object value at the specified element (object) index", - "skipCache": ":return: io.deephaven.db.v2.sources.regioned.ColumnRegionObject" + "getObject": "Get a single object from this region.\n\n*Overload 1* \n :param elementIndex: (long) - Element (object) index in the table's address space\n :return: (ColumnRegionObject.DATA_TYPE) The object value at the specified element (object) index\n \n*Overload 2* \n :param context: (io.deephaven.db.v2.sources.chunk.ChunkSource.FillContext) - A ColumnRegionFillContext to enable resource caching where suitable, with current\n region index pointing to this region\n :param elementIndex: (long) - Element (object) index in the table's address space\n :return: (ColumnRegionObject.DATA_TYPE) The object value at the specified element (object) index", + "skipCache": ":return: io.deephaven.db.v2.sources.regioned.ColumnRegionObject" }, "path": "io.deephaven.db.v2.sources.regioned.ColumnRegionObject", "text": "Column region interface for regions that support fetching objects.", diff --git a/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionObject/Constant.json b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionObject/Constant.json new file mode 100644 index 00000000000..d61c16372e0 --- /dev/null +++ b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionObject/Constant.json @@ -0,0 +1,10 @@ +{ + "className": "io.deephaven.db.v2.sources.regioned.ColumnRegionObject$Constant", + "methods": { + "fillChunkAppend": "Appends the values repeating value length times to destination.\n\n:param context: io.deephaven.db.v2.sources.chunk.ChunkSource.FillContext\n:param destination: io.deephaven.db.v2.sources.chunk.WritableChunk\n:param length: int", + "getNativeType": ":return: java.lang.Class", + "getObject": "Get a single object from this region.\n\n:param elementIndex: (long) - Element (object) index in the table's address space\n:return: (ColumnRegionObject.Constant.DATA_TYPE) The object value at the specified element (object) index" + }, + "path": "io.deephaven.db.v2.sources.regioned.ColumnRegionObject.Constant", + "typeName": "class" +} \ No newline at end of file diff --git a/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionObject/Null.json b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionObject/Null.json index 41ecf779c90..e817080c61c 100644 --- a/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionObject/Null.json +++ b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionObject/Null.json @@ -1,8 +1,8 @@ { "className": "io.deephaven.db.v2.sources.regioned.ColumnRegionObject$Null", "methods": { - "getNativeType": ":return: (java.lang.Class) null", - "getObject": "Get a single object from this region.\n\n:param elementIndex: (long) - Element (object) index in the table's address space\n:return: (ColumnRegionObject.Null.T) The object value at the specified element (object) index" + "getNativeType": ":return: (java.lang.Class) null", + "getObject": "Get a single object from this region.\n\n:param elementIndex: (long) - Element (object) index in the table's address space\n:return: (ColumnRegionObject.Null.DATA_TYPE) The object value at the specified element (object) index" }, "path": "io.deephaven.db.v2.sources.regioned.ColumnRegionObject.Null", "typeName": "class" diff --git a/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionShort/Constant.json b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionShort/Constant.json new file mode 100644 index 00000000000..b2e42c48ee4 --- /dev/null +++ b/Integrations/python/deephaven/doc/io/deephaven/db/v2/sources/regioned/ColumnRegionShort/Constant.json @@ -0,0 +1,9 @@ +{ + "className": "io.deephaven.db.v2.sources.regioned.ColumnRegionShort$Constant", + "methods": { + "fillChunkAppend": "Appends the values repeating value length times to destination.\n\n:param context: io.deephaven.db.v2.sources.chunk.ChunkSource.FillContext\n:param destination: io.deephaven.db.v2.sources.chunk.WritableChunk\n:param length: int", + "getShort": "Get a single short from this region.\n\n:param elementIndex: (long) - Element (short) index in the table's address space\n:return: (short) The short value at the specified element (short) index" + }, + "path": "io.deephaven.db.v2.sources.regioned.ColumnRegionShort.Constant", + "typeName": "class" +} \ No newline at end of file