jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1433989 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/ main/java/org/apache/jackrabbit/oak/plugins/index/p2/ main/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ main/java/org...
Date Wed, 16 Jan 2013 15:38:43 GMT
Author: thomasm
Date: Wed Jan 16 15:38:43 2013
New Revision: 1433989

URL: http://svn.apache.org/viewvc?rev=1433989&view=rev
Log:
OAK-404 Log (slow) queries

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndex.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexLookup.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2Index.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexLookup.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategy.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/IndexStoreStrategy.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Cursors.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndex.java?rev=1433989&r1=1433988&r2=1433989&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndex.java
Wed Jan 16 15:38:43 2013
@@ -71,7 +71,7 @@ class NodeTypeIndex implements QueryInde
                     "NodeType index is used even when no index is available for filter "
+ filter);
         }
         return Cursors.newPathCursorDistinct(lookup.query(
-                resolveNodeType(root, filter.getNodeType())));
+                filter, resolveNodeType(root, filter.getNodeType())));
     }
     
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexLookup.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexLookup.java?rev=1433989&r1=1433988&r2=1433989&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexLookup.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexLookup.java
Wed Jan 16 15:38:43 2013
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.plugin
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.PropertyValue;
 import org.apache.jackrabbit.oak.plugins.index.p2.Property2IndexLookup;
+import org.apache.jackrabbit.oak.spi.query.Filter;
 import org.apache.jackrabbit.oak.spi.query.PropertyValues;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
@@ -74,15 +75,16 @@ class NodeTypeIndexLookup implements Jcr
     /**
      * Returns the paths that match the given node types.
      *
+     * @param filter the filter (used for logging)
      * @param nodeTypes the names of the node types to match.
      * @return the matched paths (the result might contain duplicate entries)
      */
-    public Iterable<String> query(Iterable<String> nodeTypes) {
+    public Iterable<String> query(Filter filter, Iterable<String> nodeTypes)
{
         final PropertyValue ntNames = PropertyValues.newName(nodeTypes);
         Property2IndexLookup lookup = new Property2IndexLookup(root);
         return Iterables.concat(
-                lookup.query(JCR_PRIMARYTYPE, ntNames),
-                lookup.query(JCR_MIXINTYPES, ntNames));
+                lookup.query(filter, JCR_PRIMARYTYPE, ntNames),
+                lookup.query(filter, JCR_MIXINTYPES, ntNames));
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2Index.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2Index.java?rev=1433989&r1=1433988&r2=1433989&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2Index.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2Index.java
Wed Jan 16 15:38:43 2013
@@ -139,11 +139,11 @@ class Property2Index implements QueryInd
                 if (pr.firstIncluding && pr.lastIncluding
                     && pr.first != null && pr.first.equals(pr.last)) {
                     // "[property] = $value"
-                    paths = lookup.query(pr.propertyName, pr.first);
+                    paths = lookup.query(filter, pr.propertyName, pr.first);
                     break;
                 } else if (pr.first == null && pr.last == null) {
                     // "[property] is not null"
-                    paths = lookup.query(pr.propertyName, null);
+                    paths = lookup.query(filter, pr.propertyName, null);
                     break;
                 }
             }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexLookup.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexLookup.java?rev=1433989&r1=1433988&r2=1433989&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexLookup.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexLookup.java
Wed Jan 16 15:38:43 2013
@@ -30,6 +30,7 @@ import org.apache.jackrabbit.oak.commons
 import org.apache.jackrabbit.oak.plugins.index.IndexConstants;
 import org.apache.jackrabbit.oak.plugins.index.p2.strategy.ContentMirrorStoreStrategy;
 import org.apache.jackrabbit.oak.plugins.index.p2.strategy.IndexStoreStrategy;
+import org.apache.jackrabbit.oak.spi.query.Filter;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
@@ -91,13 +92,13 @@ public class Property2IndexLookup {
         return false;
     }
     
-    public Iterable<String> query(String name, PropertyValue value) {
+    public Iterable<String> query(Filter filter, String name, PropertyValue value)
{
         NodeState state = getIndexDataNode(root, name);
         if (state == null) {
             throw new IllegalArgumentException("No index for " + name);
         }
         List<String> values = value == null ? null : Property2Index.encode(value);
-        return store.query(name, state, values);
+        return store.query(filter, name, state, values);
     }
 
     public double getCost(String name, PropertyValue value) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategy.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategy.java?rev=1433989&r1=1433988&r2=1433989&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategy.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategy.java
Wed Jan 16 15:38:43 2013
@@ -28,6 +28,7 @@ import org.apache.jackrabbit.oak.api.Pro
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryChildNodeEntry;
+import org.apache.jackrabbit.oak.spi.query.Filter;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
@@ -149,12 +150,12 @@ public class ContentMirrorStoreStrategy 
     }
     
     @Override
-    public Iterable<String> query(final String indexName, 
+    public Iterable<String> query(final Filter filter, final String indexName, 
             final NodeState index, final Iterable<String> values) {
         return new Iterable<String>() {
             @Override
             public Iterator<String> iterator() {
-                PathIterator it = new PathIterator(indexName);
+                PathIterator it = new PathIterator(filter, indexName);
                 if (values == null) {
                     it.setPathContainsValue(true);
                     it.enqueue(index.getChildNodeEntries().iterator());
@@ -202,6 +203,7 @@ public class ContentMirrorStoreStrategy 
      */
     static class PathIterator implements Iterator<String> {
         
+        private final Filter filter;
         private final String indexName;
         private final Deque<Iterator<? extends ChildNodeEntry>> nodeIterators
=
                 Queues.newArrayDeque();
@@ -217,7 +219,8 @@ public class ContentMirrorStoreStrategy 
          */
         private final Set<String> knownPaths = Sets.newHashSet();
         
-        PathIterator(String indexName) {
+        PathIterator(Filter filter, String indexName) {
+            this.filter = filter;
             this.indexName = indexName;
             parentPath = "";
             currentPath = "/";
@@ -247,8 +250,8 @@ public class ContentMirrorStoreStrategy 
                     ChildNodeEntry entry = iterator.next();
 
                     readCount++;
-                    if (readCount % 100 == 0) {
-                        LOG.warn("Traversed " + readCount + " nodes using index " + indexName);
+                    if (readCount % 1000 == 0) {
+                        LOG.warn("Traversed " + readCount + " nodes using index " + indexName
+ " with filter " + filter);
                     }
 
                     NodeState node = entry.getNodeState();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/IndexStoreStrategy.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/IndexStoreStrategy.java?rev=1433989&r1=1433988&r2=1433989&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/IndexStoreStrategy.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/IndexStoreStrategy.java
Wed Jan 16 15:38:43 2013
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.oak.plugins.index.p2.strategy;
 
 import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.spi.query.Filter;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
@@ -53,12 +54,13 @@ public interface IndexStoreStrategy {
     /**
      * Search for a given set of values.
      * 
+     * @param filter the filter (used for logging)
      * @param indexName the name of the index (for logging)
      * @param index index node (may not be null)
      * @param values values to look for (null to check for property existence)
      * @return an iterator of paths
      */
-    Iterable<String> query(String indexName, NodeState index, Iterable<String>
values);
+    Iterable<String> query(Filter filter, String indexName, NodeState index, Iterable<String>
values);
 
     /**
      * Count the occurrence of a given set of values. Used in calculating the

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Cursors.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Cursors.java?rev=1433989&r1=1433988&r2=1433989&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Cursors.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Cursors.java
Wed Jan 16 15:38:43 2013
@@ -233,7 +233,7 @@ public class Cursors {
                     ChildNodeEntry entry = iterator.next();
 
                     readCount++;
-                    if (readCount % 100 == 0) {
+                    if (readCount % 1000 == 0) {
                         LOG.warn("Traversed " + readCount + " nodes with filter " + filter
+ "; consider creating an index or changing the query");
                     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java?rev=1433989&r1=1433988&r2=1433989&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java
Wed Jan 16 15:38:43 2013
@@ -100,7 +100,7 @@ public class IndexHookManagerTest {
     }
     
     private static Set<String> find(Property2IndexLookup lookup, String name, String
value) {
-        return Sets.newHashSet(lookup.query(name, PropertyValues.newString(value)));
+        return Sets.newHashSet(lookup.query(null, name, PropertyValues.newString(value)));
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexTest.java?rev=1433989&r1=1433988&r2=1433989&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexTest.java
Wed Jan 16 15:38:43 2013
@@ -85,7 +85,7 @@ public class Property2IndexTest {
     }
     
     private static Set<String> find(Property2IndexLookup lookup, String name, String
value) {
-        return Sets.newHashSet(lookup.query(name, value == null ? null : PropertyValues.newString(value)));
+        return Sets.newHashSet(lookup.query(null, name, value == null ? null : PropertyValues.newString(value)));
     }
 
     @Test



Mime
View raw message