Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raxLowWalk , divide and conquer instead of linear scan #24

Open
anunique opened this issue Oct 30, 2019 · 1 comment
Open

raxLowWalk , divide and conquer instead of linear scan #24

anunique opened this issue Oct 30, 2019 · 1 comment

Comments

@anunique
Copy link

what about something like:
int bleh = h->size;
do{
bleh/=2;
if (v[j] < s[i])
{
j+=bleh;
}
else if (v[j] > s[i])
{
j-=bleh;
}
else
{
//got hit
}
}while (bleh>1);

divide and conquer scanning instead of linear?

        /* Even when h->size is large, linear scan provides good
         * performances compared to other approaches that are in theory
         * more sounding, like performing a binary search. */
        for (j = 0; j < h->size; j++) {
            if (v[j] == s[i]) break;
        }
@antirez
Copy link
Owner

antirez commented Oct 30, 2019

I tried and it was slower, but actually later I found pathological cases where it could help. What to do IMHO is to test it a lot and find the right threshold when to switch to binary search.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants