/** * Deserialize from a byte array * @param path path the data came from * @param bytes byte array * @throws IOException all problems * @throws EOFException not enough data * @throws InvalidRecordException if the parsing failed -the record is invalid */ public T fromBytes(String path, byte[] bytes) throws IOException, InvalidRecordException { return fromBytes(path, bytes, ""); }
/** * Deserialize from a byte array * @param path path the data came from * @param bytes byte array * @throws IOException all problems * @throws EOFException not enough data * @throws InvalidRecordException if the parsing failed -the record is invalid * @throws NoRecordException if the data is not considered a record: either * it is too short or it did not contain the marker string. */ public T fromBytes(String path, byte[] bytes) throws IOException { return fromBytes(path, bytes, ""); }
/** * Load from a Hadoop filesystem * @param fs filesystem * @param path path * @return a loaded CD * @throws IOException IO problems * @throws EOFException if not enough bytes were read in * @throws JsonParseException parse problems * @throws JsonMappingException O/J mapping problems */ public T load(FileSystem fs, Path path) throws IOException, JsonParseException, JsonMappingException { FileStatus status = fs.getFileStatus(path); long len = status.getLen(); byte[] b = new byte[(int) len]; FSDataInputStream dataInputStream = fs.open(path); int count = dataInputStream.read(b); if (count != len) { throw new EOFException(path.toString() + ": read finished prematurely"); } return fromBytes(path.toString(), b); }