Skip to content

Use binary search over cumulative weights for distribution lookups#11

Open
wendigo wants to merge 1 commit into
trinodb:masterfrom
wendigo:user/serafin/binary-search
Open

Use binary search over cumulative weights for distribution lookups#11
wendigo wants to merge 1 commit into
trinodb:masterfrom
wendigo:user/serafin/binary-search

Conversation

@wendigo

@wendigo wendigo commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@cla-bot cla-bot Bot added the cla-signed label Jun 23, 2026
@wendigo wendigo requested a review from raunaqmorarka June 23, 2026 08:26
int low = 0;
int high = weights.size() - 1;
int result = -1;
while (low <= high) {

@raunaqmorarka raunaqmorarka Jun 23, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually linear scans are faster than binary search for very small lists, does this actually show a gain ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants