lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r900166 [2/2] - in /lucene/java/branches/flex_1458: contrib/misc/src/java/org/apache/lucene/index/ contrib/misc/src/java/org/apache/lucene/misc/ contrib/queries/src/java/org/apache/lucene/search/ contrib/regex/src/java/org/apache/lucene/sea...
Date Sun, 17 Jan 2010 17:44:12 GMT
Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java Sun Jan 17 17:44:08 2010
@@ -28,7 +28,6 @@
 import org.apache.lucene.index.FieldsEnum;
 import org.apache.lucene.index.IndexFileNames;
 import org.apache.lucene.index.SegmentInfo;
-import org.apache.lucene.index.TermRef;
 import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.TermsEnum;
 import org.apache.lucene.index.codecs.Codec;
@@ -40,6 +39,7 @@
 import org.apache.lucene.util.CloseableThreadLocal;
 import org.apache.lucene.util.cache.Cache;
 import org.apache.lucene.util.cache.DoubleBarrelLRUCache;
+import org.apache.lucene.util.BytesRef;
 
 /** Handles a terms dict, but defers all details of postings
  *  reading to an instance of {@TermsDictDocsReader}. This
@@ -57,10 +57,10 @@
   private final String segment;
   private StandardTermsIndexReader indexReader;
 
-  private final TermRef.Comparator termComp;
+  private final BytesRef.Comparator termComp;
   
   public StandardTermsDictReader(StandardTermsIndexReader indexReader, Directory dir, FieldInfos fieldInfos, String segment, StandardDocsProducer docs, int readBufferSize,
-                                 TermRef.Comparator termComp)
+                                 BytesRef.Comparator termComp)
     throws IOException {
     
     this.segment = segment;
@@ -138,17 +138,19 @@
   public void close() throws IOException {
     try {
       try {
-        if(indexReader != null) {
+        if (indexReader != null) {
           indexReader.close();
         }
       } finally {
-        if(in != null) {
+        // null so if an app hangs on to us we still free most ram
+        indexReader = null;
+        if (in != null) {
           in.close();
         }
       }
     } finally {
       try {
-        if(docs != null) {
+        if (docs != null) {
           docs.close();
         }
       } finally {
@@ -221,7 +223,7 @@
     final StandardTermsIndexReader.FieldReader indexReader;
     private final static int DEFAULT_CACHE_SIZE = 1024;
     // Used for caching the least recently looked-up Terms
-    private final Cache<TermRef,CacheEntry> termsCache = new DoubleBarrelLRUCache<TermRef,CacheEntry>(DEFAULT_CACHE_SIZE);
+    private final Cache<BytesRef,CacheEntry> termsCache = new DoubleBarrelLRUCache<BytesRef,CacheEntry>(DEFAULT_CACHE_SIZE);
 
     FieldReader(StandardTermsIndexReader.FieldReader fieldIndexReader, FieldInfo fieldInfo, long numTerms, long termsStartPointer) {
       assert numTerms > 0;
@@ -232,7 +234,7 @@
     }
 
     @Override
-    public int docFreq(TermRef text) throws IOException {
+    public int docFreq(BytesRef text) throws IOException {
       ThreadResources resources = getThreadResources();
       if (resources.termsEnum.seek(text) == TermsEnum.SeekStatus.FOUND) {
         return resources.termsEnum.docFreq();
@@ -242,7 +244,7 @@
     }
 
     @Override
-    public TermRef.Comparator getTermComparator() {
+    public BytesRef.Comparator getComparator() {
       return termComp;
     }
 
@@ -254,7 +256,7 @@
     // own terms enum and use its seek...)
     /*
     @Override
-    public DocsEnum docs(Bits skipDocs, TermRef text) throws IOException {
+    public DocsEnum docs(Bits skipDocs, BytesRef text) throws IOException {
       ThreadResources resources = getThreadResources();
       if (resources.termsEnum.seek(text) == TermsEnum.SeekStatus.FOUND) {
         return resources.termsEnum.docs(skipDocs);
@@ -312,7 +314,7 @@
       }
 
       @Override
-      public TermRef.Comparator getTermComparator() {
+      public BytesRef.Comparator getComparator() {
         return termComp;
       }
 
@@ -321,10 +323,10 @@
        *  is found, SeekStatus.NOT_FOUND if a different term
        *  was found, SeekStatus.END if we hit EOF */
       @Override
-      public SeekStatus seek(TermRef term) throws IOException {
+      public SeekStatus seek(BytesRef term) throws IOException {
 
         CacheEntry entry = null;
-        TermRef entryKey = null;
+        BytesRef entryKey = null;
 
         if (docs.canCaptureState()) {
           entry = termsCache.get(term);
@@ -437,7 +439,7 @@
             if (docs.canCaptureState() && doSeek) {
               // Store in cache
               entry = docs.captureState();
-              entryKey = (TermRef) bytesReader.term.clone();
+              entryKey = (BytesRef) bytesReader.term.clone();
               entry.freq = docFreq;
               entry.termUpTo = termUpto;
               entry.filePointer = in.getFilePointer();
@@ -492,7 +494,7 @@
         // Now, scan:
         int left = (int) (pos - termUpto);
         while(left > 0) {
-          TermRef term = next();
+          BytesRef term = next();
           assert term != null;
           left--;
         }
@@ -502,7 +504,7 @@
       }
 
       @Override
-      public TermRef term() {
+      public BytesRef term() {
         return bytesReader.term;
       }
 
@@ -512,7 +514,7 @@
       }
 
       @Override
-      public TermRef next() throws IOException {
+      public BytesRef next() throws IOException {
         if (termUpto >= numTerms-1) {
           return null;
         }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictWriter.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictWriter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictWriter.java Sun Jan 17 17:44:08 2010
@@ -25,7 +25,7 @@
 import org.apache.lucene.index.FieldInfos;
 import org.apache.lucene.index.IndexFileNames;
 import org.apache.lucene.index.SegmentWriteState;
-import org.apache.lucene.index.TermRef;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.index.codecs.Codec;
 import org.apache.lucene.index.codecs.FieldsConsumer;
 import org.apache.lucene.index.codecs.DocsConsumer;
@@ -59,12 +59,12 @@
   FieldInfo currentField;
   private final StandardTermsIndexWriter indexWriter;
   private final List<TermsConsumer> fields = new ArrayList<TermsConsumer>();
-  private final TermRef.Comparator termComp;
+  private final BytesRef.Comparator termComp;
 
   // nocommit
   private String segment;
 
-  public StandardTermsDictWriter(StandardTermsIndexWriter indexWriter, SegmentWriteState state, StandardDocsConsumer consumer, TermRef.Comparator termComp) throws IOException {
+  public StandardTermsDictWriter(StandardTermsIndexWriter indexWriter, SegmentWriteState state, StandardDocsConsumer consumer, BytesRef.Comparator termComp) throws IOException {
     final String termsFileName = IndexFileNames.segmentFileName(state.segmentName, StandardCodec.TERMS_EXTENSION);
     this.indexWriter = indexWriter;
     this.termComp = termComp;
@@ -167,12 +167,12 @@
     }
     
     @Override
-    public TermRef.Comparator getTermComparator() {
+    public BytesRef.Comparator getComparator() {
       return termComp;
     }
 
     @Override
-    public DocsConsumer startTerm(TermRef text) throws IOException {
+    public DocsConsumer startTerm(BytesRef text) throws IOException {
       consumer.startTerm();
       if (Codec.DEBUG) {
         consumer.desc = fieldInfo.name + ":" + text;
@@ -182,7 +182,7 @@
     }
 
     @Override
-    public void finishTerm(TermRef text, int numDocs) throws IOException {
+    public void finishTerm(BytesRef text, int numDocs) throws IOException {
 
       // mxx
       if (Codec.DEBUG) {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsIndexReader.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsIndexReader.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsIndexReader.java Sun Jan 17 17:44:08 2010
@@ -18,7 +18,7 @@
  */
 
 import org.apache.lucene.index.FieldInfo;
-import org.apache.lucene.index.TermRef;
+import org.apache.lucene.util.BytesRef;
 
 import java.io.IOException;
 import java.util.Collection;
@@ -41,7 +41,7 @@
 
   static class TermsIndexResult {
     long position;
-    final TermRef term = new TermRef();
+    final BytesRef term = new BytesRef();
     long offset;
   };
 
@@ -52,7 +52,7 @@
      *  expects that you'll then scan the file and
      *  sequentially call isIndexTerm for each term
      *  encountered. */
-    public abstract void getIndexOffset(TermRef term, TermsIndexResult result) throws IOException;
+    public abstract void getIndexOffset(BytesRef term, TermsIndexResult result) throws IOException;
 
     public abstract void getIndexOffset(long ord, TermsIndexResult result) throws IOException;
 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsIndexWriter.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsIndexWriter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsIndexWriter.java Sun Jan 17 17:44:08 2010
@@ -19,7 +19,7 @@
 
 import org.apache.lucene.store.IndexOutput;
 import org.apache.lucene.index.FieldInfo;
-import org.apache.lucene.index.TermRef;
+import org.apache.lucene.util.BytesRef;
 import java.io.IOException;
 
 public abstract class StandardTermsIndexWriter {
@@ -27,7 +27,7 @@
   public abstract void setTermsOutput(IndexOutput out);
 
   public abstract class FieldWriter {
-    public abstract boolean checkIndexTerm(TermRef text, int docFreq) throws IOException;
+    public abstract boolean checkIndexTerm(BytesRef text, int docFreq) throws IOException;
   }
 
   public abstract FieldWriter addField(FieldInfo fieldInfo);

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/AutomatonTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/AutomatonTermsEnum.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/AutomatonTermsEnum.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/AutomatonTermsEnum.java Sun Jan 17 17:44:08 2010
@@ -22,7 +22,7 @@
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermRef;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.UnicodeUtil;
 import org.apache.lucene.util.automaton.Automaton;
 import org.apache.lucene.util.automaton.RunAutomaton;
@@ -68,19 +68,19 @@
   // true if this enum will not seek around
   private final boolean linearMode;
   // common suffix of the automaton
-  private final TermRef commonSuffixRef;
+  private final BytesRef commonSuffixRef;
   // true if the automaton accepts a finite language
   private final boolean finite;
   // array of sorted transitions for each state, indexed by state number
   private final Transition[][] allTransitions;
   // for path tracking: each bit is a numbered state
   private final BitSet visited;
-  // used for unicode conversion from TermRef byte[] to char[]
+  // used for unicode conversion from BytesRef byte[] to char[]
   private final UnicodeUtil.UTF16Result utf16 = new UnicodeUtil.UTF16Result();
-  // used for unicode conversion from char[] to TermRef byte[]
+  // used for unicode conversion from char[] to BytesRef byte[]
   private final UnicodeUtil.UTF8Result utf8 = new UnicodeUtil.UTF8Result();
   // the reference used for seeking forwards through the term dictionary
-  private final TermRef seekTermRef = new TermRef();
+  private final BytesRef seekBytesRef = new BytesRef();
   
   // this accept stati will be returned by accept() dependent on internal mode
   private final AcceptStatus NO_MATCH, YES_MATCH;
@@ -109,7 +109,7 @@
       this.finite = false;
       allTransitions = null;
       visited = null;
-      commonSuffixRef = new TermRef(getValidUTF16Suffix(SpecialOperations
+      commonSuffixRef = new BytesRef(getValidUTF16Suffix(SpecialOperations
           .getCommonSuffix(automaton)));
       NO_MATCH = AcceptStatus.NO;
       YES_MATCH = AcceptStatus.YES;
@@ -120,7 +120,7 @@
       // we will seek each time anyway (and take the unicode conversion hit).
       // its also currently expensive to calculate, because getCommonSuffix is 
       // a bit expensive.
-      commonSuffixRef = new TermRef("");
+      commonSuffixRef = new BytesRef("");
       // build a cache of sorted transitions for every state
       allTransitions = new Transition[runAutomaton.getSize()][];
       for (State state : this.automaton.getStates())
@@ -189,7 +189,7 @@
    * In smart mode, it will never do this.   
    */
   @Override
-  protected AcceptStatus accept(final TermRef term) {
+  protected AcceptStatus accept(final BytesRef term) {
     if (term.endsWith(commonSuffixRef)) {
       UnicodeUtil.UTF8toUTF16(term.bytes, term.offset, term.length, utf16);
       return runAutomaton.run(utf16.result, 0, utf16.length) ? YES_MATCH : NO_MATCH;
@@ -199,22 +199,22 @@
   }
   
   @Override
-  protected TermRef nextSeekTerm(final TermRef term) throws IOException {
+  protected BytesRef nextSeekTerm(final BytesRef term) throws IOException {
     if (term == null) {
       // return the first seek term
       if (linearMode) {
-        seekTermRef.copy("");
+        seekBytesRef.copy("");
       } else {
         utf16.copyText("");
         if (!nextString())
           return null;
         UnicodeUtil.nextValidUTF16String(utf16);
         UnicodeUtil.UTF16toUTF8(utf16.result, 0, utf16.length, utf8);
-        seekTermRef.bytes = utf8.result;
-        seekTermRef.offset = 0;
-        seekTermRef.length = utf8.length;
+        seekBytesRef.bytes = utf8.result;
+        seekBytesRef.offset = 0;
+        seekBytesRef.length = utf8.length;
       }
-      return seekTermRef;
+      return seekBytesRef;
     } else if (!linearMode) {
       // seek to the next possible string
       UnicodeUtil.UTF8toUTF16(term.bytes, term.offset, term.length, utf16);
@@ -222,10 +222,10 @@
         // reposition
         UnicodeUtil.nextValidUTF16String(utf16);
         UnicodeUtil.UTF16toUTF8(utf16.result, 0, utf16.length, utf8);
-        seekTermRef.bytes = utf8.result;
-        seekTermRef.offset = 0;
-        seekTermRef.length = utf8.length;
-        return seekTermRef;
+        seekBytesRef.bytes = utf8.result;
+        seekBytesRef.offset = 0;
+        seekBytesRef.length = utf8.length;
+        return seekBytesRef;
       }
     }
     // no more possible strings can match

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/EmptyTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/EmptyTermsEnum.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/EmptyTermsEnum.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/EmptyTermsEnum.java Sun Jan 17 17:44:08 2010
@@ -17,7 +17,7 @@
  * limitations under the License.
  */
 
-import org.apache.lucene.index.TermRef;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.index.TermsEnum;
 
 /**
@@ -38,13 +38,13 @@
 
   @Override
   /** Always returns {@link AcceptStatus#END}. */
-  protected AcceptStatus accept(TermRef term) {
+  protected AcceptStatus accept(BytesRef term) {
     return AcceptStatus.END;
   }
 
   /** Always returns {@link SeekStatus#END}. */
   @Override
-  public SeekStatus seek(TermRef term) {
+  public SeekStatus seek(BytesRef term) {
     return SeekStatus.END;
   }
 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldCache.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldCache.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldCache.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldCache.java Sun Jan 17 17:44:08 2010
@@ -20,7 +20,7 @@
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.util.NumericUtils;
 import org.apache.lucene.util.RamUsageEstimator;
-import org.apache.lucene.index.TermRef;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.document.NumericField; // for javadocs
 import org.apache.lucene.analysis.NumericTokenStream; // for javadocs
 
@@ -101,7 +101,7 @@
    */
   public interface ByteParser extends Parser {
     /** Return a single Byte representation of this field's value. */
-    public byte parseByte(TermRef term);
+    public byte parseByte(BytesRef term);
   }
 
   /** Interface to parse shorts from document fields.
@@ -109,7 +109,7 @@
    */
   public interface ShortParser extends Parser {
     /** Return a short representation of this field's value. */
-    public short parseShort(TermRef term);
+    public short parseShort(BytesRef term);
   }
 
   /** Interface to parse ints from document fields.
@@ -117,7 +117,7 @@
    */
   public interface IntParser extends Parser {
     /** Return an integer representation of this field's value. */
-    public int parseInt(TermRef term);
+    public int parseInt(BytesRef term);
   }
 
   /** Interface to parse floats from document fields.
@@ -125,7 +125,7 @@
    */
   public interface FloatParser extends Parser {
     /** Return an float representation of this field's value. */
-    public float parseFloat(TermRef term);
+    public float parseFloat(BytesRef term);
   }
 
   /** Interface to parse long from document fields.
@@ -133,7 +133,7 @@
    */
   public interface LongParser extends Parser {
     /** Return an long representation of this field's value. */
-    public long parseLong(TermRef term);
+    public long parseLong(BytesRef term);
   }
 
   /** Interface to parse doubles from document fields.
@@ -141,7 +141,7 @@
    */
   public interface DoubleParser extends Parser {
     /** Return an long representation of this field's value. */
-    public double parseDouble(TermRef term);
+    public double parseDouble(BytesRef term);
   }
 
   /** Expert: The cache used internally by sorting and range query classes. */
@@ -149,7 +149,7 @@
 
   /** The default parser for byte values, which are encoded by {@link Byte#toString(byte)} */
   public static final ByteParser DEFAULT_BYTE_PARSER = new ByteParser() {
-    public byte parseByte(TermRef term) {
+    public byte parseByte(BytesRef term) {
       final long num = FieldCacheImpl.parseLong(term);
       if (num >= Byte.MIN_VALUE && num <= Byte.MAX_VALUE) {
         return (byte) num;
@@ -168,7 +168,7 @@
 
   /** The default parser for short values, which are encoded by {@link Short#toString(short)} */
   public static final ShortParser DEFAULT_SHORT_PARSER = new ShortParser() {
-    public short parseShort(TermRef term) {
+    public short parseShort(BytesRef term) {
       final long num = FieldCacheImpl.parseLong(term);
       if (num >= Short.MIN_VALUE && num <= Short.MAX_VALUE) {
         return (short) num;
@@ -187,7 +187,7 @@
 
   /** The default parser for int values, which are encoded by {@link Integer#toString(int)} */
   public static final IntParser DEFAULT_INT_PARSER = new IntParser() {
-    public int parseInt(TermRef term) {
+    public int parseInt(BytesRef term) {
       final long num = FieldCacheImpl.parseLong(term);
       if (num >= Integer.MIN_VALUE && num <= Integer.MAX_VALUE) {
         return (int) num;
@@ -206,7 +206,7 @@
 
   /** The default parser for float values, which are encoded by {@link Float#toString(float)} */
   public static final FloatParser DEFAULT_FLOAT_PARSER = new FloatParser() {
-    public float parseFloat(TermRef term) {
+    public float parseFloat(BytesRef term) {
       // TODO: would be far better to directly parse
       // the UTF-8 bytes into float, but that's tricky?
       return Float.parseFloat(term.toString());
@@ -222,7 +222,7 @@
 
   /** The default parser for long values, which are encoded by {@link Long#toString(long)} */
   public static final LongParser DEFAULT_LONG_PARSER = new LongParser() {
-    public long parseLong(TermRef term) {
+    public long parseLong(BytesRef term) {
       return FieldCacheImpl.parseLong(term);
     }
     protected Object readResolve() {
@@ -236,7 +236,7 @@
 
   /** The default parser for double values, which are encoded by {@link Double#toString(double)} */
   public static final DoubleParser DEFAULT_DOUBLE_PARSER = new DoubleParser() {
-    public double parseDouble(TermRef term) {
+    public double parseDouble(BytesRef term) {
       // TODO: would be far better to directly parse
       // the UTF-8 bytes into float, but that's tricky?
       return Double.parseDouble(term.toString());
@@ -255,7 +255,7 @@
    * via {@link NumericField}/{@link NumericTokenStream}.
    */
   public static final IntParser NUMERIC_UTILS_INT_PARSER=new IntParser(){
-    public int parseInt(TermRef val) {
+    public int parseInt(BytesRef val) {
       final int shift = val.bytes[val.offset]-NumericUtils.SHIFT_START_INT;
       if (shift>0 && shift<=31)
         throw new FieldCacheImpl.StopFillCacheException();
@@ -275,7 +275,7 @@
    * via {@link NumericField}/{@link NumericTokenStream}.
    */
   public static final FloatParser NUMERIC_UTILS_FLOAT_PARSER=new FloatParser(){
-    public float parseFloat(TermRef term) {
+    public float parseFloat(BytesRef term) {
       final int shift = term.bytes[term.offset]-NumericUtils.SHIFT_START_INT;
       if (shift>0 && shift<=31)
         throw new FieldCacheImpl.StopFillCacheException();
@@ -295,7 +295,7 @@
    * via {@link NumericField}/{@link NumericTokenStream}.
    */
   public static final LongParser NUMERIC_UTILS_LONG_PARSER = new LongParser(){
-    public long parseLong(TermRef term) {
+    public long parseLong(BytesRef term) {
       final int shift = term.bytes[term.offset]-NumericUtils.SHIFT_START_LONG;
       if (shift>0 && shift<=63)
         throw new FieldCacheImpl.StopFillCacheException();
@@ -315,7 +315,7 @@
    * via {@link NumericField}/{@link NumericTokenStream}.
    */
   public static final DoubleParser NUMERIC_UTILS_DOUBLE_PARSER = new DoubleParser(){
-    public double parseDouble(TermRef term) {
+    public double parseDouble(BytesRef term) {
       final int shift = term.bytes[term.offset]-NumericUtils.SHIFT_START_LONG;
       if (shift>0 && shift<=63)
         throw new FieldCacheImpl.StopFillCacheException();

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldCacheImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldCacheImpl.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldCacheImpl.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldCacheImpl.java Sun Jan 17 17:44:08 2010
@@ -29,9 +29,7 @@
 import org.apache.lucene.index.DocsEnum;
 import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.TermsEnum;
-import org.apache.lucene.index.TermEnum;
-import org.apache.lucene.index.TermDocs;          // deprecated
-import org.apache.lucene.index.TermRef;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.StringHelper;
 import org.apache.lucene.util.FieldCacheSanityChecker;
@@ -288,7 +286,7 @@
         final Bits delDocs = reader.getDeletedDocs();
         try {
           while(true) {
-            final TermRef term = termsEnum.next();
+            final BytesRef term = termsEnum.next();
             if (term == null) {
               break;
             }
@@ -341,7 +339,7 @@
         final Bits delDocs = reader.getDeletedDocs();
         try {
           while(true) {
-            final TermRef term = termsEnum.next();
+            final BytesRef term = termsEnum.next();
             if (term == null) {
               break;
             }
@@ -399,7 +397,7 @@
         final Bits delDocs = reader.getDeletedDocs();
         try {
           while(true) {
-            final TermRef term = termsEnum.next();
+            final BytesRef term = termsEnum.next();
             if (term == null) {
               break;
             }
@@ -470,7 +468,7 @@
         final Bits delDocs = reader.getDeletedDocs();
         try {
           while(true) {
-            final TermRef term = termsEnum.next();
+            final BytesRef term = termsEnum.next();
             if (term == null) {
               break;
             }
@@ -536,7 +534,7 @@
         final Bits delDocs = reader.getDeletedDocs();
         try {
           while(true) {
-            final TermRef term = termsEnum.next();
+            final BytesRef term = termsEnum.next();
             if (term == null) {
               break;
             }
@@ -604,7 +602,7 @@
         final Bits delDocs = reader.getDeletedDocs();
         try {
           while(true) {
-            final TermRef term = termsEnum.next();
+            final BytesRef term = termsEnum.next();
             if (term == null) {
               break;
             }
@@ -654,7 +652,7 @@
         final TermsEnum termsEnum = terms.iterator();
         final Bits delDocs = reader.getDeletedDocs();
         while(true) {
-          final TermRef term = termsEnum.next();
+          final BytesRef term = termsEnum.next();
           if (term == null) {
             break;
           }
@@ -705,7 +703,7 @@
         final TermsEnum termsEnum = terms.iterator();
         final Bits delDocs = reader.getDeletedDocs();
         while(true) {
-          final TermRef term = termsEnum.next();
+          final BytesRef term = termsEnum.next();
           if (term == null) {
             break;
           }
@@ -754,7 +752,7 @@
   
   // Directly parses a numeric value from UTF8 bytes
   // nocommit -- whitespace?  +e syntax?
-  final static long parseLong(TermRef term) {
+  final static long parseLong(BytesRef term) {
     int upto = term.offset;
     final int negMul;
     if (term.bytes[upto] == '-') {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FilteredTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FilteredTermsEnum.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FilteredTermsEnum.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FilteredTermsEnum.java Sun Jan 17 17:44:08 2010
@@ -20,7 +20,7 @@
 import java.io.IOException;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Terms;
-import org.apache.lucene.index.TermRef;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.index.TermsEnum;
 import org.apache.lucene.index.DocsEnum;
 import org.apache.lucene.util.AttributeSource;
@@ -39,23 +39,23 @@
  */
 public abstract class FilteredTermsEnum extends TermsEnum {
 
-  private TermRef initialSeekTerm = null;
+  private BytesRef initialSeekTerm = null;
   private boolean doSeek = true;        
-  private TermRef actualTerm = null;
+  private BytesRef actualTerm = null;
 
   private final TermsEnum tenum;
 
   /** Return value, if term should be accepted or the iteration should
    * {@code END}. The {@code *_SEEK} values denote, that after handling the current term
    * the enum should call {@link nextSeekTerm()} and step forward.
-   * @see #accept(TermRef)
+   * @see #accept(BytesRef)
    */
   protected static enum AcceptStatus {YES, YES_AND_SEEK, NO, NO_AND_SEEK, END};
   
   /** Return if term is accepted, not accepted or the iteration should ended
    * (and possibly seek).
    */
-  protected abstract AcceptStatus accept(TermRef term) throws IOException;
+  protected abstract AcceptStatus accept(BytesRef term) throws IOException;
 
   /**
    * Creates a filtered {@link TermsEnum} for the given field name and reader.
@@ -75,7 +75,7 @@
   }
 
   /**
-   * Use this method to set the initial {@link TermRef}
+   * Use this method to set the initial {@link BytesRef}
    * to seek before iterating. This is a convenience method for
    * subclasses that do not override {@link #nextSeekTerm}.
    * If the initial seek term is {@code null} (default),
@@ -83,7 +83,7 @@
    * <P>You can only use this method, if you keep the default
    * implementation of {@link #nextSeekTerm}.
    */
-  protected final void setInitialSeekTerm(TermRef term) throws IOException {
+  protected final void setInitialSeekTerm(BytesRef term) throws IOException {
     this.initialSeekTerm = term;
   }
   
@@ -102,8 +102,8 @@
    * than the last enumerated term, else the behaviour of this enum
    * violates the contract for TermsEnums.
    */
-  protected TermRef nextSeekTerm(final TermRef currentTerm) throws IOException {
-    final TermRef t = initialSeekTerm;
+  protected BytesRef nextSeekTerm(final BytesRef currentTerm) throws IOException {
+    final BytesRef t = initialSeekTerm;
     initialSeekTerm = null;
     return t;
   }
@@ -121,13 +121,13 @@
   }
   
   @Override
-  public TermRef term() throws IOException {
+  public BytesRef term() throws IOException {
     return (tenum == null) ? null : tenum.term();
   }
 
   @Override
-  public TermRef.Comparator getTermComparator() throws IOException {
-    return (tenum == null) ? null : tenum.getTermComparator();
+  public BytesRef.Comparator getComparator() throws IOException {
+    return (tenum == null) ? null : tenum.getComparator();
   }
     
   @Override
@@ -139,7 +139,7 @@
    * @throws UnsupportedOperationException
    */
   @Override
-  public SeekStatus seek(TermRef term) throws IOException {
+  public SeekStatus seek(BytesRef term) throws IOException {
     throw new UnsupportedOperationException(getClass().getName()+" does not support seeking");
   }
 
@@ -162,14 +162,14 @@
   }
     
   @Override
-  public TermRef next() throws IOException {
+  public BytesRef next() throws IOException {
     if (tenum == null)
       return null;
     for (;;) {
       // Seek or forward the iterator
       if (doSeek) {
         doSeek = false;
-        final TermRef t = nextSeekTerm(actualTerm);
+        final BytesRef t = nextSeekTerm(actualTerm);
         if (t == null || tenum.seek(t) == SeekStatus.END) {
           // no more terms to seek to or enum exhausted
           return null;

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FuzzyQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FuzzyQuery.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FuzzyQuery.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FuzzyQuery.java Sun Jan 17 17:44:08 2010
@@ -19,7 +19,6 @@
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermRef;
 import org.apache.lucene.index.TermsEnum;
 import org.apache.lucene.util.ToStringUtils;
 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FuzzyTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FuzzyTermsEnum.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FuzzyTermsEnum.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FuzzyTermsEnum.java Sun Jan 17 17:44:08 2010
@@ -19,7 +19,7 @@
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermRef;
+import org.apache.lucene.util.BytesRef;
 
 import java.io.IOException;
 
@@ -121,22 +121,22 @@
 
     this.text = searchTerm.text().substring(realPrefixLength);
     this.prefix = searchTerm.text().substring(0, realPrefixLength);
-    prefixTermRef = new TermRef(prefix);
+    prefixBytesRef = new BytesRef(prefix);
     initializeMaxDistances();
     this.d = initDistanceArray();
 
-    setInitialSeekTerm(prefixTermRef);
+    setInitialSeekTerm(prefixBytesRef);
   }
 
-  private final TermRef prefixTermRef;
+  private final BytesRef prefixBytesRef;
 
   /**
    * The termCompare method in FuzzyTermEnum uses Levenshtein distance to 
    * calculate the distance between the given term and the comparing term. 
    */
   @Override
-  protected final AcceptStatus accept(TermRef term) {
-    if (term.startsWith(prefixTermRef)) {
+  protected final AcceptStatus accept(BytesRef term) {
+    if (term.startsWith(prefixBytesRef)) {
       // TODO: costly that we create intermediate String:
       final String target = term.toString().substring(prefix.length());
       final float similarity = similarity(target);

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java Sun Jan 17 17:44:08 2010
@@ -24,7 +24,7 @@
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.DocsEnum;
 import org.apache.lucene.index.PositionsEnum;
-import org.apache.lucene.index.TermRef;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.ToStringUtils;
 import org.apache.lucene.util.PriorityQueue;
 import org.apache.lucene.util.Bits;
@@ -180,7 +180,7 @@
         } else {
           docsEnum = reader.termDocsEnum(reader.getDeletedDocs(),
                                          terms[0].field(),
-                                         new TermRef(terms[0].text()));
+                                         new BytesRef(terms[0].text()));
         }
 
         if (docsEnum == null) {
@@ -461,7 +461,7 @@
     for (int i = 0; i < terms.length; i++) {
       DocsEnum docs = indexReader.termDocsEnum(delDocs,
                                                terms[i].field(),
-                                               new TermRef(terms[i].text()));
+                                               new BytesRef(terms[i].text()));
       if (docs != null) {
         docsEnums.add(docs);
       }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiTermQuery.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiTermQuery.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiTermQuery.java Sun Jan 17 17:44:08 2010
@@ -20,12 +20,11 @@
 import java.io.IOException;
 import java.io.Serializable;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.PriorityQueue;
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermRef;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.index.TermsEnum;
 import org.apache.lucene.queryParser.QueryParser; // for javadoc
 import org.apache.lucene.util.Attribute;
@@ -183,7 +182,7 @@
           throw new NullPointerException("If you implement getTermsEnum(), you must specify a non-null field in the constructor of MultiTermQuery.");
         collector.boostAtt = boostAtt;
         int count = 0;
-        TermRef term;
+        BytesRef term;
         final Term placeholderTerm = new Term(query.field);
         while ((term = termsEnum.next()) != null) {
           if (collector.collect(placeholderTerm.createTerm(term.toString()), boostAtt.getBoost())) {
@@ -464,7 +463,7 @@
         // should not be costly, because 1) the
         // query/filter will load the TermInfo when it
         // runs, and 2) the terms dict has a cache:
-        // @deprecated: in 4.0 use TermRef for collectTerms()
+        // @deprecated: in 4.0 use BytesRef for collectTerms()
         docVisitCount += reader.docFreq(t);
         return true;
       }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java Sun Jan 17 17:44:08 2010
@@ -23,7 +23,6 @@
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermDocs;
 import org.apache.lucene.index.TermEnum;
-import org.apache.lucene.index.TermRef;
 import org.apache.lucene.index.TermsEnum;
 import org.apache.lucene.index.DocsEnum;
 import org.apache.lucene.util.OpenBitSet;

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/NumericRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/NumericRangeQuery.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/NumericRangeQuery.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/NumericRangeQuery.java Sun Jan 17 17:44:08 2010
@@ -24,10 +24,8 @@
 import org.apache.lucene.document.NumericField; // for javadocs
 import org.apache.lucene.util.NumericUtils;
 import org.apache.lucene.util.ToStringUtils;
-import org.apache.lucene.util.StringHelper;
 import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermRef;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.index.TermsEnum;
 
 /**
@@ -381,10 +379,10 @@
    */
   private final class NumericRangeTermsEnum extends FilteredTermsEnum {
 
-    private final TermRef currentLowerBound = new TermRef(), currentUpperBound = new TermRef();
+    private final BytesRef currentLowerBound = new BytesRef(), currentUpperBound = new BytesRef();
 
     private final LinkedList<String> rangeBounds = new LinkedList<String>();
-    private final TermRef.Comparator termComp;
+    private final BytesRef.Comparator termComp;
 
     NumericRangeTermsEnum(final IndexReader reader) throws IOException {
       super(reader, getField());
@@ -464,11 +462,11 @@
           throw new IllegalArgumentException("valSize must be 32 or 64");
       }
 
-      termComp = getTermComparator();
+      termComp = getComparator();
     }
     
     @Override
-    protected final TermRef nextSeekTerm(TermRef term) throws IOException {
+    protected final BytesRef nextSeekTerm(BytesRef term) throws IOException {
       if (rangeBounds.size() >= 2) {
         assert rangeBounds.size() % 2 == 0;
 
@@ -486,7 +484,7 @@
     }
     
     @Override
-    protected AcceptStatus accept(TermRef term) {
+    protected AcceptStatus accept(BytesRef term) {
       return (currentUpperBound != null && termComp.compare(term, currentUpperBound) <= 0) ?
         AcceptStatus.YES : AcceptStatus.NO_AND_SEEK;
     }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/PhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/PhraseQuery.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/PhraseQuery.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/PhraseQuery.java Sun Jan 17 17:44:08 2010
@@ -22,7 +22,7 @@
 import java.util.ArrayList;
 
 import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermRef;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.index.DocsEnum;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.Explanation.IDFExplanation;
@@ -158,7 +158,7 @@
         final Term t = terms.get(i);
         DocsEnum docsEnum = reader.termDocsEnum(delDocs,
                                                 t.field(),
-                                                new TermRef(t.text()));
+                                                new BytesRef(t.text()));
         if (docsEnum == null) {
           return null;
         }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/PrefixTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/PrefixTermsEnum.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/PrefixTermsEnum.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/PrefixTermsEnum.java Sun Jan 17 17:44:08 2010
@@ -21,7 +21,7 @@
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermRef;
+import org.apache.lucene.util.BytesRef;
 
 /**
  * Subclass of FilteredTermEnum for enumerating all terms that match the
@@ -32,15 +32,15 @@
  */
 public class PrefixTermsEnum extends FilteredTermsEnum {
 
-  private final TermRef prefixRef;
+  private final BytesRef prefixRef;
 
   public PrefixTermsEnum(IndexReader reader, Term prefix) throws IOException {
     super(reader, prefix.field());
-    setInitialSeekTerm(prefixRef = new TermRef(prefix.text()));
+    setInitialSeekTerm(prefixRef = new BytesRef(prefix.text()));
   }
 
   @Override
-  protected AcceptStatus accept(TermRef term) {
+  protected AcceptStatus accept(BytesRef term) {
     if (term.startsWith(prefixRef)) {
       return AcceptStatus.YES;
     } else {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/SingleTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/SingleTermsEnum.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/SingleTermsEnum.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/SingleTermsEnum.java Sun Jan 17 17:44:08 2010
@@ -21,8 +21,7 @@
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermRef;
-import org.apache.lucene.index.Terms;
+import org.apache.lucene.util.BytesRef;
 
 /**
  * Subclass of FilteredTermsEnum for enumerating a single term.
@@ -32,7 +31,7 @@
  * {@link MultiTermQuery#rewriteMethod}.
  */
 public final class SingleTermsEnum extends FilteredTermsEnum {
-  private final TermRef singleRef;
+  private final BytesRef singleRef;
   
   /**
    * Creates a new <code>SingleTermsEnum</code>.
@@ -42,12 +41,12 @@
    */
   public SingleTermsEnum(IndexReader reader, Term singleTerm) throws IOException {
     super(reader, singleTerm.field());
-    singleRef = new TermRef(singleTerm.text());
+    singleRef = new BytesRef(singleTerm.text());
     setInitialSeekTerm(singleRef);
   }
 
   @Override
-  protected AcceptStatus accept(TermRef term) {
+  protected AcceptStatus accept(BytesRef term) {
     return term.equals(singleRef) ? AcceptStatus.YES : AcceptStatus.END;
   }
   

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/TermQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/TermQuery.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/TermQuery.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/TermQuery.java Sun Jan 17 17:44:08 2010
@@ -22,7 +22,7 @@
 
 import org.apache.lucene.index.DocsEnum;
 import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermRef;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.Explanation.IDFExplanation;
 import org.apache.lucene.util.ToStringUtils;
@@ -72,7 +72,7 @@
 
     @Override
     public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
-      DocsEnum docs = reader.termDocsEnum(reader.getDeletedDocs(), term.field(), new TermRef(term.text()));
+      DocsEnum docs = reader.termDocsEnum(reader.getDeletedDocs(), term.field(), new BytesRef(term.text()));
       if (docs == null) {
         return null;
       }
@@ -115,7 +115,7 @@
 
       Explanation tfExplanation = new Explanation();
       int tf = 0;
-      DocsEnum docs = reader.termDocsEnum(reader.getDeletedDocs(), term.field(), new TermRef(term.text()));
+      DocsEnum docs = reader.termDocsEnum(reader.getDeletedDocs(), term.field(), new BytesRef(term.text()));
       if (docs != null) {
           int newDoc = docs.advance(doc);
           if (newDoc == doc) {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/TermRangeTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/TermRangeTermsEnum.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/TermRangeTermsEnum.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/TermRangeTermsEnum.java Sun Jan 17 17:44:08 2010
@@ -21,8 +21,7 @@
 import java.text.Collator;
 
 import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.TermRef;
-import org.apache.lucene.util.StringHelper;
+import org.apache.lucene.util.BytesRef;
 
 /**
  * Subclass of FilteredTermEnum for enumerating all terms that match the
@@ -38,9 +37,9 @@
   private String lowerTermText;
   private boolean includeLower;
   private boolean includeUpper;
-  final private TermRef lowerTermRef;
-  final private TermRef upperTermRef;
-  private final TermRef.Comparator termComp;
+  final private BytesRef lowerBytesRef;
+  final private BytesRef upperBytesRef;
+  private final BytesRef.Comparator termComp;
 
   /**
    * Enumerates all terms greater/equal than <code>lowerTerm</code>
@@ -84,28 +83,28 @@
       this.lowerTermText = "";
       this.includeLower = true;
     }
-    lowerTermRef = new TermRef(this.lowerTermText);
+    lowerBytesRef = new BytesRef(this.lowerTermText);
 
     if (this.upperTermText == null) {
       this.includeUpper = true;
-      upperTermRef = null;
+      upperBytesRef = null;
     } else {
-      upperTermRef = new TermRef(upperTermText);
+      upperBytesRef = new BytesRef(upperTermText);
     }
 
-    TermRef startTermRef = (collator == null) ? lowerTermRef : new TermRef("");
-    setInitialSeekTerm(startTermRef);
-    termComp = getTermComparator();
+    BytesRef startBytesRef = (collator == null) ? lowerBytesRef : new BytesRef("");
+    setInitialSeekTerm(startBytesRef);
+    termComp = getComparator();
   }
 
   @Override
-  protected AcceptStatus accept(TermRef term) {
+  protected AcceptStatus accept(BytesRef term) {
     if (collator == null) {
-      if (!this.includeLower && term.equals(lowerTermRef))
+      if (!this.includeLower && term.equals(lowerBytesRef))
         return AcceptStatus.NO;
       // Use this field's default sort ordering
-      if (upperTermRef != null) {
-        final int cmp = termComp.compare(upperTermRef, term);
+      if (upperBytesRef != null) {
+        final int cmp = termComp.compare(upperBytesRef, term);
         /*
          * if beyond the upper term, or is exclusive and this is equal to
          * the upper term, break out

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/SpanTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/SpanTermQuery.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/SpanTermQuery.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/SpanTermQuery.java Sun Jan 17 17:44:08 2010
@@ -19,7 +19,7 @@
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermRef;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.ToStringUtils;
 
 import java.io.IOException;
@@ -83,7 +83,7 @@
   public Spans getSpans(final IndexReader reader) throws IOException {
     return new TermSpans(reader.termDocsEnum(reader.getDeletedDocs(),
                                              term.field(),
-                                             new TermRef(term.text())), term);
+                                             new BytesRef(term.text())), term);
   }
 
 }

Added: lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/BytesRef.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/BytesRef.java?rev=900166&view=auto
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/BytesRef.java (added)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/BytesRef.java Sun Jan 17 17:44:08 2010
@@ -0,0 +1,250 @@
+package org.apache.lucene.util;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.UnsupportedEncodingException;
+
+/** Represents byte[], as a slice (offset + length) into an
+ *  existing byte[]. */
+public final class BytesRef {
+
+  public byte[] bytes;
+  public int offset;
+  public int length;
+
+  public BytesRef() {
+  }
+
+  /**
+   * @param text Initialize the byte[] from the UTF8 bytes
+   * for the provided Sring.  This must be well-formed
+   * unicode text, with no unpaired surrogates or U+FFFF.
+   */
+  public BytesRef(String text) {
+    copy(text);
+  }
+
+  public BytesRef(BytesRef other) {
+    copy(other);
+  }
+
+  // nocommit: we could do this w/ UnicodeUtil w/o requiring
+  // allocation of new bytes[]?
+  /**
+   * Copies the UTF8 bytes for this string.
+   * 
+   * @param text Must be well-formed unicode text, with no
+   * unpaired surrogates or U+FFFF.
+   */
+  public void copy(String text) {
+    // nocommit -- assert text has no unpaired surrogates??
+    try {
+      bytes = text.getBytes("UTF-8");
+    } catch (UnsupportedEncodingException uee) {
+      // should not happen:
+      throw new RuntimeException("unable to encode to UTF-8");
+    }
+    offset = 0;
+    length = bytes.length;
+  }
+
+  public boolean bytesEquals(BytesRef other) {
+    if (length == other.length) {
+      int upto = offset;
+      int otherUpto = other.offset;
+      final byte[] otherBytes = other.bytes;
+      for(int i=0;i<length;i++) {
+        if (bytes[upto++] != otherBytes[otherUpto++]) {
+          return false;
+        }
+      }
+      return true;
+    } else {
+      return false;
+    }
+  }
+
+  @Override
+  public Object clone() {
+    BytesRef other = new BytesRef();
+    other.bytes = new byte[length];
+    System.arraycopy(bytes, offset, other.bytes, 0, length);
+    other.length = length;
+    return other;
+  }
+
+  public boolean startsWith(BytesRef other, int pos) {
+    // nocommit: maybe this one shouldn't be public...
+    if (pos < 0 || length - pos < other.length) {
+      return false;
+    }
+    int i = offset + pos;
+    int j = other.offset;
+    final int k = other.offset + other.length;
+    
+    while (j < k)
+      if (bytes[i++] != other.bytes[j++])
+        return false;
+    
+    return true;
+  }
+  
+  public boolean startsWith(BytesRef other) {
+    return startsWith(other, 0);
+  }
+
+  public boolean endsWith(BytesRef other) {
+    return startsWith(other, length - other.length);   
+  }
+  
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + hash(bytes);
+    return result;
+  }
+  
+  private int hash(byte a[]) {
+    if (a == null) {
+      return 0;
+    }
+    int result = 1;
+    int upTo = offset;
+    for(int i = 0; i < length; i++) {
+      result = 31 * result + bytes[upTo++];
+    }
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    return this.bytesEquals((BytesRef) other);
+  }
+
+  @Override
+  public String toString() {
+    try {
+      return new String(bytes, offset, length, "UTF-8");
+    } catch (UnsupportedEncodingException uee) {
+      // should not happen
+      throw new RuntimeException(uee);
+    }
+  }
+
+  public String toBytesString() {
+    StringBuilder sb = new StringBuilder();
+    sb.append('[');
+    final int end = offset + length;
+    for(int i=offset;i<end;i++) {
+      if (i > offset) {
+        sb.append(' ');
+      }
+      sb.append(Integer.toHexString(bytes[i]&0xff));
+    }
+    sb.append(']');
+    return sb.toString();
+  }
+
+  private final String asUnicodeChar(char c) {
+    return "U+" + Integer.toHexString(c);
+  }
+
+  // for debugging only -- this is slow
+  public String toUnicodeString() {
+    StringBuilder sb = new StringBuilder();
+    sb.append('[');
+    final String s = toString();
+    for(int i=0;i<s.length();i++) {
+      if (i > 0) {
+        sb.append(' ');
+      }
+      sb.append(asUnicodeChar(s.charAt(i)));
+    }
+    sb.append(']');
+    return sb.toString();
+  }
+
+  public void copy(BytesRef other) {
+    if (bytes == null) {
+      bytes = new byte[other.length];
+    } else {
+      bytes = ArrayUtil.grow(bytes, other.length);
+    }
+    System.arraycopy(other.bytes, other.offset, bytes, 0, other.length);
+    length = other.length;
+    offset = 0;
+  }
+
+  public void grow(int newLength) {
+    bytes = ArrayUtil.grow(bytes, newLength);
+  }
+
+  public abstract static class Comparator {
+    abstract public int compare(BytesRef a, BytesRef b);
+  }
+
+  private final static Comparator utf8SortedAsUTF16SortOrder = new UTF8SortedAsUTF16Comparator();
+
+  public static Comparator getUTF8SortedAsUTF16Comparator() {
+    return utf8SortedAsUTF16SortOrder;
+  }
+
+  public static class UTF8SortedAsUTF16Comparator extends Comparator {
+    public int compare(BytesRef a, BytesRef b) {
+
+      final byte[] aBytes = a.bytes;
+      int aUpto = a.offset;
+      final byte[] bBytes = b.bytes;
+      int bUpto = b.offset;
+      
+      final int aStop;
+      if (a.length < b.length) {
+        aStop = aUpto + a.length;
+      } else {
+        aStop = aUpto + b.length;
+      }
+
+      while(aUpto < aStop) {
+        int aByte = aBytes[aUpto++] & 0xff;
+        int bByte = bBytes[bUpto++] & 0xff;
+
+        if (aByte != bByte) {
+
+          // See http://icu-project.org/docs/papers/utf16_code_point_order.html#utf-8-in-utf-16-order
+
+          // We know the terms are not equal, but, we may
+          // have to carefully fixup the bytes at the
+          // difference to match UTF16's sort order:
+          if (aByte >= 0xee && bByte >= 0xee) {
+            if ((aByte & 0xfe) == 0xee) {
+              aByte += 0x10;
+            }
+            if ((bByte&0xfe) == 0xee) {
+              bByte += 0x10;
+            }
+          }
+          return aByte - bByte;
+        }
+      }
+
+      // One is a prefix of the other, or, they are equal:
+      return a.length - b.length;
+    }
+  }
+}

Propchange: lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/BytesRef.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/NumericUtils.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/NumericUtils.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/NumericUtils.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/NumericUtils.java Sun Jan 17 17:44:08 2010
@@ -21,7 +21,6 @@
 import org.apache.lucene.document.NumericField; // for javadocs
 import org.apache.lucene.search.NumericRangeQuery; // for javadocs
 import org.apache.lucene.search.NumericRangeFilter; // for javadocs
-import org.apache.lucene.index.TermRef;
 
 /**
  * This is a helper class to generate prefix-encoded representations for numerical values
@@ -220,7 +219,7 @@
     return (sortableBits << shift) ^ 0x8000000000000000L;
   }
 
-  public static long prefixCodedToLong(final TermRef term) {
+  public static long prefixCodedToLong(final BytesRef term) {
     final int shift = term.bytes[term.offset]-SHIFT_START_LONG;
     if (shift>63 || shift<0)
       throw new NumberFormatException("Invalid shift value in prefixCoded string (is encoded value really an INT?)");
@@ -267,7 +266,7 @@
     return (sortableBits << shift) ^ 0x80000000;
   }
 
-  public static int prefixCodedToInt(final TermRef term) {
+  public static int prefixCodedToInt(final BytesRef term) {
     final int shift = term.bytes[term.offset]-SHIFT_START_INT;
     if (shift>31 || shift<0)
       throw new NumberFormatException("Invalid shift value in prefixCoded string (is encoded value really an INT?)");

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestExternalCodecs.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestExternalCodecs.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestExternalCodecs.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestExternalCodecs.java Sun Jan 17 17:44:08 2010
@@ -37,9 +37,9 @@
   // For fun, test that we can override how terms are
   // sorted, and basic things still work -- this comparator
   // sorts in reversed unicode code point order:
-  private static final TermRef.Comparator reverseUnicodeComparator = new TermRef.Comparator() {
+  private static final BytesRef.Comparator reverseUnicodeComparator = new BytesRef.Comparator() {
       @Override
-      public int compare(TermRef t1, TermRef t2) {
+      public int compare(BytesRef t1, BytesRef t2) {
         byte[] b1 = t1.bytes;
         byte[] b2 = t2.bytes;
         int b1Stop;
@@ -110,7 +110,7 @@
       }
 
       @Override
-      public TermRef.Comparator getTermComparator() {
+      public BytesRef.Comparator getComparator() {
         return reverseUnicodeComparator;
       }
     }
@@ -166,7 +166,7 @@
       }
       
       @Override
-      public DocsConsumer startTerm(TermRef text) {
+      public DocsConsumer startTerm(BytesRef text) {
         final String term = text.toString();
         current = new RAMTerm(term);
         docsConsumer.reset(current);
@@ -175,12 +175,12 @@
 
       
       @Override
-      public TermRef.Comparator getTermComparator() {
-        return TermRef.getUTF8SortedAsUTF16Comparator();
+      public BytesRef.Comparator getComparator() {
+        return BytesRef.getUTF8SortedAsUTF16Comparator();
       }
 
       @Override
-      public void finishTerm(TermRef text, int numDocs) {
+      public void finishTerm(BytesRef text, int numDocs) {
         // nocommit -- are we even called when numDocs == 0?
         if (numDocs > 0) {
           assert numDocs == current.docs.size();
@@ -270,12 +270,12 @@
       }
       
       @Override
-      public TermRef.Comparator getTermComparator() {
-        return TermRef.getUTF8SortedAsUTF16Comparator();
+      public BytesRef.Comparator getComparator() {
+        return BytesRef.getUTF8SortedAsUTF16Comparator();
       }
 
       @Override
-      public TermRef next() {
+      public BytesRef next() {
         if (it == null) {
           if (current == null) {
             it = ramField.termToDocs.keySet().iterator();
@@ -285,14 +285,14 @@
         }
         if (it.hasNext()) {
           current = it.next();
-          return new TermRef(current);
+          return new BytesRef(current);
         } else {
           return null;
         }
       }
 
       @Override
-      public SeekStatus seek(TermRef term) {
+      public SeekStatus seek(BytesRef term) {
         current = term.toString();
         if (ramField.termToDocs.containsKey(current)) {
           return SeekStatus.FOUND;
@@ -317,9 +317,9 @@
       }
 
       @Override
-      public TermRef term() {
-        // TODO: reuse TermRef
-        return new TermRef(current);
+      public BytesRef term() {
+        // TODO: reuse BytesRef
+        return new BytesRef(current);
       }
 
       @Override
@@ -824,20 +824,20 @@
   private void testTermsOrder(IndexReader r) throws Exception {
 
     // Verify sort order matches what my comparator said:
-    TermRef lastTermRef = null;
+    BytesRef lastBytesRef = null;
     TermsEnum terms = r.fields().terms("id").iterator();
     //System.out.println("id terms:");
     while(true) {
-      TermRef t = terms.next();
+      BytesRef t = terms.next();
       if (t == null) {
         break;
       }
       //System.out.println("  " + t);
-      if (lastTermRef == null) {
-        lastTermRef = new TermRef(t);
+      if (lastBytesRef == null) {
+        lastBytesRef = new BytesRef(t);
       } else {
-        assertTrue("terms in wrong order last=" + lastTermRef + " current=" + t, reverseUnicodeComparator.compare(lastTermRef, t) < 0);
-        lastTermRef.copy(t);
+        assertTrue("terms in wrong order last=" + lastBytesRef + " current=" + t, reverseUnicodeComparator.compare(lastBytesRef, t) < 0);
+        lastBytesRef.copy(t);
       }
     }
   }

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/FlexTestUtil.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/FlexTestUtil.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/FlexTestUtil.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/FlexTestUtil.java Sun Jan 17 17:44:08 2010
@@ -133,7 +133,7 @@
       TermsEnum terms = fields.terms();
       final TermPositions termPos = r.termPositions();
       while(true) {
-        final TermRef termRef = terms.next();
+        final BytesRef termRef = terms.next();
         if (termRef == null) {
           break;
         } else {
@@ -206,7 +206,7 @@
         final TermPositions termPos = r.termPositions();
         final TermDocs termDocs = r.termDocs();
         while(true) {
-          final TermRef termRef = terms.next();
+          final BytesRef termRef = terms.next();
           //System.out.println("TEST:   enum term=" + termRef);
           if (termRef == null) {
             break;
@@ -362,7 +362,7 @@
       String text = getRandomText(rand, 1, 3, false);
       final TermsEnum termsEnum = r.fields().terms(f).iterator();
 
-      final TermsEnum.SeekStatus seekStatus = termsEnum.seek(new TermRef(text));
+      final TermsEnum.SeekStatus seekStatus = termsEnum.seek(new BytesRef(text));
       Term t = new Term(f, text);
       //System.out.println("seek to " + t);
 

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java Sun Jan 17 17:44:08 2010
@@ -47,6 +47,7 @@
 import org.apache.lucene.util.ReaderUtil;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.BytesRef;
 
 /*
   Verify we can read the pre-2.1 file format, do searches
@@ -111,13 +112,13 @@
     zipFile.close();
   }
 
-  public void xxxtestCreateCFS() throws IOException {
+  public void testCreateCFS() throws IOException {
     String dirName = "testindex.cfs";
     createIndex(dirName, true);
     rmDir(dirName);
   }
 
-  public void xxxtestCreateNoCFS() throws IOException {
+  public void testCreateNoCFS() throws IOException {
     String dirName = "testindex.nocfs";
     createIndex(dirName, true);
     rmDir(dirName);
@@ -242,7 +243,7 @@
     assertEquals("test for compressed field should have run 4 times", 4, hasTested29);
   }
 
-  public void xxxtestSearchOldIndex() throws IOException {
+  public void testSearchOldIndex() throws IOException {
     for(int i=0;i<oldNames.length;i++) {
       String dirName = "src/test/org/apache/lucene/index/index." + oldNames[i];
       unzip(dirName, oldNames[i]);
@@ -251,7 +252,7 @@
     }
   }
 
-  public void xxxtestIndexOldIndexNoAdds() throws IOException {
+  public void testIndexOldIndexNoAdds() throws IOException {
     for(int i=0;i<oldNames.length;i++) {
       String dirName = "src/test/org/apache/lucene/index/index." + oldNames[i];
       unzip(dirName, oldNames[i]);
@@ -260,7 +261,7 @@
     }
   }
 
-  public void xxxtestIndexOldIndex() throws IOException {
+  public void testIndexOldIndex() throws IOException {
     for(int i=0;i<oldNames.length;i++) {
       String dirName = "src/test/org/apache/lucene/index/index." + oldNames[i];
       unzip(dirName, oldNames[i]);
@@ -510,7 +511,7 @@
 
   /* Verifies that the expected file names were produced */
 
-  public void xxxtestExactFileNames() throws IOException {
+  public void testExactFileNames() throws IOException {
 
     String outputDir = "lucene.backwardscompat0.index";
     rmDir(outputDir);
@@ -662,7 +663,7 @@
   }
 
   // flex: test basics of TermsEnum api on non-flex index
-  public void xxxtestNextIntoWrongField() throws Exception {
+  public void testNextIntoWrongField() throws Exception {
     for(int i=0;i<oldNames.length;i++) {
       String dirName = "src/test/org/apache/lucene/index/index." + oldNames[i];
       unzip(dirName, oldNames[i]);
@@ -670,14 +671,14 @@
       Directory dir = FSDirectory.open(new File(fullPath));
       IndexReader r = IndexReader.open(dir);
       TermsEnum terms = r.fields().terms("content").iterator();
-      TermRef t = terms.next();
+      BytesRef t = terms.next();
       assertNotNull(t);
 
       // content field only has term aaa:
       assertEquals("aaa", t.toString());
       assertNull(terms.next());
 
-      TermRef aaaTerm = new TermRef("aaa");
+      BytesRef aaaTerm = new BytesRef("aaa");
 
       // should be found exactly
       assertEquals(TermsEnum.SeekStatus.FOUND,
@@ -687,13 +688,13 @@
 
       // should hit end of field
       assertEquals(TermsEnum.SeekStatus.END,
-                   terms.seek(new TermRef("bbb")));
+                   terms.seek(new BytesRef("bbb")));
       assertNull(terms.next());
 
       // should seek to aaa
       assertEquals(TermsEnum.SeekStatus.NOT_FOUND,
-                   terms.seek(new TermRef("a")));
-      assertTrue(terms.term().termEquals(aaaTerm));
+                   terms.seek(new BytesRef("a")));
+      assertTrue(terms.term().bytesEquals(aaaTerm));
       assertEquals(35, countDocs(terms.docs(null)));
       assertNull(terms.next());
 

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestCodecs.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestCodecs.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestCodecs.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestCodecs.java Sun Jan 17 17:44:08 2010
@@ -140,13 +140,13 @@
 
   class TermData implements Comparable {
     String text2;
-    final TermRef text;
+    final BytesRef text;
     int[] docs;
     PositionData[][] positions;
     FieldData field;
     
     public TermData(String text, int[] docs, PositionData[][] positions) {
-      this.text = new TermRef(text);
+      this.text = new BytesRef(text);
       this.text2 = text;
       this.docs = docs;
       this.positions = positions;
@@ -272,14 +272,14 @@
     assertNotNull(fieldsEnum.next());
     TermsEnum termsEnum = fieldsEnum.terms();
     for(int i=0;i<NUM_TERMS;i++) {
-      TermRef term = termsEnum.next();
+      BytesRef term = termsEnum.next();
       assertNotNull(term);
       assertEquals(terms[i].text2, term.toString());
     }
     assertNull(termsEnum.next());
 
     for(int i=0;i<NUM_TERMS;i++) {
-      assertEquals(termsEnum.seek(new TermRef(terms[i].text2)), TermsEnum.SeekStatus.FOUND);
+      assertEquals(termsEnum.seek(new BytesRef(terms[i].text2)), TermsEnum.SeekStatus.FOUND);
     }
 
     assertNull(fieldsEnum.next());
@@ -416,14 +416,14 @@
 
         int upto = 0;
         while(true) {
-          TermRef term = termsEnum.next();
+          BytesRef term = termsEnum.next();
           if (term == null) {
             break;
           }
           if (Codec.DEBUG) {
             System.out.println("check " + upto + ": " + field.terms[upto].text2);
           }
-          assertTrue(new TermRef(field.terms[upto++].text2).termEquals(term));
+          assertTrue(new BytesRef(field.terms[upto++].text2).bytesEquals(term));
         }
         assertEquals(upto, field.terms.length);
 
@@ -432,7 +432,7 @@
           System.out.println("\nTEST: random seek");
         }
         TermData term = field.terms[nextInt(field.terms.length)];
-        TermsEnum.SeekStatus status = termsEnum.seek(new TermRef(term.text2));
+        TermsEnum.SeekStatus status = termsEnum.seek(new BytesRef(term.text2));
         assertEquals(status, TermsEnum.SeekStatus.FOUND);
         assertEquals(term.docs.length, termsEnum.docFreq());
         verifyDocs(term.docs, term.positions, termsEnum.docs(null), !field.omitTF);
@@ -442,7 +442,7 @@
         term = field.terms[idx];
         status = termsEnum.seek(idx);
         assertEquals(status, TermsEnum.SeekStatus.FOUND);
-        assertTrue(termsEnum.term().termEquals(new TermRef(term.text2)));
+        assertTrue(termsEnum.term().bytesEquals(new BytesRef(term.text2)));
         assertEquals(term.docs.length, termsEnum.docFreq());
         verifyDocs(term.docs, term.positions, termsEnum.docs(null), !field.omitTF);
 
@@ -452,7 +452,7 @@
         for(int i=0;i<100;i++) {
           char[] text = getRandomText();
           String text2 = new String(text, 0, text.length-1) + ".";
-          status = termsEnum.seek(new TermRef(text2));
+          status = termsEnum.seek(new BytesRef(text2));
           assertTrue(status == TermsEnum.SeekStatus.NOT_FOUND ||
                      status == TermsEnum.SeekStatus.END);
         }
@@ -465,7 +465,7 @@
           if (Codec.DEBUG) {
             System.out.println(Thread.currentThread().getName() + ": TEST: term=" + field.terms[i].text2 + " has docFreq=" + field.terms[i].docs.length);
           }
-          assertEquals(Thread.currentThread().getName() + ": field=" + field.fieldInfo.name + " term=" + field.terms[i].text2, TermsEnum.SeekStatus.FOUND, termsEnum.seek(new TermRef(field.terms[i].text2)));
+          assertEquals(Thread.currentThread().getName() + ": field=" + field.fieldInfo.name + " term=" + field.terms[i].text2, TermsEnum.SeekStatus.FOUND, termsEnum.seek(new BytesRef(field.terms[i].text2)));
           assertEquals(field.terms[i].docs.length, termsEnum.docFreq());
         }
 
@@ -479,22 +479,22 @@
           }
           assertEquals(Thread.currentThread().getName() + ": field=" + field.fieldInfo.name + " term=" + field.terms[i].text2, TermsEnum.SeekStatus.FOUND, termsEnum.seek(i));
           assertEquals(field.terms[i].docs.length, termsEnum.docFreq());
-          assertTrue(termsEnum.term().termEquals(new TermRef(field.terms[i].text2)));
+          assertTrue(termsEnum.term().bytesEquals(new BytesRef(field.terms[i].text2)));
         }
 
         // Seek to non-existent empty-string term
-        status = termsEnum.seek(new TermRef(""));
+        status = termsEnum.seek(new BytesRef(""));
         assertNotNull(status);
         assertEquals(status, TermsEnum.SeekStatus.NOT_FOUND);
 
         // Make sure we're now pointing to first term
-        assertTrue(termsEnum.term().termEquals(new TermRef(field.terms[0].text2)));
+        assertTrue(termsEnum.term().bytesEquals(new BytesRef(field.terms[0].text2)));
 
         // Test docs enum
         if (Codec.DEBUG) {
           System.out.println("\nTEST: docs/positions");
         }
-        termsEnum.seek(new TermRef(""));
+        termsEnum.seek(new BytesRef(""));
         upto = 0;
         do {
           term = field.terms[upto];

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlexExternalReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlexExternalReader.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlexExternalReader.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlexExternalReader.java Sun Jan 17 17:44:08 2010
@@ -46,8 +46,8 @@
 
     IndexReader r = new FlexTestUtil.ForcedExternalReader(w.getReader());
 
-    TermRef field1Term = new TermRef("field1");
-    TermRef field2Term = new TermRef("field2");
+    BytesRef field1Term = new BytesRef("field1");
+    BytesRef field2Term = new BytesRef("field2");
 
     assertEquals(DOC_COUNT, r.maxDoc());
     assertEquals(DOC_COUNT, r.numDocs());
@@ -60,19 +60,19 @@
     assertEquals(TermsEnum.SeekStatus.FOUND, termsEnum.seek(field1Term));
 
     assertEquals(TermsEnum.SeekStatus.NOT_FOUND, termsEnum.seek(field2Term));
-    assertTrue(new TermRef("is").termEquals(termsEnum.term()));
+    assertTrue(new BytesRef("is").bytesEquals(termsEnum.term()));
 
     terms = fields.terms("field2");
     termsEnum = terms.iterator();
     assertEquals(TermsEnum.SeekStatus.NOT_FOUND, termsEnum.seek(field1Term));
-    assertTrue(termsEnum.term().termEquals(field2Term));
+    assertTrue(termsEnum.term().bytesEquals(field2Term));
 
     assertEquals(TermsEnum.SeekStatus.FOUND, termsEnum.seek(field2Term));
 
     termsEnum = fields.terms("field3").iterator();
-    assertEquals(TermsEnum.SeekStatus.END, termsEnum.seek(new TermRef("bbb")));
+    assertEquals(TermsEnum.SeekStatus.END, termsEnum.seek(new BytesRef("bbb")));
 
-    assertEquals(TermsEnum.SeekStatus.FOUND, termsEnum.seek(new TermRef("aaa")));
+    assertEquals(TermsEnum.SeekStatus.FOUND, termsEnum.seek(new BytesRef("aaa")));
     assertNull(termsEnum.next());
 
     r.close();

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriter.java Sun Jan 17 17:44:08 2010
@@ -72,6 +72,7 @@
 import org.apache.lucene.util._TestUtil;
 import org.apache.lucene.util.Version;
 import org.apache.lucene.util.ThreadInterruptedException;
+import org.apache.lucene.util.BytesRef;
 
 public class TestIndexWriter extends LuceneTestCase {
     public TestIndexWriter(String name) {
@@ -4691,7 +4692,7 @@
 
     UnicodeUtil.UTF16Result utf16 = new UnicodeUtil.UTF16Result();
     while(true) {
-      final TermRef term = terms.next();
+      final BytesRef term = terms.next();
       if (term == null) {
         break;
       }
@@ -4725,7 +4726,7 @@
     // Test seeking:
     Iterator<String> it = seenTerms.iterator();
     while(it.hasNext()) {
-      TermRef tr = new TermRef(it.next());
+      BytesRef tr = new BytesRef(it.next());
       assertEquals("seek failed for term=" + termDesc(tr.toString()), 
                    TermsEnum.SeekStatus.FOUND,
                    terms.seek(tr));

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/JustCompileSearch.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/JustCompileSearch.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/JustCompileSearch.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/JustCompileSearch.java Sun Jan 17 17:44:08 2010
@@ -25,7 +25,7 @@
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.DocsEnum;
-import org.apache.lucene.index.TermRef;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.PriorityQueue;
 
 /**
@@ -203,7 +203,7 @@
   
   static final class JustCompileExtendedFieldCacheLongParser implements FieldCache.LongParser {
 
-    public long parseLong(TermRef string) {
+    public long parseLong(BytesRef string) {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
     }
     
@@ -211,7 +211,7 @@
   
   static final class JustCompileExtendedFieldCacheDoubleParser implements FieldCache.DoubleParser {
     
-    public double parseDouble(TermRef term) {
+    public double parseDouble(BytesRef term) {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
     }
     

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java Sun Jan 17 17:44:08 2010
@@ -24,9 +24,8 @@
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.NumericField;
 import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.TermRef;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.index.IndexWriter.MaxFieldLength;
-import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermsEnum;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.LuceneTestCase;
@@ -446,7 +445,7 @@
     TermsEnum termEnum = q.getTermsEnum(searcher.getIndexReader());
     int count = 0;
     while (termEnum.next() != null) {
-      final TermRef t = termEnum.term();
+      final BytesRef t = termEnum.term();
       if (t != null) {
         final int val = NumericUtils.prefixCodedToInt(t.toString());
         assertTrue("value not in bounds " + val + " >= " + lower + " && "

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestSort.java?rev=900166&r1=900165&r2=900166&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestSort.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestSort.java Sun Jan 17 17:44:08 2010
@@ -35,7 +35,7 @@
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermRef;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.queryParser.ParseException;
 import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.store.LockObtainFailedException;
@@ -334,7 +334,7 @@
 
 
     sort.setSort (new SortField[] { new SortField ("parser", new FieldCache.IntParser(){
-      public final int parseInt(final TermRef term) {
+      public final int parseInt(final BytesRef term) {
         return (term.bytes[term.offset]-'A') * 123456;
       }
     }), SortField.FIELD_DOC });
@@ -343,7 +343,7 @@
     fc.purgeAllCaches();
 
     sort.setSort (new SortField[] { new SortField ("parser", new FieldCache.FloatParser(){
-      public final float parseFloat(final TermRef term) {
+      public final float parseFloat(final BytesRef term) {
         return (float) Math.sqrt( term.bytes[term.offset] );
       }
     }), SortField.FIELD_DOC });
@@ -352,7 +352,7 @@
     fc.purgeAllCaches();
 
     sort.setSort (new SortField[] { new SortField ("parser", new FieldCache.LongParser(){
-      public final long parseLong(final TermRef term) {
+      public final long parseLong(final BytesRef term) {
         return (term.bytes[term.offset]-'A') * 1234567890L;
       }
     }), SortField.FIELD_DOC });
@@ -361,7 +361,7 @@
     fc.purgeAllCaches();
 
     sort.setSort (new SortField[] { new SortField ("parser", new FieldCache.DoubleParser(){
-      public final double parseDouble(final TermRef term) {
+      public final double parseDouble(final BytesRef term) {
         return Math.pow( term.bytes[term.offset], (term.bytes[term.offset]-'A') );
       }
     }), SortField.FIELD_DOC });
@@ -370,7 +370,7 @@
     fc.purgeAllCaches();
 
     sort.setSort (new SortField[] { new SortField ("parser", new FieldCache.ByteParser(){
-      public final byte parseByte(final TermRef term) {
+      public final byte parseByte(final BytesRef term) {
         return (byte) (term.bytes[term.offset]-'A');
       }
     }), SortField.FIELD_DOC });
@@ -379,7 +379,7 @@
     fc.purgeAllCaches();
 
     sort.setSort (new SortField[] { new SortField ("parser", new FieldCache.ShortParser(){
-      public final short parseShort(final TermRef term) {
+      public final short parseShort(final BytesRef term) {
         return (short) (term.bytes[term.offset]-'A');
       }
     }), SortField.FIELD_DOC });
@@ -440,7 +440,7 @@
     @Override
     public void setNextReader(IndexReader reader, int docBase) throws IOException {
       docValues = FieldCache.DEFAULT.getInts(reader, "parser", new FieldCache.IntParser() {
-          public final int parseInt(final TermRef term) {
+          public final int parseInt(final BytesRef term) {
             return (term.bytes[term.offset]-'A') * 123456;
           }
         });



Mime
View raw message