public class Aggregate extends Operator
Modifier and Type | Field and Description |
---|---|
private int |
aField |
private Aggregator |
aggregator |
private DbIterator |
child |
private int |
gbField |
private DbIterator |
iterator |
private Aggregator.Op |
op |
private static long |
serialVersionUID |
private TupleDesc |
tupleDesc |
Constructor and Description |
---|
Aggregate(DbIterator child,
int afield,
int gfield,
Aggregator.Op aop)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
aggregateField() |
java.lang.String |
aggregateFieldName() |
Aggregator.Op |
aggregateOp() |
void |
close()
Closes the iterator
|
protected Tuple |
fetchNext()
Returns the next tuple.
|
DbIterator[] |
getChildren() |
TupleDesc |
getTupleDesc()
Returns the TupleDesc of this Aggregate.
|
int |
groupField() |
java.lang.String |
groupFieldName() |
static java.lang.String |
nameOfAggregatorOp(Aggregator.Op aop) |
void |
open()
Opens the iterator
|
void |
rewind()
Rewinds the iterator
|
void |
setChildren(DbIterator[] children)
Set the children(child) of this operator.
|
getEstimatedCardinality, hasNext, next, setEstimatedCardinality
private static final long serialVersionUID
private DbIterator child
private DbIterator iterator
private int aField
private int gbField
private Aggregator.Op op
private TupleDesc tupleDesc
private Aggregator aggregator
public Aggregate(DbIterator child, int afield, int gfield, Aggregator.Op aop)
IntegerAggregator
or StringAggregator
to help
you with your implementation of readNext().child
- The DbIterator that is feeding us tuples.afield
- The column over which we are computing an aggregate.gfield
- The column over which we are grouping the result, or -1 if
there is no groupingaop
- The aggregation operator to usepublic int groupField()
Aggregator.NO_GROUPING
public java.lang.String groupFieldName()
public int aggregateField()
public java.lang.String aggregateFieldName()
public Aggregator.Op aggregateOp()
public static java.lang.String nameOfAggregatorOp(Aggregator.Op aop)
public void open() throws java.util.NoSuchElementException, DbException, TransactionAbortedException
open
in interface DbIterator
open
in class Operator
java.util.NoSuchElementException
- When no element is foundDbException
TransactionAbortedException
protected Tuple fetchNext() throws TransactionAbortedException, DbException
fetchNext
in class Operator
DbException
TransactionAbortedException
public void rewind() throws DbException, TransactionAbortedException
public TupleDesc getTupleDesc()
getTupleDesc
in interface DbIterator
getTupleDesc
in class Operator
public void close()
close
in interface DbIterator
close
in class Operator
public DbIterator[] getChildren()
getChildren
in class Operator
public void setChildren(DbIterator[] children)
Operator
setChildren
in class Operator
children
- the DbIterators which are to be set as the children(child) of
this operator