Search in sources :

Example 6 with Builder

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

the class TableJdbcTable 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);
    Optional<String> typeFilter = stringFilter(constraint, 3);
    Builder table = InMemoryRecordSet.builder(METADATA);
    for (String catalog : filter(listCatalogs(session, metadata, accessControl).keySet(), catalogFilter)) {
        QualifiedTablePrefix prefix = tablePrefix(catalog, schemaFilter, tableFilter);
        if (FilterUtil.emptyOrEquals(typeFilter, "TABLE")) {
            for (SchemaTableName name : listTables(session, metadata, accessControl, prefix)) {
                table.addRow(tableRow(catalog, name, "TABLE"));
            }
        }
        if (FilterUtil.emptyOrEquals(typeFilter, "VIEW")) {
            for (SchemaTableName name : listViews(session, metadata, accessControl, prefix)) {
                table.addRow(tableRow(catalog, name, "VIEW"));
            }
        }
    }
    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) SchemaTableName(com.facebook.presto.spi.SchemaTableName) Session(com.facebook.presto.Session) ConnectorSession(com.facebook.presto.spi.ConnectorSession) SystemConnectorSessionUtil.toSession(com.facebook.presto.connector.system.SystemConnectorSessionUtil.toSession)

Example 7 with Builder

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

the class TypesJdbcTable method cursor.

@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint) {
    Builder table = InMemoryRecordSet.builder(METADATA);
    for (Type type : typeManager.getTypes()) {
        addTypeRow(table, type);
    }
    addParametricTypeRows(table, typeManager.getParametricTypes());
    return table.build().cursor();
}
Also used : VarcharType.createUnboundedVarcharType(com.facebook.presto.spi.type.VarcharType.createUnboundedVarcharType) ColumnJdbcTable.jdbcDataType(com.facebook.presto.connector.system.jdbc.ColumnJdbcTable.jdbcDataType) Type(com.facebook.presto.spi.type.Type) ParametricType(com.facebook.presto.spi.type.ParametricType) TableMetadataBuilder.tableMetadataBuilder(com.facebook.presto.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder) Builder(com.facebook.presto.spi.InMemoryRecordSet.Builder)

Example 8 with Builder

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

the class NodeSystemTable method cursor.

@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession session, TupleDomain<Integer> constraint) {
    Builder table = InMemoryRecordSet.builder(NODES_TABLE);
    AllNodes allNodes = nodeManager.getAllNodes();
    addRows(table, allNodes.getActiveNodes(), ACTIVE);
    addRows(table, allNodes.getInactiveNodes(), INACTIVE);
    addRows(table, allNodes.getShuttingDownNodes(), SHUTTING_DOWN);
    return table.build().cursor();
}
Also used : TableMetadataBuilder.tableMetadataBuilder(com.facebook.presto.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder) Builder(com.facebook.presto.spi.InMemoryRecordSet.Builder) AllNodes(com.facebook.presto.metadata.AllNodes)

Example 9 with Builder

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

the class TaskSystemTable method cursor.

@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession session, TupleDomain<Integer> constraint) {
    Builder table = InMemoryRecordSet.builder(TASK_TABLE);
    for (TaskInfo taskInfo : taskManager.getAllTaskInfo()) {
        TaskStats stats = taskInfo.getStats();
        TaskStatus taskStatus = taskInfo.getTaskStatus();
        table.addRow(nodeId, taskStatus.getTaskId().toString(), taskStatus.getTaskId().getStageId().toString(), taskStatus.getTaskId().getQueryId().toString(), taskStatus.getState().toString(), (long) stats.getTotalDrivers(), (long) stats.getQueuedDrivers(), (long) stats.getRunningDrivers(), (long) stats.getCompletedDrivers(), toMillis(stats.getTotalScheduledTime()), toMillis(stats.getTotalCpuTime()), toMillis(stats.getTotalUserTime()), toMillis(stats.getTotalBlockedTime()), toBytes(stats.getRawInputDataSize()), stats.getRawInputPositions(), toBytes(stats.getProcessedInputDataSize()), stats.getProcessedInputPositions(), toBytes(stats.getOutputDataSize()), stats.getOutputPositions(), toTimeStamp(stats.getCreateTime()), toTimeStamp(stats.getFirstStartTime()), toTimeStamp(taskInfo.getLastHeartbeat()), toTimeStamp(stats.getEndTime()));
    }
    return table.build().cursor();
}
Also used : TaskInfo(com.facebook.presto.execution.TaskInfo) TableMetadataBuilder.tableMetadataBuilder(com.facebook.presto.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder) Builder(com.facebook.presto.spi.InMemoryRecordSet.Builder) TaskStats(com.facebook.presto.operator.TaskStats) TaskStatus(com.facebook.presto.execution.TaskStatus)

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