use of com.tinkerpop.blueprints.KeyIndexableGraph in project blueprints by tinkerpop.
the class IdGraphTest method testIdIndicesExist.
public void testIdIndicesExist() throws Exception {
KeyIndexableGraph graph = (KeyIndexableGraph) generateGraph();
graph = (KeyIndexableGraph) ((WrapperGraph) graph).getBaseGraph();
assertTrue(graph.getIndexedKeys(Vertex.class).contains(IdGraph.ID));
assertTrue(graph.getIndexedKeys(Edge.class).contains(IdGraph.ID));
graph.shutdown();
}
use of com.tinkerpop.blueprints.KeyIndexableGraph in project blueprints by tinkerpop.
the class TinkerGraphSailTest method testTmp.
@Test
public void testTmp() throws Exception {
KeyIndexableGraph g = new TinkerGraph();
GraphSail sail = new GraphSail(g, "sp,p,c,pc");
}
use of com.tinkerpop.blueprints.KeyIndexableGraph in project blueprints by tinkerpop.
the class SailLoaderTest method testAll.
@Test
public void testAll() throws Exception {
KeyIndexableGraph g = new TinkerGraph();
Sail sail = new GraphSail(g);
sail.initialize();
try {
SailLoader loader = new SailLoader(sail);
File f = resourceToFile("graph-example-sail-test.trig");
SailConnection sc = sail.getConnection();
try {
sc.begin();
assertEquals(0, sc.size());
loader.load(f);
sc.rollback();
assertEquals(29, sc.size());
} finally {
sc.close();
}
} finally {
sail.shutDown();
}
}
use of com.tinkerpop.blueprints.KeyIndexableGraph in project blueprints by tinkerpop.
the class RexsterGraphTest method resetGraph.
protected void resetGraph() {
final KeyIndexableGraph graph = (KeyIndexableGraph) this.generateGraph();
final IndexableGraph idxGraph = (IndexableGraph) graph;
// since we don't have graph.clear() anymore we manually reset the graph.
Iterator<Vertex> vertexItty = graph.getVertices().iterator();
List<Vertex> verticesToRemove = new ArrayList<Vertex>();
while (vertexItty.hasNext()) {
verticesToRemove.add(vertexItty.next());
}
for (Vertex vertexToRemove : verticesToRemove) {
graph.removeVertex(vertexToRemove);
}
for (String key : graph.getIndexedKeys(Vertex.class)) {
graph.dropKeyIndex(key, Vertex.class);
}
for (String key : graph.getIndexedKeys(Edge.class)) {
graph.dropKeyIndex(key, Edge.class);
}
for (Index idx : idxGraph.getIndices()) {
idxGraph.dropIndex(idx.getIndexName());
}
}
use of com.tinkerpop.blueprints.KeyIndexableGraph in project blueprints by tinkerpop.
the class SparkseeGraphSpecificTestSuite method testKeyIndex.
public void testKeyIndex() {
KeyIndexableGraph graph = (KeyIndexableGraph) graphTest.generateGraph();
((SparkseeGraph) graph).typeScope.set(true);
this.stopWatch();
((SparkseeGraph) graph).label.set("people");
graph.createKeyIndex("name", Vertex.class);
((SparkseeGraph) graph).label.set("thing");
graph.createKeyIndex("name", Vertex.class);
assertTrue(graph.getIndexedKeys(Edge.class).isEmpty());
assertTrue(graph.getIndexedKeys(Vertex.class).size() == 1);
assertTrue(graph.getIndexedKeys(Vertex.class).contains("name"));
((SparkseeGraph) graph).label.set("people");
Vertex v1 = graph.addVertex(null);
v1.setProperty("name", "foo");
Vertex v2 = graph.addVertex(null);
v2.setProperty("name", "boo");
((SparkseeGraph) graph).label.set("thing");
Vertex v10 = graph.addVertex(null);
v10.setProperty("name", "foo");
Vertex v20 = graph.addVertex(null);
v20.setProperty("name", "boo");
((SparkseeGraph) graph).label.set("people");
assertTrue(graph.getVertices("name", "foo").iterator().next().equals(v1));
((SparkseeGraph) graph).label.set("thing");
assertTrue(graph.getVertices("name", "foo").iterator().next().equals(v10));
ArrayList<Vertex> result = new ArrayList<Vertex>(Arrays.asList(v1, v10));
// all types!
((SparkseeGraph) graph).label.set(null);
for (Vertex current : graph.getVertices("name", "foo")) {
assertTrue(result.contains(current));
result.remove(current);
}
assertTrue(result.size() == 0);
result = new ArrayList<Vertex>(Arrays.asList(v1, v2));
for (Vertex current : graph.getVertices(StringFactory.LABEL, "people")) {
assertTrue(result.contains(current));
result.remove(current);
}
assertTrue(result.size() == 0);
// table scan
v1.setProperty("age", 99);
((SparkseeGraph) graph).label.set("people");
assertTrue(graph.getVertices("age", 99).iterator().next().equals(v1));
printPerformance(graph.toString(), null, "testKeyIndex", this.stopWatch());
graph.shutdown();
}
Aggregations