Return-Path: X-Original-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AF88F10E7B for ; Wed, 2 Oct 2013 02:00:57 +0000 (UTC) Received: (qmail 50822 invoked by uid 500); 2 Oct 2013 02:00:57 -0000 Delivered-To: apmail-jackrabbit-oak-commits-archive@jackrabbit.apache.org Received: (qmail 50800 invoked by uid 500); 2 Oct 2013 02:00:57 -0000 Mailing-List: contact oak-commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-commits@jackrabbit.apache.org Received: (qmail 50792 invoked by uid 99); 2 Oct 2013 02:00:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Oct 2013 02:00:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Oct 2013 02:00:55 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 56F7B2388A5E; Wed, 2 Oct 2013 02:00:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: oak-commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131002020035.56F7B2388A5E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 primaryTypes; private final Set mixinTypes; - - private final boolean isUnique; private final Set 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); } /**