Java Code Examples for org.apache.flink.graph.Edge#getValue()

The following examples show how to use org.apache.flink.graph.Edge#getValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Summarization.java    From flink with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 2
Source File: ReduceOnEdgesMethodsITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void iterateEdges(Vertex<Long, Long> v,
		Iterable<Edge<Long, Long>> edges, Collector<Tuple2<Long, Long>> out) throws Exception {

	long weight = Long.MAX_VALUE;
	long minNeighborId = 0;

	for (Edge<Long, Long> edge : edges) {
		if (edge.getValue() < weight) {
			weight = edge.getValue();
			minNeighborId = edge.getSource();
		}
	}
	out.collect(new Tuple2<>(v.getId(), minNeighborId));
}
 
Example 3
Source File: MusicProfiles.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
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));
}
 
Example 4
Source File: ReduceOnEdgesMethodsITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void iterateEdges(Vertex<Long, Long> v,
		Iterable<Edge<Long, Long>> edges, Collector<Tuple2<Long, Long>> out) throws Exception {

	long weight = Long.MIN_VALUE;

	for (Edge<Long, Long> edge : edges) {
		if (edge.getValue() > weight) {
			weight = edge.getValue();
		}
	}
	out.collect(new Tuple2<>(v.getId(), weight));
}
 
Example 5
Source File: ReduceOnEdgesMethodsITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void iterateEdges(Vertex<Long, Long> v,
		Iterable<Edge<Long, Long>> edges, Collector<Tuple2<Long, Long>> out) throws Exception {

	long weight = Long.MAX_VALUE;
	long minNeighborId = 0;

	for (Edge<Long, Long> edge : edges) {
		if (edge.getValue() < weight) {
			weight = edge.getValue();
			minNeighborId = edge.getTarget();
		}
	}
	out.collect(new Tuple2<>(v.getId(), minNeighborId));
}
 
Example 6
Source File: ReduceOnEdgesMethodsITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void iterateEdges(Vertex<Long, Long> v,
		Iterable<Edge<Long, Long>> edges, Collector<Tuple2<Long, Long>> out) throws Exception {

	long weight = Long.MIN_VALUE;

	for (Edge<Long, Long> edge : edges) {
		if (edge.getValue() > weight) {
			weight = edge.getValue();
		}
	}
	out.collect(new Tuple2<>(v.getId(), weight));
}
 
Example 7
Source File: ReduceOnEdgesMethodsITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void iterateEdges(Vertex<Long, Long> v,
		Iterable<Edge<Long, Long>> edges, Collector<Tuple2<Long, Long>> out) throws Exception {

	long weight = Long.MAX_VALUE;
	long minNeighborId = 0;

	for (Edge<Long, Long> edge : edges) {
		if (edge.getValue() < weight) {
			weight = edge.getValue();
			minNeighborId = edge.getSource();
		}
	}
	out.collect(new Tuple2<>(v.getId(), minNeighborId));
}
 
Example 8
Source File: MusicProfiles.java    From flink with Apache License 2.0 5 votes vote down vote up
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));
}
 
Example 9
Source File: ReduceOnEdgesMethodsITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void iterateEdges(Vertex<Long, Long> v,
		Iterable<Edge<Long, Long>> edges, Collector<Tuple2<Long, Long>> out) throws Exception {

	long weight = Long.MAX_VALUE;
	long minNeighborId = 0;

	for (Edge<Long, Long> edge : edges) {
		if (edge.getValue() < weight) {
			weight = edge.getValue();
			minNeighborId = edge.getSource();
		}
	}
	out.collect(new Tuple2<>(v.getId(), minNeighborId));
}
 
Example 10
Source File: ReduceOnEdgesMethodsITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void iterateEdges(Vertex<Long, Long> v,
		Iterable<Edge<Long, Long>> edges, Collector<Tuple2<Long, Long>> out) throws Exception {

	long weight = Long.MIN_VALUE;

	for (Edge<Long, Long> edge : edges) {
		if (edge.getValue() > weight) {
			weight = edge.getValue();
		}
	}
	out.collect(new Tuple2<>(v.getId(), weight));
}
 
Example 11
Source File: ReduceOnEdgesMethodsITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void iterateEdges(Vertex<Long, Long> v,
		Iterable<Edge<Long, Long>> edges, Collector<Tuple2<Long, Long>> out) throws Exception {

	long weight = Long.MAX_VALUE;
	long minNeighborId = 0;

	for (Edge<Long, Long> edge : edges) {
		if (edge.getValue() < weight) {
			weight = edge.getValue();
			minNeighborId = edge.getTarget();
		}
	}
	out.collect(new Tuple2<>(v.getId(), minNeighborId));
}
 
Example 12
Source File: TestFilterEdges.java    From gelly-streaming with Apache License 2.0 4 votes vote down vote up
@Override
public boolean filter(Edge<Long, Long> edge) throws Exception {
    return edge.getValue() > 20;
}
 
Example 13
Source File: TestMapEdges.java    From gelly-streaming with Apache License 2.0 4 votes vote down vote up
@Override
public Long map(Edge<Long, Long> edge) throws Exception {
    return edge.getValue() + 1;
}
 
Example 14
Source File: WindowTriangles.java    From gelly-streaming with Apache License 2.0 4 votes vote down vote up
@Override
public long extractAscendingTimestamp(Edge<Long, Long> element) {
	return element.getValue();
}
 
Example 15
Source File: JoinWithEdgesITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
public Tuple2<Long, Long> map(Edge<Long, Long> edge) throws Exception {
	return new Tuple2<>(edge.getTarget(), edge.getValue());
}
 
Example 16
Source File: JoinWithEdgesITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
public Tuple2<Long, Long> map(Edge<Long, Long> edge) throws Exception {
	return new Tuple2<>(edge.getTarget(), edge.getValue());
}
 
Example 17
Source File: MapEdgesITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
public Long map(Edge<Long, Long> edge) throws Exception {
	return edge.getValue() + 1;
}
 
Example 18
Source File: JoinWithEdgesITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
public Tuple2<Long, Long> map(Edge<Long, Long> edge) throws Exception {
	return new Tuple2<>(edge.getSource(), edge.getValue());
}
 
Example 19
Source File: JoinWithEdgesITCase.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public Tuple2<Long, Long> map(Edge<Long, Long> edge) throws Exception {
	return new Tuple2<>(edge.getSource(), edge.getValue());
}
 
Example 20
Source File: MapEdgesITCase.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public Long map(Edge<Long, Long> edge) throws Exception {
	return edge.getValue() + 1;
}