@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 hashCode() { return getSpecificData().hashCode(this, this.getSchema()); }
public Conversion<?> getConversion(String fieldName) { return getConversion(getSchema().getField(fieldName).pos()); }
record.put(i, readerSchema.getFields().get(i).defaultValue().getBooleanValue()); break; case INT: record.put(i, readerSchema.getFields().get(i).defaultValue().getIntValue()); break; case LONG: record.put(i, readerSchema.getFields().get(i).defaultValue().getLongValue()); break; case FLOAT: case DOUBLE: record.put(i, readerSchema.getFields().get(i).defaultValue().getDoubleValue()); break; case STRING: record.put(i, readerSchema.getFields().get(i).defaultValue().getTextValue()); break; record.put(i, readerSchema.getFields().get(i).defaultValue()); } else { throw new RuntimeException("Default value is not set"); record.put(i, rsRecord.nextBoolean(rsIndex)); break; case TINYINT: record.put(i, (int) rsRecord.nextByte(rsIndex));
/** * @deprecated As of Avro 1.8.2, this method has been moved to * {@link #getConversion(String)} method from 1.9.0. */ @Deprecated public Conversion<?> getConverion(String fieldName) { return getConversion(fieldName); }
@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 this.compareTo((SpecificRecord)that) == 0; }
public Conversion<?> getConversion(String fieldName) { return getConversion(getSchema().getField(fieldName).pos()); }
@Override public int compareTo(SpecificRecord that) { return getSpecificData().compare(this, that, this.getSchema()); }
@Override protected void readField(Object r, Schema.Field f, Object oldDatum, ResolvingDecoder in, Object state) throws IOException { if (r instanceof SpecificRecordBase) { Conversion<?> conversion = ((SpecificRecordBase) r).getConversion(f.pos()); Object datum; if (conversion != null) { datum = readWithConversion( oldDatum, f.schema(), f.schema().getLogicalType(), conversion, in); } else { datum = readWithoutConversion(oldDatum, f.schema(), in); } getData().setField(r, f.name(), f.pos(), datum); } else { super.readField(r, f, oldDatum, in, state); } } }
@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 this.compareTo((SpecificRecord)that) == 0; }
@Override public int hashCode() { return SpecificData.get().hashCode(this, this.getSchema()); }
public Conversion<?> getConversion(String fieldName) { return getConversion(getSchema().getField(fieldName).pos()); }
@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 protected void readField(Object r, Schema.Field f, Object oldDatum, ResolvingDecoder in, Object state) throws IOException { if (r instanceof SpecificRecordBase) { Conversion<?> conversion = ((SpecificRecordBase) r).getConversion(f.pos()); Object datum; if (conversion != null) { datum = readWithConversion( oldDatum, f.schema(), f.schema().getLogicalType(), conversion, in); } else { datum = readWithoutConversion(oldDatum, f.schema(), in); } getData().setField(r, f.name(), f.pos(), datum); } else { super.readField(r, f, oldDatum, in, state); } } }
@Override public int compareTo(SpecificRecord that) { return SpecificData.get().compare(this, that, this.getSchema()); }