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/01 23:47:42 UTC
incubator-tinkerpop git commit: added note about indicies for
multi-meta property Neo4j graphs.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/master 0becf9f2f -> 11a663f92
added note about indicies for multi-meta property Neo4j graphs.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/11a663f9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/11a663f9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/11a663f9
Branch: refs/heads/master
Commit: 11a663f92099038865475a489b4037d858bdf39d
Parents: 0becf9f
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Mon Jun 1 15:47:28 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Mon Jun 1 15:47:38 2015 -0600
----------------------------------------------------------------------
docs/src/implementations.asciidoc | 2 ++
.../gremlin/neo4j/structure/Neo4jElement.java | 13 +++++---
.../neo4j/structure/Neo4jVertexProperty.java | 15 +++++++++
.../structure/trait/MultiMetaNeo4jTrait.java | 32 ++------------------
.../trait/NoMultiNoMetaNeo4jTrait.java | 11 -------
5 files changed, 27 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/11a663f9/docs/src/implementations.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/implementations.asciidoc b/docs/src/implementations.asciidoc
index d759742..af22c58 100644
--- a/docs/src/implementations.asciidoc
+++ b/docs/src/implementations.asciidoc
@@ -620,6 +620,8 @@ gremlin> clock(1000){g.V().has('name','Garcia').next()} <6>
<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)`.
+
Cypher
~~~~~~
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/11a663f9/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jElement.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jElement.java b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jElement.java
index 28644b6..83345e3 100644
--- a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jElement.java
+++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jElement.java
@@ -20,13 +20,12 @@ package org.apache.tinkerpop.gremlin.neo4j.structure;
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.util.ElementHelper;
import org.apache.tinkerpop.gremlin.structure.util.wrapped.WrappedElement;
-import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
import org.neo4j.tinkerpop.api.Neo4jEntity;
-import java.util.Iterator;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.Set;
/**
@@ -56,7 +55,12 @@ public abstract class Neo4jElement implements Element, WrappedElement<Neo4jEntit
@Override
public Set<String> keys() {
this.graph.tx().readWrite();
- return Element.super.keys();
+ final Set<String> keys = new HashSet<>();
+ for (final String key : this.baseElement.getKeys()) {
+ if (!Graph.Hidden.isHidden(key))
+ keys.add(key);
+ }
+ return Collections.unmodifiableSet(keys);
}
@Override
@@ -75,5 +79,4 @@ public abstract class Neo4jElement implements Element, WrappedElement<Neo4jEntit
}
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/11a663f9/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jVertexProperty.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jVertexProperty.java b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jVertexProperty.java
index 60017b0..b33081a 100644
--- a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jVertexProperty.java
+++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jVertexProperty.java
@@ -19,6 +19,7 @@
package org.apache.tinkerpop.gremlin.neo4j.structure;
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.T;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -27,8 +28,11 @@ import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
import org.neo4j.tinkerpop.api.Neo4jNode;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.NoSuchElementException;
+import java.util.Set;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
@@ -113,6 +117,17 @@ public final class Neo4jVertexProperty<V> implements VertexProperty<V> {
}
@Override
+ public Set<String> keys() {
+ if(null == this.vertexPropertyNode) return Collections.emptySet();
+ final Set<String> keys = new HashSet<>();
+ for (final String key : this.vertexPropertyNode.getKeys()) {
+ if (!Graph.Hidden.isHidden(key) && !key.equals(this.key))
+ keys.add(key);
+ }
+ return Collections.unmodifiableSet(keys);
+ }
+
+ @Override
public boolean equals(final Object object) {
return ElementHelper.areEqual(this, object);
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/11a663f9/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/MultiMetaNeo4jTrait.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/MultiMetaNeo4jTrait.java b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/MultiMetaNeo4jTrait.java
index a079f7c..115dde6 100644
--- a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/MultiMetaNeo4jTrait.java
+++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/MultiMetaNeo4jTrait.java
@@ -119,7 +119,8 @@ public class MultiMetaNeo4jTrait implements Neo4jTrait {
@Override
public <V> Iterator<VertexProperty<V>> getVertexProperties(final Neo4jVertex vertex, final String... keys) {
- if (Neo4jHelper.isDeleted(vertex.getBaseVertex())) return Collections.emptyIterator(); // TODO: I believe its because the vertex property is deleted, but then seen again in the iterator. ?
+ if (Neo4jHelper.isDeleted(vertex.getBaseVertex()))
+ return Collections.emptyIterator(); // TODO: I believe its because the vertex property is deleted, but then seen again in the iterator. ?
return IteratorUtils.stream(vertex.getBaseVertex().getKeys())
.filter(key -> ElementHelper.keyExists(key, keys))
.flatMap(key -> {
@@ -292,18 +293,6 @@ public class MultiMetaNeo4jTrait implements Neo4jTrait {
}
}
}
- }/* else {
- // find a vertex by key/value
- for (final HasContainer hasContainer : hasContainers) {
- if (Compare.eq == hasContainer.getBiPredicate()) {
- return IteratorUtils.stream(graph.getBaseGraph().findNodes(hasContainer.getKey(), hasContainer.getValue()))
- .map(node -> node.hasLabel(VERTEX_PROPERTY_LABEL) ? node.relationships(Neo4jDirection.INCOMING).iterator().next().start() : node) // if a vertex property node, get the node
- .map(node -> (Vertex) new Neo4jVertex(node, graph))
- .filter(vertex -> HasContainer.testAll(vertex, hasContainers)).iterator();
- }
- }
- }*/
- if (label.isPresent()) {
// find a vertex by label
return IteratorUtils.stream(graph.getBaseGraph().findNodes(label.get()))
.filter(getNodePredicate())
@@ -314,21 +303,4 @@ public class MultiMetaNeo4jTrait implements Neo4jTrait {
return IteratorUtils.filter(graph.vertices(), vertex -> HasContainer.testAll(vertex, hasContainers));
}
}
-
- /*
- @Override
- public Set<String> keys() {
- if (isNode()) {
- this.vertex.graph().tx().readWrite();
- final Set<String> keys = new HashSet<>();
- for (final String key : this.node.getKeys()) {
- if (!Graph.Hidden.isHidden(key))
- keys.add(key);
- }
- return keys;
- } else {
- return Collections.emptySet();
- }
- }
- */
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/11a663f9/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/NoMultiNoMetaNeo4jTrait.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/NoMultiNoMetaNeo4jTrait.java b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/NoMultiNoMetaNeo4jTrait.java
index 170520d..217a815 100644
--- a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/NoMultiNoMetaNeo4jTrait.java
+++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/NoMultiNoMetaNeo4jTrait.java
@@ -172,17 +172,6 @@ public class NoMultiNoMetaNeo4jTrait implements Neo4jTrait {
}
}
}
- } /*else {
- // find a vertex by key/value
- for (final HasContainer hasContainer : hasContainers) {
- if (Compare.eq == hasContainer.getBiPredicate() && !hasContainer.getKey().equals(T.label.getAccessor())) {
- return IteratorUtils.stream(graph.getBaseGraph().findNodes(hasContainer.getKey(), hasContainer.getValue()))
- .map(node -> (Vertex) new Neo4jVertex(node, graph))
- .filter(vertex -> HasContainer.testAll(vertex, hasContainers)).iterator();
- }
- }
- }*/
- if (label.isPresent()) {
// find a vertex by label
return IteratorUtils.stream(graph.getBaseGraph().findNodes(label.get()))
.map(node -> (Vertex) new Neo4jVertex(node, graph))