Search in sources :

Example 1 with MaterializeOperator

use of org.apache.hyracks.algebricks.core.algebra.operators.logical.MaterializeOperator in project asterixdb by apache.

the class IntroduceMaterializationForInsertWithSelfScanRule method rewritePost.

@Override
public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException {
    AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
    if (op.getOperatorTag() != LogicalOperatorTag.INSERT_DELETE_UPSERT) {
        return false;
    }
    InsertDeleteUpsertOperator insertOp = (InsertDeleteUpsertOperator) op;
    boolean sameDataset = checkIfInsertAndScanDatasetsSame(op, ((DatasetDataSource) insertOp.getDataSource()).getDataset().getDatasetName());
    if (sameDataset) {
        MaterializeOperator materializeOperator = new MaterializeOperator();
        MaterializePOperator materializePOperator = new MaterializePOperator(true);
        materializeOperator.setPhysicalOperator(materializePOperator);
        materializeOperator.getInputs().add(new MutableObject<ILogicalOperator>(insertOp.getInputs().get(0).getValue()));
        context.computeAndSetTypeEnvironmentForOperator(materializeOperator);
        insertOp.getInputs().clear();
        insertOp.getInputs().add(new MutableObject<ILogicalOperator>(materializeOperator));
        context.computeAndSetTypeEnvironmentForOperator(insertOp);
        return true;
    } else {
        return false;
    }
}
Also used : MaterializeOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.MaterializeOperator) AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) InsertDeleteUpsertOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.InsertDeleteUpsertOperator) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) DatasetDataSource(org.apache.asterix.metadata.declared.DatasetDataSource) MaterializePOperator(org.apache.hyracks.algebricks.core.algebra.operators.physical.MaterializePOperator)

Example 2 with MaterializeOperator

use of org.apache.hyracks.algebricks.core.algebra.operators.logical.MaterializeOperator in project asterixdb by apache.

the class LogicalOperatorDeepCopyWithNewVariablesVisitor method visitMaterializeOperator.

@Override
public ILogicalOperator visitMaterializeOperator(MaterializeOperator op, ILogicalOperator arg) throws AlgebricksException {
    MaterializeOperator opCopy = new MaterializeOperator();
    deepCopyInputsAnnotationsAndExecutionMode(op, arg, opCopy);
    return opCopy;
}
Also used : MaterializeOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.MaterializeOperator)

Aggregations

MaterializeOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.MaterializeOperator)2 DatasetDataSource (org.apache.asterix.metadata.declared.DatasetDataSource)1 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)1 AbstractLogicalOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator)1 InsertDeleteUpsertOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.InsertDeleteUpsertOperator)1 MaterializePOperator (org.apache.hyracks.algebricks.core.algebra.operators.physical.MaterializePOperator)1