Package com.tinkerpop.blueprints

Examples of com.tinkerpop.blueprints.KeyIndexableGraph


        }
        graph.shutdown();
    }

    public void testReIndexingOfElements() {
        KeyIndexableGraph graph = (KeyIndexableGraph) graphTest.generateGraph();
        if (graph.getFeatures().supportsVertexKeyIndex) {
            Vertex vertex = graph.addVertex(null);
            vertex.setProperty("name", "marko");
            assertEquals(count(graph.getVertices("name", "marko")), 1);
            assertEquals(graph.getVertices("name", "marko").iterator().next(), vertex);
            graph.createKeyIndex("name", Vertex.class);
            assertEquals(count(graph.getVertices("name", "marko")), 1);
            assertEquals(graph.getVertices("name", "marko").iterator().next(), vertex);
        }

        if (graph.getFeatures().supportsEdgeKeyIndex) {
            Edge edge = graph.addEdge(null, graph.addVertex(null), graph.addVertex(null), graphTest.convertLabel("knows"));
            edge.setProperty("date", 2012);
            assertEquals(count(graph.getEdges("date", 2012)), 1);
            assertEquals(graph.getEdges("date", 2012).iterator().next(), edge);
            graph.createKeyIndex("date", Edge.class);
            assertEquals(count(graph.getEdges("date", 2012)), 1);
            assertEquals(graph.getEdges("date", 2012).iterator().next(), edge);
        }
        graph.shutdown();
    }
View Full Code Here


        graph.shutdown();
    }


    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();
    }
View Full Code Here

        assertTrue(Vertex.class.isAssignableFrom(index.getIndexClass()));
        assertEquals(index.getIndexName(), "blah");
    }

    public void testReadOnlyKeyIndices() {
        KeyIndexableGraph graph = new ReadOnlyKeyIndexableGraph<TinkerGraph>(TinkerGraphFactory.createTinkerGraph());
        ((KeyIndexableGraph) ((WrapperGraph<IndexableGraph>) graph).getBaseGraph()).createKeyIndex("blah", Vertex.class);
        assertTrue(graph.getIndexedKeys(Vertex.class) instanceof Set);
        assertEquals(graph.getIndexedKeys(Vertex.class).size(), 1);
        assertTrue(graph.getIndexedKeys(Vertex.class).contains("blah"));
        try {
            graph.createKeyIndex("whatever", Vertex.class);
            assertTrue(false);
        } catch (UnsupportedOperationException e) {
            assertTrue(true);
        }
        try {
            graph.dropKeyIndex("blah", Vertex.class);
            assertTrue(false);
        } catch (UnsupportedOperationException e) {
            assertTrue(true);
        }
    }
View Full Code Here

        return new TinkerGraph();
    }

    @Test
    public void testTmp() throws Exception {
        KeyIndexableGraph g = new TinkerGraph();
        GraphSail sail = new GraphSail(g, "sp,p,c,pc");
    }
View Full Code Here

* @author Joshua Shinavier (http://fortytwo.net)
*/
public class SailLoaderTest {
    @Test
    public void testAll() throws Exception {
        KeyIndexableGraph g = new TinkerGraph();
        Sail sail = new GraphSail(g);
        sail.initialize();
        try {
            SailLoader loader = new SailLoader(sail);

View Full Code Here

    @GET
    @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON})
    @Timed(name = "http.rest.key-indices.collection.get", absolute = true)
    public Response getKeyIndices(@PathParam("graphname") final String graphName) {
        final KeyIndexableGraph graph = this.getKeyIndexableGraph(graphName);
        final RexsterApplicationGraph rag = this.getRexsterApplicationGraph(graphName);
       
        try {
            final JSONArray keyVertexArray = new JSONArray();
            for (String key : graph.getIndexedKeys(Vertex.class)) {
                keyVertexArray.put(key);
            }

            final JSONArray keyEdgeArray = new JSONArray();
            for (String key : graph.getIndexedKeys(Edge.class)) {
                keyEdgeArray.put(key);
            }

            this.resultObject.put(Tokens.RESULTS, new JSONObject(new HashMap() {{
                put(Tokens.VERTEX, keyVertexArray);
View Full Code Here

            keyClass = Edge.class;
        } else {
            throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
        }
       
        final KeyIndexableGraph graph = this.getKeyIndexableGraph(graphName);
        final RexsterApplicationGraph rag = this.getRexsterApplicationGraph(graphName);

        try {
            final JSONArray keyArray = new JSONArray();
            for (String key : graph.getIndexedKeys(keyClass)) {
                keyArray.put(key);
            }

            this.resultObject.put(Tokens.RESULTS, keyArray);
            this.resultObject.put(Tokens.QUERY_TIME, this.sh.stopWatch());
View Full Code Here

        if (keyName == null || keyName.isEmpty()) {
            throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
        }

        final RexsterApplicationGraph rag = this.getRexsterApplicationGraph(graphName);
        final KeyIndexableGraph graph = this.getKeyIndexableGraph(graphName);
       
        try {
            graph.dropKeyIndex(keyName, keyClass);

            rag.tryCommit();

            this.resultObject.put(Tokens.QUERY_TIME, this.sh.stopWatch());
        } catch (JSONException ex) {
View Full Code Here

        if (keyName == null || keyName.isEmpty()) {
            throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
        }

        final RexsterApplicationGraph rag = this.getRexsterApplicationGraph(graphName);
        final KeyIndexableGraph graph = this.getKeyIndexableGraph(graphName);

        try {
            graph.createKeyIndex(keyName, keyClass);

            rag.tryCommit();

            this.resultObject.put(Tokens.QUERY_TIME, this.sh.stopWatch());
        } catch (JSONException ex) {
View Full Code Here

    }

    private KeyIndexableGraph getKeyIndexableGraph(final String graphName) {

        final Graph graph = this.getRexsterApplicationGraph(graphName).getUnwrappedGraph();
        final KeyIndexableGraph idxGraph = graph instanceof KeyIndexableGraph ? (KeyIndexableGraph) graph : null;

        if (idxGraph == null) {
            final JSONObject error = this.generateErrorObject("The requested graph is not of type IndexableGraph.");
            throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build());
        }
View Full Code Here

TOP

Related Classes of com.tinkerpop.blueprints.KeyIndexableGraph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.