Hmm, but in Lucene, a SortedIntDocSet should never contain duplicates?

Also, there are multiple binary searches in that source ... I'm not
sure which one(s) you're trying to speed up, and I don't see how
adding more conditionals would make the code faster.

Mike McCandless

http://blog.mikemccandless.com


On Wed, Aug 6, 2014 at 12:40 AM, Fuxiang Chen <[email protected]> wrote:
> Dear Lucene Developers,
>
> In the source file "SortedIntDocSet.java", the code fragment that is used
> for binary search can have its speed improved by adding two more conditions.
>
> Original Code
> --------------------
>         if (docb < doca) {
>           low = mid+1;
>         }
>         else if (docb > doca) {
>           high = mid-1;
>         }
>
>
> Changed Code
> ----------------------
>         if (docb < doca) {
>           low = mid+1;
>         }
>         else if (docb > doca) {
>           high = mid-1;
>         else if (low != mid)     //Equal but range is not fully scanned
>           high = mid; //Set upper bound to current number and rescan
>         else //Equal and full range is scanned
>           return mid;
>
> Reference: http://stackoverflow.com/questions/6676360/
>
>
> --
> Warmest Regards,
>     Fuxiang

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to