Class AvroValueComparer
Compares AvroValue data by the specification's sort order for one schema, as Apache Avro Java's
GenericData.compare does. Instances are cached per schema and are thread-safe.
public sealed class AvroValueComparer : IComparer<AvroValue>
- Inheritance
-
AvroValueComparer
- Implements
- Inherited Members
Remarks
The order, from the specification:
nullvalues are equal;falseis less thantrue; numbers compare by value.-
floatanddoublecompare as Java'sFloat.compareandDouble.comparedo: NaN is the largest value and equals itself, and -0 is less than 0. - Strings compare by their UTF-8 bytes, which is code point order;
bytesandfixedbyte by byte, unsigned. - Enums compare by the position of their symbol in the schema.
- Arrays compare item by item; an array that is the start of a longer one is less.
- Unions compare by branch first, then by value.
- Records compare field by field, in schema order, by each field's Order: Descending reverses it, and Ignore leaves the field out.
- Maps have no order: comparing two maps throws, so a map field needs Ignore.
Logical types compare by their underlying type, as in Java: a decimal by its bytes, so negative decimals
sort after positive ones.
This order is not Equals(AvroValue): values that differ in an ignored field compare as 0,
NaNs with different bit patterns compare as 0, and an int and a long of the same number compare as 0
under a long schema, while Equals(AvroValue) tells all of these apart.
Properties
- Schema
Gets the schema values are compared by.
Methods
- Compare(AvroValue, AvroValue)
Compares two values of Schema.
- Create(AvroSchema)
Gets the comparer for
schema, compiling it on first use.