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


Java VertexProgram类代码示例

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


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

示例1: executeVertexProgram

import org.apache.tinkerpop.gremlin.process.computer.VertexProgram; //导入依赖的package包/类
public void executeVertexProgram(final TriConsumer<Iterator<Vertex>, VertexProgram, TinkerWorkerMemory> worker) throws InterruptedException {
    for (int i = 0; i < this.numberOfWorkers; i++) {
        final int index = i;
        this.completionService.submit(() -> {
            final VertexProgram vp = this.vertexProgramPool.take();
            final TinkerWorkerMemory workerMemory = this.workerMemoryPool.poll();
            final List<Vertex> vertices = this.workerVertices.get(index);
            worker.accept(vertices.iterator(), vp, workerMemory);
            this.vertexProgramPool.offer(vp);
            this.workerMemoryPool.offer(workerMemory);
            return null;
        });
    }
    for (int i = 0; i < this.numberOfWorkers; i++) {
        try {
            this.completionService.take().get();
        } catch (InterruptedException ie) {
            throw ie;
        } catch (final Exception e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:24,代码来源:TinkerWorkerPool.java

示例2: compute

import org.apache.tinkerpop.gremlin.process.computer.VertexProgram; //导入依赖的package包/类
@Override
public ComputerResult compute(@Nullable VertexProgram program, @Nullable MapReduce mapReduce,
                              @Nullable Set<LabelId> types, Boolean includesRolePlayerEdges) {
    try {
        graphComputer = getGraphComputer();
        if (program != null) {
            graphComputer.program(program);
        } else {
            filterAllEdges = true;
        }
        if (mapReduce != null) graphComputer.mapReduce(mapReduce);
        applyFilters(types, includesRolePlayerEdges);
        return graphComputer.submit().get();
    } catch (InterruptedException | ExecutionException e) {
        throw asRuntimeException(e.getCause());
    }
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:18,代码来源:GraknComputerImpl.java

示例3: GraknSparkMemory

import org.apache.tinkerpop.gremlin.process.computer.VertexProgram; //导入依赖的package包/类
public GraknSparkMemory(final VertexProgram<?> vertexProgram,
                        final Set<MapReduce> mapReducers,
                        final JavaSparkContext sparkContext) {
    if (null != vertexProgram) {
        for (final MemoryComputeKey key : vertexProgram.getMemoryComputeKeys()) {
            this.memoryComputeKeys.put(key.getKey(), key);
        }
    }
    for (final MapReduce mapReduce : mapReducers) {
        this.memoryComputeKeys.put(
                mapReduce.getMemoryKey(),
                MemoryComputeKey.of(mapReduce.getMemoryKey(), Operator.assign, false, false));
    }
    for (final MemoryComputeKey memoryComputeKey : this.memoryComputeKeys.values()) {
        this.sparkMemory.put(
                memoryComputeKey.getKey(),
                sparkContext.accumulator(ObjectWritable.empty(), memoryComputeKey.getKey(),
                        new MemoryAccumulator<>(memoryComputeKey)));
    }
    this.broadcast = sparkContext.broadcast(Collections.emptyMap());
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:22,代码来源:GraknSparkMemory.java

示例4: validateProgramOnComputer

import org.apache.tinkerpop.gremlin.process.computer.VertexProgram; //导入依赖的package包/类
public static void validateProgramOnComputer(final GraphComputer computer, final VertexProgram vertexProgram) {
    if (vertexProgram.getMemoryComputeKeys().contains(null))
        throw Memory.Exceptions.memoryKeyCanNotBeNull();
    if (vertexProgram.getMemoryComputeKeys().contains(""))
        throw Memory.Exceptions.memoryKeyCanNotBeEmpty();

    final GraphComputer.Features graphComputerFeatures = computer.features();
    final VertexProgram.Features vertexProgramFeatures = vertexProgram.getFeatures();

    for (final Method method : VertexProgram.Features.class.getMethods()) {
        if (method.getName().startsWith("requires")) {
            final boolean supports;
            final boolean requires;
            try {
                supports = (boolean) GraphComputer.Features.class.getMethod(method.getName().replace("requires", "supports")).invoke(graphComputerFeatures);
                requires = (boolean) method.invoke(vertexProgramFeatures);
            } catch (final Exception e) {
                throw new IllegalStateException("A reflection exception has occurred: " + e.getMessage(), e);
            }
            if (requires && !supports)
                throw new IllegalStateException("The vertex program can not be executed on the graph computer: " + method.getName());
        }
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:25,代码来源:GraphComputerHelper.java

示例5: executeVertexProgram

import org.apache.tinkerpop.gremlin.process.computer.VertexProgram; //导入依赖的package包/类
public void executeVertexProgram(final Consumer<VertexProgram> worker) throws InterruptedException {
    for (int i = 0; i < this.numberOfWorkers; i++) {
        this.completionService.submit(() -> {
            final VertexProgram vp = this.vertexProgramPool.take();
            worker.accept(vp);
            this.vertexProgramPool.offer(vp);
            return null;
        });
    }
    for (int i = 0; i < this.numberOfWorkers; i++) {
        try {
            this.completionService.take().get();
        } catch (InterruptedException ie) {
            throw ie;
        } catch (final Exception e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:20,代码来源:TinkerWorkerPool.java

示例6: SparkMemory

import org.apache.tinkerpop.gremlin.process.computer.VertexProgram; //导入依赖的package包/类
public SparkMemory(final VertexProgram<?> vertexProgram, final Set<MapReduce> mapReducers, final JavaSparkContext sparkContext) {
    if (null != vertexProgram) {
        for (final MemoryComputeKey key : vertexProgram.getMemoryComputeKeys()) {
            this.memoryComputeKeys.put(key.getKey(), key);
        }
    }
    for (final MapReduce mapReduce : mapReducers) {
        this.memoryComputeKeys.put(mapReduce.getMemoryKey(), MemoryComputeKey.of(mapReduce.getMemoryKey(), Operator.assign, false, false));
    }
    for (final MemoryComputeKey memoryComputeKey : this.memoryComputeKeys.values()) {
        this.sparkMemory.put(
                memoryComputeKey.getKey(),
                sparkContext.accumulator(ObjectWritable.empty(), memoryComputeKey.getKey(), new MemoryAccumulator<>(memoryComputeKey)));
    }
    this.broadcast = sparkContext.broadcast(Collections.emptyMap());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:SparkMemory.java

示例7: executeVertexProgram

import org.apache.tinkerpop.gremlin.process.computer.VertexProgram; //导入依赖的package包/类
public void executeVertexProgram(Consumer<VertexProgram<M>> worker) {
for (int i = 0; i < numberOfWorkers; i++) {
    completionService.submit(() -> {
	@SuppressWarnings("unchecked")
	VertexProgram<M> vp = vertexProgramPool.take();
	worker.accept(vp);
	vertexProgramPool.offer(vp);
	return null;
    });
}
for (int i = 0; i < numberOfWorkers; i++) {
    try {
	completionService.take().get();
    } catch (Exception e) {
	throw new IllegalStateException(e.getMessage(), e);
    }
}
   }
 
开发者ID:PureSolTechnologies,项目名称:DuctileDB,代码行数:19,代码来源:DuctileWorkerPool.java

示例8: TinkerMemory

import org.apache.tinkerpop.gremlin.process.computer.VertexProgram; //导入依赖的package包/类
public TinkerMemory(final VertexProgram<?> vertexProgram, final Set<MapReduce> mapReducers) {
    this.currentMap = new ConcurrentHashMap<>();
    this.previousMap = new ConcurrentHashMap<>();
    if (null != vertexProgram) {
        for (final MemoryComputeKey memoryComputeKey : vertexProgram.getMemoryComputeKeys()) {
            this.memoryKeys.put(memoryComputeKey.getKey(), memoryComputeKey);
        }
    }
    for (final MapReduce mapReduce : mapReducers) {
        this.memoryKeys.put(mapReduce.getMemoryKey(), MemoryComputeKey.of(mapReduce.getMemoryKey(), Operator.assign, false, false));
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:13,代码来源:TinkerMemory.java

示例9: storeState

import org.apache.tinkerpop.gremlin.process.computer.VertexProgram; //导入依赖的package包/类
@Override
public void storeState(final Configuration configuration) {
    VertexProgram.super.storeState(configuration);
    configuration.setProperty(VERTEX_COUNT, this.vertexCountAsDouble);
    configuration.setProperty(ALPHA, this.alpha);
    configuration.setProperty(TOTAL_ITERATIONS, this.totalIterations);
    configuration.setProperty(PROPERTY, this.property);
    if (null != this.edgeTraversal)
        this.edgeTraversal.storeState(configuration, EDGE_TRAVERSAL);
    if (null != this.initialRankTraversal)
        this.initialRankTraversal.storeState(configuration, INITIAL_RANK_TRAVERSAL);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:13,代码来源:PageRankVertexProgram.java

示例10: storeState

import org.apache.tinkerpop.gremlin.process.computer.VertexProgram; //导入依赖的package包/类
@Override
public void storeState(final Configuration config) {
    VertexProgram.super.storeState(config);
    if (configuration != null) {
        ConfigurationUtils.copy(configuration, config);
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:8,代码来源:BulkLoaderVertexProgram.java

示例11: ProgramVertexProgramStep

import org.apache.tinkerpop.gremlin.process.computer.VertexProgram; //导入依赖的package包/类
public ProgramVertexProgramStep(final Traversal.Admin traversal, final VertexProgram vertexProgram) {
    super(traversal);
    this.configuration = new HashMap<>();
    final MapConfiguration base = new MapConfiguration(this.configuration);
    base.setDelimiterParsingDisabled(true);
    vertexProgram.storeState(base);
    this.toStringOfVertexProgram = vertexProgram.toString();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:9,代码来源:ProgramVertexProgramStep.java

示例12: generateProgram

import org.apache.tinkerpop.gremlin.process.computer.VertexProgram; //导入依赖的package包/类
@Override
public VertexProgram generateProgram(final Graph graph, final Memory memory) {
    final MapConfiguration base = new MapConfiguration(this.configuration);
    base.setDelimiterParsingDisabled(true);
    PureTraversal.storeState(base, ROOT_TRAVERSAL, TraversalHelper.getRootTraversal(this.getTraversal()).clone());
    base.setProperty(STEP_ID, this.getId());
    if (memory.exists(TraversalVertexProgram.HALTED_TRAVERSERS))
        TraversalVertexProgram.storeHaltedTraversers(base, memory.get(TraversalVertexProgram.HALTED_TRAVERSERS));
    return VertexProgram.createVertexProgram(graph, base);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:11,代码来源:ProgramVertexProgramStep.java

示例13: take

import org.apache.tinkerpop.gremlin.process.computer.VertexProgram; //导入依赖的package包/类
public VertexProgram take() {
    try {
        return this.pool.poll(TIMEOUT_MS, TimeUnit.MILLISECONDS);
    } catch (final InterruptedException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:8,代码来源:VertexProgramPool.java

示例14: offer

import org.apache.tinkerpop.gremlin.process.computer.VertexProgram; //导入依赖的package包/类
public void offer(final VertexProgram<?> vertexProgram) {
    try {
        this.pool.offer(vertexProgram, TIMEOUT_MS, TimeUnit.MILLISECONDS);
    } catch (final InterruptedException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:8,代码来源:VertexProgramPool.java

示例15: loadState

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


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