Search in sources :

Example 1 with SpillCipher

use of com.facebook.presto.spi.spiller.SpillCipher 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);
}
Also used : PagesSerde(com.facebook.presto.spi.page.PagesSerde) SpillCipher(com.facebook.presto.spi.spiller.SpillCipher)

Example 2 with SpillCipher

use of com.facebook.presto.spi.spiller.SpillCipher 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);
}
Also used : PagesSerde(com.facebook.presto.spi.page.PagesSerde) SpillCipher(com.facebook.presto.spi.spiller.SpillCipher)

Example 3 with SpillCipher

use of com.facebook.presto.spi.spiller.SpillCipher in project presto by prestodb.

the class TestSpillCipherPagesSerde method test.

@Test
public void test() {
    SpillCipher cipher = new AesSpillCipher();
    PagesSerde serde = new TestingPagesSerdeFactory().createPagesSerdeForSpill(Optional.of(cipher));
    List<Type> types = ImmutableList.of(VARCHAR);
    Page emptyPage = new Page(VARCHAR.createBlockBuilder(null, 0).build());
    assertPageEquals(types, serde.deserialize(serde.serialize(emptyPage)), emptyPage);
    BlockBuilder blockBuilder = VARCHAR.createBlockBuilder(null, 2);
    VARCHAR.writeString(blockBuilder, "hello");
    VARCHAR.writeString(blockBuilder, "world");
    Page helloWorldPage = new Page(blockBuilder.build());
    SerializedPage serialized = serde.serialize(helloWorldPage);
    assertPageEquals(types, serde.deserialize(serialized), helloWorldPage);
    assertTrue(ENCRYPTED.isSet(serialized.getPageCodecMarkers()), "page should be encrypted");
    cipher.destroy();
    assertFailure(() -> serde.serialize(helloWorldPage), "Spill cipher already destroyed");
    assertFailure(() -> serde.deserialize(serialized), "Spill cipher already destroyed");
}
Also used : Type(com.facebook.presto.common.type.Type) PagesSerde(com.facebook.presto.spi.page.PagesSerde) TestingPagesSerdeFactory(com.facebook.presto.execution.buffer.TestingPagesSerdeFactory) Page(com.facebook.presto.common.Page) SerializedPage(com.facebook.presto.spi.page.SerializedPage) SerializedPage(com.facebook.presto.spi.page.SerializedPage) SpillCipher(com.facebook.presto.spi.spiller.SpillCipher) BlockBuilder(com.facebook.presto.common.block.BlockBuilder) Test(org.testng.annotations.Test)

Aggregations

PagesSerde (com.facebook.presto.spi.page.PagesSerde)3 SpillCipher (com.facebook.presto.spi.spiller.SpillCipher)3 Page (com.facebook.presto.common.Page)1 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)1 Type (com.facebook.presto.common.type.Type)1 TestingPagesSerdeFactory (com.facebook.presto.execution.buffer.TestingPagesSerdeFactory)1 SerializedPage (com.facebook.presto.spi.page.SerializedPage)1 Test (org.testng.annotations.Test)1