Skip to content

Commit 35b45c4

Browse files
dlmarionddanielr
authored andcommitted
Recreate TabletsMetadata iterator when file ranges are not contiguous
In the Bulk Import v2 LoadFiles step a single TabletsMetadata object was used to map a tables tablets to a set of bulk import files. In the case where a small percentage of tablets were involved in the bulk import a majority of the tables tablets would still be evaluated. In the case where bulk imports were not importing into contiguous tablets the code would just iterate over the tables tablets until it found the next starting point. This change recreates the TabletMetadata object when a set of files is not going to start at the next tablet in the table. A likely better way to achieve the same thing would be to reset the range on the underlying Scanner and create a new iterator, but the TabletsMetadata object does not expose the Scanner. This change also closes the TabletsMetadata objects which was not being done previously. Related to apache#5201
1 parent e8839be commit 35b45c4

File tree

1 file changed

+14
-6
lines changed
  • server/manager/src/main/java/org/apache/accumulo/manager/tableOps/bulkVer2

1 file changed

+14
-6
lines changed

server/manager/src/main/java/org/apache/accumulo/manager/tableOps/bulkVer2/LoadFiles.java

+14-6
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,11 @@ private long loadFiles(TableId tableId, Path bulkDir, LoadMappingIterator loadMa
324324
Map.Entry<KeyExtent,Bulk.Files> loadMapEntry = lmi.peek();
325325

326326
Text startRow = loadMapEntry.getKey().prevEndRow();
327-
328327
String fmtTid = FateTxId.formatTid(tid);
329328
log.trace("{}: Starting bulk load at row: {}", fmtTid, startRow);
330329

331-
Iterator<TabletMetadata> tabletIter =
332-
TabletsMetadata.builder(manager.getContext()).forTable(tableId).overlapping(startRow, null)
333-
.checkConsistency().fetch(PREV_ROW, LOCATION, LOADED).build().iterator();
330+
TabletsMetadata tm = TabletsMetadata.builder(manager.getContext()).forTable(tableId)
331+
.overlapping(startRow, null).checkConsistency().fetch(PREV_ROW, LOCATION, LOADED).build();
334332

335333
Loader loader;
336334
if (bulkInfo.tableState == TableState.ONLINE) {
@@ -342,12 +340,22 @@ private long loadFiles(TableId tableId, Path bulkDir, LoadMappingIterator loadMa
342340
loader.start(bulkDir, manager, tid, bulkInfo.setTime);
343341

344342
long t1 = System.currentTimeMillis();
343+
KeyExtent prevLastExtent = null; // KeyExtent of last tablet from prior loadMapEntry
345344
while (lmi.hasNext()) {
346345
loadMapEntry = lmi.next();
347-
List<TabletMetadata> tablets =
348-
findOverlappingTablets(fmtTid, loadMapEntry.getKey(), tabletIter);
346+
KeyExtent loadMapKey = loadMapEntry.getKey();
347+
if (prevLastExtent != null && !loadMapKey.isPreviousExtent(prevLastExtent)) {
348+
tm.close();
349+
log.trace("Advance to next prevLastExtent: {}", loadMapKey.prevEndRow());
350+
tm = TabletsMetadata.builder(manager.getContext()).forTable(tableId)
351+
.overlapping(loadMapKey.prevEndRow(), null).checkConsistency()
352+
.fetch(PREV_ROW, LOCATION, LOADED).build();
353+
}
354+
List<TabletMetadata> tablets = findOverlappingTablets(fmtTid, loadMapKey, tm.iterator());
349355
loader.load(tablets, loadMapEntry.getValue());
356+
prevLastExtent = tablets.get(tablets.size() - 1).getExtent();
350357
}
358+
tm.close();
351359

352360
log.trace("{}: Completed Finding Overlapping Tablets", fmtTid);
353361

0 commit comments

Comments
 (0)