private Map<LogicalVariable, EquivalenceClass> getOrComputeEqClasses(ILogicalOperator op, IOptimizationContext ctx) throws AlgebricksException { Map<LogicalVariable, EquivalenceClass> eqClasses = ctx.getEquivalenceClassMap(op); if (eqClasses == null) { op.accept(this, ctx); eqClasses = ctx.getEquivalenceClassMap(op); } return eqClasses; }
private Map<LogicalVariable, EquivalenceClass> getOrCreateEqClasses(ILogicalOperator op, IOptimizationContext ctx) throws AlgebricksException { Map<LogicalVariable, EquivalenceClass> eqClasses = ctx.getEquivalenceClassMap(op); if (eqClasses == null) { eqClasses = new HashMap<LogicalVariable, EquivalenceClass>(); ctx.putEquivalenceClassMap(op, eqClasses); } return eqClasses; }
private IPhysicalPropertiesVector newPropertiesDiff(AbstractLogicalOperator newChild, IPhysicalPropertiesVector required, boolean mayExpandPartitioningProperties, IOptimizationContext context) throws AlgebricksException { IPhysicalPropertiesVector newDelivered = newChild.getDeliveredPhysicalProperties(); Map<LogicalVariable, EquivalenceClass> newChildEqClasses = context.getEquivalenceClassMap(newChild); List<FunctionalDependency> newChildFDs = context.getFDList(newChild); if (newChildEqClasses == null || newChildFDs == null) { FDsAndEquivClassesVisitor fdsVisitor = new FDsAndEquivClassesVisitor(); newChild.accept(fdsVisitor, context); newChildEqClasses = context.getEquivalenceClassMap(newChild); newChildFDs = context.getFDList(newChild); } if (AlgebricksConfig.ALGEBRICKS_LOGGER.isTraceEnabled()) { AlgebricksConfig.ALGEBRICKS_LOGGER.trace( ">>>> Required properties for new op. " + newChild.getPhysicalOperator() + ": " + required + "\n"); } return newDelivered.getUnsatisfiedPropertiesFrom(required, mayExpandPartitioningProperties, newChildEqClasses, newChildFDs); }
UnorderedPartitionedProperty uppreq = (UnorderedPartitionedProperty) requirements; Set<LogicalVariable> modifuppreq = new ListSet<LogicalVariable>(); Map<LogicalVariable, EquivalenceClass> eqmap = context.getEquivalenceClassMap(op); Set<LogicalVariable> covered = new ListSet<LogicalVariable>(); Set<LogicalVariable> keysCurrent = uppreq.getColumnSet();
UnorderedPartitionedProperty uppreq = (UnorderedPartitionedProperty) rqdpp; Set<LogicalVariable> modifuppreq = new ListSet<LogicalVariable>(); Map<LogicalVariable, EquivalenceClass> eqmap = context.getEquivalenceClassMap(op); Set<LogicalVariable> covered = new ListSet<LogicalVariable>();
private IPhysicalOperator createHashConnector(IOptimizationContext ctx, IPhysicalPropertiesVector deliveredByChild, INodeDomain domain, IPhysicalPropertiesVector requiredAtChild, IPartitioningProperty rqdPartitioning, int childIndex, ILogicalOperator parentOp) { IPhysicalOperator hashConnector; List<LogicalVariable> vars = new ArrayList<>(((UnorderedPartitionedProperty) rqdPartitioning).getColumnSet()); String hashMergeHint = (String) ctx.getMetadataProvider().getConfig().get(HASH_MERGE); if (hashMergeHint == null || !hashMergeHint.equalsIgnoreCase(TRUE_CONSTANT)) { hashConnector = new HashPartitionExchangePOperator(vars, domain); return hashConnector; } List<ILocalStructuralProperty> cldLocals = deliveredByChild.getLocalProperties(); List<ILocalStructuralProperty> reqdLocals = requiredAtChild.getLocalProperties(); boolean propWasSet = false; hashConnector = null; if (reqdLocals != null && cldLocals != null && allAreOrderProps(cldLocals)) { AbstractLogicalOperator c = (AbstractLogicalOperator) parentOp.getInputs().get(childIndex).getValue(); Map<LogicalVariable, EquivalenceClass> ecs = ctx.getEquivalenceClassMap(c); List<FunctionalDependency> fds = ctx.getFDList(c); if (PropertiesUtil.matchLocalProperties(reqdLocals, cldLocals, ecs, fds)) { List<OrderColumn> orderColumns = getOrderColumnsFromGroupingProperties(reqdLocals, cldLocals); hashConnector = new HashPartitionMergeExchangePOperator(orderColumns, vars, domain); propWasSet = true; } } if (!propWasSet) { hashConnector = new HashPartitionExchangePOperator(vars, domain); } return hashConnector; }
EquivalenceClass equivClass = new EquivalenceClass(Collections.singletonList(var), var, Collections.singletonList(expr)); Map<LogicalVariable, EquivalenceClass> equivalenceMap = context.getEquivalenceClassMap(operator); if (equivalenceMap == null) { equivalenceMap = new HashMap<LogicalVariable, EquivalenceClass>();
private boolean isRedundantSort(Mutable<ILogicalOperator> opRef, IPhysicalPropertiesVector delivered, IPhysicalPropertiesVector diffOfProperties, IOptimizationContext context) { AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue(); if (op.getOperatorTag() != LogicalOperatorTag.ORDER || (op.getPhysicalOperator().getOperatorTag() != PhysicalOperatorTag.STABLE_SORT && op.getPhysicalOperator().getOperatorTag() != PhysicalOperatorTag.IN_MEMORY_STABLE_SORT) || delivered.getLocalProperties() == null) { return false; } AbstractStableSortPOperator sortOp = (AbstractStableSortPOperator) op.getPhysicalOperator(); sortOp.computeLocalProperties(op); ILocalStructuralProperty orderProp = sortOp.getOrderProperty(); return PropertiesUtil.matchLocalProperties(Collections.singletonList(orderProp), delivered.getLocalProperties(), context.getEquivalenceClassMap(op), context.getFDList(op)); }
VariableReferenceExpression varExpr = (VariableReferenceExpression) fieldExpr; LogicalVariable fieldVar = varExpr.getVariableReference(); Map<LogicalVariable, EquivalenceClass> ecs = context.getEquivalenceClassMap(assignOp); if (ecs == null) { ecs = new HashMap<>();
mayExpandPartitioningProperties, context.getEquivalenceClassMap(child), context.getFDList(child));