|
42 | 42 | import org.apache.accumulo.core.clientImpl.ClientContext;
|
43 | 43 | import org.apache.accumulo.core.data.ByteSequence;
|
44 | 44 | import org.apache.accumulo.core.data.Key;
|
45 |
| -import org.apache.accumulo.core.data.PartialKey; |
46 | 45 | import org.apache.accumulo.core.data.Range;
|
47 | 46 | import org.apache.accumulo.core.data.TableId;
|
48 | 47 | import org.apache.accumulo.core.data.Value;
|
@@ -566,46 +565,18 @@ public static void validate(TabletMetadata tm) {
|
566 | 565 | }
|
567 | 566 |
|
568 | 567 | Collection<StoredTabletFile> files = tm.getFiles();
|
569 |
| - |
570 |
| - Text prevEndRowText = tm.getPrevEndRow(); |
571 |
| - Text endRowText = tm.getEndRow(); |
572 |
| - |
573 |
| - // Allow validation even if prevEndRow is missing, as long as endRowText exists |
574 |
| - Key prevEndRowKey = (prevEndRowText != null) ? new Key(prevEndRowText) : null; |
575 |
| - Key endRowKey = (endRowText != null) ? new Key(endRowText) : null; |
| 568 | + Range tabletRange = tm.getExtent().toDataRange(); |
576 | 569 |
|
577 | 570 | for (StoredTabletFile file : files) {
|
578 |
| - if (!isFileRangeValid(file, prevEndRowKey, endRowKey)) { |
579 |
| - throw new IllegalStateException("File range " + file.getRange() |
580 |
| - + " does not overlap with tablet range [" + prevEndRowText + ", " + endRowText + "]"); |
| 571 | + if (!isFileRangeValid(file, tabletRange)) { |
| 572 | + throw new IllegalStateException( |
| 573 | + "File range " + file.getRange() + " does not overlap with tablet range " + tabletRange); |
581 | 574 | }
|
582 | 575 | }
|
583 | 576 | }
|
584 | 577 |
|
585 |
| - private static boolean isFileRangeValid(StoredTabletFile file, Key prevEndRowKey, Key endRowKey) { |
586 |
| - Range fileRange = file.getRange(); |
587 |
| - |
588 |
| - if (!file.hasRange()) { |
589 |
| - return true; |
590 |
| - } |
591 |
| - |
592 |
| - Key fileStartKey = fileRange.getStartKey(); |
593 |
| - Key fileEndKey = fileRange.getEndKey(); |
594 |
| - |
595 |
| - // If start key is null, assume it starts at the beginning of the tablet |
596 |
| - if (fileStartKey == null) { |
597 |
| - fileStartKey = prevEndRowKey != null ? prevEndRowKey.followingKey(PartialKey.ROW) : null; |
598 |
| - } |
599 |
| - |
600 |
| - if (fileEndKey == null) { |
601 |
| - fileEndKey = endRowKey; |
602 |
| - } |
603 |
| - |
604 |
| - if (prevEndRowKey != null |
605 |
| - && fileStartKey.compareTo(prevEndRowKey.followingKey(PartialKey.ROW)) < 0) { |
606 |
| - return false; |
607 |
| - } |
608 |
| - return endRowKey == null || fileEndKey.compareTo(endRowKey) <= 0; |
| 578 | + private static boolean isFileRangeValid(StoredTabletFile file, Range tabletRange) { |
| 579 | + return !file.hasRange() || tabletRange.clip(file.getRange(), true) != null; |
609 | 580 | }
|
610 | 581 |
|
611 | 582 | static class Builder {
|
|
0 commit comments