Skip to content

Commit 0ec8982

Browse files
committed
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 6555fc1 commit 0ec8982

File tree

1 file changed

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

1 file changed

+13
-4
lines changed

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

+13-4
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,8 @@ private long loadFiles(TableId tableId, Path bulkDir, LoadMappingIterator loadMa
325325

326326
Text startRow = loadMapEntry.getKey().prevEndRow();
327327

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

332331
Loader loader;
333332
if (bulkInfo.tableState == TableState.ONLINE) {
@@ -339,11 +338,21 @@ private long loadFiles(TableId tableId, Path bulkDir, LoadMappingIterator loadMa
339338
loader.start(bulkDir, manager, tid, bulkInfo.setTime);
340339

341340
long t1 = System.currentTimeMillis();
341+
KeyExtent prevLastExtent = null; // KeyExtent of last tablet from prior loadMapEntry
342342
while (lmi.hasNext()) {
343343
loadMapEntry = lmi.next();
344-
List<TabletMetadata> tablets = findOverlappingTablets(loadMapEntry.getKey(), tabletIter);
344+
KeyExtent loadMapKey = loadMapEntry.getKey();
345+
if (prevLastExtent != null && !loadMapKey.isPreviousExtent(prevLastExtent)) {
346+
tm.close();
347+
tm = TabletsMetadata.builder(manager.getContext()).forTable(tableId)
348+
.overlapping(loadMapKey.prevEndRow(), null).checkConsistency()
349+
.fetch(PREV_ROW, LOCATION, LOADED).build();
350+
}
351+
List<TabletMetadata> tablets = findOverlappingTablets(loadMapKey, tm.iterator());
345352
loader.load(tablets, loadMapEntry.getValue());
353+
prevLastExtent = tablets.get(tablets.size() - 1).getExtent();
346354
}
355+
tm.close();
347356

348357
long sleepTime = loader.finish();
349358
if (sleepTime > 0) {

0 commit comments

Comments
 (0)