List<Object> keyCols = metadata.getElementIDsInKey(key);
int[] reorder = new int[keyCols.size()];
List<Integer> toCriteria = new ArrayList<Integer>(rightExpressions.size() - keyCols.size());
List<SingleElementSymbol> keyExpressions = right?rightExpressions:leftExpressions;
for (int j = 0; j < keyExpressions.size(); j++) {
SingleElementSymbol ses = keyExpressions.get(j);
if (!(ses instanceof ElementSymbol)) {
continue;
}
ElementSymbol es = (ElementSymbol)ses;
boolean found = false;
for (int i = 0; !found && i < keyCols.size(); i++) {
if (es.getMetadataID().equals(keyCols.get(i))) {
reorder[i] = j;
found = true;
}
}
if (!found) {
toCriteria.add(j);
}
}
List<Criteria> joinCriteria = (List<Criteria>) joinNode.getProperty(Info.JOIN_CRITERIA);
for (int index : toCriteria) {
SingleElementSymbol lses = leftExpressions.get(index);
SingleElementSymbol rses = rightExpressions.get(index);
CompareCriteria cc = new CompareCriteria(lses, CompareCriteria.EQ, rses);
if (joinCriteria == null || joinCriteria.isEmpty()) {
joinCriteria = new ArrayList<Criteria>();
joinCriteria.add(cc);
joinNode.setProperty(Info.JOIN_TYPE, JoinType.JOIN_INNER);