When trying to compile generated code for the following schema:
{code}
{
"type" : "record",
"namespace" : "com.mycompany.hadoop",
"name" : "AvroDisk",
"fields" : [ {
"name" : "serial_num",
"type" : [ "null", "string" ],
"doc" : "Serial Number"
}, {
"name" : "seq",
"type" : [ "null", "long" ],
"doc" : "Sequence #"
}, {
"name" : "attributes",
"type" : [ "null", {
"type" : "map",
"values" : "string"
} ],
"doc" : "Attributes of a disk"
} ]
}
{code}
I get errors:
{code}
[ERROR] /Users/akozlov/.../AvroDisk.java:[137,41] incompatible types
[ERROR] found : java.lang.Object
[ERROR] required: java.lang.CharSequence
[ERROR] /Users/akozlov/.../AvroDisk.java:[141,34] incompatible types
[ERROR] found : java.lang.Object
[ERROR] required: java.lang.Long
[ERROR] /Users/akozlov/.../AvroDisk.java:[145,41] incompatible types
[ERROR] found : java.lang.Object
[ERROR] required: java.util.Map<java.lang.CharSequence,java.lang.CharSequence>
{code}
It appears that the 1.7.3 code is missing an explicit cast to
((java.lang.{CharSequence, Long,Map}) in the Builder method:
{code}
133 /** Creates a Builder by copying an existing AvroDisk instance */
134 private Builder(com.seagate.hadoop.avro.AvroDisk other) {
135 super(com.seagate.hadoop.avro.AvroDisk.SCHEMA$);
136 if (isValidValue(fields()[0], other.serial_num)) {
137 this.serial_num =
data().deepCopy(fields()[0].schema(), other.serial_num);
138 fieldSetFlags()[0] = true;
139 }
140 if (isValidValue(fields()[1], other.seq)) {
141 this.seq = data().deepCopy(fields()[1].schema(), other.seq);
142 fieldSetFlags()[1] = true;
143 }
144 if (isValidValue(fields()[2], other.attributes)) {
145 this.attributes =
data().deepCopy(fields()[2].schema(), other.attributes);
146 fieldSetFlags()[2] = true;
147 }
148 }
{code}
The compiler works fine for 1.7.1 and 1.7.2 versions. The java
version I am using is:
$ java -version
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)
Has anyone else seen this error?
Thx,
--
Alex Kozlov
(408) 507-4987
(408) 830-9982 fax
(650) 887-2135 efax
[email protected]