本文整理汇总了Java中com.taobao.tddl.optimizer.core.ast.query.JoinNode.getRightNode方法的典型用法代码示例。如果您正苦于以下问题:Java JoinNode.getRightNode方法的具体用法?Java JoinNode.getRightNode怎么用?Java JoinNode.getRightNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.taobao.tddl.optimizer.core.ast.query.JoinNode
的用法示例。
在下文中一共展示了JoinNode.getRightNode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isJoinOnPartition
import com.taobao.tddl.optimizer.core.ast.query.JoinNode; //导入方法依赖的package包/类
/**
* 找到join条件完全是分区键的filter,返回null代表没找到,否则返回join条件
*/
private static PartitionJoinResult isJoinOnPartition(JoinNode join) {
QueryTreeNode left = join.getLeftNode();
QueryTreeNode right = join.getRightNode();
PartitionJoinResult leftResult = isJoinOnPartitionOneSide(join.getLeftKeys(), left);
PartitionJoinResult rightResult = isJoinOnPartitionOneSide(join.getRightKeys(), right);
// 允许一张单表和一张广播表的组合
if (!leftResult.flag && !rightResult.broadcast) {
return leftResult;
}
if (!rightResult.flag && !leftResult.broadcast) {
return rightResult;
}
PartitionJoinResult result = new PartitionJoinResult();
result.broadcast = leftResult.broadcast || rightResult.broadcast;
result.flag = StringUtils.equalsIgnoreCase(leftResult.joinGroup, rightResult.joinGroup) || result.broadcast;
result.joinGroup = leftResult.joinGroup;
result.joinFilters = join.getJoinFilter();
return result;
}
示例2: isJoinOnPartition
import com.taobao.tddl.optimizer.core.ast.query.JoinNode; //导入方法依赖的package包/类
/**
* 找到join条件完全是分区键的filter,返回null代表没找到,否则返回join条件
*/
private static PartitionJoinResult isJoinOnPartition(JoinNode join) {
QueryTreeNode left = join.getLeftNode();
QueryTreeNode right = join.getRightNode();
PartitionJoinResult leftResult = isJoinOnPartitionOneSide(join.getLeftKeys(), left);
if (!leftResult.flag) {
return leftResult;
}
PartitionJoinResult rightResult = isJoinOnPartitionOneSide(join.getRightKeys(), right);
if (!rightResult.flag) {
return rightResult;
}
PartitionJoinResult result = new PartitionJoinResult();
result.broadcast = leftResult.broadcast || rightResult.broadcast;
result.flag = StringUtils.equalsIgnoreCase(leftResult.joinGroup, rightResult.joinGroup) || result.broadcast;
result.joinGroup = leftResult.joinGroup;
result.joinFilters = join.getJoinFilter();
return result;
}
示例3: findJoinKeysAndRemoveIt
import com.taobao.tddl.optimizer.core.ast.query.JoinNode; //导入方法依赖的package包/类
/**
* 将原本的Join的where条件中的a.id=b.id构建为join条件,并从where条件中移除
*/
private static void findJoinKeysAndRemoveIt(List<IFilter> DNFNode, JoinNode join) {
// filter中可能包含join列,如id=id
// 目前必须满足以下条件
// 1、不包含or
// 2、=连接
List<IFilter> joinFilters = new LinkedList();
if (isFilterContainsColumnJoin(DNFNode)) {
List<Object> leftJoinKeys = new ArrayList<Object>();
List<Object> rightJoinKeys = new ArrayList<Object>();
for (IFilter sub : DNFNode) { // 一定是简单条件
if (!(sub instanceof IBooleanFilter)) {
continue;
}
ISelectable[] keys = getJoinKeysWithColumnJoin((IBooleanFilter) sub);
if (keys != null) {// 存在join column
if (join.getLeftNode().hasColumn(keys[0])) {
if (!join.getLeftNode().hasColumn(keys[1])) {
if (join.getRightNode().hasColumn(keys[1])) {
leftJoinKeys.add(keys[0]);
rightJoinKeys.add(keys[1]);
joinFilters.add(sub);
join.addJoinFilter((IBooleanFilter) sub);
} else {
throw new IllegalArgumentException("join查询表右边不包含join column,请修改查询语句...");
}
} else {
if (!(join.getLeftNode() instanceof JoinNode)) {
throw new IllegalArgumentException("join查询的join column都在左表上,请修改查询语句...");
}
}
} else if (join.getLeftNode().hasColumn(keys[1])) {
if (!join.getLeftNode().hasColumn(keys[0])) {
if (join.getRightNode().hasColumn(keys[0])) {
leftJoinKeys.add(keys[1]);
rightJoinKeys.add(keys[0]);
joinFilters.add(sub);
// 交换一下
Object tmp = ((IBooleanFilter) sub).getColumn();
((IBooleanFilter) sub).setColumn(((IBooleanFilter) sub).getValue());
((IBooleanFilter) sub).setValue(tmp);
join.addJoinFilter((IBooleanFilter) sub);
} else {
throw new IllegalArgumentException("join查询表左边不包含join column,请修改查询语句...");
}
} else {
if (!(join.getRightNode() instanceof JoinNode)) {
throw new IllegalArgumentException("join查询的join column都在右表上,请修改查询语句...");
}
}
}
}
}
DNFNode.removeAll(joinFilters);
}
join.build();
}
示例4: findJoinKeysAndRemoveIt
import com.taobao.tddl.optimizer.core.ast.query.JoinNode; //导入方法依赖的package包/类
/**
* 将原本的Join的where条件中的a.id=b.id构建为join条件,并从where条件中移除
*/
private static void findJoinKeysAndRemoveIt(List<IFilter> DNFNode, JoinNode join) throws QueryException {
// filter中可能包含join列,如id=id
// 目前必须满足以下条件
// 1、不包含or
// 2、=连接
List<IFilter> joinFilters = new LinkedList();
if (isFilterContainsColumnJoin(DNFNode)) {
List<Object> leftJoinKeys = new ArrayList<Object>();
List<Object> rightJoinKeys = new ArrayList<Object>();
for (IFilter sub : DNFNode) { // 一定是简单条件
ISelectable[] keys = getJoinKeysWithColumnJoin((IBooleanFilter) sub);
if (keys != null) {// 存在join column
if (join.getLeftNode().hasColumn(keys[0])) {
if (!join.getLeftNode().hasColumn(keys[1])) {
if (join.getRightNode().hasColumn(keys[1])) {
leftJoinKeys.add(keys[0]);
rightJoinKeys.add(keys[1]);
joinFilters.add(sub);
join.addJoinFilter((IBooleanFilter) sub);
} else {
throw new IllegalArgumentException("join查询表右边不包含join column,请修改查询语句...");
}
} else {
if (!(join.getLeftNode() instanceof JoinNode)) {
throw new IllegalArgumentException("join查询的join column都在左表上,请修改查询语句...");
}
}
} else if (join.getLeftNode().hasColumn(keys[1])) {
if (!join.getLeftNode().hasColumn(keys[0])) {
if (join.getRightNode().hasColumn(keys[0])) {
leftJoinKeys.add(keys[1]);
rightJoinKeys.add(keys[0]);
joinFilters.add(sub);
// 交换一下
Object tmp = ((IBooleanFilter) sub).getColumn();
((IBooleanFilter) sub).setColumn(((IBooleanFilter) sub).getValue());
((IBooleanFilter) sub).setValue(tmp);
join.addJoinFilter((IBooleanFilter) sub);
} else {
throw new IllegalArgumentException("join查询表左边不包含join column,请修改查询语句...");
}
} else {
if (!(join.getRightNode() instanceof JoinNode)) {
throw new IllegalArgumentException("join查询的join column都在右表上,请修改查询语句...");
}
}
}
}
}
DNFNode.removeAll(joinFilters);
}
join.build();
}