public class FieldBasedTupleComparator extends java.lang.Object implements TupleComparator
TupleComparator
that compares tuples in a naive field-by-field manner.
Comparison of individual field types can be controlled using FieldBasedTupleComparator.CompareFunctor
s.
A subset of the fields for a tuple can by explicitly specifying the field names.
FieldBasedTupleComparator.DEFAULT_COMPARATOR
provides a reasonable default comparison of tuples.
FieldBasedTupleComparator.DEFAULT_COMPARE_REGISTRY
provides a filled in registry of default FieldBasedTupleComparator.CompareFunctor
s.
Modifier and Type | Class and Description |
---|---|
static class |
FieldBasedTupleComparator.CompareFunctor
A strategy object for handling comparisons of specific field types.
|
static class |
FieldBasedTupleComparator.DoubleCompareFunctor
Compare double values using a ratio test and a tolerance.
|
static class |
FieldBasedTupleComparator.IgnoreTimestampCompareFunctor |
static class |
FieldBasedTupleComparator.ListCompareFunctor |
static class |
FieldBasedTupleComparator.NaiveObjectCompareFunctor |
static class |
FieldBasedTupleComparator.RegexCompareFunctor
Check if the second argument matches the regex defined for the first argument.
|
static class |
FieldBasedTupleComparator.TupleCompareFunctor |
Modifier and Type | Field and Description |
---|---|
static FieldBasedTupleComparator |
DEFAULT_COMPARATOR |
static DataType.Registry<FieldBasedTupleComparator.CompareFunctor> |
DEFAULT_COMPARE_REGISTRY |
static java.util.Map<DataType,FieldBasedTupleComparator.CompareFunctor> |
DEFAULT_FUNCTOR_MAP |
static FieldBasedTupleComparator |
IGNORE_TIMESTAMP_COMPARATOR |
static FieldBasedTupleComparator |
REGEX_COMPARATOR |
Constructor and Description |
---|
FieldBasedTupleComparator(DataType.Registry<FieldBasedTupleComparator.CompareFunctor> comparators,
java.lang.String... fields) |
FieldBasedTupleComparator(FieldBasedTupleComparator baseComparator,
java.lang.String... fields) |
Modifier and Type | Method and Description |
---|---|
boolean |
compare(Tuple expected,
Tuple actual)
Compare two tuples.
|
boolean |
compareValues(CompleteDataType cdt,
java.lang.Object expected,
java.lang.Object actual)
Compare two values with
CompleteDataType cdt. |
java.lang.String |
formatForErrorMessage(Tuple t)
Convert the provided Tuple into a string appropriate for error messages.
|
public static final java.util.Map<DataType,FieldBasedTupleComparator.CompareFunctor> DEFAULT_FUNCTOR_MAP
public static final DataType.Registry<FieldBasedTupleComparator.CompareFunctor> DEFAULT_COMPARE_REGISTRY
public static final FieldBasedTupleComparator DEFAULT_COMPARATOR
public static final FieldBasedTupleComparator REGEX_COMPARATOR
public static final FieldBasedTupleComparator IGNORE_TIMESTAMP_COMPARATOR
public FieldBasedTupleComparator(DataType.Registry<FieldBasedTupleComparator.CompareFunctor> comparators, java.lang.String... fields) throws StreamBaseException
StreamBaseException
public FieldBasedTupleComparator(FieldBasedTupleComparator baseComparator, java.lang.String... fields) throws StreamBaseException
StreamBaseException
public boolean compare(Tuple expected, Tuple actual) throws StreamBaseException
TupleComparator
compare
in interface TupleComparator
expected
- The expected valueactual
- The actual valueStreamBaseException
public boolean compareValues(CompleteDataType cdt, java.lang.Object expected, java.lang.Object actual) throws StreamBaseException
TupleComparator
CompleteDataType
cdt.compareValues
in interface TupleComparator
cdt
- The CompleteDataType
for the objects being comparedexpected
- The expected valueactual
- The actual valueStreamBaseException
public java.lang.String formatForErrorMessage(Tuple t)
TupleComparator
formatForErrorMessage
in interface TupleComparator
t
- The tuple to format