Search in sources :

Example 1 with BooleanRLEValuesDecoder

use of com.facebook.presto.parquet.batchreader.decoders.rle.BooleanRLEValuesDecoder in project presto by prestodb.

the class Decoders method createValuesDecoder.

private static final ValuesDecoder createValuesDecoder(ColumnDescriptor columnDescriptor, Dictionary dictionary, int valueCount, ParquetEncoding encoding, byte[] buffer, int offset, int length) throws IOException {
    final PrimitiveTypeName type = columnDescriptor.getPrimitiveType().getPrimitiveTypeName();
    if (encoding == PLAIN) {
        switch(type) {
            case BOOLEAN:
                return new BooleanPlainValuesDecoder(buffer, offset, length);
            case INT32:
            case FLOAT:
                return new Int32PlainValuesDecoder(buffer, offset, length);
            case INT64:
                {
                    if (isTimeStampMicrosType(columnDescriptor)) {
                        return new Int64TimestampMicrosPlainValuesDecoder(buffer, offset, length);
                    }
                }
            case DOUBLE:
                return new Int64PlainValuesDecoder(buffer, offset, length);
            case INT96:
                return new TimestampPlainValuesDecoder(buffer, offset, length);
            case BINARY:
                return new BinaryPlainValuesDecoder(buffer, offset, length);
            case FIXED_LEN_BYTE_ARRAY:
            default:
                throw new PrestoException(PARQUET_UNSUPPORTED_COLUMN_TYPE, format("Column: %s, Encoding: %s", columnDescriptor, encoding));
        }
    }
    if (encoding == RLE && type == BOOLEAN) {
        ByteBuffer byteBuffer = ByteBuffer.wrap(buffer, offset, length);
        // skip past the length
        byteBuffer.getInt();
        return new BooleanRLEValuesDecoder(byteBuffer);
    }
    if (encoding == RLE_DICTIONARY || encoding == PLAIN_DICTIONARY) {
        InputStream inputStream = ByteBufferInputStream.wrap(ByteBuffer.wrap(buffer, offset, length));
        int bitWidth = readIntLittleEndianOnOneByte(inputStream);
        switch(type) {
            case INT32:
            case FLOAT:
                {
                    return new Int32RLEDictionaryValuesDecoder(bitWidth, inputStream, (IntegerDictionary) dictionary);
                }
            case INT64:
                {
                    if (isTimeStampMicrosType(columnDescriptor)) {
                        return new Int64TimestampMicrosRLEDictionaryValuesDecoder(bitWidth, inputStream, (LongDictionary) dictionary);
                    }
                }
            case DOUBLE:
                {
                    return new Int64RLEDictionaryValuesDecoder(bitWidth, inputStream, (LongDictionary) dictionary);
                }
            case INT96:
                {
                    return new TimestampRLEDictionaryValuesDecoder(bitWidth, inputStream, (TimestampDictionary) dictionary);
                }
            case BINARY:
                {
                    return new BinaryRLEDictionaryValuesDecoder(bitWidth, inputStream, (BinaryBatchDictionary) dictionary);
                }
            case FIXED_LEN_BYTE_ARRAY:
            default:
                throw new PrestoException(PARQUET_UNSUPPORTED_COLUMN_TYPE, format("Column: %s, Encoding: %s", columnDescriptor, encoding));
        }
    }
    if (encoding == DELTA_BINARY_PACKED) {
        ByteBufferInputStream inputStream = ByteBufferInputStream.wrap(ByteBuffer.wrap(buffer, offset, length));
        switch(type) {
            case INT32:
            case FLOAT:
                {
                    return new Int32DeltaBinaryPackedValuesDecoder(valueCount, inputStream);
                }
            case INT64:
                {
                    if (isTimeStampMicrosType(columnDescriptor)) {
                        return new Int64TimestampMicrosDeltaBinaryPackedValuesDecoder(valueCount, inputStream);
                    }
                }
            case DOUBLE:
                {
                    return new Int64DeltaBinaryPackedValuesDecoder(valueCount, inputStream);
                }
            default:
                throw new PrestoException(PARQUET_UNSUPPORTED_COLUMN_TYPE, format("Column: %s, Encoding: %s", columnDescriptor, encoding));
        }
    }
    if ((encoding == DELTA_BYTE_ARRAY || encoding == DELTA_LENGTH_BYTE_ARRAY) && type == PrimitiveTypeName.BINARY) {
        ByteBufferInputStream inputStream = ByteBufferInputStream.wrap(ByteBuffer.wrap(buffer, offset, length));
        return new BinaryDeltaValuesDecoder(encoding, valueCount, inputStream);
    }
    throw new PrestoException(PARQUET_UNSUPPORTED_ENCODING, format("Column: %s, Encoding: %s", columnDescriptor, encoding));
}
Also used : Int32PlainValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.plain.Int32PlainValuesDecoder) PrestoException(com.facebook.presto.spi.PrestoException) Int64TimestampMicrosDeltaBinaryPackedValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.delta.Int64TimestampMicrosDeltaBinaryPackedValuesDecoder) Int32RLEDictionaryValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.rle.Int32RLEDictionaryValuesDecoder) TimestampDictionary(com.facebook.presto.parquet.batchreader.dictionary.TimestampDictionary) BooleanRLEValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.rle.BooleanRLEValuesDecoder) BinaryPlainValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.plain.BinaryPlainValuesDecoder) Int64RLEDictionaryValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.rle.Int64RLEDictionaryValuesDecoder) TimestampPlainValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.plain.TimestampPlainValuesDecoder) BinaryDeltaValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.delta.BinaryDeltaValuesDecoder) TimestampRLEDictionaryValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.rle.TimestampRLEDictionaryValuesDecoder) LongDictionary(com.facebook.presto.parquet.dictionary.LongDictionary) BinaryRLEDictionaryValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.rle.BinaryRLEDictionaryValuesDecoder) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteBufferInputStream(org.apache.parquet.bytes.ByteBufferInputStream) InputStream(java.io.InputStream) ByteBufferInputStream(org.apache.parquet.bytes.ByteBufferInputStream) BooleanPlainValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.plain.BooleanPlainValuesDecoder) Int64PlainValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.plain.Int64PlainValuesDecoder) ByteBuffer(java.nio.ByteBuffer) Int64TimestampMicrosRLEDictionaryValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.rle.Int64TimestampMicrosRLEDictionaryValuesDecoder) PrimitiveTypeName(org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName) Int64DeltaBinaryPackedValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.delta.Int64DeltaBinaryPackedValuesDecoder) Int32DeltaBinaryPackedValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.delta.Int32DeltaBinaryPackedValuesDecoder) IntegerDictionary(com.facebook.presto.parquet.dictionary.IntegerDictionary) Int64TimestampMicrosPlainValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.plain.Int64TimestampMicrosPlainValuesDecoder) BinaryBatchDictionary(com.facebook.presto.parquet.batchreader.dictionary.BinaryBatchDictionary)

Aggregations

BinaryDeltaValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.delta.BinaryDeltaValuesDecoder)1 Int32DeltaBinaryPackedValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.delta.Int32DeltaBinaryPackedValuesDecoder)1 Int64DeltaBinaryPackedValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.delta.Int64DeltaBinaryPackedValuesDecoder)1 Int64TimestampMicrosDeltaBinaryPackedValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.delta.Int64TimestampMicrosDeltaBinaryPackedValuesDecoder)1 BinaryPlainValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.plain.BinaryPlainValuesDecoder)1 BooleanPlainValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.plain.BooleanPlainValuesDecoder)1 Int32PlainValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.plain.Int32PlainValuesDecoder)1 Int64PlainValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.plain.Int64PlainValuesDecoder)1 Int64TimestampMicrosPlainValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.plain.Int64TimestampMicrosPlainValuesDecoder)1 TimestampPlainValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.plain.TimestampPlainValuesDecoder)1 BinaryRLEDictionaryValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.rle.BinaryRLEDictionaryValuesDecoder)1 BooleanRLEValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.rle.BooleanRLEValuesDecoder)1 Int32RLEDictionaryValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.rle.Int32RLEDictionaryValuesDecoder)1 Int64RLEDictionaryValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.rle.Int64RLEDictionaryValuesDecoder)1 Int64TimestampMicrosRLEDictionaryValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.rle.Int64TimestampMicrosRLEDictionaryValuesDecoder)1 TimestampRLEDictionaryValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.rle.TimestampRLEDictionaryValuesDecoder)1 BinaryBatchDictionary (com.facebook.presto.parquet.batchreader.dictionary.BinaryBatchDictionary)1 TimestampDictionary (com.facebook.presto.parquet.batchreader.dictionary.TimestampDictionary)1 IntegerDictionary (com.facebook.presto.parquet.dictionary.IntegerDictionary)1 LongDictionary (com.facebook.presto.parquet.dictionary.LongDictionary)1