You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/04/24 16:03:06 UTC
[1/2] incubator-tinkerpop git commit: Finalize some variables in a
test.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/refactor-io 4c29a831a -> a2a73dc9f
Finalize some variables in a test.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/d33e31a9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/d33e31a9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/d33e31a9
Branch: refs/heads/refactor-io
Commit: d33e31a9e1b6093b296182aa21f8fc5e7f708994
Parents: 4c29a83
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Apr 24 09:31:21 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Apr 24 09:31:21 2015 -0400
----------------------------------------------------------------------
.../io/gryo/GryoRecordReaderWriterTest.java | 33 ++++++++++----------
1 file changed, 16 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d33e31a9/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordReaderWriterTest.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordReaderWriterTest.java b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordReaderWriterTest.java
index 67cee16..cf15b2f 100644
--- a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordReaderWriterTest.java
+++ b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordReaderWriterTest.java
@@ -47,28 +47,27 @@ import static org.junit.Assert.assertTrue;
* @author Joshua Shinavier (http://fortytwo.net)
*/
public class GryoRecordReaderWriterTest {
- // todo: gotta fix this one after the gryo refactoring
@Test
@org.junit.Ignore
public void testAll() throws Exception {
- Configuration configuration = new Configuration(false);
+ final Configuration configuration = new Configuration(false);
configuration.set("fs.file.impl", LocalFileSystem.class.getName());
configuration.set("fs.default.name", "file:///");
- File testFile = new File(HadoopGraphProvider.PATHS.get("grateful-dead-vertices.kryo"));
- FileSplit split = new FileSplit(
+ final File testFile = new File(HadoopGraphProvider.PATHS.get("grateful-dead-vertices.kryo"));
+ final FileSplit split = new FileSplit(
new Path(testFile.getAbsoluteFile().toURI().toString()), 0,
testFile.length(), null);
System.out.println("reading Gryo file " + testFile.getAbsolutePath() + " (" + testFile.length() + " bytes)");
- GryoInputFormat inputFormat = ReflectionUtils.newInstance(GryoInputFormat.class, configuration);
- TaskAttemptContext job = new TaskAttemptContext(configuration, new TaskAttemptID());
- RecordReader reader = inputFormat.createRecordReader(split, job);
+ final GryoInputFormat inputFormat = ReflectionUtils.newInstance(GryoInputFormat.class, configuration);
+ final TaskAttemptContext job = new TaskAttemptContext(configuration, new TaskAttemptID());
+ final RecordReader reader = inputFormat.createRecordReader(split, job);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(bos)) {
- GryoOutputFormat outputFormat = new GryoOutputFormat();
- RecordWriter writer = outputFormat.getRecordWriter(job, dos);
+ final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ try (final DataOutputStream dos = new DataOutputStream(bos)) {
+ final GryoOutputFormat outputFormat = new GryoOutputFormat();
+ final RecordWriter writer = outputFormat.getRecordWriter(job, dos);
float lastProgress = -1f;
int count = 0;
@@ -76,16 +75,16 @@ public class GryoRecordReaderWriterTest {
while (reader.nextKeyValue()) {
//System.out.println("" + reader.getProgress() + "> " + reader.getCurrentKey() + ": " + reader.getCurrentValue());
count++;
- float progress = reader.getProgress();
+ final float progress = reader.getProgress();
assertTrue(progress >= lastProgress);
assertEquals(NullWritable.class, reader.getCurrentKey().getClass());
- VertexWritable v = (VertexWritable) reader.getCurrentValue();
+ final VertexWritable v = (VertexWritable) reader.getCurrentValue();
writer.write(NullWritable.get(), v);
- Vertex vertex = v.get();
+ final Vertex vertex = v.get();
assertEquals(Integer.class, vertex.id().getClass());
- Object value = vertex.property("name");
+ final Object value = vertex.property("name");
if (((Property) value).value().equals("SUGAR MAGNOLIA")) {
foundKeyValue = true;
assertEquals(92, IteratorUtils.count(vertex.edges(Direction.OUT)));
@@ -99,9 +98,9 @@ public class GryoRecordReaderWriterTest {
}
//System.out.println("bos: " + new String(bos.toByteArray()));
- String[] lines = new String(bos.toByteArray()).split("\\x3a\\x15.\\x11\\x70...");
+ final String[] lines = new String(bos.toByteArray()).split("\\x3a\\x15.\\x11\\x70...");
assertEquals(808, lines.length);
- String line42 = lines[41];
+ final String line42 = lines[41];
//System.out.println("line42: " + line42);
assertTrue(line42.contains("ITS ALL OVER NO"));
}
[2/2] incubator-tinkerpop git commit: Factored out the
Attachable.Method enum in favor of a class.
Posted by sp...@apache.org.
Factored out the Attachable.Method enum in favor of a class.
Syntax became prettier in some ways as a result, given the need to call .apply() on the return of the value from the enum. With a static method it just looks like this: Method.get(host) as opposed to Method.GET.apply(host).
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/a2a73dc9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/a2a73dc9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/a2a73dc9
Branch: refs/heads/refactor-io
Commit: a2a73dc9ff008b9938630209a75ef06fc994de21
Parents: d33e31a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Apr 24 10:01:51 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Apr 24 10:01:51 2015 -0400
----------------------------------------------------------------------
.../computer/traversal/TraverserExecutor.java | 2 +-
.../traversal/step/map/ComputerResultStep.java | 3 +-
.../gremlin/process/traversal/Traverser.java | 6 +-
.../traverser/B_O_P_S_SE_SL_Traverser.java | 4 +-
.../traverser/util/AbstractTraverser.java | 5 +-
.../traverser/util/EmptyTraverser.java | 6 +-
.../gremlin/structure/io/gryo/GryoReader.java | 4 +-
.../gremlin/structure/util/Attachable.java | 159 +++++--------------
.../structure/util/detached/DetachedPath.java | 7 +-
.../structure/util/reference/ReferencePath.java | 7 +-
.../util/detached/DetachedEdgeTest.java | 4 +-
.../util/detached/DetachedPropertyTest.java | 4 +-
.../detached/DetachedVertexPropertyTest.java | 4 +-
.../util/detached/DetachedVertexTest.java | 6 +-
.../util/reference/ReferenceEdgeTest.java | 4 +-
.../reference/ReferenceVertexPropertyTest.java | 4 +-
.../util/reference/ReferenceVertexTest.java | 4 +-
.../structure/util/star/StarGraphTest.java | 20 +--
.../process/computer/spark/SparkExecutor.java | 4 +-
.../io/graphson/GraphSONRecordReader.java | 4 +-
.../structure/io/gryo/GryoRecordReader.java | 4 +-
21 files changed, 106 insertions(+), 159 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraverserExecutor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraverserExecutor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraverserExecutor.java
index 5c3ecdb..6a1e69d 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraverserExecutor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraverserExecutor.java
@@ -51,7 +51,7 @@ public final class TraverserExecutor {
messenger.receiveMessages().forEachRemaining(traverserSet -> {
traverserSet.forEach(traverser -> {
traverser.setSideEffects(traversalSideEffects);
- traverser.attach(vertex, Attachable.Method.GET);
+ traverser.attach(vertex, Attachable.Method::get);
aliveTraversers.add((Traverser.Admin) traverser);
});
});
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/ComputerResultStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/ComputerResultStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/ComputerResultStep.java
index b57ad3a..905ea72 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/ComputerResultStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/ComputerResultStep.java
@@ -30,6 +30,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.util.ReducingBarrierS
import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
+import org.apache.tinkerpop.gremlin.structure.Element;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.util.Attachable;
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
@@ -84,7 +85,7 @@ public final class ComputerResultStep<S> extends AbstractStep<S, S> {
final Traverser.Admin<S> traverser = this.traversers.next();
if (this.attachElements && (traverser.get() instanceof Attachable))
- traverser.set((S) ((Attachable) traverser.get()).attach(this.graph, Attachable.Method.GET));
+ traverser.set((S) ((Attachable<Element>) traverser.get()).attach(this.graph, Attachable.Method::get));
return traverser;
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traverser.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traverser.java
index f8e80f6..91ea128 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traverser.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traverser.java
@@ -19,10 +19,12 @@
package org.apache.tinkerpop.gremlin.process.traversal;
import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Host;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.util.Attachable;
import java.io.Serializable;
+import java.util.function.Function;
/**
* A {@code Traverser} represents the current state of an object flowing through a {@link Traversal}.
@@ -250,7 +252,7 @@ public interface Traverser<T> extends Serializable, Comparable<Traverser<T>>, Cl
* @return The inflated traverser
*/
@Override
- public T attach(final Vertex hostVertex, final Method method);
+ public T attach(final Vertex hostVertex, final Function<Host, Function<Attachable<T>, T>> method);
/**
* Traversers can not attach to graphs and thus, an {@link UnsupportedOperationException} is thrown.
@@ -260,7 +262,7 @@ public interface Traverser<T> extends Serializable, Comparable<Traverser<T>>, Cl
* @throws UnsupportedOperationException is always thrown as it makes no sense to attach a traverser to a graph
*/
@Override
- public default T attach(final Graph graph, final Method method) throws UnsupportedOperationException {
+ public default T attach(final Graph graph, final Function<Host, Function<Attachable<T>, T>> method) throws UnsupportedOperationException {
throw new UnsupportedOperationException("A traverser can only exist at the vertices of the graph, not the graph itself");
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_P_S_SE_SL_Traverser.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_P_S_SE_SL_Traverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_P_S_SE_SL_Traverser.java
index 9a0e4af..1051d6f 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_P_S_SE_SL_Traverser.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_P_S_SE_SL_Traverser.java
@@ -22,11 +22,13 @@ import org.apache.tinkerpop.gremlin.process.traversal.Path;
import org.apache.tinkerpop.gremlin.process.traversal.Step;
import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.ImmutablePath;
+import org.apache.tinkerpop.gremlin.structure.Host;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.util.Attachable;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
import java.util.Optional;
+import java.util.function.Function;
import java.util.function.UnaryOperator;
/**
@@ -64,7 +66,7 @@ public class B_O_P_S_SE_SL_Traverser<T> extends B_O_S_SE_SL_Traverser<T> {
}
@Override
- public T attach(final Vertex hostVertex, final Method method) {
+ public T attach(final Vertex hostVertex, final Function<Host, Function<Attachable<T>, T>> method) {
// you do not want to attach a path because it will reference graph objects not at the current vertex
if (this.t instanceof Attachable && !(((Attachable) this.t).get() instanceof Path))
this.t = ((Attachable<T>) this.t).attach(hostVertex, method);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractTraverser.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractTraverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractTraverser.java
index de94701..2856e13 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractTraverser.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractTraverser.java
@@ -24,10 +24,13 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalSideEffects;
import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyPath;
import org.apache.tinkerpop.gremlin.process.traversal.util.EmptyTraversalSideEffects;
+import org.apache.tinkerpop.gremlin.structure.Host;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.util.Attachable;
import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
+import java.util.function.Function;
+
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
@@ -107,7 +110,7 @@ public abstract class AbstractTraverser<T> implements Traverser<T>, Traverser.Ad
}
@Override
- public T attach(final Vertex hostVertex, final Method method) {
+ public T attach(final Vertex hostVertex, final Function<Host, Function<Attachable<T>, T>> method) {
// you do not want to attach a path because it will reference graph objects not at the current vertex
if (this.t instanceof Attachable && !(((Attachable) this.t).get() instanceof Path))
this.t = ((Attachable<T>) this.t).attach(hostVertex, method);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/EmptyTraverser.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/EmptyTraverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/EmptyTraverser.java
index 0256956..44c13e5 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/EmptyTraverser.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/EmptyTraverser.java
@@ -23,7 +23,11 @@ import org.apache.tinkerpop.gremlin.process.traversal.Step;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalSideEffects;
import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyPath;
+import org.apache.tinkerpop.gremlin.structure.Host;
import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.util.Attachable;
+
+import java.util.function.Function;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
@@ -86,7 +90,7 @@ public final class EmptyTraverser<T> implements Traverser<T>, Traverser.Admin<T>
}
@Override
- public T attach(final Vertex hostVertex, final Method method) {
+ public T attach(final Vertex hostVertex, final Function<Host, Function<Attachable<T>, T>> method) {
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
index d372b44..0d1ecbd 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
@@ -125,9 +125,9 @@ public class GryoReader implements GraphReader {
// have vertex labels in the output we can't do this single pass
final Map<Vertex,Vertex> cache = new HashMap<>();
IteratorUtils.iterate(new VertexInputIterator(new Input(inputStream), attachable ->
- cache.put(attachable.get(), attachable.attach(graphToWriteTo, Attachable.Method.CREATE))));
+ cache.put(attachable.get(), attachable.attach(graphToWriteTo, Attachable.Method::create))));
cache.entrySet().forEach(kv -> kv.getKey().edges(Direction.OUT)
- .forEachRemaining(e -> ((Attachable) e).attach(kv.getValue(), Attachable.Method.CREATE)));
+ .forEachRemaining(e -> ((StarGraph.StarEdge) e).attach(kv.getValue(), Attachable.Method::create)));
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
index 5b34f21..280ad15 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
@@ -34,9 +34,9 @@ import java.util.function.Function;
/**
* An interface that provides methods for detached properties and elements to be re-attached to the {@link Graph}.
- * There are two general ways in which they can be attached: {@link Method#GET} or {@link Method#CREATE}.
- * A {@link Method#GET} will find the property/element at the host location and return it.
- * A {@link Method#CREATE} will create the property/element at the host location and return it.
+ * There are two general ways in which they can be attached: {@link Method#get} or {@link Method#create}.
+ * A {@link Method#get} will find the property/element at the host location and return it.
+ * A {@link Method#create} will create the property/element at the host location and return it.
*
* @author Marko A. Rodriguez (http://markorodriguez.com)
* @author Stephen Mallette (http://stephen.genoprime.com)
@@ -50,15 +50,15 @@ public interface Attachable<V> {
*/
public V get();
- public default V attach(final Vertex hostVertex, final Method method) throws IllegalStateException {
- return (V) method.apply(hostVertex).apply(this);
+ public default V attach(final Vertex hostVertex, final Function<Host, Function<Attachable<V>, V>> method) throws IllegalStateException {
+ return method.apply(hostVertex).apply(this);
}
- public default V attach(final Graph hostGraph, final Method method) throws IllegalStateException {
- return (V) method.apply(hostGraph).apply(this);
+ public default V attach(final Graph hostGraph, final Function<Host, Function<Attachable<V>, V>> method) throws IllegalStateException {
+ return method.apply(hostGraph).apply(this);
}
- public static class Method2 {
+ public static class Method {
public static <V> Function<Attachable<V>, V> get(final Host hostVertexOrGraph) {
return (Attachable<V> attachable) -> {
final Object base = attachable.get();
@@ -95,6 +95,42 @@ public interface Attachable<V> {
};
}
+ public static <V> Function<Attachable<V>, V> getOrCreate(final Host hostVertexOrGraph) {
+ return (Attachable<V> attachable) -> {
+ final Object base = attachable.get();
+ if (base instanceof Vertex) {
+ return (V) (hostVertexOrGraph instanceof Graph ?
+ Method.getVertex((Attachable<Vertex>) attachable, (Graph) hostVertexOrGraph) :
+ Method.getVertex((Attachable<Vertex>) attachable, (Vertex) hostVertexOrGraph))
+ .orElse(hostVertexOrGraph instanceof Graph ?
+ Method.createVertex((Attachable<Vertex>)attachable, (Graph) hostVertexOrGraph) :
+ Method.createVertex((Attachable<Vertex>) attachable, (Vertex) hostVertexOrGraph));
+ } else if (base instanceof Edge) {
+ return (V) (hostVertexOrGraph instanceof Graph ?
+ Method.getEdge((Attachable<Edge>) attachable, (Graph) hostVertexOrGraph) :
+ Method.getEdge((Attachable<Edge>) attachable, (Vertex) hostVertexOrGraph))
+ .orElse(hostVertexOrGraph instanceof Graph ?
+ Method.createEdge((Attachable<Edge>)attachable, (Graph) hostVertexOrGraph) :
+ Method.createEdge((Attachable<Edge>)attachable, (Vertex) hostVertexOrGraph));
+ } else if (base instanceof VertexProperty) {
+ return (V) (hostVertexOrGraph instanceof Graph ?
+ Method.getVertexProperty((Attachable<VertexProperty>) attachable, (Graph) hostVertexOrGraph) :
+ Method.getVertexProperty((Attachable<VertexProperty>) attachable, (Vertex) hostVertexOrGraph))
+ .orElse(hostVertexOrGraph instanceof Graph ?
+ Method.createVertexProperty((Attachable<VertexProperty>)attachable, (Graph) hostVertexOrGraph) :
+ Method.createVertexProperty((Attachable<VertexProperty>) attachable, (Vertex) hostVertexOrGraph));
+ } else if (base instanceof Property) {
+ return (V) (hostVertexOrGraph instanceof Graph ?
+ Method.getProperty((Attachable<Property>) attachable, (Graph) hostVertexOrGraph) :
+ Method.getProperty((Attachable<Property>) attachable, (Vertex) hostVertexOrGraph))
+ .orElse(hostVertexOrGraph instanceof Graph ?
+ Method.createProperty((Attachable<Property>)attachable, (Graph) hostVertexOrGraph) :
+ Method.createProperty((Attachable<Property>)attachable, (Vertex) hostVertexOrGraph));
+ } else
+ throw Attachable.Exceptions.providedAttachableMustContainAGraphObject(attachable);
+ };
+ }
+
public static <V> Function<Attachable<V>, V> create(final Host hostVertexOrGraph) {
return (Attachable<V> attachable) -> {
final Object base = attachable.get();
@@ -118,113 +154,6 @@ public interface Attachable<V> {
throw Attachable.Exceptions.providedAttachableMustContainAGraphObject(attachable);
};
}
- }
-
- public enum Method implements Function<Host, Function<Attachable, Object>> {
- GET {
- @Override
- public Function<Attachable, Object> apply(final Host hostVertexOrGraph) {
- return (Attachable attachable) -> {
- final Object base = attachable.get();
- if (base instanceof Vertex) {
- final Optional<Vertex> optional = hostVertexOrGraph instanceof Graph ?
- Method.getVertex(attachable, (Graph) hostVertexOrGraph) :
- Method.getVertex(attachable, (Vertex) hostVertexOrGraph);
- return optional.orElseThrow(() -> hostVertexOrGraph instanceof Graph ?
- Attachable.Exceptions.canNotGetAttachableFromHostGraph(attachable, (Graph) hostVertexOrGraph) :
- Attachable.Exceptions.canNotGetAttachableFromHostVertex(attachable, (Vertex) hostVertexOrGraph));
- } else if (base instanceof Edge) {
- final Optional<Edge> optional = hostVertexOrGraph instanceof Graph ?
- Method.getEdge(attachable, (Graph) hostVertexOrGraph) :
- Method.getEdge(attachable, (Vertex) hostVertexOrGraph);
- return optional.orElseThrow(() -> hostVertexOrGraph instanceof Graph ?
- Attachable.Exceptions.canNotGetAttachableFromHostGraph(attachable, (Graph) hostVertexOrGraph) :
- Attachable.Exceptions.canNotGetAttachableFromHostVertex(attachable, (Vertex) hostVertexOrGraph));
- } else if (base instanceof VertexProperty) {
- final Optional<VertexProperty> optional = hostVertexOrGraph instanceof Graph ?
- Method.getVertexProperty(attachable, (Graph) hostVertexOrGraph) :
- Method.getVertexProperty(attachable, (Vertex) hostVertexOrGraph);
- return optional.orElseThrow(() -> hostVertexOrGraph instanceof Graph ?
- Attachable.Exceptions.canNotGetAttachableFromHostGraph(attachable, (Graph) hostVertexOrGraph) :
- Attachable.Exceptions.canNotGetAttachableFromHostVertex(attachable, (Vertex) hostVertexOrGraph));
- } else if (base instanceof Property) {
- final Optional<Property> optional = hostVertexOrGraph instanceof Graph ?
- Method.getProperty(attachable, (Graph) hostVertexOrGraph) :
- Method.getProperty(attachable, (Vertex) hostVertexOrGraph);
- return optional.orElseThrow(() -> hostVertexOrGraph instanceof Graph ?
- Attachable.Exceptions.canNotGetAttachableFromHostGraph(attachable, (Graph) hostVertexOrGraph) :
- Attachable.Exceptions.canNotGetAttachableFromHostVertex(attachable, (Vertex) hostVertexOrGraph));
- } else
- throw Attachable.Exceptions.providedAttachableMustContainAGraphObject(attachable);
- };
- }
- },
-
- CREATE {
- @Override
- public Function<Attachable, Object> apply(final Host hostVertexOrGraph) {
- return (Attachable attachable) -> {
- final Object base = attachable.get();
- if (base instanceof Vertex) {
- return hostVertexOrGraph instanceof Graph ?
- Method.createVertex(attachable, (Graph) hostVertexOrGraph) :
- Method.createVertex(attachable, (Vertex) hostVertexOrGraph);
- } else if (base instanceof Edge) {
- return hostVertexOrGraph instanceof Graph ?
- Method.createEdge(attachable, (Graph) hostVertexOrGraph) :
- Method.createEdge(attachable, (Vertex) hostVertexOrGraph);
- } else if (base instanceof VertexProperty) {
- return hostVertexOrGraph instanceof Graph ?
- Method.createVertexProperty(attachable, (Graph) hostVertexOrGraph) :
- Method.createVertexProperty(attachable, (Vertex) hostVertexOrGraph);
- } else if (base instanceof Property) {
- return hostVertexOrGraph instanceof Graph ?
- Method.createProperty(attachable, (Graph) hostVertexOrGraph) :
- Method.createProperty(attachable, (Vertex) hostVertexOrGraph);
- } else
- throw Attachable.Exceptions.providedAttachableMustContainAGraphObject(attachable);
- };
- }
- },
-
- GET_OR_CREATE {
- @Override
- public Function<Attachable, Object> apply(final Host hostVertexOrGraph) {
- return (Attachable attachable) -> {
- final Object base = attachable.get();
- if (base instanceof Vertex) {
- return (hostVertexOrGraph instanceof Graph ?
- Method.getVertex(attachable, (Graph) hostVertexOrGraph) :
- Method.getVertex(attachable, (Vertex) hostVertexOrGraph))
- .orElse(hostVertexOrGraph instanceof Graph ?
- Method.createVertex(attachable, (Graph) hostVertexOrGraph) :
- Method.createVertex(attachable, (Vertex) hostVertexOrGraph));
- } else if (base instanceof Edge) {
- return (hostVertexOrGraph instanceof Graph ?
- Method.getEdge(attachable, (Graph) hostVertexOrGraph) :
- Method.getEdge(attachable, (Vertex) hostVertexOrGraph))
- .orElse(hostVertexOrGraph instanceof Graph ?
- Method.createEdge(attachable, (Graph) hostVertexOrGraph) :
- Method.createEdge(attachable, (Vertex) hostVertexOrGraph));
- } else if (base instanceof VertexProperty) {
- return (hostVertexOrGraph instanceof Graph ?
- Method.getVertexProperty(attachable, (Graph) hostVertexOrGraph) :
- Method.getVertexProperty(attachable, (Vertex) hostVertexOrGraph))
- .orElse(hostVertexOrGraph instanceof Graph ?
- Method.createVertexProperty(attachable, (Graph) hostVertexOrGraph) :
- Method.createVertexProperty(attachable, (Vertex) hostVertexOrGraph));
- } else if (base instanceof Property) {
- return (hostVertexOrGraph instanceof Graph ?
- Method.getProperty(attachable, (Graph) hostVertexOrGraph) :
- Method.getProperty(attachable, (Vertex) hostVertexOrGraph))
- .orElse(hostVertexOrGraph instanceof Graph ?
- Method.createProperty(attachable, (Graph) hostVertexOrGraph) :
- Method.createProperty(attachable, (Vertex) hostVertexOrGraph));
- } else
- throw Attachable.Exceptions.providedAttachableMustContainAGraphObject(attachable);
- };
- }
- };
///////////////////
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java
index 8610922..9fdb756 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java
@@ -22,10 +22,13 @@ import org.apache.tinkerpop.gremlin.process.traversal.Path;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.MutablePath;
import org.apache.tinkerpop.gremlin.structure.Element;
import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Host;
import org.apache.tinkerpop.gremlin.structure.Property;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.util.Attachable;
+import java.util.function.Function;
+
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
@@ -61,14 +64,14 @@ public class DetachedPath extends MutablePath implements Attachable<Path> {
}
@Override
- public Path attach(final Graph hostGraph, final Method method) {
+ public Path attach(final Graph hostGraph, final Function<Host, Function<Attachable<Path>, Path>> method) {
final Path path = MutablePath.make(); // TODO: Use ImmutablePath?
this.forEach((object, labels) -> path.extend(object instanceof Attachable ? ((Attachable) object).attach(hostGraph, method) : object, labels.toArray(new String[labels.size()])));
return path;
}
@Override
- public Path attach(final Vertex hostVertex, final Method method) {
+ public Path attach(final Vertex hostVertex, final Function<Host, Function<Attachable<Path>, Path>> method) {
final Path path = MutablePath.make(); // TODO: Use ImmutablePath?
this.forEach((object, labels) -> path.extend(object instanceof Attachable ? ((Attachable) object).attach(hostVertex, method) : object, labels.toArray(new String[labels.size()])));
return path;
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java
index 7b85c17..1f9b41b 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java
@@ -25,10 +25,13 @@ import org.apache.tinkerpop.gremlin.process.traversal.Path;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.MutablePath;
import org.apache.tinkerpop.gremlin.structure.Element;
import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Host;
import org.apache.tinkerpop.gremlin.structure.Property;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.util.Attachable;
+import java.util.function.Function;
+
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
@@ -64,14 +67,14 @@ public class ReferencePath extends MutablePath implements Attachable<Path> {
}
@Override
- public Path attach(final Graph hostGraph, final Method method) {
+ public Path attach(final Graph hostGraph, final Function<Host, Function<Attachable<Path>, Path>> method) {
final Path path = MutablePath.make(); // TODO: Use ImmutablePath?
this.forEach((object, labels) -> path.extend(object instanceof Attachable ? ((Attachable) object).attach(hostGraph, method) : object, labels.toArray(new String[labels.size()])));
return path;
}
@Override
- public Path attach(final Vertex hostVertex, final Method method) {
+ public Path attach(final Vertex hostVertex, final Function<Host, Function<Attachable<Path>, Path>> method) {
final Path path = MutablePath.make(); // TODO: Use ImmutablePath?
this.forEach((object, labels) -> path.extend(object instanceof Attachable ? ((Attachable) object).attach(hostVertex, method) : object, labels.toArray(new String[labels.size()])));
return path;
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdgeTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdgeTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdgeTest.java
index 0bd9b1b..c424372 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdgeTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdgeTest.java
@@ -126,7 +126,7 @@ public class DetachedEdgeTest extends AbstractGremlinTest {
public void shouldAttachToGraph() {
final Edge toDetach = g.E(convertToEdgeId("josh", "created", "lop")).next();
final DetachedEdge detachedEdge = DetachedFactory.detach(toDetach, true);
- final Edge attached = detachedEdge.attach(graph, Attachable.Method.GET);
+ final Edge attached = detachedEdge.attach(graph, Attachable.Method::get);
assertEquals(toDetach, attached);
assertFalse(attached instanceof DetachedEdge);
@@ -138,7 +138,7 @@ public class DetachedEdgeTest extends AbstractGremlinTest {
final Edge toDetach = g.E(convertToEdgeId("josh", "created", "lop")).next();
final Vertex outV = toDetach.vertices(Direction.OUT).next();
final DetachedEdge detachedEdge = DetachedFactory.detach(toDetach, true);
- final Edge attached = detachedEdge.attach(outV, Attachable.Method.GET);
+ final Edge attached = detachedEdge.attach(outV, Attachable.Method::get);
assertEquals(toDetach, attached);
assertFalse(attached instanceof DetachedEdge);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPropertyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPropertyTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPropertyTest.java
index 2fbb5e6..344ab68 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPropertyTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPropertyTest.java
@@ -73,7 +73,7 @@ public class DetachedPropertyTest extends AbstractGremlinTest {
final Edge e = g.E(convertToEdgeId("josh", "created", "lop")).next();
final Property toDetach = e.properties("weight").next();
final DetachedProperty<?> detachedProperty = DetachedFactory.detach(toDetach);
- final Property attached = detachedProperty.attach(graph, Attachable.Method.GET);
+ final Property attached = detachedProperty.attach(graph, Attachable.Method::get);
assertEquals(toDetach, attached);
assertFalse(attached instanceof DetachedProperty);
@@ -85,7 +85,7 @@ public class DetachedPropertyTest extends AbstractGremlinTest {
final Edge e = g.E(convertToEdgeId("josh", "created", "lop")).next();
final Property toDetach = e.property("weight");
final DetachedProperty<?> detachedProperty = DetachedFactory.detach(toDetach);
- final Property attached = detachedProperty.attach(e.outVertex(), Attachable.Method.GET);
+ final Property attached = detachedProperty.attach(e.outVertex(), Attachable.Method::get);
assertEquals(toDetach, attached);
assertFalse(attached instanceof DetachedProperty);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexPropertyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexPropertyTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexPropertyTest.java
index 78d1a6b..1f7730e 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexPropertyTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexPropertyTest.java
@@ -128,7 +128,7 @@ public class DetachedVertexPropertyTest extends AbstractGremlinTest {
final Vertex v = graph.addVertex();
final VertexProperty toDetach = v.property(VertexProperty.Cardinality.single, "test", "this");
final DetachedVertexProperty<?> detached = DetachedFactory.detach(toDetach, true);
- final VertexProperty attached = detached.attach(graph, Attachable.Method.GET);
+ final VertexProperty attached = detached.attach(graph, Attachable.Method::get);
assertEquals(toDetach, attached);
assertFalse(attached instanceof DetachedVertexProperty);
@@ -140,7 +140,7 @@ public class DetachedVertexPropertyTest extends AbstractGremlinTest {
final Vertex v = graph.addVertex();
final VertexProperty toDetach = v.property(VertexProperty.Cardinality.single, "test", "this");
final DetachedVertexProperty<?> detached = DetachedFactory.detach(toDetach, true);
- final VertexProperty attached = detached.attach(v, Attachable.Method.GET);
+ final VertexProperty attached = detached.attach(v, Attachable.Method::get);
assertEquals(toDetach, attached);
assertEquals(toDetach.getClass(), attached.getClass());
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexTest.java
index 99cd42f..1aebac7 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexTest.java
@@ -139,7 +139,7 @@ public class DetachedVertexTest extends AbstractGremlinTest {
public void shouldAttachToGraph() {
final Vertex toDetach = g.V(convertToVertexId("josh")).next();
final DetachedVertex detachedVertex = DetachedFactory.detach(toDetach, true);
- final Vertex attached = detachedVertex.attach(graph, Attachable.Method.GET);
+ final Vertex attached = detachedVertex.attach(graph, Attachable.Method::get);
assertEquals(toDetach, attached);
assertFalse(attached instanceof DetachedVertex);
@@ -150,7 +150,7 @@ public class DetachedVertexTest extends AbstractGremlinTest {
public void shouldAttachToVertex() {
final Vertex toDetach = g.V(convertToVertexId("josh")).next();
final DetachedVertex detachedVertex = DetachedFactory.detach(toDetach, true);
- final Vertex attached = detachedVertex.attach(toDetach, Attachable.Method.GET);
+ final Vertex attached = detachedVertex.attach(toDetach, Attachable.Method::get);
assertEquals(toDetach, attached);
assertFalse(attached instanceof DetachedVertex);
@@ -293,7 +293,7 @@ public class DetachedVertexTest extends AbstractGremlinTest {
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
public void shouldCreateVertex() {
final DetachedVertex detachedVertex = new DetachedVertex(23, "dog", Collections.emptyMap());
- detachedVertex.attach(graph, Attachable.Method.CREATE);
+ detachedVertex.attach(graph, Attachable.Method::create);
assertEquals(7, IteratorUtils.count(graph.vertices()));
final AtomicInteger dogTimes = new AtomicInteger(0);
graph.vertices().forEachRemaining(vertex -> {
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdgeTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdgeTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdgeTest.java
index 20e4073..8577865 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdgeTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdgeTest.java
@@ -103,7 +103,7 @@ public class ReferenceEdgeTest extends AbstractGremlinTest {
public void shouldAttachToGraph() {
final Edge toReference = g.E(convertToEdgeId("josh", "created", "lop")).next();
final ReferenceEdge referenceEdge = ReferenceFactory.detach(toReference);
- final Edge referenced = referenceEdge.attach(graph, Attachable.Method.GET);
+ final Edge referenced = referenceEdge.attach(graph, Attachable.Method::get);
assertEquals(toReference, referenced);
assertFalse(referenced instanceof ReferenceEdge);
@@ -115,7 +115,7 @@ public class ReferenceEdgeTest extends AbstractGremlinTest {
final Edge toReference = g.E(convertToEdgeId("josh", "created", "lop")).next();
final Vertex outV = toReference.vertices(Direction.OUT).next();
final ReferenceEdge referenceEdge = ReferenceFactory.detach(toReference);
- final Edge attached = referenceEdge.attach(outV, Attachable.Method.GET);
+ final Edge attached = referenceEdge.attach(outV, Attachable.Method::get);
assertEquals(toReference, attached);
assertFalse(attached instanceof ReferenceEdge);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexPropertyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexPropertyTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexPropertyTest.java
index d8d0086..d7cf9b2 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexPropertyTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexPropertyTest.java
@@ -81,7 +81,7 @@ public class ReferenceVertexPropertyTest extends AbstractGremlinTest {
final Vertex v = graph.addVertex();
final VertexProperty toReference = v.property(VertexProperty.Cardinality.single, "test", "this");
final ReferenceVertexProperty<?> rvp = ReferenceFactory.detach(toReference);
- final VertexProperty referenced = rvp.attach(graph, Attachable.Method.GET);
+ final VertexProperty referenced = rvp.attach(graph, Attachable.Method::get);
assertEquals(toReference, referenced);
assertFalse(referenced instanceof ReferenceVertexProperty);
@@ -93,7 +93,7 @@ public class ReferenceVertexPropertyTest extends AbstractGremlinTest {
final Vertex v = graph.addVertex();
final VertexProperty toReference = v.property(VertexProperty.Cardinality.single, "test", "this");
final ReferenceVertexProperty<?> rvp = ReferenceFactory.detach(toReference);
- final VertexProperty referenced = rvp.attach(v, Attachable.Method.GET);
+ final VertexProperty referenced = rvp.attach(v, Attachable.Method::get);
assertEquals(toReference, referenced);
assertEquals(toReference.getClass(), referenced.getClass());
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexTest.java
index 41e9c67..bcfca5e 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexTest.java
@@ -103,7 +103,7 @@ public class ReferenceVertexTest extends AbstractGremlinTest {
public void shouldAttachToGraph() {
final Vertex v = g.V(convertToVertexId("josh")).next();
final ReferenceVertex referenceVertex = ReferenceFactory.detach(v);
- final Vertex attachedV = referenceVertex.attach(graph, Attachable.Method.GET);
+ final Vertex attachedV = referenceVertex.attach(graph, Attachable.Method::get);
assertEquals(v, attachedV);
assertFalse(attachedV instanceof ReferenceVertex);
@@ -114,7 +114,7 @@ public class ReferenceVertexTest extends AbstractGremlinTest {
public void shouldAttachToVertex() {
final Vertex v = g.V(convertToVertexId("josh")).next();
final ReferenceVertex referenceVertex = ReferenceFactory.detach(v);
- final Vertex attachedV = referenceVertex.attach(v, Attachable.Method.GET);
+ final Vertex attachedV = referenceVertex.attach(v, Attachable.Method::get);
assertEquals(v, attachedV);
assertFalse(attachedV instanceof ReferenceVertex);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
index cf34667..66c8594 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
@@ -83,18 +83,18 @@ public class StarGraphTest extends AbstractGremlinTest {
@LoadGraphWith(LoadGraphWith.GraphData.CREW)
public void testAttachableGetMethod() {
// vertex host
- g.V().forEachRemaining(vertex -> TestHelper.validateEquality(vertex, StarGraph.of(vertex).getStarVertex().attach(vertex, Attachable.Method.GET)));
- g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().properties().forEachRemaining(vertexProperty -> TestHelper.validateEquality(vertexProperty, ((Attachable<VertexProperty>) vertexProperty).attach(vertex, Attachable.Method.GET))));
- g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().properties().forEachRemaining(vertexProperty -> vertexProperty.properties().forEachRemaining(property -> TestHelper.validateEquality(property, ((Attachable<Property>) property).attach(vertex, Attachable.Method.GET)))));
- g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().edges(Direction.OUT).forEachRemaining(edge -> TestHelper.validateEquality(edge, ((Attachable<Edge>) edge).attach(vertex, Attachable.Method.GET))));
- g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().edges(Direction.OUT).forEachRemaining(edge -> edge.properties().forEachRemaining(property -> TestHelper.validateEquality(property, ((Attachable<Property>) property).attach(vertex, Attachable.Method.GET)))));
+ g.V().forEachRemaining(vertex -> TestHelper.validateEquality(vertex, StarGraph.of(vertex).getStarVertex().attach(vertex, Attachable.Method::get)));
+ g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().properties().forEachRemaining(vertexProperty -> TestHelper.validateEquality(vertexProperty, ((Attachable<VertexProperty>) vertexProperty).attach(vertex, Attachable.Method::get))));
+ g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().properties().forEachRemaining(vertexProperty -> vertexProperty.properties().forEachRemaining(property -> TestHelper.validateEquality(property, ((Attachable<Property>) property).attach(vertex, Attachable.Method::get)))));
+ g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().edges(Direction.OUT).forEachRemaining(edge -> TestHelper.validateEquality(edge, ((Attachable<Edge>) edge).attach(vertex, Attachable.Method::get))));
+ g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().edges(Direction.OUT).forEachRemaining(edge -> edge.properties().forEachRemaining(property -> TestHelper.validateEquality(property, ((Attachable<Property>) property).attach(vertex, Attachable.Method::get)))));
// graph host
- g.V().forEachRemaining(vertex -> TestHelper.validateEquality(vertex, StarGraph.of(vertex).getStarVertex().attach(graph, Attachable.Method.GET)));
- g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().properties().forEachRemaining(vertexProperty -> TestHelper.validateEquality(vertexProperty, ((Attachable<VertexProperty>) vertexProperty).attach(graph, Attachable.Method.GET))));
- g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().properties().forEachRemaining(vertexProperty -> vertexProperty.properties().forEachRemaining(property -> TestHelper.validateEquality(property, ((Attachable<Property>) property).attach(graph, Attachable.Method.GET)))));
- g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().edges(Direction.OUT).forEachRemaining(edge -> TestHelper.validateEquality(edge, ((Attachable<Edge>) edge).attach(graph, Attachable.Method.GET))));
- g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().edges(Direction.OUT).forEachRemaining(edge -> edge.properties().forEachRemaining(property -> TestHelper.validateEquality(property, ((Attachable<Property>) property).attach(graph, Attachable.Method.GET)))));
+ g.V().forEachRemaining(vertex -> TestHelper.validateEquality(vertex, StarGraph.of(vertex).getStarVertex().attach(graph, Attachable.Method::get)));
+ g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().properties().forEachRemaining(vertexProperty -> TestHelper.validateEquality(vertexProperty, ((Attachable<VertexProperty>) vertexProperty).attach(graph, Attachable.Method::get))));
+ g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().properties().forEachRemaining(vertexProperty -> vertexProperty.properties().forEachRemaining(property -> TestHelper.validateEquality(property, ((Attachable<Property>) property).attach(graph, Attachable.Method::get)))));
+ g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().edges(Direction.OUT).forEachRemaining(edge -> TestHelper.validateEquality(edge, ((Attachable<Edge>) edge).attach(graph, Attachable.Method::get))));
+ g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().edges(Direction.OUT).forEachRemaining(edge -> edge.properties().forEachRemaining(property -> TestHelper.validateEquality(property, ((Attachable<Property>) property).attach(graph, Attachable.Method::get)))));
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkExecutor.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkExecutor.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkExecutor.java
index 485a953..48b0ac1 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkExecutor.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkExecutor.java
@@ -91,7 +91,7 @@ public final class SparkExecutor {
final boolean hasViewAndMessages = vertexViewIncoming._2()._2().isPresent(); // if this is the first iteration, then there are no views or messages
final List<DetachedVertexProperty<Object>> previousView = hasViewAndMessages ? vertexViewIncoming._2()._2().get().getView() : Collections.emptyList();
final List<M> incomingMessages = hasViewAndMessages ? vertexViewIncoming._2()._2().get().getIncomingMessages() : Collections.emptyList();
- previousView.forEach(property -> property.attach(vertex, Attachable.Method.CREATE)); // attach the view to the vertex
+ previousView.forEach(property -> property.attach(vertex, Attachable.Method::create)); // attach the view to the vertex
///
messenger.setVertexAndIncomingMessages(vertex, incomingMessages); // set the messenger with the incoming messages
workerVertexProgram.execute(ComputerGraph.of(vertex, elementComputeKeys), messenger, memory); // execute the vertex program on this vertex for this iteration
@@ -154,7 +154,7 @@ public final class SparkExecutor {
((StarGraph.StarVertex) vertex).dropEdges();
((StarGraph.StarVertex) vertex).dropVertexProperties(elementComputeKeys);
final List<DetachedVertexProperty<Object>> view = tuple._2().isPresent() ? tuple._2().get().getView() : Collections.emptyList();
- view.forEach(property -> property.attach(vertex, Attachable.Method.CREATE));
+ view.forEach(property -> property.attach(vertex, Attachable.Method::create));
return tuple._1();
});
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/GraphSONRecordReader.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/GraphSONRecordReader.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/GraphSONRecordReader.java
index 967e161..1d68338 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/GraphSONRecordReader.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/GraphSONRecordReader.java
@@ -65,8 +65,8 @@ public class GraphSONRecordReader extends RecordReader<NullWritable, VertexWrita
return false;
final StarGraph starGraph = StarGraph.open();
- final Function<Attachable<Vertex>, Vertex> vertexMaker = detachedVertex -> detachedVertex.attach(starGraph, Attachable.Method.CREATE);
- final Function<Attachable<Edge>, Edge> edgeMaker = detachedEdge -> detachedEdge.attach(starGraph, Attachable.Method.CREATE);
+ final Function<Attachable<Vertex>, Vertex> vertexMaker = detachedVertex -> detachedVertex.attach(starGraph, Attachable.Method::create);
+ final Function<Attachable<Edge>, Edge> edgeMaker = detachedEdge -> detachedEdge.attach(starGraph, Attachable.Method::create);
try (InputStream in = new ByteArrayInputStream(this.lineRecordReader.getCurrentValue().getBytes())) {
this.vertexWritable.set(this.hasEdges ?
this.graphsonReader.readVertex(in, vertexMaker, edgeMaker) :
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2a73dc9/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordReader.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordReader.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordReader.java
index b78ad9d..acfc8e4 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordReader.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordReader.java
@@ -131,8 +131,8 @@ public class GryoRecordReader extends RecordReader<NullWritable, VertexWritable>
if (terminatorLocation >= TERMINATOR.length) {
final StarGraph starGraph = StarGraph.open();
- final Function<Attachable<Vertex>, Vertex> vertexMaker = detachedVertex -> detachedVertex.attach(starGraph, Attachable.Method.CREATE);
- final Function<Attachable<Edge>, Edge> edgeMaker = detachedEdge -> detachedEdge.attach(starGraph, Attachable.Method.CREATE);
+ final Function<Attachable<Vertex>, Vertex> vertexMaker = detachedVertex -> detachedVertex.attach(starGraph, Attachable.Method::create);
+ final Function<Attachable<Edge>, Edge> edgeMaker = detachedEdge -> detachedEdge.attach(starGraph, Attachable.Method::create);
try (InputStream in = new ByteArrayInputStream(output.toByteArray())) {
this.vertexWritable.set(this.hasEdges ?
this.gryoReader.readVertex(in, vertexMaker, edgeMaker) :