Hello all, The function TopDocs.merge uses PriorityQueue in a pattern: pop, update value (ref.hitIndex++), add. JavaDocs for PriorityQueue.updateTop <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.lucene/lucene-core/5.2.0/org/apache/lucene/util/PriorityQueue.java#204> say that using this function instead should be at least twice as fast. Would a patch like the one attached be acceptable? Should I create a JIRA issue for it? I tried comparing the time taken to run ant test before and after the patch was applied, but apparently it was affected by random factors more than it was affected by the patch, so I don't have any performance numbers to show if / how much it changed. Is there any standard way of benchmarking? Regards, Daniel
Index: core/src/java/org/apache/lucene/search/TopDocs.java =================================================================== --- core/src/java/org/apache/lucene/search/TopDocs.java (wersja 1710387) +++ core/src/java/org/apache/lucene/search/TopDocs.java (kopia robocza) @@ -272,7 +272,7 @@ int hitUpto = 0; while (hitUpto < numIterOnHits) { assert queue.size() > 0; - ShardRef ref = queue.pop(); + ShardRef ref = queue.top(); final ScoreDoc hit = shardHits[ref.shardIndex].scoreDocs[ref.hitIndex++]; hit.shardIndex = ref.shardIndex; if (hitUpto >= start) { @@ -286,7 +286,9 @@ if (ref.hitIndex < shardHits[ref.shardIndex].scoreDocs.length) { // Not done with this these TopDocs yet: - queue.add(ref); + queue.updateTop(); + } else { + queue.pop(); } } }
--------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org