当前位置: 首页>>代码示例>>Java>>正文


Java MessageScope.Local方法代码示例

本文整理汇总了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)));
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:GiraphMessenger.java

示例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;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:27,代码来源:TinkerMessenger.java

示例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);
    }
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:19,代码来源:VertexMemoryHandler.java

示例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;
    }
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:28,代码来源:TinkerMessenger.java

示例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));
        }
    }
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:10,代码来源:TinkerMessenger.java

示例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));
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:10,代码来源:TinkerMessenger.java

示例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)));
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:12,代码来源:SparkMessenger.java

示例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);
    }
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:29,代码来源:VertexProgramScanJob.java

示例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();
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:8,代码来源:FulgoraUtil.java

示例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;
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:15,代码来源:FulgoraUtil.java

示例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;
   }
 
开发者ID:PureSolTechnologies,项目名称:DuctileDB,代码行数:30,代码来源:DuctileMessenger.java

示例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));
}
   }
 
开发者ID:PureSolTechnologies,项目名称:DuctileDB,代码行数:10,代码来源:DuctileMessenger.java

示例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);
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:6,代码来源:FulgoraUtil.java


注:本文中的org.apache.tinkerpop.gremlin.process.computer.MessageScope.Local方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。