Search in sources :

Example 1 with DateStatisticsBuilder

use of io.prestosql.orc.metadata.statistics.DateStatisticsBuilder in project hetu-core by openlookeng.

the class ColumnWriters method createColumnWriter.

public static ColumnWriter createColumnWriter(OrcColumnId columnId, ColumnMetadata<OrcType> orcTypes, Type type, CompressionKind compression, int bufferSize, DataSize stringStatisticsLimit) {
    requireNonNull(type, "type is null");
    OrcType orcType = orcTypes.get(columnId);
    switch(orcType.getOrcTypeKind()) {
        case BOOLEAN:
            return new BooleanColumnWriter(columnId, type, compression, bufferSize);
        case FLOAT:
            return new FloatColumnWriter(columnId, type, compression, bufferSize);
        case DOUBLE:
            return new DoubleColumnWriter(columnId, type, compression, bufferSize);
        case BYTE:
            return new ByteColumnWriter(columnId, type, compression, bufferSize);
        case DATE:
            return new LongColumnWriter(columnId, type, compression, bufferSize, DateStatisticsBuilder::new);
        case SHORT:
        case INT:
        case LONG:
            return new LongColumnWriter(columnId, type, compression, bufferSize, IntegerStatisticsBuilder::new);
        case DECIMAL:
            return new DecimalColumnWriter(columnId, type, compression, bufferSize);
        case TIMESTAMP:
            return new TimestampColumnWriter(columnId, type, compression, bufferSize);
        case BINARY:
            return new SliceDirectColumnWriter(columnId, type, compression, bufferSize, BinaryStatisticsBuilder::new);
        case CHAR:
        case VARCHAR:
        case STRING:
            return new SliceDictionaryColumnWriter(columnId, type, compression, bufferSize, stringStatisticsLimit);
        case LIST:
            {
                OrcColumnId fieldColumnIndex = orcType.getFieldTypeIndex(0);
                Type fieldType = type.getTypeParameters().get(0);
                ColumnWriter elementWriter = createColumnWriter(fieldColumnIndex, orcTypes, fieldType, compression, bufferSize, stringStatisticsLimit);
                return new ListColumnWriter(columnId, compression, bufferSize, elementWriter);
            }
        case MAP:
            {
                ColumnWriter keyWriter = createColumnWriter(orcType.getFieldTypeIndex(0), orcTypes, type.getTypeParameters().get(0), compression, bufferSize, stringStatisticsLimit);
                ColumnWriter valueWriter = createColumnWriter(orcType.getFieldTypeIndex(1), orcTypes, type.getTypeParameters().get(1), compression, bufferSize, stringStatisticsLimit);
                return new MapColumnWriter(columnId, compression, bufferSize, keyWriter, valueWriter);
            }
        case STRUCT:
            {
                ImmutableList.Builder<ColumnWriter> fieldWriters = ImmutableList.builder();
                for (int fieldId = 0; fieldId < orcType.getFieldCount(); fieldId++) {
                    OrcColumnId fieldColumnIndex = orcType.getFieldTypeIndex(fieldId);
                    Type fieldType = type.getTypeParameters().get(fieldId);
                    fieldWriters.add(createColumnWriter(fieldColumnIndex, orcTypes, fieldType, compression, bufferSize, stringStatisticsLimit));
                }
                return new StructColumnWriter(columnId, compression, bufferSize, fieldWriters.build());
            }
    }
    throw new IllegalArgumentException("Unsupported type: " + type);
}
Also used : DateStatisticsBuilder(io.prestosql.orc.metadata.statistics.DateStatisticsBuilder) BinaryStatisticsBuilder(io.prestosql.orc.metadata.statistics.BinaryStatisticsBuilder) OrcColumnId(io.prestosql.orc.metadata.OrcColumnId) BinaryStatisticsBuilder(io.prestosql.orc.metadata.statistics.BinaryStatisticsBuilder) IntegerStatisticsBuilder(io.prestosql.orc.metadata.statistics.IntegerStatisticsBuilder) DateStatisticsBuilder(io.prestosql.orc.metadata.statistics.DateStatisticsBuilder) IntegerStatisticsBuilder(io.prestosql.orc.metadata.statistics.IntegerStatisticsBuilder) OrcType(io.prestosql.orc.metadata.OrcType) Type(io.prestosql.spi.type.Type) OrcType(io.prestosql.orc.metadata.OrcType)

Aggregations

OrcColumnId (io.prestosql.orc.metadata.OrcColumnId)1 OrcType (io.prestosql.orc.metadata.OrcType)1 BinaryStatisticsBuilder (io.prestosql.orc.metadata.statistics.BinaryStatisticsBuilder)1 DateStatisticsBuilder (io.prestosql.orc.metadata.statistics.DateStatisticsBuilder)1 IntegerStatisticsBuilder (io.prestosql.orc.metadata.statistics.IntegerStatisticsBuilder)1 Type (io.prestosql.spi.type.Type)1