@Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
private boolean readFile(TachyonFileSystem tachyonClient) throws IOException, TachyonException { boolean pass = true; for (int i = 0; i < mNumFiles; i ++) { TachyonURI filePath = new TachyonURI(mFileFolder + "/part-" + i); LOG.debug("Reading data from {}", filePath); TachyonFile file = tachyonClient.open(filePath); FileInStream is = tachyonClient.getInStream(file); FileInfo info = tachyonClient.getInfo(file); ByteBuffer buf = ByteBuffer.allocate((int) info.getBlockSizeBytes()); is.read(buf.array()); buf.order(ByteOrder.nativeOrder()); for (int k = 0; k < mNumFiles; k ++) { pass = pass && (buf.getInt() == k); } is.close(); } return pass; }
private boolean readFile(TachyonFileSystem tachyonFileSystem, long fileId) throws IOException, TachyonException { boolean pass = true; LOG.debug("Reading data..."); TachyonFile file = new TachyonFile(fileId); final long startTimeMs = CommonUtils.getCurrentMs(); FileInStream is = tachyonFileSystem.getInStream(file, mReadOptions); ByteBuffer buf = ByteBuffer.allocate((int) is.remaining()); is.read(buf.array()); buf.order(ByteOrder.nativeOrder()); for (int k = 0; k < mNumbers; k ++) { pass = pass && (buf.getInt() == k); } is.close(); LOG.info(FormatUtils.formatTimeTakenMs(startTimeMs, "readFile file " + mFilePath)); return pass; }
private boolean read(TachyonFS tachyonClient) throws IOException { boolean pass = true; LOG.debug("Reading data..."); RawTable rawTable = tachyonClient.getRawTable(mId); ByteBuffer metadata = rawTable.getMetadata(); LOG.debug("Metadata: "); metadata.order(ByteOrder.nativeOrder()); for (int k = -mMetadataLength; k < 0; k ++) { pass = pass && (metadata.getInt() == k); } for (int column = 0; column < COLS; column ++) { RawColumn rawColumn = rawTable.getRawColumn(column); TachyonFile tFile = rawColumn.getPartition(0); FileInStream is = tFile.getInStream(mReadType); ByteBuffer buf = ByteBuffer.allocate(mDataLength * 4); is.read(buf.array()); buf.order(ByteOrder.nativeOrder()); for (int k = 0; k < mDataLength; k ++) { pass = pass && (buf.getInt() == k); } is.close(); } return pass; }
@Override public int read() throws IOException { if (mClosed) { throw new IOException("Cannot read from a closed stream."); } if (mTachyonFileInputStream != null) { int ret = 0; try { ret = mTachyonFileInputStream.read(); if (mStatistics != null && ret != -1) { mStatistics.incrementBytesRead(1); } mCurrentPosition ++; return ret; } catch (IOException e) { LOG.error(e.getMessage(), e); mTachyonFileInputStream.close(); mTachyonFileInputStream = null; } } getHdfsInputStream(); return readFromHdfsBuffer(); }
@Override public int read(byte[] b, int off, int len) throws IOException { if (mClosed) { throw new IOException("Cannot read from a closed stream."); } if (mTachyonFileInputStream != null) { int ret = 0; try { ret = mTachyonFileInputStream.read(b, off, len); if (mStatistics != null && ret != -1) { mStatistics.incrementBytesRead(ret); } mCurrentPosition += ret; return ret; } catch (IOException e) { LOG.error(e.getMessage(), e); mTachyonFileInputStream.close(); mTachyonFileInputStream = null; } } getHdfsInputStream(); int byteRead = readFromHdfsBuffer(); // byteRead is an unsigned byte, if its -1 then we have hit EOF if (byteRead == -1) { return -1; } // Convert byteRead back to a signed byte b[off] = (byte) byteRead; return 1; }
FileInStream in = closer.register(mTfs.getInStream(fd, op)); byte[] buf = new byte[8 * Constants.MB]; while (in.read(buf) != -1) {
try { mTachyonFileInputStream.seek(position); ret = mTachyonFileInputStream.read(buffer, offset, length); if (mStatistics != null && ret != -1) { mStatistics.incrementBytesRead(ret);
} else { int read = is.read(data, 0, len); if (read < 0) {
int read = is.read(buf); if (read != -1) { System.out.write(buf, 0, read);