@Override public void trigger(ChainReduceVertex vertex) throws IOException { VertexMethod<String> m = methodFromConfig(vertex, findParentMethodKey, String.class); String derivedParent = m.calculate(vertex); Text msg = new Text("FIND_NEXT " + vertex.getId().toString()); vertex.sendMessage(new Text(derivedParent), msg); }
@Override public void handle(ChainReduceVertex vertex, String[] params) throws IOException { final Text parentForwardLabel = textFromConfig(vertex, parentForwardLabelKey); final Text parentReverseLabel = textFromConfig(vertex, parentReverseLabelKey); final Text nextCandidateLabel = textFromConfig(vertex, nextCandidateLabelKey); final Text prevCandidateLabel = textFromConfig(vertex, prevCandidateLabelKey); final Text src = new Text(params[1]); Text pTargetId = findEdgeByValue(vertex, parentForwardLabel); if (pTargetId != null) { Text candidate = methodFromConfig(vertex, deriveEquivalentVertexKey, Text.class) .calculate(vertex, src, pTargetId); vertex.addEdgeRequest(src, new Edge<Text, Text>(candidate, nextCandidateLabel)); vertex.addEdgeRequest(candidate, new Edge<Text, Text>(src, prevCandidateLabel)); nudge(vertex, new Text(candidate)); } else { vertex.addEdgeRequest(src, new Edge<Text, Text>(DUMMY_VERTEX, nextCandidateLabel)); } Text rTargetId = findEdgeByValue(vertex, parentReverseLabel); if (rTargetId != null) { Text candidate = methodFromConfig(vertex, deriveEquivalentVertexKey, Text.class) .calculate(vertex, src, rTargetId); vertex.addEdgeRequest(src, new Edge<Text, Text>(candidate, prevCandidateLabel)); vertex.addEdgeRequest(candidate, new Edge<Text, Text>(src, nextCandidateLabel)); nudge(vertex, new Text(candidate)); } else { vertex.addEdgeRequest(src, new Edge<Text, Text>(DUMMY_VERTEX, prevCandidateLabel)); } nudge(vertex, new Text(src)); }
void nudge(ChainReduceVertex vertex, Text target) { if (target != null) { vertex.sendMessage(target, new Text("_")); } }