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/06/08 18:43:04 UTC
[1/2] incubator-tinkerpop git commit: ElementHelper JavaDoc.
Neo4jGraph Logger.WARN when using multi-properties as an experimental
feature. Doc examples for multi-meta properties in AsciiDocs.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/master e9385f3a1 -> b8993a019
ElementHelper JavaDoc. Neo4jGraph Logger.WARN when using multi-properties as an experimental feature. Doc examples for multi-meta properties in AsciiDocs.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/b8993a01
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/b8993a01
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/b8993a01
Branch: refs/heads/master
Commit: b8993a019066e3087824e768ba669b42204a734e
Parents: 2f78fab
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Mon Jun 8 10:42:51 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Mon Jun 8 10:42:59 2015 -0600
----------------------------------------------------------------------
docs/src/implementations.asciidoc | 60 +++++++++++++++-----
.../gremlin/structure/util/ElementHelper.java | 19 +++++--
.../gremlin/neo4j/structure/Neo4jGraph.java | 13 ++++-
3 files changed, 69 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b8993a01/docs/src/implementations.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/implementations.asciidoc b/docs/src/implementations.asciidoc
index e4f791a..8882ab7 100644
--- a/docs/src/implementations.asciidoc
+++ b/docs/src/implementations.asciidoc
@@ -556,10 +556,6 @@ gremlin> graph = Neo4jGraph.open('/tmp/neo4j')
For those leveraging Neo4j High Availability, configure `Neo4jGraph` for "HA mode" by setting the `gremlin.neo4j.ha` flag to `true` in the `Configuration` object passed to `Neo4jGraph.open()`. Note that when the flag is set (by default it is `false`), the `Neo4jGraph` instance expects HA configuration settings to be present. As with embedded Neo4j, HA configuration keys should be prefixed with `gremlin.neo4j.conf`. Please consult Neo4j documentation for more information on link:http://docs.neo4j.org/chunked/stable/ha.html[High Availability] configuration.
-IMPORTANT: `Neo4jGraph` supports both multi- and meta-properties (see <<_vertex_properties,vertex properties>>). These features are not native to Neo4j and is implemented by making use of "hidden" Neo4j nodes. For example, when a vertex has multiple "name" properties, each property is a new node (multi-properties) which can have properties attached to it (meta-properties). As such, the native, underlying representation may become difficult to query directly using another graph language such as Cypher. The default setting is to disable multi- and meta-properties. However, if this feature is desired, then it can be activated via `gremlin.neo4j.metaProperties` and `gremlin.neo4j.multiProperties` configurations being set to `true`. Once the configuration is set, it can not be changed for the lifetime of the graph.
-
-WARNING: `Neo4jGraph` without multi- and meta-properties is in 1-to-1 correspondence with the native, underlying Neo4j representation. It is recommended that if the user does not require these features, then they should not enable them. Without multi- and meta-properties enabled, Neo4j can be interacted with with other tools and technologies that do not leverage TinkerPop.
-
TIP: To host Neo4j in <<gremlin-server,Gremlin Server>>, the dependencies must first be "installed" or otherwise copied to the Gremlin Server path. The automated method for doing this would be to execute `bin/gremlin-server.sh -i org.apache.tinkerpop neo4j-gremlin x.y.z`.
Indices
@@ -613,7 +609,31 @@ graph.close()
<5> Find all artists whose name is Garcia which does a linear scan of the artist vertex-label partition.
<6> Find all vertices whose name is Garcia which requires a linear scan of all the data in the graph.
-IMPORTANT: When using a multi-property enabled `Neo4jGraph`, vertices may represent their properties on "hidden nodes" adjacent to the vertex. If a vertex property key/value is required for indexing, then two indices are required -- e.g. `CREATE INDEX ON :person(name)` and `CREATE INDEX ON :vertexProperty(name)`.
+Multi/Meta-Properties
+~~~~~~~~~~~~~~~~~~~~~
+
+`Neo4jGraph` supports both multi- and meta-properties (see <<_vertex_properties,vertex properties>>). These features are not native to Neo4j and are implemented using "hidden" Neo4j nodes. For example, when a vertex has multiple "name" properties, each property is a new node (multi-properties) which can have properties attached to it (meta-properties). As such, the native, underlying representation may become difficult to query directly using another graph language such as <<_cypher,Cypher>>. The default setting is to disable multi- and meta-properties. However, if this feature is desired, then it can be activated via `gremlin.neo4j.metaProperties` and `gremlin.neo4j.multiProperties` configurations being set to `true`. Once the configuration is set, it can not be changed for the lifetime of the graph.
+
+[gremlin-groovy]
+----
+conf = new BaseConfiguration()
+conf.setProperty('gremlin.neo4j.directory','/tmp/neo4j')
+conf.setProperty('gremlin.neo4j.multiProperties',true)
+conf.setProperty('gremlin.neo4j.metaProperties',true)
+graph = Neo4jGraph.open(conf)
+g = graph.traversal()
+random = new Random()
+g.addV('name','michael','name','michael hunger','name','mhunger')
+g.V().properties('name').property('acl', random.nextBoolean() ? 'private' : 'public')
+g.V(0).valueMap()
+g.V(0).properties()
+g.V(0).properties().valueMap()
+graph.close()
+----
+
+WARNING: `Neo4jGraph` without multi- and meta-properties is in 1-to-1 correspondence with the native, underlying Neo4j representation. It is recommended that if the user does not require multi/meta-properties, then they should not enable them. Without multi- and meta-properties enabled, Neo4j can be interacted with with other tools and technologies that do not leverage TinkerPop.
+
+IMPORTANT: When using a multi-property enabled `Neo4jGraph`, vertices may represent their properties on "hidden nodes" adjacent to the vertex. If a vertex property key/value is required for indexing, then two indices are required -- e.g. `CREATE INDEX ON :person(name)` and `CREATE INDEX ON :vertexProperty(name)` (see <<_indices,Neo4j indices>>).
Cypher
~~~~~~
@@ -650,25 +670,35 @@ An example use case is presented below.
[gremlin-groovy]
----
graph = Neo4jGraph.open('/tmp/neo4j')
-vertex = (Neo4jVertex) graph.addVertex('human::animal') // typecasting only required in Java
-vertex.label() // standard Vertex.label() method (note that labels are alphabetically sorted)
-vertex.labels() // specific Neo4jVertex.labels() method
-vertex.addLabel('organism') // specific Neo4jVertex.addLabel() method
+vertex = (Neo4jVertex) graph.addVertex('human::animal') <1>
+vertex.label() <2>
+vertex.labels() <3>
+vertex.addLabel('organism') <4>
vertex.label()
-vertex.removeLabel('human') // specific Neo4jVertex.removeLabel() method
+vertex.removeLabel('human') <5>
vertex.labels()
-vertex.addLabel('organism') // add a repeat
+vertex.addLabel('organism') <6>
vertex.labels()
-vertex.removeLabel('human') // remove a label that doesn't exist
+vertex.removeLabel('human') <7>
vertex.label()
g = graph.traversal()
-g.V().has(label,'organism') // does not match as P.eq() does a full string match
-g.V().has(label,of('organism')) // LabelP.of() is specific to neo4j-gremlin and used for multi-label matching
+g.V().has(label,'organism') <8>
+g.V().has(label,of('organism')) <9>
g.V().has(label,of('organism')).has(label,of('animal'))
g.V().has(label,of('organism').and(of('animal')))
----
-`LabelP.of()` is only required if multi-labels are leveraged. `LabelP.of()` is used when filtering/looking-up vertices by their label(s) as the standard `P.eq()` does a direct match on the `::`-representation of `vertex.label()`
+<1> Typecasting to a `Neo4jVertex` is only required in Java.
+<2> The standard `Vertex.label()` method returns all the labels in alphabetical order concatenated using `::`.
+<3> `Neo4jVertex.labels()` method returns the individual labels as a set.
+<4> `Neo4jVertex.addLabel()` method adds a single label.
+<5> `Neo4jVertex.removeLabel()` method removes a single label.
+<6> Labels are unique and thus duplicate labels don't exist.
+<7> If a label that does not exist is removed, nothing happens.
+<8> `P.eq()` does a full string match and should only be used if multi-labels are not leveraged.
+<9> `LabelP.of()` is specific to `Neo4jGraph` and used for multi-label matching.
+
+IMPORTANT: `LabelP.of()` is only required if multi-labels are leveraged. `LabelP.of()` is used when filtering/looking-up vertices by their label(s) as the standard `P.eq()` does a direct match on the `::`-representation of `vertex.label()`
[[hadoop-gremlin]]
Hadoop-Gremlin
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b8993a01/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelper.java
index 9f2a19a..7a7cf03 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelper.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelper.java
@@ -48,7 +48,8 @@ import java.util.stream.Stream;
*/
public final class ElementHelper {
- private ElementHelper() {}
+ private ElementHelper() {
+ }
/**
* Determine whether the Element label can be legally set. This is typically used as a pre-condition check.
@@ -65,7 +66,13 @@ public final class ElementHelper {
throw Element.Exceptions.labelCanNotBeAHiddenKey(label);
}
- public static void validateMixedElementIds(final Class<? extends Element> clazz, final Object... ids) {
+ /**
+ * Determine whether an array of ids are either all elements or ids of elements. This is typically used as a pre-condition check.
+ *
+ * @param clazz the class of the element for which the ids will bind
+ * @param ids the ids that must be either elements or id objects, else {@link Graph.Exceptions#idArgsMustBeEitherIdOrElement()} is thrown.
+ */
+ public static void validateMixedElementIds(final Class<? extends Element> clazz, final Object... ids) throws IllegalArgumentException {
if (ids.length > 1) {
final boolean element = clazz.isAssignableFrom(ids[0].getClass());
for (int i = 1; i < ids.length; i++) {
@@ -132,7 +139,7 @@ public final class ElementHelper {
* there are no values left, the key value list is returned as empty.
*
* @param keyToRemove the key to remove
- * @param keyValues the list to remove the accessor from
+ * @param keyValues the list to remove the accessor from
* @return the key/values without the specified accessor or an empty array if no values remain after removal
*/
public static Optional<Object[]> remove(final String keyToRemove, final Object... keyValues) {
@@ -144,7 +151,7 @@ public final class ElementHelper {
* assure that key positions contain strings and that there are an even number of elements. If after removal
* there are no values left, the key value list is returned as empty.
*
- * @param accessor to remove
+ * @param accessor to remove
* @param keyValues the list to remove the accessor from
* @return the key/values without the specified accessor or an empty array if no values remain after removal
*/
@@ -188,8 +195,8 @@ public final class ElementHelper {
* Replaces one key with a different key.
*
* @param keyValues the list of key/values to alter
- * @param oldKey the key to replace
- * @param newKey the new key
+ * @param oldKey the key to replace
+ * @param newKey the new key
*/
public static Object[] replaceKey(final Object[] keyValues, final Object oldKey, final Object newKey) {
final Object[] kvs = new Object[keyValues.length];
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b8993a01/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
index ccb77ad..e7b23f8 100644
--- a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
+++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
@@ -46,6 +46,8 @@ import org.neo4j.tinkerpop.api.Neo4jGraphAPI;
import org.neo4j.tinkerpop.api.Neo4jNode;
import org.neo4j.tinkerpop.api.Neo4jRelationship;
import org.neo4j.tinkerpop.api.Neo4jTx;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Collections;
import java.util.Iterator;
@@ -69,8 +71,14 @@ import java.util.stream.Stream;
@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT_INTEGRATE)
@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT_PERFORMANCE)
@Graph.OptIn("org.apache.tinkerpop.gremlin.neo4j.NativeNeo4jSuite")
+@Graph.OptOut(
+ test = "org.apache.tinkerpop.gremlin.structure.TransactionTest",
+ method = "shouldRollbackOnShutdownWhenConfigured",
+ reason = "There appears to be a race condition that occurs between Graph.close() and Neo4jGraphAPI.shutdown()")
public final class Neo4jGraph implements Graph, WrappedGraph<Neo4jGraphAPI> {
+ public static final Logger LOGGER = LoggerFactory.getLogger(Neo4jGraph.class);
+
static {
TraversalStrategies.GlobalCache.registerStrategies(Neo4jGraph.class, TraversalStrategies.GlobalCache.getStrategies(Graph.class).clone().addStrategies(Neo4jGraphStepStrategy.instance()));
}
@@ -110,6 +118,8 @@ public final class Neo4jGraph implements Graph, WrappedGraph<Neo4jGraphAPI> {
if (!hasMetaProperties.isPresent())
this.neo4jGraphVariables.set(Graph.Hidden.hide(CONFIG_META_PROPERTIES), supportsMetaProperties);
this.trait = supportsMultiProperties ? MultiMetaNeo4jTrait.instance() : NoMultiNoMetaNeo4jTrait.instance();
+ if (supportsMultiProperties)
+ LOGGER.warn(this.getClass().getSimpleName() + "'s multi/meta-properties feature is considered experimental and should not be used in a production setting until this warning is removed");
this.tx().commit();
}
@@ -307,8 +317,7 @@ public final class Neo4jGraph implements Graph, WrappedGraph<Neo4jGraphAPI> {
public <S, E> GraphTraversal<S, E> cypher(final String query, final Map<String, Object> parameters) {
this.tx().readWrite();
final GraphTraversal.Admin<S, E> traversal = new DefaultGraphTraversal<>(this);
- Iterator result = this.baseGraph.execute(query, parameters);
- traversal.addStep(new CypherStartStep(traversal, query, new Neo4jCypherIterator<S>(result, this)));
+ traversal.addStep(new CypherStartStep(traversal, query, new Neo4jCypherIterator<>((Iterator) this.baseGraph.execute(query, parameters), this)));
return traversal;
}
[2/2] incubator-tinkerpop git commit: added MattFrantz as contributor.
Posted by ok...@apache.org.
added MattFrantz as contributor.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/2f78fab4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/2f78fab4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/2f78fab4
Branch: refs/heads/master
Commit: 2f78fab44f874797804859b1381e05fa550f9fe7
Parents: e9385f3
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Mon Jun 8 10:01:04 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Mon Jun 8 10:42:59 2015 -0600
----------------------------------------------------------------------
pom.xml | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/2f78fab4/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 501ffe2..6826bfc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -63,7 +63,7 @@ limitations under the License.
</developer>
<developer>
<name>Stephen Mallette</name>
- <email>spmva@genoprime.com</email>
+ <email>spmallette@apache.org</email>
<url>http://stephen.genoprime.com</url>
</developer>
</developers>
@@ -73,6 +73,11 @@ limitations under the License.
<email>josh@fortytwo.net</email>
<url>http://fortytwo.net</url>
</contributor>
+ <contributor>
+ <name>Matt Frantz</name>
+ <email>matthew.h.frantz@gmail.com</email>
+ <url>https://github.com/mhfrantz</url>
+ </contributor>
</contributors>
<modules>
<module>gremlin-shaded</module>