Package org.apache.storm.starter.tools
Class RankableObjectWithFields
- java.lang.Object
-
- org.apache.storm.starter.tools.RankableObjectWithFields
-
- All Implemented Interfaces:
Serializable,Comparable<Rankable>,Rankable
public class RankableObjectWithFields extends Object implements Rankable, Serializable
This class wraps an objects and its associated count, including any additional data fields. This class can be used, for instance, to track the number of occurrences of an object in a Storm topology.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description RankableObjectWithFields(Object obj, long count, Object... otherFields)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Rankable other)Rankablecopy()Note: We do not defensively copy the wrapped object and any accompanying fields.booleanequals(Object o)static RankableObjectWithFieldsfrom(Tuple tuple)Construct a new instance based on the providedTuple.longgetCount()List<Object>getFields()Get fields.ObjectgetObject()inthashCode()StringtoString()
-
-
-
Method Detail
-
from
public static RankableObjectWithFields from(Tuple tuple)
Construct a new instance based on the providedTuple. This method expects the object to be ranked in the first field (index 0) of the provided tuple, and the number of occurrences of the object (its count) in the second field (index 1). Any further fields in the tuple will be extracted and tracked, too. These fields can be accessed viagetFields().- Parameters:
tuple-- Returns:
- new instance based on the provided tuple
-
getFields
public List<Object> getFields()
Get fields.- Returns:
- an immutable list of any additional data fields of the object (may be empty but will never be null)
-
compareTo
public int compareTo(Rankable other)
- Specified by:
compareToin interfaceComparable<Rankable>
-
-