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