本文整理汇总了Java中org.apache.giraph.edge.EdgeFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Java EdgeFactory.create方法的具体用法?Java EdgeFactory.create怎么用?Java EdgeFactory.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.giraph.edge.EdgeFactory
的用法示例。
在下文中一共展示了EdgeFactory.create方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurrentEdge
import org.apache.giraph.edge.EdgeFactory; //导入方法依赖的package包/类
@Override
public Edge<LongWritable, DoubleWritable> getCurrentEdge()
throws IOException, InterruptedException {
LongWritable destVertexId = new LongWritable();
do {
destVertexId.set(localEdgesHelper.generateDestVertex(
currentVertexId.get(), random));
} while (currentVertexDestVertices.contains(destVertexId));
++currentOutEdgesRead;
currentVertexDestVertices.add(destVertexId);
if (LOG.isTraceEnabled()) {
LOG.trace("getCurrentEdge: Return edge (" + currentVertexId + ", " +
"" + destVertexId + ")");
}
return EdgeFactory.create(
destVertexId,
new DoubleWritable(random.nextDouble()));
}
示例2: LongWritable
import org.apache.giraph.edge.EdgeFactory; //导入方法依赖的package包/类
/**
* Transforms a GoraObject into an Edge object.
* @param goraObject Object from Gora to be translated.
* @return Edge Result from transforming the gora object.
*/
@Override
protected Edge<LongWritable, FloatWritable> transformEdge
(Object goraObject) {
Edge<LongWritable, FloatWritable> edge = null;
GEdge goraEdge = (GEdge) goraObject;
Long dest;
Long value;
dest = Long.valueOf(goraEdge.getVertexOutId().toString());
this.sourceId = new LongWritable();
this.sourceId.set(Long.valueOf(goraEdge.getVertexInId().toString()));
value = (long) goraEdge.getEdgeWeight();
edge = EdgeFactory.create(new LongWritable(dest),
new FloatWritable(value));
return edge;
}
示例3: getCurrentEdge
import org.apache.giraph.edge.EdgeFactory; //导入方法依赖的package包/类
@Override
public Edge<Text, RyaStatementWritable> getCurrentEdge() throws IOException, InterruptedException {
RyaStatementWritable currentStatement = reader.getCurrentValue();
RyaStatement ryaStatement = currentStatement.getRyaStatement();
Edge<Text, RyaStatementWritable> edge = EdgeFactory.create(new Text(ryaStatement.toString()),
currentStatement);
return edge;
}
示例4: getCurrentVertex
import org.apache.giraph.edge.EdgeFactory; //导入方法依赖的package包/类
@Override
public Vertex<Text, RyaTypeWritable, RyaStatementWritable> getCurrentVertex() throws IOException, InterruptedException {
RyaStatementWritable currentStatement = reader.getCurrentValue();
RyaStatement ryaStatement = currentStatement.getRyaStatement();
RyaTypeWritable vertexWritable = new RyaTypeWritable();
vertexWritable.setRyaType(ryaStatement.getSubject());
Text vertexId = new Text(ryaStatement.getSubject().getData());
Vertex<Text, RyaTypeWritable, RyaStatementWritable> vertex = classesConfiguration.createVertex();
Edge<Text, RyaStatementWritable> edge = EdgeFactory.create(new Text(ryaStatement.toString()),
currentStatement);
List<Edge<Text, RyaStatementWritable>> edges = new ArrayList<Edge<Text, RyaStatementWritable>>();
edges.add(edge);
vertex.initialize(vertexId, vertexWritable, edges);
return vertex;
}
示例5: createEdge
import org.apache.giraph.edge.EdgeFactory; //导入方法依赖的package包/类
/**
* Create a user edge.
*
* @return Instantiated user edge.
*/
public Edge<I, E> createEdge() {
if (isEdgeValueNullWritable()) {
return (Edge<I, E>) EdgeFactory.create(createVertexId());
} else {
return EdgeFactory.create(createVertexId(), createEdgeValue());
}
}
示例6: getCurrentEdge
import org.apache.giraph.edge.EdgeFactory; //导入方法依赖的package包/类
@Override
public final Edge<I, E> getCurrentEdge() throws IOException,
InterruptedException {
Text line = getRecordReader().getCurrentValue();
I targetVertexId = getTargetVertexId(line);
E edgeValue = getValue(line);
return EdgeFactory.create(targetVertexId, edgeValue);
}
示例7: nextEdge
import org.apache.giraph.edge.EdgeFactory; //导入方法依赖的package包/类
@Override
public boolean nextEdge() throws IOException, InterruptedException {
boolean result = true;
if (haveReverseEdge) {
result = baseReader.nextEdge();
haveReverseEdge = false;
} else {
Edge<I, E> currentEdge = baseReader.getCurrentEdge();
reverseSourceId = currentEdge.getTargetVertexId();
reverseEdge = EdgeFactory.create(baseReader.getCurrentSourceId(),
currentEdge.getValue());
haveReverseEdge = true;
}
return result;
}
示例8: getCurrentEdge
import org.apache.giraph.edge.EdgeFactory; //导入方法依赖的package包/类
@Override
public Edge<ObjectWritable, EdgeValueWritable> getCurrentEdge()
throws IOException, InterruptedException {
return EdgeFactory.create(getCurrentTargetId(), new EdgeValueWritable(getCurrentHBaseEdge()));
}
示例9: decodeEdge
import org.apache.giraph.edge.EdgeFactory; //导入方法依赖的package包/类
@Override
public Edge<Text, DoubleWritable> decodeEdge(String s1, String s2) {
return EdgeFactory.create(new Text(s1),
new DoubleWritable(Double.valueOf(s2)));
}
示例10: compute
import org.apache.giraph.edge.EdgeFactory; //导入方法依赖的package包/类
@Override
public void compute(Iterable<VerifiableMessage> messages) {
String sumAggregatorName = LongSumAggregator.class.getName();
if (getSuperstep() > SUPERSTEPS) {
voteToHalt();
return;
}
if (LOG.isDebugEnabled()) {
LOG.debug("compute: " + getAggregatedValue(sumAggregatorName));
}
aggregate(sumAggregatorName, new LongWritable(getId().get()));
if (LOG.isDebugEnabled()) {
LOG.debug("compute: sum = " +
this.<LongWritable>getAggregatedValue(sumAggregatorName).get() +
" for vertex " + getId());
}
float msgValue = 0.0f;
for (VerifiableMessage message : messages) {
msgValue += message.value;
if (LOG.isDebugEnabled()) {
LOG.debug("compute: got msg = " + message +
" for vertex id " + getId() +
", vertex value " + getValue() +
" on superstep " + getSuperstep());
}
if (message.superstep != getSuperstep() - 1) {
throw new IllegalStateException(
"compute: Impossible to not get a messsage from " +
"the previous superstep, current superstep = " +
getSuperstep());
}
if ((message.sourceVertexId != getId().get() - 1) &&
(getId().get() != 0)) {
throw new IllegalStateException(
"compute: Impossible that this message didn't come " +
"from the previous vertex and came from " +
message.sourceVertexId);
}
}
int vertexValue = getValue().get();
setValue(new IntWritable(vertexValue + (int) msgValue));
if (LOG.isDebugEnabled()) {
LOG.debug("compute: vertex " + getId() +
" has value " + getValue() +
" on superstep " + getSuperstep());
}
for (Edge<LongWritable, FloatWritable> edge : getEdges()) {
FloatWritable newEdgeValue = new FloatWritable(
edge.getValue().get() + (float) vertexValue);
Edge<LongWritable, FloatWritable> newEdge =
EdgeFactory.create(edge.getTargetVertexId(), newEdgeValue);
if (LOG.isDebugEnabled()) {
LOG.debug("compute: vertex " + getId() +
" sending edgeValue " + edge.getValue() +
" vertexValue " + vertexValue +
" total " + newEdgeValue +
" to vertex " + edge.getTargetVertexId() +
" on superstep " + getSuperstep());
}
addEdge(newEdge);
sendMessage(edge.getTargetVertexId(),
new VerifiableMessage(
getSuperstep(), getId().get(), newEdgeValue.get()));
}
}
示例11: decodeEdge
import org.apache.giraph.edge.EdgeFactory; //导入方法依赖的package包/类
@Override
public Edge<LongWritable, DoubleWritable> decodeEdge(String s1, String s2) {
return EdgeFactory.create(new LongWritable(Long.valueOf(s1)),
new DoubleWritable(Double.valueOf(s2)));
}
示例12: getCurrentEdge
import org.apache.giraph.edge.EdgeFactory; //导入方法依赖的package包/类
@Override
public Edge<I, NullWritable> getCurrentEdge() throws IOException,
InterruptedException {
HCatRecord record = getRecordReader().getCurrentValue();
return EdgeFactory.create(getTargetVertexId(record));
}
示例13: compute
import org.apache.giraph.edge.EdgeFactory; //导入方法依赖的package包/类
@Override
public void compute(Iterable<FloatWritable> messages) {
SimpleCheckpointVertexWorkerContext workerContext =
(SimpleCheckpointVertexWorkerContext) getWorkerContext();
boolean enableFault = workerContext.getEnableFault();
int supersteps = workerContext.getSupersteps();
if (enableFault && (getSuperstep() == FAULTING_SUPERSTEP) &&
(getContext().getTaskAttemptID().getId() == 0) &&
(getId().get() == FAULTING_VERTEX_ID)) {
LOG.info("compute: Forced a fault on the first " +
"attempt of superstep " +
FAULTING_SUPERSTEP + " and vertex id " +
FAULTING_VERTEX_ID);
System.exit(-1);
}
if (getSuperstep() > supersteps) {
voteToHalt();
return;
}
long sumAgg = this.<LongWritable>getAggregatedValue(
LongSumAggregator.class.getName()).get();
LOG.info("compute: " + sumAgg);
aggregate(LongSumAggregator.class.getName(),
new LongWritable(getId().get()));
LOG.info("compute: sum = " + sumAgg +
" for vertex " + getId());
float msgValue = 0.0f;
for (FloatWritable message : messages) {
float curMsgValue = message.get();
msgValue += curMsgValue;
LOG.info("compute: got msgValue = " + curMsgValue +
" for vertex " + getId() +
" on superstep " + getSuperstep());
}
int vertexValue = getValue().get();
setValue(new IntWritable(vertexValue + (int) msgValue));
LOG.info("compute: vertex " + getId() +
" has value " + getValue() +
" on superstep " + getSuperstep());
for (Edge<LongWritable, FloatWritable> edge : getEdges()) {
FloatWritable newEdgeValue = new FloatWritable(edge.getValue().get() +
(float) vertexValue);
Edge<LongWritable, FloatWritable> newEdge =
EdgeFactory.create(edge.getTargetVertexId(), newEdgeValue);
LOG.info("compute: vertex " + getId() +
" sending edgeValue " + edge.getValue() +
" vertexValue " + vertexValue +
" total " + newEdgeValue +
" to vertex " + edge.getTargetVertexId() +
" on superstep " + getSuperstep());
addEdge(newEdge);
sendMessage(edge.getTargetVertexId(), newEdgeValue);
}
}