S - The type of the source field in the entity. The partition function must
accept values of this type.T - The type of the target field, which is the type of the return value of the
partition function.@Immutable public abstract class FieldPartitioner<S,T> extends Object implements com.google.common.base.Function<S,T>, Comparator<T>
Partitions values for a named field.
Used by a PartitionStrategy to calculate which partition an entity
belongs in, based on the value of a given field, called the source field. A field
partitioner can, in some cases, provide meaningful cardinality hints to query
systems. A good example of this is a hash partitioner which always knows the number of
buckets produced by the function.
Implementations of FieldPartitioner are immutable.
PartitionStrategy| Modifier and Type | Field and Description |
|---|---|
static int |
UNKNOWN_CARDINALITY |
| Modifier | Constructor and Description |
|---|---|
protected |
FieldPartitioner(String sourceName,
String name,
Class<S> sourceType,
Class<T> type) |
protected |
FieldPartitioner(String sourceName,
String name,
Class<S> sourceType,
Class<T> type,
int cardinality) |
| Modifier and Type | Method and Description |
|---|---|
abstract T |
apply(S value)
Apply the partition function to the given
value. |
int |
getCardinality() |
String |
getName() |
String |
getSourceName() |
Class<S> |
getSourceType()
The type of the source field, which is the type of the type expected by
the apply function.
|
Class<T> |
getType()
The type of the target field, which is the type of the return value of the
partition function.
|
Class<? extends T> |
getType(Class<? extends S> sourceType)
The type of the target field, which is the type of the return value of the
partition function.
|
abstract com.google.common.base.Predicate<T> |
project(com.google.common.base.Predicate<S> predicate)
Projects a source-data constraint
Predicate into the image of the
backing partition function. |
abstract com.google.common.base.Predicate<T> |
projectStrict(com.google.common.base.Predicate<S> predicate)
Projects a source-data constraint
Predicate into the image of the
backing partition function. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcompare, equalspublic static final int UNKNOWN_CARDINALITY
protected FieldPartitioner(String sourceName, String name, Class<S> sourceType, Class<T> type)
public String getName()
getSourceName() and does not appear in the dataset entity.public String getSourceName()
public int getCardinality()
public abstract T apply(S value)
Apply the partition function to the given value.
The type of value must be compatible with the field partitioner implementation. Normally, this is validated at the time of initial configuration rather than at runtime.
public Class<S> getSourceType()
The type of the source field, which is the type of the type expected by the apply function.
public Class<T> getType()
The type of the target field, which is the type of the return value of the partition function.
public Class<? extends T> getType(Class<? extends S> sourceType)
The type of the target field, which is the type of the return value of the partition function.
public abstract com.google.common.base.Predicate<T> project(com.google.common.base.Predicate<S> predicate)
Predicate into the image of the
backing partition function.
If the function cannot be projected exactly, the resulting predicate must
be more permissive than the original predicate.public abstract com.google.common.base.Predicate<T> projectStrict(com.google.common.base.Predicate<S> predicate)
Predicate into the image of the
backing partition function.
If the function cannot be projected exactly, the resulting predicate must
only accept a value if the original predicate would have.
If this method returns null, then there are no values in the image of the
partition function that guarantee the original Predicate is satisfied.predicate - a Predicate for this function's source domainCopyright © 2013–2015. All rights reserved.