keith-turner commented on code in PR #3980:
URL: https://github.com/apache/accumulo/pull/3980#discussion_r1447706537


##########
core/src/main/java/org/apache/accumulo/core/util/Merge.java:
##########
@@ -149,17 +148,37 @@ public void mergomatic(AccumuloClient client, String 
table, Text start, Text end
         throw new IllegalArgumentException("cannot merge tablets on the 
metadata table");
       }
       List<Size> sizes = new ArrayList<>();
-      long totalSize = 0;
-      // Merge any until you get larger than the goal size, and then merge one 
less tablet
-      Iterator<Size> sizeIterator = getSizeIterator(client, table, start, end);
-      while (sizeIterator.hasNext()) {
-        Size next = sizeIterator.next();
-        totalSize += next.size;
-        sizes.add(next);
-        if (totalSize > goalSize) {
-          totalSize = mergeMany(client, table, sizes, goalSize, force, false);
-        }
+      AtomicLong totalSize = new AtomicLong();
+
+      TableId tableId;
+      ClientContext context = (ClientContext) client;
+      try {
+        tableId = context.getTableId(table);
+      } catch (Exception e) {
+        throw new MergeException(e);
+      }
+      try (TabletsMetadata tablets = 
TabletsMetadata.builder(context).scanMetadataTable()
+          .overRange(new KeyExtent(tableId, end, 
start).toMetaRange()).fetch(FILES, PREV_ROW)
+          .build()) {
+        tablets.stream().map(tm -> {
+          long size = 
tm.getFilesMap().values().stream().mapToLong(DataFileValue::getSize).sum();
+          return new Size(tm.getExtent(), size);
+        }).forEach(next -> {

Review Comment:
   This is a style comment so feel free to ignore it.  I would call 
`.iterator()` on the stream and use the while loop the old code had over the 
iterator in order to avoid having to use the AtomicLong to sum data in the 
lambda.



-- 
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]

Reply via email to