List of usage examples for org.apache.hadoop.fs FSDataInputStream FSDataInputStream
public FSDataInputStream(InputStream in)
From source file:tachyon.hadoop.AbstractTFS.java
License:Apache License
/** * Attempts to open the specified file for reading. * * @param cPath the file name to open/*from w ww .j a va 2 s. c o m*/ * @param bufferSize the size in bytes of the buffer to be used * @return an FSDataInputStream at the indicated path of a file * @throws IOException if the file cannot be opened (e.g., the path is a folder) */ @Override public FSDataInputStream open(Path cPath, int bufferSize) throws IOException { LOG.info("open(" + cPath + ", " + bufferSize + ")"); if (mStatistics != null) { mStatistics.incrementReadOps(1); } TachyonURI path = new TachyonURI(Utils.getPathWithoutScheme(cPath)); fromHdfsToTachyon(path); long fileId = mTFS.getFileId(path); return new FSDataInputStream(new HdfsFileInputStream(mTFS, fileId, Utils.getHDFSPath(path, mUnderFSAddress), getConf(), bufferSize, mStatistics, mTachyonConf)); }
From source file:tajo.util.FileUtil.java
License:Apache License
public static Message loadProto(Configuration conf, Path path, Message proto) throws IOException { FileSystem fs = path.getFileSystem(conf); FSDataInputStream in = new FSDataInputStream(fs.open(path)); Message.Builder builder = proto.newBuilderForType().mergeFrom(in); return builder.build(); }