T ret = null;
ByteArrayInputStream bis = new ByteArrayInputStream(buf);
try {
ObjectInputStream ois = new ObjectInputStream(bis);
if (isMatrix) {
MatrixWritable w = new MatrixWritable();
w.readFields(ois);
ret = (T) w.get();
} else {
VectorWritable w = new VectorWritable();
w.readFields(ois);
ret = (T) w.get();
}
} catch (java.io.IOException e) {
System.out.println("Caught exception: " + e);
}
return ret;