archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1053855 - in /archiva/sandbox/populate-jcr-repo/src/main/java/org/apache/archiva/metadata/repository/jcr: PopulateRepoApp.java QueryRepoApp.java
Date Thu, 30 Dec 2010 11:32:17 GMT
Author: brett
Date: Thu Dec 30 11:32:16 2010
New Revision: 1053855

URL: http://svn.apache.org/viewvc?rev=1053855&view=rev
Log:
test JSR-170 SQL-1 queries to avoid problem in Jackrabbit with SQL-2

Modified:
    archiva/sandbox/populate-jcr-repo/src/main/java/org/apache/archiva/metadata/repository/jcr/PopulateRepoApp.java
    archiva/sandbox/populate-jcr-repo/src/main/java/org/apache/archiva/metadata/repository/jcr/QueryRepoApp.java

Modified: archiva/sandbox/populate-jcr-repo/src/main/java/org/apache/archiva/metadata/repository/jcr/PopulateRepoApp.java
URL: http://svn.apache.org/viewvc/archiva/sandbox/populate-jcr-repo/src/main/java/org/apache/archiva/metadata/repository/jcr/PopulateRepoApp.java?rev=1053855&r1=1053854&r2=1053855&view=diff
==============================================================================
--- archiva/sandbox/populate-jcr-repo/src/main/java/org/apache/archiva/metadata/repository/jcr/PopulateRepoApp.java
(original)
+++ archiva/sandbox/populate-jcr-repo/src/main/java/org/apache/archiva/metadata/repository/jcr/PopulateRepoApp.java
Thu Dec 30 11:32:16 2010
@@ -66,7 +66,7 @@ public class PopulateRepoApp
             IOFileFilter dirFilter = new NotFileFilter( new WildcardFileFilter( ".index*"
) );
             IOFileFilter fileFilter = new NotFileFilter( new WildcardFileFilter(
                 new String[]{"*.asc", "*.md5", "*.sha1", "maven-metadata*.xml"} ) );
-            Collection<File> files = FileUtils.listFiles( new File( basedir, "org/apache/archiva"
), fileFilter, dirFilter );
+            Collection<File> files = FileUtils.listFiles( basedir, fileFilter, dirFilter
);
 
             int index = basedir.getAbsolutePath().length() + 1;
 

Modified: archiva/sandbox/populate-jcr-repo/src/main/java/org/apache/archiva/metadata/repository/jcr/QueryRepoApp.java
URL: http://svn.apache.org/viewvc/archiva/sandbox/populate-jcr-repo/src/main/java/org/apache/archiva/metadata/repository/jcr/QueryRepoApp.java?rev=1053855&r1=1053854&r2=1053855&view=diff
==============================================================================
--- archiva/sandbox/populate-jcr-repo/src/main/java/org/apache/archiva/metadata/repository/jcr/QueryRepoApp.java
(original)
+++ archiva/sandbox/populate-jcr-repo/src/main/java/org/apache/archiva/metadata/repository/jcr/QueryRepoApp.java
Thu Dec 30 11:32:16 2010
@@ -29,6 +29,7 @@ import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.Row;
 
@@ -50,38 +51,87 @@ public class QueryRepoApp
         {
             Session session = jcrMetadataRepository.getJcrSession();
 
-            System.out.println( "querying" );
-            long time = System.currentTimeMillis();
+            QueryManager queryManager = session.getWorkspace().getQueryManager();
 
-            String q = "SELECT size FROM [archiva:artifact] AS artifact";
+            queryAllArtifactsInRepo( queryManager );
 
-            Query query = session.getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2
);
+            queryAllProjectsInRepo( queryManager );
 
-            QueryResult queryResult = query.execute();
-            System.out.println( "query in " + ( System.currentTimeMillis() - time ) + "ms"
);
-
-            time = System.currentTimeMillis();
-
-            long totalSize = 0, totalJars = 0, totalArtifacts = 0;
-            for ( Row row : JcrUtils.getRows( queryResult ) )
-            {
-                if ( row.getPath().startsWith( "/repositories/internal/content/" ) )
-                {
-                    totalSize += row.getValue( "size" ).getLong();
-                    if ( row.getNode().getName().endsWith( ".jar" ) )
-                    {
-                        totalJars++;
-                    }
-                    totalArtifacts++;
-                }
-            }
-            System.out.println(
-                totalArtifacts + " artifacts, " + totalSize + " bytes, " + totalJars + "
jars (count in " +
-                    ( System.currentTimeMillis() - time ) + "ms)" );
+            queryAllGroupsInRepo( queryManager );
         }
         finally
         {
             jcrMetadataRepository.close();
         }
     }
+
+    private static void queryAllGroupsInRepo( QueryManager queryManager )
+        throws RepositoryException
+    {
+        System.out.println( "querying # groups in repo" );
+
+        long time = System.currentTimeMillis();
+//            query = queryManager.createQuery(
+//                "SELECT * FROM [archiva:namespace] WHERE ISDESCENDANTNODE([/repositories/internal/content])
AND namespace IS NOT NULL",
+//                Query.JCR_SQL2 );
+        Query query = queryManager.createQuery(
+            "SELECT * FROM archiva:namespace WHERE jcr:path LIKE '/repositories/internal/content/%'
AND namespace IS NOT NULL ORDER BY jcr:score",
+            Query.SQL );
+        System.out.println(
+            "groups = " + query.execute().getRows().getSize() + " in " + ( System.currentTimeMillis()
- time ) +
+                " ms" );
+    }
+
+    private static void queryAllProjectsInRepo( QueryManager queryManager )
+        throws RepositoryException
+    {
+        System.out.println( "querying # projects in repo" );
+
+        long time = System.currentTimeMillis();
+        Query query = queryManager.createQuery(
+            "SELECT * FROM archiva:project WHERE jcr:path LIKE '/repositories/internal/content/%'
ORDER BY jcr:score",
+            Query.SQL );
+//            query = queryManager.createQuery(
+//                "SELECT * FROM [archiva:project] WHERE ISDESCENDANTNODE([/repositories/internal/content])",
+//                Query.JCR_SQL2 );
+        System.out.println(
+            "projects = " + query.execute().getRows().getSize() + " in " + ( System.currentTimeMillis()
- time ) +
+                " ms" );
+    }
+
+    private static void queryAllArtifactsInRepo( QueryManager queryManager )
+        throws RepositoryException
+    {
+        System.out.println( "querying # artifacts in repo" );
+
+        long time = System.currentTimeMillis();
+
+        // fails on Jackrabbit 2.2.0
+//            String q = "SELECT size FROM [archiva:artifact] AS artifact WHERE ISDESCENDANTNODE([/repositories/internal/content])";
+//            Query query = session.getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2
);
+
+//            String q = "SELECT size FROM archiva:artifact WHERE jcr:path LIKE '/repositories/internal/content/%'";
+//            Query query = session.getWorkspace().getQueryManager().createQuery( q, Query.SQL
);
+//
+        String q = "SELECT size FROM [archiva:artifact]";
+        Query query = queryManager.createQuery( q, Query.JCR_SQL2 );
+
+        QueryResult queryResult = query.execute();
+        System.out.println( "query in " + ( System.currentTimeMillis() - time ) + "ms" );
+
+        time = System.currentTimeMillis();
+
+        long totalSize = 0, totalJars = 0, totalArtifacts = 0;
+        for ( Row row : JcrUtils.getRows( queryResult ) )
+        {
+            totalSize += row.getValue( "size" ).getLong();
+            if ( row.getNode().getName().endsWith( ".jar" ) )
+            {
+                totalJars++;
+            }
+            totalArtifacts++;
+        }
+        System.out.println( totalArtifacts + " artifacts, " + totalSize + " bytes, " + totalJars
+ " jars (count in " +
+                                ( System.currentTimeMillis() - time ) + "ms)" );
+    }
 }



Mime
View raw message