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.
Constructor and Description |
---|
RankableObjectWithFields(Object obj,
long count,
Object... otherFields) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Rankable other) |
Rankable |
copy()
Note: We do not defensively copy the wrapped object and any accompanying fields.
|
boolean |
equals(Object o) |
static RankableObjectWithFields |
from(Tuple tuple)
Construct a new instance based on the provided
Tuple . |
long |
getCount() |
List<Object> |
getFields() |
Object |
getObject() |
int |
hashCode() |
String |
toString() |
public static RankableObjectWithFields from(Tuple tuple)
Construct a new instance based on the provided Tuple
.
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 via getFields()
.
tuple
- public List<Object> getFields()
public int compareTo(Rankable other)
compareTo
in interface Comparable<Rankable>
Copyright © 2019 The Apache Software Foundation. All rights reserved.