String[] parts = property.split(",");
limit = Integer.parseInt(parts[0]);
minTime = Integer.parseInt(parts[1]);
}
Faceter faceter = facetingManager.createFaceter();
long startTime = System.currentTimeMillis();
PriorityQueue<ScoredMatch> top = new PriorityQueue<ScoredMatch>(n, ScoredMatch.INVERSE_ORDER);
int totalCount = 0;
Iterable<ScoredMatch> matches = matcher.decode(rawMatches, query.getRoot().getBoostedNorm());
MatchFilter facetFilter = null;
if (query.getFilteringFacets() != null) {
facetFilter = facetingManager.getFacetFilter(query.getFilteringFacets());
}
for (ScoredMatch match : matches) {
if (docFilter.apply(match.getDocId())) {
if (facetFilter == null || facetFilter.matches(match.getDocId(), match.getScore(), query.getNow(), query.getVars())) {
if (query.getRangeFilter() == null || query.getRangeFilter().matches(match.getDocId(), match.getScore(), query.getNow(), query.getVars())) {
rescore(match, query, scoringFunctionIndex);
faceter.computeDocument(match.getDocId());
if (top.size() < n || top.peek().compareTo(match) > 0) {
ScoredMatch newMatch;
if (top.size() == n) {
newMatch = top.remove();
newMatch.getDocId().updateFrom(match.getDocId());
newMatch.setScore(match.getScore());
} else {
newMatch = new ScoredMatch(match.getScore(), match.getDocId().copy(256));
}
top.add(newMatch);
}
totalCount++;
if (totalCount > limit) {
if (System.currentTimeMillis() - startTime > minTime) {
totalCount = -totalCount;
break;
}
}
}
}
}
}
List<ScoredMatch> list = Lists.newArrayList(new ScoredMatch[top.size()]);
for (int i = top.size()-1; i >= 0; i--) {
list.set(i, top.poll());
}
return new SimpleScoredDocIds(list, n, totalCount, faceter.getFacets());
}