jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r635855 - in /jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene: CachingIndexReader.java ConsistencyCheck.java FieldSelectors.java SearchIndex.java
Date Tue, 11 Mar 2008 08:54:58 GMT
Author: mreutegg
Date: Tue Mar 11 01:54:56 2008
New Revision: 635855

URL: http://svn.apache.org/viewvc?rev=635855&view=rev
Log:
JCR-1375: Limit fields read from index

Added:
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FieldSelectors.java
  (with props)
Modified:
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java?rev=635855&r1=635854&r2=635855&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java
Tue Mar 11 01:54:56 2008
@@ -104,7 +104,7 @@
         }
 
         if (parent == null) {
-            Document doc = document(n);
+            Document doc = document(n, FieldSelectors.UUID_AND_PARENT);
             String parentUUID = doc.get(FieldNames.PARENT);
             if (parentUUID == null || parentUUID.length() == 0) {
                 parent = DocId.NULL;

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java?rev=635855&r1=635854&r2=635855&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java
Tue Mar 11 01:54:56 2008
@@ -162,7 +162,7 @@
                 if (reader.isDeleted(i)) {
                     continue;
                 }
-                Document d = reader.document(i);
+                Document d = reader.document(i, FieldSelectors.UUID);
                 UUID uuid = UUID.fromString(d.get(FieldNames.UUID));
                 if (stateMgr.hasItemState(new NodeId(uuid))) {
                     if (!documentUUIDs.add(uuid)) {
@@ -192,7 +192,7 @@
                 if (reader.isDeleted(i)) {
                     continue;
                 }
-                Document d = reader.document(i);
+                Document d = reader.document(i, FieldSelectors.UUID_AND_PARENT);
                 UUID uuid = UUID.fromString(d.get(FieldNames.UUID));
                 String parentUUIDString = d.get(FieldNames.PARENT);
                 UUID parentUUID = null;

Added: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FieldSelectors.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FieldSelectors.java?rev=635855&view=auto
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FieldSelectors.java
(added)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FieldSelectors.java
Tue Mar 11 01:54:56 2008
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.core.query.lucene;
+
+import org.apache.lucene.document.FieldSelector;
+import org.apache.lucene.document.FieldSelectorResult;
+
+/**
+ * <code>FieldSelectors</code> contains commonly used field selectors.
+ */
+public class FieldSelectors {
+
+    /**
+     * Do not instanciate.
+     */
+    private FieldSelectors() {
+    }
+
+    public static final FieldSelector UUID = new FieldSelector() {
+        /**
+         * Only accepts {@link FieldNames#UUID}.
+         *
+         * @param fieldName the field name to check.
+         * @return result.
+         */
+        public FieldSelectorResult accept(String fieldName) {
+            if (FieldNames.UUID == fieldName) {
+                return FieldSelectorResult.LOAD_AND_BREAK;
+            } else {
+                return FieldSelectorResult.NO_LOAD;
+            }
+        }
+    };
+
+    public static final FieldSelector UUID_AND_PARENT = new FieldSelector() {
+        /**
+         * Accepts {@link FieldNames#UUID} and {@link FieldNames#PARENT}.
+         *
+         * @param fieldName the field name to check.
+         * @return result.
+         */
+        public FieldSelectorResult accept(String fieldName) {
+            if (FieldNames.UUID == fieldName) {
+                return FieldSelectorResult.LOAD;
+            } else if (FieldNames.PARENT == fieldName) {
+                return FieldSelectorResult.LOAD;
+            } else {
+                return FieldSelectorResult.NO_LOAD;
+            }
+        }
+    };
+}

Propchange: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FieldSelectors.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java?rev=635855&r1=635854&r2=635855&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
Tue Mar 11 01:54:56 2008
@@ -1139,7 +1139,7 @@
                                     id.getUUID().toString());
                             tDocs.seek(aggregateUUIDs);
                             while (tDocs.next()) {
-                                Document doc = reader.document(tDocs.doc());
+                                Document doc = reader.document(tDocs.doc(), FieldSelectors.UUID);
                                 String uuid = doc.get(FieldNames.UUID);
                                 NodeId nId = new NodeId(UUID.fromString(uuid));
                                 map.put(nId, ism.getItemState(nId));



Mime
View raw message