Package com.thinkaurelius.faunus

Examples of com.thinkaurelius.faunus.FaunusEdge


                    this.map.incr(ElementPicker.getProperty(value, this.property), value.pathCount());
                    context.getCounter(Counters.PROPERTIES_COUNTED).increment(1l);
                }
            } else {
                for (final Edge e : value.getEdges(Direction.OUT)) {
                    final FaunusEdge edge = (FaunusEdge) e;
                    if (edge.hasPaths()) {
                        this.map.incr(ElementPicker.getProperty(edge, this.property), edge.pathCount());
                        context.getCounter(Counters.PROPERTIES_COUNTED).increment(1l);
                    }
                }
            }
View Full Code Here


                    context.getCounter(Counters.VERTICES_FILTERED).increment(1l);
                }
            } else {
                long counter = 0;
                for (final Edge e : value.getEdges(Direction.BOTH)) {
                    final FaunusEdge edge = (FaunusEdge) e;
                    if (edge.hasPaths() && !(this.startChecker.isLegal(edge) && this.endChecker.isLegal(edge))) {
                        edge.clearPaths();
                        counter++;
                    }
                }
                context.getCounter(Counters.EDGES_FILTERED).increment(counter);
            }
View Full Code Here

                    for (final List<FaunusElement.MicroElement> path : value.getPaths()) {
                        map.incr(path.get(this.step).getId(), 1);
                    }
                    for (java.util.Map.Entry<Long, Long> entry : map.entrySet()) {
                        final long linkElementId = entry.getKey();
                        final FaunusEdge edge;
                        if (this.direction.equals(IN))
                            edge = new FaunusEdge(linkElementId, valueId, this.label);
                        else
                            edge = new FaunusEdge(valueId, linkElementId, this.label);
                        edge.enablePath(this.pathEnabled);

                        if (!this.mergeWeightKey.equals(NO_WEIGHT_KEY))
                            edge.setProperty(this.mergeWeightKey, entry.getValue());

                        value.addEdge(this.direction, edge);
                        edgesCreated++;
                        this.longWritable.set(linkElementId);
                        context.write(this.longWritable, this.holder.set('e', edge));
                    }
                } else {
                    for (final List<FaunusElement.MicroElement> path : value.getPaths()) {
                        final long linkElementId = path.get(this.step).getId();
                        final FaunusEdge edge;
                        if (this.direction.equals(IN))
                            edge = new FaunusEdge(linkElementId, valueId, this.label);
                        else
                            edge = new FaunusEdge(valueId, linkElementId, this.label);
                        edge.enablePath(this.pathEnabled);
                        value.addEdge(this.direction, edge);
                        edgesCreated++;
                        this.longWritable.set(linkElementId);
                        context.write(this.longWritable, this.holder.set('e', edge));
                    }
View Full Code Here

                    }
                    value.clearPaths();
                }
            } else {
                for (final Edge e : value.getEdges(Direction.OUT)) {
                    final FaunusEdge edge = (FaunusEdge) e;
                    if (edge.hasPaths()) {
                        for (final List<FaunusElement.MicroElement> path : edge.getPaths()) {
                            if (path.get(this.step) instanceof FaunusEdge.MicroEdge)
                                throw new IOException("Back does not support backing up to previous edges");

                            final long backElementId = path.get(this.step).getId();
                            this.longWritable.set(backElementId);
                            this.vertex.reuse(backElementId);
                            this.vertex.addPath(path, false);
                            context.write(this.longWritable, this.holder.set('p', this.vertex));
                        }
                        edge.clearPaths();
                    }
                }

                for (final Edge e : value.getEdges(Direction.IN)) {
                    final FaunusEdge edge = (FaunusEdge) e;
                    if (edge.hasPaths())
                        edge.clearPaths();
                }
            }

            this.longWritable.set(value.getIdAsLong());
            context.write(this.longWritable, this.holder.set('v', value));
View Full Code Here

                        }
                    }
                }
            } else {
                for (final Edge e : value.getEdges(Direction.BOTH)) {
                    final FaunusEdge edge = (FaunusEdge) e;
                    if (edge.hasPaths()) {
                        final Iterator<List<FaunusElement.MicroElement>> itty = edge.getPaths().iterator();
                        while (itty.hasNext()) {
                            final List<FaunusElement.MicroElement> path = itty.next();
                            this.set.clear();
                            this.set.addAll(path);
                            if (path.size() != this.set.size()) {
View Full Code Here

                context.getCounter(Counters.VERTICES_COUNTED).increment(pathCount > 0 ? 1 : 0);
            } else {
                long edgesCounted = 0;
                long pathCount = 0;
                for (final Edge e : value.getEdges(Direction.OUT)) {
                    final FaunusEdge edge = (FaunusEdge) e;
                    if (edge.hasPaths()) {
                        edgesCounted++;
                        pathCount = pathCount + edge.pathCount();
                    }
                }
                this.longWritable.set(pathCount);
                context.write(NullWritable.get(), this.longWritable);
                context.getCounter(Counters.EDGES_COUNTED).increment(edgesCounted);
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.text.set(ElementPicker.getPropertyAsString(edge, this.elementKey));
                        final Object temp = ElementPicker.getProperty(edge, this.key);
                        if (this.key.equals(Tokens._COUNT)) {
                            this.writable = this.handler.set(temp);
                            context.write(this.writable, this.text);
                        } else if (temp instanceof Number) {
                            this.writable = this.handler.set(multiplyPathCount((Number) temp, edge.pathCount()));
                            context.write(this.writable, this.text);
                        } else {
                            this.writable = this.handler.set(temp);
                            for (int i = 0; i < edge.pathCount(); i++) {
                                context.write(this.writable, this.text);
                            }
                        }
                        edgesProcessed++;
                    }
View Full Code Here

        @Override
        public void setup(final Mapper.Context context) throws IOException, InterruptedException {
            this.direction = Direction.valueOf(context.getConfiguration().get(DIRECTION));
            this.labels = context.getConfiguration().getStrings(LABELS, new String[0]);
            this.pathEnabled = context.getConfiguration().getBoolean(FaunusCompiler.PATH_ENABLED, false);
            this.edge = new FaunusEdge(this.pathEnabled);

        }
View Full Code Here

            if (value.hasPaths()) {
                long edgesTraversed = 0l;

                if (this.direction.equals(IN) || this.direction.equals(BOTH)) {
                    for (final Edge e : value.getEdges(IN, this.labels)) {
                        final FaunusEdge edge = (FaunusEdge) e;
                        this.edge.reuse(edge.getIdAsLong(), edge.getVertexId(OUT), edge.getVertexId(IN), edge.getLabel());

                        if (this.pathEnabled) {
                            final List<List<FaunusElement.MicroElement>> paths = clonePaths(value, new FaunusEdge.MicroEdge(edge.getIdAsLong()));
                            edge.addPaths(paths, false);
                            this.edge.addPaths(paths, false);
                        } else {
                            edge.getPaths(value, false);
                            this.edge.getPaths(value, false);
                        }
                        this.longWritable.set(edge.getVertexId(OUT));
                        context.write(this.longWritable, this.holder.set('p', this.edge));
                        edgesTraversed++;
                    }
                }

                if (this.direction.equals(OUT) || this.direction.equals(BOTH)) {
                    for (final Edge e : value.getEdges(OUT, this.labels)) {
                        final FaunusEdge edge = (FaunusEdge) e;
                        this.edge.reuse(edge.getIdAsLong(), edge.getVertexId(OUT), edge.getVertexId(IN), edge.getLabel());

                        if (this.pathEnabled) {
                            final List<List<FaunusElement.MicroElement>> paths = clonePaths(value, new FaunusEdge.MicroEdge(edge.getIdAsLong()));
                            edge.addPaths(paths, false);
                            this.edge.addPaths(paths, false);
                        } else {
                            edge.getPaths(value, false);
                            this.edge.getPaths(value, false);
                        }
                        this.longWritable.set(edge.getVertexId(IN));
                        context.write(this.longWritable, this.holder.set('p', this.edge));
                        edgesTraversed++;
                    }
                }
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()) {
                        final Object result = this.closure.call(edge);
                        this.textWritable.set(null == result ? Tokens.NULL : result.toString());
                        for (int i = 0; i < edge.pathCount(); i++) {
                            this.outputs.write(Tokens.SIDEEFFECT, NullWritable.get(), this.textWritable);
                        }
                        edgesProcessed++;
                    }
                }
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.