Package com.tinkerpop.blueprints.impls.tg

Examples of com.tinkerpop.blueprints.impls.tg.TinkerGraph


        ScriptEngine engine = new GremlinGroovyScriptEngine();
        assertEquals("轉注", engine.eval("'轉注'"));
    }

    public void testUTF8Query() throws Exception {
        TinkerGraph graph = new TinkerGraph();
        Index<Vertex> index = graph.createIndex("nodes", Vertex.class);

        Vertex nonUtf8 = graph.addVertex("1");
        nonUtf8.setProperty("name", "marko");
        nonUtf8.setProperty("age", 29);
        index.put("name", "marko", nonUtf8);

        Vertex utf8Name = graph.addVertex("2");
        utf8Name.setProperty("name", "轉注");
        utf8Name.setProperty("age", 32);
        index.put("name", "轉注", utf8Name);
        graph.addVertex(utf8Name);

        graph.addEdge("12", nonUtf8, utf8Name, "created").setProperty("weight", 0.2f);

        ScriptEngine engine = new GremlinGroovyScriptEngine();

        engine.put("g", graph);
        Pipeline eval = (Pipeline) engine.eval("g.idx(\"nodes\")[['name' : 'marko']]");
View Full Code Here


*/
public class VertexToFaunusBinaryTest extends BaseTest {

    public void testConversion() throws IOException {

        Graph graph = new TinkerGraph();
        Vertex marko = graph.addVertex(1);
        marko.setProperty("name", "marko");
        marko.setProperty("age", 32);
        Vertex stephen = graph.addVertex(3);
        stephen.setProperty("name", "stephen");
        stephen.setProperty("weight", 160.42);
        stephen.setProperty("male", true);
        Edge e = graph.addEdge(null, marko, stephen, "knows");
        e.setProperty("weight", 0.2);
        e.setProperty("type", "coworker");

        ByteArrayOutputStream bytes1 = new ByteArrayOutputStream();
        DataOutput out = new DataOutputStream(bytes1);
View Full Code Here

        edgeMapReduceDriver.setMapper(new TinkerGraphOutputMapReduce.EdgeMap());
        edgeMapReduceDriver.setReducer(new Reducer<NullWritable, FaunusVertex, NullWritable, FaunusVertex>());
    }

    public void testTinkerGraphIncrementalVertexLoading() throws Exception {
        TinkerGraphOutputMapReduce.graph = new TinkerGraph();
        Configuration conf = BlueprintsGraphOutputMapReduce.createConfiguration();
        conf.set(BlueprintsGraphOutputMapReduce.FAUNUS_GRAPH_OUTPUT_BLUEPRINTS_SCRIPT_FILE, "./data/BlueprintsScript.groovy");
        vertexMapReduceDriver.withConfiguration(conf);
        Map<Long, FaunusVertex> graph = runWithGraph(generateGraph(BaseTest.ExampleGraph.TINKERGRAPH, conf), vertexMapReduceDriver);
        edgeMapReduceDriver.withConfiguration(conf);
View Full Code Here

        assertEquals(vertices.size(), 1);
        assertTrue(vertices.contains(josh));
    }

    public void testTinkerGraphIncrementalEdgeLoading() throws Exception {
        TinkerGraphOutputMapReduce.graph = new TinkerGraph();
        Configuration conf = BlueprintsGraphOutputMapReduce.createConfiguration();
        conf.set(BlueprintsGraphOutputMapReduce.FAUNUS_GRAPH_OUTPUT_BLUEPRINTS_SCRIPT_FILE, "./data/BlueprintsScript.groovy");
        vertexMapReduceDriver.withConfiguration(conf);
        Map<Long, FaunusVertex> graph = runWithGraph(generateGraph(BaseTest.ExampleGraph.TINKERGRAPH, conf), vertexMapReduceDriver);
        edgeMapReduceDriver.withConfiguration(conf);
View Full Code Here

        assertEquals(vertices.size(), 1);
        assertTrue(vertices.contains(josh));
    }

    public void testTinkerGraphMapping() throws Exception {
        TinkerGraphOutputMapReduce.graph = new TinkerGraph();
        Configuration conf = BlueprintsGraphOutputMapReduce.createConfiguration();
        vertexMapReduceDriver.withConfiguration(conf);
        Map<Long, FaunusVertex> graph = runWithGraph(generateGraph(BaseTest.ExampleGraph.TINKERGRAPH, conf), vertexMapReduceDriver);
        conf = BlueprintsGraphOutputMapReduce.createConfiguration();
        edgeMapReduceDriver.withConfiguration(conf);
View Full Code Here

    }

    @Test
    public void convertIteratorNotPagedWithEmbeddedMap() throws Exception {
        final JSONResultConverter converter = new JSONResultConverter(GraphSONMode.EXTENDED, 0, Long.MAX_VALUE, null);
        final Graph g = new TinkerGraph();
        final Vertex v = g.addVertex(1);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("x", 500);
        map.put("y", "some");

        ArrayList friends = new ArrayList();
        friends.add("x");
        friends.add(5);
        friends.add(map);

        v.setProperty("friends", friends);

        Iterator iterable = g.getVertices().iterator();

        JSONArray converted = converter.convert(iterable);

        Assert.assertNotNull(converted);
        Assert.assertEquals(1, converted.length());
View Full Code Here

        Assert.assertEquals(500, object3ValueX.getInt("value"));
    }

    @Test
    public void convertMapWithElementForKey() throws Exception {
        TinkerGraph g = TinkerGraphFactory.createTinkerGraph();
        Map<Vertex, Integer> map = new HashMap<Vertex, Integer>();
        map.put(g.getVertex(1), 1000);

        JSONArray converted = this.converterNotPaged.convert(map);

        Assert.assertNotNull(converted);
        Assert.assertEquals(1, converted.length());
View Full Code Here

        Assert.assertEquals("y2", mapY.get("col2"));
    }

    @Test
    public void convertElements() throws Exception {
        TinkerGraph g = TinkerGraphFactory.createTinkerGraph();
        byte[] converted = this.converter.convert(g.getVertices());

        final BufferUnpacker unpacker = msgpack.createBufferUnpacker(converted);
        final Object unpacked = unpacker.readValue();

        Assert.assertTrue(unpacked instanceof Iterable);
View Full Code Here

import com.tinkerpop.blueprints.impls.tg.TinkerGraph;

public class MockIndexableGraphConfiguration implements GraphConfiguration {

    public Graph configureGraphInstance(final GraphConfigurationContext context) throws GraphConfigurationException {
        return new TinkerGraph();
    }
View Full Code Here

        ClientResponse response = this.client.handle(request);

        JSONObject json = response.getEntity(JSONObject.class);
        JSONArray jsonArray = json.optJSONArray("graphs");

        TinkerGraph testGraph = TinkerGraphFactory.createTinkerGraph();

        this.testGraphs = new ArrayList<GraphTestHolder>();
        for (int ix = 0; ix < jsonArray.length(); ix++) {
            ClientRequest graphRequest = ClientRequest.create().build(createUri("/" + jsonArray.optString(ix)), "GET");
            ClientResponse graphResponse = this.client.handle(graphRequest);

            JSONObject graphJson = graphResponse.getEntity(JSONObject.class);

            final JSONObject featuresJson = graphJson.optJSONObject("features");
            final Map<String, Boolean> features = new HashMap<String, Boolean>();
            Iterator<String> keys = featuresJson.keys();
            while (keys.hasNext()) {
                final String key = keys.next();
                features.put(key, featuresJson.optBoolean(key));
            }
           
            GraphTestHolder holder = new GraphTestHolder(graphJson.optString("name"),
                    graphJson.optString("type"), features);
            this.testGraphs.add(holder);

            for (Vertex v : testGraph.getVertices()) {
                postVertex(holder, v);
            }

            for (Edge e : testGraph.getEdges()) {
                postEdge(holder, e);
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.tinkerpop.blueprints.impls.tg.TinkerGraph

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.