LUCENE-829: close done readers in contrib/benchmark.

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@518822 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Doron Cohen 2007-03-16 01:16:56 +00:00
parent b9edb2867f
commit 977e729685
4 changed files with 17 additions and 3 deletions

View File

@ -79,6 +79,7 @@ public class ReutersDocMaker extends BasicDocMaker {
while ((line = reader.readLine()) != null) {
bodyBuf.append(line).append(' ');
}
reader.close();
addBytes(f.length());

View File

@ -26,8 +26,10 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;
import java.util.Properties;
import java.util.zip.GZIPInputStream;
@ -159,7 +161,8 @@ public class TrecDocMaker extends BasicDocMaker {
read("</DOCHDR>",null,false,false);
// 6. collect until end of doc
sb = read("</DOC>",null,false,true);
// this is the next document, so parse it
// this is the next document, so parse it
// TODO use a more robust html parser (current one aborts parsing quite easily).
HTMLParser p = new HTMLParser(new StringReader(sb.toString()));
// title
String title = p.getTitle();
@ -175,11 +178,18 @@ public class TrecDocMaker extends BasicDocMaker {
bodyBuf.append(c,0,n);
}
}
r.close();
addBytes(bodyBuf.length());
DocData dd = new DocData();
dd.date = dateFormat.parse(dateStr.trim());
try {
dd.date = dateFormat.parse(dateStr.trim());
} catch (ParseException e) {
// do not fail test just because a date could not be parsed
System.out.println("ignoring date parse exception (assigning 'now') for: "+dateStr);
dd.date = new Date(); // now
}
dd.name = name;
dd.title = title;
dd.body = bodyBuf.toString();

View File

@ -275,6 +275,8 @@ public class StandardBenchmarker extends AbstractBenchmarker implements Benchmar
{
body.append(line).append(' ');
}
reader.close();
Date date = format.parse(dateStr.trim());
doc.add(new Field("date", DateTools.dateToString(date, DateTools.Resolution.SECOND), Field.Store.YES, Field.Index.UN_TOKENIZED));

View File

@ -135,6 +135,7 @@ public class ExtractReuters
buffer.setLength(0);
}
}
reader.close();
}
catch (