public class HashEquiJoin extends Operator
| Modifier and Type | Field and Description |
|---|---|
private DbIterator |
child1 |
private DbIterator |
child2 |
private TupleDesc |
comboTD |
(package private) java.util.Iterator<Tuple> |
listIt |
(package private) java.util.HashMap<java.lang.Object,java.util.ArrayList<Tuple>> |
map |
static int |
MAP_SIZE |
private JoinPredicate |
pred |
private static long |
serialVersionUID |
private Tuple |
t1 |
private Tuple |
t2 |
| Constructor and Description |
|---|
HashEquiJoin(JoinPredicate p,
DbIterator child1,
DbIterator child2)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this iterator.
|
protected Tuple |
fetchNext()
Returns the next Tuple in the iterator, or null if the iteration is
finished.
|
DbIterator[] |
getChildren() |
java.lang.String |
getJoinField1Name() |
java.lang.String |
getJoinField2Name() |
JoinPredicate |
getJoinPredicate() |
TupleDesc |
getTupleDesc()
Returns the TupleDesc associated with this DbIterator.
|
private boolean |
loadMap() |
void |
open()
Opens the iterator.
|
private Tuple |
processList()
Returns the next tuple generated by the join, or null if there are no
more tuples.
|
void |
rewind()
Resets the iterator to the start.
|
void |
setChildren(DbIterator[] children)
Set the children(child) of this operator.
|
getEstimatedCardinality, hasNext, next, setEstimatedCardinalityprivate static final long serialVersionUID
private JoinPredicate pred
private DbIterator child1
private DbIterator child2
private TupleDesc comboTD
private transient Tuple t1
private transient Tuple t2
java.util.HashMap<java.lang.Object,java.util.ArrayList<Tuple>> map
public static final int MAP_SIZE
transient java.util.Iterator<Tuple> listIt
public HashEquiJoin(JoinPredicate p, DbIterator child1, DbIterator child2)
p - The predicate to use to join the childrenchild1 - Iterator for the left(outer) relation to joinchild2 - Iterator for the right(inner) relation to joinpublic JoinPredicate getJoinPredicate()
public TupleDesc getTupleDesc()
DbIteratorgetTupleDesc in interface DbIteratorgetTupleDesc in class Operatorpublic java.lang.String getJoinField1Name()
public java.lang.String getJoinField2Name()
private boolean loadMap()
throws DbException,
TransactionAbortedException
public void open()
throws DbException,
java.util.NoSuchElementException,
TransactionAbortedException
DbIteratoropen in interface DbIteratoropen in class OperatorDbException - when there are problems opening/accessing the database.java.util.NoSuchElementExceptionTransactionAbortedExceptionpublic void close()
Operatorclose in interface DbIteratorclose in class Operatorpublic void rewind()
throws DbException,
TransactionAbortedException
DbIteratorDbException - when rewind is unsupported.TransactionAbortedExceptionprivate Tuple processList() throws TransactionAbortedException, DbException
Note that the tuples returned from this particular implementation of Join are simply the concatenation of joining tuples from the left and right relation. Therefore, there will be two copies of the join attribute in the results. (Removing such duplicate columns can be done with an additional projection operator if needed.)
For example, if one tuple is {1,2,3} and the other tuple is {1,5,6}, joined on equality of the first column, then this returns {1,2,3,1,5,6}.
TransactionAbortedExceptionDbExceptionJoinPredicate.filter(simpledb.Tuple, simpledb.Tuple)protected Tuple fetchNext() throws TransactionAbortedException, DbException
Operatornext
and hasNext.fetchNext in class OperatorTransactionAbortedExceptionDbExceptionpublic DbIterator[] getChildren()
getChildren in class Operatorpublic void setChildren(DbIterator[] children)
OperatorsetChildren in class Operatorchildren - the DbIterators which are to be set as the children(child) of
this operator