use of com.facebook.presto.spi.page.PagesSerde in project presto by prestodb.
the class TestPagesSerde method serializedSize.
private static int serializedSize(List<? extends Type> types, Page expectedPage) {
PagesSerde serde = new TestingPagesSerdeFactory().createPagesSerde();
DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024);
writePages(serde, sliceOutput, expectedPage);
Slice slice = sliceOutput.slice();
Iterator<Page> pageIterator = readPages(serde, slice.getInput());
if (pageIterator.hasNext()) {
assertPageEquals(types, pageIterator.next(), expectedPage);
} else {
assertEquals(expectedPage.getPositionCount(), 0);
}
assertFalse(pageIterator.hasNext());
return slice.length();
}
use of com.facebook.presto.spi.page.PagesSerde in project presto by prestodb.
the class FileSingleStreamSpillerFactory method create.
@Override
public SingleStreamSpiller create(List<Type> types, SpillContext spillContext, LocalMemoryContext memoryContext) {
Optional<SpillCipher> spillCipher = Optional.empty();
if (spillEncryptionEnabled) {
spillCipher = Optional.of(new AesSpillCipher());
}
PagesSerde serde = serdeFactory.createPagesSerdeForSpill(spillCipher);
return new FileSingleStreamSpiller(serde, executor, getNextSpillPath(), spillerStats, spillContext, memoryContext, spillCipher);
}
use of com.facebook.presto.spi.page.PagesSerde in project presto by prestodb.
the class TempStorageSingleStreamSpillerFactory method create.
@Override
public SingleStreamSpiller create(List<Type> types, SpillContext spillContext, LocalMemoryContext memoryContext) {
Optional<SpillCipher> spillCipher = Optional.empty();
if (spillEncryptionEnabled) {
spillCipher = Optional.of(new AesSpillCipher());
}
PagesSerde serde = serdeFactory.createPagesSerdeForSpill(spillCipher);
return new TempStorageSingleStreamSpiller(tempStorageManager.getTempStorage(tempStorageName), serde, executor, spillerStats, spillContext, memoryContext, spillCipher);
}
use of com.facebook.presto.spi.page.PagesSerde in project presto by prestodb.
the class ThriftSqlFunctionExecutor method toSqlFunctionResult.
private SqlFunctionResult toSqlFunctionResult(ThriftUdfResult result, Type returnType) {
ThriftUdfPage page = result.getResult();
switch(page.getPageFormat()) {
case PRESTO_THRIFT:
return new SqlFunctionResult(getOnlyElement(page.getThriftPage().getThriftBlocks()).toBlock(returnType), result.getUdfStats().getTotalCpuTimeMs());
case PRESTO_SERIALIZED:
checkState(blockEncodingSerde != null, "blockEncodingSerde not set");
PagesSerde pagesSerde = new PagesSerde(blockEncodingSerde, Optional.empty(), Optional.empty(), Optional.empty());
return new SqlFunctionResult(pagesSerde.deserialize(page.getPrestoPage().toSerializedPage()).getBlock(0), result.getUdfStats().getTotalCpuTimeMs());
default:
throw new IllegalArgumentException(format("Unknown page format: %s", page.getPageFormat()));
}
}
use of com.facebook.presto.spi.page.PagesSerde in project presto by prestodb.
the class ThriftSqlFunctionExecutor method buildThriftPage.
private ThriftUdfPage buildThriftPage(RemoteScalarFunctionImplementation functionImplementation, Page input, List<Integer> channels, List<Type> argumentTypes) {
ThriftUdfPageFormat pageFormat = executionConfigs.get(functionImplementation.getLanguage()).getThriftPageFormat();
Block[] blocks = new Block[channels.size()];
for (int i = 0; i < channels.size(); i++) {
blocks[i] = input.getBlock(channels.get(i));
}
switch(pageFormat) {
case PRESTO_THRIFT:
ImmutableList.Builder<PrestoThriftBlock> thriftBlocks = ImmutableList.builder();
for (int i = 0; i < blocks.length; i++) {
thriftBlocks.add(PrestoThriftBlock.fromBlock(blocks[i], argumentTypes.get(i)));
}
return thriftPage(new PrestoThriftPage(thriftBlocks.build(), input.getPositionCount()));
case PRESTO_SERIALIZED:
checkState(blockEncodingSerde != null, "blockEncodingSerde not set");
PagesSerde pagesSerde = new PagesSerde(blockEncodingSerde, Optional.empty(), Optional.empty(), Optional.empty());
return prestoPage(pagesSerde.serialize(wrapBlocksWithoutCopy(input.getPositionCount(), blocks)));
default:
throw new IllegalArgumentException(format("Unknown page format: %s", pageFormat));
}
}
Aggregations