This is an automated email from the ASF dual-hosted git repository.

keith-turner pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/main by this push:
     new 5d6c98f2d9 Use new stream mapMulti to construct GC refs. (#6660)
5d6c98f2d9 is described below

commit 5d6c98f2d947effefcf16038d785040babdd3d21
Author: Keith Turner <[email protected]>
AuthorDate: Wed Nov 18 18:30:52 2026 -0500

    Use new stream mapMulti to construct GC refs. (#6660)
    
    Java 16 added a new stream method called mapMulti that can be used to
    instead of flatMap.  Used this new method in GC reference construction
    code. The updates are more compact and probably more efficient.
---
 .../main/java/org/apache/accumulo/gc/GCRun.java    | 25 ++++------------------
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java 
b/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
index 8b02e7909e..78df80d7fc 100644
--- a/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
+++ b/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
@@ -58,7 +58,6 @@ import org.apache.accumulo.core.gc.Reference;
 import org.apache.accumulo.core.gc.ReferenceFile;
 import org.apache.accumulo.core.manager.state.tables.TableState;
 import org.apache.accumulo.core.metadata.RootTable;
-import org.apache.accumulo.core.metadata.StoredTabletFile;
 import org.apache.accumulo.core.metadata.SystemTables;
 import org.apache.accumulo.core.metadata.ValidationUtil;
 import org.apache.accumulo.core.metadata.schema.Ample;
@@ -186,8 +185,7 @@ public class GCRun implements GarbageCollectionEnvironment {
           .checkConsistency().fetch(DIR, FILES, SCANS).build().stream();
     }
 
-    // there is a lot going on in this "one line" so see below for more info
-    var tabletReferences = tabletStream.flatMap(tm -> {
+    var tabletReferences = tabletStream.<Reference>mapMulti((tm, refConsumer) 
-> {
       var tableId = tm.getTableId();
 
       // verify that dir and prev row entries present for to check for 
complete row scan
@@ -199,24 +197,9 @@ public class GCRun implements GarbageCollectionEnvironment 
{
             + tm.sawPrevEndRow());
       }
 
-      // combine all the entries read from file and scan columns in the 
metadata table
-      Stream<StoredTabletFile> stfStream = tm.getFiles().stream();
-      // map the files to Reference objects
-      var fileStream = stfStream.map(f -> ReferenceFile.forFile(tableId, f));
-
-      // scans are normally empty, so only introduce a layer of indirection 
when needed
-      final var tmScans = tm.getScans();
-      if (!tmScans.isEmpty()) {
-        var scanStream = tmScans.stream().map(s -> 
ReferenceFile.forScan(tableId, s));
-        fileStream = Stream.concat(fileStream, scanStream);
-      }
-      // if dirName is populated, then we have a tablet directory aka srv:dir
-      if (tm.getDirName() != null) {
-        // add the tablet directory to the stream
-        var tabletDir = ReferenceFile.forDirectory(tableId, tm.getDirName());
-        fileStream = Stream.concat(fileStream, Stream.of(tabletDir));
-      }
-      return fileStream;
+      tm.getFiles().forEach(f -> 
refConsumer.accept(ReferenceFile.forFile(tableId, f)));
+      tm.getScans().forEach(s -> 
refConsumer.accept(ReferenceFile.forScan(tableId, s)));
+      refConsumer.accept(ReferenceFile.forDirectory(tableId, tm.getDirName()));
     });
 
     var scanServerRefs = context.getAmple().scanServerRefs().list()

Reply via email to