jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1592955 - in /jackrabbit/oak/trunk/oak-solr-core/src: main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/ main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/ main/java/org/apache/jackrabbit/oak/plugins/index/solr...
Date Wed, 07 May 2014 09:59:26 GMT
Author: tommaso
Date: Wed May  7 09:59:25 2014
New Revision: 1592955

URL: http://svn.apache.org/r1592955
Log:
OAK-1800 - configurable number of rows for SolrQueryIndex

Modified:
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfiguration.java
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfiguration.java
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrNodeStateConfiguration.java
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationDefaults.java
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/package-info.java
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/OakSolrConfigurationProviderService.java
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java
    jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/TestUtils.java

Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfiguration.java?rev=1592955&r1=1592954&r2=1592955&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfiguration.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfiguration.java
Wed May  7 09:59:25 2014
@@ -82,4 +82,9 @@ public class DefaultSolrConfiguration im
         return SolrServerConfigurationDefaults.CATCHALL_FIELD;
     }
 
+    @Override
+    public int getRows() {
+        return SolrServerConfigurationDefaults.ROWS;
+    }
+
 }

Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfiguration.java?rev=1592955&r1=1592954&r2=1592955&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfiguration.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfiguration.java
Wed May  7 09:59:25 2014
@@ -68,4 +68,11 @@ public interface OakSolrConfiguration {
      * @return a <code>String</code> representing the Solr field to be used as
"catch all" field
      */
     public String getCatchAllField();
+
+    /**
+     * Provide the number of documents (rows) to be fetched for each Solr query
+     *
+     * @return an <code>int</code> for the setting of Solr rows parameter
+     */
+    public int getRows();
 }

Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrNodeStateConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrNodeStateConfiguration.java?rev=1592955&r1=1592954&r2=1592955&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrNodeStateConfiguration.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrNodeStateConfiguration.java
Wed May  7 09:59:25 2014
@@ -99,8 +99,25 @@ public abstract class OakSolrNodeStateCo
         return CommitPolicy.valueOf(getStringValueFor(Properties.COMMIT_POLICY, CommitPolicy.SOFT.toString()));
     }
 
+    @Override
+    public int getRows() {
+        return getIntValueFor(Properties.ROWS, SolrServerConfigurationDefaults.ROWS);
+    }
+
+    private int getIntValueFor(String propertyName, int defaultValue) {
+        long value = defaultValue;
+        NodeState configurationNodeState = getConfigurationNodeState();
+        if (configurationNodeState.exists()) {
+            PropertyState property = configurationNodeState.getProperty(propertyName);
+            if (property != null) {
+                value = property.getValue(Type.LONG);
+            }
+        }
+        return (int) value;
+    }
+
     protected String getStringValueFor(String propertyName, String defaultValue) {
-        String value = null;
+        String value = defaultValue;
         NodeState configurationNodeState = getConfigurationNodeState();
         if (configurationNodeState.exists()) {
             PropertyState property = configurationNodeState.getProperty(propertyName);
@@ -108,9 +125,6 @@ public abstract class OakSolrNodeStateCo
                 value = property.getValue(Type.STRING);
             }
         }
-        if (value == null || value.length() == 0) {
-            value = defaultValue;
-        }
         return value;
     }
 
@@ -143,6 +157,6 @@ public abstract class OakSolrNodeStateCo
         public static final String DESCENDANTS_FIELD = "descendantsField";
         public static final String CATCHALL_FIELD = "catchAllField";
         public static final String COMMIT_POLICY = "commitPolicy";
-
+        public static final String ROWS = "rows";
     }
 }

Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationDefaults.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationDefaults.java?rev=1592955&r1=1592954&r2=1592955&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationDefaults.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationDefaults.java
Wed May  7 09:59:25 2014
@@ -31,8 +31,10 @@ public class SolrServerConfigurationDefa
 
     public static final String PATH_FIELD_NAME = "path_exact";
     public static final String CHILD_FIELD_NAME = "path_child";
-    public static final String DESC_FIELD_NAME = "path_desc";
+    public static final String DESC_FIELD_NAME = "path_des";
     public static final String ANC_FIELD_NAME = "path_anc";
 
     public static final String CATCHALL_FIELD = "catch_all";
+
+    public static final int ROWS = 100000;
 }

Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/package-info.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/package-info.java?rev=1592955&r1=1592954&r2=1592955&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/package-info.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/package-info.java
Wed May  7 09:59:25 2014
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-@Version("1.0")
+@Version("1.1")
 @Export(optional = "provide:=true")
 package org.apache.jackrabbit.oak.plugins.index.solr.configuration;
 

Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/OakSolrConfigurationProviderService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/OakSolrConfigurationProviderService.java?rev=1592955&r1=1592954&r2=1592955&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/OakSolrConfigurationProviderService.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/OakSolrConfigurationProviderService.java
Wed May  7 09:59:25 2014
@@ -25,6 +25,7 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfiguration;
 import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration;
 import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider;
+import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationDefaults;
 import org.apache.jackrabbit.oak.spi.query.Filter;
 import org.osgi.service.component.ComponentContext;
 
@@ -35,11 +36,12 @@ import org.osgi.service.component.Compon
 @Service(OakSolrConfigurationProvider.class)
 public class OakSolrConfigurationProviderService implements OakSolrConfigurationProvider
{
 
-    private static final String DEFAULT_DESC_FIELD = "path_des";
-    private static final String DEFAULT_CHILD_FIELD = "path_child";
-    private static final String DEFAULT_PARENT_FIELD = "path_anc";
-    private static final String DEFAULT_PATH_FIELD = "path_exact";
-    private static final String DEFAULT_CATCHALL_FIELD = "catch_all";
+    private static final String DEFAULT_DESC_FIELD = SolrServerConfigurationDefaults.DESC_FIELD_NAME;
+    private static final String DEFAULT_CHILD_FIELD = SolrServerConfigurationDefaults.CHILD_FIELD_NAME;
+    private static final String DEFAULT_PARENT_FIELD = SolrServerConfigurationDefaults.ANC_FIELD_NAME;
+    private static final String DEFAULT_PATH_FIELD = SolrServerConfigurationDefaults.PATH_FIELD_NAME;
+    private static final String DEFAULT_CATCHALL_FIELD = SolrServerConfigurationDefaults.CATCHALL_FIELD;
+    private static final int DEFAULT_ROWS = SolrServerConfigurationDefaults.ROWS;
 
     @Property(value = DEFAULT_DESC_FIELD, label = "field for descendants search")
     private static final String PATH_DESCENDANTS_FIELD = "path.desc.field";
@@ -70,22 +72,29 @@ public class OakSolrConfigurationProvide
     )
     private static final String COMMIT_POLICY = "commit.policy";
 
+
+    @Property(intValue = DEFAULT_ROWS, label = "rows")
+    private static final String ROWS = "rows";
+
+
     private String pathChildrenFieldName;
     private String pathParentFieldName;
     private String pathDescendantsFieldName;
     private String pathExactFieldName;
     private String catchAllField;
     private CommitPolicy commitPolicy;
+    private int rows;
 
     private OakSolrConfiguration oakSolrConfiguration;
 
-  @Activate
+    @Activate
     protected void activate(ComponentContext componentContext) throws Exception {
         pathChildrenFieldName = String.valueOf(componentContext.getProperties().get(PATH_CHILDREN_FIELD));
         pathParentFieldName = String.valueOf(componentContext.getProperties().get(PATH_PARENT_FIELD));
         pathExactFieldName = String.valueOf(componentContext.getProperties().get(PATH_EXACT_FIELD));
         pathDescendantsFieldName = String.valueOf(componentContext.getProperties().get(PATH_DESCENDANTS_FIELD));
         catchAllField = String.valueOf(componentContext.getProperties().get(CATCH_ALL_FIELD));
+        rows = Integer.parseInt(String.valueOf(componentContext.getProperties().get(ROWS)));
         commitPolicy = CommitPolicy.valueOf(String.valueOf(componentContext.getProperties().get(COMMIT_POLICY)));
     }
 
@@ -138,6 +147,11 @@ public class OakSolrConfigurationProvide
                 public String getCatchAllField() {
                     return catchAllField;
                 }
+
+                @Override
+                public int getRows() {
+                    return rows;
+                }
             };
         }
         return oakSolrConfiguration;

Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java?rev=1592955&r1=1592954&r2=1592955&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java
Wed May  7 09:59:25 2014
@@ -337,7 +337,7 @@ public class SolrQueryIndex implements F
             solrQuery.setParam("df", catchAllField);
         }
 
-        solrQuery.setParam("rows", "100000");
+        solrQuery.setParam("rows", String.valueOf(configuration.getRows()));
     }
 
     private static String createRangeQuery(String first, String last, boolean firstIncluding,
boolean lastIncluding) {

Modified: jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/TestUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/TestUtils.java?rev=1592955&r1=1592954&r2=1592955&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/TestUtils.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/TestUtils.java
Wed May  7 09:59:25 2014
@@ -18,12 +18,11 @@ package org.apache.jackrabbit.oak.plugin
 
 import java.io.File;
 
-import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.plugins.index.solr.configuration.CommitPolicy;
+import org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfiguration;
 import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration;
 import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider;
 import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
-import org.apache.jackrabbit.oak.spi.query.Filter;
 import org.apache.solr.client.solrj.SolrServer;
 import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
 import org.apache.solr.core.CoreContainer;
@@ -58,61 +57,11 @@ public class TestUtils
     }
 
     public static OakSolrConfiguration getTestConfiguration() {
-        return new OakSolrConfiguration() {
-            @Override
-            public String getFieldNameFor(Type<?> propertyType) {
-                return null;
-            }
-
-            @Override
-            public String getPathField() {
-                return "path_exact";
-            }
-
-            @Override
-            public String getFieldForPathRestriction(Filter.PathRestriction pathRestriction)
{
-                String fieldName = null;
-                switch (pathRestriction) {
-                    case ALL_CHILDREN: {
-                        fieldName = "path_des";
-                        break;
-                    }
-                    case DIRECT_CHILDREN: {
-                        fieldName = "path_child";
-                        break;
-                    }
-                    case EXACT: {
-                        fieldName = "path_exact";
-                        break;
-                    }
-                    case PARENT: {
-                        fieldName = "path_anc";
-                        break;
-                    }
-                    case NO_RESTRICTION:
-                        break;
-                    default:
-                        break;
-
-                }
-                return fieldName;
-            }
-
-            @Override
-            public String getFieldForPropertyRestriction(Filter.PropertyRestriction propertyRestriction)
{
-                return null;
-            }
-
+        return new DefaultSolrConfiguration() {
             @Override
             public CommitPolicy getCommitPolicy() {
                 return CommitPolicy.HARD;
             }
-
-            @Override
-            public String getCatchAllField() {
-                return "catch_all";
-            }
-
         };
     }
 



Mime
View raw message