File indexDir = new File(props.getProperty("lucene.index.dir", DEFAULT_LUCENE_INDEX_DIR));
IndexWriter writer = new IndexWriter(indexDir,
new StandardAnalyzer(), true);
EventDAO eventDAO = new EventDAOImpl();
System.out.println("Counting events...");
long t1 = System.currentTimeMillis();
long events = 0;
try {
sessionStrategy.beginTransaction();
events = eventDAO.count();
sessionStrategy.commitTransaction();
} finally {
sessionStrategy.rollbackIfActive();
}
long t2 = System.currentTimeMillis();
System.out.println("...done (" + events + " events). Took " + (t2 - t1) + "ms");
System.out.println("\nIndexing to directory '" + indexDir.getAbsolutePath() + "'...");
t1 = System.currentTimeMillis();
DateFormat dateFormat = DateFormat.getDateInstance();
int start = 0;
while (start < events) {
System.out.println("Working on chunk starting at " + start + " out of " + events);
List<Event> chunk = Collections.emptyList();
try {
sessionStrategy.beginTransaction();
chunk = eventDAO.findAll(start, CHUNK_SIZE);
sessionStrategy.commitTransaction();
} finally {
sessionStrategy.rollbackIfActive();
}