Search in sources :

Example 26 with OrderColumn

use of org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn in project asterixdb by apache.

the class IndexBulkloadPOperator method getRequiredPropertiesForChildren.

@Override
public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) {
    //skVarMap is used to remove duplicated variable references for order operator
    Map<Integer, Object> skVarMap = new HashMap<Integer, Object>();
    List<LogicalVariable> scanVariables = new ArrayList<>();
    scanVariables.addAll(primaryKeys);
    scanVariables.add(new LogicalVariable(-1));
    IPhysicalPropertiesVector physicalProps = dataSourceIndex.getDataSource().getPropertiesProvider().computePropertiesVector(scanVariables);
    List<ILocalStructuralProperty> localProperties = new ArrayList<>();
    List<OrderColumn> orderColumns = new ArrayList<OrderColumn>();
    // OR [token, PK] if the index is not partitioned
    for (LogicalVariable skVar : secondaryKeys) {
        if (!skVarMap.containsKey(skVar.getId())) {
            orderColumns.add(new OrderColumn(skVar, OrderKind.ASC));
            skVarMap.put(skVar.getId(), null);
        }
    }
    for (LogicalVariable pkVar : primaryKeys) {
        orderColumns.add(new OrderColumn(pkVar, OrderKind.ASC));
    }
    localProperties.add(new LocalOrderProperty(orderColumns));
    StructuralPropertiesVector spv = new StructuralPropertiesVector(physicalProps.getPartitioningProperty(), localProperties);
    return new PhysicalRequirements(new IPhysicalPropertiesVector[] { spv }, IPartitioningRequirementsCoordinator.NO_COORDINATION);
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) StructuralPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector) HashMap(java.util.HashMap) OrderColumn(org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn) ArrayList(java.util.ArrayList) IPhysicalPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector) PhysicalRequirements(org.apache.hyracks.algebricks.core.algebra.properties.PhysicalRequirements) LocalOrderProperty(org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty) ILocalStructuralProperty(org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty)

Aggregations

OrderColumn (org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn)26 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)22 ArrayList (java.util.ArrayList)18 LocalOrderProperty (org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty)17 ILocalStructuralProperty (org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty)14 StructuralPropertiesVector (org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector)12 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)7 PhysicalRequirements (org.apache.hyracks.algebricks.core.algebra.properties.PhysicalRequirements)7 LinkedList (java.util.LinkedList)6 IPartitioningProperty (org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty)6 IVariableTypeEnvironment (org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment)5 AbstractLogicalOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator)5 IBinaryComparatorFactoryProvider (org.apache.hyracks.algebricks.data.IBinaryComparatorFactoryProvider)5 INormalizedKeyComputerFactoryProvider (org.apache.hyracks.algebricks.data.INormalizedKeyComputerFactoryProvider)5 IBinaryComparatorFactory (org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory)5 INormalizedKeyComputerFactory (org.apache.hyracks.api.dataflow.value.INormalizedKeyComputerFactory)5 Mutable (org.apache.commons.lang3.mutable.Mutable)4 ListSet (org.apache.hyracks.algebricks.common.utils.ListSet)4 Pair (org.apache.hyracks.algebricks.common.utils.Pair)4 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)4