Skip to content

Commit

Permalink
Make use of RowSetCodec instead of ExternalizableCodec for Parquet Ro…
Browse files Browse the repository at this point in the history
…wSet writing.
  • Loading branch information
rcaudy committed Mar 19, 2024
1 parent 9bc8786 commit a7bc940
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
//
package io.deephaven.engine.table.impl;

import io.deephaven.engine.rowset.RowSet;
import io.deephaven.engine.table.ColumnDefinition;
import io.deephaven.engine.table.impl.dataindex.RowSetCodec;
import io.deephaven.util.codec.*;
import io.deephaven.vector.ObjectVector;
import io.deephaven.vector.Vector;
import io.deephaven.stringset.StringSet;
import io.deephaven.util.codec.CodecCache;
import io.deephaven.util.codec.ExternalizableCodec;
import io.deephaven.util.codec.ObjectCodec;
import io.deephaven.util.codec.SerializableCodec;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -145,6 +144,10 @@ public static <TYPE> ObjectCodec<TYPE> lookup(@NotNull final Class<TYPE> dataTyp
* @return The default {@link ObjectCodec}
*/
public static <TYPE> ObjectCodec<TYPE> getDefaultCodec(@NotNull final Class<TYPE> dataType) {
// TODO (https://github.com/deephaven/deephaven-core/issues/5262): Eliminate reliance on RowSetCodec
if (dataType.equals(RowSet.class)) {
return CodecCache.DEFAULT.getCodec(RowSetCodec.class.getName(), null);
}
if (Externalizable.class.isAssignableFrom(dataType)) {
return CodecCache.DEFAULT.getCodec(ExternalizableCodec.class.getName(), dataType.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.deephaven.engine.table.ColumnDefinition;
import io.deephaven.engine.table.ColumnSource;
import io.deephaven.engine.table.impl.CodecLookup;
import io.deephaven.engine.table.impl.dataindex.RowSetCodec;
import io.deephaven.stringset.StringSet;
import io.deephaven.util.codec.ExternalizableCodec;
import io.deephaven.util.codec.SerializableCodec;
Expand Down Expand Up @@ -105,6 +106,10 @@ static Pair<String, String> getCodecAndArgs(

// Impute an appropriate codec for the data type
final Class<?> dataType = columnDefinition.getDataType();
// TODO (https://github.com/deephaven/deephaven-core/issues/5262): Eliminate reliance on RowSetCodec
if (dataType.equals(RowSet.class)) {
return new ImmutablePair<>(RowSetCodec.class.getName(), null);
}
if (Externalizable.class.isAssignableFrom(dataType)) {
return new ImmutablePair<>(ExternalizableCodec.class.getName(), dataType.getName());
}
Expand Down Expand Up @@ -144,15 +149,16 @@ static TypeInfo bigDecimalTypeInfo(
// noinspection unchecked
final PrecisionAndScale precisionAndScale = getPrecisionAndScale(
computedCache, columnName, rowSet, () -> (ColumnSource<BigDecimal>) columnSourceMap.get(columnName));
final Set<Class<?>> clazzes = Collections.singleton(BigDecimal.class);
final Set<Class<?>> clazzes = Set.of(BigDecimal.class);
return new TypeInfo() {
@Override
public Set<Class<?>> getTypes() {
return clazzes;
}

@Override
public PrimitiveBuilder<PrimitiveType> getBuilderImpl(boolean required, boolean repeating, Class dataType) {
public PrimitiveBuilder<PrimitiveType> getBuilderImpl(boolean required, boolean repeating,
Class<?> dataType) {
return type(PrimitiveTypeName.BINARY, required, repeating)
.as(LogicalTypeAnnotation.decimalType(precisionAndScale.scale, precisionAndScale.precision));
}
Expand Down Expand Up @@ -183,8 +189,7 @@ private static PrimitiveBuilder<PrimitiveType> type(PrimitiveTypeName type, bool
private enum IntType implements TypeInfo {
INSTANCE;

private static final Set<Class<?>> clazzes = Collections
.unmodifiableSet(new HashSet<>(Arrays.asList(int.class, Integer.class)));
private static final Set<Class<?>> clazzes = Set.of(int.class, Integer.class);

@Override
public Set<Class<?>> getTypes() {
Expand All @@ -200,8 +205,7 @@ public PrimitiveBuilder<PrimitiveType> getBuilderImpl(boolean required, boolean
private enum LongType implements TypeInfo {
INSTANCE;

private static final Set<Class<?>> clazzes = Collections
.unmodifiableSet(new HashSet<>(Arrays.asList(long.class, Long.class)));
private static final Set<Class<?>> clazzes = Set.of(long.class, Long.class);

@Override
public Set<Class<?>> getTypes() {
Expand All @@ -217,8 +221,7 @@ public PrimitiveBuilder<PrimitiveType> getBuilderImpl(boolean required, boolean
private enum ShortType implements TypeInfo {
INSTANCE;

private static final Set<Class<?>> clazzes = Collections
.unmodifiableSet(new HashSet<>(Arrays.asList(short.class, Short.class)));
private static final Set<Class<?>> clazzes = Set.of(short.class, Short.class);

@Override
public Set<Class<?>> getTypes() {
Expand All @@ -234,8 +237,7 @@ public PrimitiveBuilder<PrimitiveType> getBuilderImpl(boolean required, boolean
private enum BooleanType implements TypeInfo {
INSTANCE;

private static final Set<Class<?>> clazzes = Collections
.unmodifiableSet(new HashSet<>(Arrays.asList(boolean.class, Boolean.class)));
private static final Set<Class<?>> clazzes = Set.of(boolean.class, Boolean.class);

@Override
public Set<Class<?>> getTypes() {
Expand All @@ -251,8 +253,7 @@ public PrimitiveBuilder<PrimitiveType> getBuilderImpl(boolean required, boolean
private enum FloatType implements TypeInfo {
INSTANCE;

private static final Set<Class<?>> clazzes = Collections
.unmodifiableSet(new HashSet<>(Arrays.asList(float.class, Float.class)));
private static final Set<Class<?>> clazzes = Set.of(float.class, Float.class);

@Override
public Set<Class<?>> getTypes() {
Expand All @@ -268,8 +269,7 @@ public PrimitiveBuilder<PrimitiveType> getBuilderImpl(boolean required, boolean
private enum DoubleType implements TypeInfo {
INSTANCE;

private static final Set<Class<?>> clazzes = Collections
.unmodifiableSet(new HashSet<>(Arrays.asList(double.class, Double.class)));
private static final Set<Class<?>> clazzes = Set.of(double.class, Double.class);

@Override
public Set<Class<?>> getTypes() {
Expand All @@ -285,8 +285,7 @@ public PrimitiveBuilder<PrimitiveType> getBuilderImpl(boolean required, boolean
private enum CharType implements TypeInfo {
INSTANCE;

private static final Set<Class<?>> clazzes = Collections
.unmodifiableSet(new HashSet<>(Arrays.asList(char.class, Character.class)));
private static final Set<Class<?>> clazzes = Set.of(char.class, Character.class);

@Override
public Set<Class<?>> getTypes() {
Expand All @@ -302,8 +301,7 @@ public PrimitiveBuilder<PrimitiveType> getBuilderImpl(boolean required, boolean
private enum ByteType implements TypeInfo {
INSTANCE;

private static final Set<Class<?>> clazzes = Collections
.unmodifiableSet(new HashSet<>(Arrays.asList(byte.class, Byte.class)));
private static final Set<Class<?>> clazzes = Set.of(byte.class, Byte.class);

@Override
public Set<Class<?>> getTypes() {
Expand All @@ -319,7 +317,7 @@ public PrimitiveBuilder<PrimitiveType> getBuilderImpl(boolean required, boolean
private enum StringType implements TypeInfo {
INSTANCE;

private static final Set<Class<?>> clazzes = Collections.singleton(String.class);
private static final Set<Class<?>> clazzes = Set.of(String.class);

@Override
public Set<Class<?>> getTypes() {
Expand All @@ -336,7 +334,7 @@ public PrimitiveBuilder<PrimitiveType> getBuilderImpl(boolean required, boolean
private enum InstantType implements TypeInfo {
INSTANCE;

private static final Set<Class<?>> clazzes = Collections.singleton(Instant.class);
private static final Set<Class<?>> clazzes = Set.of(Instant.class);

@Override
public Set<Class<?>> getTypes() {
Expand All @@ -354,7 +352,7 @@ public PrimitiveBuilder<PrimitiveType> getBuilderImpl(boolean required, boolean
private enum LocalDateTimeType implements TypeInfo {
INSTANCE;

private static final Set<Class<?>> clazzes = Collections.singleton(LocalDateTime.class);
private static final Set<Class<?>> clazzes = Set.of(LocalDateTime.class);

@Override
public Set<Class<?>> getTypes() {
Expand All @@ -372,7 +370,7 @@ public PrimitiveBuilder<PrimitiveType> getBuilderImpl(boolean required, boolean
private enum LocalDateType implements TypeInfo {
INSTANCE;

private static final Set<Class<?>> clazzes = Collections.singleton(LocalDate.class);
private static final Set<Class<?>> clazzes = Set.of(LocalDate.class);

@Override
public Set<Class<?>> getTypes() {
Expand All @@ -389,7 +387,7 @@ public PrimitiveBuilder<PrimitiveType> getBuilderImpl(boolean required, boolean
private enum LocalTimeType implements TypeInfo {
INSTANCE;

private static final Set<Class<?>> clazzes = Collections.singleton(LocalTime.class);
private static final Set<Class<?>> clazzes = Set.of(LocalTime.class);

@Override
public Set<Class<?>> getTypes() {
Expand All @@ -413,7 +411,7 @@ public PrimitiveBuilder<PrimitiveType> getBuilderImpl(boolean required, boolean
private enum BigIntegerType implements TypeInfo {
INSTANCE;

private static final Set<Class<?>> clazzes = Collections.singleton(BigInteger.class);
private static final Set<Class<?>> clazzes = Set.of(BigInteger.class);

@Override
public Set<Class<?>> getTypes() {
Expand Down

0 comments on commit a7bc940

Please sign in to comment.