Author: jukka
Date: Tue Dec 10 18:21:50 2013
New Revision: 1549919

URL: http://svn.apache.org/r1549919
Log:
OAK-1273: Reduce overhead when handling many parallel property indices

Avoid creating a new HashSet when there is just one property name to be indexed

Modified:
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexEditor.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=1549919&r1=1549918&r2=1549919&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
 Tue Dec 10 18:21:50 2013
@@ -19,6 +19,8 @@ package org.apache.jackrabbit.oak.plugin
 import static com.google.common.collect.Sets.newHashSet;
 import static java.util.Collections.singleton;
 import static org.apache.jackrabbit.oak.api.CommitFailedException.CONSTRAINT;
+import static org.apache.jackrabbit.oak.api.Type.NAME;
+import static org.apache.jackrabbit.oak.api.Type.NAMES;
 import static org.apache.jackrabbit.oak.commons.PathUtils.concat;
 import static 
org.apache.jackrabbit.oak.plugins.index.IndexConstants.DECLARING_NODE_TYPES;
 import static 
org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_CONTENT_NODE_NAME;
@@ -105,7 +107,12 @@ class PropertyIndexEditor implements Ind
         this.definition = definition;
 
         // get property names
-        this.propertyNames = newHashSet(definition.getNames(PROPERTY_NAMES));
+        PropertyState names = definition.getProperty(PROPERTY_NAMES);
+        if (names.count() == 1) { // OAK-1273: optimize for the common case
+            this.propertyNames = singleton(names.getValue(NAME, 0));
+        } else {
+            this.propertyNames = newHashSet(names.getValue(NAMES));
+        }
 
         // get declaring types, and all their subtypes
         // TODO: should we reindex when type definitions change?


Reply via email to