Skip to content

Conversation

@triceo
Copy link
Collaborator

@triceo triceo commented Jan 23, 2026

This will allow complex filtering that will be necessary to make containingAnyOf() work.

Copilot AI review requested due to automatic review settings January 23, 2026 11:55
@triceo triceo linked an issue Jan 23, 2026 that may be closed by this pull request
@triceo triceo added this to the v1.31.0 milestone Jan 23, 2026
@triceo triceo requested review from Copilot and zepfred and removed request for Copilot January 23, 2026 11:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request converts the indexer's external iteration pattern (using UniqueRandomSequence.pick() and remove()) to an internal iteration pattern using the standard Java Iterator interface. This refactoring prepares the codebase for implementing complex filtering required by the containingAnyOf() functionality.

Changes:

  • Replaced UniqueRandomSequence interface and its implementations with UniqueRandomIterator implementing the standard Iterator interface
  • Updated all indexers to provide randomIterator() methods instead of requiring external access patterns
  • Moved iterator implementations from neighborhood.stream.enumerating.common to bavet.common.index package
  • Simplified the API by removing ElementAccessor abstraction layers (ListBasedElementAccessor and IndexerBasedElementAccessor)

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
DefaultUniqueRandomSequenceTest.java Deleted - replaced with reduced test coverage in DefaultUniqueRandomIteratorTest.java
SelectionProbabilityTest.java Moved to bavet.common.index package and updated to use new iterator API
FilteredUniqueRandomIteratorTest.java Moved and renamed from FilteredUniqueRandomSequenceTest.java, updated for iterator pattern
DefaultUniqueRandomIteratorTest.java New test file with basic iterator tests, significantly reduced coverage compared to original
UniLeftDatasetInstance.java Updated parameter name from rightSequenceStoreIndex to rightIteratorStoreIndex
UniLeftDataset.java Updated parameter name to match instance class
LeftTerminalUniEnumeratingStream.java Refactored to inline store index reservations
ListBasedElementAccessor.java Deleted - no longer needed with direct iterator access
IndexerBasedElementAccessor.java Deleted - no longer needed with direct iterator access
FilteredUniqueRandomSequence.java Deleted - replaced by FilteredUniqueRandomIterator
AbstractRightDatasetInstance.java Changed from building sequences to returning iterators directly
AbstractLeftDatasetInstance.java Simplified by removing UnwrappingIterator and using direct iterator access
BiRandomMoveIterator.java Updated to use iterator pattern instead of sequence pattern
UniqueRandomIterator.java New interface replacing UniqueRandomSequence, implementing standard Iterator
RandomAccessIndexerBackend.java Added randomIterator methods returning new iterator types
LinkedListIndexerBackend.java Added randomIterator methods that throw UnsupportedOperationException
Indexer.java Added randomIterator method signatures to interface
FilteredUniqueRandomIterator.java New implementation of filtered random iteration using Iterator pattern
EqualIndexer.java Implemented randomIterator methods delegating to downstream indexers
DefaultUniqueRandomIterator.java New implementation replacing DefaultUniqueRandomSequence with Iterator pattern
ContainingIndexer.java Implemented randomIterator methods delegating to downstream indexers
ContainingAnyOfIndexer.java Added randomIterator methods throwing UnsupportedOperationException
ContainedInIndexer.java Implemented randomIterator methods with iterator function abstraction
ComparisonIndexer.java Implemented randomIterator methods with support for single and multiple indexers
Comments suppressed due to low confidence (1)

core/src/main/java/ai/timefold/solver/core/impl/bavet/common/index/UniqueRandomIterator.java:55

  • The javadoc for the remove() method is misleading. It states "Removes a random element in the underlying list which has not already been removed." However, this is standard Iterator.remove() behavior - it removes the element that was most recently returned by next(), not a random element. The documentation should clarify that it removes the last element returned by next(), consistent with the standard Iterator contract.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
63.9% Coverage on New Code (required ≥ 70%)

See analysis details on SonarQube Cloud

@triceo triceo removed this from the v1.31.0 milestone Jan 23, 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.

Indexing: random iterators instead of direct access

1 participant