Search in sources :

Example 6 with BlockEncoding

use of io.prestosql.spi.block.BlockEncoding in project hetu-core by openlookeng.

the class KryoBlockEncodingSerde method writeBlock.

/**
 * Write a blockEncoding to the output.
 *
 * @param outputStream
 * @param block
 */
@Override
public void writeBlock(OutputStream outputStream, Block block) {
    if (!(outputStream instanceof Output)) {
        throw new PrestoException(StandardErrorCode.GENERIC_INTERNAL_ERROR, "This interface should not be called in this flow");
    }
    Output output = (Output) outputStream;
    String encodingName = block.getEncodingName();
    BlockEncoding blockEncoding = functionAndTypeManager.getBlockEncoding(encodingName);
    Serializer<Block<?>> serializer = getSerializerFromBlockEncoding(blockEncoding);
    // write the name to the output
    writeLengthPrefixedString(output, encodingName);
    if (serializer == null) {
        blockEncoding.writeBlock(this, outputStream, block);
    } else {
        // write the block to the output
        serializer.write(kryo, output, block);
    }
}
Also used : Output(com.esotericsoftware.kryo.io.Output) Block(io.prestosql.spi.block.Block) PrestoException(io.prestosql.spi.PrestoException) AbstractBlockEncoding(io.prestosql.spi.block.AbstractBlockEncoding) BlockEncoding(io.prestosql.spi.block.BlockEncoding)

Example 7 with BlockEncoding

use of io.prestosql.spi.block.BlockEncoding in project hetu-core by openlookeng.

the class InternalBlockEncodingSerde method readBlock.

@Override
public Block readBlock(SliceInput input) {
    // read the encoding name
    String encodingName = readLengthPrefixedString(input);
    // look up the encoding factory
    BlockEncoding blockEncoding = functionAndTypeManager.getBlockEncoding(encodingName);
    // load read the encoding factory from the output stream
    return blockEncoding.readBlock(this, input);
}
Also used : BlockEncoding(io.prestosql.spi.block.BlockEncoding)

Example 8 with BlockEncoding

use of io.prestosql.spi.block.BlockEncoding in project hetu-core by openlookeng.

the class InternalBlockEncodingSerde method writeBlock.

@Override
public void writeBlock(SliceOutput output, Block block) {
    Block blockToWrite = block;
    while (true) {
        // get the encoding name
        String encodingName = blockToWrite.getEncodingName();
        // look up the BlockEncoding
        BlockEncoding blockEncoding = functionAndTypeManager.getBlockEncoding(encodingName);
        // see if a replacement block should be written instead
        Optional<Block> replacementBlock = blockEncoding.replacementBlockForWrite(blockToWrite);
        if (replacementBlock.isPresent()) {
            blockToWrite = replacementBlock.get();
            continue;
        }
        // write the name to the output
        writeLengthPrefixedString(output, encodingName);
        // write the block to the output
        blockEncoding.writeBlock(this, output, blockToWrite);
        break;
    }
}
Also used : Block(io.prestosql.spi.block.Block) BlockEncoding(io.prestosql.spi.block.BlockEncoding)

Example 9 with BlockEncoding

use of io.prestosql.spi.block.BlockEncoding in project hetu-core by openlookeng.

the class ExternalBlockEncodingSerde method writeBlock.

@Override
public void writeBlock(SliceOutput output, Block inputBlock) {
    Block block = inputBlock;
    while (true) {
        // get the encoding name
        String encodingName = block.getEncodingName();
        // look up the BlockEncoding
        BlockEncoding blockEncoding = blockEncodings.get(encodingName);
        // see if a replacement block should be written instead
        Optional<Block> replacementBlock = blockEncoding.replacementBlockForWrite(block);
        if (replacementBlock.isPresent()) {
            block = replacementBlock.get();
            continue;
        }
        // write the name to the output
        writeLengthPrefixedString(output, encodingName);
        // write the block to the output
        blockEncoding.writeBlock(this, output, block);
        break;
    }
}
Also used : Block(io.prestosql.spi.block.Block) IntArrayBlockEncoding(io.prestosql.spi.block.IntArrayBlockEncoding) ByteArrayBlockEncoding(io.prestosql.spi.block.ByteArrayBlockEncoding) SingleMapBlockEncoding(io.prestosql.spi.block.SingleMapBlockEncoding) LongArrayBlockEncoding(io.prestosql.spi.block.LongArrayBlockEncoding) BlockEncoding(io.prestosql.spi.block.BlockEncoding) DictionaryBlockEncoding(io.prestosql.spi.block.DictionaryBlockEncoding) RowBlockEncoding(io.prestosql.spi.block.RowBlockEncoding) ArrayBlockEncoding(io.prestosql.spi.block.ArrayBlockEncoding) SingleRowBlockEncoding(io.prestosql.spi.block.SingleRowBlockEncoding) RunLengthBlockEncoding(io.prestosql.spi.block.RunLengthBlockEncoding) VariableWidthBlockEncoding(io.prestosql.spi.block.VariableWidthBlockEncoding) Int128ArrayBlockEncoding(io.prestosql.spi.block.Int128ArrayBlockEncoding) MapBlockEncoding(io.prestosql.spi.block.MapBlockEncoding) LazyBlockEncoding(io.prestosql.spi.block.LazyBlockEncoding) ShortArrayBlockEncoding(io.prestosql.spi.block.ShortArrayBlockEncoding)

Aggregations

BlockEncoding (io.prestosql.spi.block.BlockEncoding)9 ArrayBlockEncoding (io.prestosql.spi.block.ArrayBlockEncoding)4 Block (io.prestosql.spi.block.Block)4 ByteArrayBlockEncoding (io.prestosql.spi.block.ByteArrayBlockEncoding)4 DictionaryBlockEncoding (io.prestosql.spi.block.DictionaryBlockEncoding)4 Int128ArrayBlockEncoding (io.prestosql.spi.block.Int128ArrayBlockEncoding)4 IntArrayBlockEncoding (io.prestosql.spi.block.IntArrayBlockEncoding)4 LazyBlockEncoding (io.prestosql.spi.block.LazyBlockEncoding)4 LongArrayBlockEncoding (io.prestosql.spi.block.LongArrayBlockEncoding)4 MapBlockEncoding (io.prestosql.spi.block.MapBlockEncoding)4 RowBlockEncoding (io.prestosql.spi.block.RowBlockEncoding)4 RunLengthBlockEncoding (io.prestosql.spi.block.RunLengthBlockEncoding)4 ShortArrayBlockEncoding (io.prestosql.spi.block.ShortArrayBlockEncoding)4 SingleMapBlockEncoding (io.prestosql.spi.block.SingleMapBlockEncoding)4 SingleRowBlockEncoding (io.prestosql.spi.block.SingleRowBlockEncoding)4 VariableWidthBlockEncoding (io.prestosql.spi.block.VariableWidthBlockEncoding)4 PrestoException (io.prestosql.spi.PrestoException)2 AbstractBlockEncoding (io.prestosql.spi.block.AbstractBlockEncoding)2 Input (com.esotericsoftware.kryo.io.Input)1 Output (com.esotericsoftware.kryo.io.Output)1