public boolean filter(Edge<String, Integer> edge) { return (edge.getValue() > playcountThreshold); } }).groupBy(1)
@SuppressWarnings("unchecked") public Tuple2<K, EV> map(Edge<K, EV> edge) { return new Tuple2<>((K) edge.getField(fieldPosition), edge.getValue()); } }
public void iterateEdges(Vertex<String, NullValue> vertex, Iterable<Edge<String, Integer>> edges, Collector<Tuple2<String, String>> out) throws Exception { int maxPlaycount = 0; String topSong = ""; for (Edge<String, Integer> edge : edges) { if (edge.getValue() > maxPlaycount) { maxPlaycount = edge.getValue(); topSong = edge.getTarget(); } } out.collect(new Tuple2<>(vertex.getId(), topSong)); } }
public void compute(Vertex<Long, Double> vertex, MessageIterator<Double> messages) { double minDistance = (vertex.getId().equals(srcId)) ? 0d : Double.POSITIVE_INFINITY; for (Double msg : messages) { minDistance = Math.min(minDistance, msg); } if (minDistance < vertex.getValue()) { setNewVertexValue(minDistance); for (Edge<Long, Double> e: getEdges()) { sendMessageTo(e.getTarget(), minDistance + e.getValue()); } } } }
@Override public Edge<K, EV> join(Edge<K, EV> edge, VertexWithRepresentative<K> vertex) throws Exception { reuseEdge.setSource(vertex.getGroupRepresentativeId()); reuseEdge.setTarget(edge.getTarget()); reuseEdge.setValue(edge.getValue()); return reuseEdge; } }
@Override public void join(Vertex<K, VV> vertex, Edge<K, EV> edge, Collector<Tuple4<K, K, VV, EV>> collector) throws Exception { collector.collect(new Tuple4<>(edge.getSource(), edge.getTarget(), vertex.getValue(), edge.getValue())); } }
@Override public void sendMessages(Vertex<K, Double> vertex) { if (vertex.getValue() < Double.POSITIVE_INFINITY) { for (Edge<K, Double> edge : getEdges()) { sendMessageTo(edge.getTarget(), vertex.getValue() + edge.getValue()); } } } }
@Override public void sendMessages(Vertex<Long, Double> vertex) { if (vertex.getValue() < Double.POSITIVE_INFINITY) { for (Edge<Long, Double> edge : getEdges()) { sendMessageTo(edge.getTarget(), vertex.getValue() + edge.getValue()); } } } }
public void join(Vertex<K, VV> vertex, Edge<K, EV> edge, Collector<Tuple2<K, Neighbor<VV, EV>>> out) { out.collect(new Tuple2<>( edge.getTarget(), new Neighbor<>(vertex.getValue(), edge.getValue()))); } }
public void join(Vertex<K, VV> vertex, Edge<K, EV> edge, Collector<Tuple2<K, Neighbor<VV, EV>>> out) { out.collect(new Tuple2<>( edge.getSource(), new Neighbor<>(vertex.getValue(), edge.getValue()))); } }
@Override public void sendMessages(Vertex<K, Tuple2<Long, Double>> vertex) throws Exception { for (Edge<K, Double> edge : getEdges()) { sendMessageTo(edge.getTarget(), new Tuple2<>(vertex.getValue().f0, vertex.getValue().f1 * edge.getValue())); } } }
@Override public void sendMessages(Vertex<K, Double> vertex) { if (getSuperstepNumber() == 1) { // initialize vertex ranks vertex.setValue(1.0 / this.getNumberOfVertices()); } for (Edge<K, Double> edge : getEdges()) { sendMessageTo(edge.getTarget(), vertex.getValue() * edge.getValue()); } } }
@Override public void reduce(Iterable<Edge<K, EV>> values, Collector<Edge<K, EdgeValue<EV>>> out) throws Exception { K sourceVertexId = null; K targetVertexId = null; EV edgeGroupValue = null; Long edgeGroupCount = 0L; boolean isFirstElement = true; for (Edge<K, EV> edge : values) { if (isFirstElement) { sourceVertexId = edge.getSource(); targetVertexId = edge.getTarget(); edgeGroupValue = edge.getValue(); isFirstElement = false; } edgeGroupCount++; } reuseEdgeValue.setEdgeGroupValue(edgeGroupValue); reuseEdgeValue.setEdgeGroupCount(edgeGroupCount); reuseEdge.setSource(sourceVertexId); reuseEdge.setTarget(targetVertexId); reuseEdge.setValue(reuseEdgeValue); out.collect(reuseEdge); } }
@Override public long extractAscendingTimestamp(Edge<Long, Long> element) { return element.getValue(); } }
@SuppressWarnings("unchecked") public Tuple2<K, EV> map(Edge<K, EV> edge) { return new Tuple2<>((K) edge.getField(fieldPosition), edge.getValue()); } }
@Override public void join(Vertex<K, VV> vertex, Edge<K, EV> edge, Collector<Tuple4<K, K, VV, EV>> collector) throws Exception { collector.collect(new Tuple4<>(edge.getSource(), edge.getTarget(), vertex.getValue(), edge.getValue())); } }
public void join(Vertex<K, VV> vertex, Edge<K, EV> edge, Collector<Tuple2<K, Neighbor<VV, EV>>> out) { out.collect(new Tuple2<>( edge.getTarget(), new Neighbor<>(vertex.getValue(), edge.getValue()))); } }
@Override public void sendMessages(Vertex<K, Tuple2<Long, Double>> vertex) throws Exception { for (Edge<K, Double> edge : getEdges()) { sendMessageTo(edge.getTarget(), new Tuple2<>(vertex.getValue().f0, vertex.getValue().f1 * edge.getValue())); } } }
public void join(Vertex<K, VV> vertex, Edge<K, EV> edge, Collector<Tuple2<K, Neighbor<VV, EV>>> out) { out.collect(new Tuple2<>( edge.getTarget(), new Neighbor<>(vertex.getValue(), edge.getValue()))); } }