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

Java VertexProgram类代码示例

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

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



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


示例16: storeState

import org.apache.tinkerpop.gremlin.process.computer.VertexProgram; //导入依赖的package包/类
@Override
public void storeState(final Configuration configuration) {
    VertexProgram.super.storeState(configuration);
    this.traversal.storeState(configuration, VertexProgramStep.ROOT_TRAVERSAL);
    TraversalVertexProgram.storeHaltedTraversers(configuration, this.haltedTraversers);
    configuration.setProperty(ProgramVertexProgramStep.STEP_ID, this.programStep.getId());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:8,代码来源:ProgramTest.java


示例17: initialize

import org.apache.tinkerpop.gremlin.process.computer.VertexProgram; //导入依赖的package包/类
@Override
public void initialize(final TaskAttemptContext context) throws IOException, InterruptedException {
    final Configuration configuration = context.getConfiguration();
    this.recordWriter = ReflectionUtils.newInstance(configuration.getClass(Constants.GREMLIN_HADOOP_GRAPH_WRITER, OutputFormat.class, OutputFormat.class), configuration).getRecordWriter(context);
    this.transientComputeKeys = VertexProgramHelper.vertexComputeKeysAsArray(((VertexProgram<?>) VertexProgram.createVertexProgram(EmptyGraph.instance(), ConfUtil.makeApacheConfiguration(configuration))).getVertexComputeKeys().stream().
            filter(VertexComputeKey::isTransient).
            collect(Collectors.toSet()));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:9,代码来源:GiraphVertexWriter.java


示例18: compute

import org.apache.tinkerpop.gremlin.process.computer.VertexProgram; //导入依赖的package包/类
@Override
public void compute(final Vertex<ObjectWritable, VertexWritable, NullWritable> vertex, final Iterable<ObjectWritable> messages) throws IOException {
    final GiraphWorkerContext workerContext = this.getWorkerContext();
    final VertexProgram<?> vertexProgram = workerContext.getVertexProgramPool().take();
    vertexProgram.execute(ComputerGraph.vertexProgram(vertex.getValue().get(), vertexProgram), workerContext.getMessenger((GiraphVertex) vertex, this, messages.iterator()), workerContext.getMemory());
    workerContext.getVertexProgramPool().offer(vertexProgram);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:8,代码来源:GiraphComputation.java


示例19: program

import org.apache.tinkerpop.gremlin.process.computer.VertexProgram; //导入依赖的package包/类
@Override
public GraphComputer program(final VertexProgram vertexProgram) {
    super.program(vertexProgram);
    this.memory.addVertexProgramMemoryComputeKeys(this.vertexProgram);
    final BaseConfiguration apacheConfiguration = new BaseConfiguration();
    apacheConfiguration.setDelimiterParsingDisabled(true);
    vertexProgram.storeState(apacheConfiguration);
    IteratorUtils.fill(apacheConfiguration.getKeys(), this.vertexProgramConfigurationKeys);
    ConfUtil.mergeApacheIntoHadoopConfiguration(apacheConfiguration, this.giraphConfiguration);
    this.vertexProgram.getMessageCombiner().ifPresent(combiner -> this.giraphConfiguration.setMessageCombinerClass(GiraphMessageCombiner.class));
    return this;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:13,代码来源:GiraphGraphComputer.java


示例20: preApplication

import org.apache.tinkerpop.gremlin.process.computer.VertexProgram; //导入依赖的package包/类
public void preApplication() throws InstantiationException, IllegalAccessException {
    final Configuration apacheConfiguration = ConfUtil.makeApacheConfiguration(this.getContext().getConfiguration());
    KryoShimServiceLoader.applyConfiguration(apacheConfiguration);
    final VertexProgram vertexProgram = VertexProgram.createVertexProgram(HadoopGraph.open(apacheConfiguration), apacheConfiguration);
    this.vertexProgramPool = new VertexProgramPool(vertexProgram, this.getContext().getConfiguration().getInt(GiraphConstants.NUM_COMPUTE_THREADS.getKey(), 1));
    this.memory = new GiraphMemory(this, vertexProgram);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:8,代码来源:GiraphWorkerContext.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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