use of com.tinkerpop.blueprints.KeyIndexableGraph in project pentaho-metaverse by pentaho.
the class SynchronizedGraphFactory method wrapGraph.
/**
* Wraps the underlying graph with a synchronized one
* @param graph The graph to wrap
* @return The synchronized graph
*/
protected static Graph wrapGraph(Graph graph) {
if (graph instanceof KeyIndexableGraph) {
KeyIndexableGraph keyIndexableGraph = (KeyIndexableGraph) graph;
IdGraph<KeyIndexableGraph> idGraph = new IdGraph<KeyIndexableGraph>(keyIndexableGraph);
return new SynchronizedGraph(idGraph);
} else {
throw new IllegalArgumentException(Messages.getString("ERROR.BackingGraph.MustImplement.KeyIndexableGraph"));
}
}
use of com.tinkerpop.blueprints.KeyIndexableGraph in project pentaho-metaverse by pentaho.
the class SynchronizedGraphFactoryTest method testWrapGraph.
@Test
public void testWrapGraph() throws Exception {
Graph g = new TinkerGraph();
SynchronizedGraph wrapped = (SynchronizedGraph) SynchronizedGraphFactory.wrapGraph(g);
assertTrue(wrapped instanceof SynchronizedGraph);
assertTrue(wrapped.graph instanceof IdGraph);
assertTrue(wrapped.graph instanceof KeyIndexableGraph);
}
use of com.tinkerpop.blueprints.KeyIndexableGraph in project blueprints by tinkerpop.
the class SparkseeKeyIndexableGraphTestSuite method testCreateKeyIndexCannotAcceptNullArgumentForClass.
public void testCreateKeyIndexCannotAcceptNullArgumentForClass() {
KeyIndexableGraph graph = (KeyIndexableGraph) graphTest.generateGraph();
try {
graph.createKeyIndex("test", null);
} catch (IllegalArgumentException iae) {
return;
} finally {
graph.shutdown();
}
fail();
}
use of com.tinkerpop.blueprints.KeyIndexableGraph in project blueprints by tinkerpop.
the class SparkseeKeyIndexableGraphTestSuite method testUpdateValuesInIndexKeys.
public void testUpdateValuesInIndexKeys() throws Exception {
KeyIndexableGraph graph = (KeyIndexableGraph) graphTest.generateGraph();
graph.createKeyIndex("name", Vertex.class);
if (graph instanceof TransactionalGraph)
((TransactionalGraph) graph).commit();
Vertex v1 = graph.addVertex(null);
v1.setProperty("name", "marko");
assertEquals(v1.getProperty("name"), "marko");
vertexCount(graph, 1);
if (graph instanceof TransactionalGraph)
((TransactionalGraph) graph).commit();
v1 = graph.getVertices("name", "marko").iterator().next();
assertEquals(v1.getProperty("name"), "marko");
v1.setProperty("name", "marko a. rodriguez");
assertEquals(v1.getProperty("name"), "marko a. rodriguez");
vertexCount(graph, 1);
if (graph instanceof TransactionalGraph)
((TransactionalGraph) graph).commit();
assertFalse(graph.getVertices("name", "marko").iterator().hasNext());
v1 = graph.getVertices("name", "marko a. rodriguez").iterator().next();
assertEquals(v1.getProperty("name"), "marko a. rodriguez");
vertexCount(graph, 1);
if (graph instanceof TransactionalGraph)
((TransactionalGraph) graph).commit();
graph.shutdown();
}
use of com.tinkerpop.blueprints.KeyIndexableGraph in project blueprints by tinkerpop.
the class SparkseeKeyIndexableGraphTestSuite method testAutoIndexKeyManagementWithPersistence.
public void testAutoIndexKeyManagementWithPersistence() {
KeyIndexableGraph graph = (KeyIndexableGraph) graphTest.generateGraph();
if (graph.getFeatures().supportsVertexKeyIndex) {
assertEquals(graph.getIndexedKeys(Vertex.class).size(), 0);
this.stopWatch();
graph.createKeyIndex("name", Vertex.class);
graph.createKeyIndex("location", Vertex.class);
printPerformance(graph.toString(), 2, "automatic index keys added", this.stopWatch());
assertEquals(graph.getIndexedKeys(Vertex.class).size(), 2);
assertTrue(graph.getIndexedKeys(Vertex.class).contains("name"));
assertTrue(graph.getIndexedKeys(Vertex.class).contains("location"));
}
if (graph.getFeatures().supportsEdgeKeyIndex) {
assertEquals(graph.getIndexedKeys(Edge.class).size(), 0);
this.stopWatch();
graph.createKeyIndex("weight", Edge.class);
graph.createKeyIndex("since", Edge.class);
printPerformance(graph.toString(), 2, "automatic index keys added", this.stopWatch());
assertEquals(graph.getIndexedKeys(Edge.class).size(), 2);
assertTrue(graph.getIndexedKeys(Edge.class).contains("weight"));
assertTrue(graph.getIndexedKeys(Edge.class).contains("since"));
}
graph.shutdown();
if (graph.getFeatures().isPersistent) {
graph = (KeyIndexableGraph) graphTest.generateGraph();
if (graph.getFeatures().supportsVertexKeyIndex) {
assertEquals(graph.getIndexedKeys(Vertex.class).size(), 2);
assertTrue(graph.getIndexedKeys(Vertex.class).contains("name"));
assertTrue(graph.getIndexedKeys(Vertex.class).contains("location"));
}
if (graph.getFeatures().supportsEdgeKeyIndex) {
assertEquals(graph.getIndexedKeys(Edge.class).size(), 2);
assertTrue(graph.getIndexedKeys(Edge.class).contains("weight"));
assertTrue(graph.getIndexedKeys(Edge.class).contains("since"));
}
graph.shutdown();
}
}
Aggregations