You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by th...@apache.org on 2014/11/19 12:03:20 UTC
svn commit: r1640523 - in
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak:
plugins/index/property/strategy/ContentMirrorStoreStrategy.java
query/FilterIterators.java spi/query/Cursors.java
Author: thomasm
Date: Wed Nov 19 11:03:19 2014
New Revision: 1640523
URL: http://svn.apache.org/r1640523
Log:
OAK-2228 Changing the query traversal limit should affect already started queries
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/ContentMirrorStoreStrategy.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/FilterIterators.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Cursors.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/ContentMirrorStoreStrategy.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/ContentMirrorStoreStrategy.java?rev=1640523&r1=1640522&r2=1640523&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/ContentMirrorStoreStrategy.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/ContentMirrorStoreStrategy.java Wed Nov 19 11:03:19 2014
@@ -32,6 +32,7 @@ import org.apache.jackrabbit.oak.api.Typ
import org.apache.jackrabbit.oak.commons.PathUtils;
import org.apache.jackrabbit.oak.plugins.memory.MemoryChildNodeEntry;
import org.apache.jackrabbit.oak.query.FilterIterators;
+import org.apache.jackrabbit.oak.query.QueryEngineSettings;
import org.apache.jackrabbit.oak.spi.query.Filter;
import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -267,7 +268,7 @@ public class ContentMirrorStoreStrategy
* Keep the returned path, to avoid returning duplicate entries.
*/
private final Set<String> knownPaths = Sets.newHashSet();
- private final long maxMemoryEntries;
+ private final QueryEngineSettings settings;
PathIterator(Filter filter, String indexName, String pathPrefix) {
this.filter = filter;
@@ -284,7 +285,7 @@ public class ContentMirrorStoreStrategy
}
parentPath = "";
currentPath = "/";
- this.maxMemoryEntries = filter.getQueryEngineSettings().getLimitInMemory();
+ this.settings = filter.getQueryEngineSettings();
}
void enqueue(Iterator<? extends ChildNodeEntry> it) {
@@ -335,7 +336,7 @@ public class ContentMirrorStoreStrategy
readCount++;
if (readCount % TRAVERSING_WARN == 0) {
- FilterIterators.checkReadLimit(readCount, maxMemoryEntries);
+ FilterIterators.checkReadLimit(readCount, settings);
LOG.warn("Traversed " + readCount + " nodes using index " + indexName + " with filter " + filter);
}
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/FilterIterators.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/FilterIterators.java?rev=1640523&r1=1640522&r2=1640523&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/FilterIterators.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/FilterIterators.java Wed Nov 19 11:03:19 2014
@@ -35,10 +35,11 @@ public class FilterIterators {
* Verify the number of in-memory nodes is below the limit.
*
* @param count the number of nodes
- * @param maxMemoryEntries the maximum number of nodes
+ * @param settings the query engine settings
* @throws UnsupportedOperationException if the limit was exceeded
*/
- public static void checkMemoryLimit(long count, long maxMemoryEntries) {
+ public static void checkMemoryLimit(long count, QueryEngineSettings settings) {
+ long maxMemoryEntries = settings.getLimitInMemory();
if (count > maxMemoryEntries) {
String message = "The query read more than " +
maxMemoryEntries + " nodes in memory.";
@@ -54,9 +55,11 @@ public class FilterIterators {
* Verify the number of node read operations is below the limit.
*
* @param count the number of read operations
+ * @param settings the query engine settings
* @throws UnsupportedOperationException if the limit was exceeded
*/
- public static void checkReadLimit(long count, long maxReadEntries) {
+ public static void checkReadLimit(long count, QueryEngineSettings settings) {
+ long maxReadEntries = settings.getLimitReads();
if (count > maxReadEntries) {
String message = "The query read or traversed more than " +
maxReadEntries + " nodes.";
@@ -116,14 +119,14 @@ public class FilterIterators {
static class DistinctIterator<K> implements Iterator<K> {
private final Iterator<K> source;
- private final long maxMemoryEntries;
+ private final QueryEngineSettings settings;
private final HashSet<K> distinctSet;
private K current;
private boolean end;
DistinctIterator(Iterator<K> source, QueryEngineSettings settings) {
this.source = source;
- this.maxMemoryEntries = settings.getLimitInMemory();
+ this.settings = settings;
distinctSet = new HashSet<K>();
}
@@ -134,7 +137,7 @@ public class FilterIterators {
while (source.hasNext()) {
current = source.next();
if (distinctSet.add(current)) {
- checkMemoryLimit(distinctSet.size(), maxMemoryEntries);
+ checkMemoryLimit(distinctSet.size(), settings);
return;
}
}
@@ -180,7 +183,7 @@ public class FilterIterators {
static class SortIterator<K> implements Iterator<K> {
private final Iterator<K> source;
- private final long maxMemoryEntries;
+ private final QueryEngineSettings settings;
private final Comparator<K> orderBy;
private Iterator<K> result;
private final int max;
@@ -189,7 +192,7 @@ public class FilterIterators {
this.source = source;
this.orderBy = orderBy;
this.max = max;
- this.maxMemoryEntries = settings.getLimitInMemory();
+ this.settings = settings;
}
private void init() {
@@ -200,7 +203,7 @@ public class FilterIterators {
while (source.hasNext()) {
K x = source.next();
list.add(x);
- checkMemoryLimit(list.size(), maxMemoryEntries);
+ checkMemoryLimit(list.size(), settings);
// from time to time, sort and truncate
// this should results in O(n*log(2*keep)) operations,
// which is close to the optimum O(n*log(keep))
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=1640523&r1=1640522&r2=1640523&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 Nov 19 11:03:19 2014
@@ -173,11 +173,10 @@ public class Cursors {
it = Iterators.filter(it, new Predicate<String>() {
private final HashSet<String> known = new HashSet<String>();
- private final long maxMemoryEntries = settings.getLimitInMemory();
@Override
public boolean apply(@Nullable String input) {
- FilterIterators.checkMemoryLimit(known.size(), maxMemoryEntries);
+ FilterIterators.checkMemoryLimit(known.size(), settings);
// Set.add returns true for new entries
return known.add(input);
}
@@ -223,11 +222,11 @@ public class Cursors {
private boolean closed;
- private final long maxReadEntries;
-
+ private final QueryEngineSettings settings;
+
public TraversingCursor(Filter filter, NodeState rootState) {
this.filter = filter;
- this.maxReadEntries = filter.getQueryEngineSettings().getLimitReads();
+ this.settings = filter.getQueryEngineSettings();
String path = filter.getPath();
parentPath = null;
@@ -309,7 +308,7 @@ public class Cursors {
readCount++;
if (readCount % 1000 == 0) {
- FilterIterators.checkReadLimit(readCount, maxReadEntries);
+ FilterIterators.checkReadLimit(readCount, settings);
LOG.warn("Traversed " + readCount + " nodes with filter " + filter + "; consider creating an index or changing the query");
}
@@ -410,14 +409,14 @@ public class Cursors {
return;
}
secondSet.put(p2, s);
- FilterIterators.checkMemoryLimit(secondSet.size(), settings.getLimitInMemory());
+ FilterIterators.checkMemoryLimit(secondSet.size(), settings);
}
}
}
private void markSeen(String path) {
seen.add(path);
- FilterIterators.checkMemoryLimit(seen.size(), settings.getLimitInMemory());
+ FilterIterators.checkMemoryLimit(seen.size(), settings);
}
}
@@ -493,7 +492,7 @@ public class Cursors {
private void markSeen(String path) {
seen.add(path);
- FilterIterators.checkMemoryLimit(seen.size(), settings.getLimitInMemory());
+ FilterIterators.checkMemoryLimit(seen.size(), settings);
}
}