lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r830668 - in /lucene/java/trunk/src/java/org/apache/lucene/index: DocInverterPerField.java DocInverterPerThread.java
Date Wed, 28 Oct 2009 16:44:32 GMT
Author: uschindler
Date: Wed Oct 28 16:44:31 2009
New Revision: 830668

URL: http://svn.apache.org/viewvc?rev=830668&view=rev
Log:
No need to extend TokenStream here, a simple AttributeSource is enough for single-token-fields.
This prevents us from implementing the incrementToken() throwing UOE.

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/DocInverterPerField.java
    lucene/java/trunk/src/java/org/apache/lucene/index/DocInverterPerThread.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/DocInverterPerField.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/DocInverterPerField.java?rev=830668&r1=830667&r2=830668&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/DocInverterPerField.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/DocInverterPerField.java Wed Oct 28
16:44:31 2009
@@ -84,8 +84,8 @@
         if (!field.isTokenized()) {		  // un-tokenized field
           String stringValue = field.stringValue();
           final int valueLength = stringValue.length();
-          perThread.singleTokenTokenStream.reinit(stringValue, 0, valueLength);
-          fieldState.attributeSource = perThread.singleTokenTokenStream;
+          perThread.singleToken.reinit(stringValue, 0, valueLength);
+          fieldState.attributeSource = perThread.singleToken;
           consumer.start(field);
 
           boolean success = false;

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/DocInverterPerThread.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/DocInverterPerThread.java?rev=830668&r1=830667&r2=830668&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/DocInverterPerThread.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/DocInverterPerThread.java Wed Oct 28
16:44:31 2009
@@ -19,7 +19,7 @@
 
 import java.io.IOException;
 
-import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.util.AttributeSource;
 import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
 import org.apache.lucene.analysis.tokenattributes.TermAttribute;
 
@@ -31,14 +31,13 @@
   final DocInverter docInverter;
   final InvertedDocConsumerPerThread consumer;
   final InvertedDocEndConsumerPerThread endConsumer;
-  //TODO: change to SingleTokenTokenStream after Token was removed
-  final SingleTokenTokenStream singleTokenTokenStream = new SingleTokenTokenStream();
+  final SingleTokenAttributeSource singleToken = new SingleTokenAttributeSource();
   
-  static class SingleTokenTokenStream extends TokenStream {
-    TermAttribute termAttribute;
-    OffsetAttribute offsetAttribute;
+  static class SingleTokenAttributeSource extends AttributeSource {
+    final TermAttribute termAttribute;
+    final OffsetAttribute offsetAttribute;
     
-    SingleTokenTokenStream() {
+    private SingleTokenAttributeSource() {
       termAttribute = addAttribute(TermAttribute.class);
       offsetAttribute = addAttribute(OffsetAttribute.class);
     }
@@ -47,12 +46,6 @@
       termAttribute.setTermBuffer(stringValue);
       offsetAttribute.setOffset(startOffset, endOffset);
     }
-    
-    // this is a dummy, to not throw an UOE because this class does not implement any iteration
method
-    @Override
-    public boolean incrementToken() {
-      throw new UnsupportedOperationException();
-    }
   }
   
   final DocumentsWriter.DocState docState;



Mime
View raw message