Package com.thinkaurelius.faunus

Examples of com.thinkaurelius.faunus.FaunusEdge


        public void map(final NullWritable key, final FaunusVertex value, final Mapper<NullWritable, FaunusVertex, NullWritable, FaunusVertex>.Context context) throws IOException, InterruptedException {

            if (this.direction.equals(IN) || this.direction.equals(BOTH)) {
                long edgesProcessed = 0;
                for (final Edge e : value.getEdges(IN)) {
                    final FaunusEdge edge = (FaunusEdge) e;
                    if (edge.hasPaths()) {
                        value.getPaths(edge, true);
                        edgesProcessed++;
                        edge.clearPaths();
                    }
                }
                context.getCounter(Counters.IN_EDGES_PROCESSED).increment(edgesProcessed);
            } else {
                for (final Edge e : value.getEdges(IN)) {
                    final FaunusEdge edge = (FaunusEdge) e;
                    if (edge.hasPaths()) {
                        edge.clearPaths();
                    }
                }
            }

            if (this.direction.equals(OUT) || this.direction.equals(BOTH)) {
                long edgesProcessed = 0;
                for (final Edge e : value.getEdges(OUT)) {
                    final FaunusEdge edge = (FaunusEdge) e;
                    if (edge.hasPaths()) {
                        value.getPaths(edge, true);
                        edgesProcessed++;
                        edge.clearPaths();
                    }
                }
                context.getCounter(Counters.OUT_EDGES_PROCESSED).increment(edgesProcessed);
            } else {
                for (final Edge e : value.getEdges(OUT)) {
                    final FaunusEdge edge = (FaunusEdge) e;
                    if (edge.hasPaths()) {
                        edge.clearPaths();
                    }
                }
            }

            context.write(NullWritable.get(), value);
View Full Code Here


                }
                context.getCounter(Counters.VERTICES_PROCESSED).increment(1l);
            } else {
                long edgesProcessed = 0;
                for (final Edge e : value.getEdges(Direction.OUT)) {
                    final FaunusEdge edge = (FaunusEdge) e;
                    if (edge.hasPaths()) {
                        for (final List<FaunusElement.MicroElement> path : edge.getPaths()) {
                            this.textWritable.set(path.toString());
                            this.outputs.write(Tokens.SIDEEFFECT, NullWritable.get(), this.textWritable);
                        }
                        edgesProcessed++;
                    }
View Full Code Here

                    context.getCounter(Counters.VERTICES_PROCESSED).increment(1l);
                }
            } else {
                long edgesProcessed = 0;
                for (final Edge e : value.getEdges(Direction.OUT)) {
                    final FaunusEdge edge = (FaunusEdge) e;
                    if (edge.hasPaths()) {
                        WritableComparable writable = this.handler.set(ElementPicker.getProperty(edge, this.key));
                        for (int i = 0; i < edge.pathCount(); i++) {
                            this.outputs.write(Tokens.SIDEEFFECT, NullWritable.get(), writable);
                        }
                        edgesProcessed++;
                    }
                }
View Full Code Here

                    context.getCounter(Counters.VERTICES_PROCESSED).increment(1l);
                }
            } else {
                long edgesProcessed = 0;
                for (final Edge e : value.getEdges(Direction.OUT)) {
                    final FaunusEdge edge = (FaunusEdge) e;
                    if (edge.hasPaths()) {
                        this.longWritable.set(edge.getIdAsLong());
                        this.text.set(ElementPicker.getPropertyAsString(edge, Tokens._PROPERTIES));
                        for (int i = 0; i < edge.pathCount(); i++) {
                            this.outputs.write(Tokens.SIDEEFFECT, this.longWritable, this.text);
                        }
                        edgesProcessed++;
                    }
                }
View Full Code Here

    }

    public void testSimpleElementList() throws IOException {
        mapReduceDriver.addInput(NullWritable.get(), new FaunusVertex(1));
        mapReduceDriver.addInput(NullWritable.get(), new FaunusVertex(2));
        mapReduceDriver.addInput(NullWritable.get(), new FaunusEdge(1, 2, "knows"));
        Map<Long, FaunusVertex> results = BaseTest.run(mapReduceDriver);
        assertEquals(results.size(), 2);
        assertEquals(results.get(1l).getIdAsLong(), 1);
        assertEquals(results.get(2l).getIdAsLong(), 2);
        assertEquals(count(results.get(1l).getEdges(Direction.OUT)), 1);
View Full Code Here

        mapReduceDriver.addInput(NullWritable.get(), new FaunusVertex(1));
        mapReduceDriver.addInput(NullWritable.get(), new FaunusVertex(2));
        mapReduceDriver.addInput(NullWritable.get(), new FaunusVertex(1));
        mapReduceDriver.addInput(NullWritable.get(), new FaunusVertex(2));
        mapReduceDriver.addInput(NullWritable.get(), new FaunusVertex(2));
        mapReduceDriver.addInput(NullWritable.get(), new FaunusEdge(1, 2, "knows"));
        Map<Long, FaunusVertex> results = BaseTest.run(mapReduceDriver);
        assertEquals(results.size(), 2);
        assertEquals(results.get(1l).getIdAsLong(), 1);
        assertEquals(results.get(2l).getIdAsLong(), 2);
        assertEquals(count(results.get(1l).getEdges(Direction.OUT)), 1);
View Full Code Here

        mapReduceDriver.addInput(NullWritable.get(), new FaunusVertex(1));
        mapReduceDriver.addInput(NullWritable.get(), new FaunusVertex(2));
        mapReduceDriver.addInput(NullWritable.get(), new FaunusVertex(3));
        mapReduceDriver.addInput(NullWritable.get(), new FaunusVertex(2));
        mapReduceDriver.addInput(NullWritable.get(), new FaunusVertex(3));
        mapReduceDriver.addInput(NullWritable.get(), new FaunusEdge(1, 2, "likes"));
        mapReduceDriver.addInput(NullWritable.get(), new FaunusEdge(2, 3, "hates"));
        mapReduceDriver.addInput(NullWritable.get(), new FaunusEdge(3, 1, "likes"));
        Map<Long, FaunusVertex> results = BaseTest.run(mapReduceDriver);
        assertEquals(results.size(), 3);
        assertEquals(results.get(1l).getIdAsLong(), 1);
        assertEquals(results.get(2l).getIdAsLong(), 2);
        assertEquals(results.get(3l).getIdAsLong(), 3);
View Full Code Here

        FaunusVertex c = new FaunusVertex(1);
        c.setProperty("name", "marko");
        c.setProperty("ssn", "12345");

        FaunusEdge e = new FaunusEdge(a.getIdAsLong(), b.getIdAsLong(), "knows");
        e.setProperty("weight", 1.2f);

        mapReduceDriver.addInput(NullWritable.get(), a);
        mapReduceDriver.addInput(NullWritable.get(), b);
        mapReduceDriver.addInput(NullWritable.get(), c);
        mapReduceDriver.addInput(NullWritable.get(), e);
View Full Code Here

        FaunusVertex stephen = new FaunusVertex(2l);
        stephen.setProperty("name", "stephen");
        FaunusVertex vadas = new FaunusVertex(3l);
        vadas.setProperty("name", "vadas");

        marko.addEdge(OUT, new FaunusEdge(marko.getIdAsLong(), stephen.getIdAsLong(), "knows")).setProperty("weight", 2);
        marko.addEdge(IN, new FaunusEdge(vadas.getIdAsLong(), marko.getIdAsLong(), "knows")).setProperty("weight", 1);

        JSONObject m = FaunusGraphSONUtility.toJSON(marko);
        JSONObject s = FaunusGraphSONUtility.toJSON(stephen);

        assertEquals(m.getString("name"), "marko");
View Full Code Here

        assertEquals(josh.getProperty("name"), "josh");
        assertEquals(josh.getPropertyKeys().size(), 2);
        FaunusVertex marko = (FaunusVertex) handler.next();
        assertEquals(marko.getProperty("name"), "marko");
        assertEquals(marko.getPropertyKeys().size(), 2);
        FaunusEdge knows = (FaunusEdge) handler.next();
        assertEquals(knows.getLabel(), "knows");
        assertEquals(knows.getPropertyKeys().size(), 1);
        assertFalse(handler.hasNext());
    }
View Full Code Here

TOP

Related Classes of com.thinkaurelius.faunus.FaunusEdge

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.