use of com.facebook.presto.memory.context.SimpleLocalMemoryContext in project presto by prestodb.
the class TestBroadcastOutputBuffer method createBroadcastBuffer.
private BroadcastOutputBuffer createBroadcastBuffer(OutputBuffers outputBuffers, DataSize dataSize) {
BroadcastOutputBuffer buffer = new BroadcastOutputBuffer(TASK_INSTANCE_ID, new StateMachine<>("bufferState", stateNotificationExecutor, OPEN, TERMINAL_BUFFER_STATES), dataSize, () -> new SimpleLocalMemoryContext(newSimpleAggregatedMemoryContext(), "test"), stateNotificationExecutor);
buffer.setOutputBuffers(outputBuffers);
buffer.registerLifespanCompletionCallback(ignore -> {
});
return buffer;
}
use of com.facebook.presto.memory.context.SimpleLocalMemoryContext in project presto by prestodb.
the class TestArbitraryOutputBuffer method createArbitraryBuffer.
private ArbitraryOutputBuffer createArbitraryBuffer(OutputBuffers buffers, DataSize dataSize) {
ArbitraryOutputBuffer buffer = new ArbitraryOutputBuffer(TASK_INSTANCE_ID, new StateMachine<>("bufferState", stateNotificationExecutor, OPEN, TERMINAL_BUFFER_STATES), dataSize, () -> new SimpleLocalMemoryContext(newSimpleAggregatedMemoryContext(), "test"), stateNotificationExecutor);
buffer.setOutputBuffers(buffers);
buffer.registerLifespanCompletionCallback(ignore -> {
});
return buffer;
}
use of com.facebook.presto.memory.context.SimpleLocalMemoryContext in project presto by prestodb.
the class TestPartitionedOutputBuffer method createPartitionedBuffer.
private PartitionedOutputBuffer createPartitionedBuffer(OutputBuffers buffers, DataSize dataSize) {
PartitionedOutputBuffer buffer = new PartitionedOutputBuffer(TASK_INSTANCE_ID, new StateMachine<>("bufferState", stateNotificationExecutor, OPEN, TERMINAL_BUFFER_STATES), buffers, dataSize, () -> new SimpleLocalMemoryContext(newSimpleAggregatedMemoryContext(), "test"), stateNotificationExecutor);
buffer.registerLifespanCompletionCallback(ignore -> {
});
return buffer;
}
use of com.facebook.presto.memory.context.SimpleLocalMemoryContext 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.memory.context.SimpleLocalMemoryContext in project presto by prestodb.
the class TestPartitionedOutputOperator method createPartitionedOutputOperator.
private static PartitionedOutputOperator createPartitionedOutputOperator(boolean shouldReplicate) {
PartitionFunction partitionFunction = new LocalPartitionGenerator(new InterpretedHashGenerator(ImmutableList.of(BIGINT), new int[] { 0 }), PARTITION_COUNT);
OutputPartitioning outputPartitioning;
if (shouldReplicate) {
outputPartitioning = new OutputPartitioning(partitionFunction, ImmutableList.of(0), ImmutableList.of(Optional.empty()), true, OptionalInt.of(0));
} else {
outputPartitioning = new OutputPartitioning(partitionFunction, ImmutableList.of(0), ImmutableList.of(Optional.empty(), Optional.empty()), false, OptionalInt.empty());
}
PagesSerdeFactory serdeFactory = new PagesSerdeFactory(new BlockEncodingManager(), false);
DriverContext driverContext = TestingTaskContext.builder(EXECUTOR, SCHEDULER, TEST_SESSION).setMemoryPoolSize(MAX_MEMORY).setQueryMaxTotalMemory(MAX_MEMORY).build().addPipelineContext(0, true, true, false).addDriverContext();
OutputBuffers buffers = createInitialEmptyOutputBuffers(PARTITIONED);
for (int partition = 0; partition < PARTITION_COUNT; partition++) {
buffers = buffers.withBuffer(new OutputBuffers.OutputBufferId(partition), partition);
}
PartitionedOutputBuffer buffer = new PartitionedOutputBuffer("task-instance-id", new StateMachine<>("bufferState", SCHEDULER, OPEN, TERMINAL_BUFFER_STATES), buffers.withNoMoreBufferIds(), new DataSize(Long.MAX_VALUE, BYTE), () -> new SimpleLocalMemoryContext(newSimpleAggregatedMemoryContext(), "test"), SCHEDULER);
buffer.registerLifespanCompletionCallback(ignore -> {
});
PartitionedOutputOperator.PartitionedOutputFactory operatorFactory;
if (shouldReplicate) {
operatorFactory = new PartitionedOutputOperator.PartitionedOutputFactory(buffer, PARTITION_MAX_MEMORY);
return (PartitionedOutputOperator) operatorFactory.createOutputOperator(0, new PlanNodeId("plan-node-0"), REPLICATION_TYPES, Function.identity(), Optional.of(outputPartitioning), serdeFactory).createOperator(driverContext);
} else {
operatorFactory = new PartitionedOutputOperator.PartitionedOutputFactory(buffer, PARTITION_MAX_MEMORY);
return (PartitionedOutputOperator) operatorFactory.createOutputOperator(0, new PlanNodeId("plan-node-0"), TYPES, Function.identity(), Optional.of(outputPartitioning), serdeFactory).createOperator(driverContext);
}
}
Aggregations