我正在运行一个使用Java类的Pig脚本。在运行Pig脚本时出现错误: 1.不兼容的类型:org.apache.hadoop.hive.kafka.KafkaWritable无法转换为org.apache.hadoop.io.BytesWritable 2.不兼容的类型:java.lang.Object无法转换为org.apache.avro.generic.GenericRecord
public Tuple getNext() throws IOException {
try {
if (((KafkaRecordReader) this.reader).nextKeyValue()) {
BytesWritable b = ((KafkaRecordReader) this.reader).getCurrentValue();
DataByteArray d = new DataByteArray(b.getBytes());
if (this.avroSchema == null) {
Tuple t = this.tupleFactory.newTuple(1);
t.set(0, d);
return t;
}
List<Field> fields = this.avroSchema.getFields();
Tuple t = this.tupleFactory.newTuple();
GenericRecord record = this.fromBytes(b.getBytes());
Iterator var6 = fields.iterator();
while (var6.hasNext()) {
Field f = (Field) var6.next();
t.append(record.get(f.name()).toString());
}
return t;
}
} catch (InterruptedException var8) {
var8.printStackTrace();
}
return null;
}