Search in sources :

Example 21 with SliceOutput

use of io.airlift.slice.SliceOutput in project presto by prestodb.

the class LongDecimalWithOverflowAndLongStateSerializer method serialize.

@Override
public void serialize(LongDecimalWithOverflowAndLongState state, BlockBuilder out) {
    if (state.getLongDecimal() == null) {
        out.appendNull();
    } else {
        Slice slice = Slices.allocate(Long.BYTES + Long.BYTES + UnscaledDecimal128Arithmetic.UNSCALED_DECIMAL_128_SLICE_LENGTH);
        SliceOutput output = slice.getOutput();
        output.writeLong(state.getLong());
        output.writeLong(state.getOverflow());
        output.writeBytes(state.getLongDecimal());
        VARBINARY.writeSlice(out, slice);
    }
}
Also used : SliceOutput(io.airlift.slice.SliceOutput) Slice(io.airlift.slice.Slice)

Aggregations

SliceOutput (io.airlift.slice.SliceOutput)21 DynamicSliceOutput (io.airlift.slice.DynamicSliceOutput)11 Slice (io.airlift.slice.Slice)9 Test (org.testng.annotations.Test)3 Block (com.facebook.presto.spi.block.Block)2 LiteralParameters (com.facebook.presto.spi.function.LiteralParameters)2 ScalarFunction (com.facebook.presto.spi.function.ScalarFunction)2 SqlType (com.facebook.presto.spi.function.SqlType)2 BlockSerdeUtil.writeBlock (com.facebook.presto.block.BlockSerdeUtil.writeBlock)1 Signature (com.facebook.presto.metadata.Signature)1 ColumnData (com.facebook.presto.rcfile.ColumnData)1 PrestoException (com.facebook.presto.spi.PrestoException)1 Description (com.facebook.presto.spi.function.Description)1 TypeSignature.parseTypeSignature (com.facebook.presto.spi.type.TypeSignature.parseTypeSignature)1 VarcharType (com.facebook.presto.spi.type.VarcharType)1 ArithmeticUnaryExpression (com.facebook.presto.sql.tree.ArithmeticUnaryExpression)1 BooleanLiteral (com.facebook.presto.sql.tree.BooleanLiteral)1 Cast (com.facebook.presto.sql.tree.Cast)1 DoubleLiteral (com.facebook.presto.sql.tree.DoubleLiteral)1 Expression (com.facebook.presto.sql.tree.Expression)1