use of com.facebook.presto.parquet.batchreader.decoders.plain.TimestampPlainValuesDecoder 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));
}
Aggregations