ArrayWritable is a touch hard to use. Say you have an array of
IntWritable[]. The get() method or ArrayWritable, after
serializations/deserialization, does in fact return an array of type
Writable. As such you cannot cast it directly to IntWritable[]. Individual
elements are of type IntWritable and can be cast as such.
Will not work:
IntWritable[] array = (IntWritable[]) writable.get();
Will work:
for(Writable element : writable.get()) {
IntWritable intWritable = (IntWritable)element;
}
ArrayWritable的使用方式
最新推荐文章于 2021-05-31 13:10:18 发布