本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.computer.MessageScope.Local方法的典型用法代码示例。如果您正苦于以下问题:Java MessageScope.Local方法的具体用法?Java MessageScope.Local怎么用?Java MessageScope.Local使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tinkerpop.gremlin.process.computer.MessageScope
的用法示例。
在下文中一共展示了MessageScope.Local方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendMessage
import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入方法依赖的package包/类
@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 = GiraphMessenger.setVertexStart(localMessageScope.getIncidentTraversal().get().asAdmin(), this.giraphVertex.getValue().get());
final Direction direction = GiraphMessenger.getOppositeDirection(incidentTraversal);
incidentTraversal.forEachRemaining(edge ->
this.giraphComputation.sendMessage(
new ObjectWritable<>(edge.vertices(direction).next().id()),
new ObjectWritable<>(localMessageScope.getEdgeFunction().apply(message, edge))));
} else {
final MessageScope.Global globalMessageScope = (MessageScope.Global) messageScope;
globalMessageScope.vertices().forEach(vertex ->
this.giraphComputation.sendMessage(new ObjectWritable<>(vertex.id()), new ObjectWritable<>(message)));
}
}
示例2: receiveMessages
import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入方法依赖的package包/类
@Override
public Iterator<M> receiveMessages() {
final MultiIterator<M> multiIterator = new MultiIterator<>();
for (final MessageScope messageScope : this.messageBoard.previousMessageScopes) {
if (messageScope instanceof MessageScope.Local) {
final MessageScope.Local<M> localMessageScope = (MessageScope.Local<M>) messageScope;
final Traversal.Admin<Vertex, Edge> incidentTraversal = TinkerMessenger.setVertexStart(localMessageScope.getIncidentTraversal().get().asAdmin(), this.vertex);
final Direction direction = TinkerMessenger.getDirection(incidentTraversal);
final Edge[] edge = new Edge[1]; // simulates storage side-effects available in Gremlin, but not Java8 streams
multiIterator.addIterator(StreamSupport.stream(Spliterators.spliteratorUnknownSize(VertexProgramHelper.reverse(incidentTraversal.asAdmin()), Spliterator.IMMUTABLE | Spliterator.SIZED), false)
.map(e -> this.messageBoard.receiveMessages.get((edge[0] = e).vertices(direction).next()))
.filter(q -> null != q)
.flatMap(Queue::stream)
.map(message -> localMessageScope.getEdgeFunction().apply(message, edge[0]))
.iterator());
} else {
multiIterator.addIterator(Stream.of(this.vertex)
.map(this.messageBoard.receiveMessages::get)
.filter(q -> null != q)
.flatMap(Queue::stream)
.iterator());
}
}
return multiIterator;
}
示例3: receiveMessages
import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入方法依赖的package包/类
public Stream<M> receiveMessages(MessageScope messageScope) {
if (messageScope instanceof MessageScope.Global) {
M message = vertexMemory.getMessage(vertexId,messageScope);
if (message == null) return Stream.empty();
else return Stream.of(message);
} else {
final MessageScope.Local<M> localMessageScope = (MessageScope.Local) messageScope;
final Traversal<Vertex, Edge> reverseIncident = FulgoraUtil.getReverseElementTraversal(localMessageScope,vertex,vertex.tx());
final BiFunction<M,Edge,M> edgeFct = localMessageScope.getEdgeFunction();
return IteratorUtils.stream(reverseIncident)
.map(e -> {
M msg = vertexMemory.getMessage(vertexMemory.getCanonicalId(((TitanEdge) e).otherVertex(vertex).longId()), localMessageScope);
return msg == null ? null : edgeFct.apply(msg, e);
})
.filter(m -> m != null);
}
}
示例4: receiveMessages
import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入方法依赖的package包/类
@Override
public Iterator<M> receiveMessages() {
final MultiIterator<M> multiIterator = new MultiIterator<>();
for (final MessageScope messageScope : this.messageBoard.receiveMessages.keySet()) {
// for (final MessageScope messageScope : this.messageBoard.previousMessageScopes) {
if (messageScope instanceof MessageScope.Local) {
final MessageScope.Local<M> localMessageScope = (MessageScope.Local<M>) messageScope;
final Traversal.Admin<Vertex, Edge> incidentTraversal = TinkerMessenger.setVertexStart(localMessageScope.getIncidentTraversal().get().asAdmin(), this.vertex);
final Direction direction = TinkerMessenger.getDirection(incidentTraversal);
final Edge[] edge = new Edge[1]; // simulates storage side-effects available in Gremlin, but not Java8 streams
multiIterator.addIterator(StreamSupport.stream(Spliterators.spliteratorUnknownSize(VertexProgramHelper.reverse(incidentTraversal.asAdmin()), Spliterator.IMMUTABLE | Spliterator.SIZED), false)
.map(e -> this.messageBoard.receiveMessages.get(messageScope).get((edge[0] = e).vertices(direction).next()))
.filter(q -> null != q)
.flatMap(Queue::stream)
.map(message -> localMessageScope.getEdgeFunction().apply(message, edge[0]))
.iterator());
} else {
multiIterator.addIterator(Stream.of(this.vertex)
.map(this.messageBoard.receiveMessages.get(messageScope)::get)
.filter(q -> null != q)
.flatMap(Queue::stream)
.iterator());
}
}
return multiIterator;
}
示例5: sendMessage
import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入方法依赖的package包/类
@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));
}
}
示例6: sendMessage
import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入方法依赖的package包/类
@Override
public void sendMessage(final MessageScope messageScope, final M message) {
this.messageBoard.currentMessageScopes.add(messageScope);
if (messageScope instanceof MessageScope.Local) {
addMessage(this.vertex, message);
} else {
((MessageScope.Global) messageScope).vertices().forEach(v -> addMessage(v, message));
}
}
示例7: sendMessage
import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入方法依赖的package包/类
@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);
incidentTraversal.forEachRemaining(edge -> this.outgoingMessages.add(new Tuple2<>(edge.vertices(direction).next().id(), message)));
} else {
((MessageScope.Global) messageScope).vertices().forEach(v -> this.outgoingMessages.add(new Tuple2<>(v.id(), message)));
}
}
示例8: process
import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入方法依赖的package包/类
@Override
public void process(TitanVertex vertex, ScanMetrics metrics) {
PreloadedVertex v = (PreloadedVertex)vertex;
long vertexId = v.longId();
VertexMemoryHandler<M> vh = new VertexMemoryHandler(vertexMemory,v);
v.setAccessCheck(PreloadedVertex.OPENSTAR_CHECK);
if (idManager.isPartitionedVertex(vertexId)) {
if (idManager.isCanonicalVertexId(vertexId)) {
EntryList results = v.getFromCache(SYSTEM_PROPS_QUERY);
if (results == null) results = EntryList.EMPTY_LIST;
vertexMemory.setLoadedProperties(vertexId,results);
}
for (MessageScope scope : vertexMemory.getPreviousScopes()) {
if (scope instanceof MessageScope.Local) {
M combinedMsg = null;
for (Iterator<M> msgIter = vh.receiveMessages(scope).iterator(); msgIter.hasNext(); ) {
M msg = msgIter.next();
if (combinedMsg==null) combinedMsg=msg;
else combinedMsg = combiner.combine(combinedMsg,msg);
}
if (combinedMsg!=null) vertexMemory.aggregateMessage(vertexId,combinedMsg,scope);
}
}
} else {
v.setPropertyMixing(vh);
vertexProgram.execute(v, vh, memory);
}
}
示例9: getReverseTitanVertexStep
import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入方法依赖的package包/类
public static TitanVertexStep<Vertex> getReverseTitanVertexStep(final MessageScope.Local<?> scope,
final TitanTransaction graph) {
FulgoraElementTraversal<Vertex,Edge> result = getReverseTraversal(scope,graph,null);
result.asAdmin().applyStrategies();
verifyIncidentTraversal(result);
return (TitanVertexStep)result.getStartStep();
}
示例10: getReverseTraversal
import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入方法依赖的package包/类
private static FulgoraElementTraversal<Vertex,Edge> getReverseTraversal(final MessageScope.Local<?> scope,
final TitanTransaction graph, @Nullable final Vertex start) {
Traversal.Admin<Vertex,Edge> incident = scope.getIncidentTraversal().get().asAdmin();
FulgoraElementTraversal<Vertex,Edge> result = FulgoraElementTraversal.of(graph);
for (Step step : incident.getSteps()) result.addStep(step);
Step<Vertex,?> startStep = result.getStartStep();
assert startStep instanceof VertexStep;
((VertexStep) startStep).reverseDirection();
if (start!=null) result.addStep(0, new StartStep<>(incident, start));
result.asAdmin().setStrategies(FULGORA_STRATEGIES);
return result;
}
示例11: receiveMessages
import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入方法依赖的package包/类
@Override
public Iterator<M> receiveMessages() {
MultiIterator<M> multiIterator = new MultiIterator<>();
for (MessageScope messageScope : messageBoard.getPreviousMessageScopes()) {
if (messageScope instanceof MessageScope.Local) {
@SuppressWarnings("unchecked")
MessageScope.Local<M> localMessageScope = (MessageScope.Local<M>) messageScope;
Traversal.Admin<Vertex, Edge> incidentTraversal = DuctileMessenger
.setVertexStart(localMessageScope.getIncidentTraversal().get().asAdmin(), vertex);
Direction direction = DuctileMessenger.getDirection(incidentTraversal);
Edge[] edge = new Edge[1];
multiIterator.addIterator(//
StreamSupport
//
.stream(Spliterators.spliteratorUnknownSize(
VertexProgramHelper.reverse(incidentTraversal.asAdmin()),
Spliterator.IMMUTABLE | Spliterator.SIZED), false)//
.map(e -> messageBoard.getReceiveMessage((edge[0] = e).vertices(direction).next()))//
.filter(q -> null != q)//
.flatMap(Queue::stream)//
.map(message -> localMessageScope.getEdgeFunction().apply(message, edge[0]))
.iterator());
} else {
multiIterator.addIterator(Stream.of(vertex).map(messageBoard.getReceiveMessages()::get)
.filter(q -> null != q).flatMap(Queue::stream).iterator());
}
}
return multiIterator;
}
示例12: sendMessage
import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入方法依赖的package包/类
@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));
}
}
示例13: getReverseElementTraversal
import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入方法依赖的package包/类
public static Traversal<Vertex,Edge> getReverseElementTraversal(final MessageScope.Local<?> scope,
final Vertex start,
final TitanTransaction graph) {
return getReverseTraversal(scope,graph,start);
}