Search in sources :

Example 1 with PropertyType

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

the class PropertiesUtil method matchNormalizedLocalProperties.

// Checks whether normalized delivered properties can satisfy normalized required property.
private static boolean matchNormalizedLocalProperties(List<ILocalStructuralProperty> reqs, List<ILocalStructuralProperty> dlvds) {
    boolean hasOrderPropertyInReq = false;
    boolean hasGroupingPropertyInReq = false;
    boolean orderPropertyMet = false;
    boolean groupingPropertyMet = false;
    for (ILocalStructuralProperty req : reqs) {
        PropertyType reqType = req.getPropertyType();
        hasOrderPropertyInReq |= reqType == PropertyType.LOCAL_ORDER_PROPERTY;
        hasGroupingPropertyInReq |= reqType == PropertyType.LOCAL_GROUPING_PROPERTY;
        for (ILocalStructuralProperty dlvd : dlvds) {
            PropertyType dlvdType = dlvd.getPropertyType();
            if (reqType == PropertyType.LOCAL_ORDER_PROPERTY && dlvdType != PropertyType.LOCAL_ORDER_PROPERTY) {
                // property.
                continue;
            }
            if (reqType == PropertyType.LOCAL_ORDER_PROPERTY) {
                LocalOrderProperty lop = (LocalOrderProperty) dlvd;
                // It is enough that one required ordering property is met.
                orderPropertyMet |= lop.implies(req);
            } else {
                Set<LogicalVariable> reqdCols = new ListSet<>();
                Set<LogicalVariable> dlvdCols = new ListSet<>();
                req.getColumns(reqdCols);
                dlvd.getColumns(dlvdCols);
                // It is enough that one required grouping property is met.
                groupingPropertyMet |= isPrefixOf(reqdCols.iterator(), dlvdCols.iterator());
            }
        }
    }
    // satisfied and one of required grouping properties is satisfied.
    return (!hasOrderPropertyInReq || orderPropertyMet) && (!hasGroupingPropertyInReq || groupingPropertyMet);
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) ListSet(org.apache.hyracks.algebricks.common.utils.ListSet) PropertyType(org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty.PropertyType)

Example 2 with PropertyType

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

the class AbstractPreclusteredGroupByPOperator method getPropagatedProperty.

// Returns the local structure property that is propagated from an input local structure property
// through a pre-clustered GROUP BY physical operator.
private ILocalStructuralProperty getPropagatedProperty(ILocalStructuralProperty lsp, GroupByOperator gby) {
    PropertyType propertyType = lsp.getPropertyType();
    if (propertyType == PropertyType.LOCAL_GROUPING_PROPERTY) {
        // A new grouping property is generated.
        return new LocalGroupingProperty(new ListSet<>(gby.getGbyVarList()));
    } else {
        LocalOrderProperty lop = (LocalOrderProperty) lsp;
        List<OrderColumn> orderColumns = new ArrayList<>();
        for (OrderColumn oc : lop.getOrderColumns()) {
            LogicalVariable v2 = getLhsGbyVar(gby, oc.getColumn());
            if (v2 != null) {
                orderColumns.add(new OrderColumn(v2, oc.getOrder()));
            } else {
                break;
            }
        }
        // maintained.
        return orderColumns.isEmpty() ? null : new LocalOrderProperty(orderColumns);
    }
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) LocalGroupingProperty(org.apache.hyracks.algebricks.core.algebra.properties.LocalGroupingProperty) LocalOrderProperty(org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty) OrderColumn(org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn) ArrayList(java.util.ArrayList) PropertyType(org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty.PropertyType)

Aggregations

LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)2 PropertyType (org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty.PropertyType)2 ArrayList (java.util.ArrayList)1 ListSet (org.apache.hyracks.algebricks.common.utils.ListSet)1 LocalGroupingProperty (org.apache.hyracks.algebricks.core.algebra.properties.LocalGroupingProperty)1 LocalOrderProperty (org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty)1 OrderColumn (org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn)1