public abstract class Marker extends Object
Marker is a bookmark in the partition space, which is the space of
each possible partition in a PartitionStrategy.
A Marker holds un-ordered values that can be used to create keys by
a PartitionStrategy. It can hold either source values, like a
timestamp, or concrete values, like a year.
A Marker can be used as a generic placeholder or bookmark for an
entity (an object in a Dataset. For example, when fetching a record
from HBase, you can use a Marker to hold the information that
PartitionStrategy uses to build a concrete key and fetch the entity.
A Marker can also be used as a partial key, where some of the values
needed to create a complete key are missing. In this case, a Marker
contains a subset of the partition space: all Marker the keys that
share the values that are set in the Marker.
The Marker.Builder class is the easiest way to make a Marker.
Any Marker created by the Marker.Builder is Immutable
and will not change. The Builder can copy values from other
Marker objects and provides a fluent interface to easily create new
instances:
// a partial Marker for all events with the same hash code and approx time
Marker partial = new Marker.Builder()
.add("shard", id.hashCode())
.add("timestamp", System.getTimeMillis())
.build();
// a Marker that represents a particular object
Marker concrete = new Marker.Builder(partial).add("id", id).build();
// a partial Marker for approx time, for all shards
new Marker.Builder("timestamp", System.getTimeMillis()).build();
| Modifier and Type | Class and Description |
|---|---|
static class |
Marker.Builder
A fluent builder for creating Marker instances.
|
| Constructor and Description |
|---|
Marker() |
| Modifier and Type | Method and Description |
|---|---|
abstract Object |
get(String name)
Returns the value for
name. |
<T> T |
getAs(String name,
Class<T> returnType)
Returns the value for
name coerced to the given type, T. |
abstract boolean |
has(String name)
Returns whether
name is stored in this Marker. |
<S,T> T |
valueFor(FieldPartitioner<S,T> fp)
Return the value of a
FieldPartitioner field for this Marker. |
public abstract boolean has(String name)
name is stored in this Marker.name - a String namenamepublic abstract Object get(String name)
name.name - the String name of the value to returnnamepublic <T> T getAs(String name, Class<T> returnType)
name coerced to the given type, T.T - the return typename - the String name of the value to returnreturnType - The return type, which must be assignable from Long,
Integer, String, or Objectname coerced to a TClassCastException - if the return type is unknown@Nullable public <S,T> T valueFor(FieldPartitioner<S,T> fp)
FieldPartitioner field for this Marker.
If the Marker has a value for the field's name, that value is
returned using getAs(java.lang.String, java.lang.Class). If
the Marker only has a value for the the source field name, then
that value is retrieved using
getAs(java.lang.String,
java.lang.Class) and the field's transformation is applied to it as the source value.fp - a FieldPartitionermarker, or nullCopyright © 2013–2015. All rights reserved.