• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MessageScope类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.computer.MessageScope的典型用法代码示例。如果您正苦于以下问题:Java MessageScope类的具体用法?Java MessageScope怎么用?Java MessageScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MessageScope类属于org.apache.tinkerpop.gremlin.process.computer包,在下文中一共展示了MessageScope类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: addMessage

import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入依赖的package包/类
public synchronized void addMessage(M message, MessageScope scope, Map<MessageScope,Integer> scopeMap,
                                    MessageCombiner<M> combiner) {
    assert message!=null && scope!=null && combiner!=null;
    Preconditions.checkArgument(scopeMap.containsKey(scope),"Provided scope was not declared in the VertexProgram: %s",scope);
    assert scopeMap.containsKey(scope);
    initializeCurrentMessages(scopeMap);
    if (scopeMap.size()==1) {
        if (currentMessages==null) currentMessages = message;
        else currentMessages = combiner.combine(message,(M)currentMessages);
    } else {
        int pos = scopeMap.get(scope);
        Object[] msgs =  (Object[])currentMessages;
        if (msgs[pos]==null) msgs[pos]=message;
        else msgs[pos] = combiner.combine(message,(M)msgs[pos]);
    }
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:17,代码来源:VertexState.java


示例5: loadState

import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入依赖的package包/类
@Override
public void loadState(final Graph graph, final Configuration configuration) {
    if (configuration.containsKey(INITIAL_RANK_TRAVERSAL))
        this.initialRankTraversal = PureTraversal.loadState(configuration, INITIAL_RANK_TRAVERSAL, graph);
    if (configuration.containsKey(EDGE_TRAVERSAL)) {
        this.edgeTraversal = PureTraversal.loadState(configuration, EDGE_TRAVERSAL, graph);
        this.incidentMessageScope = MessageScope.Local.of(() -> this.edgeTraversal.get().clone());
        this.countMessageScope = MessageScope.Local.of(new MessageScope.Local.ReverseTraversalSupplier(this.incidentMessageScope));
    }
    this.alpha = configuration.getDouble(ALPHA, this.alpha);
    this.epsilon = configuration.getDouble(EPSILON, this.epsilon);
    this.maxIterations = configuration.getInt(MAX_ITERATIONS, 20);
    this.property = configuration.getString(PROPERTY, PAGE_RANK);
    this.vertexComputeKeys = new HashSet<>(Arrays.asList(
            VertexComputeKey.of(this.property, false),
            VertexComputeKey.of(EDGE_COUNT, true)));
    this.memoryComputeKeys = new HashSet<>(Arrays.asList(
            MemoryComputeKey.of(TELEPORTATION_ENERGY, Operator.sum, true, true),
            MemoryComputeKey.of(VERTEX_COUNT, Operator.sum, true, true),
            MemoryComputeKey.of(CONVERGENCE_ERROR, Operator.sum, false, true)));
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:22,代码来源:PageRankVertexProgram.java


示例6: 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


示例7: 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


示例8: addMessage

import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入依赖的package包/类
private void addMessage(final Vertex vertex, final M message, MessageScope messageScope) {
    this.messageBoard.sendMessages.compute(messageScope, (ms, messages) -> {
        if(null==messages) messages = new ConcurrentHashMap<>();
        return messages;
    });
    this.messageBoard.sendMessages.get(messageScope).compute(vertex, (v, queue) -> {
        if (null == queue) queue = new ConcurrentLinkedQueue<>();
        queue.add(null != this.combiner && !queue.isEmpty() ? this.combiner.combine(queue.remove(), message) : message);
        return queue;
    });
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:12,代码来源:TinkerMessenger.java


示例9: getMessageScopes

import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入依赖的package包/类
@Override
public Set<MessageScope> getMessageScopes(final Memory memory) {
    switch (memory.getIteration()) {
        case 0:
            return Sets.newHashSet(messageScopeShortcutIn, messageScopeResourceOut);
        case 1:
            return Collections.singleton(messageScopeShortcutOut);
        default:
            return Collections.emptySet();
    }
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:12,代码来源:MedianVertexProgram.java


示例10: loadState

import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入依赖的package包/类
@Override
public void loadState(final Graph graph, final Configuration configuration) {
    if (configuration.containsKey(INITIAL_RANK_TRAVERSAL))
        this.initialRankTraversal = PureTraversal.loadState(configuration, INITIAL_RANK_TRAVERSAL, graph);
    if (configuration.containsKey(EDGE_TRAVERSAL)) {
        this.edgeTraversal = PureTraversal.loadState(configuration, EDGE_TRAVERSAL, graph);
        this.incidentMessageScope = MessageScope.Local.of(() -> this.edgeTraversal.get().clone());
        this.countMessageScope = MessageScope.Local.of(new MessageScope.Local.ReverseTraversalSupplier(this.incidentMessageScope));
    }
    this.vertexCountAsDouble = configuration.getDouble(VERTEX_COUNT, 1.0d);
    this.alpha = configuration.getDouble(ALPHA, 0.85d);
    this.totalIterations = configuration.getInt(TOTAL_ITERATIONS, 30);
    this.property = configuration.getString(PROPERTY, PAGE_RANK);
    this.vertexComputeKeys = new HashSet<>(Arrays.asList(VertexComputeKey.of(this.property, false), VertexComputeKey.of(EDGE_COUNT, true)));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:16,代码来源:PageRankVertexProgram.java


示例11: loadState

import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入依赖的package包/类
@Override
public void loadState(final Graph graph, final Configuration configuration) {
    if (configuration.containsKey(INITIAL_VOTE_STRENGTH_TRAVERSAL))
        this.initialVoteStrengthTraversal = PureTraversal.loadState(configuration, INITIAL_VOTE_STRENGTH_TRAVERSAL, graph);
    if (configuration.containsKey(EDGE_TRAVERSAL)) {
        this.edgeTraversal = PureTraversal.loadState(configuration, EDGE_TRAVERSAL, graph);
        this.voteScope = MessageScope.Local.of(() -> this.edgeTraversal.get().clone());
        this.countScope = MessageScope.Local.of(new MessageScope.Local.ReverseTraversalSupplier(this.voteScope));
    }
    this.property = configuration.getString(PROPERTY, CLUSTER);
    this.maxIterations = configuration.getInt(MAX_ITERATIONS, 30);
    this.distributeVote = configuration.getBoolean(DISTRIBUTE_VOTE, false);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:14,代码来源:PeerPressureVertexProgram.java


示例12: 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


示例13: 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


示例14: loadState

import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入依赖的package包/类
@Override
public void loadState(final Graph graph, final Configuration configuration) {
    maxDepth = configuration.getInt(MAX_DEPTH);
    seed = configuration.getLong(SEED);
    weightProperty = configuration.getString(WEIGHT_PROPERTY, "distance");
    incidentMessageScope = MessageScope.Local.of(__::inE, (msg, edge) -> msg + edge.<Integer>value(weightProperty));
    log.debug("Loaded maxDepth={}", maxDepth);
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:9,代码来源:ShortestDistanceVertexProgram.java


示例15: 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


示例16: setMessage

import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入依赖的package包/类
public synchronized void setMessage(M message, MessageScope scope, Map<MessageScope,Integer> scopeMap) {
    assert message!=null && scope!=null;
    Preconditions.checkArgument(scopeMap.containsKey(scope),"Provided scope was not declared in the VertexProgram: %s",scope);
    initializeCurrentMessages(scopeMap);
    if (scopeMap.size()==1) currentMessages = message;
    else ((Object[])currentMessages)[scopeMap.get(scope)]=message;
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:8,代码来源:VertexState.java


示例17: 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


示例18: 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


示例19: 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


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CacheReplicationMonitor类代码示例发布时间:2022-05-23
下一篇:
Java SearchScrollRequest类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap