Search in sources :

Example 1 with InMemoryStableSortPOperator

use of org.apache.hyracks.algebricks.core.algebra.operators.physical.InMemoryStableSortPOperator in project asterixdb by apache.

the class EnforceStructuralPropertiesRule method enforceOrderProperties.

private Mutable<ILogicalOperator> enforceOrderProperties(List<LocalOrderProperty> oList, Mutable<ILogicalOperator> topOp, boolean isMicroOp, IOptimizationContext context) throws AlgebricksException {
    List<Pair<IOrder, Mutable<ILogicalExpression>>> oe = new LinkedList<>();
    for (LocalOrderProperty orderProperty : oList) {
        for (OrderColumn oc : orderProperty.getOrderColumns()) {
            IOrder ordType = (oc.getOrder() == OrderKind.ASC) ? OrderOperator.ASC_ORDER : OrderOperator.DESC_ORDER;
            Pair<IOrder, Mutable<ILogicalExpression>> pair = new Pair<>(ordType, new MutableObject<ILogicalExpression>(new VariableReferenceExpression(oc.getColumn())));
            oe.add(pair);
        }
    }
    OrderOperator oo = new OrderOperator(oe);
    oo.setExecutionMode(AbstractLogicalOperator.ExecutionMode.LOCAL);
    if (isMicroOp) {
        oo.setPhysicalOperator(new InMemoryStableSortPOperator());
    } else {
        oo.setPhysicalOperator(new StableSortPOperator(physicalOptimizationConfig.getMaxFramesExternalSort()));
    }
    oo.getInputs().add(topOp);
    context.computeAndSetTypeEnvironmentForOperator(oo);
    if (AlgebricksConfig.DEBUG) {
        AlgebricksConfig.ALGEBRICKS_LOGGER.fine(">>>> Added sort enforcer " + oo.getPhysicalOperator() + ".\n");
    }
    return new MutableObject<ILogicalOperator>(oo);
}
Also used : IOrder(org.apache.hyracks.algebricks.core.algebra.operators.logical.OrderOperator.IOrder) OrderColumn(org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn) OrderOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.OrderOperator) InMemoryStableSortPOperator(org.apache.hyracks.algebricks.core.algebra.operators.physical.InMemoryStableSortPOperator) LinkedList(java.util.LinkedList) Mutable(org.apache.commons.lang3.mutable.Mutable) ILogicalExpression(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression) VariableReferenceExpression(org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression) LocalOrderProperty(org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty) InMemoryStableSortPOperator(org.apache.hyracks.algebricks.core.algebra.operators.physical.InMemoryStableSortPOperator) AbstractStableSortPOperator(org.apache.hyracks.algebricks.core.algebra.operators.physical.AbstractStableSortPOperator) StableSortPOperator(org.apache.hyracks.algebricks.core.algebra.operators.physical.StableSortPOperator) Pair(org.apache.hyracks.algebricks.common.utils.Pair) MutableObject(org.apache.commons.lang3.mutable.MutableObject)

Aggregations

LinkedList (java.util.LinkedList)1 Mutable (org.apache.commons.lang3.mutable.Mutable)1 MutableObject (org.apache.commons.lang3.mutable.MutableObject)1 Pair (org.apache.hyracks.algebricks.common.utils.Pair)1 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)1 VariableReferenceExpression (org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression)1 OrderOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.OrderOperator)1 IOrder (org.apache.hyracks.algebricks.core.algebra.operators.logical.OrderOperator.IOrder)1 AbstractStableSortPOperator (org.apache.hyracks.algebricks.core.algebra.operators.physical.AbstractStableSortPOperator)1 InMemoryStableSortPOperator (org.apache.hyracks.algebricks.core.algebra.operators.physical.InMemoryStableSortPOperator)1 StableSortPOperator (org.apache.hyracks.algebricks.core.algebra.operators.physical.StableSortPOperator)1 LocalOrderProperty (org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty)1 OrderColumn (org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn)1