mbien commented on code in PR #277:
URL: https://github.com/apache/maven-indexer/pull/277#discussion_r1032837361


##########
indexer-core/src/main/java/org/apache/maven/index/updater/IndexDataReader.java:
##########
@@ -277,17 +277,17 @@ private IndexWriter tempWriter( final String name ) 
throws IOException
     }
 
     private void addToIndex( final Document doc, final IndexingContext 
context, final IndexWriter indexWriter,
-                             final ConcurrentMap<String, Boolean> rootGroups,
-                             final ConcurrentMap<String, Boolean> allGroups )
+                             final Set<String> rootGroups,
+                             final Set<String> allGroups )
             throws IOException
     {
         ArtifactInfo ai = IndexUtils.constructArtifactInfo( doc, context );
         if ( ai != null )
         {
             indexWriter.addDocument( IndexUtils.updateDocument( doc, context, 
false, ai ) );
 
-            rootGroups.putIfAbsent( ai.getRootGroup(), Boolean.TRUE );
-            allGroups.putIfAbsent( ai.getGroupId(), Boolean.TRUE );
+            rootGroups.add( ai.getRootGroup() );
+            allGroups.add( ai.getGroupId() );

Review Comment:
   `add` should be a little bit faster compared to `putIfAbsent` in the 
concurrent case. But since so much IO is going on it goes down in the noise.



##########
indexer-core/src/main/java/org/apache/maven/index/updater/IndexDataReader.java:
##########
@@ -165,8 +165,8 @@ private IndexDataReadResult readIndexMT( IndexWriter w, 
IndexingContext context
 
         final Document theEnd = new Document();
 
-        ConcurrentMap<String, Boolean> rootGroups = new ConcurrentHashMap<>();
-        ConcurrentMap<String, Boolean> allGroups = new ConcurrentHashMap<>();
+        Set<String> rootGroups = ConcurrentHashMap.newKeySet();
+        Set<String> allGroups = ConcurrentHashMap.newKeySet();

Review Comment:
   I tried to size them appropriately (central has about 70k groups, and 
resizing CHMs has a larger impact than normal maps), but since this made no 
performance difference I left the defaults as is.



-- 
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: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to