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);
}
}
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);
}
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;
}
}
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;
}
}
Aggregations