Package org.apache.storm.starter.tools
Class RankableObjectWithFields
java.lang.Object
org.apache.storm.starter.tools.RankableObjectWithFields
- All Implemented Interfaces:
Serializable
,Comparable<Rankable>
,Rankable
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:
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
RankableObjectWithFields
-
-
Method Details
-
from
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
-
getObject
-
getCount
public long getCount() -
getFields
Get fields.- Returns:
- an immutable list of any additional data fields of the object (may be empty but will never be null)
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Rankable>
-
equals
-
hashCode
public int hashCode() -
toString
-
copy
Note: We do not defensively copy the wrapped object and any accompanying fields. We do guarantee, however, do return a defensive (shallow) copy of the List object that is wrapping any accompanying fields.
-