|
25 | 25 | import java.util.Map;
|
26 | 26 | import java.util.Map.Entry;
|
27 | 27 | import java.util.Objects;
|
28 |
| -import java.util.Optional; |
29 | 28 | import java.util.Set;
|
30 | 29 | import java.util.function.Predicate;
|
31 | 30 |
|
|
48 | 47 | import org.slf4j.Logger;
|
49 | 48 | import org.slf4j.LoggerFactory;
|
50 | 49 |
|
| 50 | +import com.google.common.base.Preconditions; |
51 | 51 | import com.google.common.collect.Sets;
|
52 | 52 |
|
53 | 53 | public class FindMergeableRangeTask implements Runnable {
|
@@ -125,20 +125,20 @@ void submit(MergeableRange range, FateInstanceType type, Entry<TableId,String> t
|
125 | 125 | TableId tableId = table.getKey();
|
126 | 126 | String tableName = table.getValue();
|
127 | 127 |
|
128 |
| - range.startRow = Optional.ofNullable(range.startRow).map(Text::new).orElse(new Text("")); |
129 |
| - range.endRow = Optional.ofNullable(range.endRow).map(Text::new).orElse(new Text("")); |
| 128 | + final Text startRow = range.startRow != null ? range.startRow : new Text(""); |
| 129 | + final Text endRow = range.endRow != null ? range.endRow : new Text(""); |
130 | 130 |
|
131 |
| - String startRowStr = StringUtils.defaultIfBlank(range.startRow.toString(), "-inf"); |
132 |
| - String endRowStr = StringUtils.defaultIfBlank(range.endRow.toString(), "+inf"); |
| 131 | + String startRowStr = StringUtils.defaultIfBlank(startRow.toString(), "-inf"); |
| 132 | + String endRowStr = StringUtils.defaultIfBlank(endRow.toString(), "+inf"); |
133 | 133 | log.debug("FindMergeableRangeTask: Creating merge op: {} from startRow: {} to endRow: {}",
|
134 | 134 | tableId, startRowStr, endRowStr);
|
135 | 135 | var fateId = manager.fate(type).startTransaction();
|
136 | 136 | String goalMessage = TableOperation.MERGE + " Merge table " + tableName + "(" + tableId
|
137 | 137 | + ") splits from " + startRowStr + " to " + endRowStr;
|
138 | 138 |
|
139 | 139 | manager.fate(type).seedTransaction(FateOperation.SYSTEM_MERGE, fateId,
|
140 |
| - new TraceRepo<>(new TableRangeOp(Operation.SYSTEM_MERGE, namespaceId, tableId, |
141 |
| - range.startRow, range.endRow)), |
| 140 | + new TraceRepo<>( |
| 141 | + new TableRangeOp(Operation.SYSTEM_MERGE, namespaceId, tableId, startRow, endRow)), |
142 | 142 | true, goalMessage);
|
143 | 143 | }
|
144 | 144 |
|
@@ -176,6 +176,9 @@ boolean add(TabletMetadata tm) {
|
176 | 176 |
|
177 | 177 | private boolean validate(TabletMetadata tm) {
|
178 | 178 | if (tabletCount > 0) {
|
| 179 | + // This is at least the second tablet seen so there should not be a null prevEndRow |
| 180 | + Preconditions.checkState(tm.getPrevEndRow() != null, |
| 181 | + "Unexpected null prevEndRow found for %s", tm.getExtent()); |
179 | 182 | // If this is not the first tablet, then verify its prevEndRow matches
|
180 | 183 | // the last endRow tracked, the server filter will skip tablets marked as never
|
181 | 184 | if (!tm.getPrevEndRow().equals(endRow)) {
|
|
0 commit comments