HADOOP-18355. Update previous index properly while validating overlapping ranges. (#4647)
part of HADOOP-18103. Contributed By: Mukund Thakur
This commit is contained in:
parent
c5ec727435
commit
66dec9d322
|
@ -210,6 +210,7 @@ public final class VectoredReadUtils {
|
|||
if (sortedRanges[i].getOffset() < prev.getOffset() + prev.getLength()) {
|
||||
throw new UnsupportedOperationException("Overlapping ranges are not supported");
|
||||
}
|
||||
prev = sortedRanges[i];
|
||||
}
|
||||
return Arrays.asList(sortedRanges);
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ import org.apache.hadoop.fs.impl.CombinedFileRange;
|
|||
import org.apache.hadoop.test.HadoopTestBase;
|
||||
|
||||
import static org.apache.hadoop.fs.VectoredReadUtils.sortRanges;
|
||||
import static org.apache.hadoop.fs.VectoredReadUtils.validateNonOverlappingAndReturnSortedRanges;
|
||||
import static org.apache.hadoop.test.LambdaTestUtils.intercept;
|
||||
import static org.apache.hadoop.test.MoreAsserts.assertFutureCompletedSuccessfully;
|
||||
import static org.apache.hadoop.test.MoreAsserts.assertFutureFailedExceptionally;
|
||||
|
||||
|
@ -231,6 +233,36 @@ public class TestVectoredReadUtils extends HadoopTestBase {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateOverlappingRanges() throws Exception {
|
||||
List<FileRange> input = Arrays.asList(
|
||||
FileRange.createFileRange(100, 100),
|
||||
FileRange.createFileRange(200, 100),
|
||||
FileRange.createFileRange(250, 100)
|
||||
);
|
||||
|
||||
intercept(UnsupportedOperationException.class,
|
||||
() -> validateNonOverlappingAndReturnSortedRanges(input));
|
||||
|
||||
List<FileRange> input1 = Arrays.asList(
|
||||
FileRange.createFileRange(100, 100),
|
||||
FileRange.createFileRange(500, 100),
|
||||
FileRange.createFileRange(1000, 100),
|
||||
FileRange.createFileRange(1000, 100)
|
||||
);
|
||||
|
||||
intercept(UnsupportedOperationException.class,
|
||||
() -> validateNonOverlappingAndReturnSortedRanges(input1));
|
||||
|
||||
List<FileRange> input2 = Arrays.asList(
|
||||
FileRange.createFileRange(100, 100),
|
||||
FileRange.createFileRange(200, 100),
|
||||
FileRange.createFileRange(300, 100)
|
||||
);
|
||||
// consecutive ranges should pass.
|
||||
validateNonOverlappingAndReturnSortedRanges(input2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaxSizeZeroDisablesMering() throws Exception {
|
||||
List<FileRange> randomRanges = Arrays.asList(
|
||||
|
|
Loading…
Reference in New Issue