mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r1094781 - /mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/lucene/LuceneIterator.java
Date Mon, 18 Apr 2011 21:45:27 GMT
Author: srowen
Date: Mon Apr 18 21:45:27 2011
New Revision: 1094781

URL: http://svn.apache.org/viewvc?rev=1094781&view=rev
Log:
MAHOUT-675 just warn about docs with no term freq vector

Modified:
    mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/lucene/LuceneIterator.java

Modified: mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/lucene/LuceneIterator.java
URL: http://svn.apache.org/viewvc/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/lucene/LuceneIterator.java?rev=1094781&r1=1094780&r2=1094781&view=diff
==============================================================================
--- mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/lucene/LuceneIterator.java
(original)
+++ mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/lucene/LuceneIterator.java
Mon Apr 18 21:45:27 2011
@@ -30,6 +30,8 @@ import org.apache.lucene.index.TermDocs;
 import org.apache.lucene.index.TermFreqVector;
 import org.apache.mahout.math.NamedVector;
 import org.apache.mahout.math.Vector;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * An {@link Iterator} over {@link Vector}s that uses a Lucene index as the source for creating
the
@@ -37,6 +39,8 @@ import org.apache.mahout.math.Vector;
  */
 public final class LuceneIterator extends AbstractIterator<Vector> {
 
+  private static final Logger log = LoggerFactory.getLogger(LuceneIterator.class);
+
   private final IndexReader indexReader;
   private final String field;
   private final String idField;
@@ -82,7 +86,8 @@ public final class LuceneIterator extend
       int doc = termDocs.doc();
       TermFreqVector termFreqVector = indexReader.getTermFreqVector(doc, field);
       if (termFreqVector == null) {
-        throw new IllegalStateException("Field '" + field + "' does not have term vectors");
+        log.warn(indexReader.document(doc).get(idField) + " does not have a term vector for
" + field);
+        computeNext();
       }
 
       indexReader.getTermFreqVector(doc, field, mapper);



Mime
View raw message