Search in sources :

Example 1 with IsolationLevel

use of com.facebook.presto.spi.transaction.IsolationLevel in project presto by prestodb.

the class IndexedTpchConnectorFactory method create.

@Override
public Connector create(String catalogName, Map<String, String> properties, ConnectorContext context) {
    int splitsPerNode = getSplitsPerNode(properties);
    TpchIndexedData indexedData = new TpchIndexedData(catalogName, indexSpec);
    NodeManager nodeManager = context.getNodeManager();
    return new Connector() {

        @Override
        public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) {
            return TpchTransactionHandle.INSTANCE;
        }

        @Override
        public ConnectorMetadata getMetadata(ConnectorTransactionHandle transactionHandle) {
            return new TpchIndexMetadata(catalogName, indexedData);
        }

        @Override
        public ConnectorSplitManager getSplitManager() {
            return new TpchSplitManager(nodeManager, splitsPerNode);
        }

        @Override
        public ConnectorRecordSetProvider getRecordSetProvider() {
            return new TpchRecordSetProvider();
        }

        @Override
        public ConnectorIndexProvider getIndexProvider() {
            return new TpchIndexProvider(indexedData);
        }

        @Override
        public Set<SystemTable> getSystemTables() {
            return ImmutableSet.of(new ExampleSystemTable());
        }

        @Override
        public ConnectorNodePartitioningProvider getNodePartitioningProvider() {
            return new TpchNodePartitioningProvider(nodeManager, splitsPerNode);
        }
    };
}
Also used : Connector(com.facebook.presto.spi.connector.Connector) IsolationLevel(com.facebook.presto.spi.transaction.IsolationLevel) ConnectorTransactionHandle(com.facebook.presto.spi.connector.ConnectorTransactionHandle) TpchSplitManager(com.facebook.presto.tpch.TpchSplitManager) NodeManager(com.facebook.presto.spi.NodeManager) TpchNodePartitioningProvider(com.facebook.presto.tpch.TpchNodePartitioningProvider) SystemTable(com.facebook.presto.spi.SystemTable) TpchRecordSetProvider(com.facebook.presto.tpch.TpchRecordSetProvider)

Example 2 with IsolationLevel

use of com.facebook.presto.spi.transaction.IsolationLevel in project presto by prestodb.

the class TpchConnectorFactory method create.

@Override
public Connector create(String catalogName, Map<String, String> properties, ConnectorContext context) {
    int splitsPerNode = getSplitsPerNode(properties);
    ColumnNaming columnNaming = ColumnNaming.valueOf(properties.getOrDefault(TPCH_COLUMN_NAMING_PROPERTY, ColumnNaming.SIMPLIFIED.name()).toUpperCase());
    NodeManager nodeManager = context.getNodeManager();
    return new Connector() {

        @Override
        public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) {
            return TpchTransactionHandle.INSTANCE;
        }

        @Override
        public ConnectorMetadata getMetadata(ConnectorTransactionHandle transaction) {
            return new TpchMetadata(catalogName, columnNaming, predicatePushdownEnabled, isPartitioningEnabled(properties));
        }

        @Override
        public ConnectorSplitManager getSplitManager() {
            return new TpchSplitManager(nodeManager, splitsPerNode);
        }

        @Override
        public ConnectorRecordSetProvider getRecordSetProvider() {
            return new TpchRecordSetProvider();
        }

        @Override
        public ConnectorNodePartitioningProvider getNodePartitioningProvider() {
            return new TpchNodePartitioningProvider(nodeManager, splitsPerNode);
        }
    };
}
Also used : NodeManager(com.facebook.presto.spi.NodeManager) Connector(com.facebook.presto.spi.connector.Connector) IsolationLevel(com.facebook.presto.spi.transaction.IsolationLevel) ConnectorTransactionHandle(com.facebook.presto.spi.connector.ConnectorTransactionHandle)

Example 3 with IsolationLevel

use of com.facebook.presto.spi.transaction.IsolationLevel in project presto by prestodb.

the class TpcdsConnectorFactory method create.

@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
    int splitsPerNode = getSplitsPerNode(config);
    NodeManager nodeManager = context.getNodeManager();
    return new Connector() {

        @Override
        public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) {
            return TpcdsTransactionHandle.INSTANCE;
        }

        @Override
        public ConnectorMetadata getMetadata(ConnectorTransactionHandle transactionHandle) {
            return new TpcdsMetadata();
        }

        @Override
        public ConnectorSplitManager getSplitManager() {
            return new TpcdsSplitManager(nodeManager, splitsPerNode, isWithNoSexism(config));
        }

        @Override
        public ConnectorRecordSetProvider getRecordSetProvider() {
            return new TpcdsRecordSetProvider();
        }

        @Override
        public ConnectorNodePartitioningProvider getNodePartitioningProvider() {
            return new TpcdsNodePartitioningProvider(nodeManager, splitsPerNode);
        }
    };
}
Also used : NodeManager(com.facebook.presto.spi.NodeManager) Connector(com.facebook.presto.spi.connector.Connector) IsolationLevel(com.facebook.presto.spi.transaction.IsolationLevel) ConnectorTransactionHandle(com.facebook.presto.spi.connector.ConnectorTransactionHandle)

Example 4 with IsolationLevel

use of com.facebook.presto.spi.transaction.IsolationLevel in project presto by prestodb.

the class StartTransactionTask method execute.

@Override
public ListenableFuture<?> execute(StartTransaction statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine, List<Expression> parameters) {
    Session session = stateMachine.getSession();
    if (!session.isClientTransactionSupport()) {
        throw new PrestoException(StandardErrorCode.INCOMPATIBLE_CLIENT, "Client does not support transactions");
    }
    if (session.getTransactionId().isPresent()) {
        throw new PrestoException(StandardErrorCode.NOT_SUPPORTED, "Nested transactions not supported");
    }
    Optional<IsolationLevel> isolationLevel = extractIsolationLevel(statement);
    Optional<Boolean> readOnly = extractReadOnly(statement);
    TransactionId transactionId = transactionManager.beginTransaction(isolationLevel.orElse(TransactionManager.DEFAULT_ISOLATION), readOnly.orElse(TransactionManager.DEFAULT_READ_ONLY), false);
    stateMachine.setStartedTransactionId(transactionId);
    // Since the current session does not contain this new transaction ID, we need to manually mark it as inactive
    // when this statement completes.
    transactionManager.trySetInactive(transactionId);
    return immediateFuture(null);
}
Also used : IsolationLevel(com.facebook.presto.spi.transaction.IsolationLevel) PrestoException(com.facebook.presto.spi.PrestoException) Session(com.facebook.presto.Session) TransactionId(com.facebook.presto.transaction.TransactionId)

Aggregations

IsolationLevel (com.facebook.presto.spi.transaction.IsolationLevel)4 NodeManager (com.facebook.presto.spi.NodeManager)3 Connector (com.facebook.presto.spi.connector.Connector)3 ConnectorTransactionHandle (com.facebook.presto.spi.connector.ConnectorTransactionHandle)3 Session (com.facebook.presto.Session)1 PrestoException (com.facebook.presto.spi.PrestoException)1 SystemTable (com.facebook.presto.spi.SystemTable)1 TpchNodePartitioningProvider (com.facebook.presto.tpch.TpchNodePartitioningProvider)1 TpchRecordSetProvider (com.facebook.presto.tpch.TpchRecordSetProvider)1 TpchSplitManager (com.facebook.presto.tpch.TpchSplitManager)1 TransactionId (com.facebook.presto.transaction.TransactionId)1