@Override public void write(DataOutput out) throws IOException { out.writeUTF(getValueClass().getName()); Writable[] writables = get(); // handle null - ArrayWritable does not if (writables == null) { out.writeInt(0); } else { super.write(out); } } }
@Test public void testEmptyArrayReadWrite() throws Exception { ArrayWritable array = new WritableArrayWritable(Text.class); FastByteArrayOutputStream out = new FastByteArrayOutputStream(); DataOutputStream da = new DataOutputStream(out); array.write(da); da.close(); WritableArrayWritable waw = new WritableArrayWritable(NullWritable.class); waw.readFields(new DataInputStream(new FastByteArrayInputStream(out.bytes()))); assertSame(array.getValueClass(), waw.getValueClass()); } }
@Override public void write(DataOutput out) throws IOException { out.writeUTF(getValueClass().getName()); Writable[] writables = get(); // handle null - ArrayWritable does not if (writables == null) { out.writeInt(0); } else { super.write(out); } } }
@Override public void write(DataOutput out) throws IOException { out.writeUTF(getValueClass().getName()); Writable[] writables = get(); // handle null - ArrayWritable does not if (writables == null) { out.writeInt(0); } else { super.write(out); } } }
@Override public void write(DataOutput out) throws IOException { out.writeUTF(getValueClass().getName()); Writable[] writables = get(); // handle null - ArrayWritable does not if (writables == null) { out.writeInt(0); } else { super.write(out); } } }
@Override public void write(DataOutput out) throws IOException { out.writeUTF(getValueClass().getName()); Writable[] writables = get(); // handle null - ArrayWritable does not if (writables == null) { out.writeInt(0); } else { super.write(out); } } }