Skip to content

Implement existing TODO: binary search optimization in SortedStreamSetObjectsList #3137

@ezylopx5

Description

@ezylopx5

Problem

SortedStreamSetObjectsList maintains a sorted list but currently:

  • Uses LinkedList, which does not provide efficient random access
  • Uses linear scans for insertion and removal
  • Contains explicit TODO comments requesting binary search optimization

This leads to inefficient behavior as metadata size grows.

Solution

  • Replace LinkedList with ArrayList to enable efficient random access
  • Use Collections.binarySearch() to locate insertion and removal positions
  • Correctly handle duplicate orderId cases (since compareTo uses orderId while equals uses objectId)
  • Add tests covering relevant edge cases

Changes

File Change
SortedStreamSetObjectsList.java Switch to ArrayList, implement binary search logic
SortedStreamSetObjectsListTest.java Add tests for insertion and removal behavior

Notes

  • Behavior-preserving change
  • Directly implements existing TODO comments in the code

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions