jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1528295 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property: PropertyIndexEditor.java PropertyIndexLookup.java strategy/UniqueEntryStoreStrategy.java
Date Wed, 02 Oct 2013 02:00:35 GMT
Author: jukka
Date: Wed Oct  2 02:00:34 2013
New Revision: 1528295

URL: http://svn.apache.org/r1528295
Log:
OAK-1059 Property index: faster unique indexes using new storage strategy

Revert revision 1528094 as it was causing integration test failures

Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/UniqueEntryStoreStrategy.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexEditor.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexLookup.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexEditor.java?rev=1528295&r1=1528294&r2=1528295&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexEditor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexEditor.java
Wed Oct  2 02:00:34 2013
@@ -45,7 +45,6 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.index.IndexEditor;
 import org.apache.jackrabbit.oak.plugins.index.property.strategy.ContentMirrorStoreStrategy;
 import org.apache.jackrabbit.oak.plugins.index.property.strategy.IndexStoreStrategy;
-import org.apache.jackrabbit.oak.plugins.index.property.strategy.UniqueEntryStoreStrategy;
 import org.apache.jackrabbit.oak.spi.commit.Editor;
 import org.apache.jackrabbit.oak.spi.query.PropertyValues;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -60,13 +59,9 @@ import org.apache.jackrabbit.oak.spi.sta
 class PropertyIndexEditor implements IndexEditor {
 
     /** Index storage strategy */
-    private static final IndexStoreStrategy MIRROR =
+    private static final IndexStoreStrategy STORE =
             new ContentMirrorStoreStrategy();
 
-    /** Index storage strategy */
-    private static final IndexStoreStrategy UNIQUE =
-            new UniqueEntryStoreStrategy();
-
     /** Parent editor, or {@code null} if this is the root editor. */
     private final PropertyIndexEditor parent;
 
@@ -84,8 +79,6 @@ class PropertyIndexEditor implements Ind
     private final Set<String> primaryTypes;
 
     private final Set<String> mixinTypes;
-    
-    private final boolean isUnique;
 
     private final Set<String> keysToCheckForUniqueness;
 
@@ -140,10 +133,8 @@ class PropertyIndexEditor implements Ind
 
         // keep track of modified keys for uniqueness checks
         if (definition.getBoolean(IndexConstants.UNIQUE_PROPERTY_NAME)) {
-            isUnique = true;
             this.keysToCheckForUniqueness = newHashSet();
         } else {
-            isUnique = false;
             this.keysToCheckForUniqueness = null;
         }
     }
@@ -157,7 +148,6 @@ class PropertyIndexEditor implements Ind
         this.primaryTypes = parent.primaryTypes;
         this.mixinTypes = parent.mixinTypes;
         this.keysToCheckForUniqueness = parent.keysToCheckForUniqueness;
-        this.isUnique = parent.isUnique;
     }
 
     /**
@@ -227,11 +217,9 @@ class PropertyIndexEditor implements Ind
 
             if (!beforeKeys.isEmpty() || !afterKeys.isEmpty()) {
                 NodeBuilder index = definition.child(INDEX_CONTENT_NODE_NAME);
-                
-                if (keysToCheckForUniqueness == null) {
-                    MIRROR.update(index, getPath(), beforeKeys, afterKeys);
-                } else {
-                    UNIQUE.update(index, getPath(), beforeKeys, afterKeys);
+                STORE.update(index, getPath(), beforeKeys, afterKeys);
+
+                if (keysToCheckForUniqueness != null) {
                     keysToCheckForUniqueness.addAll(afterKeys);
                 }
             }
@@ -246,7 +234,7 @@ class PropertyIndexEditor implements Ind
                     && !keysToCheckForUniqueness.isEmpty()) {
                 NodeState indexMeta = definition.getNodeState();
                 for (String key : keysToCheckForUniqueness) {
-                    if (UNIQUE.count(indexMeta, singleton(key), 2) > 1) {
+                    if (STORE.count(indexMeta, singleton(key), 2) > 1) {
                         throw new CommitFailedException(
                                 CONSTRAINT, 30,
                                 "Uniqueness constraint violated for key " + key);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexLookup.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexLookup.java?rev=1528295&r1=1528294&r2=1528295&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexLookup.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexLookup.java
Wed Oct  2 02:00:34 2013
@@ -34,10 +34,8 @@ import org.apache.jackrabbit.oak.api.Pro
 import org.apache.jackrabbit.oak.api.PropertyValue;
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.commons.PathUtils;
-import org.apache.jackrabbit.oak.plugins.index.IndexConstants;
 import org.apache.jackrabbit.oak.plugins.index.property.strategy.ContentMirrorStoreStrategy;
 import org.apache.jackrabbit.oak.plugins.index.property.strategy.IndexStoreStrategy;
-import org.apache.jackrabbit.oak.plugins.index.property.strategy.UniqueEntryStoreStrategy;
 import org.apache.jackrabbit.oak.spi.query.Filter;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
@@ -62,13 +60,7 @@ public class PropertyIndexLookup {
 
     private static final int MAX_COST = 100;
 
-    /** Index storage strategy */
-    private static final IndexStoreStrategy MIRROR =
-            new ContentMirrorStoreStrategy();
-
-    /** Index storage strategy */
-    private static final IndexStoreStrategy UNIQUE =
-            new UniqueEntryStoreStrategy();
+    private final IndexStoreStrategy store = new ContentMirrorStoreStrategy();
 
     private final NodeState root;
 
@@ -107,14 +99,7 @@ public class PropertyIndexLookup {
         if (indexMeta == null) {
             throw new IllegalArgumentException("No index for " + propertyName);
         }
-        return getStrategy(indexMeta).query(filter, propertyName, indexMeta, encode(value));
-    }
-        
-    private static IndexStoreStrategy getStrategy(NodeState indexMeta) {
-        if (indexMeta.getBoolean(IndexConstants.UNIQUE_PROPERTY_NAME)) {
-            return UNIQUE;
-        }
-        return MIRROR;
+        return store.query(filter, propertyName, indexMeta, encode(value));
     }
 
     public double getCost(Filter filter, String propertyName, PropertyValue value) {
@@ -122,7 +107,7 @@ public class PropertyIndexLookup {
         if (indexMeta == null) {
             return Double.POSITIVE_INFINITY;
         }
-        return getStrategy(indexMeta).count(indexMeta, encode(value), MAX_COST);
+        return store.count(indexMeta, encode(value), MAX_COST);
     }
 
     /**



Mime
View raw message