mirror of https://github.com/apache/lucene.git
print a message to infoStream if the number of maximum tokens per document (maxFieldLength) is reached
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150706 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a7495a6df8
commit
857624d038
|
@ -17,6 +17,7 @@ package org.apache.lucene.index;
|
|||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.util.Hashtable;
|
||||
|
@ -38,6 +39,7 @@ final class DocumentWriter {
|
|||
private Similarity similarity;
|
||||
private FieldInfos fieldInfos;
|
||||
private int maxFieldLength;
|
||||
private PrintStream infoStream;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -159,8 +161,11 @@ final class DocumentWriter {
|
|||
addPosition(fieldName, t.termText(), position++, null);
|
||||
|
||||
lastToken = t;
|
||||
if (++length > maxFieldLength)
|
||||
if (++length > maxFieldLength) {
|
||||
if (infoStream != null)
|
||||
infoStream.println("maxFieldLength " +maxFieldLength+ " reached, ignoring following tokens");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(lastToken != null)
|
||||
|
@ -367,6 +372,13 @@ final class DocumentWriter {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** If non-null, a message will be printed to this if maxFieldLength is reached.
|
||||
*/
|
||||
void setInfoStream(PrintStream infoStream) {
|
||||
this.infoStream = infoStream;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final class Posting { // info about a Term in a doc
|
||||
|
|
|
@ -321,7 +321,8 @@ public class IndexWriter {
|
|||
return mergeFactor;
|
||||
}
|
||||
|
||||
/** If non-null, information about merges will be printed to this.
|
||||
/** If non-null, information about merges and a message when
|
||||
* maxFieldLength is reached will be printed to this.
|
||||
*/
|
||||
public void setInfoStream(PrintStream infoStream) {
|
||||
this.infoStream = infoStream;
|
||||
|
@ -404,6 +405,7 @@ public class IndexWriter {
|
|||
public void addDocument(Document doc, Analyzer analyzer) throws IOException {
|
||||
DocumentWriter dw =
|
||||
new DocumentWriter(ramDirectory, analyzer, similarity, maxFieldLength);
|
||||
dw.setInfoStream(infoStream);
|
||||
String segmentName = newSegmentName();
|
||||
dw.addDocument(segmentName, doc);
|
||||
synchronized (this) {
|
||||
|
|
Loading…
Reference in New Issue