lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r932862 [2/2] - in /lucene/dev/trunk/solr: ./ contrib/clustering/ contrib/dataimporthandler/ contrib/extraction/ contrib/velocity/ src/java/org/apache/solr/analysis/ src/java/org/apache/solr/handler/ src/java/org/apache/solr/handler/compone...
Date Sun, 11 Apr 2010 10:31:35 GMT
Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/analysis/TestWordDelimiterFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/analysis/TestWordDelimiterFilter.java?rev=932862&r1=932861&r2=932862&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/analysis/TestWordDelimiterFilter.java (original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/analysis/TestWordDelimiterFilter.java Sun
Apr 11 10:31:34 2010
@@ -28,7 +28,7 @@ import org.apache.lucene.analysis.Whites
 import org.apache.lucene.analysis.miscellaneous.SingleTokenTokenStream;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
-import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.solr.SolrTestCaseJ4;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -347,19 +347,17 @@ public class TestWordDelimiterFilter ext
    * Set a large position increment gap of 10 if the token is "largegap" or "/"
    */
   private final class LargePosIncTokenFilter extends TokenFilter {
-    private TermAttribute termAtt;
-    private PositionIncrementAttribute posIncAtt;
+    private CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
+    private PositionIncrementAttribute posIncAtt = addAttribute(PositionIncrementAttribute.class);
     
     protected LargePosIncTokenFilter(TokenStream input) {
       super(input);
-      termAtt = addAttribute(TermAttribute.class);
-      posIncAtt = addAttribute(PositionIncrementAttribute.class);
     }
 
     @Override
     public boolean incrementToken() throws IOException {
       if (input.incrementToken()) {
-        if (termAtt.term().equals("largegap") || termAtt.term().equals("/"))
+        if (termAtt.toString().equals("largegap") || termAtt.toString().equals("/"))
           posIncAtt.setPositionIncrement(10);
         return true;
       } else {

Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/SimpleQueryConverter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/SimpleQueryConverter.java?rev=932862&r1=932861&r2=932862&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/SimpleQueryConverter.java (original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/SimpleQueryConverter.java Sun
Apr 11 10:31:34 2010
@@ -19,11 +19,11 @@ package org.apache.solr.spelling;
 import org.apache.lucene.analysis.Token;
 import org.apache.lucene.analysis.WhitespaceAnalyzer;
 import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.analysis.tokenattributes.FlagsAttribute;
 import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
 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.TypeAttribute;
 
 import java.util.Collection;
@@ -43,18 +43,18 @@ class SimpleQueryConverter extends Spell
     WhitespaceAnalyzer analyzer = new WhitespaceAnalyzer();
     TokenStream ts = analyzer.tokenStream("", new StringReader(origQuery));
     // TODO: support custom attributes
-    TermAttribute termAtt = (TermAttribute) ts.addAttribute(TermAttribute.class);
-    OffsetAttribute offsetAtt = (OffsetAttribute) ts.addAttribute(OffsetAttribute.class);
-    TypeAttribute typeAtt = (TypeAttribute) ts.addAttribute(TypeAttribute.class);
-    FlagsAttribute flagsAtt = (FlagsAttribute) ts.addAttribute(FlagsAttribute.class);
-    PayloadAttribute payloadAtt = (PayloadAttribute) ts.addAttribute(PayloadAttribute.class);
-    PositionIncrementAttribute posIncAtt = (PositionIncrementAttribute) ts.addAttribute(PositionIncrementAttribute.class);
+    CharTermAttribute termAtt = ts.addAttribute(CharTermAttribute.class);
+    OffsetAttribute offsetAtt = ts.addAttribute(OffsetAttribute.class);
+    TypeAttribute typeAtt = ts.addAttribute(TypeAttribute.class);
+    FlagsAttribute flagsAtt = ts.addAttribute(FlagsAttribute.class);
+    PayloadAttribute payloadAtt = ts.addAttribute(PayloadAttribute.class);
+    PositionIncrementAttribute posIncAtt = ts.addAttribute(PositionIncrementAttribute.class);
     
     try {
       ts.reset();
       while (ts.incrementToken()){
         Token tok = new Token();
-        tok.setTermBuffer(termAtt.termBuffer(), 0, termAtt.termLength());
+        tok.setTermBuffer(termAtt.buffer(), 0, termAtt.length());
         tok.setOffset(offsetAtt.startOffset(), offsetAtt.endOffset());
         tok.setFlags(flagsAtt.getFlags());
         tok.setPayload(payloadAtt.getPayload());

Modified: lucene/dev/trunk/solr/src/webapp/web/admin/analysis.jsp
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/webapp/web/admin/analysis.jsp?rev=932862&r1=932861&r2=932862&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/webapp/web/admin/analysis.jsp (original)
+++ lucene/dev/trunk/solr/src/webapp/web/admin/analysis.jsp Sun Apr 11 10:31:34 2010
@@ -213,17 +213,17 @@
 
          final Iterator<Token> iter = tokens.iterator();
          tstream = filtfac.create( new TokenStream() {
-           TermAttribute termAtt = (TermAttribute) addAttribute(TermAttribute.class);
-           OffsetAttribute offsetAtt = (OffsetAttribute) addAttribute (OffsetAttribute.class);
-           TypeAttribute typeAtt = (TypeAttribute) addAttribute (TypeAttribute.class);
-           FlagsAttribute flagsAtt = (FlagsAttribute) addAttribute (FlagsAttribute.class);
-           PayloadAttribute payloadAtt = (PayloadAttribute) addAttribute (PayloadAttribute.class);
-           PositionIncrementAttribute posIncAtt = (PositionIncrementAttribute) addAttribute
(PositionIncrementAttribute.class);
+           CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
+           OffsetAttribute offsetAtt = addAttribute (OffsetAttribute.class);
+           TypeAttribute typeAtt = addAttribute (TypeAttribute.class);
+           FlagsAttribute flagsAtt = addAttribute (FlagsAttribute.class);
+           PayloadAttribute payloadAtt = addAttribute (PayloadAttribute.class);
+           PositionIncrementAttribute posIncAtt = addAttribute (PositionIncrementAttribute.class);
            
            public boolean incrementToken() throws IOException {
              if (iter.hasNext()) {
                Token token = iter.next();
-               termAtt.setTermBuffer(token.termBuffer(), 0, token.termLength());
+               termAtt.copyBuffer(token.termBuffer(), 0, token.termLength());
                offsetAtt.setOffset(token.startOffset(), token.endOffset());
                typeAtt.setType(token.type());
                flagsAtt.setFlags(token.getFlags());
@@ -255,19 +255,19 @@
 
   static List<Token> getTokens(TokenStream tstream) throws IOException {
     List<Token> tokens = new ArrayList<Token>();
-    TermAttribute termAtt = (TermAttribute) tstream.addAttribute(TermAttribute.class);
-    OffsetAttribute offsetAtt = (OffsetAttribute) tstream.addAttribute (OffsetAttribute.class);
-    TypeAttribute typeAtt = (TypeAttribute) tstream.addAttribute (TypeAttribute.class);
-    FlagsAttribute flagsAtt = (FlagsAttribute) tstream.addAttribute (FlagsAttribute.class);
-    PayloadAttribute payloadAtt = (PayloadAttribute) tstream.addAttribute (PayloadAttribute.class);
-    PositionIncrementAttribute posIncAtt = (PositionIncrementAttribute) tstream.addAttribute
(PositionIncrementAttribute.class);
+    CharTermAttribute termAtt = tstream.addAttribute(CharTermAttribute.class);
+    OffsetAttribute offsetAtt = tstream.addAttribute (OffsetAttribute.class);
+    TypeAttribute typeAtt = tstream.addAttribute (TypeAttribute.class);
+    FlagsAttribute flagsAtt = tstream.addAttribute (FlagsAttribute.class);
+    PayloadAttribute payloadAtt = tstream.addAttribute (PayloadAttribute.class);
+    PositionIncrementAttribute posIncAtt = tstream.addAttribute (PositionIncrementAttribute.class);
    
     while (true) {
       if (!tstream.incrementToken())
         break;
       else {
       	Token token = new Token();
-      	token.setTermBuffer(termAtt.termBuffer(), 0, termAtt.termLength());
+      	token.setTermBuffer(termAtt.buffer(), 0, termAtt.length());
       	token.setType(typeAtt.type());
       	token.setOffset(offsetAtt.startOffset(), offsetAtt.endOffset());
       	token.setPayload(payloadAtt.getPayload());



Mime
View raw message