[
https://issues.apache.org/jira/browse/TINKERPOP-3295?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18146360#comment-18146360
]
ASF GitHub Bot commented on TINKERPOP-3295:
-------------------------------------------
kenhuuu commented on code in PR #3802:
URL: https://github.com/apache/tinkerpop/pull/3802#discussion_r4603870951
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AddVertexStep.java:
##########
@@ -106,6 +108,35 @@ public void configure(final Object... keyValues) {
}
}
+ /**
+ * Adds a vertex for each traverser that a bulked traverser represents.
+ */
+ @Override
+ protected Traverser.Admin<Vertex> processNextStart() {
+ final Traverser.Admin<S> traverser = nextUnbulkedStart();
+ return traverser.split(this.map(traverser), this);
+ }
+
+ private Traverser.Admin<S> nextUnbulkedStart() {
+ if (null == this.bulkedStart) {
+ final Traverser.Admin<S> start = this.starts.next();
+ if (start.bulk() <= 1L) return start;
+ this.bulkedStart = start;
+ this.remainingBulk = start.bulk();
+ }
+ final Traverser.Admin<S> unit = this.bulkedStart.split();
+ unit.setBulk(1L);
+ if (--this.remainingBulk == 0L) this.bulkedStart = null;
+ return unit;
+ }
+
+ @Override
+ public void reset() {
Review Comment:
Nit: You might want to add a test that uses a step that actually `reset()`s.
Something like the following on an empty graph would work since it uses
`local()`:
```
g.V().label().order().barrier().
local(__.addV("animal").
property("source", __.identity()).limit(1))
```
You'd have to setup the empty graph in a way that would have multiple
traversers with the same label for this to work so there is probably a simpler
equivalent.
> inject() and addV() has bulking issues
> --------------------------------------
>
> Key: TINKERPOP-3295
> URL: https://issues.apache.org/jira/browse/TINKERPOP-3295
> Project: TinkerPop
> Issue Type: Bug
> Components: process
> Affects Versions: 3.7.7
> Reporter: Stephen Mallette
> Priority: Critical
>
> {code}
> gremlin> g.inject(1,1).addV('X').id()
> ==>0
> ==>0
> gremlin> g.V().count()
> ==>1
> {code}
> the example is for {{addV()}} and the {{inject()}} start step but
> investigation should probably cover other variations of mutations like,
> {{addE()}}, {{mergeV/E()}} and {{drop()}} and steps and mid-traversal
> {{inject()}}.
> Should also cover cases like: {{g.inject(1, 1).addV('X').property(T.id,
> 'same')}}
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)