From d02a4cfa0380061fa4c23480eb74634c83835762 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Fri, 7 Aug 2009 12:54:26 +0000 Subject: [PATCH] SOLR-1338: use StringHelper.intern() git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@801981 13f79535-47bb-0310-9956-ffa450edef68 --- .../solr/handler/component/QueryElevationComponent.java | 3 ++- .../org/apache/solr/handler/component/TermsComponent.java | 3 ++- src/java/org/apache/solr/request/JSONResponseWriter.java | 3 ++- .../org/apache/solr/search/function/FileFloatSource.java | 3 ++- src/java/org/apache/solr/util/HighFrequencyDictionary.java | 5 +++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/java/org/apache/solr/handler/component/QueryElevationComponent.java b/src/java/org/apache/solr/handler/component/QueryElevationComponent.java index 9b31a182e23..c3203d4cd14 100644 --- a/src/java/org/apache/solr/handler/component/QueryElevationComponent.java +++ b/src/java/org/apache/solr/handler/component/QueryElevationComponent.java @@ -43,6 +43,7 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; import org.apache.lucene.search.*; +import org.apache.lucene.util.StringHelper; import org.apache.solr.common.SolrException; import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.DOMUtil; @@ -155,7 +156,7 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "QueryElevationComponent requires the schema to have a uniqueKeyField" ); } - idField = sf.getName().intern(); + idField = StringHelper.intern(sf.getName()); forceElevation = initArgs.getBool( FORCE_ELEVATION, forceElevation ); try { diff --git a/src/java/org/apache/solr/handler/component/TermsComponent.java b/src/java/org/apache/solr/handler/component/TermsComponent.java index 0dd83580642..3260b7307e7 100644 --- a/src/java/org/apache/solr/handler/component/TermsComponent.java +++ b/src/java/org/apache/solr/handler/component/TermsComponent.java @@ -18,6 +18,7 @@ package org.apache.solr.handler.component; import org.apache.lucene.index.Term; import org.apache.lucene.index.TermEnum; +import org.apache.lucene.util.StringHelper; import org.apache.solr.common.SolrException; import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.SolrParams; @@ -62,7 +63,7 @@ public class TermsComponent extends SearchComponent { String prefix = params.get(TermsParams.TERMS_PREFIX_STR); boolean raw = params.getBool(TermsParams.TERMS_RAW, false); for (int j = 0; j < fields.length; j++) { - String field = fields[j].intern(); + String field = StringHelper.intern(fields[j]); FieldType ft = raw ? null : rb.req.getSchema().getFieldTypeNoEx(field); if (ft==null) ft = new StrField(); diff --git a/src/java/org/apache/solr/request/JSONResponseWriter.java b/src/java/org/apache/solr/request/JSONResponseWriter.java index b0bd5671774..c2a2569d221 100644 --- a/src/java/org/apache/solr/request/JSONResponseWriter.java +++ b/src/java/org/apache/solr/request/JSONResponseWriter.java @@ -19,6 +19,7 @@ package org.apache.solr.request; import org.apache.lucene.document.Document; import org.apache.lucene.document.Fieldable; +import org.apache.lucene.util.StringHelper; import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrDocumentList; import org.apache.solr.common.params.CommonParams; @@ -78,7 +79,7 @@ class JSONWriter extends TextResponseWriter { public JSONWriter(Writer writer, SolrQueryRequest req, SolrQueryResponse rsp) { super(writer, req, rsp); - namedListStyle = req.getParams().get(JSON_NL_STYLE, JSON_NL_FLAT).intern(); + namedListStyle = StringHelper.intern(req.getParams().get(JSON_NL_STYLE, JSON_NL_FLAT)); wrapperFunction = req.getParams().get(JSON_WRAPPER_FUNCTION); } diff --git a/src/java/org/apache/solr/search/function/FileFloatSource.java b/src/java/org/apache/solr/search/function/FileFloatSource.java index b28ba614a63..8bc10da6b44 100755 --- a/src/java/org/apache/solr/search/function/FileFloatSource.java +++ b/src/java/org/apache/solr/search/function/FileFloatSource.java @@ -20,6 +20,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.TermDocs; import org.apache.lucene.index.TermEnum; import org.apache.lucene.index.Term; +import org.apache.lucene.util.StringHelper; import org.apache.solr.core.SolrCore; import org.apache.solr.schema.SchemaField; import org.apache.solr.schema.FieldType; @@ -206,7 +207,7 @@ public class FileFloatSource extends ValueSource { BufferedReader r = new BufferedReader(new InputStreamReader(is)); - String idName = ffs.keyField.getName().intern(); + String idName = StringHelper.intern(ffs.keyField.getName()); FieldType idType = ffs.keyField.getType(); boolean sorted=true; // assume sorted until we discover it's not diff --git a/src/java/org/apache/solr/util/HighFrequencyDictionary.java b/src/java/org/apache/solr/util/HighFrequencyDictionary.java index b5130966989..f66f4f9eab7 100644 --- a/src/java/org/apache/solr/util/HighFrequencyDictionary.java +++ b/src/java/org/apache/solr/util/HighFrequencyDictionary.java @@ -24,6 +24,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; import org.apache.lucene.index.TermEnum; import org.apache.lucene.search.spell.Dictionary; +import org.apache.lucene.util.StringHelper; /** * HighFrequencyDictionary: terms taken from the given field @@ -45,7 +46,7 @@ public class HighFrequencyDictionary implements Dictionary { public HighFrequencyDictionary(IndexReader reader, String field, float thresh) { this.reader = reader; - this.field = field.intern(); + this.field = StringHelper.intern(field); this.thresh = thresh; } @@ -108,7 +109,7 @@ public class HighFrequencyDictionary implements Dictionary { String currentField = actualTerm.field(); // if the next word doesn't have the same field return false - if (currentField != field) { + if (currentField != field) { // intern'd comparison actualTerm = null; return false; }