Package com.thinkaurelius.titan.core

Examples of com.thinkaurelius.titan.core.TitanVertex


            readThreads[t] = new Thread(new Runnable() {
                @Override
                public void run() {
                    for (int t = 1; t <= trials; t++) {
                        TitanTransaction tx = graph.newTransaction();
                        TitanVertex v = tx.getVertex(vids[random.nextInt(numV)]);
                        for (int r = 0; r < repetitions; r++) {
                            assertEquals((int) Math.pow(numE, 2), Iterables.size(new GremlinPipeline<Vertex, Vertex>(v)
                                    .out(label).out(label)
                            ));
                        }
View Full Code Here


        final int repetitions = 1000;
        long start = System.currentTimeMillis();

        TitanTransaction tx = graph.buildTransaction().readOnly().start();
        for (int r = 0; r < repetitions; r++) {
            TitanVertex v = tx.getVertex(vids[random.nextInt(numV)]);
            assertTrue((int) Math.pow(numE, 2) <= Iterables.size(
                    new GremlinPipeline<Vertex, Vertex>(v)
                            .both(label).both(label)
            ));
            assertEquals((int) Math.pow(numE, 2), Iterables.size(
View Full Code Here

            writeThreads[t] = new Thread(new Runnable() {
                @Override
                public void run() {
                    for (int r = 0; r < rounds; r++) {
                        TitanTransaction tx = graph.newTransaction();
                        TitanVertex previous = null;
                        for (int c = 0; c < commitSize; c++) {
                            TitanVertex v = tx.addVertex();
                            long uid = uidCounter.incrementAndGet();
                            v.setProperty("uid", uid);
                            v.setProperty("name", "user" + uid);
                            if (previous != null) {
                                v.addEdge("friend", previous).setProperty("time", Math.abs(random.nextInt()));
                            }
                            previous = v;
                        }
                        tx.commit();
                    }
                }
            });
            writeThreads[t].start();
        }
        for (int t = 0; t < writeThreads.length; t++) {
            writeThreads[t].join();
        }
        System.out.println("Write time for " + (rounds * commitSize * writeThreads.length) + " vertices & edges: " + (System.currentTimeMillis() - start));

        final int maxUID = uidCounter.get();
        final int trials = 1000;
        final String fixedName = "john";
        Thread[] readThreads = new Thread[Runtime.getRuntime().availableProcessors() * 2];
        start = System.currentTimeMillis();
        for (int t = 0; t < readThreads.length; t++) {
            readThreads[t] = new Thread(new Runnable() {
                @Override
                public void run() {
                    TitanTransaction tx = graph.newTransaction();
                    long ruid = random.nextInt(maxUID) + 1;
                    tx.getVertex("uid", ruid).setProperty("name", fixedName);
                    for (int t = 1; t <= trials; t++) {
                        TitanVertex v = tx.getVertex("uid", random.nextInt(maxUID) + 1);
                        assertEquals(2, Iterables.size(v.getProperties()));
                        int count = 0;
                        for (TitanEdge e : v.getEdges()) {
                            count++;
                            assertTrue(((Number) e.getProperty("time")).longValue() >= 0);
                        }
                        assertTrue(count <= 2);
//                        if (t%(trials/10)==0) System.out.println(t);
View Full Code Here

            for (boolean flush : new boolean[]{true, false}) {
                TitanGraph graph = getInMemoryGraph();
                int numVertices = 100;
                List<TitanVertex> vertices = new ArrayList<TitanVertex>(numVertices);
                List<InternalRelation> relations = new ArrayList<InternalRelation>();
                TitanVertex old = null;
                for (int i = 0; i < numVertices; i++) {
                    TitanVertex next = (TitanVertex) graph.addVertex(null);
                    InternalRelation edge = null;
                    if (old != null) {
                        edge = (InternalRelation) graph.addEdge(null, old, next, "knows");
                    }
                    InternalRelation property = (InternalRelation) next.addProperty("age", 25);
                    if (flush) {
                        idAssigner.assignID((InternalVertex) next);
                        idAssigner.assignID(property);
                        if (edge != null) idAssigner.assignID(edge);
                    } else {
View Full Code Here

    public void testValueOrdering() {
        StandardTitanGraph graph = (StandardTitanGraph) StorageSetup.getInMemoryGraph();
        TitanLabel father = graph.makeLabel("father").manyToOne().make();
        for (int i=1;i<=5;i++) graph.makeKey("key"+i).single().dataType(Integer.class).make();

        TitanVertex v1 = graph.addVertex(null), v2 = graph.addVertex(null);
        TitanEdge e1 = v1.addEdge("father",v2);
        for (int i=1;i<=5;i++) e1.setProperty("key"+i,i);

        graph.commit();

        e1.remove();
View Full Code Here

TOP

Related Classes of com.thinkaurelius.titan.core.TitanVertex

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.