Search in sources :

Example 81 with ConnectorTableHandle

use of com.facebook.presto.spi.ConnectorTableHandle in project presto by prestodb.

the class MetadataManager method beginStatisticsCollection.

@Override
public AnalyzeTableHandle beginStatisticsCollection(Session session, TableHandle tableHandle) {
    ConnectorId connectorId = tableHandle.getConnectorId();
    CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, connectorId);
    ConnectorMetadata metadata = catalogMetadata.getMetadata();
    ConnectorTransactionHandle transactionHandle = catalogMetadata.getTransactionHandleFor(connectorId);
    ConnectorTableHandle connectorTableHandle = metadata.beginStatisticsCollection(session.toConnectorSession(connectorId), tableHandle.getConnectorHandle());
    return new AnalyzeTableHandle(connectorId, transactionHandle, connectorTableHandle);
}
Also used : ConnectorTransactionHandle(com.facebook.presto.spi.connector.ConnectorTransactionHandle) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ConnectorId(com.facebook.presto.spi.ConnectorId) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle)

Example 82 with ConnectorTableHandle

use of com.facebook.presto.spi.ConnectorTableHandle in project presto by prestodb.

the class MetadataManager method beginDelete.

@Override
public TableHandle beginDelete(Session session, TableHandle tableHandle) {
    ConnectorId connectorId = tableHandle.getConnectorId();
    CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, connectorId);
    ConnectorTableHandle newHandle = catalogMetadata.getMetadata().beginDelete(session.toConnectorSession(connectorId), tableHandle.getConnectorHandle());
    return new TableHandle(tableHandle.getConnectorId(), newHandle, tableHandle.getTransaction(), Optional.empty());
}
Also used : ConnectorOutputTableHandle(com.facebook.presto.spi.ConnectorOutputTableHandle) TableHandle(com.facebook.presto.spi.TableHandle) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) ConnectorInsertTableHandle(com.facebook.presto.spi.ConnectorInsertTableHandle) ConnectorId(com.facebook.presto.spi.ConnectorId) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle)

Example 83 with ConnectorTableHandle

use of com.facebook.presto.spi.ConnectorTableHandle in project presto by prestodb.

the class TestSystemMemoryBlocking method testTableScanSystemMemoryBlocking.

@Test
public void testTableScanSystemMemoryBlocking() {
    PlanNodeId sourceId = new PlanNodeId("source");
    final List<Type> types = ImmutableList.of(VARCHAR);
    TableScanOperator source = new TableScanOperator(driverContext.addOperatorContext(1, new PlanNodeId("test"), "values"), sourceId, (session, split, table, columns) -> new FixedPageSource(rowPagesBuilder(types).addSequencePage(10, 1).addSequencePage(10, 1).addSequencePage(10, 1).addSequencePage(10, 1).addSequencePage(10, 1).build()), new TableHandle(new ConnectorId("test"), new ConnectorTableHandle() {
    }, new ConnectorTransactionHandle() {
    }, Optional.empty()), ImmutableList.of());
    PageConsumerOperator sink = createSinkOperator(types);
    Driver driver = Driver.createDriver(driverContext, source, sink);
    assertSame(driver.getDriverContext(), driverContext);
    assertFalse(driver.isFinished());
    Split testSplit = new Split(new ConnectorId("test"), TestingTransactionHandle.create(), new TestSplit());
    driver.updateSource(new TaskSource(sourceId, ImmutableSet.of(new ScheduledSplit(0, sourceId, testSplit)), true));
    ListenableFuture<?> blocked = driver.processFor(new Duration(1, NANOSECONDS));
    // the driver shouldn't block in the first call as it will be able to move a page between source and the sink operator
    // but the operator should be blocked
    assertTrue(blocked.isDone());
    assertFalse(source.getOperatorContext().isWaitingForMemory().isDone());
    // and they should stay blocked until more memory becomes available
    for (int i = 0; i < 10; i++) {
        blocked = driver.processFor(new Duration(1, NANOSECONDS));
        assertFalse(blocked.isDone());
        assertFalse(source.getOperatorContext().isWaitingForMemory().isDone());
    }
    // free up some memory
    memoryPool.free(QUERY_ID, "test", memoryPool.getReservedBytes());
    // the operator should be unblocked
    assertTrue(source.getOperatorContext().isWaitingForMemory().isDone());
    // the driver shouldn't be blocked
    blocked = driver.processFor(new Duration(1, NANOSECONDS));
    assertTrue(blocked.isDone());
}
Also used : TableScanOperator(com.facebook.presto.operator.TableScanOperator) ScheduledSplit(com.facebook.presto.execution.ScheduledSplit) ConnectorTransactionHandle(com.facebook.presto.spi.connector.ConnectorTransactionHandle) Driver(com.facebook.presto.operator.Driver) Duration(io.airlift.units.Duration) FixedPageSource(com.facebook.presto.spi.FixedPageSource) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) PageConsumerOperator(com.facebook.presto.testing.PageConsumerOperator) Type(com.facebook.presto.common.type.Type) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) TableHandle(com.facebook.presto.spi.TableHandle) ScheduledSplit(com.facebook.presto.execution.ScheduledSplit) ConnectorSplit(com.facebook.presto.spi.ConnectorSplit) Split(com.facebook.presto.metadata.Split) TaskSource(com.facebook.presto.execution.TaskSource) ConnectorId(com.facebook.presto.spi.ConnectorId) Test(org.testng.annotations.Test)

Example 84 with ConnectorTableHandle

use of com.facebook.presto.spi.ConnectorTableHandle in project presto by prestodb.

the class TestSystemTableHandle method testSystemDeserialize.

@Test
public void testSystemDeserialize() throws Exception {
    String json = objectMapper.writeValueAsString(SCHEMA_AS_MAP);
    ConnectorTableHandle tableHandle = objectMapper.readValue(json, ConnectorTableHandle.class);
    assertEquals(tableHandle.getClass(), SystemTableHandle.class);
    SystemTableHandle systemHandle = (SystemTableHandle) tableHandle;
    assertEquals(systemHandle.getConnectorId(), CONNECTOR_ID);
    assertEquals(systemHandle.getSchemaTableName(), new SchemaTableName("system_schema", "system_table"));
}
Also used : SystemTableHandle(com.facebook.presto.connector.system.SystemTableHandle) SchemaTableName(com.facebook.presto.spi.SchemaTableName) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) Test(org.testng.annotations.Test)

Example 85 with ConnectorTableHandle

use of com.facebook.presto.spi.ConnectorTableHandle in project presto by prestodb.

the class TestInformationSchemaTableHandle method testInformationSchemaDeserialize.

@Test
public void testInformationSchemaDeserialize() throws Exception {
    String json = objectMapper.writeValueAsString(SCHEMA_AS_MAP);
    ConnectorTableHandle tableHandle = objectMapper.readValue(json, ConnectorTableHandle.class);
    assertEquals(tableHandle.getClass(), InformationSchemaTableHandle.class);
    InformationSchemaTableHandle informationSchemaHandle = (InformationSchemaTableHandle) tableHandle;
    assertEquals(informationSchemaHandle.getCatalogName(), "information_schema_catalog");
    assertEquals(informationSchemaHandle.getSchemaName(), "information_schema_schema");
    assertEquals(informationSchemaHandle.getTableName(), "information_schema_table");
}
Also used : InformationSchemaTableHandle(com.facebook.presto.connector.informationSchema.InformationSchemaTableHandle) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) Test(org.testng.annotations.Test)

Aggregations

ConnectorTableHandle (com.facebook.presto.spi.ConnectorTableHandle)117 Test (org.testng.annotations.Test)68 ColumnHandle (com.facebook.presto.spi.ColumnHandle)64 ConnectorMetadata (com.facebook.presto.spi.connector.ConnectorMetadata)64 ConnectorSession (com.facebook.presto.spi.ConnectorSession)61 ConnectorTableMetadata (com.facebook.presto.spi.ConnectorTableMetadata)49 TestingConnectorSession (com.facebook.presto.testing.TestingConnectorSession)45 SchemaTableName (com.facebook.presto.spi.SchemaTableName)42 Constraint (com.facebook.presto.spi.Constraint)35 ConnectorOutputTableHandle (com.facebook.presto.spi.ConnectorOutputTableHandle)31 MaterializedResult (com.facebook.presto.testing.MaterializedResult)31 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)30 Slice (io.airlift.slice.Slice)30 PrestoException (com.facebook.presto.spi.PrestoException)29 ConnectorInsertTableHandle (com.facebook.presto.spi.ConnectorInsertTableHandle)28 ConnectorTableLayout (com.facebook.presto.spi.ConnectorTableLayout)28 ConnectorTableLayoutHandle (com.facebook.presto.spi.ConnectorTableLayoutHandle)27 ImmutableList (com.google.common.collect.ImmutableList)27 Map (java.util.Map)27 Optional (java.util.Optional)27