use of com.facebook.presto.common.block.BlockEncodingSerde in project presto by prestodb.
the class TestFileSingleStreamSpillerFactory method testDistributesSpillOverPaths.
@Test
public void testDistributesSpillOverPaths() throws Exception {
List<Type> types = ImmutableList.of(BIGINT);
BlockEncodingSerde blockEncodingSerde = new BlockEncodingManager();
List<Path> spillPaths = ImmutableList.of(spillPath1.toPath(), spillPath2.toPath());
FileSingleStreamSpillerFactory spillerFactory = new FileSingleStreamSpillerFactory(// executor won't be closed, because we don't call destroy() on the spiller factory
executor, blockEncodingSerde, new SpillerStats(), spillPaths, 1.0, false, false);
assertEquals(listFiles(spillPath1.toPath()).size(), 0);
assertEquals(listFiles(spillPath2.toPath()).size(), 0);
Page page = buildPage();
List<SingleStreamSpiller> spillers = new ArrayList<>();
for (int i = 0; i < 10; ++i) {
SingleStreamSpiller singleStreamSpiller = spillerFactory.create(types, new TestingSpillContext(), newSimpleAggregatedMemoryContext().newLocalMemoryContext("test"));
getUnchecked(singleStreamSpiller.spill(page));
spillers.add(singleStreamSpiller);
}
assertEquals(listFiles(spillPath1.toPath()).size(), 5);
assertEquals(listFiles(spillPath2.toPath()).size(), 5);
spillers.forEach(SingleStreamSpiller::close);
assertEquals(listFiles(spillPath1.toPath()).size(), 0);
assertEquals(listFiles(spillPath2.toPath()).size(), 0);
}
use of com.facebook.presto.common.block.BlockEncodingSerde in project presto by prestodb.
the class TestFileSingleStreamSpillerFactory method throwsIfNoDiskSpace.
@Test(expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = "No free space available for spill")
public void throwsIfNoDiskSpace() {
List<Type> types = ImmutableList.of(BIGINT);
BlockEncodingSerde blockEncodingSerde = new BlockEncodingManager();
List<Path> spillPaths = ImmutableList.of(spillPath1.toPath(), spillPath2.toPath());
FileSingleStreamSpillerFactory spillerFactory = new FileSingleStreamSpillerFactory(// executor won't be closed, because we don't call destroy() on the spiller factory
executor, blockEncodingSerde, new SpillerStats(), spillPaths, 0.0, false, false);
spillerFactory.create(types, new TestingSpillContext(), newSimpleAggregatedMemoryContext().newLocalMemoryContext("test"));
}
use of com.facebook.presto.common.block.BlockEncodingSerde in project presto by prestodb.
the class LocalQueryProvider method getQuery.
public Query getQuery(QueryId queryId, String slug) {
Query query = queries.get(queryId);
if (query != null) {
if (!query.isSlugValid(slug)) {
throw notFound("Query not found");
}
return query;
}
// this is the first time the query has been accessed on this coordinator
Session session;
try {
if (!queryManager.isQuerySlugValid(queryId, slug)) {
throw notFound("Query not found");
}
session = queryManager.getQuerySession(queryId);
} catch (NoSuchElementException e) {
throw notFound("Query not found");
}
query = queries.computeIfAbsent(queryId, id -> {
ExchangeClient exchangeClient = exchangeClientSupplier.get(new SimpleLocalMemoryContext(newSimpleAggregatedMemoryContext(), LocalQueryProvider.class.getSimpleName()));
return Query.create(session, slug, queryManager, transactionManager, exchangeClient, responseExecutor, timeoutExecutor, blockEncodingSerde, retryCircuitBreaker);
});
return query;
}
use of com.facebook.presto.common.block.BlockEncodingSerde in project presto by prestodb.
the class TestFileSingleStreamSpillerFactory method testCleanupOldSpillFiles.
@Test
public void testCleanupOldSpillFiles() throws Exception {
BlockEncodingSerde blockEncodingSerde = new BlockEncodingManager();
List<Path> spillPaths = ImmutableList.of(spillPath1.toPath(), spillPath2.toPath());
spillPath1.mkdirs();
spillPath2.mkdirs();
java.nio.file.Files.createTempFile(spillPath1.toPath(), SPILL_FILE_PREFIX, SPILL_FILE_SUFFIX);
java.nio.file.Files.createTempFile(spillPath1.toPath(), SPILL_FILE_PREFIX, SPILL_FILE_SUFFIX);
java.nio.file.Files.createTempFile(spillPath1.toPath(), SPILL_FILE_PREFIX, "blah");
java.nio.file.Files.createTempFile(spillPath2.toPath(), SPILL_FILE_PREFIX, SPILL_FILE_SUFFIX);
java.nio.file.Files.createTempFile(spillPath2.toPath(), "blah", SPILL_FILE_SUFFIX);
java.nio.file.Files.createTempFile(spillPath2.toPath(), "blah", "blah");
assertEquals(listFiles(spillPath1.toPath()).size(), 3);
assertEquals(listFiles(spillPath2.toPath()).size(), 3);
FileSingleStreamSpillerFactory spillerFactory = new FileSingleStreamSpillerFactory(// executor won't be closed, because we don't call destroy() on the spiller factory
executor, blockEncodingSerde, new SpillerStats(), spillPaths, 1.0, false, false);
spillerFactory.cleanupOldSpillFiles();
assertEquals(listFiles(spillPath1.toPath()).size(), 1);
assertEquals(listFiles(spillPath2.toPath()).size(), 2);
}
Aggregations