lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r932749 [2/2] - in /lucene/dev/trunk/lucene: ./ backwards/src/test/org/apache/lucene/analysis/ src/java/org/apache/lucene/analysis/ src/java/org/apache/lucene/analysis/standard/ src/java/org/apache/lucene/collation/ src/java/org/apache/luce...
Date Sat, 10 Apr 2010 15:41:28 GMT
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=932749&r1=932748&r2=932749&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java Sat Apr
10 15:41:27 2010
@@ -46,7 +46,7 @@ import org.apache.lucene.analysis.Whites
 import org.apache.lucene.analysis.WhitespaceTokenizer;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.analysis.standard.StandardTokenizer;
-import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
@@ -3482,7 +3482,7 @@ public class TestIndexWriter extends Luc
   // LUCENE-1255
   public void testNegativePositions() throws Throwable {
     final TokenStream tokens = new TokenStream() {
-      final TermAttribute termAtt = addAttribute(TermAttribute.class);
+      final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
       final PositionIncrementAttribute posIncrAtt = addAttribute(PositionIncrementAttribute.class);
       
       final Iterator<String> terms = Arrays.asList("a","b","c").iterator();
@@ -3492,7 +3492,7 @@ public class TestIndexWriter extends Luc
       public boolean incrementToken() {
         if (!terms.hasNext()) return false;
         clearAttributes();
-        termAtt.setTermBuffer( terms.next());
+        termAtt.append(terms.next());
         posIncrAtt.setPositionIncrement(first ? 0 : 1);
         first = false;
         return true;

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestPayloads.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestPayloads.java?rev=932749&r1=932748&r2=932749&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestPayloads.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestPayloads.java Sat Apr 10
15:41:27 2010
@@ -33,7 +33,7 @@ import org.apache.lucene.analysis.TokenS
 import org.apache.lucene.analysis.WhitespaceAnalyzer;
 import org.apache.lucene.analysis.WhitespaceTokenizer;
 import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
-import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
@@ -538,7 +538,7 @@ public class TestPayloads extends Lucene
         private ByteArrayPool pool;
         private String term;
 
-        TermAttribute termAtt;
+        CharTermAttribute termAtt;
         PayloadAttribute payloadAtt;
         
         PoolingPayloadTokenStream(ByteArrayPool pool) {
@@ -548,7 +548,7 @@ public class TestPayloads extends Lucene
             term = pool.bytesToString(payload);
             first = true;
             payloadAtt = addAttribute(PayloadAttribute.class);
-            termAtt = addAttribute(TermAttribute.class);
+            termAtt = addAttribute(CharTermAttribute.class);
         }
         
         @Override
@@ -556,7 +556,7 @@ public class TestPayloads extends Lucene
             if (!first) return false;
             first = false;
             clearAttributes();
-            termAtt.setTermBuffer(term);
+            termAtt.append(term);
             payloadAtt.setPayload(new Payload(payload));
             return true;
         }

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java?rev=932749&r1=932748&r2=932749&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java Sat
Apr 10 15:41:27 2010
@@ -28,7 +28,7 @@ import org.apache.lucene.analysis.Analyz
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
 import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
-import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.store.MockRAMDirectory;
@@ -123,12 +123,12 @@ public class TestTermVectorsReader exten
   private class MyTokenStream extends TokenStream {
     int tokenUpto;
     
-    TermAttribute termAtt;
+    CharTermAttribute termAtt;
     PositionIncrementAttribute posIncrAtt;
     OffsetAttribute offsetAtt;
     
     public MyTokenStream() {
-      termAtt = addAttribute(TermAttribute.class);
+      termAtt = addAttribute(CharTermAttribute.class);
       posIncrAtt = addAttribute(PositionIncrementAttribute.class);
       offsetAtt = addAttribute(OffsetAttribute.class);
     }
@@ -140,7 +140,7 @@ public class TestTermVectorsReader exten
       else {
         final TestToken testToken = tokens[tokenUpto++];
         clearAttributes();
-        termAtt.setTermBuffer(testToken.text);
+        termAtt.append(testToken.text);
         offsetAtt.setOffset(testToken.startOffset, testToken.endOffset);
         if (tokenUpto > 1) {
           posIncrAtt.setPositionIncrement(testToken.pos - tokens[tokenUpto-2].pos);

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java?rev=932749&r1=932748&r2=932749&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java Sat Apr
10 15:41:27 2010
@@ -23,7 +23,7 @@ import java.util.Random;
 
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
@@ -33,12 +33,12 @@ import org.apache.lucene.util.LuceneTest
 
 class RepeatingTokenStream extends TokenStream {
   public int num;
-  TermAttribute termAtt;
+  CharTermAttribute termAtt;
   String value;
 
    public RepeatingTokenStream(String val) {
      this.value = val;
-     this.termAtt = addAttribute(TermAttribute.class);
+     this.termAtt = addAttribute(CharTermAttribute.class);
    }
 
    @Override
@@ -46,7 +46,7 @@ class RepeatingTokenStream extends Token
      num--;
      if (num >= 0) {
        clearAttributes();
-       termAtt.setTermBuffer(value);
+       termAtt.append(value);
        return true;
      }
      return false;

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java?rev=932749&r1=932748&r2=932749&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java
(original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java
Sat Apr 10 15:41:27 2010
@@ -26,7 +26,7 @@ import org.apache.lucene.analysis.TokenS
 import org.apache.lucene.analysis.standard.StandardTokenizer;
 import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
 import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
-import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.analysis.tokenattributes.TypeAttribute;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.analysis.BaseTokenStreamTestCase;
@@ -148,14 +148,14 @@ public class TestMultiAnalyzer extends B
     private int prevStartOffset;
     private int prevEndOffset;
     
-    TermAttribute termAtt;
+    CharTermAttribute termAtt;
     PositionIncrementAttribute posIncrAtt;
     OffsetAttribute offsetAtt;
     TypeAttribute typeAtt;
     
     public TestFilter(TokenStream in) {
       super(in);
-      termAtt = addAttribute(TermAttribute.class);
+      termAtt = addAttribute(CharTermAttribute.class);
       posIncrAtt = addAttribute(PositionIncrementAttribute.class);
       offsetAtt = addAttribute(OffsetAttribute.class);
       typeAtt = addAttribute(TypeAttribute.class);
@@ -164,7 +164,7 @@ public class TestMultiAnalyzer extends B
     @Override
     public final boolean incrementToken() throws java.io.IOException {
       if (multiToken > 0) {
-        termAtt.setTermBuffer("multi"+(multiToken+1));
+        termAtt.setEmpty().append("multi"+(multiToken+1));
         offsetAtt.setOffset(prevStartOffset, prevEndOffset);
         typeAtt.setType(prevType);
         posIncrAtt.setPositionIncrement(0);
@@ -178,7 +178,7 @@ public class TestMultiAnalyzer extends B
         prevType = typeAtt.type();
         prevStartOffset = offsetAtt.startOffset();
         prevEndOffset = offsetAtt.endOffset();
-        String text = termAtt.term();
+        String text = termAtt.toString();
         if (text.equals("triplemulti")) {
           multiToken = 2;
           return true;
@@ -212,21 +212,21 @@ public class TestMultiAnalyzer extends B
 
   private final class TestPosIncrementFilter extends TokenFilter {
     
-    TermAttribute termAtt;
+    CharTermAttribute termAtt;
     PositionIncrementAttribute posIncrAtt;
     
     public TestPosIncrementFilter(TokenStream in) {
       super(in);
-      termAtt = addAttribute(TermAttribute.class);
+      termAtt = addAttribute(CharTermAttribute.class);
       posIncrAtt = addAttribute(PositionIncrementAttribute.class);
     }
 
     @Override
     public final boolean incrementToken () throws java.io.IOException {
       while(input.incrementToken()) {
-        if (termAtt.term().equals("the")) {
+        if (termAtt.toString().equals("the")) {
           // stopword, do nothing
-        } else if (termAtt.term().equals("quick")) {
+        } else if (termAtt.toString().equals("quick")) {
           posIncrAtt.setPositionIncrement(2);
           return true;
         } else {

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.java?rev=932749&r1=932748&r2=932749&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.java Sat
Apr 10 15:41:27 2010
@@ -40,7 +40,7 @@ import org.apache.lucene.analysis.TokenS
 import org.apache.lucene.analysis.WhitespaceAnalyzer;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
-import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.document.DateField;
 import org.apache.lucene.document.DateTools;
 import org.apache.lucene.document.Document;
@@ -82,7 +82,7 @@ public class TestQueryParser extends Loc
   public static Analyzer qpAnalyzer = new QPTestAnalyzer();
 
   public static class QPTestFilter extends TokenFilter {
-    TermAttribute termAtt;
+    CharTermAttribute termAtt;
     OffsetAttribute offsetAtt;
         
     /**
@@ -91,7 +91,7 @@ public class TestQueryParser extends Loc
      */
     public QPTestFilter(TokenStream in) {
       super(in);
-      termAtt = addAttribute(TermAttribute.class);
+      termAtt = addAttribute(CharTermAttribute.class);
       offsetAtt = addAttribute(OffsetAttribute.class);
     }
 
@@ -103,19 +103,19 @@ public class TestQueryParser extends Loc
       if (inPhrase) {
         inPhrase = false;
         clearAttributes();
-        termAtt.setTermBuffer("phrase2");
+        termAtt.append("phrase2");
         offsetAtt.setOffset(savedStart, savedEnd);
         return true;
       } else
         while (input.incrementToken()) {
-          if (termAtt.term().equals("phrase")) {
+          if (termAtt.toString().equals("phrase")) {
             inPhrase = true;
             savedStart = offsetAtt.startOffset();
             savedEnd = offsetAtt.endOffset();
-            termAtt.setTermBuffer("phrase1");
+            termAtt.setEmpty().append("phrase1");
             offsetAtt.setOffset(savedStart, savedEnd);
             return true;
-          } else if (!termAtt.term().equals("stop"))
+          } else if (!termAtt.toString().equals("stop"))
             return true;
         }
       return false;

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java?rev=932749&r1=932748&r2=932749&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java Sat
Apr 10 15:41:27 2010
@@ -31,7 +31,7 @@ import org.apache.lucene.analysis.Whites
 import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
 import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
 import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
-import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.analysis.CharArraySet;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
@@ -74,7 +74,7 @@ public class TestPositionIncrement exten
           private int i = 0;
 
           PositionIncrementAttribute posIncrAtt = addAttribute(PositionIncrementAttribute.class);
-          TermAttribute termAtt = addAttribute(TermAttribute.class);
+          CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
           OffsetAttribute offsetAtt = addAttribute(OffsetAttribute.class);
           
           @Override
@@ -82,7 +82,7 @@ public class TestPositionIncrement exten
             if (i == TOKENS.length)
               return false;
             clearAttributes();
-            termAtt.setTermBuffer(TOKENS[i]);
+            termAtt.append(TOKENS[i]);
             offsetAtt.setOffset(i,i);
             posIncrAtt.setPositionIncrement(INCREMENTS[i]);
             i++;
@@ -347,7 +347,7 @@ class PayloadFilter extends TokenFilter 
 
   final PositionIncrementAttribute posIncrAttr;
   final PayloadAttribute payloadAttr;
-  final TermAttribute termAttr;
+  final CharTermAttribute termAttr;
 
   public PayloadFilter(TokenStream input, String fieldName) {
     super(input);
@@ -356,7 +356,7 @@ class PayloadFilter extends TokenFilter 
     i = 0;
     posIncrAttr = input.addAttribute(PositionIncrementAttribute.class);
     payloadAttr = input.addAttribute(PayloadAttribute.class);
-    termAttr = input.addAttribute(TermAttribute.class);
+    termAttr = input.addAttribute(CharTermAttribute.class);
   }
 
   @Override
@@ -372,7 +372,7 @@ class PayloadFilter extends TokenFilter 
       posIncrAttr.setPositionIncrement(posIncr);
       pos += posIncr;
       if (TestPositionIncrement.VERBOSE) {
-        System.out.println("term=" + termAttr.term() + " pos=" + pos);
+        System.out.println("term=" + termAttr + " pos=" + pos);
       }
       i++;
       return true;

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java?rev=932749&r1=932748&r2=932749&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java Sat
Apr 10 15:41:27 2010
@@ -27,7 +27,7 @@ import org.apache.lucene.store.RAMDirect
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.Tokenizer;
-import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 
 import org.apache.lucene.util.LuceneTestCase;
 import java.io.IOException;
@@ -280,27 +280,25 @@ public class TestTermRangeQuery extends 
 
     private static class SingleCharTokenizer extends Tokenizer {
       char[] buffer = new char[1];
-      boolean done;
-      TermAttribute termAtt;
+      boolean done = false;
+      CharTermAttribute termAtt;
       
       public SingleCharTokenizer(Reader r) {
         super(r);
-        termAtt = addAttribute(TermAttribute.class);
+        termAtt = addAttribute(CharTermAttribute.class);
       }
 
       @Override
       public boolean incrementToken() throws IOException {
-        int count = input.read(buffer);
         if (done)
           return false;
         else {
+          int count = input.read(buffer);
           clearAttributes();
           done = true;
           if (count == 1) {
-            termAtt.termBuffer()[0] = buffer[0];
-            termAtt.setTermLength(1);
-          } else
-            termAtt.setTermLength(0);
+            termAtt.copyBuffer(buffer, 0, 1);
+          }
           return true;
         }
       }

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java?rev=932749&r1=932748&r2=932749&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
(original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
Sat Apr 10 15:41:27 2010
@@ -29,7 +29,7 @@ import org.apache.lucene.analysis.TokenF
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
 import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
-import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.CorruptIndexException;
@@ -479,7 +479,7 @@ public class TestPayloadSpans extends Lu
     Set<String> nopayload = new HashSet<String>();
     int pos;
     PayloadAttribute payloadAtt;
-    TermAttribute termAtt;
+    CharTermAttribute termAtt;
     PositionIncrementAttribute posIncrAtt;
 
     public PayloadFilter(TokenStream input, String fieldName) {
@@ -490,7 +490,7 @@ public class TestPayloadSpans extends Lu
       entities.add("one");
       nopayload.add("nopayload");
       nopayload.add("np");
-      termAtt = addAttribute(TermAttribute.class);
+      termAtt = addAttribute(CharTermAttribute.class);
       posIncrAtt = addAttribute(PositionIncrementAttribute.class);
       payloadAtt = addAttribute(PayloadAttribute.class);
     }
@@ -498,7 +498,7 @@ public class TestPayloadSpans extends Lu
     @Override
     public boolean incrementToken() throws IOException {
       if (input.incrementToken()) {
-        String token = new String(termAtt.termBuffer(), 0, termAtt.termLength());
+        String token = termAtt.toString();
 
         if (!nopayload.contains(token)) {
           if (entities.contains(token)) {



Mime
View raw message