Author: cutting
Date: Tue Dec 15 23:05:45 2009
New Revision: 891063
URL: http://svn.apache.org/viewvc?rev=891063&view=rev
Log:
AVRO-257. Remove some dead Java code and un-needed casts. Contributed by
Kevin Oliver.
Modified:
hadoop/avro/trunk/CHANGES.txt
hadoop/avro/trunk/src/java/org/apache/avro/reflect/ReflectData.java
hadoop/avro/trunk/src/java/org/apache/avro/specific/SpecificRecordBase.java
Modified: hadoop/avro/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=891063&r1=891062&r2=891063&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Tue Dec 15 23:05:45 2009
@@ -134,6 +134,9 @@
AVRO-253. Improve documentation of schema names in specification. (cutting)
+ AVRO-257. Remove some dead Java code and un-needed casts.
+ (Kevin Oliver via cutting)
+
OPTIMIZATIONS
AVRO-172. More efficient schema processing (massie)
Modified: hadoop/avro/trunk/src/java/org/apache/avro/reflect/ReflectData.java
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/java/org/apache/avro/reflect/ReflectData.java?rev=891063&r1=891062&r2=891063&view=diff
==============================================================================
--- hadoop/avro/trunk/src/java/org/apache/avro/reflect/ReflectData.java
(original)
+++ hadoop/avro/trunk/src/java/org/apache/avro/reflect/ReflectData.java Tue Dec
15 23:05:45 2009
@@ -106,8 +106,8 @@
public boolean validate(Schema schema, Object datum) {
switch (schema.getType()) {
case RECORD:
+ if (datum == null) return false;
Class c = datum.getClass();
- if (!(datum instanceof Object)) return false;
for (Map.Entry<String, Schema> entry : schema.getFieldSchemas()) {
try {
if (!validate(entry.getValue(),
@@ -234,7 +234,7 @@
result.setProp(CLASS_PROP, Short.class.getName());
return result;
} else if (type instanceof Class) { // Class
- Class c = (Class)type;
+ Class<?> c = (Class<?>)type;
if (c.isPrimitive() || Number.class.isAssignableFrom(c)
|| c == Void.class || c == Boolean.class) // primitive
return super.createSchema(type, names);
@@ -255,7 +255,7 @@
String space = c.getPackage().getName();
if (c.getEnclosingClass() != null) // nested class
space = c.getEnclosingClass().getName() + "$";
- Union union = (Union)c.getAnnotation(Union.class);
+ Union union = c.getAnnotation(Union.class);
if (union != null) { // union annotated
return getAnnotatedUnion(union, names);
} else if (c.isAnnotationPresent(Stringable.class)){ // Stringable
@@ -269,7 +269,7 @@
symbols.add(constants[i].name());
schema = Schema.createEnum(name, space, symbols);
} else if (GenericFixed.class.isAssignableFrom(c)) { // fixed
- int size = ((FixedSize)c.getAnnotation(FixedSize.class)).value();
+ int size = c.getAnnotation(FixedSize.class).value();
schema = Schema.createFixed(name, space, size);
} else { // record
LinkedHashMap<String,Schema.Field> fields =
@@ -296,8 +296,8 @@
@SuppressWarnings(value="unchecked")
private void setElement(Schema schema, Type element) {
if (!(element instanceof Class)) return;
- Class c = (Class)element;
- Union union = (Union)c.getAnnotation(Union.class);
+ Class<?> c = (Class<?>)element;
+ Union union = c.getAnnotation(Union.class);
if (union != null) // element is annotated union
schema.setProp(ELEMENT_PROP, c.getName());
}
@@ -379,7 +379,7 @@
}
Schema request = Schema.createRecord(fields);
- Union union = (Union)method.getAnnotation(Union.class);
+ Union union = method.getAnnotation(Union.class);
Schema response = union == null
? getSchema(method.getGenericReturnType(), names)
: getAnnotatedUnion(union, names);
Modified:
hadoop/avro/trunk/src/java/org/apache/avro/specific/SpecificRecordBase.java
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/java/org/apache/avro/specific/SpecificRecordBase.java?rev=891063&r1=891062&r2=891063&view=diff
==============================================================================
--- hadoop/avro/trunk/src/java/org/apache/avro/specific/SpecificRecordBase.java
(original)
+++ hadoop/avro/trunk/src/java/org/apache/avro/specific/SpecificRecordBase.java
Tue Dec 15 23:05:45 2009
@@ -27,6 +27,7 @@
public abstract Object get(int field);
public abstract void set(int field, Object value);
+ @Override
public boolean equals(Object that) {
if (that == this) return true; // identical object
if (!(that instanceof SpecificRecord)) return false; // not a record
@@ -34,11 +35,12 @@
return this.compareTo((SpecificRecord)that) == 0;
}
+ @Override
public int hashCode() {
return SpecificData.get().hashCode(this, this.getSchema());
}
- @SuppressWarnings(value="unchecked")
+ @Override
public int compareTo(SpecificRecord that) {
return SpecificData.get().compare(this, that, this.getSchema());
}