use of com.tinkerpop.blueprints.KeyIndexableGraph in project blueprints by tinkerpop.
the class SparkseeKeyIndexableGraphTestSuite method testNoConcurrentModificationException.
public void testNoConcurrentModificationException() {
KeyIndexableGraph graph = (KeyIndexableGraph) graphTest.generateGraph();
if (graph.getFeatures().supportsEdgeKeyIndex) {
graph.createKeyIndex("key", Edge.class);
for (int i = 0; i < 25; i++) {
graph.addEdge(null, graph.addVertex(null), graph.addVertex(null), graphTest.convertLabel("test")).setProperty("key", "value");
}
if (graph.getFeatures().supportsVertexIteration)
assertEquals(count(graph.getVertices()), 50);
if (graph.getFeatures().supportsEdgeIteration)
assertEquals(count(graph.getEdges()), 25);
int counter = 0;
for (final Edge edge : graph.getEdges("key", "value")) {
graph.removeEdge(edge);
counter++;
}
assertEquals(counter, 25);
if (graph.getFeatures().supportsVertexIteration)
assertEquals(count(graph.getVertices()), 50);
if (graph.getFeatures().supportsEdgeIteration)
assertEquals(count(graph.getEdges()), 0);
}
graph.shutdown();
}
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();
}
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());
}
}
Aggregations