Search in sources :

Example 1 with Float8Writer

use of org.apache.drill.exec.vector.complex.writer.Float8Writer in project drill by axbaretto.

the class DrillParquetGroupConverter method getConverterForType.

@SuppressWarnings("resource")
private PrimitiveConverter getConverterForType(String name, PrimitiveType type) {
    switch(type.getPrimitiveTypeName()) {
        case INT32:
            {
                if (type.getOriginalType() == null) {
                    IntWriter writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).integer() : mapWriter.integer(name);
                    return new DrillIntConverter(writer);
                }
                switch(type.getOriginalType()) {
                    case UINT_8:
                    case UINT_16:
                    case UINT_32:
                    case INT_8:
                    case INT_16:
                    case INT_32:
                        {
                            IntWriter writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).integer() : mapWriter.integer(name);
                            return new DrillIntConverter(writer);
                        }
                    case DECIMAL:
                        {
                            ParquetReaderUtility.checkDecimalTypeEnabled(options);
                            Decimal9Writer writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).decimal9() : mapWriter.decimal9(name, type.getDecimalMetadata().getScale(), type.getDecimalMetadata().getPrecision());
                            return new DrillDecimal9Converter(writer, type.getDecimalMetadata().getPrecision(), type.getDecimalMetadata().getScale());
                        }
                    case DATE:
                        {
                            DateWriter writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).date() : mapWriter.date(name);
                            switch(containsCorruptedDates) {
                                case META_SHOWS_CORRUPTION:
                                    return new DrillCorruptedDateConverter(writer);
                                case META_SHOWS_NO_CORRUPTION:
                                    return new DrillDateConverter(writer);
                                case META_UNCLEAR_TEST_VALUES:
                                    return new CorruptionDetectingDateConverter(writer);
                                default:
                                    throw new DrillRuntimeException(String.format("Issue setting up parquet reader for date type, " + "unrecognized date corruption status %s. See DRILL-4203 for more info.", containsCorruptedDates));
                            }
                        }
                    case TIME_MILLIS:
                        {
                            TimeWriter writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).time() : mapWriter.time(name);
                            return new DrillTimeConverter(writer);
                        }
                    default:
                        {
                            throw new UnsupportedOperationException("Unsupported type: " + type.getOriginalType());
                        }
                }
            }
        case INT64:
            {
                if (type.getOriginalType() == null) {
                    BigIntWriter writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).bigInt() : mapWriter.bigInt(name);
                    return new DrillBigIntConverter(writer);
                }
                switch(type.getOriginalType()) {
                    case UINT_64:
                    case INT_64:
                        {
                            BigIntWriter writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).bigInt() : mapWriter.bigInt(name);
                            return new DrillBigIntConverter(writer);
                        }
                    case DECIMAL:
                        {
                            ParquetReaderUtility.checkDecimalTypeEnabled(options);
                            Decimal18Writer writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).decimal18() : mapWriter.decimal18(name, type.getDecimalMetadata().getScale(), type.getDecimalMetadata().getPrecision());
                            return new DrillDecimal18Converter(writer, type.getDecimalMetadata().getPrecision(), type.getDecimalMetadata().getScale());
                        }
                    case TIMESTAMP_MILLIS:
                        {
                            TimeStampWriter writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).timeStamp() : mapWriter.timeStamp(name);
                            return new DrillTimeStampConverter(writer);
                        }
                    default:
                        {
                            throw new UnsupportedOperationException("Unsupported type " + type.getOriginalType());
                        }
                }
            }
        case INT96:
            {
                // TODO: replace null with TIMESTAMP_NANOS once parquet support such type annotation.
                if (type.getOriginalType() == null) {
                    if (options.getOption(ExecConstants.PARQUET_READER_INT96_AS_TIMESTAMP).bool_val) {
                        TimeStampWriter writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).timeStamp() : mapWriter.timeStamp(name);
                        return new DrillFixedBinaryToTimeStampConverter(writer);
                    } else {
                        VarBinaryWriter writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).varBinary() : mapWriter.varBinary(name);
                        return new DrillFixedBinaryToVarbinaryConverter(writer, ParquetColumnMetadata.getTypeLengthInBits(type.getPrimitiveTypeName()) / 8, mutator.getManagedBuffer());
                    }
                }
            }
        case FLOAT:
            {
                Float4Writer writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).float4() : mapWriter.float4(name);
                return new DrillFloat4Converter(writer);
            }
        case DOUBLE:
            {
                Float8Writer writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).float8() : mapWriter.float8(name);
                return new DrillFloat8Converter(writer);
            }
        case BOOLEAN:
            {
                BitWriter writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).bit() : mapWriter.bit(name);
                return new DrillBoolConverter(writer);
            }
        case BINARY:
            {
                if (type.getOriginalType() == null) {
                    VarBinaryWriter writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).varBinary() : mapWriter.varBinary(name);
                    return new DrillVarBinaryConverter(writer, mutator.getManagedBuffer());
                }
                switch(type.getOriginalType()) {
                    case UTF8:
                        {
                            VarCharWriter writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).varChar() : mapWriter.varChar(name);
                            return new DrillVarCharConverter(writer, mutator.getManagedBuffer());
                        }
                    case ENUM:
                        {
                            VarCharWriter writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).varChar() : mapWriter.varChar(name);
                            return new DrillVarCharConverter(writer, mutator.getManagedBuffer());
                        }
                    // TODO not sure if BINARY/DECIMAL is actually supported
                    case DECIMAL:
                        {
                            ParquetReaderUtility.checkDecimalTypeEnabled(options);
                            DecimalMetadata metadata = type.getDecimalMetadata();
                            if (metadata.getPrecision() <= 28) {
                                Decimal28SparseWriter writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).decimal28Sparse() : mapWriter.decimal28Sparse(name, metadata.getScale(), metadata.getPrecision());
                                return new DrillBinaryToDecimal28Converter(writer, metadata.getPrecision(), metadata.getScale(), mutator.getManagedBuffer());
                            } else {
                                Decimal38SparseWriter writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).decimal38Sparse() : mapWriter.decimal38Sparse(name, metadata.getScale(), metadata.getPrecision());
                                return new DrillBinaryToDecimal38Converter(writer, metadata.getPrecision(), metadata.getScale(), mutator.getManagedBuffer());
                            }
                        }
                    default:
                        {
                            throw new UnsupportedOperationException("Unsupported type " + type.getOriginalType());
                        }
                }
            }
        case FIXED_LEN_BYTE_ARRAY:
            if (type.getOriginalType() == OriginalType.DECIMAL) {
                ParquetReaderUtility.checkDecimalTypeEnabled(options);
                DecimalMetadata metadata = type.getDecimalMetadata();
                if (metadata.getPrecision() <= 28) {
                    Decimal28SparseWriter writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).decimal28Sparse() : mapWriter.decimal28Sparse(name, metadata.getScale(), metadata.getPrecision());
                    return new DrillBinaryToDecimal28Converter(writer, metadata.getPrecision(), metadata.getScale(), mutator.getManagedBuffer());
                } else {
                    Decimal38SparseWriter writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).decimal38Sparse() : mapWriter.decimal38Sparse(name, metadata.getScale(), metadata.getPrecision());
                    return new DrillBinaryToDecimal38Converter(writer, metadata.getPrecision(), metadata.getScale(), mutator.getManagedBuffer());
                }
            } else if (type.getOriginalType() == OriginalType.INTERVAL) {
                IntervalWriter writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).interval() : mapWriter.interval(name);
                return new DrillFixedLengthByteArrayToInterval(writer);
            } else {
                VarBinaryWriter writer = type.getRepetition() == Repetition.REPEATED ? mapWriter.list(name).varBinary() : mapWriter.varBinary(name);
                return new DrillFixedBinaryToVarbinaryConverter(writer, type.getTypeLength(), mutator.getManagedBuffer());
            }
        default:
            throw new UnsupportedOperationException("Unsupported type: " + type.getPrimitiveTypeName());
    }
}
Also used : BitWriter(org.apache.drill.exec.vector.complex.writer.BitWriter) Decimal9Writer(org.apache.drill.exec.vector.complex.writer.Decimal9Writer) Float4Writer(org.apache.drill.exec.vector.complex.writer.Float4Writer) TimeWriter(org.apache.drill.exec.vector.complex.writer.TimeWriter) VarBinaryWriter(org.apache.drill.exec.vector.complex.writer.VarBinaryWriter) TimeStampWriter(org.apache.drill.exec.vector.complex.writer.TimeStampWriter) DateWriter(org.apache.drill.exec.vector.complex.writer.DateWriter) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) IntervalWriter(org.apache.drill.exec.vector.complex.writer.IntervalWriter) Decimal18Writer(org.apache.drill.exec.vector.complex.writer.Decimal18Writer) BigIntWriter(org.apache.drill.exec.vector.complex.writer.BigIntWriter) IntWriter(org.apache.drill.exec.vector.complex.writer.IntWriter) VarCharWriter(org.apache.drill.exec.vector.complex.writer.VarCharWriter) Float8Writer(org.apache.drill.exec.vector.complex.writer.Float8Writer) BigIntWriter(org.apache.drill.exec.vector.complex.writer.BigIntWriter) DecimalMetadata(org.apache.parquet.schema.DecimalMetadata) Decimal28SparseWriter(org.apache.drill.exec.vector.complex.writer.Decimal28SparseWriter) Decimal38SparseWriter(org.apache.drill.exec.vector.complex.writer.Decimal38SparseWriter)

Example 2 with Float8Writer

use of org.apache.drill.exec.vector.complex.writer.Float8Writer in project drill by apache.

the class DrillParquetGroupConverter method getConverterForType.

protected PrimitiveConverter getConverterForType(String name, PrimitiveType type) {
    switch(type.getPrimitiveTypeName()) {
        case INT32:
            {
                if (type.getOriginalType() == null) {
                    return getIntConverter(name, type);
                }
                switch(type.getOriginalType()) {
                    case UINT_8:
                    case UINT_16:
                    case UINT_32:
                    case INT_8:
                    case INT_16:
                    case INT_32:
                        {
                            return getIntConverter(name, type);
                        }
                    case DECIMAL:
                        {
                            ParquetReaderUtility.checkDecimalTypeEnabled(options);
                            return getVarDecimalConverter(name, type);
                        }
                    case DATE:
                        {
                            DateWriter writer = type.isRepetition(Repetition.REPEATED) ? getWriter(name, (m, f) -> m.list(f).date(), l -> l.list().date()) : getWriter(name, (m, f) -> m.date(f), l -> l.date());
                            switch(containsCorruptedDates) {
                                case META_SHOWS_CORRUPTION:
                                    return new DrillCorruptedDateConverter(writer);
                                case META_SHOWS_NO_CORRUPTION:
                                    return new DrillDateConverter(writer);
                                case META_UNCLEAR_TEST_VALUES:
                                    return new CorruptionDetectingDateConverter(writer);
                                default:
                                    throw new DrillRuntimeException(String.format("Issue setting up parquet reader for date type, " + "unrecognized date corruption status %s. See DRILL-4203 for more info.", containsCorruptedDates));
                            }
                        }
                    case TIME_MILLIS:
                        {
                            TimeWriter writer = type.isRepetition(Repetition.REPEATED) ? getWriter(name, (m, f) -> m.list(f).time(), l -> l.list().time()) : getWriter(name, (m, f) -> m.time(f), l -> l.time());
                            return new DrillTimeConverter(writer);
                        }
                    default:
                        {
                            throw new UnsupportedOperationException("Unsupported type: " + type.getOriginalType());
                        }
                }
            }
        case INT64:
            {
                if (type.getOriginalType() == null) {
                    return getBigIntConverter(name, type);
                }
                switch(type.getOriginalType()) {
                    case UINT_64:
                    case INT_64:
                        return getBigIntConverter(name, type);
                    case TIMESTAMP_MICROS:
                        {
                            TimeStampWriter writer = getTimeStampWriter(name, type);
                            return new DrillTimeStampMicrosConverter(writer);
                        }
                    case TIME_MICROS:
                        {
                            TimeWriter writer = type.isRepetition(Repetition.REPEATED) ? getWriter(name, (m, f) -> m.list(f).time(), l -> l.list().time()) : getWriter(name, MapWriter::time, ListWriter::time);
                            return new DrillTimeMicrosConverter(writer);
                        }
                    case DECIMAL:
                        {
                            ParquetReaderUtility.checkDecimalTypeEnabled(options);
                            return getVarDecimalConverter(name, type);
                        }
                    case TIMESTAMP_MILLIS:
                        {
                            TimeStampWriter writer = getTimeStampWriter(name, type);
                            return new DrillTimeStampConverter(writer);
                        }
                    default:
                        {
                            throw new UnsupportedOperationException("Unsupported type " + type.getOriginalType());
                        }
                }
            }
        case INT96:
            {
                // TODO: replace null with TIMESTAMP_NANOS once parquet support such type annotation.
                if (type.getOriginalType() == null) {
                    if (options.getOption(ExecConstants.PARQUET_READER_INT96_AS_TIMESTAMP).bool_val) {
                        TimeStampWriter writer = getTimeStampWriter(name, type);
                        return new DrillFixedBinaryToTimeStampConverter(writer);
                    } else {
                        VarBinaryWriter writer = type.isRepetition(Repetition.REPEATED) ? getWriter(name, (m, f) -> m.list(f).varBinary(), l -> l.list().varBinary()) : getWriter(name, (m, f) -> m.varBinary(f), listWriter -> listWriter.varBinary());
                        return new DrillFixedBinaryToVarbinaryConverter(writer, ParquetColumnMetadata.getTypeLengthInBits(type.getPrimitiveTypeName()) / 8, mutator.getManagedBuffer());
                    }
                }
            }
        case FLOAT:
            {
                Float4Writer writer = type.isRepetition(Repetition.REPEATED) ? getWriter(name, (m, f) -> m.list(f).float4(), l -> l.list().float4()) : getWriter(name, (m, f) -> m.float4(f), l -> l.float4());
                return new DrillFloat4Converter(writer);
            }
        case DOUBLE:
            {
                Float8Writer writer = type.isRepetition(Repetition.REPEATED) ? getWriter(name, (m, f) -> m.list(f).float8(), l -> l.list().float8()) : getWriter(name, (m, f) -> m.float8(f), l -> l.float8());
                return new DrillFloat8Converter(writer);
            }
        case BOOLEAN:
            {
                BitWriter writer = type.isRepetition(Repetition.REPEATED) ? getWriter(name, (m, f) -> m.list(f).bit(), l -> l.list().bit()) : getWriter(name, (m, f) -> m.bit(f), l -> l.bit());
                return new DrillBoolConverter(writer);
            }
        case BINARY:
            {
                LogicalTypeAnnotation.LogicalTypeAnnotationVisitor<PrimitiveConverter> typeAnnotationVisitor = new LogicalTypeAnnotation.LogicalTypeAnnotationVisitor<PrimitiveConverter>() {

                    @Override
                    public Optional<PrimitiveConverter> visit(LogicalTypeAnnotation.DecimalLogicalTypeAnnotation decimalLogicalType) {
                        ParquetReaderUtility.checkDecimalTypeEnabled(options);
                        return Optional.of(getVarDecimalConverter(name, type));
                    }

                    @Override
                    public Optional<PrimitiveConverter> visit(LogicalTypeAnnotation.StringLogicalTypeAnnotation stringLogicalType) {
                        return Optional.of(getVarCharConverter(name, type));
                    }

                    @Override
                    public Optional<PrimitiveConverter> visit(LogicalTypeAnnotation.EnumLogicalTypeAnnotation stringLogicalType) {
                        return Optional.of(getVarCharConverter(name, type));
                    }
                };
                Supplier<PrimitiveConverter> converterSupplier = () -> {
                    VarBinaryWriter writer = type.isRepetition(Repetition.REPEATED) ? getWriter(name, (m, f) -> m.list(f).varBinary(), l -> l.list().varBinary()) : getWriter(name, MapWriter::varBinary, ListWriter::varBinary);
                    return new DrillVarBinaryConverter(writer, mutator.getManagedBuffer());
                };
                return Optional.ofNullable(type.getLogicalTypeAnnotation()).map(typeAnnotation -> typeAnnotation.accept(typeAnnotationVisitor)).flatMap(Function.identity()).orElseGet(converterSupplier);
            }
        case FIXED_LEN_BYTE_ARRAY:
            LogicalTypeAnnotation.LogicalTypeAnnotationVisitor<PrimitiveConverter> typeAnnotationVisitor = new LogicalTypeAnnotation.LogicalTypeAnnotationVisitor<PrimitiveConverter>() {

                @Override
                public Optional<PrimitiveConverter> visit(LogicalTypeAnnotation.DecimalLogicalTypeAnnotation decimalLogicalType) {
                    ParquetReaderUtility.checkDecimalTypeEnabled(options);
                    return Optional.of(getVarDecimalConverter(name, type));
                }

                @Override
                public Optional<PrimitiveConverter> visit(LogicalTypeAnnotation.IntervalLogicalTypeAnnotation intervalLogicalType) {
                    IntervalWriter writer = type.isRepetition(Repetition.REPEATED) ? getWriter(name, (m, f) -> m.list(f).interval(), l -> l.list().interval()) : getWriter(name, MapWriter::interval, ListWriter::interval);
                    return Optional.of(new DrillFixedLengthByteArrayToInterval(writer));
                }
            };
            Supplier<PrimitiveConverter> converterSupplier = () -> {
                VarBinaryWriter writer = type.isRepetition(Repetition.REPEATED) ? getWriter(name, (m, f) -> m.list(f).varBinary(), l -> l.list().varBinary()) : getWriter(name, MapWriter::varBinary, ListWriter::varBinary);
                return new DrillFixedBinaryToVarbinaryConverter(writer, type.getTypeLength(), mutator.getManagedBuffer());
            };
            return Optional.ofNullable(type.getLogicalTypeAnnotation()).map(typeAnnotation -> typeAnnotation.accept(typeAnnotationVisitor)).flatMap(Function.identity()).orElseGet(converterSupplier);
        default:
            throw new UnsupportedOperationException("Unsupported type: " + type.getPrimitiveTypeName());
    }
}
Also used : IntervalHolder(org.apache.drill.exec.expr.holders.IntervalHolder) PrimitiveType(org.apache.parquet.schema.PrimitiveType) VarDecimalHolder(org.apache.drill.exec.expr.holders.VarDecimalHolder) SingleMapWriter(org.apache.drill.exec.vector.complex.impl.SingleMapWriter) BiFunction(java.util.function.BiFunction) VarCharHolder(org.apache.drill.exec.expr.holders.VarCharHolder) ParquetReaderUtility(org.apache.drill.exec.store.parquet.ParquetReaderUtility) OutputMutator(org.apache.drill.exec.physical.impl.OutputMutator) VarCharWriter(org.apache.drill.exec.vector.complex.writer.VarCharWriter) PathSegment(org.apache.drill.common.expression.PathSegment) TimeStampWriter(org.apache.drill.exec.vector.complex.writer.TimeStampWriter) PrimitiveConverter(org.apache.parquet.io.api.PrimitiveConverter) DateHolder(org.apache.drill.exec.expr.holders.DateHolder) DrillBuf(io.netty.buffer.DrillBuf) BigIntHolder(org.apache.drill.exec.expr.holders.BigIntHolder) VarBinaryWriter(org.apache.drill.exec.vector.complex.writer.VarBinaryWriter) BigIntWriter(org.apache.drill.exec.vector.complex.writer.BigIntWriter) AbstractRepeatedMapWriter(org.apache.drill.exec.vector.complex.impl.AbstractRepeatedMapWriter) IntWriter(org.apache.drill.exec.vector.complex.writer.IntWriter) GroupType(org.apache.parquet.schema.GroupType) GroupConverter(org.apache.parquet.io.api.GroupConverter) VarDecimalWriter(org.apache.drill.exec.vector.complex.writer.VarDecimalWriter) Collection(java.util.Collection) SchemaPath(org.apache.drill.common.expression.SchemaPath) Float4Writer(org.apache.drill.exec.vector.complex.writer.Float4Writer) TimeWriter(org.apache.drill.exec.vector.complex.writer.TimeWriter) BaseWriter(org.apache.drill.exec.vector.complex.writer.BaseWriter) MapWriter(org.apache.drill.exec.vector.complex.writer.BaseWriter.MapWriter) Binary(org.apache.parquet.io.api.Binary) Longs(org.apache.drill.shaded.guava.com.google.common.primitives.Longs) List(java.util.List) DYNAMIC_STAR(org.apache.drill.common.expression.SchemaPath.DYNAMIC_STAR) Optional(java.util.Optional) Type(org.apache.parquet.schema.Type) ExecConstants(org.apache.drill.exec.ExecConstants) DateWriter(org.apache.drill.exec.vector.complex.writer.DateWriter) BitHolder(org.apache.drill.exec.expr.holders.BitHolder) OptionManager(org.apache.drill.exec.server.options.OptionManager) Ints(org.apache.drill.shaded.guava.com.google.common.primitives.Ints) BitWriter(org.apache.drill.exec.vector.complex.writer.BitWriter) Float8Writer(org.apache.drill.exec.vector.complex.writer.Float8Writer) Converter(org.apache.parquet.io.api.Converter) ListWriter(org.apache.drill.exec.vector.complex.writer.BaseWriter.ListWriter) Repetition(org.apache.parquet.schema.Type.Repetition) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) LogicalTypeAnnotation(org.apache.parquet.schema.LogicalTypeAnnotation) Function(java.util.function.Function) Supplier(java.util.function.Supplier) Float8Holder(org.apache.drill.exec.expr.holders.Float8Holder) VarBinaryHolder(org.apache.drill.exec.expr.holders.VarBinaryHolder) ArrayList(java.util.ArrayList) Float4Holder(org.apache.drill.exec.expr.holders.Float4Holder) NanoTimeUtils.getDateTimeValueFromBinary(org.apache.drill.exec.store.parquet.ParquetReaderUtility.NanoTimeUtils.getDateTimeValueFromBinary) TimeHolder(org.apache.drill.exec.expr.holders.TimeHolder) IntHolder(org.apache.drill.exec.expr.holders.IntHolder) DictWriter(org.apache.drill.exec.vector.complex.writer.BaseWriter.DictWriter) Iterator(java.util.Iterator) IntervalWriter(org.apache.drill.exec.vector.complex.writer.IntervalWriter) ParquetColumnMetadata(org.apache.drill.exec.store.parquet.columnreaders.ParquetColumnMetadata) Collections(java.util.Collections) TimeStampHolder(org.apache.drill.exec.expr.holders.TimeStampHolder) DateTimeConstants(org.joda.time.DateTimeConstants) BitWriter(org.apache.drill.exec.vector.complex.writer.BitWriter) SingleMapWriter(org.apache.drill.exec.vector.complex.impl.SingleMapWriter) AbstractRepeatedMapWriter(org.apache.drill.exec.vector.complex.impl.AbstractRepeatedMapWriter) MapWriter(org.apache.drill.exec.vector.complex.writer.BaseWriter.MapWriter) Float4Writer(org.apache.drill.exec.vector.complex.writer.Float4Writer) TimeWriter(org.apache.drill.exec.vector.complex.writer.TimeWriter) VarBinaryWriter(org.apache.drill.exec.vector.complex.writer.VarBinaryWriter) TimeStampWriter(org.apache.drill.exec.vector.complex.writer.TimeStampWriter) LogicalTypeAnnotation(org.apache.parquet.schema.LogicalTypeAnnotation) ListWriter(org.apache.drill.exec.vector.complex.writer.BaseWriter.ListWriter) DateWriter(org.apache.drill.exec.vector.complex.writer.DateWriter) Supplier(java.util.function.Supplier) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) IntervalWriter(org.apache.drill.exec.vector.complex.writer.IntervalWriter) Optional(java.util.Optional) Float8Writer(org.apache.drill.exec.vector.complex.writer.Float8Writer) PrimitiveConverter(org.apache.parquet.io.api.PrimitiveConverter)

Example 3 with Float8Writer

use of org.apache.drill.exec.vector.complex.writer.Float8Writer in project drill by axbaretto.

the class HttpdLogRecord method set.

/**
 * This method is referenced and called via reflection. This is added as a parsing target for the parser. It will get
 * called when the value of a log field is a Double data type.
 *
 * @param field name of field
 * @param value value of field
 */
@SuppressWarnings("unused")
public void set(final String field, final Double value) {
    if (value != null) {
        final Float8Writer w = doubles.get(field);
        if (w != null) {
            LOG.trace("Parsed field: {}, as double: {}", field, value);
            w.writeFloat8(value);
        } else {
            LOG.warn("No 'double' writer found for field: {}", field);
        }
    }
}
Also used : Float8Writer(org.apache.drill.exec.vector.complex.writer.Float8Writer)

Example 4 with Float8Writer

use of org.apache.drill.exec.vector.complex.writer.Float8Writer in project drill by axbaretto.

the class HttpdLogRecord method setWildcard.

/**
 * This method is referenced and called via reflection. When the parser processes a field like:
 * HTTP.URI:request.firstline.uri.query.* where star is an arbitrary field that the parser found this method will be
 * invoked. <br>
 *
 * @param field name of field
 * @param value value of field
 */
@SuppressWarnings("unused")
public void setWildcard(final String field, final Double value) {
    if (value != null) {
        final MapWriter mapWriter = getWildcardWriter(field);
        LOG.trace("Parsed wildcard field: {}, as double: {}", field, value);
        final Float8Writer w = mapWriter.float8(cleanExtensions.get(field));
        w.writeFloat8(value);
    }
}
Also used : MapWriter(org.apache.drill.exec.vector.complex.writer.BaseWriter.MapWriter) Float8Writer(org.apache.drill.exec.vector.complex.writer.Float8Writer)

Aggregations

Float8Writer (org.apache.drill.exec.vector.complex.writer.Float8Writer)4 DrillRuntimeException (org.apache.drill.common.exceptions.DrillRuntimeException)2 BigIntWriter (org.apache.drill.exec.vector.complex.writer.BigIntWriter)2 BitWriter (org.apache.drill.exec.vector.complex.writer.BitWriter)2 DateWriter (org.apache.drill.exec.vector.complex.writer.DateWriter)2 Float4Writer (org.apache.drill.exec.vector.complex.writer.Float4Writer)2 IntWriter (org.apache.drill.exec.vector.complex.writer.IntWriter)2 IntervalWriter (org.apache.drill.exec.vector.complex.writer.IntervalWriter)2 TimeStampWriter (org.apache.drill.exec.vector.complex.writer.TimeStampWriter)2 TimeWriter (org.apache.drill.exec.vector.complex.writer.TimeWriter)2 VarBinaryWriter (org.apache.drill.exec.vector.complex.writer.VarBinaryWriter)2 VarCharWriter (org.apache.drill.exec.vector.complex.writer.VarCharWriter)2 DrillBuf (io.netty.buffer.DrillBuf)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Optional (java.util.Optional)1 BiFunction (java.util.function.BiFunction)1