Skip to content

perf(metadata): optimize SortedStreamSetObjectsList using binary search#3138

Closed
ezylopx5 wants to merge 1 commit intoAutoMQ:mainfrom
ezylopx5:ezylopx5/optimize-sorted-stream-set-objects
Closed

perf(metadata): optimize SortedStreamSetObjectsList using binary search#3138
ezylopx5 wants to merge 1 commit intoAutoMQ:mainfrom
ezylopx5:ezylopx5/optimize-sorted-stream-set-objects

Conversation

@ezylopx5
Copy link
Copy Markdown

@ezylopx5 ezylopx5 commented Jan 6, 2026

Closes #3137

Problem

SortedStreamSetObjectsList maintains a sorted list but currently:

  • Uses LinkedList, which has O(n) random access
  • Uses linear scans for insertion and removal
  • Contains explicit TODOs requesting binary search optimization

Solution

  • Replace LinkedList with ArrayList for O(1) random access
  • Use Collections.binarySearch() to find insertion/removal positions in O(log n)
  • Handle duplicate orderId cases correctly
  • Add tests covering edge cases

Testing

Added unit tests for:

  • Binary search insertion at beginning, middle, end
  • Removal from various positions
  • Duplicate orderId handling
  • Large list correctness (1000 elements)

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jan 6, 2026

CLA assistant check
All committers have signed the CLA.

@superhx
Copy link
Copy Markdown
Collaborator

superhx commented Mar 30, 2026

Sorry, I missed this PR. It looks like this issue has been fixed by #3215.

@superhx superhx closed this Mar 30, 2026
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

Successfully merging this pull request may close these issues.

Implement existing TODO: binary search optimization in SortedStreamSetObjectsList

3 participants