You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2011/05/25 00:44:37 UTC
svn commit: r1127326 [2/2] - in /lucene/dev/trunk:
lucene/contrib/highlighter/src/java/org/apache/lucene/search/vectorhighlight/
lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/
lucene/contrib/queries/src/java/org/apache/lucen...
Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableIntField.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableIntField.java?rev=1127326&r1=1127325&r2=1127326&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableIntField.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableIntField.java Tue May 24 22:44:36 2011
@@ -19,7 +19,7 @@ package org.apache.solr.schema;
import org.apache.lucene.search.SortField;
import org.apache.lucene.util.BytesRef;
-import org.apache.noggit.CharArr;
+import org.apache.lucene.util.CharsRef;
import org.apache.solr.search.MutableValueInt;
import org.apache.solr.search.MutableValue;
import org.apache.solr.search.QParser;
@@ -29,7 +29,6 @@ import org.apache.solr.search.function.D
import org.apache.solr.search.function.StringIndexDocValues;
import org.apache.lucene.document.Fieldable;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.solr.util.ByteUtils;
import org.apache.solr.util.NumberUtils;
import org.apache.solr.response.TextResponseWriter;
@@ -75,10 +74,11 @@ public class SortableIntField extends Fi
return NumberUtils.SortableStr2int(indexedForm);
}
- @Override
- public void indexedToReadable(BytesRef input, CharArr out) {
+ public CharsRef indexedToReadable(BytesRef input, CharsRef charsRef) {
// TODO: this could be more efficient, but the sortable types should be deprecated instead
- out.write( indexedToReadable(ByteUtils.UTF8toUTF16(input)) );
+ final char[] indexedToReadable = indexedToReadable(input.utf8ToChars(charsRef).toString()).toCharArray();
+ charsRef.copy(indexedToReadable, 0, indexedToReadable.length);
+ return charsRef;
}
@Override
Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableLongField.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableLongField.java?rev=1127326&r1=1127325&r2=1127326&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableLongField.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableLongField.java Tue May 24 22:44:36 2011
@@ -19,7 +19,7 @@ package org.apache.solr.schema;
import org.apache.lucene.search.SortField;
import org.apache.lucene.util.BytesRef;
-import org.apache.noggit.CharArr;
+import org.apache.lucene.util.CharsRef;
import org.apache.solr.search.MutableValueLong;
import org.apache.solr.search.MutableValue;
import org.apache.solr.search.QParser;
@@ -29,7 +29,6 @@ import org.apache.solr.search.function.D
import org.apache.solr.search.function.StringIndexDocValues;
import org.apache.lucene.document.Fieldable;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.solr.util.ByteUtils;
import org.apache.solr.util.NumberUtils;
import org.apache.solr.response.TextResponseWriter;
@@ -67,10 +66,11 @@ public class SortableLongField extends F
return NumberUtils.SortableStr2long(indexedForm);
}
- @Override
- public void indexedToReadable(BytesRef input, CharArr out) {
+ public CharsRef indexedToReadable(BytesRef input, CharsRef charsRef) {
// TODO: this could be more efficient, but the sortable types should be deprecated instead
- out.write( indexedToReadable(ByteUtils.UTF8toUTF16(input)) );
+ final char[] indexedToReadable = indexedToReadable(input.utf8ToChars(charsRef).toString()).toCharArray();
+ charsRef.copy(indexedToReadable, 0, indexedToReadable.length);
+ return charsRef;
}
@Override
Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/schema/StrField.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/schema/StrField.java?rev=1127326&r1=1127325&r2=1127326&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/schema/StrField.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/schema/StrField.java Tue May 24 22:44:36 2011
@@ -23,7 +23,6 @@ import org.apache.lucene.util.BytesRef;
import org.apache.solr.response.TextResponseWriter;
import org.apache.solr.search.function.ValueSource;
import org.apache.solr.search.QParser;
-import org.apache.solr.util.ByteUtils;
import java.util.Map;
import java.io.IOException;
@@ -54,7 +53,7 @@ public class StrField extends FieldType
@Override
public Object toObject(SchemaField sf, BytesRef term) {
- return ByteUtils.UTF8toUTF16(term);
+ return term.utf8ToString();
}
}
Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/schema/StrFieldSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/schema/StrFieldSource.java?rev=1127326&r1=1127325&r2=1127326&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/schema/StrFieldSource.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/schema/StrFieldSource.java Tue May 24 22:44:36 2011
@@ -18,12 +18,9 @@
package org.apache.solr.schema;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.util.BytesRef;
-import org.apache.noggit.CharArr;
import org.apache.solr.search.function.DocValues;
import org.apache.solr.search.function.FieldCacheSource;
import org.apache.solr.search.function.StringIndexDocValues;
-import org.apache.solr.util.ByteUtils;
import java.io.IOException;
import java.util.Map;
Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/schema/TextField.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/schema/TextField.java?rev=1127326&r1=1127325&r2=1127326&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/schema/TextField.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/schema/TextField.java Tue May 24 22:44:36 2011
@@ -34,7 +34,6 @@ import org.apache.lucene.analysis.Analyz
import org.apache.lucene.util.BytesRef;
import org.apache.solr.response.TextResponseWriter;
import org.apache.solr.search.QParser;
-import org.apache.solr.util.ByteUtils;
import java.util.Map;
import java.util.List;
@@ -81,7 +80,7 @@ public class TextField extends FieldType
@Override
public Object toObject(SchemaField sf, BytesRef term) {
- return ByteUtils.UTF8toUTF16(term);
+ return term.utf8ToString();
}
@Override
Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/schema/TrieDateField.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/schema/TrieDateField.java?rev=1127326&r1=1127325&r2=1127326&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/schema/TrieDateField.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/schema/TrieDateField.java Tue May 24 22:44:36 2011
@@ -17,7 +17,6 @@
package org.apache.solr.schema;
-import org.apache.noggit.CharArr;
import org.apache.solr.search.function.ValueSource;
import org.apache.solr.search.QParser;
import org.apache.solr.response.TextResponseWriter;
@@ -26,6 +25,7 @@ import org.apache.lucene.search.SortFiel
import org.apache.lucene.search.Query;
import org.apache.lucene.search.NumericRangeQuery;
import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.CharsRef;
import java.util.Map;
import java.util.Date;
@@ -111,10 +111,10 @@ public class TrieDateField extends DateF
public String indexedToReadable(String _indexedForm) {
return wrappedField.indexedToReadable(_indexedForm);
}
-
@Override
- public void indexedToReadable(BytesRef input, CharArr out) {
- wrappedField.indexedToReadable(input, out);
+ public CharsRef indexedToReadable(BytesRef input, CharsRef charsRef) {
+ // TODO: this could be more efficient, but the sortable types should be deprecated instead
+ return wrappedField.indexedToReadable(input, charsRef);
}
@Override
Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/schema/TrieField.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/schema/TrieField.java?rev=1127326&r1=1127325&r2=1127326&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/schema/TrieField.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/schema/TrieField.java Tue May 24 22:44:36 2011
@@ -26,8 +26,8 @@ import org.apache.lucene.search.cache.Fl
import org.apache.lucene.search.cache.IntValuesCreator;
import org.apache.lucene.search.cache.LongValuesCreator;
import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.CharsRef;
import org.apache.lucene.util.NumericUtils;
-import org.apache.noggit.CharArr;
import org.apache.solr.analysis.*;
import org.apache.solr.common.SolrException;
import org.apache.solr.response.TextResponseWriter;
@@ -296,7 +296,7 @@ public class TrieField extends FieldType
@Override
public String readableToIndexed(String val) {
// TODO: Numeric should never be handled as String, that may break in future lucene versions! Change to use BytesRef for term texts!
- BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_LONG);
+ final BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_LONG);
readableToIndexed(val, bytes);
return bytes.utf8ToString();
}
@@ -363,31 +363,29 @@ public class TrieField extends FieldType
}
@Override
- public void indexedToReadable(BytesRef input, CharArr out) {
- BytesRef indexedForm = input;
- String s;
-
+ public CharsRef indexedToReadable(BytesRef indexedForm, CharsRef charsRef) {
+ final char[] value;
switch (type) {
case INTEGER:
- s = Integer.toString( NumericUtils.prefixCodedToInt(indexedForm) );
+ value = Integer.toString( NumericUtils.prefixCodedToInt(indexedForm) ).toCharArray();
break;
case FLOAT:
- s = Float.toString( NumericUtils.sortableIntToFloat(NumericUtils.prefixCodedToInt(indexedForm)) );
+ value = Float.toString( NumericUtils.sortableIntToFloat(NumericUtils.prefixCodedToInt(indexedForm)) ).toCharArray();
break;
case LONG:
- s = Long.toString( NumericUtils.prefixCodedToLong(indexedForm) );
+ value = Long.toString( NumericUtils.prefixCodedToLong(indexedForm) ).toCharArray();
break;
case DOUBLE:
- s = Double.toString( NumericUtils.sortableLongToDouble(NumericUtils.prefixCodedToLong(indexedForm)) );
+ value = Double.toString( NumericUtils.sortableLongToDouble(NumericUtils.prefixCodedToLong(indexedForm)) ).toCharArray();
break;
case DATE:
- s = dateField.toExternal( new Date(NumericUtils.prefixCodedToLong(indexedForm)) );
+ value = dateField.toExternal( new Date(NumericUtils.prefixCodedToLong(indexedForm)) ).toCharArray();
break;
default:
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
}
-
- out.write(s);
+ charsRef.copy(value, 0, value.length);
+ return charsRef;
}
@Override
Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/search/MissingStringLastComparatorSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/search/MissingStringLastComparatorSource.java?rev=1127326&r1=1127325&r2=1127326&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/search/MissingStringLastComparatorSource.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/search/MissingStringLastComparatorSource.java Tue May 24 22:44:36 2011
@@ -21,11 +21,11 @@ import org.apache.lucene.search.*;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.UnicodeUtil;
import org.apache.lucene.util.packed.Direct16;
import org.apache.lucene.util.packed.Direct32;
import org.apache.lucene.util.packed.Direct8;
import org.apache.lucene.util.packed.PackedInts;
-import org.apache.solr.util.ByteUtils;
import java.io.IOException;
@@ -34,7 +34,7 @@ public class MissingStringLastComparator
private final BytesRef missingValueProxy;
public MissingStringLastComparatorSource() {
- this(ByteUtils.bigTerm);
+ this(UnicodeUtil.BIG_TERM);
}
/** Creates a {@link FieldComparatorSource} that sorts null last in a normal ascending sort.
Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/search/MutableValueStr.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/search/MutableValueStr.java?rev=1127326&r1=1127325&r2=1127326&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/search/MutableValueStr.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/search/MutableValueStr.java Tue May 24 22:44:36 2011
@@ -17,14 +17,13 @@
package org.apache.solr.search;
import org.apache.lucene.util.BytesRef;
-import org.apache.solr.util.ByteUtils;
public class MutableValueStr extends MutableValue {
public BytesRef value = new BytesRef();
@Override
public Object toObject() {
- return exists ? ByteUtils.UTF8toUTF16(value) : null;
+ return exists ? value.utf8ToString() : null;
}
@Override
Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/IDFValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/IDFValueSource.java?rev=1127326&r1=1127325&r2=1127326&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/IDFValueSource.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/IDFValueSource.java Tue May 24 22:44:36 2011
@@ -22,7 +22,6 @@ import org.apache.lucene.index.IndexRead
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Similarity;
import org.apache.lucene.util.BytesRef;
-import org.apache.solr.util.ByteUtils;
import java.io.IOException;
import java.util.Map;
@@ -43,8 +42,7 @@ public class IDFValueSource extends DocF
IndexSearcher searcher = (IndexSearcher)context.get("searcher");
Similarity sim = searcher.getSimilarityProvider().get(field);
// todo: we need docFreq that takes a BytesRef
- String strVal = ByteUtils.UTF8toUTF16(indexedBytes);
- int docfreq = searcher.docFreq(new Term(indexedField, strVal));
+ int docfreq = searcher.docFreq(new Term(indexedField, indexedBytes.utf8ToString()));
float idf = sim.idf(docfreq, searcher.maxDoc());
return new ConstDoubleDocValues(idf, this);
}
Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/StringIndexDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/StringIndexDocValues.java?rev=1127326&r1=1127325&r2=1127326&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/StringIndexDocValues.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/StringIndexDocValues.java Tue May 24 22:44:36 2011
@@ -21,10 +21,9 @@ import org.apache.lucene.search.FieldCac
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.util.BytesRef;
-import org.apache.noggit.CharArr;
+import org.apache.lucene.util.CharsRef;
import org.apache.solr.search.MutableValue;
import org.apache.solr.search.MutableValueStr;
-import org.apache.solr.util.ByteUtils;
import java.io.IOException;
@@ -36,7 +35,7 @@ public abstract class StringIndexDocValu
protected final ValueSource vs;
protected final MutableValueStr val = new MutableValueStr();
protected final BytesRef spare = new BytesRef();
- protected final CharArr spareChars = new CharArr();
+ protected final CharsRef spareChars = new CharsRef();
public StringIndexDocValues(ValueSource vs, AtomicReaderContext context, String field) throws IOException {
try {
@@ -75,8 +74,7 @@ public abstract class StringIndexDocValu
int ord=termsIndex.getOrd(doc);
if (ord==0) return null;
termsIndex.lookup(ord, spare);
- spareChars.reset();
- ByteUtils.UTF8toUTF16(spare, spareChars);
+ spare.utf8ToChars(spareChars);
return spareChars.toString();
}
Modified: lucene/dev/trunk/solr/src/webapp/web/admin/analysis.jsp
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/webapp/web/admin/analysis.jsp?rev=1127326&r1=1127325&r2=1127326&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/webapp/web/admin/analysis.jsp (original)
+++ lucene/dev/trunk/solr/src/webapp/web/admin/analysis.jsp Tue May 24 22:44:36 2011
@@ -19,6 +19,7 @@
org.apache.lucene.util.AttributeSource,
org.apache.lucene.util.Attribute,
org.apache.lucene.util.BytesRef,
+ org.apache.lucene.util.CharsRef,
org.apache.lucene.analysis.TokenStream,
org.apache.lucene.index.Payload,
org.apache.lucene.analysis.CharReader,
@@ -32,8 +33,7 @@
org.apache.solr.schema.FieldType,
org.apache.solr.schema.SchemaField,
org.apache.solr.common.util.XML,
- javax.servlet.jsp.JspWriter,java.io.IOException,
- org.apache.noggit.CharArr
+ javax.servlet.jsp.JspWriter,java.io.IOException
"%>
<%@ page import="java.io.Reader"%>
<%@ page import="java.io.StringReader"%>
@@ -287,9 +287,7 @@
bytes = new BytesRef(spare);
rawText = (token.hasAttribute(CharTermAttribute.class)) ?
token.getAttribute(CharTermAttribute.class).toString() : null;
- final CharArr textBuf = new CharArr(bytes.length);
- ft.indexedToReadable(bytes, textBuf);
- text = textBuf.toString();
+ text = ft.indexedToReadable(bytes, new CharsRef()).toString();
token.reflectWith(new AttributeReflector() {
public void reflect(Class<? extends Attribute> attClass, String key, Object value) {
// leave out position and raw term