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


Java ProgramPhase类代码示例

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


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

示例1: terminate

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

示例2: setMemorySideEffects

import org.apache.tinkerpop.gremlin.process.computer.ProgramPhase; //导入依赖的package包/类
public static void setMemorySideEffects(final Traversal.Admin<?, ?> traversal, final Memory memory, final ProgramPhase phase) {
    final TraversalSideEffects sideEffects = traversal.getSideEffects();
    if (!(sideEffects instanceof MemoryTraversalSideEffects)) {
        traversal.setSideEffects(new MemoryTraversalSideEffects(sideEffects));
    }
    final MemoryTraversalSideEffects memoryTraversalSideEffects = ((MemoryTraversalSideEffects) traversal.getSideEffects());
    memoryTraversalSideEffects.memory = memory;
    memoryTraversalSideEffects.phase = phase;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:10,代码来源:MemoryTraversalSideEffects.java

示例3: setup

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

示例4: execute

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

示例5: workerIterationStart

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

示例6: terminate

import org.apache.tinkerpop.gremlin.process.computer.ProgramPhase; //导入依赖的package包/类
@Override
public boolean terminate(final Memory memory) {
    // memory is local
    MemoryTraversalSideEffects.setMemorySideEffects(this.traversal.get(), memory, ProgramPhase.TERMINATE);
    final boolean voteToHalt = memory.<Boolean>get(VOTE_TO_HALT);
    memory.set(VOTE_TO_HALT, true);
    memory.set(ACTIVE_TRAVERSERS, new TraverserSet<>());
    if (voteToHalt) {
        // local traverser sets to process
        final TraverserSet<Object> toProcessTraversers = new TraverserSet<>();
        // traversers that need to be sent back to the workers (no longer can be processed locally by the master traversal)
        final TraverserSet<Object> remoteActiveTraversers = new TraverserSet<>();
        // halted traversers that have completed their journey
        final TraverserSet<Object> haltedTraversers = memory.get(HALTED_TRAVERSERS);
        // get all barrier traversers
        final Set<String> completedBarriers = new HashSet<>();
        MasterExecutor.processMemory(this.traversalMatrix, memory, toProcessTraversers, completedBarriers);
        // process all results from barriers locally and when elements are touched, put them in remoteActiveTraversers
        MasterExecutor.processTraversers(this.traversal, this.traversalMatrix, toProcessTraversers, remoteActiveTraversers, haltedTraversers, this.haltedTraverserStrategy);
        // tell parallel barriers that might not have been active in the last round that they are no longer active
        memory.set(COMPLETED_BARRIERS, completedBarriers);
        if (!remoteActiveTraversers.isEmpty() ||
                completedBarriers.stream().map(this.traversalMatrix::getStepById).filter(step -> step instanceof LocalBarrier).findAny().isPresent()) {
            // send active traversers back to workers
            memory.set(ACTIVE_TRAVERSERS, remoteActiveTraversers);
            return false;
        } else {
            // finalize locally with any last traversers dangling in the local traversal
            final Step<?, Object> endStep = (Step<?, Object>) this.traversal.get().getEndStep();
            while (endStep.hasNext()) {
                haltedTraversers.add(this.haltedTraverserStrategy.halt(endStep.next()));
            }
            // the result of a TraversalVertexProgram are the halted traversers
            memory.set(HALTED_TRAVERSERS, haltedTraversers);
            // finalize profile side-effect steps. (todo: try and hide this)
            for (final ProfileSideEffectStep profileStep : TraversalHelper.getStepsOfAssignableClassRecursively(ProfileSideEffectStep.class, this.traversal.get())) {
                this.traversal.get().getSideEffects().set(profileStep.getSideEffectKey(), profileStep.generateFinalResult(this.traversal.get().getSideEffects().get(profileStep.getSideEffectKey())));
            }
            return true;
        }
    } else {
        return false;
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:45,代码来源:TraversalVertexProgram.java

示例7: workerIterationEnd

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

示例8: getMemorySideEffectsPhase

import org.apache.tinkerpop.gremlin.process.computer.ProgramPhase; //导入依赖的package包/类
public static ProgramPhase getMemorySideEffectsPhase(final Traversal.Admin<?, ?> traversal) {
    return traversal.getSideEffects() instanceof MemoryTraversalSideEffects ?
            ((MemoryTraversalSideEffects)traversal.getSideEffects()).phase:null;
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:5,代码来源:MemoryTraversalSideEffects.java


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