lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r807223 - /lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java
Date Mon, 24 Aug 2009 14:03:51 GMT
Author: uschindler
Date: Mon Aug 24 14:03:51 2009
New Revision: 807223

URL: http://svn.apache.org/viewvc?rev=807223&view=rev
Log:
Sorry for the last commit, this is the better solution. As the offset attribute was normally
already added before in the indexing process, the addAttribute is at no cost. And the additional
if-clause is prevented (I missed a second one in the previous commit). Now only payloads are
conditional to attribute existence.

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java?rev=807223&r1=807222&r2=807223&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java
(original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsTermsWriterPerField.java
Mon Aug 24 14:03:51 2009
@@ -195,8 +195,8 @@
   }
   
   void start(Fieldable f) {
-    if (doVectorOffsets && fieldState.attributeSource.hasAttribute(OffsetAttribute.class))
{
-      offsetAttribute = (OffsetAttribute) fieldState.attributeSource.getAttribute(OffsetAttribute.class);
+    if (doVectorOffsets) {
+      offsetAttribute = (OffsetAttribute) fieldState.attributeSource.addAttribute(OffsetAttribute.class);
     } else {
       offsetAttribute = null;
     }
@@ -211,12 +211,8 @@
     p.freq = 1;
 
     if (doVectorOffsets) {
-      int startOffset = fieldState.offset;
-      int endOffset = fieldState.offset;
-      if (offsetAttribute != null) {
-        startOffset += offsetAttribute.startOffset();
-        endOffset += offsetAttribute.endOffset();
-      }
+      int startOffset = fieldState.offset + offsetAttribute.startOffset();;
+      int endOffset = fieldState.offset + offsetAttribute.endOffset();
       
       termsHashPerField.writeVInt(1, startOffset);
       termsHashPerField.writeVInt(1, endOffset - startOffset);



Mime
View raw message