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

Java Memory类代码示例

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

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



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

示例1: safeExecute

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的package包/类
@Override
public void safeExecute(final Vertex vertex, Messenger<PathMessage> messenger, final Memory memory) {
    if (memory.isInitialIteration()) {
        // The type of id will likely have to change as we support more and more vendors
        String id = getVertexId(vertex);
        if (persistentProperties.get(SOURCE).equals(id)) {
            LOGGER.debug("Found source vertex");
            vertex.property(VISITED_IN_ITERATION, 1);
            sendMessage(messenger, PathMessage.of(FROM_SOURCE, id));
        } else if (persistentProperties.get(DESTINATION).equals(id)) {
            LOGGER.debug("Found destination vertex");
            vertex.property(VISITED_IN_ITERATION, -1);
            sendMessage(messenger, PathMessage.of(FROM_DESTINATION, id));
        }
    } else {
        if (memory.<Boolean>get(FOUND_PATH)) {
            if (messenger.receiveMessages().hasNext() && vertex.property(VISITED_IN_ITERATION).isPresent()) {
                recordPredecessors(vertex, messenger, memory);
            }
        } else if (messenger.receiveMessages().hasNext()) {
            updateInstance(vertex, messenger, memory);
        }
    }
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:25,代码来源:ShortestPathVertexProgram.java


示例2: setup

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的package包/类
@Override
public void setup(final Memory memory) {
    LOGGER.debug("MedianVertexProgram Started !!!!!!!!");
    memory.set(COUNT, 0L);
    memory.set(LABEL_SELECTED, memory.getIteration());
    memory.set(NEGATIVE_COUNT, 0L);
    memory.set(POSITIVE_COUNT, 0L);
    memory.set(FOUND, false);
    if (persistentProperties.get(RESOURCE_DATA_TYPE).equals(Schema.VertexProperty.VALUE_LONG.name())) {
        memory.set(MEDIAN, 0L);
        memory.set(PIVOT, 0L);
        memory.set(PIVOT_NEGATIVE, 0L);
        memory.set(PIVOT_POSITIVE, 0L);
    } else {
        memory.set(MEDIAN, 0D);
        memory.set(PIVOT, 0D);
        memory.set(PIVOT_NEGATIVE, 0D);
        memory.set(PIVOT_POSITIVE, 0D);
    }
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:21,代码来源:MedianVertexProgram.java


示例3: updateEntityAndAttribute

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的package包/类
private void updateEntityAndAttribute(Vertex vertex, Messenger<String> messenger, Memory memory) {
    if (vertex.property(CLUSTER_LABEL).isPresent()) {
        String id = vertex.value(Schema.VertexProperty.ID.name());
        int messageCount = getMessageCount(messenger, id) +
                (vertex.property(IMPLICIT_MESSAGE_COUNT).isPresent() ?
                        (int) vertex.value(IMPLICIT_MESSAGE_COUNT) : 0);

        if (messageCount >= k) {
            LOGGER.trace("Sending msg from " + id);
            sendMessage(messenger, id);
            memory.add(K_CORE_EXIST, true);
        } else {
            LOGGER.trace("Removing label of " + id);
            vertex.property(CLUSTER_LABEL).remove();
            memory.add(K_CORE_STABLE, false);
        }
    }
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:19,代码来源:KCoreVertexProgram.java


示例4: safeExecute

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的package包/类
@Override
public void safeExecute(final Vertex vertex, Messenger<Long> messenger, final Memory memory) {
    switch (memory.getIteration()) {
        case 0:
            degreeStatisticsStepResourceOwner(vertex, messenger, ofLabelIds);
            break;
        case 1:
            degreeStatisticsStepResourceRelation(vertex, messenger, ofLabelIds);
            break;
        case 2:
            degreeStatisticsStepResource(vertex, messenger, ofLabelIds);
            break;
        default:
            throw CommonUtil.unreachableStatement("Exceeded expected maximum number of iterations");
    }
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:17,代码来源:DegreeStatisticsVertexProgram.java


示例5: get

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的package包/类
@Override
public <R> R get(final String key) throws IllegalArgumentException {
    if (!this.memoryComputeKeys.containsKey(key)) {
        throw Memory.Exceptions.memoryDoesNotExist(key);
    }
    if (this.inExecute && !this.memoryComputeKeys.get(key).isBroadcast()) {
        throw Memory.Exceptions.memoryDoesNotExist(key);
    }
    final ObjectWritable<R> r = (ObjectWritable<R>) (this.inExecute ?
            this.broadcast.value().get(key) : this.sparkMemory.get(key).value());
    if (null == r || r.isEmpty()) {
        throw Memory.Exceptions.memoryDoesNotExist(key);
    } else {
        return r.get();
    }
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:17,代码来源:GraknSparkMemory.java


示例6: execute

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的package包/类
@Override
public void execute(final Vertex vertex, Messenger<Double> messenger, final Memory memory) {
    if (memory.isInitialIteration()) {
        messenger.sendMessage(this.countMessageScope, 1.0d);
    } else if (1 == memory.getIteration()) {
        double initialPageRank = (null == this.initialRankTraversal ?
                1.0d :
                TraversalUtil.apply(vertex, this.initialRankTraversal.get()).doubleValue()) / this.vertexCountAsDouble;
        double edgeCount = IteratorUtils.reduce(messenger.receiveMessages(), 0.0d, (a, b) -> a + b);
        vertex.property(VertexProperty.Cardinality.single, this.property, initialPageRank);
        vertex.property(VertexProperty.Cardinality.single, EDGE_COUNT, edgeCount);
        if (!this.terminate(memory)) // don't send messages if this is the last iteration
            messenger.sendMessage(this.incidentMessageScope, initialPageRank / edgeCount);
    } else {
        double newPageRank = IteratorUtils.reduce(messenger.receiveMessages(), 0.0d, (a, b) -> a + b);
        newPageRank = (this.alpha * newPageRank) + ((1.0d - this.alpha) / this.vertexCountAsDouble);
        vertex.property(VertexProperty.Cardinality.single, this.property, newPageRank);
        if (!this.terminate(memory)) // don't send messages if this is the last iteration
            messenger.sendMessage(this.incidentMessageScope, newPageRank / vertex.<Double>value(EDGE_COUNT));
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:22,代码来源:PageRankVertexProgram.java


示例7: workerIterationStart

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的package包/类
@Override
public void workerIterationStart(final Memory memory) {
    if (null == graph) {
        graph = GraphFactory.open(configuration.subset(WRITE_GRAPH_CFG_KEY));
        LOGGER.info("Opened Graph instance: {}", graph);
        try {
            listener = new BulkLoadingListener();
            g = graph.traversal().withStrategies(EventStrategy.build().addListener(listener).create());
        } catch (Exception e) {
            try {
                graph.close();
            } catch (Exception e2) {
                LOGGER.warn("Failed to close Graph instance", e2);
            }
            throw e;
        }
    } else {
        LOGGER.warn("Leaked Graph instance: {}", graph);
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:21,代码来源:BulkLoaderVertexProgram.java


示例8: generateProgram

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的package包/类
@Override
public TraversalVertexProgram generateProgram(final Graph graph, final Memory memory) {
    final Traversal.Admin<?, ?> computerSpecificTraversal = this.computerTraversal.getPure();
    final TraversalStrategies computerSpecificStrategies = this.getTraversal().getStrategies().clone();
    TraversalStrategies.GlobalCache.getStrategies(graph.getClass())
            .toList()
            .stream()
            .filter(s -> s instanceof TraversalStrategy.ProviderOptimizationStrategy)
            .forEach(computerSpecificStrategies::addStrategies);
    computerSpecificTraversal.setStrategies(computerSpecificStrategies);
    computerSpecificTraversal.setSideEffects(new MemoryTraversalSideEffects(this.getTraversal().getSideEffects()));
    computerSpecificTraversal.setParent(this);
    final TraversalVertexProgram.Builder builder = TraversalVertexProgram.build().traversal(computerSpecificTraversal);
    if (memory.exists(TraversalVertexProgram.HALTED_TRAVERSERS))
        builder.haltedTraversers(memory.get(TraversalVertexProgram.HALTED_TRAVERSERS));
    return builder.create(graph);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:TraversalVertexProgramStep.java


示例9: processMemory

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的package包/类
protected static void processMemory(final TraversalMatrix<?, ?> traversalMatrix, final Memory memory, final TraverserSet<Object> toProcessTraversers, final Set<String> completedBarriers) {
    // handle traversers and data that were sent from the workers to the master traversal via memory
    if (memory.exists(TraversalVertexProgram.MUTATED_MEMORY_KEYS)) {
        for (final String key : memory.<Set<String>>get(TraversalVertexProgram.MUTATED_MEMORY_KEYS)) {
            final Step<Object, Object> step = traversalMatrix.getStepById(key);
            assert step instanceof Barrier;
            completedBarriers.add(step.getId());
            if (!(step instanceof LocalBarrier)) {  // local barriers don't do any processing on the master traversal (they just lock on the workers)
                final Barrier<Object> barrier = (Barrier<Object>) step;
                barrier.addBarrier(memory.get(key));
                step.forEachRemaining(toProcessTraversers::add);
                // if it was a reducing barrier step, reset the barrier to its seed value
                if (step instanceof ReducingBarrierStep)
                    memory.set(step.getId(), ((ReducingBarrierStep) step).getSeedSupplier().get());
            }
        }
    }
    memory.set(TraversalVertexProgram.MUTATED_MEMORY_KEYS, new HashSet<>());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:20,代码来源:MasterExecutor.java


示例10: terminate

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的package包/类
@Override
public boolean terminate(final Memory memory) {
    final TraverserGenerator generator = this.traversal.get().getTraverserGenerator();
    MemoryTraversalSideEffects.setMemorySideEffects(this.traversal.get(), memory, ProgramPhase.TERMINATE);
    checkSideEffects();
    if (memory.isInitialIteration()) {
        assertFalse(memory.exists(TraversalVertexProgram.HALTED_TRAVERSERS));
        return false;
    } else {
        ///
        assertTrue(memory.exists(TraversalVertexProgram.HALTED_TRAVERSERS));
        final TraverserSet<String> haltedTraversers = memory.get(TraversalVertexProgram.HALTED_TRAVERSERS);
        haltedTraversers.add(generator.generate("hello", this.programStep, 1l));
        haltedTraversers.add(generator.generate("gremlin", this.programStep, 1l));
        memory.set(TraversalVertexProgram.HALTED_TRAVERSERS, haltedTraversers);
        return true;
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:19,代码来源:ProgramTest.java


示例11: get

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的package包/类
@Override
public <R> R get(final String key) throws IllegalArgumentException {
    final R r = (R) this.previousMap.get(key);
    if (null == r)
        throw Memory.Exceptions.memoryDoesNotExist(key);
    else if (this.inExecute && !this.memoryKeys.get(key).isBroadcast())
        throw Memory.Exceptions.memoryDoesNotExist(key);
    else
        return r;
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:11,代码来源:TinkerMemory.java


示例12: set

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的package包/类
@Override
public void set(final String key, final Object value) {
    checkKeyValue(key, value);
    if (this.inExecute)
        throw Memory.Exceptions.memorySetOnlyDuringVertexProgramSetUpAndTerminate(key);
    this.currentMap.put(key, value);
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:8,代码来源:TinkerMemory.java


示例13: add

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的package包/类
@Override
public void add(final String key, final Object value) {
    checkKeyValue(key, value);
    if (!this.inExecute)
        throw Memory.Exceptions.memoryAddOnlyDuringVertexProgramExecute(key);
    this.currentMap.compute(key, (k, v) -> null == v ? value : this.memoryKeys.get(key).getReducer().apply(v, value));
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:8,代码来源:TinkerMemory.java


示例14: setup

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的package包/类
@Override
public void setup(final Memory memory) {
    LOGGER.debug("ShortestPathVertexProgram Started !!!!!!!!");

    memory.set(VOTE_TO_HALT_SOURCE, true);
    memory.set(VOTE_TO_HALT_DESTINATION, true);
    memory.set(FOUND_PATH, false);
    memory.set(PATH_HAS_MIDDLE_POINT, true);
    memory.set(ITERATIONS_LEFT, -1);
    memory.set(PREDECESSORS_FROM_SOURCE, new HashMap<String, Set<String>>());
    memory.set(PREDECESSORS_FROM_DESTINATION, new HashMap<String, Set<String>>());
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:13,代码来源:ShortestPathVertexProgram.java


示例15: set

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的package包/类
@Override
public void set(final String key, final Object value) {
    this.checkKeyValue(key, value);
    if (this.inExecute)
        throw Memory.Exceptions.memorySetOnlyDuringVertexProgramSetUpAndTerminate(key);
    this.setAggregatedValue(key, new ObjectWritable<>(new Pair<>(this.memoryComputeKeys.get(key).getReducer(), value)));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:8,代码来源:GiraphMemory.java


示例16: execute

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的package包/类
@Override
public void execute(Vertex vertex, Messenger<T> messenger, Memory memory) {
    // try to deal with ghost vertex issues by ignoring them
    if (Utility.isAlive(vertex)) {
        safeExecute(vertex, messenger, memory);
    }
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:8,代码来源:GraknVertexProgram.java


示例17: safeExecute

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的package包/类
@Override
public void safeExecute(final Vertex vertex, Messenger<String> messenger, final Memory memory) {
    if (memory.isInitialIteration()) {
        String id = vertex.value(Schema.VertexProperty.ID.name());
        vertex.property(CLUSTER_LABEL, id);
        messenger.sendMessage(messageScopeIn, id);
        messenger.sendMessage(messageScopeOut, id);
    } else {
        updateClusterLabel(vertex, messenger, memory);
    }
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:12,代码来源:ConnectedComponentsVertexProgram.java


示例18: updateClusterLabel

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的package包/类
private static void updateClusterLabel(Vertex vertex, Messenger<String> messenger, Memory memory) {
    String currentMax = vertex.value(CLUSTER_LABEL);
    String max = IteratorUtils.reduce(messenger.receiveMessages(), currentMax,
            (a, b) -> a.compareTo(b) > 0 ? a : b);
    if (max.compareTo(currentMax) > 0) {
        vertex.property(CLUSTER_LABEL, max);
        messenger.sendMessage(messageScopeIn, max);
        messenger.sendMessage(messageScopeOut, max);
        memory.add(VOTE_TO_HALT, false);
    }
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:12,代码来源:ConnectedComponentsVertexProgram.java


示例19: terminate

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的package包/类
@Override
public boolean terminate(final Memory memory) {
    LOGGER.debug("Finished Iteration " + memory.getIteration());
    if (memory.getIteration() < 2) return false;
    if (memory.<Boolean>get(VOTE_TO_HALT)) {
        return true;
    }
    if (memory.getIteration() == MAX_ITERATION) {
        LOGGER.debug("Reached Max Iteration: " + MAX_ITERATION + " !!!!!!!!");
        throw GraqlQueryException.maxIterationsReached(this.getClass());
    }

    memory.set(VOTE_TO_HALT, true);
    return false;
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:16,代码来源:ConnectedComponentsVertexProgram.java


示例20: getMessageScopes

import org.apache.tinkerpop.gremlin.process.computer.Memory; //导入依赖的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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java RenderableView类代码示例发布时间:2022-05-23
下一篇:
Java ImageMessageBody类代码示例发布时间: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