Permalink
Browse files

more work on GraphQuery -- JavaDoc.

  • Loading branch information...
1 parent 50d4e2e commit af784c17a2e9c6cb0838267f49daa8b2e7f9e73c @okram okram committed Mar 8, 2013
@@ -109,7 +109,11 @@
*/
public Iterable<Edge> getEdges(String key, Object value);
-
+ /**
+ * Generate a query object that can be used to fine tune which edges/vertices are retrieved from the graph.
+ *
+ * @return a graph query object with methods for constraining which data is pulled from the underlying graph
+ */
public GraphQuery query();
/**
@@ -10,6 +10,9 @@
import java.util.NoSuchElementException;
/**
+ * For those graph engines that do not support the low-level querying of the vertices or edges, then DefaultQuery can be used.
+ * DefaultQuery assumes, at minimum, that Graph.getVertices() and Graph.getEdges() is implemented by the respective Graph.
+ *
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public class DefaultGraphQuery extends DefaultQuery implements GraphQuery {
@@ -60,6 +63,7 @@ public DefaultGraphQueryIterable(final boolean forVertex) {
this.iterable = (Iterable<T>) graph.getVertices(hasContainer.key, hasContainer.value);
else
this.iterable = (Iterable<T>) graph.getEdges(hasContainer.key, hasContainer.value);
+ break;
}
}
if (null == this.iterable) {
@@ -284,8 +284,13 @@ public void testGraphQueryForEdges() {
assertEquals(count(graph.query().has("type", "aurelius").edges()), 1);
assertEquals(count(graph.query().has("weight", null).edges()), 1);
assertEquals(graph.query().has("weight", null).edges().iterator().next().getProperty("type"), "aurelius");
+
assertEquals(count(graph.query().has("weight", 1.0).edges()), 1);
assertEquals(graph.query().has("weight", 1.0).edges().iterator().next().getProperty("type"), "tinkerpop");
+ assertEquals(count(graph.query().has("weight", 1.0).has("type", "tinkerpop").edges()), 1);
+ assertEquals(graph.query().has("weight", 1.0).has("type", "tinkerpop").edges().iterator().next().getProperty("type"), "tinkerpop");
+ assertEquals(count(graph.query().has("weight", 1.0).has("type", "aurelius").edges()), 0);
+
assertEquals(graph.query().interval("weight", 0.0, 1.1).edges().iterator().next().getProperty("type"), "tinkerpop");
assertEquals(count(graph.query().interval("weight", 0.0, 1.0).edges()), 0);
}

0 comments on commit af784c1

Please sign in to comment.