public class Join extends Operator
Modifier and Type | Field and Description |
---|---|
private DbIterator |
child1 |
private DbIterator |
child2 |
private JoinPredicate |
predicate |
private static long |
serialVersionUID |
(package private) java.util.Iterator<Tuple> |
tuples |
Constructor and Description |
---|
Join(JoinPredicate predicate,
DbIterator child1,
DbIterator child2)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close iterators
|
protected Tuple |
fetchNext()
Returns the next tuple generated by the join, or null if there are no
more tuples.
|
DbIterator[] |
getChildren() |
java.lang.String |
getJoinField1Name() |
java.lang.String |
getJoinField2Name() |
JoinPredicate |
getJoinPredicate() |
TupleDesc |
getTupleDesc()
Returns the TupleDesc associated with this DbIterator.
|
void |
open()
Open iterators
|
void |
rewind()
Rewind the iterators
|
void |
setChildren(DbIterator[] children)
Set the children(child) of this operator.
|
getEstimatedCardinality, hasNext, next, setEstimatedCardinality
private static final long serialVersionUID
private JoinPredicate predicate
private DbIterator child1
private DbIterator child2
java.util.Iterator<Tuple> tuples
public Join(JoinPredicate predicate, DbIterator child1, DbIterator child2)
predicate
- 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 java.lang.String getJoinField1Name()
public java.lang.String getJoinField2Name()
public TupleDesc getTupleDesc()
DbIterator
getTupleDesc
in interface DbIterator
getTupleDesc
in class Operator
for possible
implementation logic.
public void open() throws DbException, java.util.NoSuchElementException, TransactionAbortedException
open
in interface DbIterator
open
in class Operator
DbException
java.util.NoSuchElementException
TransactionAbortedException
public void close()
close
in interface DbIterator
close
in class Operator
public void rewind() throws DbException, TransactionAbortedException
protected Tuple fetchNext() 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, if an equality predicate is used 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}.
fetchNext
in class Operator
TransactionAbortedException
DbException
JoinPredicate.filter(simpledb.Tuple, simpledb.Tuple)
public DbIterator[] getChildren()
getChildren
in class Operator
public void setChildren(DbIterator[] children)
setChildren
in class Operator
children
- the DbIterators which are to be set as the children(child) of
this operator