Search in sources :

Example 11 with DatasetDataSource

use of org.apache.asterix.metadata.declared.DatasetDataSource in project asterixdb by apache.

the class IntroduceLSMComponentFilterRule method changePlan.

private void changePlan(List<IOptimizableFuncExpr> optFuncExprs, AbstractLogicalOperator op, Dataset dataset, IOptimizationContext context) throws AlgebricksException {
    Queue<Mutable<ILogicalOperator>> queue = new LinkedList<>(op.getInputs());
    while (!queue.isEmpty()) {
        AbstractLogicalOperator descendantOp = (AbstractLogicalOperator) queue.poll().getValue();
        if (descendantOp == null) {
            continue;
        }
        if (descendantOp.getOperatorTag() == LogicalOperatorTag.DATASOURCESCAN) {
            DataSourceScanOperator dataSourceScanOp = (DataSourceScanOperator) descendantOp;
            DataSource ds = (DataSource) dataSourceScanOp.getDataSource();
            if (dataset.getDatasetName().compareTo(((DatasetDataSource) ds).getDataset().getDatasetName()) == 0) {
                List<LogicalVariable> minFilterVars = new ArrayList<>();
                List<LogicalVariable> maxFilterVars = new ArrayList<>();
                AssignOperator assignOp = createAssignOperator(optFuncExprs, minFilterVars, maxFilterVars, context);
                dataSourceScanOp.setMinFilterVars(minFilterVars);
                dataSourceScanOp.setMaxFilterVars(maxFilterVars);
                List<Mutable<ILogicalExpression>> additionalFilteringExpressions = new ArrayList<>();
                for (LogicalVariable var : assignOp.getVariables()) {
                    additionalFilteringExpressions.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(var)));
                }
                dataSourceScanOp.setAdditionalFilteringExpressions(additionalFilteringExpressions);
                assignOp.getInputs().add(new MutableObject<>(dataSourceScanOp.getInputs().get(0).getValue()));
                dataSourceScanOp.getInputs().get(0).setValue(assignOp);
            }
        } else if (descendantOp.getOperatorTag() == LogicalOperatorTag.UNNEST_MAP) {
            UnnestMapOperator unnestMapOp = (UnnestMapOperator) descendantOp;
            ILogicalExpression unnestExpr = unnestMapOp.getExpressionRef().getValue();
            if (unnestExpr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
                AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) unnestExpr;
                FunctionIdentifier fid = f.getFunctionIdentifier();
                if (!fid.equals(BuiltinFunctions.INDEX_SEARCH)) {
                    throw new IllegalStateException();
                }
                AccessMethodJobGenParams jobGenParams = new AccessMethodJobGenParams();
                jobGenParams.readFromFuncArgs(f.getArguments());
                if (dataset.getDatasetName().compareTo(jobGenParams.datasetName) == 0) {
                    List<LogicalVariable> minFilterVars = new ArrayList<>();
                    List<LogicalVariable> maxFilterVars = new ArrayList<>();
                    AssignOperator assignOp = createAssignOperator(optFuncExprs, minFilterVars, maxFilterVars, context);
                    unnestMapOp.setMinFilterVars(minFilterVars);
                    unnestMapOp.setMaxFilterVars(maxFilterVars);
                    List<Mutable<ILogicalExpression>> additionalFilteringExpressions = new ArrayList<>();
                    for (LogicalVariable var : assignOp.getVariables()) {
                        additionalFilteringExpressions.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(var)));
                    }
                    unnestMapOp.setAdditionalFilteringExpressions(additionalFilteringExpressions);
                    assignOp.getInputs().add(new MutableObject<>(unnestMapOp.getInputs().get(0).getValue()));
                    unnestMapOp.getInputs().get(0).setValue(assignOp);
                }
            }
        }
        queue.addAll(descendantOp.getInputs());
    }
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) UnnestMapOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.UnnestMapOperator) AbstractFunctionCallExpression(org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression) ArrayList(java.util.ArrayList) AssignOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AssignOperator) LinkedList(java.util.LinkedList) DataSource(org.apache.asterix.metadata.declared.DataSource) DatasetDataSource(org.apache.asterix.metadata.declared.DatasetDataSource) Mutable(org.apache.commons.lang3.mutable.Mutable) FunctionIdentifier(org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier) ILogicalExpression(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression) DataSourceScanOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.DataSourceScanOperator) VariableReferenceExpression(org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) MutableObject(org.apache.commons.lang3.mutable.MutableObject)

Example 12 with DatasetDataSource

use of org.apache.asterix.metadata.declared.DatasetDataSource in project asterixdb by apache.

the class ExternalDataLookupPOperator method computeDeliveredProperties.

@Override
public void computeDeliveredProperties(ILogicalOperator op, IOptimizationContext context) throws AlgebricksException {
    DataSource ds = new DatasetDataSource(datasetId, dataset, recordType, null, /*external dataset doesn't have meta records.*/
    Type.EXTERNAL_DATASET, dataset.getDatasetDetails(), context.getComputationNodeDomain());
    IDataSourcePropertiesProvider dspp = ds.getPropertiesProvider();
    AbstractScanOperator as = (AbstractScanOperator) op;
    deliveredProperties = dspp.computePropertiesVector(as.getVariables());
}
Also used : AbstractScanOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractScanOperator) DatasetDataSource(org.apache.asterix.metadata.declared.DatasetDataSource) DataSource(org.apache.asterix.metadata.declared.DataSource) DatasetDataSource(org.apache.asterix.metadata.declared.DatasetDataSource) IDataSourcePropertiesProvider(org.apache.hyracks.algebricks.core.algebra.metadata.IDataSourcePropertiesProvider)

Aggregations

DatasetDataSource (org.apache.asterix.metadata.declared.DatasetDataSource)12 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)7 AbstractLogicalOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator)7 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)5 VariableReferenceExpression (org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression)5 DataSourceScanOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.DataSourceScanOperator)5 ArrayList (java.util.ArrayList)4 DataSource (org.apache.asterix.metadata.declared.DataSource)4 Mutable (org.apache.commons.lang3.mutable.Mutable)4 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)4 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)4 AssignOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AssignOperator)4 InsertDeleteUpsertOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.InsertDeleteUpsertOperator)4 List (java.util.List)3 Dataset (org.apache.asterix.metadata.entities.Dataset)3 InternalDatasetDetails (org.apache.asterix.metadata.entities.InternalDatasetDetails)3 AString (org.apache.asterix.om.base.AString)3 IAType (org.apache.asterix.om.types.IAType)3 MutableObject (org.apache.commons.lang3.mutable.MutableObject)3 AbstractFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)3