Search in sources :

Example 6 with KeyIndexableGraph

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();
}
Also used : WrapperGraph(com.tinkerpop.blueprints.util.wrappers.WrapperGraph) KeyIndexableGraph(com.tinkerpop.blueprints.KeyIndexableGraph)

Example 7 with KeyIndexableGraph

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");
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) KeyIndexableGraph(com.tinkerpop.blueprints.KeyIndexableGraph) Test(org.junit.Test)

Example 8 with KeyIndexableGraph

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();
    }
}
Also used : SailConnection(org.openrdf.sail.SailConnection) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Sail(org.openrdf.sail.Sail) KeyIndexableGraph(com.tinkerpop.blueprints.KeyIndexableGraph) File(java.io.File) Test(org.junit.Test)

Example 9 with KeyIndexableGraph

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());
    }
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) KeyIndexableGraph(com.tinkerpop.blueprints.KeyIndexableGraph) IndexableGraph(com.tinkerpop.blueprints.IndexableGraph) KeyIndexableGraph(com.tinkerpop.blueprints.KeyIndexableGraph) ArrayList(java.util.ArrayList) Index(com.tinkerpop.blueprints.Index)

Example 10 with KeyIndexableGraph

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();
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) KeyIndexableGraph(com.tinkerpop.blueprints.KeyIndexableGraph) ArrayList(java.util.ArrayList)

Aggregations

KeyIndexableGraph (com.tinkerpop.blueprints.KeyIndexableGraph)15 Vertex (com.tinkerpop.blueprints.Vertex)6 Edge (com.tinkerpop.blueprints.Edge)3 IndexableGraph (com.tinkerpop.blueprints.IndexableGraph)2 TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 Index (com.tinkerpop.blueprints.Index)1 TransactionalGraph (com.tinkerpop.blueprints.TransactionalGraph)1 WrapperGraph (com.tinkerpop.blueprints.util.wrappers.WrapperGraph)1 File (java.io.File)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Sail (org.openrdf.sail.Sail)1 SailConnection (org.openrdf.sail.SailConnection)1