use of io.mycat.config.ServerConfig in project Mycat2 by MyCATApache.
the class SQLRBORewriter method pushDownJoinByNormalTableOrGlobalTable.
private static Optional<RelNode> pushDownJoinByNormalTableOrGlobalTable(Join join, MycatView left, MycatView right) {
Distribution ldistribution = left.getDistribution();
Distribution rdistribution = right.getDistribution();
Distribution.Type lType = ldistribution.type();
Distribution.Type rType = rdistribution.type();
boolean asBroadcast = ldistribution.canAsBroadcast(rdistribution);
if (lType == Distribution.Type.SHARDING && (rType == Distribution.Type.BROADCAST || rType == Distribution.Type.PHY && asBroadcast)) {
switch(join.getJoinType()) {
case INNER:
case LEFT:
case SEMI:
case ANTI:
break;
case RIGHT:
RelHint lastPushJoinHint = HintTools.getLastPushJoinHint(join.getHints());
if (lastPushJoinHint != null) {
if ("push_down_join_broadcast".equalsIgnoreCase(lastPushJoinHint.hintName)) {
break;
}
}
ServerConfig serverConfig = getServerConfig();
if (serverConfig.isForcedPushDownBroadcast()) {
break;
}
return Optional.empty();
case FULL:
return Optional.empty();
}
} else if ((lType == Distribution.Type.BROADCAST || lType == Distribution.Type.PHY && asBroadcast) && rType == Distribution.Type.SHARDING) {
switch(join.getJoinType()) {
case INNER:
case RIGHT:
break;
case SEMI:
case ANTI:
case LEFT:
RelHint lastPushJoinHint = HintTools.getLastPushJoinHint(join.getHints());
if (lastPushJoinHint != null) {
if ("push_down_join_broadcast".equalsIgnoreCase(lastPushJoinHint.hintName)) {
break;
}
}
ServerConfig serverConfig = getServerConfig();
if (serverConfig.isForcedPushDownBroadcast()) {
break;
}
return Optional.empty();
case FULL:
return Optional.empty();
}
} else if (lType == Distribution.Type.PHY && rType == Distribution.Type.BROADCAST || (lType == Distribution.Type.BROADCAST && rType == Distribution.Type.PHY)) {
switch(join.getJoinType()) {
case INNER:
case LEFT:
case SEMI:
case ANTI:
case RIGHT:
break;
case FULL:
return Optional.empty();
}
} else if (lType == Distribution.Type.PHY && rType == Distribution.Type.PHY) {
} else if (lType == Distribution.Type.BROADCAST && rType == Distribution.Type.BROADCAST) {
} else {
return Optional.empty();
}
return ldistribution.join(rdistribution).map(distribution -> MycatView.ofBottom(join.copy(join.getTraitSet(), ImmutableList.of(left.getRelNode(), right.getRelNode())), distribution));
}
Aggregations