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