Search in sources :

Example 11 with CommitOperator

use of org.apache.asterix.algebra.operators.CommitOperator in project asterixdb by apache.

the class LangExpressionToPlanTranslator method translateConnectFeed.

private ILogicalOperator translateConnectFeed(DatasetDataSource targetDatasource, Mutable<ILogicalExpression> varRef, List<Mutable<ILogicalExpression>> varRefsForLoading, List<Mutable<ILogicalExpression>> additionalFilteringExpressions, ILogicalOperator assign) {
    InsertDeleteUpsertOperator insertOp = new InsertDeleteUpsertOperator(targetDatasource, varRef, varRefsForLoading, InsertDeleteUpsertOperator.Kind.INSERT, false);
    insertOp.setAdditionalFilteringExpressions(additionalFilteringExpressions);
    insertOp.getInputs().add(new MutableObject<>(assign));
    ILogicalOperator leafOperator = new DelegateOperator(new CommitOperator(true));
    leafOperator.getInputs().add(new MutableObject<>(insertOp));
    return leafOperator;
}
Also used : InsertDeleteUpsertOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.InsertDeleteUpsertOperator) DelegateOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.DelegateOperator) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) CommitOperator(org.apache.asterix.algebra.operators.CommitOperator)

Example 12 with CommitOperator

use of org.apache.asterix.algebra.operators.CommitOperator in project asterixdb by apache.

the class LangExpressionToPlanTranslator method translateInsert.

private ILogicalOperator translateInsert(DatasetDataSource targetDatasource, Mutable<ILogicalExpression> varRef, List<Mutable<ILogicalExpression>> varRefsForLoading, List<Mutable<ILogicalExpression>> additionalFilteringExpressions, ILogicalOperator assign, ICompiledDmlStatement stmt) throws AlgebricksException {
    if (targetDatasource.getDataset().hasMetaPart()) {
        throw new AlgebricksException(targetDatasource.getDataset().getDatasetName() + ": insert into dataset is not supported on Datasets with Meta records");
    }
    // Adds the insert operator.
    InsertDeleteUpsertOperator insertOp = new InsertDeleteUpsertOperator(targetDatasource, varRef, varRefsForLoading, InsertDeleteUpsertOperator.Kind.INSERT, false);
    insertOp.setAdditionalFilteringExpressions(additionalFilteringExpressions);
    insertOp.getInputs().add(new MutableObject<>(assign));
    // Adds the commit operator.
    CompiledInsertStatement compiledInsert = (CompiledInsertStatement) stmt;
    Expression returnExpression = compiledInsert.getReturnExpression();
    ILogicalOperator rootOperator = new DelegateOperator(new CommitOperator(returnExpression == null ? true : false));
    rootOperator.getInputs().add(new MutableObject<>(insertOp));
    // Compiles the return expression.
    return processReturningExpression(rootOperator, insertOp, compiledInsert);
}
Also used : InsertDeleteUpsertOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.InsertDeleteUpsertOperator) ILangExpression(org.apache.asterix.lang.common.base.ILangExpression) AggregateFunctionCallExpression(org.apache.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression) Expression(org.apache.asterix.lang.common.base.Expression) VariableReferenceExpression(org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression) QuantifiedExpression(org.apache.asterix.lang.common.expression.QuantifiedExpression) ScalarFunctionCallExpression(org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression) ConstantExpression(org.apache.hyracks.algebricks.core.algebra.expressions.ConstantExpression) ILogicalExpression(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression) AbstractFunctionCallExpression(org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression) UnnestingFunctionCallExpression(org.apache.hyracks.algebricks.core.algebra.expressions.UnnestingFunctionCallExpression) DelegateOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.DelegateOperator) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) AlgebricksException(org.apache.hyracks.algebricks.common.exceptions.AlgebricksException) CommitOperator(org.apache.asterix.algebra.operators.CommitOperator) CompiledInsertStatement(org.apache.asterix.translator.CompiledStatements.CompiledInsertStatement)

Example 13 with CommitOperator

use of org.apache.asterix.algebra.operators.CommitOperator in project asterixdb by apache.

the class LangExpressionToPlanTranslator method translateDelete.

private ILogicalOperator translateDelete(DatasetDataSource targetDatasource, Mutable<ILogicalExpression> varRef, List<Mutable<ILogicalExpression>> varRefsForLoading, List<Mutable<ILogicalExpression>> additionalFilteringExpressions, ILogicalOperator assign) throws AlgebricksException {
    if (targetDatasource.getDataset().hasMetaPart()) {
        throw new AlgebricksException(targetDatasource.getDataset().getDatasetName() + ": delete from dataset is not supported on Datasets with Meta records");
    }
    InsertDeleteUpsertOperator deleteOp = new InsertDeleteUpsertOperator(targetDatasource, varRef, varRefsForLoading, InsertDeleteUpsertOperator.Kind.DELETE, false);
    deleteOp.setAdditionalFilteringExpressions(additionalFilteringExpressions);
    deleteOp.getInputs().add(new MutableObject<>(assign));
    ILogicalOperator leafOperator = new DelegateOperator(new CommitOperator(true));
    leafOperator.getInputs().add(new MutableObject<>(deleteOp));
    return leafOperator;
}
Also used : InsertDeleteUpsertOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.InsertDeleteUpsertOperator) DelegateOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.DelegateOperator) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) AlgebricksException(org.apache.hyracks.algebricks.common.exceptions.AlgebricksException) CommitOperator(org.apache.asterix.algebra.operators.CommitOperator)

Aggregations

CommitOperator (org.apache.asterix.algebra.operators.CommitOperator)13 DelegateOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.DelegateOperator)13 InsertDeleteUpsertOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.InsertDeleteUpsertOperator)10 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)8 AbstractLogicalOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator)8 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)7 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)7 VariableReferenceExpression (org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression)7 ArrayList (java.util.ArrayList)6 Mutable (org.apache.commons.lang3.mutable.Mutable)5 AbstractFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)5 AssignOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AssignOperator)5 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)4 ScalarFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression)4 DataSource (org.apache.asterix.metadata.declared.DataSource)3 ARecordType (org.apache.asterix.om.types.ARecordType)3 IAType (org.apache.asterix.om.types.IAType)3 MutableObject (org.apache.commons.lang3.mutable.MutableObject)3 ConstantExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ConstantExpression)3 ProjectOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.ProjectOperator)3