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; }
/** * 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); } }
public Vertex<K, VV> getSrcVertex() { return new Vertex<>(this.f0, this.f2); }
@Override public Long map(Vertex<K, Tuple2<Long, Double>> vertex) throws Exception { return vertex.getValue().f0; } }
public Tuple2<K, Either<NullValue, Message>> map(Vertex<K, VV> vertex) { outTuple.f0 = vertex.getId(); return outTuple; } }
/** * Constructor. */ public VertexToGellyVertexWithNullValue() { reuseVertex = new org.apache.flink.graph.Vertex<>(); reuseVertex.setValue(NullValue.getInstance()); }
/** * Sets the new value of this vertex. Setting a new value triggers the sending of outgoing messages from this vertex. * * <p>This should be called at most once per updateVertex. * * @param newValue The new vertex value. */ public void setNewVertexValue(VV newValue) { if (setNewVertexValueCalled) { throw new IllegalStateException("setNewVertexValue should only be called at most once per updateVertex"); } setNewVertexValueCalled = true; if (isOptDegrees()) { outValWithDegrees.f1.f0 = newValue; outWithDegrees.collect(outValWithDegrees); } else { outVal.setValue(newValue); out.collect(outVal); } }
@Override public org.apache.flink.graph.Vertex<GradoopId, NullValue> map(Vertex epgmVertex) { reuseVertex.setId(epgmVertex.getId()); return reuseVertex; } }
public Vertex<K, VV> getTrgVertex() { return new Vertex<>(this.f1, this.f3); }
@Override public Tuple3<Long, Long, Double> map(Triplet<Long, Point, Double> triplet) throws Exception { Vertex<Long, Point> srcVertex = triplet.getSrcVertex(); Vertex<Long, Point> trgVertex = triplet.getTrgVertex(); return new Tuple3<>(srcVertex.getId(), trgVertex.getId(), srcVertex.getValue().euclideanDistance(trgVertex.getValue())); } });
@Override public void sendMessages(Vertex<K, VV> vertex) throws Exception { // send current minimum to neighbors sendMessageToAllNeighbors(vertex.getValue()); }
@Override public void coGroup(Iterable<Edge<K, EV>> edges, Iterable<Vertex<K, VV>> state, Collector<Tuple2<K, Message>> out) throws Exception { final Iterator<Vertex<K, VV>> stateIter = state.iterator(); if (stateIter.hasNext()) { Vertex<K, VV> newVertexState = stateIter.next(); scatterFunction.set(edges.iterator(), out, newVertexState.getId()); scatterFunction.sendMessages(newVertexState); } } }
/** * Constructor. */ public VertexToGellyVertexWithNullValue() { reuseVertex = new org.apache.flink.graph.Vertex<>(); reuseVertex.setValue(NullValue.getInstance()); }
/** * Sets the new value of this vertex. Setting a new value triggers the sending of outgoing messages from this vertex. * * This should be called at most once per updateVertex. * * @param newValue The new vertex value. */ public void setNewVertexValue(VV newValue) { if(setNewVertexValueCalled) { throw new IllegalStateException("setNewVertexValue should only be called at most once per updateVertex"); } setNewVertexValueCalled = true; if(isOptDegrees()) { outValWithDegrees.f1.f0 = newValue; outWithDegrees.collect(outValWithDegrees); } else { outVal.setValue(newValue); out.collect(outVal); } }
@Override public org.apache.flink.graph.Vertex<GradoopId, NullValue> map(Vertex epgmVertex) { reuseVertex.setId(epgmVertex.getId()); return reuseVertex; } }