use of org.apache.hyracks.algebricks.core.algebra.properties.FunctionalDependency in project asterixdb by apache.
the class EnforceStructuralPropertiesRule method newPropertiesDiff.
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);
}
AlgebricksConfig.ALGEBRICKS_LOGGER.finest(">>>> Required properties for new op. " + newChild.getPhysicalOperator() + ": " + required + "\n");
return newDelivered.getUnsatisfiedPropertiesFrom(required, mayExpandPartitioningProperties, newChildEqClasses, newChildFDs);
}
use of org.apache.hyracks.algebricks.core.algebra.properties.FunctionalDependency in project asterixdb by apache.
the class AbstractFunctionCallExpression method addFD.
private static final void addFD(Collection<FunctionalDependency> fds, LogicalVariable var1, LogicalVariable var2) {
LinkedList<LogicalVariable> set1 = new LinkedList<LogicalVariable>();
set1.add(var1);
LinkedList<LogicalVariable> set2 = new LinkedList<LogicalVariable>();
set2.add(var2);
FunctionalDependency fd1 = new FunctionalDependency(set1, set2);
fds.add(fd1);
}
use of org.apache.hyracks.algebricks.core.algebra.properties.FunctionalDependency in project asterixdb by apache.
the class FDsAndEquivClassesVisitor method visitDataScanOperator.
@Override
public Void visitDataScanOperator(DataSourceScanOperator op, IOptimizationContext ctx) throws AlgebricksException {
ILogicalOperator inp1 = op.getInputs().get(0).getValue();
Map<LogicalVariable, EquivalenceClass> eqClasses = getOrCreateEqClasses(op, ctx);
Map<LogicalVariable, EquivalenceClass> propagatedEqClasses = getOrComputeEqClasses(inp1, ctx);
eqClasses.putAll(propagatedEqClasses);
ctx.putEquivalenceClassMap(op, eqClasses);
List<FunctionalDependency> fds = new ArrayList<FunctionalDependency>(getOrComputeFDs(inp1, ctx));
ctx.putFDList(op, fds);
op.getDataSource().computeFDs(op.getVariables(), fds);
return null;
}
use of org.apache.hyracks.algebricks.core.algebra.properties.FunctionalDependency in project asterixdb by apache.
the class FDsAndEquivClassesVisitor method visitLeftOuterUnnestMapOperator.
@Override
public Void visitLeftOuterUnnestMapOperator(LeftOuterUnnestMapOperator op, IOptimizationContext ctx) throws AlgebricksException {
// Unlike the unnest-map operator, we propagate all inputs since
// propagateInuput is always true.
Map<LogicalVariable, EquivalenceClass> equivalenceClasses = new HashMap<LogicalVariable, EquivalenceClass>();
List<FunctionalDependency> functionalDependencies = new ArrayList<FunctionalDependency>();
ctx.putEquivalenceClassMap(op, equivalenceClasses);
ctx.putFDList(op, functionalDependencies);
ILogicalOperator childOp = op.getInputs().get(0).getValue();
functionalDependencies.addAll(getOrComputeFDs(childOp, ctx));
equivalenceClasses.putAll(getOrComputeEqClasses(childOp, ctx));
// Like Left-Outer join case, we add functional dependencies.
List<LogicalVariable> leftSideVars = new ArrayList<LogicalVariable>();
List<LogicalVariable> producedVars = new ArrayList<LogicalVariable>();
VariableUtilities.getUsedVariables(op, leftSideVars);
VariableUtilities.getProducedVariables(op, leftSideVars);
functionalDependencies.add(new FunctionalDependency(leftSideVars, producedVars));
return null;
}
use of org.apache.hyracks.algebricks.core.algebra.properties.FunctionalDependency in project asterixdb by apache.
the class FDsAndEquivClassesVisitor method visitLeftOuterJoinOperator.
@Override
public Void visitLeftOuterJoinOperator(LeftOuterJoinOperator op, IOptimizationContext ctx) throws AlgebricksException {
Map<LogicalVariable, EquivalenceClass> equivalenceClasses = new HashMap<LogicalVariable, EquivalenceClass>();
List<FunctionalDependency> functionalDependencies = new ArrayList<FunctionalDependency>();
ctx.putEquivalenceClassMap(op, equivalenceClasses);
ctx.putFDList(op, functionalDependencies);
ILogicalOperator opLeft = op.getInputs().get(0).getValue();
ILogicalOperator opRight = op.getInputs().get(1).getValue();
functionalDependencies.addAll(getOrComputeFDs(opLeft, ctx));
functionalDependencies.addAll(getOrComputeFDs(opRight, ctx));
equivalenceClasses.putAll(getOrComputeEqClasses(opLeft, ctx));
equivalenceClasses.putAll(getOrComputeEqClasses(opRight, ctx));
Collection<LogicalVariable> leftSideVars;
if (opLeft.getSchema() == null) {
leftSideVars = new LinkedList<LogicalVariable>();
VariableUtilities.getLiveVariables(opLeft, leftSideVars);
// actually, not all produced vars. are visible (due to projection)
// so using cached schema is better and faster
} else {
leftSideVars = opLeft.getSchema();
}
ILogicalExpression expr = op.getCondition().getValue();
expr.getConstraintsForOuterJoin(functionalDependencies, leftSideVars);
return null;
}
Aggregations