public class FieldBasedTupleComparator extends 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 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,
String... fields) |
FieldBasedTupleComparator(FieldBasedTupleComparator baseComparator,
String... fields) |
Modifier and Type | Method and Description |
---|---|
boolean |
compare(Tuple expected,
Tuple actual)
Compare two tuples.
|
boolean |
compareValues(CompleteDataType cdt,
Object expected,
Object actual)
Compare two values with
CompleteDataType cdt. |
String |
formatForErrorMessage(Tuple t)
Convert the provided Tuple into a string appropriate for error messages.
|
public static final 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, String... fields) throws StreamBaseException
StreamBaseException
public FieldBasedTupleComparator(FieldBasedTupleComparator baseComparator, 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, Object expected, 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 String formatForErrorMessage(Tuple t)
TupleComparator
formatForErrorMessage
in interface TupleComparator
t
- The tuple to format