@@ -73,9 +73,10 @@ public static void readAsync(PositionedReadable stream,
7373 * @param allocate the function to allocate ByteBuffers
7474 * @return the CompletableFuture that contains the read data
7575 */
76- public static CompletableFuture <ByteBuffer > readRangeFrom (PositionedReadable stream ,
77- FileRange range ,
78- IntFunction <ByteBuffer > allocate ) {
76+ public static
77+ CompletableFuture <ByteBuffer > readRangeFrom (PositionedReadable stream ,
78+ FileRange range ,
79+ IntFunction <ByteBuffer > allocate ){
7980 CompletableFuture <ByteBuffer > result = new CompletableFuture <>();
8081 try {
8182 ByteBuffer buffer = allocate .apply (range .getLength ());
@@ -104,7 +105,8 @@ public static CompletableFuture<ByteBuffer> readRangeFrom(PositionedReadable str
104105 }
105106
106107 /**
107- * Is the given input list:
108+ * Is the given input list already in the desired order?
109+ * In particular, does it meet these requirements:
108110 * <ul>
109111 * <li>already sorted by offset</li>
110112 * <li>each range is more than minimumSeek apart</li>
@@ -158,7 +160,8 @@ public static long roundUp(long offset, int chunkSize) {
158160 * <li>Upper layers want to pass down logical file ranges.</li>
159161 * <li>Fewer reads have better performance.</li>
160162 * <li>Applications want callbacks as ranges are read.</li>
161- * <li>Some file systems want to round ranges to be at checksum boundaries.</li>
163+ * <li>Some file systems want to round ranges to be at checksum boundaries.
164+ * </li>
162165 * </ul>
163166 *
164167 * @param input the list of input ranges
@@ -167,10 +170,11 @@ public static long roundUp(long offset, int chunkSize) {
167170 * @param maxSize the largest combined file range in bytes
168171 * @return the list of sorted CombinedFileRanges that cover the input
169172 */
170- public static List <CombinedFileRange > sortAndMergeRanges (List <? extends FileRange > input ,
171- int chunkSize ,
172- int minimumSeek ,
173- int maxSize ) {
173+ public static
174+ List <CombinedFileRange > sortAndMergeRanges (List <? extends FileRange > input ,
175+ int chunkSize ,
176+ int minimumSeek ,
177+ int maxSize ) {
174178 // sort the ranges by offset
175179 FileRange [] ranges = input .toArray (new FileRange [0 ]);
176180 Arrays .sort (ranges , Comparator .comparingLong (FileRange ::getOffset ));
@@ -180,8 +184,10 @@ public static List<CombinedFileRange> sortAndMergeRanges(List<? extends FileRang
180184 // now merge together the ones that merge
181185 for (FileRange range : ranges ) {
182186 long start = roundDown (range .getOffset (), chunkSize );
183- long end = roundUp (range .getOffset () + range .getLength (), chunkSize );
184- if (current == null || !current .merge (start , end , range , minimumSeek , maxSize )) {
187+ long end = roundUp (range .getOffset () + range .getLength (),
188+ chunkSize );
189+ if (current == null ||
190+ !current .merge (start , end , range , minimumSeek , maxSize )) {
185191 current = new CombinedFileRange (start , end , range );
186192 result .add (current );
187193 }
0 commit comments