Search in sources :

Example 1 with SimpleLocalMemoryContext

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;
}
Also used : SimpleLocalMemoryContext(com.facebook.presto.memory.context.SimpleLocalMemoryContext)

Example 2 with SimpleLocalMemoryContext

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;
}
Also used : SimpleLocalMemoryContext(com.facebook.presto.memory.context.SimpleLocalMemoryContext)

Example 3 with SimpleLocalMemoryContext

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;
}
Also used : SimpleLocalMemoryContext(com.facebook.presto.memory.context.SimpleLocalMemoryContext)

Example 4 with SimpleLocalMemoryContext

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;
}
Also used : Logger(com.facebook.airlift.log.Logger) QueryManager(com.facebook.presto.execution.QueryManager) BlockEncodingSerde(com.facebook.presto.common.block.BlockEncodingSerde) ConcurrentMap(java.util.concurrent.ConcurrentMap) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) Executors.newSingleThreadScheduledExecutor(java.util.concurrent.Executors.newSingleThreadScheduledExecutor) BoundedExecutor(com.facebook.airlift.concurrent.BoundedExecutor) SimpleLocalMemoryContext(com.facebook.presto.memory.context.SimpleLocalMemoryContext) Objects.requireNonNull(java.util.Objects.requireNonNull) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) NoSuchElementException(java.util.NoSuchElementException) AggregatedMemoryContext.newSimpleAggregatedMemoryContext(com.facebook.presto.memory.context.AggregatedMemoryContext.newSimpleAggregatedMemoryContext) TransactionManager(com.facebook.presto.transaction.TransactionManager) Status(javax.ws.rs.core.Response.Status) Threads.threadsNamed(com.facebook.airlift.concurrent.Threads.threadsNamed) Session(com.facebook.presto.Session) ExchangeClient(com.facebook.presto.operator.ExchangeClient) ExchangeClientSupplier(com.facebook.presto.operator.ExchangeClientSupplier) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) TEXT_PLAIN_TYPE(javax.ws.rs.core.MediaType.TEXT_PLAIN_TYPE) Response(javax.ws.rs.core.Response) QueryId(com.facebook.presto.spi.QueryId) PostConstruct(javax.annotation.PostConstruct) Entry(java.util.Map.Entry) ForStatementResource(com.facebook.presto.server.ForStatementResource) WebApplicationException(javax.ws.rs.WebApplicationException) ExchangeClient(com.facebook.presto.operator.ExchangeClient) SimpleLocalMemoryContext(com.facebook.presto.memory.context.SimpleLocalMemoryContext) NoSuchElementException(java.util.NoSuchElementException) Session(com.facebook.presto.Session)

Example 5 with SimpleLocalMemoryContext

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);
    }
}
Also used : PartitionedOutputBuffer(com.facebook.presto.execution.buffer.PartitionedOutputBuffer) SimpleLocalMemoryContext(com.facebook.presto.memory.context.SimpleLocalMemoryContext) PartitionedOutputOperator(com.facebook.presto.operator.repartition.PartitionedOutputOperator) LocalPartitionGenerator(com.facebook.presto.operator.exchange.LocalPartitionGenerator) PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) PagesSerdeFactory(com.facebook.presto.execution.buffer.PagesSerdeFactory) OutputBuffers.createInitialEmptyOutputBuffers(com.facebook.presto.execution.buffer.OutputBuffers.createInitialEmptyOutputBuffers) OutputBuffers(com.facebook.presto.execution.buffer.OutputBuffers) BlockEncodingManager(com.facebook.presto.common.block.BlockEncodingManager) DataSize(io.airlift.units.DataSize) OutputPartitioning(com.facebook.presto.sql.planner.OutputPartitioning)

Aggregations

SimpleLocalMemoryContext (com.facebook.presto.memory.context.SimpleLocalMemoryContext)5 BoundedExecutor (com.facebook.airlift.concurrent.BoundedExecutor)1 Threads.threadsNamed (com.facebook.airlift.concurrent.Threads.threadsNamed)1 Logger (com.facebook.airlift.log.Logger)1 Session (com.facebook.presto.Session)1 BlockEncodingManager (com.facebook.presto.common.block.BlockEncodingManager)1 BlockEncodingSerde (com.facebook.presto.common.block.BlockEncodingSerde)1 QueryManager (com.facebook.presto.execution.QueryManager)1 OutputBuffers (com.facebook.presto.execution.buffer.OutputBuffers)1 OutputBuffers.createInitialEmptyOutputBuffers (com.facebook.presto.execution.buffer.OutputBuffers.createInitialEmptyOutputBuffers)1 PagesSerdeFactory (com.facebook.presto.execution.buffer.PagesSerdeFactory)1 PartitionedOutputBuffer (com.facebook.presto.execution.buffer.PartitionedOutputBuffer)1 AggregatedMemoryContext.newSimpleAggregatedMemoryContext (com.facebook.presto.memory.context.AggregatedMemoryContext.newSimpleAggregatedMemoryContext)1 ExchangeClient (com.facebook.presto.operator.ExchangeClient)1 ExchangeClientSupplier (com.facebook.presto.operator.ExchangeClientSupplier)1 LocalPartitionGenerator (com.facebook.presto.operator.exchange.LocalPartitionGenerator)1 PartitionedOutputOperator (com.facebook.presto.operator.repartition.PartitionedOutputOperator)1 ForStatementResource (com.facebook.presto.server.ForStatementResource)1 QueryId (com.facebook.presto.spi.QueryId)1 PlanNodeId (com.facebook.presto.spi.plan.PlanNodeId)1