/**
* Set bytes into the passed Writable by calling its
* {@link Writable#readFields(java.io.DataInput)}.
* @param bytes serialized bytes
* @param offset offset into array
* @param length length of data
* @param w An empty Writable (usually made by calling the null-arg
* constructor).
* @return The passed Writable after its readFields has been called fed
* by the passed <code>bytes</code> array or IllegalArgumentException
* if passed null or an empty <code>bytes</code> array.
* @throws IOException e
* @throws IllegalArgumentException
*/
public static Writable getWritable(final byte [] bytes, final int offset,
final int length, final Writable w)
throws IOException {
if (bytes == null || length <=0) {
throw new IllegalArgumentException("Can't build a writable with empty " +
"bytes array");
}
if (w == null) {
throw new IllegalArgumentException("Writable cannot be null");
}
DataInputBuffer in = new DataInputBuffer();
try {
in.reset(bytes, offset, length);
w.readFields(in);
return w;
} finally {
in.close();
}
}
Writables.java 文件源码
java
阅读 18
收藏 0
点赞 0
评论 0
项目:ditb
作者:
评论列表
文章目录