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