use of com.actiontech.dble.plan.node.TableNode in project dble by actiontech.
the class PlanUtil method findColumnInTableLeaf.
/**
* check obj is the column of an real tablenode ,if obj is not Column Type return null
* <the column to be found must be table's parent's column>
*
* @param column column
* @param node node
* @return the target table node and the column
*/
public static Pair<TableNode, ItemField> findColumnInTableLeaf(ItemField column, PlanNode node) {
// union return
if (node.type() == PlanNodeType.MERGE)
return null;
NamedField tmpField = new NamedField(column.getTableName(), column.getItemName(), null);
NamedField coutField = node.getInnerFields().get(tmpField);
if (coutField == null)
return null;
else if (node.type() == PlanNodeType.TABLE) {
return new Pair<>((TableNode) node, column);
} else {
PlanNode referNode = column.getReferTables().iterator().next();
Item cSel = referNode.getOuterFields().get(coutField);
if (cSel instanceof ItemField) {
return findColumnInTableLeaf((ItemField) cSel, referNode);
} else {
return null;
}
}
}
use of com.actiontech.dble.plan.node.TableNode in project dble by actiontech.
the class JoinStrategyChooser method tryInnerJoinNestLoop.
/**
* @param jn
* @return
*/
private boolean tryInnerJoinNestLoop() {
TableNode tnLeft = (TableNode) jn.getLeftNode();
TableNode tnRight = (TableNode) jn.getRightNode();
boolean isLeftSmall = isSmallTable(tnLeft);
boolean isRightSmall = isSmallTable(tnRight);
if (isLeftSmall && isRightSmall)
return false;
else if (!isLeftSmall && !isRightSmall)
return false;
else {
handleNestLoopStrategy(isLeftSmall);
return true;
}
}
use of com.actiontech.dble.plan.node.TableNode in project dble by actiontech.
the class MyOptimizer method updateReferedTableNodes.
private static List<TableNode> updateReferedTableNodes(PlanNode node) {
List<TableNode> subTables = new ArrayList<>();
for (PlanNode childNode : node.getChildren()) {
List<TableNode> childSubTables = updateReferedTableNodes(childNode);
node.getReferedTableNodes().addAll(childSubTables);
subTables.addAll(childSubTables);
}
for (ItemSubQuery subQuery : node.getSubQueries()) {
List<TableNode> childSubTables = subQuery.getPlanNode().getReferedTableNodes();
node.getReferedTableNodes().addAll(childSubTables);
subTables.addAll(childSubTables);
}
return subTables;
}
use of com.actiontech.dble.plan.node.TableNode in project dble by actiontech.
the class ERJoinChooser method getLeftOutJoinChildER.
private ERTable getLeftOutJoinChildER(JoinNode joinNode, PlanNode child, Item onItem) {
if (PlanUtil.existAggregate(child))
return null;
else if (!PlanUtil.isERNode(child) && child.type() != PlanNode.PlanNodeType.TABLE)
return null;
if (onItem == null || !onItem.type().equals(Item.ItemType.FIELD_ITEM))
return null;
Pair<TableNode, ItemField> joinColumnInfo = PlanUtil.findColumnInTableLeaf((ItemField) onItem, joinNode);
if (joinColumnInfo == null)
return null;
TableNode tn = joinColumnInfo.getKey();
ItemField col = joinColumnInfo.getValue();
ERTable erKey = new ERTable(tn.getSchema(), tn.getPureName(), col.getItemName());
if (child.type() == PlanNode.PlanNodeType.TABLE) {
return erKey;
} else {
// joinnode
List<ERTable> erKeys = ((JoinNode) child).getERkeys();
for (ERTable cerKey : erKeys) {
if (isErRelation(erKey, cerKey))
return erKey;
}
return null;
}
}
use of com.actiontech.dble.plan.node.TableNode in project dble by actiontech.
the class ERJoinChooser method getERKey.
private ERTable getERKey(PlanNode tn, Item c) {
if (!(c instanceof ItemField))
return null;
if (tn.type() != PlanNode.PlanNodeType.TABLE && !PlanUtil.isERNode(tn)) {
return null;
}
Pair<TableNode, ItemField> pair = PlanUtil.findColumnInTableLeaf((ItemField) c, tn);
if (pair == null)
return null;
TableNode tableNode = pair.getKey();
ItemField col = pair.getValue();
ERTable cm = new ERTable(tableNode.getSchema(), tableNode.getPureName(), col.getItemName());
if (tn.type() == PlanNode.PlanNodeType.TABLE) {
return cm;
} else {
List<ERTable> erList = ((JoinNode) tn).getERkeys();
for (ERTable cerKey : erList) {
if (isErRelation(cm, cerKey))
return cm;
}
return null;
}
}
Aggregations