/** * We create a unique index for recording seen nodes by * treating the joined indexes as a base (max-index) number. */ private int getSeenIndex(Join join) { // we reserve indexes 0..._graph.size() for joined tables return join.getIndex1() * _graph.size() + join.getIndex2() + _graph.size(); }
/** * We create a unique index for recording seen nodes by * treating the joined indexes as a base (max-index) number. */ private int getSeenIndex(Join join) { // we reserve indexes 0..._graph.size() for joined tables return join.getIndex1() * _graph.size() + join.getIndex2() + _graph.size(); }
/** * We create a unique index for recording seen nodes by * treating the joined indexes as a base (max-index) number. */ private int getSeenIndex(Join join) { // we reserve indexes 0..._graph.size() for joined tables return join.getIndex1() * _graph.size() + join.getIndex2() + _graph.size(); }
/** * We create a unique index for recording seen nodes by * treating the joined indexes as a base (max-index) number. */ private int getSeenIndex(Join join) { // we reserve indexes 0..._graph.size() for joined tables return join.getIndex1() * _graph.size() + join.getIndex2() + _graph.size(); }
/** * We create a unique index for recording seen nodes by * treating the joined indexes as a base (max-index) number. */ private int getSeenIndex(Join join) { // we reserve indexes 0..._graph.size() for joined tables return join.getIndex1() * _graph.size() + join.getIndex2() + _graph.size(); }
/** * Add the give join to our graph. */ private void addNode(Join join) { _sorted = null; int size = Math.max(join.getIndex1(), join.getIndex2()) + 1; while (_graph.size() < size) _graph.add(null); Node node = (Node) _graph.get(join.getIndex1()); if (node == null) _graph.set(join.getIndex1(), new Node(join, true)); else { while (node.next != null) node = node.next; node.next = new Node(join, true); } node = (Node) _graph.get(join.getIndex2()); if (node == null) _graph.set(join.getIndex2(), new Node(join, false)); else { while (node.next != null) node = node.next; node.next = new Node(join, false); } _size++; }
public boolean remove(Join join) { if (join == null || _graph.size() <= join.getIndex1()) return false; if (remove(join, join.getIndex1())) { _size--; return remove(join, join.getIndex2()); } return false; }
public boolean remove(Join join) { if (join == null || _graph.size() <= join.getIndex1()) return false; if (remove(join, join.getIndex1())) { _size--; return remove(join, join.getIndex2()); } return false; }
public boolean remove(Join join) { if (join == null || _graph.size() <= join.getIndex1()) return false; if (remove(join, join.getIndex1())) { _size--; return remove(join, join.getIndex2()); } return false; }
public boolean remove(Join join) { if (join == null || _graph.size() <= join.getIndex1()) return false; if (remove(join, join.getIndex1())) { _size--; return remove(join, join.getIndex2()); } return false; }
public boolean remove(Join join) { if (join == null || _graph.size() <= join.getIndex1()) return false; if (remove(join, join.getIndex1())) { _size--; return remove(join, join.getIndex2()); } return false; }
private void setCorrelated(Join j) { if (_sel._parent == null) return; if (_sel._aliases == null) { j.setIsNotMyJoin(); return; } Object aliases[] = _sel._aliases.values().toArray(); boolean found1 = false; boolean found2 = false; for (int i = 0; i < aliases.length; i++) { int alias = ((Integer)aliases[i]).intValue(); if (alias == j.getIndex1()) found1 = true; if (alias == j.getIndex2()) found2 = true; } if (found1 && found2) return; else if (!found1 && !found2) { j.setIsNotMyJoin(); return; } else { j.setCorrelated(); } }
private boolean correlatedJoinCondition(Join join, Select sel) { if (!join.isCorrelated()) return false; Iterator itr = sel.getJoinIterator(); boolean skip = false; //if table1 in join is in the main query, table2 is in //subquery, and table2 participates in other joins //in subquery, the join condition can only be placed in //the where clause in the subquery while (itr.hasNext()) { Join join1 = (Join) itr.next(); if (join == join1 && !join.isForeignKeyInversed()) { continue; } if (join.getIndex2() == join1.getIndex1() || join.getIndex2() == join1.getIndex2()) { skip = true; if (join.getForeignKey() != null){ SQLBuffer where = new SQLBuffer(this); where.append("(").append(toTraditionalJoin(join)).append(")"); sel.where(where.getSQL()); } break; } } return skip; }
private void addJoinsToParent(SelectImpl parent, Join join) { if (parent._aliases == null) return; Object aliases[] = parent._aliases.values().toArray(); boolean found1 = false; boolean found2 = false; for (int i = 0; i < aliases.length; i++) { int alias = ((Integer)aliases[i]).intValue(); if (alias == join.getIndex1()) found1 = true; if (alias == join.getIndex2()) found2 = true; } if (found1 && found2) { // this is my join, add join if (parent._joins == null) parent._joins = new SelectJoins(parent); SelectJoins p = parent._joins; if (p.joins() == null) p.setJoins(new JoinSet()); p.joins().add(join); } else if (parent._parent != null) addJoinsToParent(parent._parent, join); }
private void addJoinsToParent(SelectImpl parent, Join join) { if (parent._aliases == null) return; Object aliases[] = parent._aliases.values().toArray(); boolean found1 = false; boolean found2 = false; for (int i = 0; i < aliases.length; i++) { int alias = ((Integer)aliases[i]).intValue(); if (alias == join.getIndex1()) found1 = true; if (alias == join.getIndex2()) found2 = true; } if (found1 && found2) { // this is my join, add join if (parent._joins == null) parent._joins = new SelectJoins(parent); SelectJoins p = parent._joins; if (p.joins() == null) p.setJoins(new JoinSet()); p.joins().add(join); } else if (parent._parent != null) addJoinsToParent(parent._parent, join); }
public boolean add(Join join) { if (join.getType() == Join.TYPE_OUTER) { // outer shouldn't override any other join type if (!contains(join)) { addNode(join); return true; } return false; } // replace any existing join with this one Node node = getNode(join, join.getIndex1()); if (node != null) { node.join = join; getNode(join, join.getIndex2()).join = join; _sorted = null; } else addNode(join); return true; }
public boolean add(Join join) { if (join.getType() == Join.TYPE_OUTER) { // outer shouldn't override any other join type if (!contains(join)) { addNode(join); return true; } return false; } // replace any existing join with this one Node node = getNode(join, join.getIndex1()); if (node != null) { node.join = join; getNode(join, join.getIndex2()).join = join; _sorted = null; } else addNode(join); return true; }
public boolean add(Join join) { if (join.getType() == Join.TYPE_OUTER) { // outer shouldn't override any other join type if (!contains(join)) { addNode(join); return true; } return false; } // replace any existing join with this one Node node = getNode(join, join.getIndex1()); if (node != null) { node.join = join; getNode(join, join.getIndex2()).join = join; _sorted = null; } else addNode(join); return true; }
public boolean add(Join join) { if (join.getType() == Join.TYPE_OUTER) { // outer shouldn't override any other join type if (!contains(join)) { addNode(join); return true; } return false; } // replace any existing join with this one Node node = getNode(join, join.getIndex1()); if (node != null) { node.join = join; getNode(join, join.getIndex2()).join = join; _sorted = null; } else addNode(join); return true; }
public boolean add(Join join) { if (join.getType() == Join.TYPE_OUTER) { // outer shouldn't override any other join type if (!contains(join)) { addNode(join); return true; } return false; } // replace any existing join with this one Node node = getNode(join, join.getIndex1()); if (node != null) { node.join = join; getNode(join, join.getIndex2()).join = join; _sorted = null; } else addNode(join); return true; }