joerghoh commented on code in PR #63:
URL: 
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/63#discussion_r865841262


##########
src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java:
##########
@@ -975,52 +976,52 @@ private boolean addEntry(final Map<String, 
List<MapEntry>> entryMap, final Strin
     }
 
     /**
-     * Load aliases Search for all nodes inheriting the sling:alias
-     * property
+     * Load aliases - Search for all nodes (except under /jcr:system) below
+     * configured alias locations having the sling:alias property
      */
     private Map<String, Map<String, String>> loadAliases(final 
ResourceResolver resolver) {
         final Map<String, Map<String, String>> map = new ConcurrentHashMap<>();
-        final String queryString = updateAliasQuery();
+        final String queryString = generateAliasQuery();
+
         log.debug("start alias query: {}", queryString);
+        long queryStart = System.nanoTime();
         final Iterator<Resource> i = resolver.findResources(queryString, 
"sql");
-        log.debug("end alias query");
+        long queryElapsed = System.nanoTime() - queryStart;
+        log.debug("end alias query; elapsed {}ms", 
TimeUnit.NANOSECONDS.toMillis(queryElapsed));
+
         long count = 0;
+        long processStart = System.nanoTime();
         while (i.hasNext()) {
             count += 1;
-            final Resource resource = i.next();
-            loadAlias(resource, map);
+            loadAlias(i.next(), map);
         }
-        log.debug("read {} aliases", count);
+        long processElapsed = System.nanoTime() - processStart;
+        log.debug("processed {} aliases in {}ms", count, 
TimeUnit.NANOSECONDS.toMillis(processElapsed));
+
         return map;
     }
 
-
     /*
-    * Update alias query based on configured alias locations
-    */
-    private String updateAliasQuery(){
+     * generate alias query based on configured alias locations
+     */
+    private String generateAliasQuery() {
         final Set<String> allowedLocations = 
this.factory.getAllowedAliasLocations();
 
         StringBuilder baseQuery = new StringBuilder(ALIAS_BASE_QUERY_DEFAULT);
         baseQuery.append(" ").append("WHERE");
 
-        if(allowedLocations.isEmpty()){
+        if (allowedLocations.isEmpty()) {
             String jcrSystemPath = StringUtils.removeEnd(JCR_SYSTEM_PREFIX, 
"/");
-            baseQuery.append(" ").append("(").append("NOT 
ISDESCENDANTNODE(page,")
-                    
.append("\"").append(jcrSystemPath).append("\"").append("))");
-
-        }else{
+            baseQuery.append(" (").append("NOT 
ISDESCENDANTNODE(page,'").append(queryLiteral(jcrSystemPath)).append("'))");

Review Comment:
   would it make sense to use String.format or something else? I think it's not 
really readable what's happening here.



##########
src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java:
##########
@@ -975,52 +976,52 @@ private boolean addEntry(final Map<String, 
List<MapEntry>> entryMap, final Strin
     }
 
     /**
-     * Load aliases Search for all nodes inheriting the sling:alias
-     * property
+     * Load aliases - Search for all nodes (except under /jcr:system) below
+     * configured alias locations having the sling:alias property
      */
     private Map<String, Map<String, String>> loadAliases(final 
ResourceResolver resolver) {
         final Map<String, Map<String, String>> map = new ConcurrentHashMap<>();
-        final String queryString = updateAliasQuery();
+        final String queryString = generateAliasQuery();
+
         log.debug("start alias query: {}", queryString);
+        long queryStart = System.nanoTime();
         final Iterator<Resource> i = resolver.findResources(queryString, 
"sql");
-        log.debug("end alias query");
+        long queryElapsed = System.nanoTime() - queryStart;

Review Comment:
   I am not sure how relevant this information is, because the query itself is 
executed lazily (IIRC it just loads 20 hits on execution), and just fetching 
the additional result rows gets costly.
   
   I would drop this information and just collect the "processElapsed" value 
you capture below.



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