jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1005470 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/
Date Thu, 07 Oct 2010 14:47:18 GMT
Author: mreutegg
Date: Thu Oct  7 14:47:17 2010
New Revision: 1005470

URL: http://svn.apache.org/viewvc?rev=1005470&view=rev
Log:
JCR-2769: Avoid String.intern() for UUID terms

Added:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/TermFactory.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingMultiIndexReader.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ScoreNode.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SimilarityQuery.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java?rev=1005470&r1=1005469&r2=1005470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java
Thu Oct  7 14:47:17 2010
@@ -82,7 +82,7 @@ public abstract class AbstractExcerpt im
         IndexReader reader = index.getIndexReader();
         try {
             checkRewritten(reader);
-            Term idTerm = new Term(FieldNames.UUID, id.toString());
+            Term idTerm = TermFactory.createUUIDTerm(id.toString());
             TermDocs tDocs = reader.termDocs(idTerm);
             int docNumber;
             Document doc;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java?rev=1005470&r1=1005469&r2=1005470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java
Thu Oct  7 14:47:17 2010
@@ -192,7 +192,7 @@ class CachingIndexReader extends FilterI
                     parent = DocId.create(parentUUIDs);
                 } else {
                     if (!existing) {
-                        Term id = new Term(FieldNames.UUID, parentUUIDs[0]);
+                        Term id = TermFactory.createUUIDTerm(parentUUIDs[0]);
                         TermDocs docs = termDocs(id);
                         try {
                             while (docs.next()) {
@@ -431,7 +431,7 @@ class CachingIndexReader extends FilterI
 
             // initialize in multiple passes with
             // a fixed number of nodes at a time
-            final Term[] startUUID = new Term[]{new Term(FieldNames.UUID, "")};
+            final Term[] startUUID = new Term[]{TermFactory.createUUIDTerm("")};
 
             for (;;) {
                 final Map<Object, NodeInfo> docs = new HashMap<Object, NodeInfo>();
@@ -439,7 +439,7 @@ class CachingIndexReader extends FilterI
 
                 if (startUUID[0].text().length() != 0) {
                     // force reading the next uuid after startUUID
-                    startUUID[0] = new Term(FieldNames.UUID, startUUID[0].text() + "_");
+                    startUUID[0] = TermFactory.createUUIDTerm(startUUID[0].text() + "_");
                 }
                 // read UUIDs
                 collectTermDocs(reader, startUUID[0], new TermDocsCollector() {
@@ -489,7 +489,7 @@ class CachingIndexReader extends FilterI
                 });
 
                 // scan UUIDs again to get document numbers for parents
-                collectTermDocs(reader, new Term(FieldNames.UUID, ""), new TermDocsCollector()
{
+                collectTermDocs(reader, TermFactory.createUUIDTerm(""), new TermDocsCollector()
{
                     public boolean collect(Term term, TermDocs tDocs) throws IOException
{
                         NodeId id = new NodeId(term.text());
                         while (tDocs.next()) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingMultiIndexReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingMultiIndexReader.java?rev=1005470&r1=1005469&r2=1005470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingMultiIndexReader.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingMultiIndexReader.java
Thu Oct  7 14:47:17 2010
@@ -182,7 +182,7 @@ public final class CachingMultiIndexRead
      * {@inheritDoc}
      */
     public ForeignSegmentDocId createDocId(NodeId id) throws IOException {
-        Term term = new Term(FieldNames.UUID, id.toString());
+        Term term = TermFactory.createUUIDTerm(id.toString());
         int doc;
         long tick;
         for (ReadOnlyIndexReader subReader : subReaders) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java?rev=1005470&r1=1005469&r2=1005470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
Thu Oct  7 14:47:17 2010
@@ -639,7 +639,7 @@ class ChildAxisQuery extends Query imple
                     }
                     for (ChildNodeEntry entry : entries) {
                         NodeId childId = entry.getId();
-                        Term uuidTerm = new Term(FieldNames.UUID, childId.toString());
+                        Term uuidTerm = TermFactory.createUUIDTerm(childId.toString());
                         TermDocs docs = reader.termDocs(uuidTerm);
                         try {
                             if (docs.next()) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java?rev=1005470&r1=1005469&r2=1005470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
Thu Oct  7 14:47:17 2010
@@ -346,7 +346,7 @@ class DerefQuery extends Query {
                 // bitset.
                 hits.clear();
                 for (String uuid : uuids) {
-                    TermDocs node = reader.termDocs(new Term(FieldNames.UUID, uuid));
+                    TermDocs node = reader.termDocs(TermFactory.createUUIDTerm(uuid));
                     try {
                         while (node.next()) {
                             hits.set(node.doc());

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java?rev=1005470&r1=1005469&r2=1005470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
Thu Oct  7 14:47:17 2010
@@ -504,7 +504,7 @@ public class MultiIndex {
         }
         int num;
         try {
-            Term idTerm = new Term(FieldNames.UUID, id.toString());
+            Term idTerm = TermFactory.createUUIDTerm(id.toString());
             executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
             num = volatileIndex.removeDocument(idTerm);
             if (num > 0) {
@@ -1979,7 +1979,7 @@ public class MultiIndex {
                 Util.disposeDocument(doc);
                 index.notifyIfIndexingQueueIsEmpty();
             }
-            Term idTerm = new Term(FieldNames.UUID, uuidString);
+            Term idTerm = TermFactory.createUUIDTerm(uuidString);
             // if the document cannot be deleted from the volatile index
             // delete it from one of the persistent indexes.
             int num = index.volatileIndex.removeDocument(idTerm);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java?rev=1005470&r1=1005469&r2=1005470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java
Thu Oct  7 14:47:17 2010
@@ -339,7 +339,7 @@ public class PredicateDerefQuery extends
                         if (values[v].startsWith(prefix)) {
                             String uuid = values[v].substring(prefix.length());
                             
-                            TermDocs node = reader.termDocs(new Term(FieldNames.UUID, uuid));
+                            TermDocs node = reader.termDocs(TermFactory.createUUIDTerm(uuid));
                             try {
                                 while (node.next()) {
                                     if (subQueryHits.get(node.doc())) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java?rev=1005470&r1=1005469&r2=1005470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java
Thu Oct  7 14:47:17 2010
@@ -194,7 +194,7 @@ public class QueryHitsQuery extends Quer
             try {
                 while ((node = hits.nextScoreNode()) != null) {
                     String uuid = node.getNodeId().toString();
-                    Term id = new Term(FieldNames.UUID, uuid);
+                    Term id = TermFactory.createUUIDTerm(uuid);
                     TermDocs tDocs = reader.termDocs(id);
                     try {
                         if (tDocs.next()) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ScoreNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ScoreNode.java?rev=1005470&r1=1005469&r2=1005470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ScoreNode.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ScoreNode.java
Thu Oct  7 14:47:17 2010
@@ -102,7 +102,7 @@ public final class ScoreNode {
      */
     public int getDoc(IndexReader reader) throws IOException {
         if (doc == -1) {
-            TermDocs docs = reader.termDocs(new Term(FieldNames.UUID, id.toString()));
+            TermDocs docs = reader.termDocs(TermFactory.createUUIDTerm(id.toString()));
             try {
                 if (docs.next()) {
                     return docs.doc();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SimilarityQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SimilarityQuery.java?rev=1005470&r1=1005469&r2=1005470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SimilarityQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SimilarityQuery.java
Thu Oct  7 14:47:17 2010
@@ -55,7 +55,7 @@ public class SimilarityQuery extends Que
         more.setFieldNames(new String[]{FieldNames.FULLTEXT});
         more.setMinWordLen(4);
         Query similarityQuery = null;
-        TermDocs td = reader.termDocs(new Term(FieldNames.UUID, uuid));
+        TermDocs td = reader.termDocs(TermFactory.createUUIDTerm(uuid));
         try {
             if (td.next()) {
                 similarityQuery = more.like(td.doc());

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/TermFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/TermFactory.java?rev=1005470&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/TermFactory.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/TermFactory.java
Thu Oct  7 14:47:17 2010
@@ -0,0 +1,42 @@
+/*
+ * 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.index.Term;
+
+/**
+ * <code>TermFactory</code> is a factory for <code>Term</code> instances
with
+ * frequently used field names.
+ */
+public final class TermFactory {
+
+    /**
+     * Template for UUID terms.
+     */
+    private static final Term UUID_TERM_TEMPLATE = new Term(FieldNames.UUID);
+
+    /**
+     * Creates a Term with the given <code>id</code> value and with a field
+     * name {@link FieldNames#UUID}.
+     *
+     * @param id the id.
+     * @return the UUIDTerm.
+     */
+    public static Term createUUIDTerm(String id) {
+        return UUID_TERM_TEMPLATE.createTerm(id);
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/TermFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message