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


Java MemoryTraversalSideEffects类代码示例

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


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

示例1: generateProgram

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

示例2: terminate

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

示例3: loadState

import org.apache.tinkerpop.gremlin.process.computer.traversal.MemoryTraversalSideEffects; //导入依赖的package包/类
@Override
public void loadState(final Graph graph, final Configuration configuration) {
    VertexProgram.super.loadState(graph, configuration);
    this.traversal = PureTraversal.loadState(configuration, VertexProgramStep.ROOT_TRAVERSAL, graph);
    this.haltedTraversers = TraversalVertexProgram.loadHaltedTraversers(configuration);
    this.programStep = new TraversalMatrix<>(this.traversal.get()).getStepById(configuration.getString(ProgramVertexProgramStep.STEP_ID));
    this.memoryComputeKeys.addAll(MemoryTraversalSideEffects.getMemoryComputeKeys(this.traversal.get()));
    this.memoryComputeKeys.add(MemoryComputeKey.of(TraversalVertexProgram.HALTED_TRAVERSERS, Operator.addAll, false, false));
    this.memoryComputeKeys.add(MemoryComputeKey.of(TraversalVertexProgram.ACTIVE_TRAVERSERS, Operator.addAll, true, true));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:11,代码来源:ProgramTest.java

示例4: setup

import org.apache.tinkerpop.gremlin.process.computer.traversal.MemoryTraversalSideEffects; //导入依赖的package包/类
@Override
public void setup(final Memory memory) {
    MemoryTraversalSideEffects.setMemorySideEffects(this.traversal.get(), memory, ProgramPhase.SETUP);
    final Map<Vertex, Long> map = (Map<Vertex, Long>) this.haltedTraversers.iterator().next().get();
    assertEquals(2, map.size());
    assertTrue(map.values().contains(3l));
    assertTrue(map.values().contains(1l));
    final TraverserSet<Object> activeTraversers = new TraverserSet<>();
    map.keySet().forEach(vertex -> activeTraversers.add(this.haltedTraversers.peek().split(vertex, EmptyStep.instance())));
    this.haltedTraversers.clear();
    this.checkSideEffects();
    memory.set(TraversalVertexProgram.ACTIVE_TRAVERSERS, activeTraversers);


}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:16,代码来源:ProgramTest.java

示例5: execute

import org.apache.tinkerpop.gremlin.process.computer.traversal.MemoryTraversalSideEffects; //导入依赖的package包/类
@Override
public void execute(final Vertex vertex, final Messenger messenger, final Memory memory) {
    assertFalse(memory.exists(TraversalVertexProgram.HALTED_TRAVERSERS));
    final TraverserGenerator generator = this.traversal.get().getTraverserGenerator();
    MemoryTraversalSideEffects.setMemorySideEffects(this.traversal.get(), memory, ProgramPhase.EXECUTE);
    this.checkSideEffects();
    final TraverserSet<Vertex> activeTraversers = memory.get(TraversalVertexProgram.ACTIVE_TRAVERSERS);
    if (vertex.label().equals("software")) {
        assertEquals(1, activeTraversers.stream().filter(v -> v.get().equals(vertex)).count());
        if (memory.isInitialIteration()) {
            assertFalse(vertex.property(TraversalVertexProgram.HALTED_TRAVERSERS).isPresent());
            vertex.property(
                    TraversalVertexProgram.HALTED_TRAVERSERS,
                    new TraverserSet<>(generator.generate(vertex.value("name"), this.programStep, 1l)));
        } else {
            assertTrue(vertex.property(TraversalVertexProgram.HALTED_TRAVERSERS).isPresent());
        }
    } else {
        assertFalse(vertex.property(TraversalVertexProgram.HALTED_TRAVERSERS).isPresent());
        assertEquals(0, activeTraversers.stream().filter(v -> v.get().equals(vertex)).count());
        if (!memory.isInitialIteration()) {
            if (vertex.value("name").equals("marko"))
                memory.add(TraversalVertexProgram.HALTED_TRAVERSERS, new TraverserSet<>(generator.generate("marko-is-my-name", this.programStep, 1l)));
            else if (vertex.value("name").equals("vadas"))
                this.traversal.get().getSideEffects().add(TraversalVertexProgram.HALTED_TRAVERSERS, new TraverserSet<>(generator.generate("the-v-o-double-g", this.programStep, 1l)));
        }
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:29,代码来源:ProgramTest.java

示例6: workerIterationStart

import org.apache.tinkerpop.gremlin.process.computer.traversal.MemoryTraversalSideEffects; //导入依赖的package包/类
@Override
public void workerIterationStart(final Memory memory) {
    assertNotNull(this.haltedTraversers);
    this.haltedTraversers.clear();
    assertFalse(memory.exists(TraversalVertexProgram.HALTED_TRAVERSERS));
    MemoryTraversalSideEffects.setMemorySideEffects(this.traversal.get(), memory, ProgramPhase.WORKER_ITERATION_START);
    checkSideEffects();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:9,代码来源:ProgramTest.java

示例7: checkSideEffects

import org.apache.tinkerpop.gremlin.process.computer.traversal.MemoryTraversalSideEffects; //导入依赖的package包/类
private void checkSideEffects() {
    assertEquals(0, this.haltedTraversers.size());
    assertTrue(this.haltedTraversers.isEmpty());
    final TraversalSideEffects sideEffects = this.traversal.get().getSideEffects();
    assertTrue(sideEffects instanceof MemoryTraversalSideEffects);
    assertEquals(1, sideEffects.keys().size());
    assertFalse(sideEffects.exists(TraversalVertexProgram.HALTED_TRAVERSERS));
    assertTrue(sideEffects.exists("x"));
    final BulkSet<String> bulkSet = sideEffects.get("x");
    assertEquals(4, bulkSet.size());
    assertEquals(4, bulkSet.get("java"));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:13,代码来源:ProgramTest.java

示例8: workerIterationEnd

import org.apache.tinkerpop.gremlin.process.computer.traversal.MemoryTraversalSideEffects; //导入依赖的package包/类
@Override
public void workerIterationEnd(final Memory memory) {
    assertFalse(memory.exists(TraversalVertexProgram.HALTED_TRAVERSERS));
    MemoryTraversalSideEffects.setMemorySideEffects(this.traversal.get(), memory, ProgramPhase.WORKER_ITERATION_END);
    checkSideEffects();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:7,代码来源:ProgramTest.java


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