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/14 11:15:36 UTC

svn commit: r1617902 [1/2] - in /lucene/dev/branches/branch_4x: lucene/core/src/java/org/apache/lucene/util/ lucene/core/src/java/org/apache/lucene/util/mutable/ lucene/core/src/test/org/apache/lucene/util/mutable/ lucene/grouping/src/test/org/apache/l...

Author: jpountz
Date: Thu Aug 14 09:15:35 2014
New Revision: 1617902

URL: http://svn.apache.org/r1617902
Log:
LUCENE-5864: Backward compatibility.

Modified:
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/BytesRef.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/CharsRef.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/IntsRef.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/UnicodeUtil.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/mutable/MutableValueStr.java
    lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/mutable/TestMutableValues.java
    lucene/dev/branches/branch_4x/lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java
    lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionValues.java
    lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/DocTermsIndexDocValues.java
    lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/BytesRefFieldSource.java
    lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/DefFunction.java
    lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/IfFunction.java
    lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/LiteralValueSource.java
    lucene/dev/branches/branch_4x/lucene/queries/src/test/org/apache/lucene/queries/function/TestDocValuesFieldSources.java
    lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/serialized/SerializedDVStrategy.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/PivotFacetHelper.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/TermsComponent.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/DocValuesFacets.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/NumericFacets.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/SimpleFacets.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/UnInvertedField.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/BoolField.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/DateField.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/EnumField.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/FieldType.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableDoubleField.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableFloatField.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableIntField.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableLongField.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/TrieDateField.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/TrieField.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/QueryParsing.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/TermQParserPlugin.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DeleteUpdateCommand.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessorFactory.java

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/BytesRef.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/BytesRef.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/BytesRef.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/BytesRef.java Thu Aug 14 09:15:35 2014
@@ -17,7 +17,6 @@ package org.apache.lucene.util;
  * limitations under the License.
  */
 
-import java.util.Arrays;
 import java.util.Comparator;
 
 /** Represents byte[], as a slice (offset + length) into an
@@ -84,6 +83,19 @@ public final class BytesRef implements C
     this(new byte[UnicodeUtil.MAX_UTF8_BYTES_PER_CHAR * text.length()]);
     length = UnicodeUtil.UTF16toUTF8(text, 0, text.length(), bytes);
   }
+
+  /**
+   * Copies the UTF8 bytes for this string.
+   * 
+   * @param text Must be well-formed unicode text, with no
+   * unpaired surrogates or invalid UTF16 code units.
+   * @deprecated {@link BytesRef} should not be used as a buffer, use {@link BytesRefBuilder} instead
+   */
+  @Deprecated
+  public void copyChars(CharSequence text) {
+    assert offset == 0;   // TODO broken if offset != 0
+    UnicodeUtil.UTF16toUTF8(text, this);
+  }
   
   /**
    * Expert: compares the bytes against another BytesRef,
@@ -166,6 +178,55 @@ public final class BytesRef implements C
     return sb.toString();
   }
 
+  /**
+   * Copies the bytes from the given {@link BytesRef}
+   * <p>
+   * NOTE: if this would exceed the array size, this method creates a 
+   * new reference array.
+   * @deprecated {@link BytesRef} should not be used as a buffer, use {@link BytesRefBuilder} instead
+   */
+  @Deprecated
+  public void copyBytes(BytesRef other) {
+    if (bytes.length - offset < other.length) {
+      bytes = new byte[other.length];
+      offset = 0;
+    }
+    System.arraycopy(other.bytes, other.offset, bytes, offset, other.length);
+    length = other.length;
+  }
+
+  /**
+   * Appends the bytes from the given {@link BytesRef}
+   * <p>
+   * NOTE: if this would exceed the array size, this method creates a 
+   * new reference array.
+   * @deprecated {@link BytesRef} should not be used as a buffer, use {@link BytesRefBuilder} instead
+   */
+  @Deprecated
+  public void append(BytesRef other) {
+    int newLen = length + other.length;
+    if (bytes.length - offset < newLen) {
+      byte[] newBytes = new byte[newLen];
+      System.arraycopy(bytes, offset, newBytes, 0, length);
+      offset = 0;
+      bytes = newBytes;
+    }
+    System.arraycopy(other.bytes, other.offset, bytes, length+offset, other.length);
+    length = newLen;
+  }
+
+  /** 
+   * Used to grow the reference array. 
+   * 
+   * In general this should not be used as it does not take the offset into account.
+   * @deprecated {@link BytesRef} should not be used as a buffer, use {@link BytesRefBuilder} instead
+   * @lucene.internal */
+  @Deprecated
+  public void grow(int newLength) {
+    assert offset == 0; // NOTE: senseless if offset != 0
+    bytes = ArrayUtil.grow(bytes, newLength);
+  }
+
   /** Unsigned byte order comparison */
   @Override
   public int compareTo(BytesRef other) {
@@ -278,9 +339,7 @@ public final class BytesRef implements C
    */
   public static BytesRef deepCopyOf(BytesRef other) {
     BytesRef copy = new BytesRef();
-    copy.bytes = Arrays.copyOfRange(other.bytes, other.offset, other.offset + other.length);
-    copy.offset = 0;
-    copy.length = other.length;
+    copy.copyBytes(other);
     return copy;
   }
   

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/CharsRef.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/CharsRef.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/CharsRef.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/CharsRef.java Thu Aug 14 09:15:35 2014
@@ -17,7 +17,6 @@ package org.apache.lucene.util;
  * limitations under the License.
  */
 
-import java.util.Arrays;
 import java.util.Comparator;
 
 /**
@@ -148,6 +147,63 @@ public final class CharsRef implements C
     // One is a prefix of the other, or, they are equal:
     return this.length - other.length;
   }
+  
+  /**
+   * Copies the given {@link CharsRef} referenced content into this instance.
+   * 
+   * @param other
+   *          the {@link CharsRef} to copy
+   * @deprecated {@link CharsRef} should not be used as a buffer, use {@link CharsRefBuilder} instead
+   */
+  @Deprecated
+  public void copyChars(CharsRef other) {
+    copyChars(other.chars, other.offset, other.length);
+  }
+
+  /** 
+   * Used to grow the reference array. 
+   * 
+   * In general this should not be used as it does not take the offset into account.
+   * @deprecated {@link CharsRef} should not be used as a buffer, use {@link CharsRefBuilder} instead
+   * @lucene.internal */
+  @Deprecated
+  public void grow(int newLength) {
+    assert offset == 0;
+    if (chars.length < newLength) {
+      chars = ArrayUtil.grow(chars, newLength);
+    }
+  }
+
+  /**
+   * Copies the given array into this CharsRef.
+   * @deprecated {@link CharsRef} should not be used as a buffer, use {@link CharsRefBuilder} instead
+   */
+  @Deprecated
+  public void copyChars(char[] otherChars, int otherOffset, int otherLength) {
+    if (chars.length - offset < otherLength) {
+      chars = new char[otherLength];
+      offset = 0;
+    }
+    System.arraycopy(otherChars, otherOffset, chars, offset, otherLength);
+    length = otherLength;
+  }
+
+  /**
+   * Appends the given array to this CharsRef
+   * @deprecated {@link CharsRef} should not be used as a buffer, use {@link CharsRefBuilder} instead
+   */
+  @Deprecated
+  public void append(char[] otherChars, int otherOffset, int otherLength) {
+    int newLen = length + otherLength;
+    if (chars.length - offset < newLen) {
+      char[] newChars = new char[newLen];
+      System.arraycopy(chars, offset, newChars, 0, length);
+      offset = 0;
+      chars = newChars;
+    }
+    System.arraycopy(otherChars, otherOffset, chars, length+offset, otherLength);
+    length = newLen;
+  }
 
   @Override
   public String toString() {
@@ -244,7 +300,9 @@ public final class CharsRef implements C
    * and an offset of zero.
    */
   public static CharsRef deepCopyOf(CharsRef other) {
-    return new CharsRef(Arrays.copyOfRange(other.chars, other.offset, other.offset + other.length), 0, other.length);
+    CharsRef clone = new CharsRef();
+    clone.copyChars(other);
+    return clone;
   }
   
   /** 

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/IntsRef.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/IntsRef.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/IntsRef.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/IntsRef.java Thu Aug 14 09:15:35 2014
@@ -1,7 +1,5 @@
 package org.apache.lucene.util;
 
-import java.util.Arrays;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -134,6 +132,33 @@ public final class IntsRef implements Co
     return this.length - other.length;
   }
 
+  /**
+   * @deprecated {@link IntsRef} should not be used as a buffer, use {@link IntsRefBuilder} instead
+   */
+  @Deprecated
+  public void copyInts(IntsRef other) {
+    if (ints.length - offset < other.length) {
+      ints = new int[other.length];
+      offset = 0;
+    }
+    System.arraycopy(other.ints, other.offset, ints, offset, other.length);
+    length = other.length;
+  }
+
+  /** 
+   * Used to grow the reference array. 
+   * 
+   * In general this should not be used as it does not take the offset into account.
+   * @deprecated {@link IntsRef} should not be used as a buffer, use {@link IntsRefBuilder} instead
+   * @lucene.internal */
+  @Deprecated
+  public void grow(int newLength) {
+    assert offset == 0;
+    if (ints.length < newLength) {
+      ints = ArrayUtil.grow(ints, newLength);
+    }
+  }
+
   @Override
   public String toString() {
     StringBuilder sb = new StringBuilder();
@@ -157,7 +182,9 @@ public final class IntsRef implements Co
    * and an offset of zero.
    */
   public static IntsRef deepCopyOf(IntsRef other) {
-    return new IntsRef(Arrays.copyOfRange(other.ints, other.offset, other.offset + other.length), 0, other.length);
+    IntsRef clone = new IntsRef();
+    clone.copyInts(other);
+    return clone;
   }
   
   /** 

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/UnicodeUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/UnicodeUtil.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/UnicodeUtil.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/UnicodeUtil.java Thu Aug 14 09:15:35 2014
@@ -574,4 +574,28 @@ public final class UnicodeUtil {
     return UTF8toUTF16(bytesRef.bytes, bytesRef.offset, bytesRef.length, chars);
   }
 
+  /**
+   * @deprecated Uses {@link CharsRef} as a buffer.
+   */
+  @Deprecated
+  public static void UTF8toUTF16(BytesRef bytes, CharsRef chars) {
+    assert chars.offset == 0;
+    if (chars.chars.length < bytes.length) {
+      chars.chars = new char[bytes.length];
+    }
+    chars.length = UTF8toUTF16(bytes, chars.chars);
+  }
+
+  /**
+   * @deprecated Uses {@link BytesRef} as a buffer.
+   */
+  @Deprecated
+  public static void UTF16toUTF8(CharSequence chars, BytesRef bytes) {
+    assert bytes.offset == 0;
+    if (bytes.length < MAX_UTF8_BYTES_PER_CHAR * chars.length()) {
+      bytes.bytes = new byte[MAX_UTF8_BYTES_PER_CHAR * chars.length()];
+    }
+    bytes.length = UTF16toUTF8(chars, 0, chars.length(), bytes.bytes);
+  }
+
 }

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/mutable/MutableValueStr.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/mutable/MutableValueStr.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/mutable/MutableValueStr.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/mutable/MutableValueStr.java Thu Aug 14 09:15:35 2014
@@ -26,12 +26,12 @@ import org.apache.lucene.util.BytesRefBu
  * have a <code>value</code> with a length set to 0.
  */
 public class MutableValueStr extends MutableValue {
-  public BytesRefBuilder value = new BytesRefBuilder();
+  public BytesRef value = new BytesRef();
 
   @Override
   public Object toObject() {
-    assert exists || 0 == value.length();
-    return exists ? value.get().utf8ToString() : null;
+    assert exists || 0 == value.length;
+    return exists ? value.utf8ToString() : null;
   }
 
   @Override
@@ -51,16 +51,16 @@ public class MutableValueStr extends Mut
 
   @Override
   public boolean equalsSameType(Object other) {
-    assert exists || 0 == value.length();
+    assert exists || 0 == value.length;
     MutableValueStr b = (MutableValueStr)other;
-    return value.get().equals(b.value.get()) && exists == b.exists;
+    return value.equals(b.value) && exists == b.exists;
   }
 
   @Override
   public int compareSameType(Object other) {
-    assert exists || 0 == value.length();
+    assert exists || 0 == value.length;
     MutableValueStr b = (MutableValueStr)other;
-    int c = value.get().compareTo(b.value.get());
+    int c = value.compareTo(b.value);
     if (c != 0) return c;
     if (exists == b.exists) return 0;
     return exists ? 1 : -1;
@@ -69,7 +69,7 @@ public class MutableValueStr extends Mut
 
   @Override
   public int hashCode() {
-    assert exists || 0 == value.length();
-    return value.get().hashCode();
+    assert exists || 0 == value.length;
+    return value.hashCode();
   }
 }

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/mutable/TestMutableValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/mutable/TestMutableValues.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/mutable/TestMutableValues.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/mutable/TestMutableValues.java Thu Aug 14 09:15:35 2014
@@ -26,7 +26,7 @@ public class TestMutableValues extends L
 
   public void testStr() {
     MutableValueStr xxx = new MutableValueStr();
-    assert xxx.value.get().equals(new BytesRef()) : "defaults have changed, test utility may not longer be as high";
+    assert xxx.value.equals(new BytesRef()) : "defaults have changed, test utility may not longer be as high";
     assert xxx.exists : "defaults have changed, test utility may not longer be as high";
     assertSanity(xxx);
     MutableValueStr yyy = new MutableValueStr();
@@ -42,14 +42,14 @@ public class TestMutableValues extends L
     yyy.exists = false;
     assertEquality(xxx, yyy);
 
-    xxx.value.clear();
+    xxx.value.length = 0;
     xxx.value.copyChars("zzz");
     xxx.exists = true;
     assertSanity(xxx);
 
     assertInEquality(xxx,yyy);
 
-    yyy.value.clear();
+    yyy.value.length = 0;
     yyy.value.copyChars("aaa");
     yyy.exists = true;
     assertSanity(yyy);
@@ -65,11 +65,11 @@ public class TestMutableValues extends L
     // special BytesRef considerations...
 
     xxx.exists = false;
-    xxx.value.clear(); // but leave bytes alone
+    xxx.value.length = 0; // but leave bytes alone
     assertInEquality(xxx,yyy);
 
     yyy.exists = false;
-    yyy.value.clear(); // but leave bytes alone
+    yyy.value.length = 0; // but leave bytes alone
     assertEquality(xxx, yyy);
 
   }

Modified: lucene/dev/branches/branch_4x/lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java (original)
+++ lucene/dev/branches/branch_4x/lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java Thu Aug 14 09:15:35 2014
@@ -300,7 +300,7 @@ public class TestGrouping extends Lucene
       List<SearchGroup<BytesRef>> groups = new ArrayList<>(mutableValueGroups.size());
       for (SearchGroup<MutableValue> mutableValueGroup : mutableValueGroups) {
         SearchGroup<BytesRef> sg = new SearchGroup<>();
-        sg.groupValue = mutableValueGroup.groupValue.exists() ? ((MutableValueStr) mutableValueGroup.groupValue).value.get() : null;
+        sg.groupValue = mutableValueGroup.groupValue.exists() ? ((MutableValueStr) mutableValueGroup.groupValue).value : null;
         sg.sortValues = mutableValueGroup.sortValues;
         groups.add(sg);
       }
@@ -318,7 +318,7 @@ public class TestGrouping extends Lucene
       TopGroups<MutableValue> mvalTopGroups = ((FunctionSecondPassGroupingCollector) c).getTopGroups(withinGroupOffset);
       List<GroupDocs<BytesRef>> groups = new ArrayList<>(mvalTopGroups.groups.length);
       for (GroupDocs<MutableValue> mvalGd : mvalTopGroups.groups) {
-        BytesRef groupValue = mvalGd.groupValue.exists() ? ((MutableValueStr) mvalGd.groupValue).value.get() : null;
+        BytesRef groupValue = mvalGd.groupValue.exists() ? ((MutableValueStr) mvalGd.groupValue).value : null;
         groups.add(new GroupDocs<>(Float.NaN, mvalGd.maxScore, mvalGd.totalHits, mvalGd.scoreDocs, groupValue, mvalGd.groupSortValues));
       }
       return new TopGroups<>(mvalTopGroups.groupSort, mvalTopGroups.withinGroupSort, mvalTopGroups.totalHitCount, mvalTopGroups.totalGroupedHitCount, groups.toArray(new GroupDocs[groups.size()]), Float.NaN);

Modified: lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionValues.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionValues.java (original)
+++ lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionValues.java Thu Aug 14 09:15:35 2014
@@ -19,7 +19,7 @@ package org.apache.lucene.queries.functi
 
 import org.apache.lucene.search.*;
 import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.util.BytesRefBuilder;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.mutable.MutableValue;
 import org.apache.lucene.util.mutable.MutableValueFloat;
 
@@ -53,10 +53,10 @@ public abstract class FunctionValues {
   }
 
   /** returns the bytes representation of the string val - TODO: should this return the indexed raw bytes not? */
-  public boolean bytesVal(int doc, BytesRefBuilder target) {
+  public boolean bytesVal(int doc, BytesRef target) {
     String s = strVal(doc);
     if (s==null) {
-      target.clear();
+      target.length = 0;
       return false;
     }
     target.copyChars(s);

Modified: lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/DocTermsIndexDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/DocTermsIndexDocValues.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/DocTermsIndexDocValues.java (original)
+++ lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/DocTermsIndexDocValues.java Thu Aug 14 09:15:35 2014
@@ -27,7 +27,7 @@ import org.apache.lucene.queries.functio
 import org.apache.lucene.queries.function.ValueSourceScorer;
 import org.apache.lucene.search.FieldCache;
 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.lucene.util.mutable.MutableValue;
 import org.apache.lucene.util.mutable.MutableValueStr;
@@ -40,7 +40,8 @@ public abstract class DocTermsIndexDocVa
   protected final SortedDocValues termsIndex;
   protected final ValueSource vs;
   protected final MutableValueStr val = new MutableValueStr();
-  protected final CharsRefBuilder spareChars = new CharsRefBuilder();
+  protected final CharsRefBuilder spareCharsBuilder = new CharsRefBuilder();
+  protected final CharsRef spareChars = new CharsRef();
 
   public DocTermsIndexDocValues(ValueSource vs, AtomicReaderContext context, String field) throws IOException {
     try {
@@ -69,10 +70,9 @@ public abstract class DocTermsIndexDocVa
   }
 
   @Override
-  public boolean bytesVal(int doc, BytesRefBuilder target) {
-    target.clear();
+  public boolean bytesVal(int doc, BytesRef target) {
     target.copyBytes(termsIndex.get(doc));
-    return target.length() > 0;
+    return target.length > 0;
   }
 
   @Override
@@ -81,8 +81,8 @@ public abstract class DocTermsIndexDocVa
     if (term.length == 0) {
       return null;
     }
-    spareChars.copyUTF8Bytes(term);
-    return spareChars.toString();
+    spareCharsBuilder.copyUTF8Bytes(term);
+    return spareCharsBuilder.toString();
   }
 
   @Override
@@ -149,7 +149,7 @@ public abstract class DocTermsIndexDocVa
       @Override
       public void fillValue(int doc) {
         int ord = termsIndex.getOrd(doc);
-        mval.value.clear();
+        mval.value.length = 0;
         mval.exists = ord >= 0;
         if (mval.exists) {
           mval.value.copyBytes(termsIndex.lookupOrd(ord));

Modified: lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/BytesRefFieldSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/BytesRefFieldSource.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/BytesRefFieldSource.java (original)
+++ lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/BytesRefFieldSource.java Thu Aug 14 09:15:35 2014
@@ -28,7 +28,7 @@ import org.apache.lucene.queries.functio
 import org.apache.lucene.queries.function.docvalues.DocTermsIndexDocValues;
 import org.apache.lucene.search.FieldCache;
 import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRefBuilder;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.mutable.MutableValue;
 import org.apache.lucene.util.mutable.MutableValueStr;
 
@@ -57,15 +57,15 @@ public class BytesRefFieldSource extends
         }
 
         @Override
-        public boolean bytesVal(int doc, BytesRefBuilder target) {
+        public boolean bytesVal(int doc, BytesRef target) {
           target.copyBytes(binaryValues.get(doc));
-          return target.length() > 0;
+          return target.length > 0;
         }
 
         public String strVal(int doc) {
-          final BytesRefBuilder bytes = new BytesRefBuilder();
+          final BytesRef bytes = new BytesRef();
           return bytesVal(doc, bytes)
-              ? bytes.get().utf8ToString()
+              ? bytes.utf8ToString()
               : null;
         }
 
@@ -92,7 +92,6 @@ public class BytesRefFieldSource extends
             @Override
             public void fillValue(int doc) {
               mval.exists = docsWithField.get(doc);
-              mval.value.clear();
               mval.value.copyBytes(binaryValues.get(doc));
             }
           };

Modified: lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/DefFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/DefFunction.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/DefFunction.java (original)
+++ lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/DefFunction.java Thu Aug 14 09:15:35 2014
@@ -16,15 +16,15 @@ package org.apache.lucene.queries.functi
  * limitations under the License.
  */
 
-import org.apache.lucene.index.AtomicReaderContext;
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.ValueSource;
-import org.apache.lucene.util.BytesRefBuilder;
-
 import java.io.IOException;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.queries.function.FunctionValues;
+import org.apache.lucene.queries.function.ValueSource;
+import org.apache.lucene.util.BytesRef;
+
 /**
  * {@link ValueSource} implementation which only returns the values from the provided
  * ValueSources which are available for a particular docId.  Consequently, when combined
@@ -100,7 +100,7 @@ public class DefFunction extends MultiFu
       }
 
       @Override
-      public boolean bytesVal(int doc, BytesRefBuilder target) {
+      public boolean bytesVal(int doc, BytesRef target) {
         return get(doc).bytesVal(doc, target);
       }
 

Modified: lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/IfFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/IfFunction.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/IfFunction.java (original)
+++ lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/IfFunction.java Thu Aug 14 09:15:35 2014
@@ -17,17 +17,14 @@
 
 package org.apache.lucene.queries.function.valuesource;
 
+import java.io.IOException;
+import java.util.Map;
+
 import org.apache.lucene.index.AtomicReaderContext;
-import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.queries.function.FunctionValues;
 import org.apache.lucene.queries.function.ValueSource;
-import org.apache.lucene.search.Explanation;
 import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.util.BytesRefBuilder;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
+import org.apache.lucene.util.BytesRef;
 
 
 /**
@@ -94,7 +91,7 @@ public class IfFunction extends BoolFunc
       }
 
       @Override
-      public boolean bytesVal(int doc, BytesRefBuilder target) {
+      public boolean bytesVal(int doc, BytesRef target) {
         return ifVals.boolVal(doc) ? trueVals.bytesVal(doc, target) : falseVals.bytesVal(doc, target);
       }
 

Modified: lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/LiteralValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/LiteralValueSource.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/LiteralValueSource.java (original)
+++ lucene/dev/branches/branch_4x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/LiteralValueSource.java Thu Aug 14 09:15:35 2014
@@ -21,7 +21,6 @@ import org.apache.lucene.queries.functio
 import org.apache.lucene.queries.function.ValueSource;
 import org.apache.lucene.queries.function.docvalues.StrDocValues;
 import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.BytesRefBuilder;
 
 import java.util.Map;
 import java.io.IOException;
@@ -55,7 +54,7 @@ public class LiteralValueSource extends 
       }
 
       @Override
-      public boolean bytesVal(int doc, BytesRefBuilder target) {
+      public boolean bytesVal(int doc, BytesRef target) {
         target.copyBytes(bytesRef);
         return true;
       }

Modified: lucene/dev/branches/branch_4x/lucene/queries/src/test/org/apache/lucene/queries/function/TestDocValuesFieldSources.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/queries/src/test/org/apache/lucene/queries/function/TestDocValuesFieldSources.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/queries/src/test/org/apache/lucene/queries/function/TestDocValuesFieldSources.java (original)
+++ lucene/dev/branches/branch_4x/lucene/queries/src/test/org/apache/lucene/queries/function/TestDocValuesFieldSources.java Thu Aug 14 09:15:35 2014
@@ -34,7 +34,6 @@ import org.apache.lucene.queries.functio
 import org.apache.lucene.queries.function.valuesource.LongFieldSource;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.BytesRefBuilder;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
 import org.apache.lucene.util.TestUtil;
@@ -110,7 +109,7 @@ public class TestDocValuesFieldSources e
           throw new AssertionError();
       }
       final FunctionValues values = vs.getValues(null, leave);
-      BytesRefBuilder bytes = new BytesRefBuilder();
+      BytesRef bytes = new BytesRef();
       for (int i = 0; i < leave.reader().maxDoc(); ++i) {
         assertTrue(values.exists(i));
         if (vs instanceof BytesRefFieldSource) {
@@ -133,7 +132,7 @@ public class TestDocValuesFieldSources e
             assertEquals(expected, values.objectVal(i));
             assertEquals(expected, values.strVal(i));
             assertTrue(values.bytesVal(i, bytes));
-            assertEquals(new BytesRef((String) expected), bytes.get());
+            assertEquals(new BytesRef((String) expected), bytes);
             break;
           case NUMERIC:
             assertEquals(((Number) expected).longValue(), values.longVal(i));
@@ -146,11 +145,12 @@ public class TestDocValuesFieldSources e
   }
 
   public void test() throws IOException {
-    for (DocValuesType type : DocValuesType.values()) {
+    DocValuesType type = DocValuesType.SORTED;
+    //for (DocValuesType type : DocValuesType.values()) {
       if (type != DocValuesType.SORTED_SET && type != DocValuesType.SORTED_NUMERIC) {
         test(type);
       }
-    }
+    //}
   }
 
 }

Modified: lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/serialized/SerializedDVStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/serialized/SerializedDVStrategy.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/serialized/SerializedDVStrategy.java (original)
+++ lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/serialized/SerializedDVStrategy.java Thu Aug 14 09:15:35 2014
@@ -38,7 +38,6 @@ import org.apache.lucene.spatial.util.Di
 import org.apache.lucene.spatial.util.ShapePredicateValueSource;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.BytesRefBuilder;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -212,14 +211,14 @@ public class SerializedDVStrategy extend
 
       return new FunctionValues() {
         int bytesRefDoc = -1;
-        BytesRefBuilder bytesRef = new BytesRefBuilder();
+        BytesRef bytesRef = new BytesRef();//scratch
 
         boolean fillBytes(int doc) {
           if (bytesRefDoc != doc) {
             bytesRef.copyBytes(docValues.get(doc));
             bytesRefDoc = doc;
           }
-          return bytesRef.length() != 0;
+          return bytesRef.length != 0;
         }
 
         @Override
@@ -228,12 +227,14 @@ public class SerializedDVStrategy extend
         }
 
         @Override
-        public boolean bytesVal(int doc, BytesRefBuilder target) {
-          target.clear();
+        public boolean bytesVal(int doc, BytesRef target) {
           if (fillBytes(doc)) {
-            target.copyBytes(bytesRef);
+            target.bytes = bytesRef.bytes;
+            target.offset = bytesRef.offset;
+            target.length = bytesRef.length;
             return true;
           } else {
+            target.length = 0;
             return false;
           }
         }
@@ -243,7 +244,7 @@ public class SerializedDVStrategy extend
           if (!fillBytes(docId))
             return null;
           DataInputStream dataInput = new DataInputStream(
-              new ByteArrayInputStream(bytesRef.bytes(), 0, bytesRef.length()));
+              new ByteArrayInputStream(bytesRef.bytes, bytesRef.offset, bytesRef.length));
           try {
             return binaryCodec.readShape(dataInput);
           } catch (IOException e) {

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java Thu Aug 14 09:15:35 2014
@@ -249,7 +249,7 @@ public abstract class AnalysisRequestHan
       final TermToBytesRefAttribute termAtt = token.getAttribute(TermToBytesRefAttribute.class);
       BytesRef rawBytes = termAtt.getBytesRef();
       termAtt.fillBytesRef();
-      final String text = fieldType.indexedToReadable(rawBytes, new CharsRefBuilder()).toString();
+      final String text = fieldType.indexedToReadable(rawBytes, new CharsRef()).toString();
       tokenNamedList.add("text", text);
       
       if (token.hasAttribute(CharTermAttribute.class)) {

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java Thu Aug 14 09:15:35 2014
@@ -218,7 +218,7 @@ public class ExpandComponent extends Sea
     searcher.search(query, pfilter.filter, collector);
     IntObjectMap groups = groupExpandCollector.getGroups();
     Map<String, DocSlice> outMap = new HashMap();
-    CharsRefBuilder charsRef = new CharsRefBuilder();
+    CharsRef charsRef = new CharsRef();
     FieldType fieldType = searcher.getSchema().getField(field).getType();
     for (IntObjectCursor cursor : (Iterable<IntObjectCursor>) groups) {
       int ord = cursor.key;

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/PivotFacetHelper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/PivotFacetHelper.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/PivotFacetHelper.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/PivotFacetHelper.java Thu Aug 14 09:15:35 2014
@@ -28,6 +28,7 @@ import org.apache.lucene.index.Term;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.search.TermRangeQuery;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.BytesRefBuilder;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrException.ErrorCode;
@@ -116,16 +117,16 @@ public class PivotFacetHelper extends Si
 
         // don't reuse the same BytesRef each time since we will be 
         // constructing Term objects used in TermQueries that may be cached.
-        BytesRefBuilder termval = null;
+        BytesRef termval = null;
 
         SimpleOrderedMap<Object> pivot = new SimpleOrderedMap<>();
         pivot.add( "field", field );
         if (null == fieldValue) {
           pivot.add( "value", null );
         } else {
-          termval = new BytesRefBuilder();
+          termval = new BytesRef();
           ftype.readableToIndexed(fieldValue, termval);
-          pivot.add( "value", ftype.toObject(sfield, termval.get()) );
+          pivot.add( "value", ftype.toObject(sfield, termval) );
         }
         pivot.add( "count", kv.getValue() );
         
@@ -139,7 +140,7 @@ public class PivotFacetHelper extends Si
               (new TermRangeQuery(field, null, null, false, false));
             subset = docs.andNot(hasVal);
           } else {
-            Query query = new TermQuery(new Term(field, termval.get()));
+            Query query = new TermQuery(new Term(field, termval));
             subset = searcher.getDocSet(query, docs);
           }
           super.docs = subset;//used by getTermCounts()

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java Thu Aug 14 09:15:35 2014
@@ -138,11 +138,11 @@ public class RealTimeGetComponent extend
    try {
      SolrIndexSearcher searcher = null;
 
-     BytesRefBuilder idBytes = new BytesRefBuilder();
+     BytesRef idBytes = new BytesRef();
      for (String idStr : allIds) {
        fieldType.readableToIndexed(idStr, idBytes);
        if (ulog != null) {
-         Object o = ulog.lookup(idBytes.get());
+         Object o = ulog.lookup(idBytes);
          if (o != null) {
            // should currently be a List<Oper,Ver,Doc/Id>
            List entry = (List)o;
@@ -173,7 +173,7 @@ public class RealTimeGetComponent extend
 
        // SolrCore.verbose("RealTimeGet using searcher ", searcher);
 
-       int docid = searcher.getFirstMatch(new Term(idField.getName(), idBytes.get()));
+       int docid = searcher.getFirstMatch(new Term(idField.getName(), idBytes));
        if (docid < 0) continue;
        Document luceneDocument = searcher.doc(docid);
        SolrDocument doc = toSolrDoc(luceneDocument,  core.getLatestSchema());

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/TermsComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/TermsComponent.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/TermsComponent.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/TermsComponent.java Thu Aug 14 09:15:35 2014
@@ -139,9 +139,9 @@ public class TermsComponent extends Sear
 
       BytesRef upperBytes = null;
       if (upperStr != null) {
-        BytesRefBuilder b = new BytesRefBuilder();
+        BytesRef b = new BytesRef();
         ft.readableToIndexed(upperStr, b);
-        upperBytes = b.get();
+        upperBytes = b;
       }
 
       BytesRef lowerBytes;
@@ -155,9 +155,9 @@ public class TermsComponent extends Sear
           // perhaps we detect if the FieldType is non-character and expect hex if so?
           lowerBytes = new BytesRef(lowerStr);
         } else {
-          BytesRefBuilder b = new BytesRefBuilder();
+          BytesRef b = new BytesRef();
           ft.readableToIndexed(lowerStr, b);
-          lowerBytes = b.get();
+          lowerBytes = b;
         }
       }
 
@@ -182,7 +182,7 @@ public class TermsComponent extends Sear
 
       int i = 0;
       BoundedTreeSet<CountPair<BytesRef, Integer>> queue = (sort ? new BoundedTreeSet<CountPair<BytesRef, Integer>>(limit) : null);
-      CharsRefBuilder external = new CharsRefBuilder();
+      CharsRef external = new CharsRef();
       while (term != null && (i<limit || sort)) {
         boolean externalized = false; // did we fill in "external" yet for this term?
 
@@ -194,7 +194,7 @@ public class TermsComponent extends Sear
           // TODO: support "raw" mode?
           ft.indexedToReadable(term, external);
           externalized = true;
-          if (!pattern.matcher(external.get()).matches()) {
+          if (!pattern.matcher(external).matches()) {
             term = termsEnum.next();
             continue;
           }

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/DocValuesFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/DocValuesFacets.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/DocValuesFacets.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/DocValuesFacets.java Thu Aug 14 09:15:35 2014
@@ -111,7 +111,7 @@ public class DocValuesFacets {
 
     final int nTerms=endTermIndex-startTermIndex;
     int missingCount = -1; 
-    final CharsRefBuilder charsRef = new CharsRefBuilder();
+    final CharsRef charsRef = new CharsRef();
     if (nTerms>0 && docs.size() >= mincount) {
 
       // count collection array only needs to be as big as the number of terms we are

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/NumericFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/NumericFacets.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/NumericFacets.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/NumericFacets.java Thu Aug 14 09:15:35 2014
@@ -291,7 +291,7 @@ final class NumericFacets {
             default:
               throw new AssertionError();
           }
-          final CharsRefBuilder spare = new CharsRefBuilder();
+          final CharsRef spare = new CharsRef();
           for (int skipped = hashTable.size; skipped < offset && term != null && StringHelper.startsWith(term, prefix); ) {
             ft.indexedToReadable(term, spare);
             final String termStr = spare.toString();
@@ -344,7 +344,7 @@ final class NumericFacets {
           default:
             throw new AssertionError();
         }
-        final CharsRefBuilder spare = new CharsRefBuilder();
+        final CharsRef spare = new CharsRef();
         for (int i = 0; i < offset && term != null && StringHelper.startsWith(term, prefix); ++i) {
           term = termsEnum.next();
         }

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/SimpleFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/SimpleFacets.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/SimpleFacets.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/SimpleFacets.java Thu Aug 14 09:15:35 2014
@@ -483,7 +483,7 @@ public class SimpleFacets {
                                       (offset + limit), 
                                       mincount, orderByCount);
 
-    CharsRefBuilder charsRef = new CharsRefBuilder();
+    CharsRef charsRef = new CharsRef();
     FieldType facetFieldType = searcher.getSchema().getFieldType(field);
     NamedList<Integer> facetCounts = new NamedList<>();
     List<TermGroupFacetCollector.FacetEntry> scopedEntries 
@@ -682,7 +682,7 @@ public class SimpleFacets {
 
     final int nTerms=endTermIndex-startTermIndex;
     int missingCount = -1; 
-    final CharsRefBuilder charsRef = new CharsRefBuilder();
+    final CharsRef charsRef = new CharsRef();
     if (nTerms>0 && docs.size() >= mincount) {
 
       // count collection array only needs to be as big as the number of terms we are
@@ -849,7 +849,7 @@ public class SimpleFacets {
     }
 
     DocsEnum docsEnum = null;
-    CharsRefBuilder charsRef = new CharsRefBuilder();
+    CharsRef charsRef = new CharsRef();
 
     if (docs.size() >= mincount) {
       while (term != null) {

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/UnInvertedField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/UnInvertedField.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/UnInvertedField.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/UnInvertedField.java Thu Aug 14 09:15:35 2014
@@ -32,7 +32,6 @@ import org.apache.lucene.search.TermRang
 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.lucene.util.FixedBitSet;
 import org.apache.lucene.util.UnicodeUtil;
 import org.apache.solr.common.SolrException;
@@ -346,7 +345,7 @@ public class UnInvertedField extends Doc
           }
         }
       }
-      final CharsRefBuilder charsRef = new CharsRefBuilder();
+      final CharsRef charsRef = new CharsRef();
 
       int off=offset;
       int lim=limit>=0 ? limit : Integer.MAX_VALUE;
@@ -626,7 +625,7 @@ public class UnInvertedField extends Doc
 
   }
 
-  String getReadableValue(BytesRef termval, FieldType ft, CharsRefBuilder charsRef) {
+  String getReadableValue(BytesRef termval, FieldType ft, CharsRef charsRef) {
     return ft.indexedToReadable(termval, charsRef).toString();
   }
 

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/BoolField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/BoolField.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/BoolField.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/BoolField.java Thu Aug 14 09:15:35 2014
@@ -35,7 +35,6 @@ import org.apache.lucene.search.FieldCac
 import org.apache.lucene.search.SortField;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.CharsRef;
-import org.apache.lucene.util.CharsRefBuilder;
 import org.apache.lucene.util.mutable.MutableValue;
 import org.apache.lucene.util.mutable.MutableValueBool;
 import org.apache.solr.analysis.SolrAnalyzer;
@@ -138,13 +137,13 @@ public class BoolField extends Primitive
   private static final CharsRef FALSE = new CharsRef("false");
   
   @Override
-  public CharsRef indexedToReadable(BytesRef input, CharsRefBuilder charsRef) {
+  public CharsRef indexedToReadable(BytesRef input, CharsRef charsRef) {
     if (input.length > 0 && input.bytes[input.offset] == 'T') {
       charsRef.copyChars(TRUE);
     } else {
       charsRef.copyChars(FALSE);
     }
-    return charsRef.get();
+    return charsRef;
   }
 
   @Override

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/DateField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/DateField.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/DateField.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/DateField.java Thu Aug 14 09:15:35 2014
@@ -28,7 +28,6 @@ import org.apache.lucene.queries.functio
 import org.apache.lucene.queries.function.valuesource.FieldCacheSource;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.CharsRef;
-import org.apache.lucene.util.CharsRefBuilder;
 import org.apache.lucene.util.UnicodeUtil;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.util.DateUtil;
@@ -217,10 +216,10 @@ public class DateField extends Primitive
   }
 
   @Override
-  public CharsRef indexedToReadable(BytesRef input, CharsRefBuilder charsRef) {
-    charsRef.copyUTF8Bytes(input);
+  public CharsRef indexedToReadable(BytesRef input, CharsRef charsRef) {
+    UnicodeUtil.UTF8toUTF16(input, charsRef);
     charsRef.append(Z_ARRAY, 0, 1);
-    return charsRef.get();
+    return charsRef;
   }
 
   @Override

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/EnumField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/EnumField.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/EnumField.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/EnumField.java Thu Aug 14 09:15:35 2014
@@ -19,14 +19,12 @@ package org.apache.solr.schema;
 
 import org.apache.lucene.document.FieldType;
 import org.apache.lucene.index.IndexableField;
-
 import org.apache.lucene.queries.function.ValueSource;
 import org.apache.lucene.queries.function.valuesource.EnumFieldSource;
 import org.apache.lucene.search.*;
 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.lucene.util.NumericUtils;
 import org.apache.solr.common.EnumFieldValue;
 import org.apache.solr.common.SolrException;
@@ -265,22 +263,24 @@ public class EnumField extends Primitive
     if (val == null)
       return null;
 
-    final BytesRefBuilder bytes = new BytesRefBuilder();
+    final BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_LONG);
     readableToIndexed(val, bytes);
-    return bytes.get().utf8ToString();
+    return bytes.utf8ToString();
   }
 
   /**
    * {@inheritDoc}
    */
   @Override
-  public void readableToIndexed(CharSequence val, BytesRefBuilder result) {
+  public void readableToIndexed(CharSequence val, BytesRef result) {
     final String s = val.toString();
     if (s == null)
       return;
 
     final Integer intValue = stringValueToIntValue(s);
-    NumericUtils.intToPrefixCoded(intValue, 0, result);
+    BytesRefBuilder b = new BytesRefBuilder();
+    NumericUtils.intToPrefixCoded(intValue, 0, b);
+    result.copyBytes(b.get());
   }
 
   /**
@@ -319,13 +319,13 @@ public class EnumField extends Primitive
    * {@inheritDoc}
    */
   @Override
-  public CharsRef indexedToReadable(BytesRef input, CharsRefBuilder output) {
+  public CharsRef indexedToReadable(BytesRef input, CharsRef output) {
     final Integer intValue = NumericUtils.prefixCodedToInt(input);
     final String stringValue = intValueToStringValue(intValue);
     output.grow(stringValue.length());
-    output.setLength(stringValue.length());
-    stringValue.getChars(0, output.length(), output.chars(), 0);
-    return output.get();
+    output.length = stringValue.length();
+    stringValue.getChars(0, output.length, output.chars, 0);
+    return output;
   }
 
   /**

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/FieldType.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/FieldType.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/FieldType.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/FieldType.java Thu Aug 14 09:15:35 2014
@@ -42,9 +42,7 @@ import org.apache.lucene.search.TermQuer
 import org.apache.lucene.search.TermRangeQuery;
 import org.apache.lucene.search.similarities.Similarity;
 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.lucene.util.UnicodeUtil;
 import org.apache.solr.analysis.SolrAnalyzer;
 import org.apache.solr.analysis.TokenizerChain;
@@ -360,7 +358,7 @@ public abstract class FieldType extends 
   }
 
   public Object toObject(SchemaField sf, BytesRef term) {
-    final CharsRefBuilder ref = new CharsRefBuilder();
+    final CharsRef ref = new CharsRef(term.length);
     indexedToReadable(term, ref);
     final IndexableField f = createField(sf, ref.toString(), 1.0f);
     return toObject(f);
@@ -372,9 +370,9 @@ public abstract class FieldType extends 
   }
 
   /** Given an indexed term, append the human readable representation*/
-  public CharsRef indexedToReadable(BytesRef input, CharsRefBuilder output) {
-    output.copyUTF8Bytes(input);
-    return output.get();
+  public CharsRef indexedToReadable(BytesRef input, CharsRef output) {
+    UnicodeUtil.UTF8toUTF16(input, output);
+    return output;
   }
 
   /** Given the stored field, return the human readable representation */
@@ -396,9 +394,9 @@ public abstract class FieldType extends 
   }
 
   /** Given the readable value, return the term value that will match it. */
-  public void readableToIndexed(CharSequence val, BytesRefBuilder result) {
+  public void readableToIndexed(CharSequence val, BytesRef result) {
     final String internal = readableToIndexed(val.toString());
-    result.copyChars(internal);
+    UnicodeUtil.UTF16toUTF8(internal, result);
   }
 
   public void setIsExplicitQueryAnalyzer(boolean isExplicitQueryAnalyzer) {
@@ -748,13 +746,13 @@ public abstract class FieldType extends 
    * 
    */
   public Query getFieldQuery(QParser parser, SchemaField field, String externalVal) {
-    BytesRefBuilder br = new BytesRefBuilder();
+    BytesRef br = new BytesRef();
     readableToIndexed(externalVal, br);
     if (field.hasDocValues() && !field.indexed()) {
       // match-only
       return getRangeQuery(parser, field, externalVal, externalVal, true, true);
     } else {
-      return new TermQuery(new Term(field.getName(), br.toBytesRef()));
+      return new TermQuery(new Term(field.getName(), br));
     }
   }
   
@@ -1010,8 +1008,8 @@ public abstract class FieldType extends 
     if (null == value) {
       return null;
     }
-    CharsRefBuilder spare = new CharsRefBuilder();
-    spare.copyUTF8Bytes((BytesRef)value);
+    CharsRef spare = new CharsRef();
+    UnicodeUtil.UTF8toUTF16((BytesRef)value, spare);
     return spare.toString();
   }
 
@@ -1022,10 +1020,10 @@ public abstract class FieldType extends 
     if (null == value) {
       return null;
     }
-    BytesRefBuilder spare = new BytesRefBuilder();
+    BytesRef spare = new BytesRef();
     String stringVal = (String)value;
-    spare.copyChars(stringVal);
-    return spare.get();
+    UnicodeUtil.UTF16toUTF8(stringVal, spare);
+    return spare;
   }
 
   /**

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableDoubleField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableDoubleField.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableDoubleField.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableDoubleField.java Thu Aug 14 09:15:35 2014
@@ -23,9 +23,8 @@ import org.apache.lucene.queries.functio
 import org.apache.lucene.queries.function.valuesource.FieldCacheSource;
 import org.apache.lucene.search.SortField;
 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.lucene.util.UnicodeUtil;
 import org.apache.lucene.util.mutable.MutableValue;
 import org.apache.lucene.util.mutable.MutableValueDouble;
 import org.apache.solr.search.QParser;
@@ -36,7 +35,6 @@ import org.apache.solr.response.TextResp
 
 import java.util.Map;
 import java.io.IOException;
-
 /**
  * A legacy numeric field type that encodes "Double" values as Strings such 
  * that Term enumeration order matches the natural numeric order.  This class 
@@ -88,12 +86,12 @@ public class SortableDoubleField extends
   }
 
   @Override
-  public CharsRef indexedToReadable(BytesRef input, CharsRefBuilder charsRef) {
+  public CharsRef indexedToReadable(BytesRef input, CharsRef charsRef) {
     // TODO: this could be more efficient, but the sortable types should be deprecated instead
-    charsRef.copyUTF8Bytes(input);
+    UnicodeUtil.UTF8toUTF16(input, charsRef);
     final char[] indexedToReadable = indexedToReadable(charsRef.toString()).toCharArray();
     charsRef.copyChars(indexedToReadable, 0, indexedToReadable.length);
-    return charsRef.get();
+    return charsRef;
   }
 
   @Override
@@ -107,9 +105,9 @@ public class SortableDoubleField extends
     if (null == value) {
       return null;
     }
-    CharsRefBuilder chars = new CharsRefBuilder();
-    chars.copyUTF8Bytes((BytesRef) value);
-    return NumberUtils.SortableStr2double(chars.get().toString());
+    CharsRef chars = new CharsRef();
+    UnicodeUtil.UTF8toUTF16((BytesRef)value, chars);
+    return NumberUtils.SortableStr2double(chars.toString());
   }
 
   @Override
@@ -118,9 +116,9 @@ public class SortableDoubleField extends
       return null;
     }
     String sortableString = NumberUtils.double2sortableStr(value.toString());
-    BytesRefBuilder bytes = new BytesRefBuilder();
-    bytes.copyChars(sortableString);
-    return bytes.get();
+    BytesRef bytes = new BytesRef();
+    UnicodeUtil.UTF16toUTF8(sortableString, bytes);
+    return bytes;
   }
 }
 

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableFloatField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableFloatField.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableFloatField.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableFloatField.java Thu Aug 14 09:15:35 2014
@@ -23,9 +23,7 @@ import org.apache.lucene.queries.functio
 import org.apache.lucene.queries.function.valuesource.FieldCacheSource;
 import org.apache.lucene.search.SortField;
 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.lucene.util.UnicodeUtil;
 import org.apache.lucene.util.mutable.MutableValue;
 import org.apache.lucene.util.mutable.MutableValueFloat;
@@ -89,12 +87,12 @@ public class SortableFloatField extends 
   }
 
   @Override
-  public CharsRef indexedToReadable(BytesRef input, CharsRefBuilder charsRef) {
+  public CharsRef indexedToReadable(BytesRef input, CharsRef charsRef) {
     // TODO: this could be more efficient, but the sortable types should be deprecated instead
-    charsRef.copyUTF8Bytes(input);
+    UnicodeUtil.UTF8toUTF16(input, charsRef);
     final char[] indexedToReadable = indexedToReadable(charsRef.toString()).toCharArray();
     charsRef.copyChars(indexedToReadable, 0, indexedToReadable.length);
-    return charsRef.get();
+    return charsRef;
   }
 
   @Override
@@ -108,9 +106,9 @@ public class SortableFloatField extends 
     if (null == value) {
       return null;
     }
-    CharsRefBuilder chars = new CharsRefBuilder();
-    chars.copyUTF8Bytes((BytesRef)value);
-    return NumberUtils.SortableStr2float(chars.get().toString());
+    CharsRef chars = new CharsRef();
+    UnicodeUtil.UTF8toUTF16((BytesRef)value, chars);
+    return NumberUtils.SortableStr2float(chars.toString());
   }
 
   @Override
@@ -119,9 +117,9 @@ public class SortableFloatField extends 
       return null;
     }
     String sortableString = NumberUtils.float2sortableStr(value.toString());
-    BytesRefBuilder bytes = new BytesRefBuilder();
-    bytes.copyChars(sortableString);
-    return bytes.get();
+    BytesRef bytes = new BytesRef();
+    UnicodeUtil.UTF16toUTF8(sortableString, bytes);
+    return bytes;
   }
 }
 

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableIntField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableIntField.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableIntField.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableIntField.java Thu Aug 14 09:15:35 2014
@@ -23,9 +23,7 @@ import org.apache.lucene.queries.functio
 import org.apache.lucene.queries.function.valuesource.FieldCacheSource;
 import org.apache.lucene.search.SortField;
 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.lucene.util.UnicodeUtil;
 import org.apache.lucene.util.mutable.MutableValue;
 import org.apache.lucene.util.mutable.MutableValueInt;
@@ -87,12 +85,12 @@ public class SortableIntField extends Pr
   }
 
   @Override
-  public CharsRef indexedToReadable(BytesRef input, CharsRefBuilder charsRef) {
+  public CharsRef indexedToReadable(BytesRef input, CharsRef charsRef) {
     // TODO: this could be more efficient, but the sortable types should be deprecated instead
-    charsRef.copyUTF8Bytes(input);
-    final char[] indexedToReadable = indexedToReadable(charsRef.get().toString()).toCharArray();
+    UnicodeUtil.UTF8toUTF16(input, charsRef);
+    final char[] indexedToReadable = indexedToReadable(charsRef.toString()).toCharArray();
     charsRef.copyChars(indexedToReadable, 0, indexedToReadable.length);
-    return charsRef.get();
+    return charsRef;
   }
 
   @Override
@@ -111,8 +109,8 @@ public class SortableIntField extends Pr
     if (null == value) { 
       return null;
     }
-    CharsRefBuilder chars = new CharsRefBuilder();
-    chars.copyUTF8Bytes((BytesRef)value);
+    CharsRef chars = new CharsRef();
+    UnicodeUtil.UTF8toUTF16((BytesRef)value, chars);
     return NumberUtils.SortableStr2int(chars.toString());
   }
 
@@ -122,9 +120,9 @@ public class SortableIntField extends Pr
       return null;
     }
     String sortableString = NumberUtils.int2sortableStr(value.toString());
-    BytesRefBuilder bytes = new BytesRefBuilder();
-    bytes.copyChars(sortableString);
-    return bytes.get();
+    BytesRef bytes = new BytesRef();
+    UnicodeUtil.UTF16toUTF8(sortableString, bytes);
+    return bytes;
   }
 }
 

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableLongField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableLongField.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableLongField.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SortableLongField.java Thu Aug 14 09:15:35 2014
@@ -23,9 +23,7 @@ import org.apache.lucene.queries.functio
 import org.apache.lucene.queries.function.valuesource.FieldCacheSource;
 import org.apache.lucene.search.SortField;
 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.lucene.util.UnicodeUtil;
 import org.apache.lucene.util.mutable.MutableValue;
 import org.apache.lucene.util.mutable.MutableValueLong;
@@ -78,12 +76,12 @@ public class SortableLongField extends P
   }
 
   @Override
-  public CharsRef indexedToReadable(BytesRef input, CharsRefBuilder charsRef) {
+  public CharsRef indexedToReadable(BytesRef input, CharsRef charsRef) {
     // TODO: this could be more efficient, but the sortable types should be deprecated instead
-    charsRef.copyUTF8Bytes(input);
-    final char[] indexedToReadable = indexedToReadable(charsRef.get().toString()).toCharArray();
+    UnicodeUtil.UTF8toUTF16(input, charsRef);
+    final char[] indexedToReadable = indexedToReadable(charsRef.toString()).toCharArray();
     charsRef.copyChars(indexedToReadable, 0, indexedToReadable.length);
-    return charsRef.get();
+    return charsRef;
   }
 
   @Override
@@ -107,8 +105,8 @@ public class SortableLongField extends P
     if (null == value) {
       return null;
     }
-    CharsRefBuilder chars = new CharsRefBuilder();
-    chars.copyUTF8Bytes((BytesRef) value);
+    CharsRef chars = new CharsRef();
+    UnicodeUtil.UTF8toUTF16((BytesRef)value, chars);
     return NumberUtils.SortableStr2long(chars.toString());
   }
 
@@ -118,9 +116,9 @@ public class SortableLongField extends P
       return null;
     }
     String sortableString = NumberUtils.long2sortableStr(value.toString());
-    BytesRefBuilder bytes = new BytesRefBuilder();
-    bytes.copyChars(sortableString);
-    return bytes.get();
+    BytesRef bytes = new BytesRef();
+    UnicodeUtil.UTF16toUTF8(sortableString, bytes);
+    return bytes;
   }
 }
 

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/TrieDateField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/TrieDateField.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/TrieDateField.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/TrieDateField.java Thu Aug 14 09:15:35 2014
@@ -30,7 +30,6 @@ import org.apache.lucene.search.Query;
 import org.apache.lucene.search.SortField;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.CharsRef;
-import org.apache.lucene.util.CharsRefBuilder;
 import org.apache.solr.response.TextResponseWriter;
 import org.apache.solr.search.QParser;
 import org.apache.solr.update.processor.TimestampUpdateProcessorFactory; //jdoc
@@ -156,7 +155,7 @@ public class TrieDateField extends DateF
     return wrappedField.indexedToReadable(_indexedForm);
   }
   @Override
-  public CharsRef indexedToReadable(BytesRef input, CharsRefBuilder charsRef) {
+  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);
   }

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/TrieField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/TrieField.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/TrieField.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/TrieField.java Thu Aug 14 09:15:35 2014
@@ -47,7 +47,6 @@ import org.apache.lucene.search.SortFiel
 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.lucene.util.NumericUtils;
 import org.apache.lucene.util.mutable.MutableValueDate;
 import org.apache.lucene.util.mutable.MutableValueLong;
@@ -376,34 +375,36 @@ public class TrieField extends Primitive
   @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!
-    final BytesRefBuilder bytes = new BytesRefBuilder();
+    final BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_LONG);
     readableToIndexed(val, bytes);
-    return bytes.get().utf8ToString();
+    return bytes.utf8ToString();
   }
 
   @Override
-  public void readableToIndexed(CharSequence val, BytesRefBuilder result) {
+  public void readableToIndexed(CharSequence val, BytesRef result) {
     String s = val.toString();
+    BytesRefBuilder b = new BytesRefBuilder();
     try {
       switch (type) {
         case INTEGER:
-          NumericUtils.intToPrefixCodedBytes(Integer.parseInt(s), 0, result);
+          NumericUtils.intToPrefixCodedBytes(Integer.parseInt(s), 0, b);
           break;
         case FLOAT:
-          NumericUtils.intToPrefixCodedBytes(NumericUtils.floatToSortableInt(Float.parseFloat(s)), 0, result);
+          NumericUtils.intToPrefixCodedBytes(NumericUtils.floatToSortableInt(Float.parseFloat(s)), 0, b);
           break;
         case LONG:
-          NumericUtils.longToPrefixCodedBytes(Long.parseLong(s), 0, result);
+          NumericUtils.longToPrefixCodedBytes(Long.parseLong(s), 0, b);
           break;
         case DOUBLE:
-          NumericUtils.longToPrefixCodedBytes(NumericUtils.doubleToSortableLong(Double.parseDouble(s)), 0, result);
+          NumericUtils.longToPrefixCodedBytes(NumericUtils.doubleToSortableLong(Double.parseDouble(s)), 0, b);
           break;
         case DATE:
-          NumericUtils.longToPrefixCodedBytes(dateField.parseMath(null, s).getTime(), 0, result);
+          NumericUtils.longToPrefixCodedBytes(dateField.parseMath(null, s).getTime(), 0, b);
           break;
         default:
           throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
       }
+      result.copyBytes(b.get());
     } catch (NumberFormatException nfe) {
       throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, 
                               "Invalid Number: " + val);
@@ -447,7 +448,7 @@ public class TrieField extends Primitive
   }
 
   @Override
-  public CharsRef indexedToReadable(BytesRef indexedForm, CharsRefBuilder charsRef) {
+  public CharsRef indexedToReadable(BytesRef indexedForm, CharsRef charsRef) {
     final String value;
     switch (type) {
       case INTEGER:
@@ -469,9 +470,9 @@ public class TrieField extends Primitive
         throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
     }
     charsRef.grow(value.length());
-    charsRef.setLength(value.length());
-    value.getChars(0, charsRef.length(), charsRef.chars(), 0);
-    return charsRef.get();
+    charsRef.length = value.length();
+    value.getChars(0, charsRef.length, charsRef.chars, 0);
+    return charsRef;
   }
 
   @Override
@@ -641,9 +642,9 @@ public class TrieField extends Primitive
       fields.add(field);
       
       if (sf.multiValued()) {
-        BytesRefBuilder bytes = new BytesRefBuilder();
+        BytesRef bytes = new BytesRef();
         readableToIndexed(value.toString(), bytes);
-        fields.add(new SortedSetDocValuesField(sf.getName(), bytes.get()));
+        fields.add(new SortedSetDocValuesField(sf.getName(), bytes));
       } else {
         final long bits;
         if (field.numericValue() instanceof Integer || field.numericValue() instanceof Long) {

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/QueryParsing.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/QueryParsing.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/QueryParsing.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/QueryParsing.java Thu Aug 14 09:15:35 2014
@@ -34,7 +34,6 @@ import org.apache.lucene.search.TermRang
 import org.apache.lucene.search.WildcardQuery;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.CharsRef;
-import org.apache.lucene.util.CharsRefBuilder;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.params.MapSolrParams;
 import org.apache.solr.common.params.SolrParams;
@@ -423,9 +422,9 @@ public class QueryParsing {
   static void writeFieldVal(BytesRef val, FieldType ft, Appendable out, int flags) throws IOException {
     if (ft != null) {
       try {
-        CharsRefBuilder readable = new CharsRefBuilder();
+        CharsRef readable = new CharsRef();
         ft.indexedToReadable(val, readable);
-        out.append(readable.get());
+        out.append(readable);
       } catch (Exception e) {
         out.append("EXCEPTION(val=");
         out.append(val.utf8ToString());

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/TermQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/TermQParserPlugin.java?rev=1617902&r1=1617901&r2=1617902&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/TermQParserPlugin.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/TermQParserPlugin.java Thu Aug 14 09:15:35 2014
@@ -19,6 +19,7 @@ package org.apache.solr.search;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.BytesRefBuilder;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.NamedList;
@@ -55,13 +56,13 @@ public class TermQParserPlugin extends Q
         String fname = localParams.get(QueryParsing.F);
         FieldType ft = req.getSchema().getFieldTypeNoEx(fname);
         String val = localParams.get(QueryParsing.V);
-        BytesRefBuilder term = new BytesRefBuilder();
+        BytesRef term = new BytesRef();
         if (ft != null) {
           ft.readableToIndexed(val, term);
         } else {
           term.copyChars(val);
         }
-        return new TermQuery(new Term(fname, term.get()));
+        return new TermQuery(new Term(fname, term));
       }
     };
   }

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=1617902&r1=1617901&r2=1617902&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 Thu Aug 14 09:15:35 2014
@@ -122,7 +122,7 @@ public class TermsQParserPlugin extends 
         assert splitVals.length > 0;
 
         BytesRef[] bytesRefs = new BytesRef[splitVals.length];
-        BytesRefBuilder term = new BytesRefBuilder();
+        BytesRef term = new BytesRef();
         for (int i = 0; i < splitVals.length; i++) {
           String stringVal = splitVals[i];
           //logic same as TermQParserPlugin
@@ -131,7 +131,7 @@ public class TermsQParserPlugin extends 
           } else {
             term.copyChars(stringVal);
           }
-          bytesRefs[i] = term.toBytesRef();
+          bytesRefs[i] = BytesRef.deepCopyOf(term);
         }
 
         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=1617902&r1=1617901&r2=1617902&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 Thu Aug 14 09:15:35 2014
@@ -592,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.get());
+        return new DocFreqValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes);
       }
     });
 
@@ -600,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.get());
+        return new TotalTermFreqValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes);
       }
     });
     alias("totaltermfreq","ttf");
@@ -618,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.get());
+        return new IDFValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes);
       }
     });
 
@@ -626,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.get());
+        return new TermFreqValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes);
       }
     });
 
@@ -634,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.get());
+        return new TFValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes);
       }
     });
 
@@ -794,7 +794,7 @@ public abstract class ValueSourceParser 
 
     tinfo.indexedField = tinfo.field = fp.parseArg();
     tinfo.val = fp.parseArg();
-    tinfo.indexedBytes = new BytesRefBuilder();
+    tinfo.indexedBytes = new BytesRef();
 
     FieldType ft = fp.getReq().getSchema().getFieldTypeNoEx(tinfo.field);
     if (ft == null) ft = new StrField();
@@ -870,7 +870,7 @@ public abstract class ValueSourceParser 
     String field;
     String val;
     String indexedField;
-    BytesRefBuilder indexedBytes;
+    BytesRef 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=1617902&r1=1617901&r2=1617902&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 Thu Aug 14 09:15:35 2014
@@ -22,7 +22,6 @@ 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;
@@ -268,7 +267,7 @@ public class FileFloatSource extends Val
 
     char delimiter='=';
 
-    BytesRefBuilder internalKey = new BytesRefBuilder();
+    BytesRef internalKey = new BytesRef();
 
     try {
       TermsEnum termsEnum = MultiFields.getTerms(reader, idName).iterator(null);
@@ -298,7 +297,7 @@ public class FileFloatSource extends Val
           continue;  // go to next line in file.. leave values as default.
         }
 
-        if (!termsEnum.seekExact(internalKey.get())) {
+        if (!termsEnum.seekExact(internalKey)) {
           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=1617902&r1=1617901&r2=1617902&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 Thu Aug 14 09:15:35 2014
@@ -95,9 +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 {
-             BytesRefBuilder b = new BytesRefBuilder();
+             BytesRef b = new BytesRef();
              sf.getType().readableToIndexed(field.getFirstValue().toString(), b);
-             indexedId = b.get();
+             indexedId = b;
            }
          }
        }

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=1617902&r1=1617901&r2=1617902&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 Thu Aug 14 09:15:35 2014
@@ -62,9 +62,9 @@ public class DeleteUpdateCommand extends
       IndexSchema schema = req.getSchema();
       SchemaField sf = schema.getUniqueKeyField();
       if (sf != null && id != null) {
-        BytesRefBuilder b = new BytesRefBuilder();
+        BytesRef b = new BytesRef();
         sf.getType().readableToIndexed(id, b);
-        indexedId = b.get();
+        indexedId = b;
       }
     }
     return indexedId;
@@ -75,7 +75,7 @@ public class DeleteUpdateCommand extends
       IndexSchema schema = req.getSchema();
       SchemaField sf = schema.getUniqueKeyField();
       if (sf != null) {
-        CharsRefBuilder ref = new CharsRefBuilder();
+        CharsRef ref = new CharsRef();
         sf.getType().indexedToReadable(indexedId, ref);
         id = ref.toString();
       }