Methods Summary |
---|
public int | doLogic()
int res = 0;
boolean closeReader = false;
// open reader or use existing one
IndexReader ir = getRunData().getIndexReader();
if (ir == null) {
Directory dir = getRunData().getDirectory();
ir = IndexReader.open(dir);
closeReader = true;
//res++; //this is confusing, comment it out
}
// optionally warm and add num docs traversed to count
if (withWarm()) {
Document doc = null;
for (int m = 0; m < ir.maxDoc(); m++) {
if (!ir.isDeleted(m)) {
doc = ir.document(m);
res += (doc==null ? 0 : 1);
}
}
}
if (withSearch()) {
res++;
IndexSearcher searcher = new IndexSearcher(ir);
QueryMaker queryMaker = getQueryMaker();
Query q = queryMaker.makeQuery();
Hits hits = searcher.search(q);
//System.out.println("searched: "+q);
if (withTraverse()) {
Document doc = null;
if (hits != null && hits.length() > 0) {
for (int m = 0; m < hits.length(); m++) {
int id = hits.id(m);
res++;
if (withRetrieve()) {
doc = ir.document(id);
res += (doc==null ? 0 : 1);
}
}
}
}
searcher.close();
}
if (closeReader) {
ir.close();
}
return res;
|
public abstract org.apache.lucene.benchmark.byTask.feeds.QueryMaker | getQueryMaker()Return query maker used for this task.
|
public abstract boolean | withRetrieve()Return true if, with search & results traversing, docs should be retrieved.
|
public abstract boolean | withSearch()Return true if search should be performed.
|
public abstract boolean | withTraverse()Return true if, with search, results should be traversed.
|
public abstract boolean | withWarm()Return true if warming should be performed.
|