Repository navigation
Write a map() that is all of a project().by() as the traversal it wraps - #2475
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 14.x #2475 +/- ##
==========================================
+ Coverage 93.57% 93.59% +0.01%
==========================================
Files 279 279
Lines 7880 7894 +14
Branches 885 885
==========================================
+ Hits 7374 7388 +14
Misses 313 313
Partials 193 193 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…n as Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… built, not where it is written Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
danielcweber
force-pushed
the
optimize/unwrap-map-in-project-by
branch
from
September 30, 2026 12:53
aca13c8 to
59a435a
Compare
map() as the only step of a project().by() traversalmap() that is all of a project().by() as the traversal it wraps
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.
Project(...).By(...)no longer writes amap()that is all of theby()traversal:By(__ => __.Map(__ => __.Out<WorksFor>().Count()))is emitted asby(__.out('WorksFor').count())instead ofby(__.map(__.out('WorksFor').count())).by()only takes the first result of its traversal for the one element it is given, which is all thatmap()does, so the step only added length and one more step to evaluate per element. The shape comes up with helpers like "the first value of a property per element", which need themap()in the middle of a query and not once they end up in aby(). Alocal()in the same position was already left out. Both are now handled in one place, in any nesting:By(__ => __.Local(__ => __.Map(...)))andBy(__ => __.Map(__ => __.Map(...)))end up without either.Changes
Project(...).By(...): when the traversal of aby()is nothing but amap()or alocal(), the traversal inside it takes its place, repeatedly. This happens where theby()is built.by()of aproject()is written as it is. Leaving out alocal()there has moved to the operator above.Notes
values('key')with a single key keeps themap()orlocal()around it. TinkerPop'sByModulatorOptimizationStrategyturnsby(__.values('key'))intoby('key'), which fails on a property with more than one value, whileby(__.map(__.values('key')))takes the first one. This now holds forlocal()as well:By(__ => __.Local(__ => __.Values(x => x.Name)))was emitted asby(__.values('Name'))and is now emitted asby(__.local(__.values('Name'))). It is a commit of its own.ProjectStep.ByTraversalSteppushed directly viaConfigureStepsis written as pushed, including alocal()inside it, which the serializer used to leave out.EnableEmptyProjectionValueProtection, themap()orlocal()is now gone beforelimit(1).fold()is appended, soby(__.local(t).limit(1).fold())becomesby(t.limit(1).fold()). The value is the same: the first result oft, folded. One existing snapshot changes for this reason.by()ofproject()(one element, bulk 1, first result), read in the 3.4 and 3.7 sources, not on a run against a server. The new tests are serialization tests only.🤖 Generated with Claude Code