Repository navigation
4.x: Add Streamable count operator - #8396
Merged
Merged
Conversation
🐷 TruffleHog + Entropy Beauty ScanAverage entropy of changed code: 4.56 bits/char Changed files entropy: ✅ No secrets or suspicious high-entropy strings found. Mid-4 beauty heuristic in action — powered by our entropy chats! 😊 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.x #8396 +/- ##
============================================
+ Coverage 98.58% 98.63% +0.04%
- Complexity 7169 7170 +1
============================================
Files 826 826
Lines 50972 50973 +1
Branches 6944 6944
============================================
+ Hits 50251 50275 +24
+ Misses 482 474 -8
+ Partials 239 224 -15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
akarnokd
approved these changes
Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related #8299.
Summary
Add
Streamable.count()withSingle<Long>as its result type.The implementation composes the existing
collect(Collectors.counting())andlastOrError()operators. It returns 0 for an empty source, counts all items otherwise, and propagates upstream errors.Internal record compatibility
Adding this method makes five existing record component accessors incompatible with
Streamable.count():StreamableRange,StreamableRangeLong,StreamableIntervalRange,StreamableSkip, andStreamableTakeeach had acountcomponent whose generated accessor returnedintorlong.Their top-level record components are renamed to
itemCount. Constructor parameter types and order, stream calculations, and nested streamer fields are unchanged.Tests
Added
StreamableCountTestfor empty sources, multiple items, and upstream error propagation.Test-first evidence: before adding
count(), the new test class failed compilation with three missing-method errors. The first implementation then exposed the five record-accessor return-type conflicts described above; the internal component renames resolve them without changing constructor signatures.The following focused tests pass on Zulu JDK 26:
StreamableCountTestStreamableJustTestStreamableRangeTestStreamableIntervalRangeTestStreamableSkipTestStreamableTakeTestCheckParamValidationNamingTest.checkStreamableTotal: 91 tests, 0 failures/errors, 6 existing skips.
checkstyleMainandcheckstyleTestalso pass. The full suite was not run for this separate focused addition.AI disclosure: Kimi Code assisted with API analysis, implementation, record-conflict analysis, tests, local verification, and this PR description. The failing-before compilation results, final affected tests, and seven-file diff were checked.
CI result for a19acc4
All checks pass: Validation, default build, JDK 27, JDK 28, the security scan,
codecov/patch, andcodecov/project.