|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ebay.erl.mobius.core.function.base.Projectable
com.ebay.erl.mobius.core.function.base.GroupFunction
com.ebay.erl.mobius.core.function.Top
public class Top
Returns up to topX
Tuple
in a group.
Natural ordering is used by default. Users can override
the ordering by providing a customized comparator in
Top(Dataset, String[], int, Class)
.
The output result is sorted in the reversed order of the provided comparator.
This product is licensed under the Apache License, Version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0. This product contains portions derived from Apache hadoop which is licensed under the Apache License, Version 2.0, available at http://hadoop.apache.org. © 2007 – 2012 eBay Inc., Evan Chiu, Woody Zhou, Neel Sundaresan
Field Summary |
---|
Fields inherited from class com.ebay.erl.mobius.core.function.base.GroupFunction |
---|
rowsToBeOutputted |
Fields inherited from class com.ebay.erl.mobius.core.function.base.Projectable |
---|
conf, hashCode, inputs, outputSchema, reporter, requireDataFromMultiDatasets |
Constructor Summary | |
---|---|
Top(Dataset ds,
java.lang.String[] inputColumns,
int topX)
Create a Top operation that emit up to
topX rows from the given dataset
ds . |
|
Top(Dataset ds,
java.lang.String[] inputColumns,
int topX,
java.lang.Class<? extends java.util.Comparator<Tuple>> comparator)
Create a Top operation that emit up to
topX rows from the given dataset
ds . |
Method Summary | |
---|---|
void |
consume(Tuple tuple)
Put the tuple into a min heap, once the heap size is greater than the specified topX ,
the smallest element (head of the heap) is poll
out from the heap. |
BigTupleList |
getResult()
Get the computed result. |
void |
reset()
Empty previous result ( rowsToBeOutputted ), reset is
called when the values within a group have been all iterated. |
Methods inherited from class com.ebay.erl.mobius.core.function.base.GroupFunction |
---|
getNoMatchResult, getRowsToBeOutputted, output |
Methods inherited from class com.ebay.erl.mobius.core.function.base.Projectable |
---|
calledByCombiner, equals, getConf, getInputColumns, getOutputSchema, getParticipatedDataset, hashCode, init, isCombinable, requireDataFromMultiDatasets, setCalledByCombiner, setConf, setOutputSchema, setReporter, toString, useGroupKeyOnly |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Top(Dataset ds, java.lang.String[] inputColumns, int topX)
Top
operation that emit up to
topX
rows from the given dataset
ds
.
The ordering is natural ordering by comparing the
value of inputColumns
, in sequence.
public Top(Dataset ds, java.lang.String[] inputColumns, int topX, java.lang.Class<? extends java.util.Comparator<Tuple>> comparator)
Top
operation that emit up to
topX
rows from the given dataset
ds
.
The ordering is defined by the specified comparator
,
note that, the comparator can only access columns in
inputColumns
.
Method Detail |
---|
public void consume(Tuple tuple)
topX
,
the smallest element (head of the heap) is poll
out from the heap.
consume
in class GroupFunction
public BigTupleList getResult()
GroupFunction
The computed result will be cross-product with results from other functions ( if any).
getResult
in class GroupFunction
public void reset()
GroupFunction
rowsToBeOutputted
), reset is
called when the values within a group have been all iterated.
It is important to call super.reset() when override this method in a sub-class, fail to do so, will result in wrong result.
reset
in class GroupFunction
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |