Search in sources :

Example 1 with Binary

use of parquet.io.api.Binary in project presto by prestodb.

the class ParquetTimestampColumnReader method readValue.

@Override
protected void readValue(BlockBuilder blockBuilder, Type type) {
    if (definitionLevel == columnDescriptor.getMaxDefinitionLevel()) {
        Binary binary = valuesReader.readBytes();
        type.writeLong(blockBuilder, getTimestampMillis(binary));
    } else {
        blockBuilder.appendNull();
    }
}
Also used : Binary(parquet.io.api.Binary)

Example 2 with Binary

use of parquet.io.api.Binary in project presto by prestodb.

the class ParquetLongDecimalColumnReader method readValue.

@Override
protected void readValue(BlockBuilder blockBuilder, Type type) {
    if (definitionLevel == columnDescriptor.getMaxDefinitionLevel()) {
        Binary value = valuesReader.readBytes();
        type.writeSlice(blockBuilder, Decimals.encodeUnscaledValue(new BigInteger(value.getBytes())));
    } else {
        blockBuilder.appendNull();
    }
}
Also used : BigInteger(java.math.BigInteger) Binary(parquet.io.api.Binary)

Example 3 with Binary

use of parquet.io.api.Binary in project presto by prestodb.

the class TestParquetTimestampUtils method assertTimestampCorrect.

private static void assertTimestampCorrect(String timestampString) {
    Timestamp timestamp = Timestamp.valueOf(timestampString);
    Binary timestampBytes = NanoTimeUtils.getNanoTime(timestamp, false).toBinary();
    long decodedTimestampMillis = getTimestampMillis(timestampBytes);
    assertEquals(decodedTimestampMillis, timestamp.getTime());
}
Also used : Binary(parquet.io.api.Binary) Timestamp(java.sql.Timestamp)

Example 4 with Binary

use of parquet.io.api.Binary in project presto by prestodb.

the class ParquetBinaryColumnReader method readValue.

@Override
protected void readValue(BlockBuilder blockBuilder, Type type) {
    if (definitionLevel == columnDescriptor.getMaxDefinitionLevel()) {
        Binary binary = valuesReader.readBytes();
        Slice value;
        if (binary.length() == 0) {
            value = EMPTY_SLICE;
        } else {
            value = wrappedBuffer(binary.getBytes());
        }
        if (isVarcharType(type)) {
            value = truncateToLength(value, type);
        }
        if (isCharType(type)) {
            value = trimSpacesAndTruncateToLength(value, type);
        }
        type.writeSlice(blockBuilder, value);
    } else {
        blockBuilder.appendNull();
    }
}
Also used : Slice(io.airlift.slice.Slice) Binary(parquet.io.api.Binary)

Aggregations

Binary (parquet.io.api.Binary)4 Slice (io.airlift.slice.Slice)1 BigInteger (java.math.BigInteger)1 Timestamp (java.sql.Timestamp)1