HBASE-16660 ArrayIndexOutOfBounds during the majorCompactionCheck in DateTieredCompaction
Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
parent
b644e0fb8d
commit
d127d64266
|
@ -153,6 +153,9 @@ public class DateTieredCompactionPolicy extends SortedCompactionPolicy {
|
|||
minTimestamp == null ? (Long)Long.MAX_VALUE : minTimestamp);
|
||||
int upperWindowIndex = Collections.binarySearch(boundaries,
|
||||
file.getMaximumTimestamp() == null ? (Long)Long.MAX_VALUE : file.getMaximumTimestamp());
|
||||
// Handle boundary conditions and negative values of binarySearch
|
||||
lowerWindowIndex = (lowerWindowIndex < 0) ? Math.abs(lowerWindowIndex + 2) : lowerWindowIndex;
|
||||
upperWindowIndex = (upperWindowIndex < 0) ? Math.abs(upperWindowIndex + 2) : upperWindowIndex;
|
||||
if (lowerWindowIndex != upperWindowIndex) {
|
||||
LOG.debug("Major compaction triggered on store " + this + "; because file "
|
||||
+ file.getPath() + " has data with timestamps cross window boundaries");
|
||||
|
|
|
@ -234,6 +234,22 @@ public class TestDateTieredCompactionPolicy extends AbstractTestDateTieredCompac
|
|||
new long[] { Long.MIN_VALUE, 24, 48, 72, 96, 120, 144, 150, 156 }, true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Major Compaction to check min max timestamp falling in the same window and also to check
|
||||
* boundary condition in which case binary sort gives insertion point as length of the array
|
||||
* @throws IOException
|
||||
*/
|
||||
@Test
|
||||
public void checkMinMaxTimestampSameBoundary() throws IOException {
|
||||
long[] minTimestamps = new long[] { 0, 26, 50, 90, 98, 122, 145, 151, 158, 166 };
|
||||
long[] maxTimestamps = new long[] { 12, 46, 70, 95, 100, 140, 148, 155, 162, 174 };
|
||||
long[] sizes = new long[] { 0, 50, 51, 40, 41, 42, 33, 30, 31, 2 };
|
||||
|
||||
compactEquals(161, sfCreate(minTimestamps, maxTimestamps, sizes),
|
||||
new long[] { 0, 50, 51, 40, 41, 42, 33, 30, 31, 2 },
|
||||
new long[] { Long.MIN_VALUE, 24, 48, 72, 96, 120, 144, 150, 156 }, true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Major compaction with negative numbers
|
||||
* @throws IOException with error
|
||||
|
|
Loading…
Reference in New Issue