Skip to content

Improve sorting logic in NeighborArray #16321

Description

@rajat315315

Description

The legacy sorting logic in NeighborArray below takes long N^2 in worst case, as it is a simple insertion sort and pushes/copies the rest of the array towards the end for each uncheckedIndex.

int[] sort(RandomVectorScorer scorer) throws IOException {

I think it has a lot of scope for improvement and I'm attaching a PR below and opening a discussion for same.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions