@Immutable public class MarkerComparator extends Object implements Comparator<Marker>
Marker objects with respect to a
PartitionStrategy.| Constructor and Description |
|---|
MarkerComparator(PartitionStrategy strategy) |
| Modifier and Type | Method and Description |
|---|---|
int |
compare(Marker m1,
Marker m2)
Compare two
Marker objects under the PartitionStrategy. |
boolean |
contains(Marker container,
Marker test)
Returns true if
container contains test, false otherwise. |
boolean |
equals(Object o) |
int |
hashCode() |
int |
leftCompare(Marker m1,
Marker m2)
Compare two
Marker objects under the PartitionStrategy. |
int |
rightCompare(Marker m1,
Marker m2)
Compare two
Marker objects under the PartitionStrategy. |
public MarkerComparator(PartitionStrategy strategy)
public boolean contains(Marker container, Marker test)
container contains test, false otherwise.
Fields for which set has no value
(Marker.valueFor(FieldPartitioner) returns
null) are treated as wildcards and always match.
All fields in the PartitionStrategy are compared.container - a Marker that defines a set of partitionstest - a Marker that may be a subset of containertrue if the partitions in test are a subset of
container, false otherwisepublic int compare(Marker m1, Marker m2)
Marker objects under the PartitionStrategy.
All comparisons are with respect to the partition ordering defined by
this comparator's PartitionStrategy. Under a
PartitionStrategy, a Marker contains a set of one or
more partitions. A Marker is strictly less than another if all of
the partitions it contains are less than the partitions of the other.
Similarly, if all partitions are greater than the partitions of the other,
then the Marker is greater. Two Markers are equal if they
contain the same set of partitions.
This method implements strictly exclusive comparison: if either
Marker contains the other, then this throws
IllegalStateException. This is because there is at least one
partition in the containing Marker that is less than or equal to
all partitions in the contained Marker and at least one partition
that is greater than or equal to all partitions in the contained
Marker.
Alternatively, the comparison methods leftCompare(Marker, Marker)
and rightCompare(Marker, Marker) consider contained Marker
objects to be greater-than and less-than respectively.
Note: Because Marker objects are hierarchical, they are either
completely disjoint or one marker contains the other. If one contains the
other and the two are not equal, this method throws
IllegalStateException.
TODO: catch wildcard to concrete comparisons and throw an Exceptioncompare in interface Comparator<Marker>m1 - a Markerm2 - a MarkerIllegalStateException - If either Marker is a proper subset of the otherleftCompare(Marker, Marker),
rightCompare(Marker, Marker)public int rightCompare(Marker m1, Marker m2)
Marker objects under the PartitionStrategy.
All comparisons are with respect to the partition ordering defined by
this comparator's PartitionStrategy. Under a
PartitionStrategy, a Marker contains a set of one or
more partitions. A Marker is strictly less than another if all of
the partitions it contains are less than the partitions of the other.
Similarly, if all partitions are greater than the partitions of the other,
then the Marker is greater. Two Markers are equal if they
contain the same set of partitions.
This method implements right-inclusive comparison: if either Marker
contains the other, then it is considered greater. This means that there
is at least one partition in the containing Marker that is greater
than all of the partitions in the contained Marker. This behavior
is for checking an inclusive upper bound for a range.
m1 = [ 2013, Oct, * ]
m2 = [ 2013, Oct, 12 ]
rightCompare(m1, m2) returns 1
rightCompare(m2, m1) returns -1
The comparison method leftCompare(Marker, Marker) implements
left-inclusive comparison.
Note: Because Marker objects are hierarchical, they are either
completely disjoint or one marker contains the other. If one contains the
other and the two are not equal, this method considers it to be greater
than the other.
TODO: catch wildcard to concrete comparisons and throw an Exceptionm1 - a Markerm2 - a Markercompare(Marker, Marker),
leftCompare(Marker, Marker)public int leftCompare(Marker m1, Marker m2)
Marker objects under the PartitionStrategy.
All comparisons are with respect to the partition ordering defined by
this comparator's PartitionStrategy. Under a
PartitionStrategy, a Marker contains a set of one or
more partitions. A Marker is strictly less than another if all of
the partitions it contains are less than the partitions of the other.
Similarly, if all partitions are greater than the partitions of the other,
then the Marker is greater. Two Markers are equal if they
contain the same set of partitions.
This method implements left-inclusive comparison: if either Marker
contains the other, then it is considered lesser. This means that there
is at least one partition in the containing Marker that is less
than all of the partitions in the contained Marker. This behavior
is for checking an inclusive lower bound for a range.
m1 = [ 2013, Oct, * ]
m2 = [ 2013, Oct, 12 ]
leftCompare(m1, m2) returns 1
leftCompare(m2, m1) returns -1
The comparison method rightCompare(Marker, Marker) implements
right-inclusive comparison.
Note: Because Marker objects are hierarchical, they are either
completely disjoint or one marker contains the other. If one contains the
other and the two are not equal, this method considers it to be less than
than the other.
TODO: catch wildcard to concrete comparisons and throw an Exceptionm1 - a Markerm2 - a Markercompare(Marker, Marker),
rightCompare(Marker, Marker)public boolean equals(Object o)
equals in interface Comparator<Marker>equals in class ObjectCopyright © 2013–2015. All rights reserved.