You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2015/02/12 00:13:18 UTC
[2/3] incubator-tinkerpop git commit: INSANE COMMIT HERE ---
Traversals are now fully serializable as all lambda references have been
gutted -- back to Java7 :). What this means is that you can now
.submit(g.compute()) Gremlin-Java traversals across the
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/ReducingBarrierStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/ReducingBarrierStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/ReducingBarrierStep.java
index 4b807ed..35a293a 100644
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/ReducingBarrierStep.java
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/ReducingBarrierStep.java
@@ -18,13 +18,15 @@
*/
package com.tinkerpop.gremlin.process.graph.traversal.step.util;
+import com.tinkerpop.gremlin.process.FastNoSuchElementException;
import com.tinkerpop.gremlin.process.Step;
import com.tinkerpop.gremlin.process.Traversal;
import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.traversal.step.Reducing;
import com.tinkerpop.gremlin.process.traversal.step.AbstractStep;
-import com.tinkerpop.gremlin.process.FastNoSuchElementException;
+import com.tinkerpop.gremlin.process.traversal.step.Reducing;
+import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
+import java.io.Serializable;
import java.util.function.BiFunction;
import java.util.function.Supplier;
@@ -71,7 +73,7 @@ public abstract class ReducingBarrierStep<S, E> extends AbstractStep<S, E> {
while (this.starts.hasNext())
seed = this.reducingBiFunction.apply(seed, this.starts.next());
this.done = true;
- return this.getTraversal().asAdmin().getTraverserGenerator().generate(Reducing.FinalGet.tryFinalGet(seed), (Step) this, 1l);
+ return TraversalHelper.getRootTraversal(this.getTraversal()).getTraverserGenerator().generate(Reducing.FinalGet.tryFinalGet(seed), (Step) this, 1l);
}
@Override
@@ -83,7 +85,7 @@ public abstract class ReducingBarrierStep<S, E> extends AbstractStep<S, E> {
///////
- public static class ObjectBiFunction<S, E> implements BiFunction<E, Traverser<S>, E> { // Cloneable {
+ public static class ObjectBiFunction<S, E> implements BiFunction<E, Traverser<S>, E>, Serializable {
private final BiFunction<E, S, E> biFunction;
@@ -100,13 +102,6 @@ public abstract class ReducingBarrierStep<S, E> extends AbstractStep<S, E> {
return this.biFunction.apply(seed, traverser.get());
}
- /*@Override
- public ObjectBiFunction<S, E> clone() throws CloneNotSupportedException {
- final ObjectBiFunction<S, E> clone = (ObjectBiFunction<S, E>) super.clone();
- clone.biFunction = CloneableLambda.tryClone(this.biFunction);
- return clone;
-
- }*/
}
///////
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/SupplyingBarrierStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/SupplyingBarrierStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/SupplyingBarrierStep.java
index 4153c85..f9b8696 100644
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/SupplyingBarrierStep.java
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/SupplyingBarrierStep.java
@@ -18,29 +18,24 @@
*/
package com.tinkerpop.gremlin.process.graph.traversal.step.util;
+import com.tinkerpop.gremlin.process.FastNoSuchElementException;
import com.tinkerpop.gremlin.process.Step;
import com.tinkerpop.gremlin.process.Traversal;
import com.tinkerpop.gremlin.process.Traverser;
import com.tinkerpop.gremlin.process.traversal.step.AbstractStep;
-import com.tinkerpop.gremlin.process.FastNoSuchElementException;
-
-import java.util.function.Supplier;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public abstract class SupplyingBarrierStep<S, E> extends AbstractStep<S, E> {
- public Supplier<E> supplier;
private boolean done = false;
public SupplyingBarrierStep(final Traversal.Admin traversal) {
super(traversal);
}
- public void setSupplier(final Supplier<E> supplier) {
- this.supplier = supplier;
- }
+ public abstract E supply();
@Override
public void reset() {
@@ -55,7 +50,7 @@ public abstract class SupplyingBarrierStep<S, E> extends AbstractStep<S, E> {
while (this.starts.hasNext())
this.starts.next();
this.done = true;
- return this.getTraversal().asAdmin().getTraverserGenerator().generate(this.supplier.get(), (Step) this, 1l);
+ return this.getTraversal().asAdmin().getTraverserGenerator().generate(this.supply(), (Step) this, 1l);
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/util/HasContainer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/util/HasContainer.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/util/HasContainer.java
index b4dfe37..468b4fd 100644
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/util/HasContainer.java
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/util/HasContainer.java
@@ -26,6 +26,7 @@ import com.tinkerpop.gremlin.structure.Property;
import com.tinkerpop.gremlin.structure.Vertex;
import com.tinkerpop.gremlin.structure.VertexProperty;
+import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
import java.util.function.BiPredicate;
@@ -33,7 +34,7 @@ import java.util.function.BiPredicate;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
-public final class HasContainer {
+public final class HasContainer implements Serializable {
public String key;
public BiPredicate predicate;
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/DefaultTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/DefaultTraversal.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/DefaultTraversal.java
index 80ff527..c2e93c8 100644
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/DefaultTraversal.java
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/DefaultTraversal.java
@@ -148,8 +148,6 @@ public class DefaultTraversal<S, E> implements Traversal.Admin<S, E> {
clone.strategies = this.strategies.clone(); // TODO: does this need to be cloned?
clone.lastEnd = null;
clone.lastEndCount = 0l;
- //clone.traversalEngine = this.traversalEngine.isPresent() ? Optional.of(this.traversalEngine.get()) : Optional.empty();
- //clone.locked = this.traversalEngine.isPresent();
for (final Step<?, ?> step : this.steps) {
final Step<?, ?> clonedStep = step.clone();
clonedStep.setTraversal(clone);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/StepPosition.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/StepPosition.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/StepPosition.java
index a511845..6c6675d 100644
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/StepPosition.java
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/StepPosition.java
@@ -18,10 +18,12 @@
*/
package com.tinkerpop.gremlin.process.traversal;
+import java.io.Serializable;
+
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
-public final class StepPosition {
+public final class StepPosition implements Serializable {
public int x; // step in traversal length
public int y; // depth in traversal nested tree
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/lambda/ConstantTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/lambda/ConstantTraversal.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/lambda/ConstantTraversal.java
new file mode 100644
index 0000000..6ddb9bb
--- /dev/null
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/lambda/ConstantTraversal.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.tinkerpop.gremlin.process.traversal.lambda;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class ConstantTraversal<S, E> extends AbstractLambdaTraversal<S, E> {
+
+ private final E end;
+
+ public ConstantTraversal(final E end) {
+ this.end = end;
+ }
+
+ @Override
+ public E next() {
+ return this.end;
+ }
+
+ @Override
+ public String toString() {
+ return "(" + this.end.toString() + ")";
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/lambda/OneTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/lambda/OneTraversal.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/lambda/OneTraversal.java
deleted file mode 100644
index 71e6aec..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/lambda/OneTraversal.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.process.traversal.lambda;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class OneTraversal<S> extends AbstractLambdaTraversal<S, Number> {
-
- private static final OneTraversal INSTANCE = new OneTraversal<>();
-
- @Override
- public Number next() {
- return 1.0d;
- }
-
- @Override
- public String toString() {
- return "1.0";
- }
-
- @Override
- public OneTraversal<S> clone() throws CloneNotSupportedException {
- return INSTANCE;
- }
-
- public static <A> OneTraversal<A> instance() {
- return INSTANCE;
- }
-
-
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/step/ElementFunctionComparator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/step/ElementFunctionComparator.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/step/ElementFunctionComparator.java
index 6e75f60..237ee4d 100644
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/step/ElementFunctionComparator.java
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/step/ElementFunctionComparator.java
@@ -20,13 +20,14 @@ package com.tinkerpop.gremlin.process.traversal.step;
import com.tinkerpop.gremlin.structure.Element;
+import java.io.Serializable;
import java.util.Comparator;
import java.util.function.Function;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
-public class ElementFunctionComparator<V> implements Comparator<Element> {
+public class ElementFunctionComparator<V> implements Comparator<Element>, Serializable{
private final Function<Element, V> elementFunction;
private final Comparator<V> valueComparator;
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/step/ExpandableStepIterator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/step/ExpandableStepIterator.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/step/ExpandableStepIterator.java
index 14fc2bd..171e7e4 100644
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/step/ExpandableStepIterator.java
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/step/ExpandableStepIterator.java
@@ -23,12 +23,13 @@ import com.tinkerpop.gremlin.process.Traverser;
import com.tinkerpop.gremlin.util.iterator.MultiIterator;
import com.tinkerpop.gremlin.process.util.TraverserSet;
+import java.io.Serializable;
import java.util.Iterator;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
-public final class ExpandableStepIterator<E> implements Iterator<Traverser.Admin<E>> {
+public final class ExpandableStepIterator<E> implements Iterator<Traverser.Admin<E>>, Serializable {
private final TraverserSet<E> traverserSet = new TraverserSet<>();
private final MultiIterator<Traverser.Admin<E>> traverserIterators = new MultiIterator<>();
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/util/TraversalRing.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/util/TraversalRing.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/util/TraversalRing.java
index bc451c5..5fc87d7 100644
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/util/TraversalRing.java
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/util/TraversalRing.java
@@ -21,6 +21,7 @@ package com.tinkerpop.gremlin.process.traversal.util;
import com.tinkerpop.gremlin.process.Traversal;
import com.tinkerpop.gremlin.process.traversal.lambda.IdentityTraversal;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -29,7 +30,7 @@ import java.util.List;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
-public final class TraversalRing<A, B> {
+public final class TraversalRing<A, B> implements Serializable {
private final IdentityTraversal<A, B> identityTraversal = new IdentityTraversal<>();
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traverser/TraverserGeneratorFactory.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traverser/TraverserGeneratorFactory.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traverser/TraverserGeneratorFactory.java
index cba2f53..aa6225c 100644
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traverser/TraverserGeneratorFactory.java
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traverser/TraverserGeneratorFactory.java
@@ -21,10 +21,12 @@ package com.tinkerpop.gremlin.process.traverser;
import com.tinkerpop.gremlin.process.Traversal;
import com.tinkerpop.gremlin.process.TraverserGenerator;
+import java.io.Serializable;
+
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
-public interface TraverserGeneratorFactory {
+public interface TraverserGeneratorFactory extends Serializable {
public TraverserGenerator getTraverserGenerator(final Traversal.Admin<?, ?> traversal);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ArrayListSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ArrayListSupplier.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ArrayListSupplier.java
new file mode 100644
index 0000000..ac694a9
--- /dev/null
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ArrayListSupplier.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.tinkerpop.gremlin.util.function;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.function.Supplier;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class ArrayListSupplier<A> implements Supplier<ArrayList<A>>, Serializable {
+ private static final ArrayListSupplier INSTANCE = new ArrayListSupplier();
+
+ private ArrayListSupplier() {
+ }
+
+ @Override
+ public ArrayList<A> get() {
+ return new ArrayList<>();
+ }
+
+ public static <A> ArrayListSupplier<A> instance() {
+ return INSTANCE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/BulkSetSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/BulkSetSupplier.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/BulkSetSupplier.java
new file mode 100644
index 0000000..0c5d25c
--- /dev/null
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/BulkSetSupplier.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.tinkerpop.gremlin.util.function;
+
+import com.tinkerpop.gremlin.process.util.BulkSet;
+
+import java.io.Serializable;
+import java.util.function.Supplier;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class BulkSetSupplier<A> implements Supplier<BulkSet<A>>, Serializable {
+ private static final BulkSetSupplier INSTANCE = new BulkSetSupplier();
+
+ private BulkSetSupplier() {
+ }
+
+ @Override
+ public BulkSet<A> get() {
+ return new BulkSet<>();
+ }
+
+ public static <A> BulkSetSupplier<A> instance() {
+ return INSTANCE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/CloningUnaryOperator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/CloningUnaryOperator.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/CloningUnaryOperator.java
new file mode 100644
index 0000000..51f9bf2
--- /dev/null
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/CloningUnaryOperator.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.tinkerpop.gremlin.util.function;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.function.UnaryOperator;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class CloningUnaryOperator<A> implements UnaryOperator<A>, Serializable {
+
+ private static final CloningUnaryOperator INSTANCE = new CloningUnaryOperator();
+
+ private CloningUnaryOperator() {
+ }
+
+ @Override
+ public A apply(final A a) {
+ if (a instanceof HashMap)
+ return (A) ((HashMap) a).clone();
+ else if (a instanceof HashSet)
+ return (A) ((HashSet) a).clone();
+ else
+ throw new IllegalArgumentException("The provided class is not registered for cloning: " + a.getClass());
+ }
+
+ public static <A> CloningUnaryOperator<A> instance() {
+ return INSTANCE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ConstantSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ConstantSupplier.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ConstantSupplier.java
new file mode 100644
index 0000000..5f2ee81
--- /dev/null
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ConstantSupplier.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.tinkerpop.gremlin.util.function;
+
+import java.io.Serializable;
+import java.util.function.Supplier;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class ConstantSupplier<A> implements Supplier<A>, Serializable {
+
+ private final A a;
+
+ public ConstantSupplier(final A a) {
+ this.a = a;
+ }
+
+ public A get() {
+ return this.a;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/HashMapSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/HashMapSupplier.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/HashMapSupplier.java
new file mode 100644
index 0000000..ca44bff
--- /dev/null
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/HashMapSupplier.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.tinkerpop.gremlin.util.function;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.Supplier;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class HashMapSupplier<K, V> implements Supplier<Map<K, V>>, Serializable {
+
+ private static final HashMapSupplier INSTANCE = new HashMapSupplier();
+
+ private HashMapSupplier() {
+ }
+
+ @Override
+ public HashMap<K, V> get() {
+ return new HashMap<>();
+ }
+
+ public static <K, V> HashMapSupplier<K, V> instance() {
+ return INSTANCE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/HashSetSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/HashSetSupplier.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/HashSetSupplier.java
new file mode 100644
index 0000000..7447bef
--- /dev/null
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/HashSetSupplier.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.tinkerpop.gremlin.util.function;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.function.Supplier;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class HashSetSupplier<A> implements Supplier<HashSet<A>>, Serializable {
+ private static final HashSetSupplier INSTANCE = new HashSetSupplier();
+
+ private HashSetSupplier() {
+ }
+
+ @Override
+ public HashSet<A> get() {
+ return new HashSet<>();
+ }
+
+ public static <A> HashSetSupplier<A> instance() {
+ return INSTANCE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/MeanNumberSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/MeanNumberSupplier.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/MeanNumberSupplier.java
new file mode 100644
index 0000000..ec94d16
--- /dev/null
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/MeanNumberSupplier.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.tinkerpop.gremlin.util.function;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.MeanStep;
+
+import java.io.Serializable;
+import java.util.function.Supplier;
+
+public final class MeanNumberSupplier implements Supplier<MeanStep.MeanNumber>, Serializable {
+
+ private static final MeanNumberSupplier INSTANCE = new MeanNumberSupplier();
+
+ private MeanNumberSupplier() {
+
+ }
+
+ @Override
+ public MeanStep.MeanNumber get() {
+ return new MeanStep.MeanNumber();
+ }
+
+ public static MeanNumberSupplier instance() {
+ return INSTANCE;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/ArrayIterator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/ArrayIterator.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/ArrayIterator.java
index cd82ad3..450378d 100644
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/ArrayIterator.java
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/ArrayIterator.java
@@ -20,12 +20,13 @@ package com.tinkerpop.gremlin.util.iterator;
import com.tinkerpop.gremlin.process.FastNoSuchElementException;
+import java.io.Serializable;
import java.util.Iterator;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
-public final class ArrayIterator<T> implements Iterator<T> {
+public final class ArrayIterator<T> implements Iterator<T>, Serializable {
private final T[] array;
private int current = 0;
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/DoubleIterator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/DoubleIterator.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/DoubleIterator.java
index e8ceaa5..840ccdf 100644
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/DoubleIterator.java
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/DoubleIterator.java
@@ -20,12 +20,13 @@ package com.tinkerpop.gremlin.util.iterator;
import com.tinkerpop.gremlin.process.FastNoSuchElementException;
+import java.io.Serializable;
import java.util.Iterator;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
-final class DoubleIterator<T> implements Iterator<T> {
+final class DoubleIterator<T> implements Iterator<T>, Serializable {
private final T a;
private final T b;
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/EmptyIterator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/EmptyIterator.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/EmptyIterator.java
new file mode 100644
index 0000000..af7f312
--- /dev/null
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/EmptyIterator.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.tinkerpop.gremlin.util.iterator;
+
+import com.tinkerpop.gremlin.process.FastNoSuchElementException;
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class EmptyIterator<S> implements Iterator<S>, Serializable {
+
+ private static final EmptyIterator INSTANCE = new EmptyIterator<>();
+
+ private EmptyIterator() {
+ }
+
+ @Override
+ public boolean hasNext() {
+ return false;
+ }
+
+ @Override
+ public S next() {
+ throw FastNoSuchElementException.instance();
+ }
+
+ public static <S> Iterator<S> instance() {
+ return INSTANCE;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/MultiIterator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/MultiIterator.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/MultiIterator.java
index 79ec1d3..c5dca2d 100644
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/MultiIterator.java
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/MultiIterator.java
@@ -20,6 +20,7 @@ package com.tinkerpop.gremlin.util.iterator;
import com.tinkerpop.gremlin.process.FastNoSuchElementException;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -27,7 +28,7 @@ import java.util.List;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
-public final class MultiIterator<T> implements Iterator<T> {
+public final class MultiIterator<T> implements Iterator<T>, Serializable {
private final List<Iterator<T>> iterators = new ArrayList<>();
private int current = 0;
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/SingleIterator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/SingleIterator.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/SingleIterator.java
index 1e661c4..178c6a9 100644
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/SingleIterator.java
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/SingleIterator.java
@@ -20,12 +20,13 @@ package com.tinkerpop.gremlin.util.iterator;
import com.tinkerpop.gremlin.process.FastNoSuchElementException;
+import java.io.Serializable;
import java.util.Iterator;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
-final class SingleIterator<T> implements Iterator<T> {
+final class SingleIterator<T> implements Iterator<T>,Serializable {
private final T t;
private boolean alive = true;
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyBranchTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyBranchTest.groovy b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyBranchTest.groovy
index 516df78..e100b67 100644
--- a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyBranchTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyBranchTest.groovy
@@ -24,6 +24,9 @@ import com.tinkerpop.gremlin.process.graph.traversal.step.branch.BranchTest
import com.tinkerpop.gremlin.structure.Vertex
import com.tinkerpop.gremlin.process.graph.traversal.__
+
+import static com.tinkerpop.gremlin.process.graph.traversal.__.label
+
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
@@ -33,10 +36,10 @@ public abstract class GroovyBranchTest {
@Override
public Traversal<Vertex, Object> get_g_V_branchXlabel_eq_person__a_bX_optionXa__ageX_optionXb__langX_optionXb__nameX() {
- g.V.branch { it.label() == 'person' ? 'a' : 'b' }
- .option('a', __.age)
- .option('b', __.lang)
- .option('b', __.name)
+ g.V.branch(__.label.is('person').count)
+ .option(1L, __.age)
+ .option(0L, __.lang)
+ .option(0L, __.name)
}
@Override
@@ -52,7 +55,7 @@ public abstract class GroovyBranchTest {
@Override
public Traversal<Vertex, Object> get_g_V_branchXlabel_eq_person__a_bX_optionXa__ageX_optionXb__langX_optionXb__nameX() {
- ComputerTestHelper.compute("g.V.branch { it.label() == 'person' ? 'a' : 'b' }.option('a', __.age).option('b', __.lang).option('b',__.name)", g);
+ ComputerTestHelper.compute("g.V.branch(__.label.is('person').count).option(1L, __.age).option(0L, __.lang).option(0L,__.name)", g);
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyChooseTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyChooseTest.groovy b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyChooseTest.groovy
index 5a99c9c..aca4c50 100644
--- a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyChooseTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyChooseTest.groovy
@@ -18,11 +18,9 @@
*/
package com.tinkerpop.gremlin.process.graph.traversal.step.branch
-import com.tinkerpop.gremlin.process.T
+import com.tinkerpop.gremlin.process.ComputerTestHelper
import com.tinkerpop.gremlin.process.Traversal
import com.tinkerpop.gremlin.process.graph.traversal.__
-import com.tinkerpop.gremlin.process.ComputerTestHelper
-import com.tinkerpop.gremlin.process.graph.traversal.step.branch.ChooseTest
import com.tinkerpop.gremlin.structure.Vertex
/**
@@ -34,25 +32,6 @@ public abstract class GroovyChooseTest {
public static class StandardTest extends ChooseTest {
@Override
- public Traversal<Vertex, String> get_g_V_chooseXname_length_5XoutXinX_name() {
- g.V.choose({ it.name.length() == 5 },
- __.out,
- __.in).name;
- }
-
- @Override
- public Traversal<Vertex, String> get_g_VX1X_chooseX0X_optionX0__outX_name(Object v1Id) {
- g.V(v1Id).choose { 0 }.option(0, __.out.name)
- }
-
- @Override
- public Traversal<Vertex, String> get_g_V_hasXlabel_personX_chooseXname_lengthX_optionX5__inX_optionX4__outX_optionX3__bothX_name() {
- g.V.has(T.label, 'person').choose {
- it.name.length()
- }.option(5, __.in).option(4, __.out).option(3, __.both).name
- }
-
- @Override
public Traversal<Vertex, Object> get_g_V_chooseXout_countX_optionX2L__nameX_optionX3L__valueMapX() {
g.V.choose(__.out.count).option(2L, __.values('name')).option(3L, __.valueMap())
}
@@ -61,23 +40,6 @@ public abstract class GroovyChooseTest {
public static class ComputerTest extends ChooseTest {
@Override
- public Traversal<Vertex, String> get_g_V_chooseXname_length_5XoutXinX_name() {
- ComputerTestHelper.compute("""g.V.choose({ it.name.length() == 5 },
- __.out(),
- __.in).name""", g);
- }
-
- @Override
- public Traversal<Vertex, String> get_g_VX1X_chooseX0X_optionX0__outX_name(Object v1Id) {
- ComputerTestHelper.compute("g.V(${v1Id}).choose { 0 }.option(0, __.out.name)", g);
- }
-
- @Override
- public Traversal<Vertex, String> get_g_V_hasXlabel_personX_chooseXname_lengthX_optionX5__inX_optionX4__outX_optionX3__bothX_name() {
- ComputerTestHelper.compute("g.V.has(T.label,'person').choose { it.name.length() }.option(5, __.in).option(4, __.out).option(3, __.both).name", g);
- }
-
- @Override
public Traversal<Vertex, Object> get_g_V_chooseXout_countX_optionX2L__nameX_optionX3L__valueMapX() {
ComputerTestHelper.compute("g.V.choose(__.out.count).option(2L, __.values('name')).option(3L, __.valueMap())", g);
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyRepeatTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyRepeatTest.groovy b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyRepeatTest.groovy
index 17e41e4..bc3cfc8 100644
--- a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyRepeatTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyRepeatTest.groovy
@@ -39,36 +39,11 @@ public abstract class GroovyRepeatTest {
}
@Override
- public Traversal<Vertex, String> get_g_VX1X_repeatXoutX_untilXloops_gte_2X_name(final Object v1Id) {
- g.V(v1Id).repeat(out()).until { it.loops() >= 2 }.name
- }
-
- @Override
- public Traversal<Vertex, Vertex> get_g_V_repeatXoutX_untilXloops_gte_2X() {
- g.V.repeat(out()).until { it.loops() >= 2 }
- }
-
- @Override
- public Traversal<Vertex, Vertex> get_g_V_repeatXoutX_untilXloops_gte_2X_emit() {
- g.V.repeat(out()).until { it.loops() >= 2 }.emit
- }
-
- @Override
- public Traversal<Vertex, Path> get_g_V_repeatXoutX_untilXloops_gte_2X_emit_path() {
- g.V.repeat(__.out).until { it.loops() >= 2 }.emit.path
- }
-
- @Override
public Traversal<Vertex, Path> get_g_V_repeatXoutX_timesX2X_emit_path() {
g.V.repeat(__.out).times(2).emit.path
}
@Override
- public Traversal<Vertex, String> get_g_V_repeatXoutX_untilXloops_gte_2X_repeatXinX_untilXloops_gte_2X_name() {
- g.V.repeat(__.out).until { it.loops() >= 2 }.repeat(__.in).until { it.loops() >= 2 }.name
- }
-
- @Override
public Traversal<Vertex, String> get_g_V_repeatXoutX_timesX2X_repeatXinX_timesX2X_name() {
g.V.repeat(__.out).times(2).repeat(__.in).times(2).name
}
@@ -84,11 +59,6 @@ public abstract class GroovyRepeatTest {
}
@Override
- public Traversal<Vertex, String> get_g_VX1X_untilXloops_gte_2X_repeatXoutX_name(Object v1Id) {
- g.V(v1Id).until { it.loops() >= 2 }.repeat(__.out).name
- }
-
- @Override
public Traversal<Vertex, String> get_g_VX1X_timesX2X_repeatXoutX_name(Object v1Id) {
g.V(v1Id).times(2).repeat(__.out).name
}
@@ -120,36 +90,11 @@ public abstract class GroovyRepeatTest {
}
@Override
- public Traversal<Vertex, String> get_g_VX1X_repeatXoutX_untilXloops_gte_2X_name(final Object v1Id) {
- ComputerTestHelper.compute("g.V(${v1Id}).repeat(__.out).until { it.loops() >= 2 }.name", g)
- }
-
- @Override
- public Traversal<Vertex, Vertex> get_g_V_repeatXoutX_untilXloops_gte_2X() {
- ComputerTestHelper.compute("g.V.repeat(__.out).until { it.loops() >= 2 }", g)
- }
-
- @Override
- public Traversal<Vertex, Vertex> get_g_V_repeatXoutX_untilXloops_gte_2X_emit() {
- ComputerTestHelper.compute("g.V.repeat(__.out).until { it.loops() >= 2 }.emit", g)
- }
-
- @Override
- public Traversal<Vertex, Path> get_g_V_repeatXoutX_untilXloops_gte_2X_emit_path() {
- ComputerTestHelper.compute("g.V.repeat(__.out).until { it.loops() >= 2 }.emit.path", g)
- }
-
- @Override
public Traversal<Vertex, Path> get_g_V_repeatXoutX_timesX2X_emit_path() {
ComputerTestHelper.compute("g.V.repeat(__.out).times(2).emit.path", g)
}
@Override
- public Traversal<Vertex, String> get_g_V_repeatXoutX_untilXloops_gte_2X_repeatXinX_untilXloops_gte_2X_name() {
- ComputerTestHelper.compute("g.V.repeat(__.out).until { it.loops() >= 2 }.repeat(__.in).until { it.loops() >= 2 }.name", g)
- }
-
- @Override
public Traversal<Vertex, String> get_g_V_repeatXoutX_timesX2X_repeatXinX_timesX2X_name() {
ComputerTestHelper.compute("g.V.repeat(__.out).times(2).repeat(__.in).times(2).name", g)
}
@@ -165,11 +110,6 @@ public abstract class GroovyRepeatTest {
}
@Override
- public Traversal<Vertex, String> get_g_VX1X_untilXloops_gte_2X_repeatXoutX_name(Object v1Id) {
- ComputerTestHelper.compute("g.V(${v1Id}).until{it.loops() >= 2}.repeat(__.out).name", g)
- }
-
- @Override
public Traversal<Vertex, String> get_g_VX1X_timesX2X_repeatXoutX_name(Object v1Id) {
ComputerTestHelper.compute("g.V(${v1Id}).times(2).repeat(__.out).name", g)
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyUnionTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyUnionTest.groovy b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyUnionTest.groovy
index d5788f0..da76ee2 100644
--- a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyUnionTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/branch/GroovyUnionTest.groovy
@@ -41,12 +41,12 @@ public abstract class GroovyUnionTest {
g.V(v1Id).union(repeat(__.out).times(2), __.out).name
}
- public Traversal<Vertex, String> get_g_V_chooseXlabel_eq_person__unionX__out_lang__out_nameX__in_labelX() {
- g.V.choose({ it.label() == 'person' }, union(__.out.lang, __.out.name), __.in.label)
+ public Traversal<Vertex, String> get_g_V_chooseXlabel_is_person__unionX__out_lang__out_nameX__in_labelX() {
+ g.V.choose(__.label.is('person'), union(__.out.lang, __.out.name), __.in.label)
}
- public Traversal<Vertex, Map<String, Long>> get_g_V_chooseXlabel_eq_person__unionX__out_lang__out_nameX__in_labelX_groupCount() {
- g.V.choose({ it.label() == 'person' }, union(__.out.lang, __.out.name), __.in.label).groupCount
+ public Traversal<Vertex, Map<String, Long>> get_g_V_chooseXlabel_is_person__unionX__out_lang__out_nameX__in_labelX_groupCount() {
+ g.V.choose(__.label.is('person'), union(__.out.lang, __.out.name), __.in.label).groupCount
}
public Traversal<Vertex, Map<String, Long>> get_g_V_unionXrepeatXunionXoutXcreatedX__inXcreatedXX_timesX2X__repeatXunionXinXcreatedX__outXcreatedXX_timesX2XX_label_groupCount() {
@@ -77,12 +77,12 @@ public abstract class GroovyUnionTest {
ComputerTestHelper.compute("g.V(${v1Id}).union(repeat(__.out).times(2), __.out).name", g)
}
- public Traversal<Vertex, String> get_g_V_chooseXlabel_eq_person__unionX__out_lang__out_nameX__in_labelX() {
- ComputerTestHelper.compute("g.V.choose({ it.label() == 'person' }, union(__.out.lang, __.out.name), __.in.label)", g)
+ public Traversal<Vertex, String> get_g_V_chooseXlabel_is_person__unionX__out_lang__out_nameX__in_labelX() {
+ ComputerTestHelper.compute("g.V.choose(__.label.is('person'), union(__.out.lang, __.out.name), __.in.label)", g)
}
- public Traversal<Vertex, Map<String, Long>> get_g_V_chooseXlabel_eq_person__unionX__out_lang__out_nameX__in_labelX_groupCount() {
- ComputerTestHelper.compute("g.V.choose({ it.label() == 'person' }, union(__.out.lang, __.out.name), __.in.label).groupCount", g)
+ public Traversal<Vertex, Map<String, Long>> get_g_V_chooseXlabel_is_person__unionX__out_lang__out_nameX__in_labelX_groupCount() {
+ ComputerTestHelper.compute("g.V.choose(__.label.is('person'), union(__.out.lang, __.out.name), __.in.label).groupCount", g)
}
public Traversal<Vertex, Map<String, Long>> get_g_V_unionXrepeatXunionXoutXcreatedX__inXcreatedXX_timesX2X__repeatXunionXinXcreatedX__outXcreatedXX_timesX2XX_label_groupCount() {
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/filter/GroovyHasTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/filter/GroovyHasTest.groovy b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/filter/GroovyHasTest.groovy
index 77bbc86..7b4fdf0 100644
--- a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/filter/GroovyHasTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/filter/GroovyHasTest.groovy
@@ -100,11 +100,6 @@ public abstract class GroovyHasTest {
}
@Override
- public Traversal<Vertex, Vertex> get_g_V_hasXname_equalspredicate_markoX() {
- g.V().has("name", { v1, v2 -> v1.equals(v2) }, "marko");
- }
-
- @Override
public Traversal<Vertex, Integer> get_g_V_hasXperson_name_markoX_age() {
g.V.has('person', 'name', 'marko').age;
}
@@ -183,11 +178,6 @@ public abstract class GroovyHasTest {
}
@Override
- public Traversal<Vertex, Vertex> get_g_V_hasXname_equalspredicate_markoX() {
- ComputerTestHelper.compute(" g.V().has('name', { v1, v2 -> v1.equals(v2) }, 'marko')", g);
- }
-
- @Override
public Traversal<Vertex, Integer> get_g_V_hasXperson_name_markoX_age() {
ComputerTestHelper.compute("g.V.has('person', 'name', 'marko').age", g);
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/filter/GroovyWhereTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/filter/GroovyWhereTest.groovy b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/filter/GroovyWhereTest.groovy
index b10266e..3455396 100644
--- a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/filter/GroovyWhereTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/filter/GroovyWhereTest.groovy
@@ -38,8 +38,8 @@ public abstract class GroovyWhereTest {
}
@Override
- public Traversal<Vertex, Map<String, Object>> get_g_V_hasXageX_asXaX_out_in_hasXageX_asXbX_select_whereXa_b_neqX() {
- g.V.has('age').as('a').out.in.has('age').as('b').select().where('a', 'b') { a, b -> !a.equals(b) };
+ public Traversal<Vertex, Map<String, Object>> get_g_V_hasXageX_asXaX_out_in_hasXageX_asXbX_select_whereXa_neq_bX() {
+ g.V.has('age').as('a').out.in.has('age').as('b').select().where('a',Compare.neq, 'b');
}
@Override
@@ -60,8 +60,8 @@ public abstract class GroovyWhereTest {
}
@Override
- public Traversal<Vertex, Map<String, Object>> get_g_V_hasXageX_asXaX_out_in_hasXageX_asXbX_select_whereXa_b_neqX() {
- ComputerTestHelper.compute("g.V.has('age').as('a').out.in.has('age').as('b').select().where('a', 'b') { a, b -> !a.equals(b) }", g);
+ public Traversal<Vertex, Map<String, Object>> get_g_V_hasXageX_asXaX_out_in_hasXageX_asXbX_select_whereXa_neq_bX() {
+ ComputerTestHelper.compute("g.V.has('age').as('a').out.in.has('age').as('b').select().where('a', Compare.neq, 'b')", g);
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/map/GroovyCountTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/map/GroovyCountTest.groovy b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/map/GroovyCountTest.groovy
index b57049c..2347456 100644
--- a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/map/GroovyCountTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/map/GroovyCountTest.groovy
@@ -56,8 +56,8 @@ public abstract class GroovyCountTest {
}
@Override
- public Traversal<Vertex, Long> get_g_V_filterXfalseX_count() {
- g.V.filter { false }.count
+ public Traversal<Vertex, Long> get_g_V_hasXnoX_count() {
+ g.V.has('no').count
}
}
@@ -88,8 +88,8 @@ public abstract class GroovyCountTest {
}
@Override
- public Traversal<Vertex, Long> get_g_V_filterXfalseX_count() {
- ComputerTestHelper.compute("g.V.filter{false}.count", g)
+ public Traversal<Vertex, Long> get_g_V_hasXnoX_count() {
+ ComputerTestHelper.compute("g.V.has('no').count", g)
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/map/GroovyOrderTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/map/GroovyOrderTest.groovy b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/map/GroovyOrderTest.groovy
index f89065a..17ba595 100644
--- a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/map/GroovyOrderTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/map/GroovyOrderTest.groovy
@@ -39,11 +39,6 @@ public abstract class GroovyOrderTest {
}
@Override
- public Traversal<Vertex, String> get_g_V_name_order_byXabX() {
- g.V.name.order.by { a, b -> b <=> a }
- }
-
- @Override
public Traversal<Vertex, String> get_g_V_name_order_byXa1_b1X_byXb2_a2X() {
g.V.name.order.by { a, b -> a[1] <=> b[1] }.by { a, b -> b[2] <=> a[2] }
}
@@ -95,11 +90,6 @@ public abstract class GroovyOrderTest {
}
@Override
- public Traversal<Vertex, String> get_g_V_name_order_byXabX() {
- ComputerTestHelper.compute("g.V.name.order.by { a, b -> b <=> a }", g)
- }
-
- @Override
public Traversal<Vertex, String> get_g_V_name_order_byXa1_b1X_byXb2_a2X() {
ComputerTestHelper.compute("g.V.name.order.by { a, b -> a[1] <=> b[1] }.by{ a, b -> b[2] <=> a[2] }", g)
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/map/GroovyUnfoldTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/map/GroovyUnfoldTest.groovy b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/map/GroovyUnfoldTest.groovy
index 169c878..aeb6c23 100644
--- a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/map/GroovyUnfoldTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/map/GroovyUnfoldTest.groovy
@@ -18,9 +18,9 @@
*/
package com.tinkerpop.gremlin.process.graph.traversal.step.map
-import com.tinkerpop.gremlin.process.Traversal
import com.tinkerpop.gremlin.process.ComputerTestHelper
-import com.tinkerpop.gremlin.process.graph.traversal.step.map.UnfoldTest
+import com.tinkerpop.gremlin.process.Traversal
+import com.tinkerpop.gremlin.process.graph.traversal.__
import com.tinkerpop.gremlin.structure.Edge
import com.tinkerpop.gremlin.structure.Vertex
@@ -32,8 +32,8 @@ public abstract class GroovyUnfoldTest {
public static class StandardTest extends UnfoldTest {
@Override
- public Traversal<Vertex, Edge> get_g_V_mapXoutEX_unfold() {
- g.V.map { it.outE }.unfold
+ public Traversal<Vertex, Edge> get_g_V_localXoutE_foldX_unfold() {
+ g.V.local(__.outE.fold).unfold
}
@Override
@@ -45,8 +45,8 @@ public abstract class GroovyUnfoldTest {
public static class ComputerTest extends UnfoldTest {
@Override
- public Traversal<Vertex, Edge> get_g_V_mapXoutEX_unfold() {
- ComputerTestHelper.compute("g.V.map { it.outE }.unfold", g)
+ public Traversal<Vertex, Edge> get_g_V_localXoutE_foldX_unfold() {
+ ComputerTestHelper.compute("g.V.local(__.outE.fold).unfold", g)
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/GroovyGroupCountTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/GroovyGroupCountTest.groovy b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/GroovyGroupCountTest.groovy
index 6c54482..ec0bb0f 100644
--- a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/GroovyGroupCountTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/GroovyGroupCountTest.groovy
@@ -47,8 +47,8 @@ public abstract class GroovyGroupCountTest {
}
@Override
- public Traversal<Vertex, Map<Object, Long>> get_g_V_filterXfalseX_groupCount() {
- g.V.filter { false }.groupCount;
+ public Traversal<Vertex, Map<Object, Long>> get_g_V_hasXnoX_groupCount() {
+ g.V.has('no').groupCount;
}
@Override
@@ -82,8 +82,8 @@ public abstract class GroovyGroupCountTest {
}
@Override
- public Traversal<Vertex, Map<Object, Long>> get_g_V_filterXfalseX_groupCount() {
- ComputerTestHelper.compute("g.V.filter { false }.groupCount", g)
+ public Traversal<Vertex, Map<Object, Long>> get_g_V_hasXnoX_groupCount() {
+ ComputerTestHelper.compute("g.V.has('no').groupCount", g)
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/GroovyGroupTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/GroovyGroupTest.groovy b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/GroovyGroupTest.groovy
index 237c91f..eb4151e 100644
--- a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/GroovyGroupTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/GroovyGroupTest.groovy
@@ -18,12 +18,11 @@
*/
package com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect
-import com.tinkerpop.gremlin.process.Traversal
import com.tinkerpop.gremlin.process.ComputerTestHelper
-import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.GroupTest
+import com.tinkerpop.gremlin.process.Traversal
+import com.tinkerpop.gremlin.process.graph.traversal.__
import com.tinkerpop.gremlin.structure.Vertex
-import com.tinkerpop.gremlin.process.graph.traversal.__
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
@@ -42,13 +41,13 @@ public abstract class GroovyGroupTest {
}
@Override
- public Traversal<Vertex, Map<String, Integer>> get_g_V_hasXlangX_group_byXlangX_byX1X_byXsizeX() {
- g.V.has('lang').group.by('lang').by { 1 }.by { it.size() }
+ public Traversal<Vertex, Map<String, Long>> get_g_V_hasXlangX_group_byXlangX_byX1X_byXunfold_countX() {
+ g.V.has('lang').group.by('lang').by(__.inject(1)).by(__.unfold().count());
}
@Override
- public Traversal<Vertex, Map<String, Integer>> get_g_V_repeatXout_groupXaX_byXnameX_by_byXsizeXX_timesX2X_capXaX() {
- g.V.repeat(__.out.group('a').by('name').by.by { it.size() }).times(2).cap('a')
+ public Traversal<Vertex, Map<String, Long>> get_g_V_repeatXout_groupXaX_byXnameX_by_byXsizeXX_timesX2X_capXaX() {
+ g.V.repeat(__.out.group('a').by('name').by.by(__.unfold().count())).times(2).cap('a')
}
@Override
@@ -70,13 +69,13 @@ public abstract class GroovyGroupTest {
}
@Override
- public Traversal<Vertex, Map<String, Integer>> get_g_V_hasXlangX_group_byXlangX_byX1X_byXsizeX() {
- ComputerTestHelper.compute("g.V.has('lang').group.by('lang').by{1}.by{it.size()}", g)
+ public Traversal<Vertex, Map<String, Long>> get_g_V_hasXlangX_group_byXlangX_byX1X_byXunfold_countX() {
+ ComputerTestHelper.compute("g.V.has('lang').group.by('lang').by(__.inject(1)).by(__.unfold().count())", g)
}
@Override
- public Traversal<Vertex, Map<String, Integer>> get_g_V_repeatXout_groupXaX_byXnameX_by_byXsizeXX_timesX2X_capXaX() {
- ComputerTestHelper.compute("g.V.repeat(__.out.group('a').by('name').by.by { it.size() }).times(2).cap('a')", g)
+ public Traversal<Vertex, Map<String, Long>> get_g_V_repeatXout_groupXaX_byXnameX_by_byXsizeXX_timesX2X_capXaX() {
+ ComputerTestHelper.compute("g.V.repeat(__.out.group('a').by('name').by.by(__.unfold().count())).times(2).cap('a')", g)
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/GroovySackTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/GroovySackTest.groovy b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/GroovySackTest.groovy
index 9fa604a..77fd9a8 100644
--- a/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/GroovySackTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/com/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/GroovySackTest.groovy
@@ -18,12 +18,11 @@
*/
package com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect
-import com.tinkerpop.gremlin.process.Traversal
import com.tinkerpop.gremlin.process.ComputerTestHelper
-import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.SackTest
+import com.tinkerpop.gremlin.process.Traversal
+import com.tinkerpop.gremlin.process.graph.traversal.__
import com.tinkerpop.gremlin.structure.Vertex
-import com.tinkerpop.gremlin.process.graph.traversal.__
import static com.tinkerpop.gremlin.structure.Operator.sum
/**
@@ -35,12 +34,12 @@ public abstract class GroovySackTest {
@Override
public Traversal<Vertex, Double> get_g_V_withSackX0X_outE_sackXsum_weightX_inV_sack_sum() {
- g.V().withSack { 0.0f }.outE.sack(sum, 'weight').inV.sack.sum()
+ g.V().withSack(0.0f).outE.sack(sum, 'weight').inV.sack.sum()
}
@Override
public Traversal<Vertex, Float> get_g_V_withSackX0X_repeatXoutE_sackXsum_weightX_inVX_timesX2X_sack() {
- g.V.withSack { 0.0f }.repeat(__.outE.sack(sum, 'weight').inV).times(2).sack
+ g.V.withSack(0.0f).repeat(__.outE.sack(sum, 'weight').inV).times(2).sack
}
@Override
@@ -53,12 +52,12 @@ public abstract class GroovySackTest {
@Override
public Traversal<Vertex, Double> get_g_V_withSackX0X_outE_sackXsum_weightX_inV_sack_sum() {
- ComputerTestHelper.compute("g.V().withSack{0.0f}.outE.sack(sum, 'weight').inV.sack.sum()", g);
+ ComputerTestHelper.compute("g.V().withSack(0.0f).outE.sack(sum, 'weight').inV.sack.sum()", g);
}
@Override
public Traversal<Vertex, Float> get_g_V_withSackX0X_repeatXoutE_sackXsum_weightX_inVX_timesX2X_sack() {
- ComputerTestHelper.compute("g.V.withSack{ 0.0f }.repeat(__.outE.sack(sum, 'weight').inV).times(2).sack", g)
+ ComputerTestHelper.compute("g.V.withSack(0.0f).repeat(__.outE.sack(sum, 'weight').inV).times(2).sack", g)
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-groovy/src/main/groovy/com/tinkerpop/gremlin/groovy/loaders/StepLoader.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/groovy/com/tinkerpop/gremlin/groovy/loaders/StepLoader.groovy b/gremlin-groovy/src/main/groovy/com/tinkerpop/gremlin/groovy/loaders/StepLoader.groovy
index c9551f8..d83ee88 100644
--- a/gremlin-groovy/src/main/groovy/com/tinkerpop/gremlin/groovy/loaders/StepLoader.groovy
+++ b/gremlin-groovy/src/main/groovy/com/tinkerpop/gremlin/groovy/loaders/StepLoader.groovy
@@ -20,6 +20,8 @@ package com.tinkerpop.gremlin.groovy.loaders
import com.tinkerpop.gremlin.groovy.function.GComparator
import com.tinkerpop.gremlin.groovy.function.GFunction
+import com.tinkerpop.gremlin.groovy.function.GSupplier
+import com.tinkerpop.gremlin.groovy.function.GUnaryOperator
import com.tinkerpop.gremlin.process.graph.traversal.GraphTraversal
/**
@@ -41,5 +43,13 @@ class StepLoader {
GraphTraversal.metaClass.by = { final Closure closure ->
return ((GraphTraversal) delegate).by(1 == closure.getMaximumNumberOfParameters() ? new GFunction(closure) : new GComparator(closure));
}
+
+ GraphTraversal.metaClass.withSack = { final Closure closure ->
+ return ((GraphTraversal) delegate).withSack(new GSupplier(closure));
+ }
+
+ GraphTraversal.metaClass.withSack = { final Closure closure, final Closure operator ->
+ return ((GraphTraversal) delegate).withSack(new GSupplier(closure), new GUnaryOperator(operator));
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/function/GComparator.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/function/GComparator.java b/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/function/GComparator.java
index ada2866..ce11fa5 100644
--- a/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/function/GComparator.java
+++ b/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/function/GComparator.java
@@ -25,7 +25,7 @@ import java.util.Comparator;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
-public class GComparator<A> implements Comparator<A> {
+public final class GComparator<A> implements Comparator<A> {
private final Closure closure;
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/function/GFunction.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/function/GFunction.java b/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/function/GFunction.java
index 6f38530..5505d6c 100644
--- a/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/function/GFunction.java
+++ b/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/function/GFunction.java
@@ -25,7 +25,7 @@ import java.util.function.Function;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
-public class GFunction<A, B> implements Function<A, B> {
+public final class GFunction<A, B> implements Function<A, B> {
private final Closure closure;
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/function/GSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/function/GSupplier.java b/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/function/GSupplier.java
new file mode 100644
index 0000000..94fd83e
--- /dev/null
+++ b/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/function/GSupplier.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.tinkerpop.gremlin.groovy.function;
+
+import groovy.lang.Closure;
+
+import java.util.function.Supplier;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class GSupplier<A> implements Supplier<A> {
+
+ private final Closure closure;
+
+ public GSupplier(final Closure closure) {
+ this.closure = closure;
+ }
+
+ @Override
+ public A get() {
+ return (A) this.closure.call();
+ }
+
+ public static GSupplier[] make(final Closure... closures) {
+ final GSupplier[] functions = new GSupplier[closures.length];
+ for (int i = 0; i < closures.length; i++) {
+ functions[i] = new GSupplier(closures[i]);
+ }
+ return functions;
+ }
+
+ @Override
+ public String toString() {
+ return "lambda";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/function/GUnaryOperator.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/function/GUnaryOperator.java b/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/function/GUnaryOperator.java
new file mode 100644
index 0000000..eb107c2
--- /dev/null
+++ b/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/function/GUnaryOperator.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.tinkerpop.gremlin.groovy.function;
+
+import groovy.lang.Closure;
+
+import java.util.function.UnaryOperator;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class GUnaryOperator<A> implements UnaryOperator<A> {
+
+ private final Closure closure;
+
+ public GUnaryOperator(final Closure closure) {
+ this.closure = closure;
+ }
+
+ public static GUnaryOperator[] make(final Closure... closures) {
+ final GUnaryOperator[] functions = new GUnaryOperator[closures.length];
+ for (int i = 0; i < closures.length; i++) {
+ functions[i] = new GUnaryOperator(closures[i]);
+ }
+ return functions;
+ }
+
+ @Override
+ public String toString() {
+ return "lambda";
+ }
+
+ @Override
+ public A apply(final A a) {
+ return (A) closure.call(a);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-test/src/main/java/com/tinkerpop/gremlin/process/ProcessComputerSuite.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/com/tinkerpop/gremlin/process/ProcessComputerSuite.java b/gremlin-test/src/main/java/com/tinkerpop/gremlin/process/ProcessComputerSuite.java
index 667bada..d606134 100644
--- a/gremlin-test/src/main/java/com/tinkerpop/gremlin/process/ProcessComputerSuite.java
+++ b/gremlin-test/src/main/java/com/tinkerpop/gremlin/process/ProcessComputerSuite.java
@@ -70,7 +70,7 @@ public class ProcessComputerSuite extends AbstractGremlinSuite {
private static final Class<?>[] allTests = new Class<?>[]{
// basic api semantics testing
- GraphComputerTest.ComputerTest.class, // todo: not sure this should be here as it forces retest of GraphComputer without an "implementation"
+ // GraphComputerTest.ComputerTest.class, // todo: not sure this should be here as it forces retest of GraphComputer without an "implementation"
// branch
BranchTest.ComputerTest.class,
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-test/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/BranchTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/BranchTest.java b/gremlin-test/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/BranchTest.java
index d9a1922..c729eb5 100644
--- a/gremlin-test/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/BranchTest.java
+++ b/gremlin-test/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/BranchTest.java
@@ -28,7 +28,8 @@ import java.util.Arrays;
import java.util.List;
import static com.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN;
-import static com.tinkerpop.gremlin.process.graph.traversal.__.*;
+import static com.tinkerpop.gremlin.process.graph.traversal.__.label;
+import static com.tinkerpop.gremlin.process.graph.traversal.__.values;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
@@ -64,10 +65,10 @@ public abstract class BranchTest extends AbstractGremlinProcessTest {
@Override
public Traversal<Vertex, Object> get_g_V_branchXlabelX_optionXperson__ageX_optionXsoftware__langX_optionXsoftware__nameX() {
- return g.V().branch(label())
- .option("person", values("age"))
- .option("software", values("lang"))
- .option("software", values("name"));
+ return g.V().branch(label().is("person").count())
+ .option(1L, values("age"))
+ .option(0L, values("lang"))
+ .option(0L, values("name"));
}
}
@@ -75,10 +76,10 @@ public abstract class BranchTest extends AbstractGremlinProcessTest {
@Override
public Traversal<Vertex, Object> get_g_V_branchXlabel_eq_person__a_bX_optionXa__ageX_optionXb__langX_optionXb__nameX() {
- return g.V().branch(v -> v.get().label().equals("person") ? "a" : "b")
- .option("a", values("age"))
- .option("b", values("lang"))
- .option("b", values("name")).submit(g.compute());
+ return g.V().branch(label().is("person").count())
+ .option(1L, values("age"))
+ .option(0L, values("lang"))
+ .option(0L, values("name")).submit(g.compute());
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af7eb283/gremlin-test/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/ChooseTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/ChooseTest.java b/gremlin-test/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/ChooseTest.java
index d6a12b1..6a9837b 100644
--- a/gremlin-test/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/ChooseTest.java
+++ b/gremlin-test/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/ChooseTest.java
@@ -20,7 +20,6 @@ package com.tinkerpop.gremlin.process.graph.traversal.step.branch;
import com.tinkerpop.gremlin.LoadGraphWith;
import com.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
-import com.tinkerpop.gremlin.process.T;
import com.tinkerpop.gremlin.process.Traversal;
import com.tinkerpop.gremlin.process.util.MapHelper;
import com.tinkerpop.gremlin.structure.Vertex;
@@ -40,76 +39,10 @@ import static org.junit.Assert.assertFalse;
*/
public abstract class ChooseTest extends AbstractGremlinProcessTest {
- public abstract Traversal<Vertex, String> get_g_V_chooseXname_length_5XoutXinX_name();
-
- public abstract Traversal<Vertex, String> get_g_VX1X_chooseX0X_optionX0__outX_name(Object v1Id);
-
- public abstract Traversal<Vertex, String> get_g_V_hasXlabel_personX_chooseXname_lengthX_optionX5__inX_optionX4__outX_optionX3__bothX_name();
-
public abstract Traversal<Vertex, Object> get_g_V_chooseXout_countX_optionX2L__nameX_optionX3L__valueMapX();
@Test
@LoadGraphWith(MODERN)
- public void g_V_chooseXname_length_5XoutXinX_name() {
- final Traversal<Vertex, String> traversal = get_g_V_chooseXname_length_5XoutXinX_name();
- printTraversalForm(traversal);
- Map<String, Long> counts = new HashMap<>();
- int counter = 0;
- while (traversal.hasNext()) {
- MapHelper.incr(counts, traversal.next(), 1l);
- counter++;
- }
- assertFalse(traversal.hasNext());
- assertEquals(9, counter);
- assertEquals(5, counts.size());
- assertEquals(Long.valueOf(1), counts.get("vadas"));
- assertEquals(Long.valueOf(3), counts.get("josh"));
- assertEquals(Long.valueOf(2), counts.get("lop"));
- assertEquals(Long.valueOf(2), counts.get("marko"));
- assertEquals(Long.valueOf(1), counts.get("peter"));
-
- }
-
- @Test
- @LoadGraphWith(MODERN)
- public void g_VX1X_chooseX0X_optionX0__outX_name() {
- final Traversal<Vertex, String> traversal = get_g_VX1X_chooseX0X_optionX0__outX_name(convertToVertexId("marko"));
- printTraversalForm(traversal);
- Map<String, Long> counts = new HashMap<>();
- int counter = 0;
- while (traversal.hasNext()) {
- MapHelper.incr(counts, traversal.next(), 1l);
- counter++;
- }
- assertFalse(traversal.hasNext());
- assertEquals(3, counter);
- assertEquals(3, counts.size());
- assertEquals(Long.valueOf(1), counts.get("vadas"));
- assertEquals(Long.valueOf(1), counts.get("josh"));
- assertEquals(Long.valueOf(1), counts.get("lop"));
- }
-
- @Test
- @LoadGraphWith(MODERN)
- public void g_V_hasXlabel_personX_chooseXname_lengthX_optionX5__inX_optionX4__outX_optionX3__bothX_name() {
- final Traversal<Vertex, String> traversal = get_g_V_hasXlabel_personX_chooseXname_lengthX_optionX5__inX_optionX4__outX_optionX3__bothX_name();
- printTraversalForm(traversal);
- Map<String, Long> counts = new HashMap<>();
- int counter = 0;
- while (traversal.hasNext()) {
- MapHelper.incr(counts, traversal.next(), 1l);
- counter++;
- }
- assertFalse(traversal.hasNext());
- assertEquals(3, counter);
- assertEquals(3, counts.size());
- assertEquals(Long.valueOf(1), counts.get("marko"));
- assertEquals(Long.valueOf(1), counts.get("lop"));
- assertEquals(Long.valueOf(1), counts.get("ripple"));
- }
-
- @Test
- @LoadGraphWith(MODERN)
public void g_V_chooseXout_countX_optionX2L__nameX_optionX3L__valueMapX() {
final Traversal<Vertex, Object> traversal = get_g_V_chooseXout_countX_optionX2L__nameX_optionX3L__valueMapX();
printTraversalForm(traversal);
@@ -129,26 +62,6 @@ public abstract class ChooseTest extends AbstractGremlinProcessTest {
public static class StandardTest extends ChooseTest {
@Override
- public Traversal<Vertex, String> get_g_V_chooseXname_length_5XoutXinX_name() {
- return g.V().choose(v -> v.<String>value("name").length() == 5,
- out(),
- in()).values("name");
- }
-
- @Override
- public Traversal<Vertex, String> get_g_VX1X_chooseX0X_optionX0__outX_name(Object v1Id) {
- return g.V(v1Id).choose(t -> 0).option(0, out()).values("name");
- }
-
- @Override
- public Traversal<Vertex, String> get_g_V_hasXlabel_personX_chooseXname_lengthX_optionX5__inX_optionX4__outX_optionX3__bothX_name() {
- return g.V().has(T.label, "person").choose(v -> v.<String>value("name").length())
- .option(5, in())
- .option(4, out())
- .option(3, both()).values("name");
- }
-
- @Override
public Traversal<Vertex, Object> get_g_V_chooseXout_countX_optionX2L__nameX_optionX3L__valueMapX() {
return g.V().choose(out().count())
.option(2L, values("name"))
@@ -163,26 +76,6 @@ public abstract class ChooseTest extends AbstractGremlinProcessTest {
}
@Override
- public Traversal<Vertex, String> get_g_V_chooseXname_length_5XoutXinX_name() {
- return g.V().choose(v -> v.<String>value("name").length() == 5,
- out(),
- in()).<String>values("name").submit(g.compute());
- }
-
- @Override
- public Traversal<Vertex, String> get_g_VX1X_chooseX0X_optionX0__outX_name(Object v1Id) {
- return g.V(v1Id).choose(t -> 0).option(0, out()).<String>values("name").submit(g.compute());
- }
-
- @Override
- public Traversal<Vertex, String> get_g_V_hasXlabel_personX_chooseXname_lengthX_optionX5__inX_optionX4__outX_optionX3__bothX_name() {
- return g.V().has(T.label, "person").choose(v -> v.<String>value("name").length())
- .option(5, in())
- .option(4, out())
- .option(3, both()).<String>values("name").submit(g.compute());
- }
-
- @Override
public Traversal<Vertex, Object> get_g_V_chooseXout_countX_optionX2L__nameX_optionX3L__valueMapX() {
return g.V().choose(out().count())
.option(2L, values("name"))