maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ogusa...@apache.org
Subject svn commit: r707775 - in /maven/mercury/trunk: mercury-it/src/test/java/org/apache/maven/mercury/dependency/tests/DependencyTreeBuilderTest.java mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java
Date Fri, 24 Oct 2008 22:54:32 GMT
Author: ogusakov
Date: Fri Oct 24 15:54:32 2008
New Revision: 707775

URL: http://svn.apache.org/viewvc?rev=707775&view=rev
Log:
tree builder optimized - removed duplicate node creation

Modified:
    maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/dependency/tests/DependencyTreeBuilderTest.java
    maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java

Modified: maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/dependency/tests/DependencyTreeBuilderTest.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/dependency/tests/DependencyTreeBuilderTest.java?rev=707775&r1=707774&r2=707775&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/dependency/tests/DependencyTreeBuilderTest.java
(original)
+++ maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/dependency/tests/DependencyTreeBuilderTest.java
Fri Oct 24 15:54:32 2008
@@ -17,7 +17,6 @@
 import org.apache.maven.mercury.builder.api.DependencyProcessor;
 import org.apache.maven.mercury.metadata.DependencyBuilder;
 import org.apache.maven.mercury.metadata.DependencyBuilderFactory;
-import org.apache.maven.mercury.metadata.DependencyTreeBuilder;
 import org.apache.maven.mercury.metadata.MetadataTreeException;
 import org.apache.maven.mercury.metadata.MetadataTreeNode;
 import org.apache.maven.mercury.repository.api.ArtifactResults;

Modified: maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java?rev=707775&r1=707774&r2=707775&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java
(original)
+++ maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java
Fri Oct 24 15:54:32 2008
@@ -3,6 +3,7 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Comparator;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -23,12 +24,12 @@
 
 /**
  * This is the new entry point into Artifact resolution process.
- * It implements 3-phase 
  * 
  * @author Oleg Gusakov
  * @version $Id: MetadataTree.java 681180 2008-07-30 19:34:16Z ogusakov $
  */
-public class DependencyTreeBuilder implements DependencyBuilder
+class DependencyTreeBuilder
+implements DependencyBuilder
 {
   Language _lang = new DefaultLanguage(DependencyTreeBuilder.class);
   
@@ -40,6 +41,8 @@
   
   MetadataTreeNode _root;
   
+  Map< String, MetadataTreeNode > existingNodes;
+  
   /**
    * creates an instance of MetadataTree. Use this instance to 
    * <ul>
@@ -81,9 +84,6 @@
     this._reader = new VirtualRepositoryReader( repositories, processor );
   }
   //------------------------------------------------------------------------
-  /* (non-Javadoc)
-   * @see org.apache.maven.mercury.metadata.DependencyBuilder#buildTree(org.apache.maven.mercury.artifact.ArtifactBasicMetadata)
-   */
   public MetadataTreeNode buildTree( ArtifactBasicMetadata startMD )
   throws MetadataTreeException
   {
@@ -100,6 +100,8 @@
       throw new MetadataTreeException(e);
     }
     
+    existingNodes = new HashMap<String, MetadataTreeNode>(128);
+    
     _root = createNode( startMD, null, startMD );
     return _root;
   }
@@ -111,6 +113,11 @@
 
     ArtifactMetadata mr;
     
+    MetadataTreeNode existingNode = existingNodes.get( nodeQuery.toString() );
+    
+    if( existingNode != null )
+      return existingNode;
+    
     try
     {
         mr = _reader.readDependencies( nodeMD );
@@ -128,9 +135,6 @@
         ArtifactBasicResults res = _reader.readVersions( dependencies );
         Map<ArtifactBasicMetadata, List<ArtifactBasicMetadata>> expandedDeps
= res.getResults();
         
-//        if( expandedDeps == null )
-//          return node;
-      
         for( ArtifactBasicMetadata md : dependencies )
         {
           List<ArtifactBasicMetadata> versions = expandedDeps.get( md );
@@ -175,6 +179,8 @@
           else
             node.addQuery(md);
       }
+        
+      existingNodes.put( nodeQuery.toString(), node );
     
       return node;
     }
@@ -240,9 +246,6 @@
     return true;
   }
   //-----------------------------------------------------
-  /* (non-Javadoc)
-   * @see org.apache.maven.mercury.metadata.DependencyBuilder#resolveConflicts(org.apache.maven.mercury.artifact.ArtifactScopeEnum)
-   */
   public List<ArtifactMetadata> resolveConflicts( ArtifactScopeEnum scope )
   throws MetadataTreeException
   {



Mime
View raw message