}
FileSystem fs = FileSystem.get(new Configuration());
RetrievalEnvironment env = new RetrievalEnvironment(indexPath, fs);
env.initialize(true);
DocnoMapping docnoMapping = env.getDocnoMapping();
SmallAdaptiveRanker ranker = new SmallAdaptiveRanker(postingsIndexPath, fs);
//Parse queries and find integer codes for the query terms.
HMapIV<int[]> queries = QueryUtility.queryToIntegerCode(env, queryPath);
//Evaluate queries and/or write the results to an output file
int[] newDocidsLookup = null;
FSDataOutputStream output = null;
if(writeOutput) {
final SpamPercentileScore spamScores = new SpamPercentileScore();
spamScores.initialize(options.getOptionValue(OptionManager.SPAM_PATH), fs);
newDocidsLookup = DocumentUtility.reverseLookupSpamSortedDocids(DocumentUtility.spamSortDocids(spamScores));
output = fs.create(new Path(options.getOptionValue(OptionManager.OUTPUT_PATH)));
output.write(("<parameters>\n").getBytes());
}
// DocnoMapping docnoMapping = env.getDocnoMapping();
for (int qid: queries.keySet()) {
int[] qterms = queries.get(qid);
if(qterms.length == 0) {
continue;
}
long start = System.nanoTime();
int[] docs = ranker.rank(qterms, hits);
System.out.println(System.nanoTime() - start);
if(writeOutput) {
for(int i = 0; i < docs.length; i++) {
if(docs[i] != 0) {
output.write(("<judgment qid=\"" + qid +
"\" doc=\"" + docnoMapping.getDocid(newDocidsLookup[docs[i]]) +
"\" grade=\"0\" />\n").getBytes());
}
}
}
}