use of org.apache.hyracks.algebricks.core.algebra.expressions.BroadcastExpressionAnnotation.BroadcastSide in project asterixdb by apache.
the class JoinUtils method setJoinAlgorithmAndExchangeAlgo.
public static void setJoinAlgorithmAndExchangeAlgo(AbstractBinaryJoinOperator op, IOptimizationContext context) throws AlgebricksException {
List<LogicalVariable> sideLeft = new LinkedList<>();
List<LogicalVariable> sideRight = new LinkedList<>();
List<LogicalVariable> varsLeft = op.getInputs().get(0).getValue().getSchema();
List<LogicalVariable> varsRight = op.getInputs().get(1).getValue().getSchema();
if (isHashJoinCondition(op.getCondition().getValue(), varsLeft, varsRight, sideLeft, sideRight)) {
BroadcastSide side = getBroadcastJoinSide(op.getCondition().getValue(), varsLeft, varsRight);
if (side == null) {
setHashJoinOp(op, JoinPartitioningType.PAIRWISE, sideLeft, sideRight, context);
} else {
switch(side) {
case RIGHT:
setHashJoinOp(op, JoinPartitioningType.BROADCAST, sideLeft, sideRight, context);
break;
case LEFT:
Mutable<ILogicalOperator> opRef0 = op.getInputs().get(0);
Mutable<ILogicalOperator> opRef1 = op.getInputs().get(1);
ILogicalOperator tmp = opRef0.getValue();
opRef0.setValue(opRef1.getValue());
opRef1.setValue(tmp);
setHashJoinOp(op, JoinPartitioningType.BROADCAST, sideRight, sideLeft, context);
break;
default:
setHashJoinOp(op, JoinPartitioningType.PAIRWISE, sideLeft, sideRight, context);
}
}
} else {
setNestedLoopJoinOp(op, context);
}
}
use of org.apache.hyracks.algebricks.core.algebra.expressions.BroadcastExpressionAnnotation.BroadcastSide in project asterixdb by apache.
the class JoinUtils method getBroadcastJoinSide.
private static BroadcastSide getBroadcastJoinSide(ILogicalExpression e, List<LogicalVariable> varsLeft, List<LogicalVariable> varsRight) {
if (e.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
return null;
}
AbstractFunctionCallExpression fexp = (AbstractFunctionCallExpression) e;
IExpressionAnnotation ann = fexp.getAnnotations().get(BroadcastExpressionAnnotation.BROADCAST_ANNOTATION_KEY);
if (ann == null) {
return null;
}
BroadcastSide side = (BroadcastSide) ann.getObject();
if (side == null) {
return null;
}
int i;
switch(side) {
case LEFT:
i = 0;
break;
case RIGHT:
i = 1;
break;
default:
return null;
}
ArrayList<LogicalVariable> vars = new ArrayList<>();
fexp.getArguments().get(i).getValue().getUsedVariables(vars);
if (varsLeft.containsAll(vars)) {
return BroadcastSide.LEFT;
} else if (varsRight.containsAll(vars)) {
return BroadcastSide.RIGHT;
} else {
return null;
}
}
Aggregations