Esempio n. 1
0
 @Override
 public int directRead(byte[] b, int off, int len) throws IOException {
   ByteBuffer buf = mLocalFileChannel.map(FileChannel.MapMode.READ_ONLY, getPosition(), len);
   buf.get(b, off, len);
   BufferUtils.cleanDirectBuffer(buf);
   return len;
 }
Esempio n. 2
0
 @Override
 protected void bufferedRead(int len) throws IOException {
   if (mBuffer.isDirect()) { // Buffer may not be direct on initialization
     BufferUtils.cleanDirectBuffer(mBuffer);
   }
   mBuffer = mLocalFileChannel.map(FileChannel.MapMode.READ_ONLY, getPosition(), len);
 }
Esempio n. 3
0
  @Override
  public void close() throws IOException {
    if (mClosed) {
      return;
    }
    try {
      if (mBlockIsRead) {
        mWorkerClient.accessBlock(mBlockId);
        ClientContext.getClientMetrics().incBlocksReadLocal(1);
      }
      mWorkerClient.unlockBlock(mBlockId);
    } catch (TachyonException e) {
      throw new IOException(e);
    } finally {
      mContext.releaseWorkerClient(mWorkerClient);
      mCloser.close();
      if (mBuffer != null && mBuffer.isDirect()) {
        BufferUtils.cleanDirectBuffer(mBuffer);
      }
    }

    mClosed = true;
  }