Search in sources :

Example 1 with Builder

use of com.facebook.presto.spi.InMemoryRecordSet.Builder in project presto by prestodb.

the class ColumnJdbcTable method cursor.

@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint) {
    Session session = toSession(transactionHandle, connectorSession);
    Optional<String> catalogFilter = stringFilter(constraint, 0);
    Optional<String> schemaFilter = stringFilter(constraint, 1);
    Optional<String> tableFilter = stringFilter(constraint, 2);
    Builder table = InMemoryRecordSet.builder(METADATA);
    for (String catalog : filter(listCatalogs(session, metadata, accessControl).keySet(), catalogFilter)) {
        QualifiedTablePrefix prefix = FilterUtil.tablePrefix(catalog, schemaFilter, tableFilter);
        for (Entry<SchemaTableName, List<ColumnMetadata>> entry : listTableColumns(session, metadata, accessControl, prefix).entrySet()) {
            addColumnRows(table, catalog, entry.getKey(), entry.getValue());
        }
    }
    return table.build().cursor();
}
Also used : QualifiedTablePrefix(com.facebook.presto.metadata.QualifiedTablePrefix) TableMetadataBuilder.tableMetadataBuilder(com.facebook.presto.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder) Builder(com.facebook.presto.spi.InMemoryRecordSet.Builder) List(java.util.List) SchemaTableName(com.facebook.presto.spi.SchemaTableName) SystemConnectorSessionUtil.toSession(com.facebook.presto.connector.system.SystemConnectorSessionUtil.toSession) Session(com.facebook.presto.Session) ConnectorSession(com.facebook.presto.spi.ConnectorSession)

Example 2 with Builder

use of com.facebook.presto.spi.InMemoryRecordSet.Builder in project presto by prestodb.

the class SchemaJdbcTable method cursor.

@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint) {
    Session session = toSession(transactionHandle, connectorSession);
    Optional<String> catalogFilter = FilterUtil.stringFilter(constraint, 1);
    Builder table = InMemoryRecordSet.builder(METADATA);
    for (String catalog : filter(listCatalogs(session, metadata, accessControl).keySet(), catalogFilter)) {
        for (String schema : listSchemas(session, metadata, accessControl, catalog)) {
            table.addRow(schema, catalog);
        }
    }
    return table.build().cursor();
}
Also used : TableMetadataBuilder.tableMetadataBuilder(com.facebook.presto.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder) Builder(com.facebook.presto.spi.InMemoryRecordSet.Builder) Session(com.facebook.presto.Session) ConnectorSession(com.facebook.presto.spi.ConnectorSession) SystemConnectorSessionUtil.toSession(com.facebook.presto.connector.system.SystemConnectorSessionUtil.toSession)

Example 3 with Builder

use of com.facebook.presto.spi.InMemoryRecordSet.Builder in project presto by prestodb.

the class CatalogSystemTable method cursor.

@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint) {
    Session session = toSession(transactionHandle, connectorSession);
    Builder table = InMemoryRecordSet.builder(CATALOG_TABLE);
    for (Map.Entry<String, ConnectorId> entry : listCatalogs(session, metadata, accessControl).entrySet()) {
        table.addRow(entry.getKey(), entry.getValue().toString());
    }
    return table.build().cursor();
}
Also used : TableMetadataBuilder.tableMetadataBuilder(com.facebook.presto.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder) Builder(com.facebook.presto.spi.InMemoryRecordSet.Builder) Map(java.util.Map) Session(com.facebook.presto.Session) ConnectorSession(com.facebook.presto.spi.ConnectorSession) SystemConnectorSessionUtil.toSession(com.facebook.presto.connector.system.SystemConnectorSessionUtil.toSession) ConnectorId(com.facebook.presto.connector.ConnectorId)

Example 4 with Builder

use of com.facebook.presto.spi.InMemoryRecordSet.Builder in project presto by prestodb.

the class QuerySystemTable method cursor.

@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession session, TupleDomain<Integer> constraint) {
    Builder table = InMemoryRecordSet.builder(QUERY_TABLE);
    for (QueryInfo queryInfo : queryManager.getAllQueryInfo()) {
        QueryStats queryStats = queryInfo.getQueryStats();
        table.addRow(nodeId, queryInfo.getQueryId().toString(), queryInfo.getState().toString(), queryInfo.getSession().getUser(), queryInfo.getSession().getSource().orElse(null), queryInfo.getQuery(), toMillis(queryStats.getQueuedTime()), toMillis(queryStats.getAnalysisTime()), toMillis(queryStats.getDistributedPlanningTime()), toTimeStamp(queryStats.getCreateTime()), toTimeStamp(queryStats.getExecutionStartTime()), toTimeStamp(queryStats.getLastHeartbeat()), toTimeStamp(queryStats.getEndTime()));
    }
    return table.build().cursor();
}
Also used : QueryStats(com.facebook.presto.execution.QueryStats) TableMetadataBuilder.tableMetadataBuilder(com.facebook.presto.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder) Builder(com.facebook.presto.spi.InMemoryRecordSet.Builder) QueryInfo(com.facebook.presto.execution.QueryInfo)

Example 5 with Builder

use of com.facebook.presto.spi.InMemoryRecordSet.Builder in project presto by prestodb.

the class CatalogJdbcTable method cursor.

@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint) {
    Session session = toSession(transactionHandle, connectorSession);
    Builder table = InMemoryRecordSet.builder(METADATA);
    for (String name : listCatalogs(session, metadata, accessControl).keySet()) {
        table.addRow(name);
    }
    return table.build().cursor();
}
Also used : TableMetadataBuilder.tableMetadataBuilder(com.facebook.presto.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder) Builder(com.facebook.presto.spi.InMemoryRecordSet.Builder) Session(com.facebook.presto.Session) ConnectorSession(com.facebook.presto.spi.ConnectorSession) SystemConnectorSessionUtil.toSession(com.facebook.presto.connector.system.SystemConnectorSessionUtil.toSession)

Aggregations

TableMetadataBuilder.tableMetadataBuilder (com.facebook.presto.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder)9 Builder (com.facebook.presto.spi.InMemoryRecordSet.Builder)9 Session (com.facebook.presto.Session)5 SystemConnectorSessionUtil.toSession (com.facebook.presto.connector.system.SystemConnectorSessionUtil.toSession)5 ConnectorSession (com.facebook.presto.spi.ConnectorSession)5 QualifiedTablePrefix (com.facebook.presto.metadata.QualifiedTablePrefix)2 SchemaTableName (com.facebook.presto.spi.SchemaTableName)2 ConnectorId (com.facebook.presto.connector.ConnectorId)1 ColumnJdbcTable.jdbcDataType (com.facebook.presto.connector.system.jdbc.ColumnJdbcTable.jdbcDataType)1 QueryInfo (com.facebook.presto.execution.QueryInfo)1 QueryStats (com.facebook.presto.execution.QueryStats)1 TaskInfo (com.facebook.presto.execution.TaskInfo)1 TaskStatus (com.facebook.presto.execution.TaskStatus)1 AllNodes (com.facebook.presto.metadata.AllNodes)1 TaskStats (com.facebook.presto.operator.TaskStats)1 ParametricType (com.facebook.presto.spi.type.ParametricType)1 Type (com.facebook.presto.spi.type.Type)1 VarcharType.createUnboundedVarcharType (com.facebook.presto.spi.type.VarcharType.createUnboundedVarcharType)1 List (java.util.List)1 Map (java.util.Map)1