Skip to content
This repository
Browse code

more work on GraphQuery -- JavaDoc.

  • Loading branch information...
commit af784c17a2e9c6cb0838267f49daa8b2e7f9e73c 1 parent 50d4e2e
Marko A. Rodriguez okram authored
6 blueprints-core/src/main/java/com/tinkerpop/blueprints/Graph.java
@@ -109,7 +109,11 @@
109 109 */
110 110 public Iterable<Edge> getEdges(String key, Object value);
111 111
112   -
  112 + /**
  113 + * Generate a query object that can be used to fine tune which edges/vertices are retrieved from the graph.
  114 + *
  115 + * @return a graph query object with methods for constraining which data is pulled from the underlying graph
  116 + */
113 117 public GraphQuery query();
114 118
115 119 /**
4 blueprints-core/src/main/java/com/tinkerpop/blueprints/util/DefaultGraphQuery.java
@@ -10,6 +10,9 @@
10 10 import java.util.NoSuchElementException;
11 11
12 12 /**
  13 + * For those graph engines that do not support the low-level querying of the vertices or edges, then DefaultQuery can be used.
  14 + * DefaultQuery assumes, at minimum, that Graph.getVertices() and Graph.getEdges() is implemented by the respective Graph.
  15 + *
13 16 * @author Marko A. Rodriguez (http://markorodriguez.com)
14 17 */
15 18 public class DefaultGraphQuery extends DefaultQuery implements GraphQuery {
@@ -60,6 +63,7 @@ public DefaultGraphQueryIterable(final boolean forVertex) {
60 63 this.iterable = (Iterable<T>) graph.getVertices(hasContainer.key, hasContainer.value);
61 64 else
62 65 this.iterable = (Iterable<T>) graph.getEdges(hasContainer.key, hasContainer.value);
  66 + break;
63 67 }
64 68 }
65 69 if (null == this.iterable) {
5 blueprints-test/src/main/java/com/tinkerpop/blueprints/QueryTestSuite.java
@@ -284,8 +284,13 @@ public void testGraphQueryForEdges() {
284 284 assertEquals(count(graph.query().has("type", "aurelius").edges()), 1);
285 285 assertEquals(count(graph.query().has("weight", null).edges()), 1);
286 286 assertEquals(graph.query().has("weight", null).edges().iterator().next().getProperty("type"), "aurelius");
  287 +
287 288 assertEquals(count(graph.query().has("weight", 1.0).edges()), 1);
288 289 assertEquals(graph.query().has("weight", 1.0).edges().iterator().next().getProperty("type"), "tinkerpop");
  290 + assertEquals(count(graph.query().has("weight", 1.0).has("type", "tinkerpop").edges()), 1);
  291 + assertEquals(graph.query().has("weight", 1.0).has("type", "tinkerpop").edges().iterator().next().getProperty("type"), "tinkerpop");
  292 + assertEquals(count(graph.query().has("weight", 1.0).has("type", "aurelius").edges()), 0);
  293 +
289 294 assertEquals(graph.query().interval("weight", 0.0, 1.1).edges().iterator().next().getProperty("type"), "tinkerpop");
290 295 assertEquals(count(graph.query().interval("weight", 0.0, 1.0).edges()), 0);
291 296 }

0 comments on commit af784c1

Please sign in to comment.
Something went wrong with that request. Please try again.