dlmarion commented on code in PR #5340:
URL: https://github.com/apache/accumulo/pull/5340#discussion_r1962286342
##########
core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletMetadata.java:
##########
@@ -558,6 +560,57 @@ private static Optional<TServerInstance>
checkServer(ClientContext context, Stri
.map(address -> new TServerInstance(address,
stat.getEphemeralOwner()));
}
+ public static void validate(TabletMetadata tm) {
+ if (tm == null) {
+ throw new IllegalStateException("TabletMetadata cannot be null");
+ }
+
+ Text prevEndRowText = tm.getPrevEndRow();
+ Text endRowText = tm.getEndRow();
+
+ // Allow validation even if prevEndRow is missing, as long as endRowText
exists
+ Key prevEndRowKey = (prevEndRowText != null) ? new Key(prevEndRowText) :
null;
+ Key endRowKey = (endRowText != null) ? new Key(endRowText) : null;
+
+ Collection<StoredTabletFile> files = tm.getFiles();
+ if (files == null || files.isEmpty()) {
+ return;
+ }
+
+ for (StoredTabletFile file : files) {
+ if (!isFileRangeValid(file, prevEndRowKey, endRowKey)) {
+ throw new IllegalStateException("File range " + file.getRange()
+ + " is inconsistent with tablet range [" + prevEndRowText + ", " +
endRowText + "]");
Review Comment:
```suggestion
+ " does not overlap tablet range [" + prevEndRowText + ", " +
endRowText + "]");
```
##########
core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletMetadata.java:
##########
@@ -558,6 +560,57 @@ private static Optional<TServerInstance>
checkServer(ClientContext context, Stri
.map(address -> new TServerInstance(address,
stat.getEphemeralOwner()));
}
+ public static void validate(TabletMetadata tm) {
+ if (tm == null) {
+ throw new IllegalStateException("TabletMetadata cannot be null");
+ }
+
+ Text prevEndRowText = tm.getPrevEndRow();
+ Text endRowText = tm.getEndRow();
+
+ // Allow validation even if prevEndRow is missing, as long as endRowText
exists
+ Key prevEndRowKey = (prevEndRowText != null) ? new Key(prevEndRowText) :
null;
+ Key endRowKey = (endRowText != null) ? new Key(endRowText) : null;
+
+ Collection<StoredTabletFile> files = tm.getFiles();
+ if (files == null || files.isEmpty()) {
+ return;
+ }
+
+ for (StoredTabletFile file : files) {
+ if (!isFileRangeValid(file, prevEndRowKey, endRowKey)) {
+ throw new IllegalStateException("File range " + file.getRange()
+ + " is inconsistent with tablet range [" + prevEndRowText + ", " +
endRowText + "]");
+ }
+ }
+ }
+
+ private static boolean isFileRangeValid(StoredTabletFile file, Key
prevEndRowKey, Key endRowKey) {
+ Range fileRange = file.getRange();
+
+ if (fileRange == null) {
+ return false;
+ }
Review Comment:
It doesn't appear that Range can be null. It appears that the file Range, if
not specified, is +/- infinity, which will overlap the tablet.
```suggestion
if (!file.hasRange()) {
return true;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]