@Override public void coGroup(Iterable<Tuple2<K, Message>> messages, Iterable<Vertex<K, VV>> vertex, Collector<Vertex<K, VV>> out) throws Exception { final Iterator<Vertex<K, VV>> vertexIter = vertex.iterator(); if (vertexIter.hasNext()) { Vertex<K, VV> vertexState = vertexIter.next(); @SuppressWarnings("unchecked") Iterator<Tuple2<?, Message>> downcastIter = (Iterator<Tuple2<?, Message>>) (Iterator<?>) messages.iterator(); messageIter.setSource(downcastIter); gatherFunction.setOutput(vertexState, out); gatherFunction.updateVertex(vertexState, messageIter); } else { final Iterator<Tuple2<K, Message>> messageIter = messages.iterator(); if (messageIter.hasNext()) { String message = "Target vertex does not exist!."; try { Tuple2<K, Message> next = messageIter.next(); message = "Target vertex '" + next.f0 + "' does not exist!."; } catch (Throwable ignored) {} throw new Exception(message); } else { throw new Exception(); } } } }
/** * In order to hide the Tuple3(actualValue, inDegree, OutDegree) vertex value from the user, * another function will be called from {@link org.apache.flink.graph.spargel.ScatterGatherIteration}. * * <p>This function will retrieve the vertex from the vertexState and will set its degrees, afterwards calling * the regular updateVertex function. * * @param vertexState * @param inMessages * @throws Exception */ @SuppressWarnings("unchecked") <VertexWithDegree> void updateVertexFromScatterGatherIteration(Vertex<K, VertexWithDegree> vertexState, MessageIterator<Message> inMessages) throws Exception { Vertex<K, VV> vertex = new Vertex<>(vertexState.f0, ((Tuple3<VV, Long, Long>) vertexState.getValue()).f0); updateVertex(vertex, inMessages); } }
@Override public void coGroup(Iterable<Tuple2<K, Message>> messages, Iterable<Vertex<K, VV>> vertex, Collector<Vertex<K, VV>> out) throws Exception { final Iterator<Vertex<K, VV>> vertexIter = vertex.iterator(); if (vertexIter.hasNext()) { Vertex<K, VV> vertexState = vertexIter.next(); @SuppressWarnings("unchecked") Iterator<Tuple2<?, Message>> downcastIter = (Iterator<Tuple2<?, Message>>) (Iterator<?>) messages.iterator(); messageIter.setSource(downcastIter); gatherFunction.setOutput(vertexState, out); gatherFunction.updateVertex(vertexState, messageIter); } else { final Iterator<Tuple2<K, Message>> messageIter = messages.iterator(); if (messageIter.hasNext()) { String message = "Target vertex does not exist!."; try { Tuple2<K, Message> next = messageIter.next(); message = "Target vertex '" + next.f0 + "' does not exist!."; } catch (Throwable ignored) {} throw new Exception(message); } else { throw new Exception(); } } } }
@Override public void coGroup(Iterable<Tuple2<K, Message>> messages, Iterable<Vertex<K, VV>> vertex, Collector<Vertex<K, VV>> out) throws Exception { final Iterator<Vertex<K, VV>> vertexIter = vertex.iterator(); if (vertexIter.hasNext()) { Vertex<K, VV> vertexState = vertexIter.next(); @SuppressWarnings("unchecked") Iterator<Tuple2<?, Message>> downcastIter = (Iterator<Tuple2<?, Message>>) (Iterator<?>) messages.iterator(); messageIter.setSource(downcastIter); gatherFunction.setOutput(vertexState, out); gatherFunction.updateVertex(vertexState, messageIter); } else { final Iterator<Tuple2<K, Message>> messageIter = messages.iterator(); if (messageIter.hasNext()) { String message = "Target vertex does not exist!."; try { Tuple2<K, Message> next = messageIter.next(); message = "Target vertex '" + next.f0 + "' does not exist!."; } catch (Throwable ignored) {} throw new Exception(message); } else { throw new Exception(); } } } }
@Override public void coGroup(Iterable<Tuple2<K, Message>> messages, Iterable<Vertex<K, VV>> vertex, Collector<Vertex<K, VV>> out) throws Exception { final Iterator<Vertex<K, VV>> vertexIter = vertex.iterator(); if (vertexIter.hasNext()) { Vertex<K, VV> vertexState = vertexIter.next(); @SuppressWarnings("unchecked") Iterator<Tuple2<?, Message>> downcastIter = (Iterator<Tuple2<?, Message>>) (Iterator<?>) messages.iterator(); messageIter.setSource(downcastIter); gatherFunction.setOutput(vertexState, out); gatherFunction.updateVertex(vertexState, messageIter); } else { final Iterator<Tuple2<K, Message>> messageIter = messages.iterator(); if (messageIter.hasNext()) { String message = "Target vertex does not exist!."; try { Tuple2<K, Message> next = messageIter.next(); message = "Target vertex '" + next.f0 + "' does not exist!."; } catch (Throwable ignored) {} throw new Exception(message); } else { throw new Exception(); } } } }
/** * In order to hide the Tuple3(actualValue, inDegree, OutDegree) vertex value from the user, * another function will be called from {@link org.apache.flink.graph.spargel.ScatterGatherIteration}. * * <p>This function will retrieve the vertex from the vertexState and will set its degrees, afterwards calling * the regular updateVertex function. * * @param vertexState * @param inMessages * @throws Exception */ @SuppressWarnings("unchecked") <VertexWithDegree> void updateVertexFromScatterGatherIteration(Vertex<K, VertexWithDegree> vertexState, MessageIterator<Message> inMessages) throws Exception { Vertex<K, VV> vertex = new Vertex<>(vertexState.f0, ((Tuple3<VV, Long, Long>) vertexState.getValue()).f0); updateVertex(vertex, inMessages); } }
/** * In order to hide the Tuple3(actualValue, inDegree, OutDegree) vertex value from the user, * another function will be called from {@link org.apache.flink.graph.spargel.ScatterGatherIteration}. * * This function will retrieve the vertex from the vertexState and will set its degrees, afterwards calling * the regular updateVertex function. * * @param vertexState * @param inMessages * @throws Exception */ @SuppressWarnings("unchecked") <VertexWithDegree> void updateVertexFromScatterGatherIteration(Vertex<K, VertexWithDegree> vertexState, MessageIterator<Message> inMessages) throws Exception { Vertex<K, VV> vertex = new Vertex<>(vertexState.f0, ((Tuple3<VV, Long, Long>) vertexState.getValue()).f0); updateVertex(vertex, inMessages); } }
/** * In order to hide the Tuple3(actualValue, inDegree, OutDegree) vertex value from the user, * another function will be called from {@link org.apache.flink.graph.spargel.ScatterGatherIteration}. * * <p>This function will retrieve the vertex from the vertexState and will set its degrees, afterwards calling * the regular updateVertex function. * * @param vertexState * @param inMessages * @throws Exception */ @SuppressWarnings("unchecked") <VertexWithDegree> void updateVertexFromScatterGatherIteration(Vertex<K, VertexWithDegree> vertexState, MessageIterator<Message> inMessages) throws Exception { Vertex<K, VV> vertex = new Vertex<>(vertexState.f0, ((Tuple3<VV, Long, Long>) vertexState.getValue()).f0); updateVertex(vertex, inMessages); } }