You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2014/08/13 11:36:59 UTC

svn commit: r1617695 [9/9] - in /lucene/dev/branches/branch_4x: ./ lucene/ lucene/analysis/ lucene/analysis/common/src/java/org/apache/lucene/analysis/charfilter/ lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/ lucene/analysis/comm...

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java?rev=1617695&r1=1617694&r2=1617695&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java Wed Aug 13 09:36:54 2014
@@ -29,6 +29,7 @@ import org.apache.lucene.search.Query;
 import org.apache.lucene.search.QueryWrapperFilter;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.BytesRefBuilder;
 import org.apache.lucene.util.automaton.Automata;
 import org.apache.lucene.util.automaton.Automaton;
 import org.apache.solr.common.params.SolrParams;
@@ -121,16 +122,16 @@ public class TermsQParserPlugin extends 
         assert splitVals.length > 0;
 
         BytesRef[] bytesRefs = new BytesRef[splitVals.length];
+        BytesRefBuilder term = new BytesRefBuilder();
         for (int i = 0; i < splitVals.length; i++) {
           String stringVal = splitVals[i];
           //logic same as TermQParserPlugin
-          BytesRef term = new BytesRef();
           if (ft != null) {
             ft.readableToIndexed(stringVal, term);
           } else {
             term.copyChars(stringVal);
           }
-          bytesRefs[i] = term;
+          bytesRefs[i] = term.toBytesRef();
         }
 
         return new SolrConstantScoreQuery(method.makeFilter(fname, bytesRefs));

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java?rev=1617695&r1=1617694&r2=1617695&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java Wed Aug 13 09:36:54 2014
@@ -17,6 +17,7 @@
 package org.apache.solr.search;
 
 import com.spatial4j.core.distance.DistanceUtils;
+
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.queries.function.BoostedQuery;
@@ -35,12 +36,12 @@ import org.apache.lucene.search.spell.Le
 import org.apache.lucene.search.spell.NGramDistance;
 import org.apache.lucene.search.spell.StringDistance;
 import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.BytesRefBuilder;
 import org.apache.lucene.util.UnicodeUtil;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.request.SolrRequestInfo;
 import org.apache.solr.schema.*;
-
 import org.apache.solr.search.function.CollapseScoreFunction;
 import org.apache.solr.search.function.distance.*;
 import org.apache.solr.util.plugin.NamedListInitializedPlugin;
@@ -591,7 +592,7 @@ public abstract class ValueSourceParser 
       @Override
       public ValueSource parse(FunctionQParser fp) throws SyntaxError {
         TInfo tinfo = parseTerm(fp);
-        return new DocFreqValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes);
+        return new DocFreqValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes.get());
       }
     });
 
@@ -599,7 +600,7 @@ public abstract class ValueSourceParser 
       @Override
       public ValueSource parse(FunctionQParser fp) throws SyntaxError {
         TInfo tinfo = parseTerm(fp);
-        return new TotalTermFreqValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes);
+        return new TotalTermFreqValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes.get());
       }
     });
     alias("totaltermfreq","ttf");
@@ -617,7 +618,7 @@ public abstract class ValueSourceParser 
       @Override
       public ValueSource parse(FunctionQParser fp) throws SyntaxError {
         TInfo tinfo = parseTerm(fp);
-        return new IDFValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes);
+        return new IDFValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes.get());
       }
     });
 
@@ -625,7 +626,7 @@ public abstract class ValueSourceParser 
       @Override
       public ValueSource parse(FunctionQParser fp) throws SyntaxError {
         TInfo tinfo = parseTerm(fp);
-        return new TermFreqValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes);
+        return new TermFreqValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes.get());
       }
     });
 
@@ -633,7 +634,7 @@ public abstract class ValueSourceParser 
       @Override
       public ValueSource parse(FunctionQParser fp) throws SyntaxError {
         TInfo tinfo = parseTerm(fp);
-        return new TFValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes);
+        return new TFValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes.get());
       }
     });
 
@@ -793,7 +794,7 @@ public abstract class ValueSourceParser 
 
     tinfo.indexedField = tinfo.field = fp.parseArg();
     tinfo.val = fp.parseArg();
-    tinfo.indexedBytes = new BytesRef();
+    tinfo.indexedBytes = new BytesRefBuilder();
 
     FieldType ft = fp.getReq().getSchema().getFieldTypeNoEx(tinfo.field);
     if (ft == null) ft = new StrField();
@@ -807,7 +808,7 @@ public abstract class ValueSourceParser 
         tinfo.indexedField = term.field();
         indexedVal = term.text();
       }
-      UnicodeUtil.UTF16toUTF8(indexedVal, 0, indexedVal.length(), tinfo.indexedBytes);
+      tinfo.indexedBytes.copyChars(indexedVal);
     } else {
       ft.readableToIndexed(tinfo.val, tinfo.indexedBytes);
     }
@@ -869,7 +870,7 @@ public abstract class ValueSourceParser 
     String field;
     String val;
     String indexedField;
-    BytesRef indexedBytes;
+    BytesRefBuilder indexedBytes;
   }
 
 }

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java?rev=1617695&r1=1617694&r2=1617695&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java Wed Aug 13 09:36:54 2014
@@ -22,6 +22,7 @@ import org.apache.lucene.queries.functio
 import org.apache.lucene.queries.function.docvalues.FloatDocValues;
 import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.BytesRefBuilder;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.handler.RequestHandlerBase;
 import org.apache.solr.handler.RequestHandlerUtils;
@@ -267,7 +268,7 @@ public class FileFloatSource extends Val
 
     char delimiter='=';
 
-    BytesRef internalKey = new BytesRef();
+    BytesRefBuilder internalKey = new BytesRefBuilder();
 
     try {
       TermsEnum termsEnum = MultiFields.getTerms(reader, idName).iterator(null);
@@ -297,7 +298,7 @@ public class FileFloatSource extends Val
           continue;  // go to next line in file.. leave values as default.
         }
 
-        if (!termsEnum.seekExact(internalKey)) {
+        if (!termsEnum.seekExact(internalKey.get())) {
           if (notFoundCount<10) {  // collect first 10 not found for logging
             notFound.add(key);
           }

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java?rev=1617695&r1=1617694&r2=1617695&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java Wed Aug 13 09:36:54 2014
@@ -24,6 +24,7 @@ import java.util.List;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.BytesRefBuilder;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.SolrInputField;
@@ -94,8 +95,9 @@ public class AddUpdateCommand extends Up
            } else if (count  > 1) {
              throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Document contains multiple values for uniqueKey field: " + field);
            } else {
-             indexedId = new BytesRef();
-             sf.getType().readableToIndexed(field.getFirstValue().toString(), indexedId);
+             BytesRefBuilder b = new BytesRefBuilder();
+             sf.getType().readableToIndexed(field.getFirstValue().toString(), b);
+             indexedId = b.get();
            }
          }
        }

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DeleteUpdateCommand.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DeleteUpdateCommand.java?rev=1617695&r1=1617694&r2=1617695&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DeleteUpdateCommand.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DeleteUpdateCommand.java Wed Aug 13 09:36:54 2014
@@ -18,7 +18,9 @@
 package org.apache.solr.update;
 
 import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.BytesRefBuilder;
 import org.apache.lucene.util.CharsRef;
+import org.apache.lucene.util.CharsRefBuilder;
 import org.apache.solr.common.SolrInputField;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.schema.IndexSchema;
@@ -60,8 +62,9 @@ public class DeleteUpdateCommand extends
       IndexSchema schema = req.getSchema();
       SchemaField sf = schema.getUniqueKeyField();
       if (sf != null && id != null) {
-        indexedId = new BytesRef();
-        sf.getType().readableToIndexed(id, indexedId);
+        BytesRefBuilder b = new BytesRefBuilder();
+        sf.getType().readableToIndexed(id, b);
+        indexedId = b.get();
       }
     }
     return indexedId;
@@ -72,7 +75,7 @@ public class DeleteUpdateCommand extends
       IndexSchema schema = req.getSchema();
       SchemaField sf = schema.getUniqueKeyField();
       if (sf != null) {
-        CharsRef ref = new CharsRef();
+        CharsRefBuilder ref = new CharsRefBuilder();
         sf.getType().indexedToReadable(indexedId, ref);
         id = ref.toString();
       }

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java?rev=1617695&r1=1617694&r2=1617695&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java Wed Aug 13 09:36:54 2014
@@ -34,6 +34,7 @@ import org.apache.lucene.search.DocIdSet
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.CharsRef;
+import org.apache.lucene.util.CharsRefBuilder;
 import org.apache.lucene.util.FixedBitSet;
 import org.apache.lucene.util.IOUtils;
 import org.apache.solr.common.cloud.CompositeIdRouter;
@@ -167,7 +168,7 @@ public class SolrIndexSplitter {
     BytesRef term = null;
     DocsEnum docsEnum = null;
 
-    CharsRef idRef = new CharsRef(100);
+    CharsRefBuilder idRef = new CharsRefBuilder();
     for (;;) {
       term = termsEnum.next();
       if (term == null) break;
@@ -176,7 +177,7 @@ public class SolrIndexSplitter {
 
       // FUTURE: if conversion to strings costs too much, we could
       // specialize and use the hash function that can work over bytes.
-      idRef = field.getType().indexedToReadable(term, idRef);
+      field.getType().indexedToReadable(term, idRef);
       String idString = idRef.toString();
 
       if (splitKey != null) {

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java?rev=1617695&r1=1617694&r2=1617695&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java Wed Aug 13 09:36:54 2014
@@ -36,7 +36,9 @@ import java.util.concurrent.atomic.Atomi
 import java.util.concurrent.locks.ReentrantLock;
 
 import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.BytesRefBuilder;
 import org.apache.lucene.util.CharsRef;
+import org.apache.lucene.util.CharsRefBuilder;
 import org.apache.solr.client.solrj.request.UpdateRequest;
 import org.apache.solr.cloud.CloudDescriptor;
 import org.apache.solr.cloud.DistributedQueue;
@@ -238,7 +240,7 @@ public class DistributedUpdateProcessor 
   private NamedList addsResponse = null;
   private NamedList deleteResponse = null;
   private NamedList deleteByQueryResponse = null;
-  private CharsRef scratch;
+  private CharsRefBuilder scratch;
   
   private final SchemaField idField;
   
@@ -747,7 +749,7 @@ public class DistributedUpdateProcessor 
         addsResponse = new NamedList<String>();
         rsp.add("adds",addsResponse);
       }
-      if (scratch == null) scratch = new CharsRef();
+      if (scratch == null) scratch = new CharsRefBuilder();
       idField.getType().indexedToReadable(cmd.getIndexedId(), scratch);
       addsResponse.add(scratch.toString(), cmd.getVersion());
     }
@@ -1121,9 +1123,9 @@ public class DistributedUpdateProcessor 
       // TODO: fieldtype needs externalToObject?
       String oldValS = numericField.getFirstValue().toString();
       SchemaField sf = schema.getField(sif.getName());
-      BytesRef term = new BytesRef();
+      BytesRefBuilder term = new BytesRefBuilder();
       sf.getType().readableToIndexed(oldValS, term);
-      Object oldVal = sf.getType().toObject(sf, term);
+      Object oldVal = sf.getType().toObject(sf, term.get());
 
       String fieldValS = fieldVal.toString();
       Number result;
@@ -1233,7 +1235,7 @@ public class DistributedUpdateProcessor 
         deleteResponse = new NamedList<String>();
         rsp.add("deletes",deleteResponse);
       }
-      if (scratch == null) scratch = new CharsRef();
+      if (scratch == null) scratch = new CharsRefBuilder();
       idField.getType().indexedToReadable(cmd.getIndexedId(), scratch);
       deleteResponse.add(scratch.toString(), cmd.getVersion());  // we're returning the version of the delete.. not the version of the doc we deleted.
     }

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessorFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessorFactory.java?rev=1617695&r1=1617694&r2=1617695&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessorFactory.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessorFactory.java Wed Aug 13 09:36:54 2014
@@ -20,6 +20,7 @@ package org.apache.solr.update.processor
 import org.apache.lucene.queries.function.FunctionValues;
 import org.apache.lucene.queries.function.ValueSource;
 import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.BytesRefBuilder;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.util.NamedList;
@@ -230,9 +231,9 @@ public class DocBasedVersionConstraintsP
         // in theory, the FieldType might still be CharSequence based,
         // but in that case trust it to do an identiy conversion...
         FieldType fieldType = userVersionField.getType();
-        BytesRef term = new BytesRef();
+        BytesRefBuilder term = new BytesRefBuilder();
         fieldType.readableToIndexed((CharSequence)rawValue, term);
-        return fieldType.toObject(userVersionField, term);
+        return fieldType.toObject(userVersionField, term.get());
       }
       // else...
       return rawValue;