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/04/08 18:53:58 UTC
[4/5] incubator-tinkerpop git commit: StarGraph is now in
structure/util/star and all the tests fully pass for SparkGraphComputer and
GiraphGraphComputer (which leverage it). HadoopGremlin no longer depends on
TinkerGraph as StarGraph has replaced it.
StarGraph is now in structure/util/star and all the tests fully pass for SparkGraphComputer and GiraphGraphComputer (which leverage it). HadoopGremlin no longer depends on TinkerGraph as StarGraph has replaced it.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/65b4596f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/65b4596f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/65b4596f
Branch: refs/heads/master
Commit: 65b4596f2ca50c6563568c85903d8e33fa9dcb4b
Parents: 2fc49e1
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Apr 8 10:53:26 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Apr 8 10:53:26 2015 -0600
----------------------------------------------------------------------
.../computer/util/star/StarAdjacentVertex.java | 104 ---
.../process/computer/util/star/StarEdge.java | 83 ---
.../process/computer/util/star/StarElement.java | 67 --
.../process/computer/util/star/StarGraph.java | 159 -----
.../process/computer/util/star/StarInEdge.java | 64 --
.../computer/util/star/StarInVertex.java | 51 --
.../process/computer/util/star/StarOutEdge.java | 63 --
.../computer/util/star/StarOutVertex.java | 51 --
.../computer/util/star/StarProperty.java | 68 --
.../process/computer/util/star/StarVertex.java | 141 ----
.../computer/util/star/StarVertexProperty.java | 112 ----
.../gremlin/structure/util/star/StarGraph.java | 639 +++++++++++++++++++
hadoop-gremlin/pom.xml | 5 -
.../process/computer/spark/SparkExecutor.java | 7 +-
.../hadoop/structure/io/VertexWritable.java | 12 +-
.../io/graphson/GraphSONRecordReader.java | 9 +-
.../structure/io/gryo/GryoRecordReader.java | 10 +-
.../structure/io/script/ScriptRecordReader.java | 6 +-
.../tinkergraph/structure/TinkerProperty.java | 3 +
.../tinkergraph/structure/TinkerGraphTest.java | 7 +-
20 files changed, 663 insertions(+), 998 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarAdjacentVertex.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarAdjacentVertex.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarAdjacentVertex.java
deleted file mode 100644
index 61228f0..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarAdjacentVertex.java
+++ /dev/null
@@ -1,104 +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 org.apache.tinkerpop.gremlin.process.computer.util.star;
-
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Element;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
-import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
-
-import java.util.Collections;
-import java.util.Iterator;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public abstract class StarAdjacentVertex implements Vertex {
-
- private final Object id;
- protected final StarVertex starVertex;
-
- protected StarAdjacentVertex(final Object id, final StarVertex starVertex) {
- this.id = id;
- this.starVertex = starVertex;
- }
-
- @Override
- public <V> VertexProperty<V> property(final VertexProperty.Cardinality cardinality, final String key, final V value, final Object... keyValues) {
- throw Element.Exceptions.propertyAdditionNotSupported();
- }
-
- @Override
- public Iterator<Edge> edges(final Direction direction, final String... edgeLabels) {
- return Collections.emptyIterator();
- }
-
- @Override
- public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) {
- return Collections.emptyIterator();
- }
-
- @Override
- public Object id() {
- return this.id;
- }
-
- @Override
- public String label() {
- return Vertex.DEFAULT_LABEL;
- }
-
- @Override
- public Graph graph() {
- return EmptyGraph.instance();
- }
-
- @Override
- public void remove() {
- throw Vertex.Exceptions.vertexRemovalNotSupported();
- }
-
- @Override
- public <V> Iterator<VertexProperty<V>> properties(final String... propertyKeys) {
- return Collections.emptyIterator();
- }
-
- @Override
- public boolean equals(final Object other) {
- return ElementHelper.areEqual(this, other);
- }
-
- @Override
- public int hashCode() {
- return ElementHelper.hashCode(this);
- }
-
- @Override
- public String toString() {
- return StringFactory.vertexString(this);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarEdge.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarEdge.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarEdge.java
deleted file mode 100644
index 7244610..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarEdge.java
+++ /dev/null
@@ -1,83 +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 org.apache.tinkerpop.gremlin.process.computer.util.star;
-
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Property;
-import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
-import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public abstract class StarEdge extends StarElement implements Edge {
-
- private Map<String, Object> properties = null;
-
- public StarEdge(final Object id, final String label) {
- super(id, label);
- }
-
- @Override
- public <V> Property<V> property(final String key, final V value) {
- if (null == this.properties)
- this.properties = new HashMap<>();
- this.properties.put(key, value);
- return new StarProperty<>(key, value,this);
- }
-
- @Override
- public <V> Iterator<Property<V>> properties(final String... propertyKeys) {
- return null == this.properties ?
- Collections.emptyIterator() :
- (Iterator) this.properties.entrySet()
- .stream()
- .filter(entry -> ElementHelper.keyExists(entry.getKey(), propertyKeys))
- .map(entry -> new StarProperty<>(entry.getKey(), (V) entry.getValue(),this))
- .iterator();
- }
-
- @Override
- public void remove() {
- //TODO: throw Edge.Exceptions.edgeRemovalNotSupported();
- }
-
- @Override
- public boolean equals(final Object other) {
- return ElementHelper.areEqual(this, other);
- }
-
- @Override
- public int hashCode() {
- return ElementHelper.hashCode(this);
- }
-
- @Override
- public String toString() {
- return StringFactory.edgeString(this);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarElement.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarElement.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarElement.java
deleted file mode 100644
index 8456ad3..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarElement.java
+++ /dev/null
@@ -1,67 +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 org.apache.tinkerpop.gremlin.process.computer.util.star;
-
-import org.apache.tinkerpop.gremlin.structure.Element;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
-import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public abstract class StarElement implements Element {
-
- private final Object id;
- private final String label;
-
- protected StarElement(final Object id, final String label) {
- this.id = null == id ? StarGraph.randomId() : id;
- this.label = label;
- }
-
- @Override
- public Object id() {
- return this.id;
- }
-
- @Override
- public String label() {
- return this.label;
- }
-
- @Override
- public Graph graph() {
- return EmptyGraph.instance();
- }
-
- @Override
- public boolean equals(final Object other) {
- return ElementHelper.areEqual(this, other);
- }
-
- @Override
- public int hashCode() {
- return ElementHelper.hashCode(this);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarGraph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarGraph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarGraph.java
deleted file mode 100644
index f9f0941..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarGraph.java
+++ /dev/null
@@ -1,159 +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 org.apache.tinkerpop.gremlin.process.computer.util.star;
-
-import org.apache.commons.configuration.BaseConfiguration;
-import org.apache.commons.configuration.Configuration;
-import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
-import org.apache.tinkerpop.gremlin.process.traversal.T;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Transaction;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
-import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Random;
-import java.util.stream.Stream;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class StarGraph implements Graph {
-
- private static final Configuration EMPTY_CONFIGURATION = new BaseConfiguration();
-
- private StarVertex starVertex;
-
- @Override
- public Vertex addVertex(final Object... keyValues) {
- throw Graph.Exceptions.vertexAdditionsNotSupported();
- }
-
- @Override
- public <C extends GraphComputer> C compute(final Class<C> graphComputerClass) throws IllegalArgumentException {
- throw Graph.Exceptions.graphComputerNotSupported();
- }
-
- @Override
- public GraphComputer compute() throws IllegalArgumentException {
- throw Graph.Exceptions.graphComputerNotSupported();
- }
-
- @Override
- public Iterator<Vertex> vertices(final Object... vertexIds) {
- return null == this.starVertex ?
- Collections.emptyIterator() :
- Stream.concat(
- Stream.of(this.starVertex),
- Stream.concat(
- this.starVertex.outEdges.values()
- .stream()
- .flatMap(List::stream)
- .map(Edge::inVertex),
- this.starVertex.inEdges.values()
- .stream()
- .flatMap(List::stream)
- .map(Edge::outVertex)))
- .filter(vertex -> ElementHelper.idExists(vertex.id(), vertexIds))
- .iterator();
- }
-
- @Override
- public Iterator<Edge> edges(final Object... edgeIds) {
- return null == this.starVertex ?
- Collections.emptyIterator() :
- Stream.concat(
- this.starVertex.inEdges.values().stream(),
- this.starVertex.outEdges.values().stream())
- .flatMap(List::stream)
- .filter(edge -> ElementHelper.idExists(edge.id(), edgeIds))
- .iterator();
- }
-
- @Override
- public Transaction tx() {
- throw Graph.Exceptions.transactionsNotSupported();
- }
-
- @Override
- public Variables variables() {
- throw Graph.Exceptions.variablesNotSupported();
- }
-
- @Override
- public Configuration configuration() {
- return EMPTY_CONFIGURATION;
- }
-
- @Override
- public void close() throws Exception {
-
- }
-
- @Override
- public String toString() {
- return StringFactory.graphString(this, "starOf:" + this.starVertex);
- }
-
- public static StarGraph open() {
- return new StarGraph();
- }
-
- public static Vertex addTo(final StarGraph graph, final DetachedVertex detachedVertex) {
- if (null != graph.starVertex)
- return null;
-
- graph.starVertex = new StarVertex(detachedVertex.id(), detachedVertex.label());
- detachedVertex.properties().forEachRemaining(detachedVertexProperty -> {
- final VertexProperty<?> vertexProperty = graph.starVertex.property(VertexProperty.Cardinality.list, detachedVertexProperty.key(), detachedVertexProperty.value());
- detachedVertexProperty.properties().forEachRemaining(detachedVertexPropertyProperty -> {
- vertexProperty.property(detachedVertexPropertyProperty.key(), detachedVertexPropertyProperty.value());
- // todo: id of vertex property
- });
- });
- return graph.starVertex;
- }
-
- public static Edge addTo(final StarGraph graph, final DetachedEdge edge) {
- final Object id = edge.inVertex().id();
- if (!graph.starVertex.id().equals(id)) {
- final Edge outEdge = graph.starVertex.addEdge(edge.label(), new StarInVertex(edge.inVertex().id(), graph.starVertex), new Object[]{T.id, edge.id()});
- edge.properties().forEachRemaining(property -> outEdge.property(property.key(), property.value()));
- return outEdge;
- } else {
- final Edge inEdge = new StarOutVertex(edge.outVertex().id(), graph.starVertex).addEdge(edge.label(), graph.starVertex, new Object[]{T.id, edge.id()});
- edge.properties().forEachRemaining(property -> inEdge.property(property.key(), property.value()));
- return inEdge;
- }
- }
-
- protected static Long randomId() {
- return new Random().nextLong(); // TODO: you shouldn't need this!
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarInEdge.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarInEdge.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarInEdge.java
deleted file mode 100644
index 5d382a8..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarInEdge.java
+++ /dev/null
@@ -1,64 +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 org.apache.tinkerpop.gremlin.process.computer.util.star;
-
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
-
-import java.util.Iterator;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class StarInEdge extends StarEdge {
-
- private final StarOutVertex starOutVertex;
- private final StarVertex starVertex;
-
- public StarInEdge(final Object id, final StarOutVertex starOutVertex, final String label, final StarVertex starVertex) {
- super(id, label);
- this.starOutVertex = starOutVertex;
- this.starVertex = starVertex;
-
- }
-
- @Override
- public Iterator<Vertex> vertices(final Direction direction) {
- if (direction.equals(Direction.OUT))
- return IteratorUtils.of(this.starOutVertex);
- else if (direction.equals(Direction.IN))
- return IteratorUtils.of(this.starVertex);
- else
- return IteratorUtils.of(this.starOutVertex, this.starVertex);
- }
-
- @Override
- public Vertex outVertex() {
- return this.starOutVertex;
- }
-
- @Override
- public Vertex inVertex() {
- return this.starVertex;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarInVertex.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarInVertex.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarInVertex.java
deleted file mode 100644
index b9ea627..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarInVertex.java
+++ /dev/null
@@ -1,51 +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 org.apache.tinkerpop.gremlin.process.computer.util.star;
-
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class StarInVertex extends StarAdjacentVertex {
-
- public StarInVertex(final Object id, final StarVertex starVertex) {
- super(id, starVertex);
- }
-
- @Override
- public Edge addEdge(final String label, final Vertex inVertex, final Object... keyValues) {
- List<Edge> outE = this.starVertex.outEdges.get(label);
- if (null == outE) {
- outE = new ArrayList<>();
- this.starVertex.outEdges.put(label, outE);
- }
- final StarOutEdge outEdge = new StarOutEdge(ElementHelper.getIdValue(keyValues).orElse(null), (StarVertex) inVertex, label, this);
- outE.add(outEdge);
- return outEdge;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarOutEdge.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarOutEdge.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarOutEdge.java
deleted file mode 100644
index 533bea6..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarOutEdge.java
+++ /dev/null
@@ -1,63 +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 org.apache.tinkerpop.gremlin.process.computer.util.star;
-
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
-
-import java.util.Iterator;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class StarOutEdge extends StarEdge {
-
- private final StarVertex starVertex;
- private final StarInVertex starInVertex;
-
- public StarOutEdge(final Object id, final StarVertex starVertex, final String label, final StarInVertex starInVertex) {
- super(id, label);
- this.starVertex = starVertex;
- this.starInVertex = starInVertex;
- }
-
- @Override
- public Iterator<Vertex> vertices(final Direction direction) {
- if (direction.equals(Direction.OUT))
- return IteratorUtils.of(this.starVertex);
- else if (direction.equals(Direction.IN))
- return IteratorUtils.of(this.starInVertex);
- else
- return IteratorUtils.of(this.starVertex, this.starInVertex);
- }
-
- @Override
- public Vertex outVertex() {
- return this.starVertex;
- }
-
- @Override
- public Vertex inVertex() {
- return this.starInVertex;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarOutVertex.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarOutVertex.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarOutVertex.java
deleted file mode 100644
index c6ead65..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarOutVertex.java
+++ /dev/null
@@ -1,51 +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 org.apache.tinkerpop.gremlin.process.computer.util.star;
-
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class StarOutVertex extends StarAdjacentVertex {
-
- public StarOutVertex(final Object id, final StarVertex starVertex) {
- super(id, starVertex);
- }
-
- @Override
- public Edge addEdge(final String label, final Vertex inVertex, final Object... keyValues) {
- List<Edge> inE = this.starVertex.inEdges.get(label);
- if (null == inE) {
- inE = new ArrayList<>();
- this.starVertex.inEdges.put(label, inE);
- }
- final StarInEdge inEdge = new StarInEdge(ElementHelper.getIdValue(keyValues).orElse(null), this, label, (StarVertex) inVertex);
- inE.add(inEdge);
- return inEdge;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarProperty.java
deleted file mode 100644
index e884f30..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarProperty.java
+++ /dev/null
@@ -1,68 +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 org.apache.tinkerpop.gremlin.process.computer.util.star;
-
-import org.apache.tinkerpop.gremlin.structure.Element;
-import org.apache.tinkerpop.gremlin.structure.Property;
-
-import java.util.NoSuchElementException;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class StarProperty<V> implements Property<V> {
-
- private final String key;
- private final V value;
- private final Element element;
-
- public StarProperty(final String key, final V value, final Element element) {
- this.key = key;
- this.value =value;
- this.element = element;
- }
-
- @Override
- public String key() {
- return this.key;
- }
-
- @Override
- public V value() throws NoSuchElementException {
- return this.value;
- }
-
- @Override
- public boolean isPresent() {
- return true;
- }
-
- @Override
- public Element element() {
- return this.element;
- }
-
- @Override
- public void remove() {
- throw Element.Exceptions.propertyRemovalNotSupported();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarVertex.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarVertex.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarVertex.java
deleted file mode 100644
index a66657a..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarVertex.java
+++ /dev/null
@@ -1,141 +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 org.apache.tinkerpop.gremlin.process.computer.util.star;
-
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
-import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Stream;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class StarVertex extends StarElement implements Vertex {
-
- protected Map<String, List<VertexProperty<?>>> properties = null;
- protected Map<String, List<Edge>> outEdges = new HashMap<>();
- protected Map<String, List<Edge>> inEdges = new HashMap<>();
-
- public StarVertex(final Object id, final String label) {
- super(id, label);
- }
-
- @Override
- public Edge addEdge(final String label, final Vertex inVertex, final Object... keyValues) {
- List<Edge> outE = this.outEdges.get(label);
- if (null == outE) {
- outE = new ArrayList<>();
- this.outEdges.put(label, outE);
- }
- final StarOutEdge outEdge = new StarOutEdge(ElementHelper.getIdValue(keyValues).orElse(null), this, label, (StarInVertex) inVertex);
- outE.add(outEdge);
- return outEdge;
- }
-
- @Override
- public <V> VertexProperty<V> property(final VertexProperty.Cardinality cardinality, final String key, V value, final Object... keyValues) {
- if (null == this.properties)
- this.properties = new HashMap<>();
-
- final List<VertexProperty<?>> list = cardinality.equals(VertexProperty.Cardinality.single) ? new ArrayList<>(1) : this.properties.getOrDefault(key, new ArrayList<>());
- final VertexProperty<V> vertexProperty = new StarVertexProperty<>(ElementHelper.getIdValue(keyValues).orElse(null), key, value, this, keyValues);
- list.add(vertexProperty);
- this.properties.put(key, list);
- return vertexProperty;
- }
-
- @Override
- public Iterator<Edge> edges(final Direction direction, final String... edgeLabels) {
- if (direction.equals(Direction.OUT)) {
- return this.outEdges.entrySet().stream()
- .filter(entry -> ElementHelper.keyExists(entry.getKey(), edgeLabels))
- .map(Map.Entry::getValue)
- .flatMap(List::stream)
- .iterator();
- } else if (direction.equals(Direction.IN)) {
- return this.inEdges.entrySet().stream()
- .filter(entry -> ElementHelper.keyExists(entry.getKey(), edgeLabels))
- .map(Map.Entry::getValue)
- .flatMap(List::stream)
- .iterator();
- } else {
- return Stream.concat(this.inEdges.entrySet().stream(), this.outEdges.entrySet().stream())
- .filter(entry -> ElementHelper.keyExists(entry.getKey(), edgeLabels))
- .map(Map.Entry::getValue)
- .flatMap(List::stream)
- .iterator();
- }
- }
-
- @Override
- public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) {
- if (direction.equals(Direction.OUT)) {
- return this.outEdges.entrySet().stream()
- .filter(entry -> ElementHelper.keyExists(entry.getKey(), edgeLabels))
- .map(Map.Entry::getValue)
- .flatMap(List::stream)
- .map(Edge::inVertex)
- .iterator();
- } else if (direction.equals(Direction.IN)) {
- return this.inEdges.entrySet().stream()
- .filter(entry -> ElementHelper.keyExists(entry.getKey(), edgeLabels))
- .map(Map.Entry::getValue)
- .flatMap(List::stream)
- .map(Edge::outVertex)
- .iterator();
- } else {
- return Stream.concat(this.outEdges.entrySet().stream(), this.inEdges.entrySet().stream())
- .filter(entry -> ElementHelper.keyExists(entry.getKey(), edgeLabels))
- .map(Map.Entry::getValue)
- .flatMap(List::stream)
- .map(Edge::outVertex)
- .iterator();
- }
- }
-
- @Override
- public void remove() {
-
- }
-
- @Override
- public String toString() {
- return StringFactory.vertexString(this);
- }
-
- @Override
- public <V> Iterator<VertexProperty<V>> properties(final String... propertyKeys) {
- return null == this.properties ?
- Collections.emptyIterator() :
- (Iterator) this.properties.entrySet().stream().filter(entry -> ElementHelper.keyExists(entry.getKey(), propertyKeys)).flatMap(entry -> entry.getValue().stream()).iterator();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarVertexProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarVertexProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarVertexProperty.java
deleted file mode 100644
index d3e35f5..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/star/StarVertexProperty.java
+++ /dev/null
@@ -1,112 +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 org.apache.tinkerpop.gremlin.process.computer.util.star;
-
-import org.apache.tinkerpop.gremlin.structure.Element;
-import org.apache.tinkerpop.gremlin.structure.Property;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.NoSuchElementException;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class StarVertexProperty<V> implements VertexProperty<V> {
-
- private final Object id;
- private final String key;
- private final V value;
- private Map<String, Object> properties = null;
- private final StarVertex starVertex;
-
- public StarVertexProperty(final Object id, final String key, final V value, final StarVertex starVertex, final Object... keyValues) {
- this.id = null == id ? StarGraph.randomId() : id;
- this.key = key;
- this.value = value;
- this.starVertex = starVertex;
- ElementHelper.attachProperties(this,keyValues);
- }
-
- @Override
- public String key() {
- return this.key;
- }
-
- @Override
- public V value() throws NoSuchElementException {
- return this.value;
- }
-
- @Override
- public boolean isPresent() {
- return true;
- }
-
- @Override
- public Vertex element() {
- return this.starVertex;
- }
-
- @Override
- public void remove() {
- this.starVertex.properties.get(this.key).remove(this);
- }
-
- @Override
- public <U> Iterator<Property<U>> properties(final String... propertyKeys) {
- return null == this.properties ?
- Collections.emptyIterator() :
- (Iterator) this.properties.entrySet().stream()
- .filter(entry -> ElementHelper.keyExists(entry.getKey(), propertyKeys))
- .map(entry -> new StarProperty<>(entry.getKey(), entry.getValue(), this))
- .iterator();
- }
-
- @Override
- public Object id() {
- return this.id;
- }
-
- @Override
- public <U> Property<U> property(final String key, final U value) {
- if (null == this.properties)
- this.properties = new HashMap<>();
- this.properties.put(key, value);
- return new StarProperty<>(key, value, this);
- }
-
- @Override
- public boolean equals(final Object other) {
- return ElementHelper.areEqual(this, other);
- }
-
- @Override
- public int hashCode() {
- return ElementHelper.hashCode((Element)this);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
new file mode 100644
index 0000000..fc01dbc
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
@@ -0,0 +1,639 @@
+/*
+ *
+ * * 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 org.apache.tinkerpop.gremlin.structure.util.star;
+
+import org.apache.commons.configuration.BaseConfiguration;
+import org.apache.commons.configuration.Configuration;
+import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
+import org.apache.tinkerpop.gremlin.process.traversal.T;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Element;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Property;
+import org.apache.tinkerpop.gremlin.structure.Transaction;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.UUID;
+import java.util.stream.Stream;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class StarGraph implements Graph {
+
+ private static final Configuration EMPTY_CONFIGURATION = new BaseConfiguration();
+ private StarVertex starVertex = null;
+
+ @Override
+ public Vertex addVertex(final Object... keyValues) {
+ return null == this.starVertex ?
+ this.starVertex = new StarVertex(ElementHelper.getIdValue(keyValues).get(), ElementHelper.getLabelValue(keyValues).get()) :
+ new StarAdjacentVertex(ElementHelper.getIdValue(keyValues).get());
+ }
+
+ @Override
+ public <C extends GraphComputer> C compute(final Class<C> graphComputerClass) throws IllegalArgumentException {
+ throw Graph.Exceptions.graphComputerNotSupported();
+ }
+
+ @Override
+ public GraphComputer compute() throws IllegalArgumentException {
+ throw Graph.Exceptions.graphComputerNotSupported();
+ }
+
+ @Override
+ public Iterator<Vertex> vertices(final Object... vertexIds) {
+ if (null == this.starVertex)
+ return Collections.emptyIterator();
+ else if (ElementHelper.idExists(this.starVertex.id(), vertexIds))
+ return IteratorUtils.of(this.starVertex);
+ else
+ return Collections.emptyIterator();
+ // TODO: is this the semantics we want? the only "real vertex" is star vertex.
+ /*return null == this.starVertex ?
+ Collections.emptyIterator() :
+ Stream.concat(
+ Stream.of(this.starVertex),
+ Stream.concat(
+ this.starVertex.outEdges.values()
+ .stream()
+ .flatMap(List::stream)
+ .map(Edge::inVertex),
+ this.starVertex.inEdges.values()
+ .stream()
+ .flatMap(List::stream)
+ .map(Edge::outVertex)))
+ .filter(vertex -> ElementHelper.idExists(vertex.id(), vertexIds))
+ .iterator();*/
+ }
+
+ @Override
+ public Iterator<Edge> edges(final Object... edgeIds) {
+ return null == this.starVertex ?
+ Collections.emptyIterator() :
+ Stream.concat(
+ this.starVertex.inEdges.values().stream(),
+ this.starVertex.outEdges.values().stream())
+ .flatMap(List::stream)
+ .filter(edge -> ElementHelper.idExists(edge.id(), edgeIds))
+ .iterator();
+ }
+
+ @Override
+ public Transaction tx() {
+ throw Graph.Exceptions.transactionsNotSupported();
+ }
+
+ @Override
+ public Variables variables() {
+ throw Graph.Exceptions.variablesNotSupported();
+ }
+
+ @Override
+ public Configuration configuration() {
+ return EMPTY_CONFIGURATION;
+ }
+
+ @Override
+ public void close() throws Exception {
+
+ }
+
+ @Override
+ public String toString() {
+ return StringFactory.graphString(this, "starOf:" + this.starVertex);
+ }
+
+ public static StarGraph open() {
+ return new StarGraph();
+ }
+
+ public static Vertex addTo(final StarGraph graph, final DetachedVertex detachedVertex) {
+ if (null != graph.starVertex)
+ return null;
+
+ graph.addVertex(T.id, detachedVertex.id(), T.label, detachedVertex.label());
+ detachedVertex.properties().forEachRemaining(detachedVertexProperty -> {
+ final List<Object> keyValues = new ArrayList<>();
+ keyValues.add(T.id);
+ keyValues.add(detachedVertexProperty.id());
+ detachedVertexProperty.properties().forEachRemaining(detachedVertexPropertyProperty -> {
+ keyValues.add(detachedVertexPropertyProperty.key());
+ keyValues.add(detachedVertexPropertyProperty.value());
+ });
+ graph.starVertex.property(VertexProperty.Cardinality.list, detachedVertexProperty.key(), detachedVertexProperty.value(), keyValues.toArray(new Object[keyValues.size()]));
+ });
+ return graph.starVertex;
+ }
+
+ public static Edge addTo(final StarGraph graph, final DetachedEdge edge) {
+ final List<Object> keyValues = new ArrayList<>();
+ keyValues.add(T.id);
+ keyValues.add(edge.id());
+ edge.properties().forEachRemaining(property -> {
+ keyValues.add(property.key());
+ keyValues.add(property.value());
+ });
+ return !graph.starVertex.id().equals(edge.inVertex().id()) ?
+ graph.starVertex.addOutEdge(edge.label(), edge.inVertex(), keyValues.toArray(new Object[keyValues.size()])) :
+ graph.starVertex.addInEdge(edge.label(), edge.outVertex(), keyValues.toArray(new Object[keyValues.size()]));
+ }
+
+ ///////////////////////
+ //// STAR ELEMENT ////
+ //////////////////////
+
+ public abstract class StarElement implements Element {
+
+ protected final Object id;
+ protected final String label;
+
+ protected StarElement(final Object id, final String label) {
+ this.id = id;
+ this.label = label;
+ }
+
+ @Override
+ public Object id() {
+ return this.id;
+ }
+
+ @Override
+ public String label() {
+ return this.label;
+ }
+
+ @Override
+ public Graph graph() {
+ return StarGraph.this;
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ return ElementHelper.areEqual(this, other);
+ }
+
+ @Override
+ public int hashCode() {
+ return ElementHelper.hashCode(this);
+ }
+ }
+
+ //////////////////////
+ //// STAR VERTEX ////
+ /////////////////////
+
+ public final class StarVertex extends StarElement implements Vertex {
+
+ private Map<String, List<Edge>> outEdges = new HashMap<>();
+ private Map<String, List<Edge>> inEdges = new HashMap<>();
+ private Map<String, List<VertexProperty>> vertexProperties = new HashMap<>();
+
+ public StarVertex(final Object id, final String label) {
+ super(id, label);
+ }
+
+ public void dropEdges() {
+ this.outEdges.clear();
+ this.inEdges.clear();
+ }
+
+ @Override
+ public Edge addEdge(final String label, final Vertex inVertex, final Object... keyValues) {
+ return this.addOutEdge(label, inVertex, keyValues);
+ }
+
+ protected Edge addOutEdge(final String label, final Vertex inVertex, final Object... keyValues) {
+ List<Edge> outE = this.outEdges.get(label);
+ if (null == outE) {
+ outE = new ArrayList<>();
+ this.outEdges.put(label, outE);
+ }
+ final StarEdge outEdge = new StarEdge(ElementHelper.getIdValue(keyValues).orElse(UUID.randomUUID()), label, inVertex.id(), Direction.OUT);
+ ElementHelper.attachProperties(outEdge, keyValues);
+ outE.add(outEdge);
+ return outEdge;
+ }
+
+ protected Edge addInEdge(final String label, final Vertex outVertex, final Object... keyValues) {
+ List<Edge> inE = this.inEdges.get(label);
+ if (null == inE) {
+ inE = new ArrayList<>();
+ this.inEdges.put(label, inE);
+ }
+ final StarEdge inEdge = new StarEdge(ElementHelper.getIdValue(keyValues).orElse(UUID.randomUUID()), label, outVertex.id(), Direction.IN);
+ ElementHelper.attachProperties(inEdge, keyValues);
+ inE.add(inEdge);
+ return inEdge;
+ }
+
+ @Override
+ public <V> VertexProperty<V> property(final VertexProperty.Cardinality cardinality, final String key, V value, final Object... keyValues) {
+ final List<VertexProperty> list = cardinality.equals(VertexProperty.Cardinality.single) ? new ArrayList<>(1) : this.vertexProperties.getOrDefault(key, new ArrayList<>());
+ final VertexProperty<V> vertexProperty = new StarVertexProperty<>(ElementHelper.getIdValue(keyValues).orElse(UUID.randomUUID()), key, value);
+ ElementHelper.attachProperties(vertexProperty, keyValues);
+ list.add(vertexProperty);
+ this.vertexProperties.put(key, list);
+ return vertexProperty;
+ }
+
+ @Override
+ public Iterator<Edge> edges(final Direction direction, final String... edgeLabels) {
+ if (direction.equals(Direction.OUT)) {
+ return this.outEdges.entrySet().stream()
+ .filter(entry -> ElementHelper.keyExists(entry.getKey(), edgeLabels))
+ .map(Map.Entry::getValue)
+ .flatMap(List::stream)
+ .iterator();
+ } else if (direction.equals(Direction.IN)) {
+ return this.inEdges.entrySet().stream()
+ .filter(entry -> ElementHelper.keyExists(entry.getKey(), edgeLabels))
+ .map(Map.Entry::getValue)
+ .flatMap(List::stream)
+ .iterator();
+ } else {
+ return Stream.concat(this.inEdges.entrySet().stream(), this.outEdges.entrySet().stream())
+ .filter(entry -> ElementHelper.keyExists(entry.getKey(), edgeLabels))
+ .map(Map.Entry::getValue)
+ .flatMap(List::stream)
+ .iterator();
+ }
+ }
+
+ @Override
+ public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) {
+ if (direction.equals(Direction.OUT)) {
+ return IteratorUtils.map(this.edges(direction, edgeLabels), Edge::inVertex);
+ } else if (direction.equals(Direction.IN)) {
+ return IteratorUtils.map(this.edges(direction, edgeLabels), Edge::outVertex);
+ } else {
+ return IteratorUtils.<Vertex>concat(
+ IteratorUtils.map(this.edges(Direction.IN, edgeLabels), Edge::outVertex),
+ IteratorUtils.map(this.edges(Direction.OUT, edgeLabels), Edge::inVertex));
+ }
+ }
+
+ @Override
+ public void remove() {
+ throw new IllegalStateException("The star vertex can not be removed from the StarGraph: " + this);
+ }
+
+ @Override
+ public String toString() {
+ return StringFactory.vertexString(this);
+ }
+
+ @Override
+ public <V> Iterator<VertexProperty<V>> properties(final String... propertyKeys) {
+ if (this.vertexProperties.isEmpty())
+ return Collections.emptyIterator();
+ else if (propertyKeys.length == 0)
+ return (Iterator) this.vertexProperties.entrySet().stream()
+ .flatMap(entry -> entry.getValue().stream())
+ .iterator();
+ else if (propertyKeys.length == 1)
+ return (Iterator) this.vertexProperties.getOrDefault(propertyKeys[0], Collections.emptyList()).iterator();
+ else
+ return (Iterator) this.vertexProperties.entrySet().stream()
+ .filter(entry -> ElementHelper.keyExists(entry.getKey(), propertyKeys))
+ .flatMap(entry -> entry.getValue().stream())
+ .iterator();
+ }
+ }
+
+ ///////////////////////////////
+ //// STAR VERTEX PROPERTY ////
+ //////////////////////////////
+
+ public final class StarVertexProperty<V> extends StarElement implements VertexProperty<V> {
+
+ private final V value;
+ private Map<String, Object> metaProperties = null;
+
+ public StarVertexProperty(final Object id, final String key, final V value) {
+ super(id, key);
+ this.value = value;
+ }
+
+ @Override
+ public String key() {
+ return this.label;
+ }
+
+ @Override
+ public V value() throws NoSuchElementException {
+ return this.value;
+ }
+
+ @Override
+ public boolean isPresent() {
+ return true;
+ }
+
+ @Override
+ public Vertex element() {
+ return starVertex;
+ }
+
+ @Override
+ public void remove() {
+ StarGraph.this.starVertex.vertexProperties.get(this.label).remove(this);
+ }
+
+ @Override
+ public <U> Iterator<Property<U>> properties(final String... propertyKeys) {
+ if (null == this.metaProperties)
+ return Collections.emptyIterator();
+ else if (propertyKeys.length == 0)
+ return (Iterator) this.metaProperties.entrySet().stream()
+ .map(entry -> new StarProperty<>(entry.getKey(), entry.getValue(), this))
+ .iterator();
+ else if (propertyKeys.length == 1) {
+ final Object v = this.metaProperties.get(propertyKeys[0]);
+ return null == v ?
+ Collections.emptyIterator() :
+ (Iterator) IteratorUtils.of(new StarProperty<>(propertyKeys[0], v, this));
+ } else {
+ return (Iterator) this.metaProperties.entrySet().stream()
+ .filter(entry -> ElementHelper.keyExists(entry.getKey(), propertyKeys))
+ .map(entry -> new StarProperty<>(entry.getKey(), entry.getValue(), this))
+ .iterator();
+ }
+ }
+
+ @Override
+ public Object id() {
+ return this.id;
+ }
+
+ @Override
+ public <U> Property<U> property(final String key, final U value) {
+ if (null == this.metaProperties)
+ this.metaProperties = new HashMap<>();
+ this.metaProperties.put(key, value);
+ return new StarProperty<>(key, value, this);
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ return ElementHelper.areEqual(this, other);
+ }
+
+ @Override
+ public int hashCode() {
+ return ElementHelper.hashCode((Element) this);
+ }
+ }
+
+
+ ///////////////////////////////
+ //// STAR ADJACENT VERTEX ////
+ //////////////////////////////
+
+ public class StarAdjacentVertex implements Vertex {
+
+ private final Object id;
+
+ protected StarAdjacentVertex(final Object id) {
+ this.id = id;
+ }
+
+ @Override
+ public Edge addEdge(final String label, final Vertex inVertex, final Object... keyValues) {
+ if (!ElementHelper.areEqual(starVertex, inVertex))
+ throw new IllegalStateException("An adjacent vertex can only connect to the star vertex: " + starVertex);
+ return starVertex.addInEdge(label, this, keyValues);
+ }
+
+ @Override
+ public <V> VertexProperty<V> property(final VertexProperty.Cardinality cardinality, final String key, final V value, final Object... keyValues) {
+ throw Element.Exceptions.propertyAdditionNotSupported();
+ }
+
+ @Override
+ public Iterator<Edge> edges(final Direction direction, final String... edgeLabels) {
+ return Collections.emptyIterator(); // TODO: just return to starVertex?
+ }
+
+ @Override
+ public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) {
+ return Collections.emptyIterator(); // TODO: just return star vertex?
+ }
+
+ @Override
+ public Object id() {
+ return this.id;
+ }
+
+ @Override
+ public String label() {
+ return Vertex.DEFAULT_LABEL;
+ }
+
+ @Override
+ public Graph graph() {
+ return StarGraph.this;
+ }
+
+ @Override
+ public void remove() {
+ throw Vertex.Exceptions.vertexRemovalNotSupported();
+ }
+
+ @Override
+ public <V> Iterator<VertexProperty<V>> properties(final String... propertyKeys) {
+ return Collections.emptyIterator();
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ return ElementHelper.areEqual(this, other);
+ }
+
+ @Override
+ public int hashCode() {
+ return ElementHelper.hashCode(this);
+ }
+
+ @Override
+ public String toString() {
+ return StringFactory.vertexString(this);
+ }
+ }
+
+ ////////////////////
+ //// STAR EDGE ////
+ ///////////////////
+
+ public final class StarEdge extends StarElement implements Edge {
+
+ private final Object otherId;
+ private final Direction direction;
+ private Map<String, Object> edgeProperties = null;
+
+ public StarEdge(final Object id, final String label, final Object otherId, final Direction direction) {
+ super(id, label);
+ this.otherId = otherId;
+ this.direction = direction;
+ }
+
+ @Override
+ public Iterator<Vertex> vertices(final Direction direction) {
+ if (direction.equals(Direction.OUT))
+ return IteratorUtils.of(this.outVertex());
+ else if (direction.equals(Direction.IN))
+ return IteratorUtils.of(this.inVertex());
+ else
+ return this.direction.equals(Direction.OUT) ?
+ IteratorUtils.of(starVertex, new StarAdjacentVertex(this.otherId)) :
+ IteratorUtils.of(new StarAdjacentVertex(this.otherId), starVertex);
+ }
+
+ public Vertex outVertex() {
+ return this.direction.equals(Direction.OUT) ? starVertex : new StarAdjacentVertex(this.otherId);
+ }
+
+ public Vertex inVertex() {
+ return this.direction.equals(Direction.OUT) ? new StarAdjacentVertex(this.otherId) : starVertex;
+ }
+
+ @Override
+ public <V> Property<V> property(final String key, final V value) {
+ if (null == this.edgeProperties)
+ this.edgeProperties = new HashMap<>();
+ this.edgeProperties.put(key, value);
+ return new StarProperty<>(key, value, this);
+ }
+
+ @Override
+ public <V> Iterator<Property<V>> properties(final String... propertyKeys) {
+ if (null == this.edgeProperties)
+ return Collections.emptyIterator();
+ else if (propertyKeys.length == 0)
+ return (Iterator) this.edgeProperties.entrySet().stream()
+ .map(entry -> new StarProperty<>(entry.getKey(), entry.getValue(), this))
+ .iterator();
+ else if (propertyKeys.length == 1) {
+ final Object v = this.edgeProperties.get(propertyKeys[0]);
+ return null == v ?
+ Collections.emptyIterator() :
+ (Iterator) IteratorUtils.of(new StarProperty<>(propertyKeys[0], v, this));
+ } else {
+ return (Iterator) this.edgeProperties.entrySet().stream()
+ .filter(entry -> ElementHelper.keyExists(entry.getKey(), propertyKeys))
+ .map(entry -> new StarProperty<>(entry.getKey(), entry.getValue(), this))
+ .iterator();
+ }
+ }
+
+ @Override
+ public void remove() {
+ //TODO: throw Edge.Exceptions.edgeRemovalNotSupported();
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ return ElementHelper.areEqual(this, other);
+ }
+
+ @Override
+ public int hashCode() {
+ return ElementHelper.hashCode(this);
+ }
+
+ @Override
+ public String toString() {
+ return StringFactory.edgeString(this);
+ }
+ }
+
+ ////////////////////////
+ //// STAR PROPERTY ////
+ ///////////////////////
+
+ public final class StarProperty<V> implements Property<V> {
+
+ private final String key;
+ private final V value;
+ private final Element element;
+
+ public StarProperty(final String key, final V value, final Element element) {
+ this.key = key;
+ this.value = value;
+ this.element = element;
+ }
+
+ @Override
+ public String key() {
+ return this.key;
+ }
+
+ @Override
+ public V value() throws NoSuchElementException {
+ return this.value;
+ }
+
+ @Override
+ public boolean isPresent() {
+ return true;
+ }
+
+ @Override
+ public Element element() {
+ return this.element;
+ }
+
+ @Override
+ public void remove() {
+ throw Element.Exceptions.propertyRemovalNotSupported();
+ }
+
+ @Override
+ public String toString() {
+ return StringFactory.propertyString(this);
+ }
+
+ @Override
+ public boolean equals(final Object object) {
+ return ElementHelper.areEqual(this, object);
+ }
+
+ @Override
+ public int hashCode() {
+ return ElementHelper.hashCode(this);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/hadoop-gremlin/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/pom.xml b/hadoop-gremlin/pom.xml
index 28c6c02..1bb9c4d 100644
--- a/hadoop-gremlin/pom.xml
+++ b/hadoop-gremlin/pom.xml
@@ -37,11 +37,6 @@ limitations under the License.
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.tinkerpop</groupId>
- <artifactId>tinkergraph-gremlin</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>${hadoop.version}</version>
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/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 00ae3ab..1ff6552 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
@@ -41,8 +41,7 @@ import org.apache.tinkerpop.gremlin.process.computer.Memory;
import org.apache.tinkerpop.gremlin.process.computer.MessageCombiner;
import org.apache.tinkerpop.gremlin.process.computer.VertexProgram;
import org.apache.tinkerpop.gremlin.process.computer.util.ComputerGraph;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.util.star.StarGraph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty;
@@ -140,13 +139,13 @@ public final class SparkExecutor {
public static <M> JavaPairRDD<Object, VertexWritable> prepareGraphRDDForMapReduce(final JavaPairRDD<Object, VertexWritable> graphRDD, final JavaPairRDD<Object, ViewIncomingPayload<M>> viewIncomingRDD) {
return (null == viewIncomingRDD) ?
graphRDD.mapValues(vertexWritable -> {
- vertexWritable.get().edges(Direction.BOTH).forEachRemaining(Edge::remove);
+ ((StarGraph.StarVertex)vertexWritable.get()).dropEdges();
return vertexWritable;
}) :
graphRDD.leftOuterJoin(viewIncomingRDD)
.mapValues(tuple -> {
final Vertex vertex = tuple._1().get();
- vertex.edges(Direction.BOTH).forEachRemaining(Edge::remove);
+ ((StarGraph.StarVertex)vertex).dropEdges();
final List<DetachedVertexProperty<Object>> view = tuple._2().isPresent() ? tuple._2().get().getView() : Collections.emptyList();
view.forEach(property -> DetachedVertexProperty.addTo(vertex, property));
return tuple._1();
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java
index af3ceb1..fad244b 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java
@@ -20,14 +20,10 @@ package org.apache.tinkerpop.gremlin.hadoop.structure.io;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableUtils;
-import org.apache.tinkerpop.gremlin.process.computer.util.star.StarGraph;
+import org.apache.tinkerpop.gremlin.structure.util.star.StarGraph;
import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -68,10 +64,10 @@ public final class VertexWritable implements Writable, Serializable {
this.vertex = HadoopPools.GRYO_POOL.doWithReader(gryoReader -> {
try {
final ByteArrayInputStream inputStream = new ByteArrayInputStream(WritableUtils.readCompressedByteArray(input));
- final StarGraph gLocal = StarGraph.open();
+ final StarGraph starGraph = StarGraph.open();
return gryoReader.readVertex(inputStream, Direction.BOTH,
- detachedVertex -> StarGraph.addTo(gLocal, detachedVertex),
- detachedEdge -> StarGraph.addTo(gLocal, detachedEdge));
+ detachedVertex -> StarGraph.addTo(starGraph, detachedVertex),
+ detachedEdge -> StarGraph.addTo(starGraph, detachedEdge));
} catch (final IOException e) {
throw new IllegalStateException(e.getMessage(), e);
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/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 e77e60f..87cfbb8 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
@@ -25,14 +25,13 @@ import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.lib.input.LineRecordReader;
import org.apache.tinkerpop.gremlin.hadoop.Constants;
import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
-import org.apache.tinkerpop.gremlin.process.computer.util.star.StarGraph;
+import org.apache.tinkerpop.gremlin.structure.util.star.StarGraph;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -64,9 +63,9 @@ public class GraphSONRecordReader extends RecordReader<NullWritable, VertexWrita
if (!this.lineRecordReader.nextKeyValue())
return false;
- final StarGraph gLocal = StarGraph.open();
- final Function<DetachedVertex, Vertex> vertexMaker = detachedVertex -> StarGraph.addTo(gLocal, detachedVertex);
- final Function<DetachedEdge, Edge> edgeMaker = detachedEdge -> StarGraph.addTo(gLocal, detachedEdge);
+ final StarGraph starGraph = StarGraph.open();
+ final Function<DetachedVertex, Vertex> vertexMaker = detachedVertex -> StarGraph.addTo(starGraph, detachedVertex);
+ final Function<DetachedEdge, Edge> edgeMaker = detachedEdge -> StarGraph.addTo(starGraph, detachedEdge);
try (InputStream in = new ByteArrayInputStream(this.lineRecordReader.getCurrentValue().getBytes())) {
this.vertexWritable.set(this.hasEdges ?
this.graphsonReader.readVertex(in, Direction.BOTH, vertexMaker, edgeMaker) :
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/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 4862959..6a74f1e 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
@@ -29,16 +29,14 @@ import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.lib.input.FileSplit;
import org.apache.tinkerpop.gremlin.hadoop.Constants;
import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
-import org.apache.tinkerpop.gremlin.process.computer.util.star.StarGraph;
+import org.apache.tinkerpop.gremlin.structure.util.star.StarGraph;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -131,9 +129,9 @@ public class GryoRecordReader extends RecordReader<NullWritable, VertexWritable>
terminatorLocation = 0;
if (terminatorLocation >= TERMINATOR.length) {
- final StarGraph gLocal = StarGraph.open();
- final Function<DetachedVertex, Vertex> vertexMaker = detachedVertex -> StarGraph.addTo(gLocal, detachedVertex);
- final Function<DetachedEdge, Edge> edgeMaker = detachedEdge -> StarGraph.addTo(gLocal, detachedEdge);
+ final StarGraph starGraph = StarGraph.open();
+ final Function<DetachedVertex, Vertex> vertexMaker = detachedVertex -> StarGraph.addTo(starGraph, detachedVertex);
+ final Function<DetachedEdge, Edge> edgeMaker = detachedEdge -> StarGraph.addTo(starGraph, detachedEdge);
try (InputStream in = new ByteArrayInputStream(output.toByteArray())) {
this.vertexWritable.set(this.hasEdges ?
this.gryoReader.readVertex(in, Direction.BOTH, vertexMaker, edgeMaker) :
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordReader.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordReader.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordReader.java
index 62d8e68..c9e2c94 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordReader.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordReader.java
@@ -32,7 +32,7 @@ import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
import org.apache.tinkerpop.gremlin.process.traversal.T;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.apache.tinkerpop.gremlin.structure.util.star.StarGraph;
import javax.script.Bindings;
import javax.script.ScriptEngine;
@@ -115,10 +115,10 @@ public class ScriptRecordReader extends RecordReader<NullWritable, VertexWritabl
protected class ScriptElementFactory {
- private final TinkerGraph graph;
+ private final StarGraph graph;
public ScriptElementFactory() {
- this.graph = TinkerGraph.open();
+ this.graph = StarGraph.open();
}
public Vertex vertex(final Object id) {
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerProperty.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerProperty.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerProperty.java
index c886b1e..28259ac 100644
--- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerProperty.java
+++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerProperty.java
@@ -59,14 +59,17 @@ public class TinkerProperty<V> implements Property<V> {
return null != this.value;
}
+ @Override
public String toString() {
return StringFactory.propertyString(this);
}
+ @Override
public boolean equals(final Object object) {
return ElementHelper.areEqual(this, object);
}
+ @Override
public int hashCode() {
return ElementHelper.hashCode(this);
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65b4596f/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
index 23933f6..5e08a00 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
@@ -21,7 +21,7 @@ package org.apache.tinkerpop.gremlin.tinkergraph.structure;
import org.apache.commons.io.FileUtils;
import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
import org.apache.tinkerpop.gremlin.TestHelper;
-import org.apache.tinkerpop.gremlin.process.computer.util.star.StarGraph;
+import org.apache.tinkerpop.gremlin.structure.util.star.StarGraph;
import org.apache.tinkerpop.gremlin.process.traversal.T;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
@@ -30,7 +30,6 @@ import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Operator;
import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLWriter;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
@@ -38,7 +37,6 @@ import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
-import org.apache.tinkerpop.gremlin.util.StreamFactory;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
@@ -146,8 +144,9 @@ public class TinkerGraphTest {
TinkerGraph tg = TinkerFactory.createModern();
StarGraph sg = StarGraph.open();
tg.vertices().forEachRemaining(v -> StarGraph.addTo(sg, DetachedFactory.detach(v,true)));
- tg.vertices(1).next().edges(Direction.BOTH).forEachRemaining(e -> StarGraph.addTo(sg,DetachedFactory.detach(e,true)));
+ tg.vertices(1).next().edges(Direction.BOTH).forEachRemaining(e -> StarGraph.addTo(sg, DetachedFactory.detach(e, true)));
sg.vertices().forEachRemaining(System.out::println);
+ sg.edges().forEachRemaining(System.out::println);
}
@Test