use of com.facebook.presto.transaction.TransactionId in project presto by prestodb.
the class AbstractPropertiesSystemTable method cursor.
@Override
public final RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession session, TupleDomain<Integer> constraint) {
TransactionId transactionId = ((GlobalSystemTransactionHandle) transactionHandle).getTransactionId();
InMemoryRecordSet.Builder table = InMemoryRecordSet.builder(tableMetadata);
Map<ConnectorId, Map<String, PropertyMetadata<?>>> connectorProperties = propertySupplier.get();
for (Entry<String, ConnectorId> entry : new TreeMap<>(transactionManager.getCatalogNames(transactionId)).entrySet()) {
String catalog = entry.getKey();
Map<String, PropertyMetadata<?>> properties = new TreeMap<>(connectorProperties.getOrDefault(entry.getValue(), ImmutableMap.of()));
for (PropertyMetadata<?> propertyMetadata : properties.values()) {
table.addRow(catalog, propertyMetadata.getName(), firstNonNull(propertyMetadata.getDefaultValue(), "").toString(), propertyMetadata.getSqlType().toString(), propertyMetadata.getDescription());
}
}
return table.build().cursor();
}
use of com.facebook.presto.transaction.TransactionId in project presto by prestodb.
the class QueryStateMachine method beginWithTicker.
static QueryStateMachine beginWithTicker(QueryId queryId, String query, Session session, URI self, boolean transactionControl, TransactionManager transactionManager, AccessControl accessControl, Executor executor, Ticker ticker, Metadata metadata) {
session.getTransactionId().ifPresent(transactionControl ? transactionManager::trySetActive : transactionManager::checkAndSetActive);
Session querySession;
boolean autoCommit = !session.getTransactionId().isPresent() && !transactionControl;
if (autoCommit) {
// TODO: make autocommit isolation level a session parameter
TransactionId transactionId = transactionManager.beginTransaction(true);
querySession = session.beginTransactionId(transactionId, transactionManager, accessControl);
} else {
querySession = session;
}
QueryStateMachine queryStateMachine = new QueryStateMachine(queryId, query, querySession, self, autoCommit, transactionManager, executor, ticker, metadata);
queryStateMachine.addStateChangeListener(newState -> log.debug("Query %s is %s", queryId, newState));
queryStateMachine.addStateChangeListener(newState -> {
if (newState.isDone()) {
session.getTransactionId().ifPresent(transactionManager::trySetInactive);
}
});
return queryStateMachine;
}
Aggregations