Skip to content

Commit

Permalink
Merge branch '3.5-dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
spmallette committed Feb 16, 2022
2 parents 4fc5a80 + c5f56a4 commit f8af061
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ This release also includes changes from <<release-3-4-13, 3.4.13>>.
* Fixed support for `SeedStrategy` in the Gremlin Grammar.
* Fixed bug in `Translator` of `gremlin-javascript` around array translation.
* Fixed bugs in `PythonTranslator`, `JavascriptTranslator` and `DotNetTranslator` when translating `TraversalStrategy` objects to Javascript.
* Fixed bug in `DefaultTraversal.clone()` where the resulting `Traversal` copy could not be re-iterated.
* Prevented exception with `hasLabel(null)` and `hasKey(null)` and instead filter away traversers as these structural components can't ever be null.
* Improved handling of `null` when passed to `P` predicates.
* Handled `null` for mathematical reducing operations of `sum()`, `mean()`, `max()` and `min()`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ public DefaultTraversal<S, E> clone() {
clone.steps.add(clonedStep);
}
clone.finalEndStep = clone.getEndStep();
clone.closed = false;
return clone;
} catch (final CloneNotSupportedException e) {
throw new IllegalStateException(e.getMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public void shouldCloneTraversalCorrectly() {
assertEquals(1, original.getSideEffects().<Integer>get("m").intValue());
assertEquals(2, clone.getSideEffects().<Integer>get("m").intValue());
assertNotSame(original.bytecode, clone.bytecode);
assertEquals(original.closed, clone.closed);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.BulkSet;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.VerificationException;
import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Graph;
Expand All @@ -53,6 +54,7 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

Expand Down Expand Up @@ -80,6 +82,26 @@ public void shouldNeverPropagateANoBulkTraverser() {
}
}

@Test
@LoadGraphWith(MODERN)
public void shouldCloneTraversalForReuse() {
final DefaultTraversal<Vertex, Long> t = (DefaultTraversal) g.V().count();
assertEquals(6, t.next().intValue());
assertThat(t.hasNext(), is(false));

final DefaultTraversal<Vertex, Long> t1 = t.clone();
assertEquals(6, t1.next().intValue());
assertThat(t1.hasNext(), is(false));

final DefaultTraversal<Vertex, Long> t2 = t.clone();
assertEquals(6, t2.next().intValue());
assertThat(t2.hasNext(), is(false));

final DefaultTraversal<Vertex, Long> t3 = t1.clone();
assertEquals(6, t3.next().intValue());
assertThat(t3.hasNext(), is(false));
}

@Test
@LoadGraphWith(MODERN)
public void shouldFilterOnIterate() {
Expand Down

0 comments on commit f8af061

Please sign in to comment.