static CompletableFuture readOneRange()

in hadoop-api-shim/src/main/java/org/apache/hadoop/fs/shim/impl/VectoredRangeReadImpl.java [212:232]


  static CompletableFuture<ByteBuffer> readOneRange(
      FSDataInputStreamShim in,
      boolean useByteBufferPositionedRead,
      VectorFileRange range,
      IntFunction<ByteBuffer> allocate) {
    CompletableFuture<ByteBuffer> result = new CompletableFuture<>();
    try {
      ByteBuffer buffer = allocate.apply(range.getLength());
      if (useByteBufferPositionedRead) {
        // use readFully if present
        in.readFully(range.getOffset(), buffer);
        buffer.flip();
      } else {
        readRangeThroughPositionedReadable(in, range, buffer);
      }
      result.complete(buffer);
    } catch (IOException ioe) {
      result.completeExceptionally(ioe);
    }
    return result;
  }