@Override public boolean equals(Object that) { if (that == this) return true; // identical object if (!(that instanceof SpecificRecord)) return false; // not a record if (this.getClass() != that.getClass()) return false; // not same schema return getSpecificData().compare(this, that, this.getSchema(), true) == 0; }
@Override public boolean equals(Object that) { if (that == this) return true; // identical object if (!(that instanceof SpecificRecord)) return false; // not a record if (this.getClass() != that.getClass()) return false; // not same schema return SpecificData.get().compare(this, that, this.getSchema(), true) == 0; }
public boolean equals(Object that) { if (that == this) return true; // identical object if (!(that instanceof SpecificExceptionBase)) return false; // not a record if (this.getClass() != that.getClass()) return false; // not same schema return SpecificData.get().compare(this, that, this.getSchema()) == 0; }
public boolean equals(Object that) { if (that == this) return true; // identical object if (!(that instanceof SpecificExceptionBase)) return false; // not a record if (this.getClass() != that.getClass()) return false; // not same schema return SpecificData.get().compare(this, that, this.getSchema()) == 0; }
@Override public int compareTo(SpecificRecord that) { return getSpecificData().compare(this, that, this.getSchema()); }
@Override public int compareTo(SpecificRecord that) { return SpecificData.get().compare(this, that, this.getSchema()); }
@Override protected int compare(Object o1, Object o2, Schema s, boolean equals) { switch (s.getType()) { case ARRAY: if (!o1.getClass().isArray()) break; Schema elementType = s.getElementType(); int l1 = java.lang.reflect.Array.getLength(o1); int l2 = java.lang.reflect.Array.getLength(o2); int l = Math.min(l1, l2); for (int i = 0; i < l; i++) { int compare = compare(java.lang.reflect.Array.get(o1, i), java.lang.reflect.Array.get(o2, i), elementType, equals); if (compare != 0) return compare; } return l1 - l2; case BYTES: if (!o1.getClass().isArray()) break; byte[] b1 = (byte[])o1; byte[] b2 = (byte[])o2; return BinaryData.compareBytes(b1, 0, b1.length, b2, 0, b2.length); } return super.compare(o1, o2, s, equals); }
@Override protected int compare(Object o1, Object o2, Schema s, boolean equals) { switch (s.getType()) { case ARRAY: if (!o1.getClass().isArray()) break; Schema elementType = s.getElementType(); int l1 = java.lang.reflect.Array.getLength(o1); int l2 = java.lang.reflect.Array.getLength(o2); int l = Math.min(l1, l2); for (int i = 0; i < l; i++) { int compare = compare(java.lang.reflect.Array.get(o1, i), java.lang.reflect.Array.get(o2, i), elementType, equals); if (compare != 0) return compare; } return l1 - l2; case BYTES: if (!o1.getClass().isArray()) break; byte[] b1 = (byte[])o1; byte[] b2 = (byte[])o2; return BinaryData.compareBytes(b1, 0, b1.length, b2, 0, b2.length); } return super.compare(o1, o2, s, equals); }
@Override public boolean equals(Object that) { if (that == this) return true; // identical object if (!(that instanceof SpecificRecord)) return false; // not a record if (this.getClass() != that.getClass()) return false; // not same schema return SpecificData.get().compare(this, that, this.getSchema(), true) == 0; }
public boolean equals(Object that) { if (that == this) return true; // identical object if (!(that instanceof SpecificExceptionBase)) return false; // not a record if (this.getClass() != that.getClass()) return false; // not same schema return SpecificData.get().compare(this, that, this.getSchema()) == 0; }
public boolean equals(Object that) { if (that == this) return true; // identical object if (!(that instanceof SpecificExceptionBase)) return false; // not a record if (this.getClass() != that.getClass()) return false; // not same schema return SpecificData.get().compare(this, that, this.getSchema()) == 0; }
public boolean equals(Object that) { if (that == this) return true; // identical object if (!(that instanceof SpecificExceptionBase)) return false; // not a record if (this.getClass() != that.getClass()) return false; // not same schema return SpecificData.get().compare(this, that, this.getSchema()) == 0; }
public boolean equals(Object that) { if (that == this) return true; // identical object if (!(that instanceof SpecificExceptionBase)) return false; // not a record if (this.getClass() != that.getClass()) return false; // not same schema return SpecificData.get().compare(this, that, this.getSchema()) == 0; }
@Override public boolean equals(Object that) { if (that == this) return true; // identical object if (!(that instanceof SpecificRecord)) return false; // not a record if (this.getClass() != that.getClass()) return false; // not same schema return SpecificData.get().compare(this, that, this.getSchema(), true) == 0; }
@Override public int compareTo(SpecificRecord that) { return SpecificData.get().compare(this, that, this.getSchema()); }
@Override public int compareTo(SpecificRecord that) { return SpecificData.get().compare(this, that, this.getSchema()); }
@Override public int compareTo(SpecificRecord that) { return SpecificData.get().compare(this, that, this.getSchema()); }
@Override public int compareTo(SpecificRecord that) { return SpecificData.get().compare(this, that, this.getSchema()); }
public int compare(AvroWrapper<T> x, AvroWrapper<T> y) { return SpecificData.get().compare(x.datum(), y.datum(), schema); }
public static void assertAvroObjs(Object expected, Object given) { if (expected instanceof byte[]) { Assert.assertArrayEquals((byte[]) expected, (byte[]) given); } else if(expected instanceof SpecificRecord) { Assert.assertTrue(SpecificData.get().compare(expected, given, ((SpecificRecord) expected).getSchema()) == 0); } else { Assert.assertEquals(expected, given); } }