@Override public void sendMessage(final MessageScope messageScope, final M message) { if (messageScope instanceof MessageScope.Local) { final MessageScope.Local<M> localMessageScope = (MessageScope.Local) messageScope; final Traversal.Admin<Vertex, Edge> incidentTraversal = SparkMessenger.setVertexStart(localMessageScope.getIncidentTraversal().get().asAdmin(), this.vertex); final Direction direction = SparkMessenger.getOppositeDirection(incidentTraversal); // handle processing for BOTH given TINKERPOP-1862 where the target of the message is the one opposite // the current vertex incidentTraversal.forEachRemaining(edge -> { if (direction.equals(Direction.IN) || direction.equals(Direction.OUT)) this.outgoingMessages.add(new Tuple2<>(edge.vertices(direction).next().id(), localMessageScope.getEdgeFunction().apply(message, edge))); else this.outgoingMessages.add(new Tuple2<>(edge instanceof StarGraph.StarOutEdge ? edge.inVertex().id() : edge.outVertex().id(), localMessageScope.getEdgeFunction().apply(message, edge))); }); } else { ((MessageScope.Global) messageScope).vertices().forEach(v -> this.outgoingMessages.add(new Tuple2<>(v.id(), message))); } }
public static Global of(final Vertex... vertices) { return new Global(Arrays.asList(vertices)); }
if (!vertex.equals(hostingVertex)) { // if its host is not the current vertex, then send the traverser to the hosting vertex voteToHalt.set(false); // if message is passed, then don't vote to halt messenger.sendMessage(MessageScope.Global.of(hostingVertex), new TraverserSet<>(traverser.detach())); } else {
@Override public void sendMessage(final MessageScope messageScope, final M message) { if (messageScope instanceof MessageScope.Local) { final MessageScope.Local<M> localMessageScope = (MessageScope.Local) messageScope; final Traversal.Admin<Vertex, Edge> incidentTraversal = SparkMessenger.setVertexStart(localMessageScope.getIncidentTraversal().get().asAdmin(), this.vertex); final Direction direction = SparkMessenger.getOppositeDirection(incidentTraversal); // handle processing for BOTH given TINKERPOP-1862 where the target of the message is the one opposite // the current vertex incidentTraversal.forEachRemaining(edge -> { if (direction.equals(Direction.IN) || direction.equals(Direction.OUT)) this.outgoingMessages.add(new Tuple2<>(edge.vertices(direction).next().id(), localMessageScope.getEdgeFunction().apply(message, edge))); else this.outgoingMessages.add(new Tuple2<>(edge instanceof StarGraph.StarOutEdge ? edge.inVertex().id() : edge.outVertex().id(), localMessageScope.getEdgeFunction().apply(message, edge))); }); } else { ((MessageScope.Global) messageScope).vertices().forEach(v -> this.outgoingMessages.add(new Tuple2<>(v.id(), message))); } }
private void processEdges(final Vertex vertex, final Path currentPath, final Number currentDistance, final Messenger<Triplet<Path, Edge, Number>> messenger) { final Traversal.Admin<Vertex, Edge> edgeTraversal = this.edgeTraversal.getPure(); edgeTraversal.addStart(edgeTraversal.getTraverserGenerator().generate(vertex, edgeTraversal.getStartStep(), 1)); while (edgeTraversal.hasNext()) { final Edge edge = edgeTraversal.next(); final Number distance = getDistance(edge); Vertex otherV = edge.inVertex(); if (otherV.equals(vertex)) otherV = edge.outVertex(); // only send message if the adjacent vertex is not yet part of the current path if (!currentPath.objects().contains(otherV)) { messenger.sendMessage(MessageScope.Global.of(otherV), Triplet.with(currentPath, this.includeEdges ? edge : null, NumberHelper.add(currentDistance, distance))); } } }
public static Global of(final Vertex... vertices) { return new Global(Arrays.asList(vertices)); }
public static Global of(final Iterable<Vertex> vertices) { return new Global(vertices); }
@Override public void sendMessage(MessageScope messageScope, M m) { if (messageScope instanceof MessageScope.Local) { vertexMemory.sendMessage(vertexId, m, messageScope); } else { ((MessageScope.Global) messageScope).vertices().forEach(v -> { long vertexId; if (v instanceof TitanVertex) vertexId=((TitanVertex)v).longId(); else vertexId = (Long)v.id(); vertexMemory.sendMessage(vertexMemory.getCanonicalId(vertexId), m, messageScope); }); } }
@Override public void sendMessage(final MessageScope messageScope, final M message) { // this.messageBoard.currentMessageScopes.add(messageScope); if (messageScope instanceof MessageScope.Local) { addMessage(this.vertex, message, messageScope); } else { ((MessageScope.Global) messageScope).vertices().forEach(v -> addMessage(v, message, messageScope)); } }
@Override public void sendMessage(MessageScope messageScope, M message) { messageBoard.addCurrentMessageScope(messageScope); if (messageScope instanceof MessageScope.Local) { addMessage(vertex, message); } else { ((MessageScope.Global) messageScope).vertices().forEach(v -> addMessage(v, message)); } }
@Override public void sendMessage(final MessageScope messageScope, final M message) { // this.messageBoard.currentMessageScopes.add(messageScope); if (messageScope instanceof MessageScope.Local) { addMessage(this.vertex, message, messageScope); } else { ((MessageScope.Global) messageScope).vertices().forEach(v -> addMessage(v, message, messageScope)); } }
if (!vertex.equals(hostingVertex)) { // if its host is not the current vertex, then send the traverser to the hosting vertex voteToHalt.set(false); // if message is passed, then don't vote to halt messenger.sendMessage(MessageScope.Global.of(hostingVertex), new TraverserSet<>(traverser.detach())); } else {
private void processEdges(final Vertex vertex, final Path currentPath, final Number currentDistance, final Messenger<Triplet<Path, Edge, Number>> messenger) { final Traversal.Admin<Vertex, Edge> edgeTraversal = this.edgeTraversal.getPure(); edgeTraversal.addStart(edgeTraversal.getTraverserGenerator().generate(vertex, edgeTraversal.getStartStep(), 1)); while (edgeTraversal.hasNext()) { final Edge edge = edgeTraversal.next(); final Number distance = getDistance(edge); Vertex otherV = edge.inVertex(); if (otherV.equals(vertex)) otherV = edge.outVertex(); // only send message if the adjacent vertex is not yet part of the current path if (!currentPath.objects().contains(otherV)) { messenger.sendMessage(MessageScope.Global.of(otherV), Triplet.with(currentPath, this.includeEdges ? edge : null, NumberHelper.add(currentDistance, distance))); } } }
public static Global of(final Iterable<Vertex> vertices) { return new Global(vertices); }
@Override public void sendMessage(final MessageScope messageScope, final M message) { // this.messageBoard.currentMessageScopes.add(messageScope); if (messageScope instanceof MessageScope.Local) { addMessage(this.vertex, message, messageScope); } else { ((MessageScope.Global) messageScope).vertices().forEach(v -> addMessage(v, message, messageScope)); } }
@Override public void sendMessage(MessageScope messageScope, M m) { if (messageScope instanceof MessageScope.Local) { vertexMemory.sendMessage(vertexId, m, messageScope); } else { ((MessageScope.Global) messageScope).vertices().forEach(v -> { long vertexId; if (v instanceof JanusGraphVertex) vertexId=((JanusGraphVertex)v).longId(); else vertexId = (Long)v.id(); vertexMemory.sendMessage(vertexMemory.getCanonicalId(vertexId), m, messageScope); }); } }
@Override public void sendMessage(MessageScope messageScope, M m) { if (messageScope instanceof MessageScope.Local) { vertexMemory.sendMessage(vertexId, m, messageScope); } else { ((MessageScope.Global) messageScope).vertices().forEach(v -> { long vertexId; if (v instanceof TitanVertex) vertexId=((TitanVertex)v).longId(); else vertexId = (Long)v.id(); vertexMemory.sendMessage(vertexMemory.getCanonicalId(vertexId), m, messageScope); }); } }