当前位置: 首页>>代码示例>>Java>>正文


Java Vertex.getValue方法代码示例

本文整理汇总了Java中org.apache.flink.graph.Vertex.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Vertex.getValue方法的具体用法?Java Vertex.getValue怎么用?Java Vertex.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.flink.graph.Vertex的用法示例。


在下文中一共展示了Vertex.getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compute

import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@Override
public void compute(Vertex<K, Double> vertex, MessageIterator<NewMinDistance> messageIterator) throws Exception {
    // Send initial group of messages from the source vertex
    if (vertex.getId().equals(sourceVertex) && getSuperstepNumber() == 1) {
        sendNewDistanceToAll(0);
    }

    // Calculate new min distance from source node
    double minDistance = minDistance(messageIterator);

    // Send new min distance to neighbour vertices if new min distance is less
    if (minDistance < vertex.getValue()) {
        setNewVertexValue(minDistance);
        sendNewDistanceToAll(minDistance);
    }
}
 
开发者ID:mushketyk,项目名称:flink-examples,代码行数:17,代码来源:PregelShortestPath.java

示例2: reduce

import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@Override
public void reduce(Iterable<Vertex<K, VV>> values, Collector<VertexGroupItem<K, VV>> out) throws Exception {
	K vertexGroupRepresentativeID = null;
	long vertexGroupCount = 0L;
	VV vertexGroupValue = null;
	boolean isFirstElement = true;

	for (Vertex<K, VV> vertex : values) {
		if (isFirstElement) {
			// take final group representative vertex id from first tuple
			vertexGroupRepresentativeID = vertex.getId();
			vertexGroupValue = vertex.getValue();
			isFirstElement = false;
		}
		// no need to set group value for those tuples
		reuseVertexGroupItem.setVertexId(vertex.getId());
		reuseVertexGroupItem.setGroupRepresentativeId(vertexGroupRepresentativeID);
		out.collect(reuseVertexGroupItem);
		vertexGroupCount++;
	}

	createGroupRepresentativeTuple(vertexGroupRepresentativeID, vertexGroupValue, vertexGroupCount);
	out.collect(reuseVertexGroupItem);
	reuseVertexGroupItem.reset();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:26,代码来源:Summarization.java

示例3: updateVertex

import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@Override
public void updateVertex(Vertex<K, Double> vertex,
		MessageIterator<Double> inMessages) {

	Double minDistance = Double.MAX_VALUE;

	for (double msg : inMessages) {
		if (msg < minDistance) {
			minDistance = msg;
		}
	}

	if (vertex.getValue() > minDistance) {
		setNewVertexValue(minDistance);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:SingleSourceShortestPaths.java

示例4: map

import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
public String map(Vertex<Long, Long> vertex) throws Exception {
	String stringValue;
	if (vertex.getValue() == 1) {
		stringValue = "one";
	} else if (vertex.getValue() == 2) {
		stringValue = "two";
	} else if (vertex.getValue() == 3) {
		stringValue = "three";
	} else if (vertex.getValue() == 4) {
		stringValue = "four";
	} else if (vertex.getValue() == 5) {
		stringValue = "five";
	} else {
		stringValue = "";
	}
	return stringValue;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:MapVerticesITCase.java

示例5: compute

import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@Override
public void compute(Vertex<String, Double> vertex, MessageIterator<Double> messages) throws Exception {
	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<String, Double> e : getEdges()) {
			sendMessageTo(e.getTarget(), minDistance + e.getValue());
		}
	}

}
 
开发者ID:PacktPublishing,项目名称:Mastering-Apache-Flink,代码行数:16,代码来源:BatchJob.java

示例6: sendMessages

import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@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());
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:9,代码来源:SingleSourceShortestPaths.java

示例7: updateVertex

import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@Override
public void updateVertex(Vertex<Long, Double> vertex, MessageIterator<Double> inMessages) {

	Double minDistance = Double.MAX_VALUE;

	for (double msg : inMessages) {
		if (msg < minDistance) {
			minDistance = msg;
		}
	}

	if (vertex.getValue() > minDistance) {
		setNewVertexValue(minDistance);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:16,代码来源:SingleSourceShortestPaths.java

示例8: compute

import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
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());
				}
			}
		}
 
开发者ID:axbaretto,项目名称:flink,代码行数:16,代码来源:PregelSSSP.java

示例9: Projection

import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
public Projection(
		Vertex<KC, VVC> connectingVertex,
		VV sourceVertexValue, VV targetVertexValue,
		EV sourceEdgeValue, EV targetEdgeValue) {
	this.f0 = connectingVertex.getId();
	this.f1 = connectingVertex.getValue();
	this.f2 = sourceVertexValue;
	this.f3 = targetVertexValue;
	this.f4 = sourceEdgeValue;
	this.f5 = targetEdgeValue;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:12,代码来源:Projection.java

示例10: updateVertex

import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@Override
public void updateVertex(Vertex<K, VV> vertex, MessageIterator<VV> messages) throws Exception {
	VV current = vertex.getValue();
	VV min = current;

	for (VV msg : messages) {
		if (msg.compareTo(min) < 0) {
			min = msg;
		}
	}

	if (!min.equals(current)) {
		setNewVertexValue(min);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:16,代码来源:ConnectedComponents.java

示例11: updateVertex

import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
public void updateVertex(Vertex<K, VV> vertex, MessageIterator<VV> inMessages) {
	Map<VV, Long> labelsWithFrequencies = new HashMap<>();

	long maxFrequency = 1;
	VV mostFrequentLabel = vertex.getValue();

	// store the labels with their frequencies
	for (VV msg : inMessages) {
		if (labelsWithFrequencies.containsKey(msg)) {
			long currentFreq = labelsWithFrequencies.get(msg);
			labelsWithFrequencies.put(msg, currentFreq + 1);
		} else {
			labelsWithFrequencies.put(msg, 1L);
		}
	}
	// select the most frequent label: if two or more labels have the
	// same frequency, the node adopts the label with the highest value
	for (Entry<VV, Long> entry : labelsWithFrequencies.entrySet()) {
		if (entry.getValue() == maxFrequency) {
			// check the label value to break ties
			if (entry.getKey().compareTo(mostFrequentLabel) > 0) {
				mostFrequentLabel = entry.getKey();
			}
		} else if (entry.getValue() > maxFrequency) {
			maxFrequency = entry.getValue();
			mostFrequentLabel = entry.getKey();
		}
	}
	setNewVertexValue(mostFrequentLabel);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:31,代码来源:LabelPropagation.java

示例12: sendMessages

import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@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());
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:9,代码来源:SingleSourceShortestPaths.java

示例13: compute

import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@Override
public void compute(Vertex<Long, Long> vertex, MessageIterator<Long> messages) throws Exception {
	long currentComponent = vertex.getValue();

	for (Long msg : messages) {
		currentComponent = Math.min(currentComponent, msg);
	}

	if ((getSuperstepNumber() == 1) || (currentComponent < vertex.getValue())) {
		setNewVertexValue(currentComponent);
		for (Edge<Long, NullValue> edge : getEdges()) {
			sendMessageTo(edge.getTarget(), currentComponent);
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:16,代码来源:PregelCompilerTest.java

示例14: iterateEdges

import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@Override
public void iterateEdges(Vertex<Long, Long> v, Iterable<Edge<Long, Long>> edges,
		Collector<Tuple2<Long, Long>> out) throws Exception {
	for (Edge<Long, Long> edge : edges) {
		if (v.getValue() > 4) {
			if (v.getId().equals(edge.getTarget())) {
				out.collect(new Tuple2<>(v.getId(), edge.getSource()));
			} else {
				out.collect(new Tuple2<>(v.getId(), edge.getTarget()));
			}
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:14,代码来源:ReduceOnEdgesWithExceptionITCase.java

示例15: iterateEdges

import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@Override
public void iterateEdges(Vertex<Long, Long> v, Iterable<Edge<Long, Long>> edges,
		Collector<Tuple2<Long, Long>> out) throws Exception {

	for (Edge<Long, Long> edge : edges) {
		if (v.getValue() > 2) {
			out.collect(new Tuple2<>(v.getId(), edge.getTarget()));
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:11,代码来源:ReduceOnEdgesMethodsITCase.java


注:本文中的org.apache.flink.graph.Vertex.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。