Java Code Examples for org.apache.tinkerpop.gremlin.process.computer.ComputerResult

The following are top voted examples for showing how to use org.apache.tinkerpop.gremlin.process.computer.ComputerResult. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: grakn   File: MedianQueryImpl.java   Source Code and License 6 votes vote down vote up
@Override
public Optional<Number> execute() {
    LOGGER.info("MedianVertexProgram is called");
    long startTime = System.currentTimeMillis();

    initSubGraph();
    getAllSubTypes();

    AttributeType.DataType dataType = getDataTypeOfSelectedResourceTypes();
    if (!selectedResourceTypesHaveInstance(statisticsResourceLabels)) return Optional.empty();
    Set<LabelId> allSubLabelIds = convertLabelsToIds(getCombinedSubTypes());
    Set<LabelId> statisticsResourceLabelIds = convertLabelsToIds(statisticsResourceLabels);

    ComputerResult result = getGraphComputer().compute(
            new MedianVertexProgram(statisticsResourceLabelIds, dataType),
            null, allSubLabelIds);

    Number finalResult = result.memory().get(MedianVertexProgram.MEDIAN);
    LOGGER.debug("Median = " + finalResult);

    LOGGER.info("MedianVertexProgram is done in " + (System.currentTimeMillis() - startTime) + " ms");
    return Optional.of(finalResult);
}
 
Example 2
Project: grakn   File: SumQueryImpl.java   Source Code and License 6 votes vote down vote up
@Override
public Optional<Number> execute() {
    LOGGER.info("SumMapReduce is called");
    long startTime = System.currentTimeMillis();

    initSubGraph();
    getAllSubTypes();

    AttributeType.DataType dataType = getDataTypeOfSelectedResourceTypes();
    if (!selectedResourceTypesHaveInstance(statisticsResourceLabels)) return Optional.empty();
    Set<LabelId> allSubLabelIds = convertLabelsToIds(getCombinedSubTypes());
    Set<LabelId> statisticsResourceLabelIds = convertLabelsToIds(statisticsResourceLabels);

    ComputerResult result = getGraphComputer().compute(
            new DegreeStatisticsVertexProgram(statisticsResourceLabelIds),
            new SumMapReduce(statisticsResourceLabelIds, dataType,
                    DegreeVertexProgram.DEGREE),
            allSubLabelIds);
    Map<Serializable, Number> sum = result.memory().get(SumMapReduce.class.getName());

    Number finalResult = sum.get(MapReduce.NullObject.instance());
    LOGGER.info("Sum = " + finalResult);

    LOGGER.info("SumMapReduce is done in " + (System.currentTimeMillis() - startTime) + " ms");
    return Optional.of(finalResult);
}
 
Example 3
Project: grakn   File: MinQueryImpl.java   Source Code and License 6 votes vote down vote up
@Override
public Optional<Number> execute() {
    LOGGER.info("MinMapReduce is called");
    long startTime = System.currentTimeMillis();

    initSubGraph();
    getAllSubTypes();

    AttributeType.DataType dataType = getDataTypeOfSelectedResourceTypes();
    if (!selectedResourceTypesHaveInstance(statisticsResourceLabels)) return Optional.empty();
    Set<LabelId> allSubLabelIds = convertLabelsToIds(getCombinedSubTypes());
    Set<LabelId> statisticsResourceLabelIds = convertLabelsToIds(statisticsResourceLabels);

    ComputerResult result = getGraphComputer().compute(
            new DegreeStatisticsVertexProgram(statisticsResourceLabelIds),
            new MinMapReduce(statisticsResourceLabelIds, dataType,
                    DegreeVertexProgram.DEGREE),
            allSubLabelIds);
    Map<Serializable, Number> min = result.memory().get(MinMapReduce.class.getName());

    LOGGER.debug("Min = " + min.get(MapReduce.NullObject.instance()));
    LOGGER.info("MinMapReduce is done in " + (System.currentTimeMillis() - startTime) + " ms");
    return Optional.of(min.get(MapReduce.NullObject.instance()));
}
 
Example 4
Project: grakn   File: MaxQueryImpl.java   Source Code and License 6 votes vote down vote up
@Override
public Optional<Number> execute() {
    LOGGER.info("MaxMapReduce is called");
    long startTime = System.currentTimeMillis();

    initSubGraph();
    getAllSubTypes();

    AttributeType.DataType dataType = getDataTypeOfSelectedResourceTypes();
    if (!selectedResourceTypesHaveInstance(statisticsResourceLabels)) return Optional.empty();
    Set<LabelId> allSubLabelIds = convertLabelsToIds(getCombinedSubTypes());
    Set<LabelId> statisticsResourceLabelIds = convertLabelsToIds(statisticsResourceLabels);

    ComputerResult result = getGraphComputer().compute(
            new DegreeStatisticsVertexProgram(statisticsResourceLabelIds),
            new MaxMapReduce(statisticsResourceLabelIds, dataType,
                    DegreeVertexProgram.DEGREE),
            allSubLabelIds);
    Map<Serializable, Number> max = result.memory().get(MaxMapReduce.class.getName());

    LOGGER.debug("Max = " + max.get(MapReduce.NullObject.instance()));
    LOGGER.info("MaxMapReduce is done in " + (System.currentTimeMillis() - startTime) + " ms");
    return Optional.of(max.get(MapReduce.NullObject.instance()));
}
 
Example 5
Project: grakn   File: GraknComputerImpl.java   Source Code and License 6 votes vote down vote up
@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());
    }
}
 
Example 6
Project: LiteGraph   File: GiraphGraphComputer.java   Source Code and License 6 votes vote down vote up
private Future<ComputerResult> submitWithExecutor(final Executor exec) {
    final long startTime = System.currentTimeMillis();
    final Configuration apacheConfiguration = ConfUtil.makeApacheConfiguration(this.giraphConfiguration);
    return CompletableFuture.<ComputerResult>supplyAsync(() -> {
        try {
            this.loadJars(giraphConfiguration);
            ToolRunner.run(this, new String[]{});
        } catch (final Exception e) {
            //e.printStackTrace();
            throw new IllegalStateException(e.getMessage(), e);
        }
        this.memory.setRuntime(System.currentTimeMillis() - startTime);
        // clear properties that should not be propagated in an OLAP chain
        apacheConfiguration.clearProperty(Constants.GREMLIN_HADOOP_GRAPH_FILTER);
        apacheConfiguration.clearProperty(Constants.GREMLIN_HADOOP_VERTEX_PROGRAM_INTERCEPTOR);
        this.vertexProgramConfigurationKeys.forEach(apacheConfiguration::clearProperty); // clear out vertex program specific configurations
        return new DefaultComputerResult(InputOutputHelper.getOutputGraph(apacheConfiguration, this.resultGraph, this.persist), this.memory.asImmutable());
    }, exec);
}
 
Example 7
Project: tinkerpop   File: GiraphGraphComputer.java   Source Code and License 6 votes vote down vote up
private Future<ComputerResult> submitWithExecutor(final Executor exec) {
    final long startTime = System.currentTimeMillis();
    final Configuration apacheConfiguration = ConfUtil.makeApacheConfiguration(this.giraphConfiguration);
    return CompletableFuture.<ComputerResult>supplyAsync(() -> {
        try {
            this.loadJars(giraphConfiguration);
            ToolRunner.run(this, new String[]{});
        } catch (final Exception e) {
            //e.printStackTrace();
            throw new IllegalStateException(e.getMessage(), e);
        }
        this.memory.setRuntime(System.currentTimeMillis() - startTime);
        // clear properties that should not be propagated in an OLAP chain
        apacheConfiguration.clearProperty(Constants.GREMLIN_HADOOP_GRAPH_FILTER);
        apacheConfiguration.clearProperty(Constants.GREMLIN_HADOOP_VERTEX_PROGRAM_INTERCEPTOR);
        this.vertexProgramConfigurationKeys.forEach(apacheConfiguration::clearProperty); // clear out vertex program specific configurations
        return new DefaultComputerResult(InputOutputHelper.getOutputGraph(apacheConfiguration, this.resultGraph, this.persist), this.memory.asImmutable());
    }, exec);
}
 
Example 8
Project: janusgraph_tutorial   File: ComputeWeight.java   Source Code and License 5 votes vote down vote up
public static void main(String[] argv) throws InterruptedException, IOException {
  Graph hadoopGraph = null;

  try {
    LOGGER.info("Connect to the hadoop graph");
    hadoopGraph = GraphFactory.open(new PropertiesConfiguration(HADOOP_CONFIG_FILE));
    ComputeWeightVertexProgram.Builder builder = ComputeWeightVertexProgram.build().withRwGraphConfig(Schema.CONFIG_FILE);

    ComputerResult result = hadoopGraph.
        compute().
        program(
            builder.create(hadoopGraph)
        ).
        vertices(hasLabel(Schema.USER)).
        submit().get();
    result.close();
    hadoopGraph.close();
    Spark.close();

    hadoopGraph = null;
  } catch (Exception e) {
    e.printStackTrace();
    try {
      if (hadoopGraph != null) {
        hadoopGraph.close();
        Spark.close();
      }
    } catch (Exception e1) {
      System.err.println("Couldn't close graph or spark...");
    }
  }

  // we need to call this one or else the program will be waiting forever
  LOGGER.info("bye bye");
  System.exit(0);
}
 
Example 9
Project: grakn   File: KCoreQueryImpl.java   Source Code and License 5 votes vote down vote up
@Override
public Map<String, Set<String>> execute() {
    LOGGER.info("KCore query is started");
    long startTime = System.currentTimeMillis();

    if (k < 2) throw GraqlQueryException.kValueSmallerThanTwo();

    initSubGraph();
    getAllSubTypes();

    if (!selectedTypesHaveInstance()) {
        LOGGER.info("KCore query is finished in " + (System.currentTimeMillis() - startTime) + " ms");
        return Collections.emptyMap();
    }

    ComputerResult result;
    Set<LabelId> subLabelIds = convertLabelsToIds(subLabels);
    try {
        result = getGraphComputer().compute(
                new KCoreVertexProgram(k),
                new ClusterMemberMapReduce(KCoreVertexProgram.CLUSTER_LABEL),
                subLabelIds);
    } catch (NoResultException e) {
        LOGGER.info("KCore query is finished in " + (System.currentTimeMillis() - startTime) + " ms");
        return Collections.emptyMap();
    }

    LOGGER.info("KCore query is finished in " + (System.currentTimeMillis() - startTime) + " ms");
    return result.memory().get(ClusterMemberMapReduce.class.getName());
}
 
Example 10
Project: grakn   File: StdQueryImpl.java   Source Code and License 5 votes vote down vote up
@Override
public Optional<Double> execute() {
    LOGGER.info("StdMapReduce is called");
    long startTime = System.currentTimeMillis();

    initSubGraph();
    getAllSubTypes();

    AttributeType.DataType dataType = getDataTypeOfSelectedResourceTypes();
    if (!selectedResourceTypesHaveInstance(statisticsResourceLabels)) return Optional.empty();

    Set<LabelId> allSubLabelIds = convertLabelsToIds(getCombinedSubTypes());
    Set<LabelId> statisticsResourceLabelIds = convertLabelsToIds(statisticsResourceLabels);

    ComputerResult result = getGraphComputer().compute(
            new DegreeStatisticsVertexProgram(statisticsResourceLabelIds),
            new StdMapReduce(statisticsResourceLabelIds, dataType,
                    DegreeVertexProgram.DEGREE),
            allSubLabelIds);
    Map<Serializable, Map<String, Double>> std = result.memory().get(StdMapReduce.class.getName());
    Map<String, Double> stdTuple = std.get(MapReduce.NullObject.instance());
    double squareSum = stdTuple.get(StdMapReduce.SQUARE_SUM);
    double sum = stdTuple.get(StdMapReduce.SUM);
    double count = stdTuple.get(StdMapReduce.COUNT);

    double finalResult = Math.sqrt(squareSum / count - (sum / count) * (sum / count));
    LOGGER.debug("Std = " + finalResult);

    LOGGER.info("StdMapReduce is done in " + (System.currentTimeMillis() - startTime) + " ms");
    return Optional.of(finalResult);
}
 
Example 11
Project: grakn   File: MeanQueryImpl.java   Source Code and License 5 votes vote down vote up
@Override
public Optional<Double> execute() {
    LOGGER.info("MeanMapReduce is called");
    long startTime = System.currentTimeMillis();

    initSubGraph();
    getAllSubTypes();

    AttributeType.DataType dataType = getDataTypeOfSelectedResourceTypes();
    if (!selectedResourceTypesHaveInstance(statisticsResourceLabels)) return Optional.empty();
    Set<LabelId> allSubLabelIds = convertLabelsToIds(getCombinedSubTypes());
    Set<LabelId> statisticsResourceLabelIds = convertLabelsToIds(statisticsResourceLabels);

    ComputerResult result = getGraphComputer().compute(
            new DegreeStatisticsVertexProgram(statisticsResourceLabelIds),
            new MeanMapReduce(statisticsResourceLabelIds, dataType,
                    DegreeVertexProgram.DEGREE),
            allSubLabelIds);
    Map<Serializable, Map<String, Double>> mean = result.memory().get(MeanMapReduce.class.getName());
    Map<String, Double> meanPair = mean.get(MapReduce.NullObject.instance());

    double finalResult = meanPair.get(MeanMapReduce.SUM) / meanPair.get(MeanMapReduce.COUNT);
    LOGGER.debug("Mean = " + finalResult);

    LOGGER.info("MeanMapReduce is done in " + (System.currentTimeMillis() - startTime) + " ms");
    return Optional.of(finalResult);
}
 
Example 12
Project: grakn   File: DegreeQueryImpl.java   Source Code and License 5 votes vote down vote up
@Override
public Map<Long, Set<String>> execute() {
    LOGGER.info("DegreeVertexProgram is called");
    long startTime = System.currentTimeMillis();

    initSubGraph();
    getAllSubTypes();

    // Check if ofType is valid before returning emptyMap
    if (ofLabels.isEmpty()) {
        ofLabels.addAll(subLabels);
    } else {
        ofLabels = ofLabels.stream()
                .flatMap(typeLabel -> {
                    Type type = tx.get().getSchemaConcept(typeLabel);
                    if (type == null) throw GraqlQueryException.labelNotFound(typeLabel);
                    return type.subs();
                })
                .map(SchemaConcept::getLabel)
                .collect(Collectors.toSet());
        subLabels.addAll(ofLabels);
    }

    if (!selectedTypesHaveInstance()) return Collections.emptyMap();

    Set<LabelId> subLabelIds = convertLabelsToIds(subLabels);
    Set<LabelId> ofLabelIds = convertLabelsToIds(ofLabels);

    ComputerResult result = getGraphComputer().compute(
            new DegreeVertexProgram(ofLabelIds),
            new DegreeDistributionMapReduce(ofLabelIds, DegreeVertexProgram.DEGREE),
            subLabelIds);

    LOGGER.info("DegreeVertexProgram is done in " + (System.currentTimeMillis() - startTime) + " ms");
    return result.memory().get(DegreeDistributionMapReduce.class.getName());
}
 
Example 13
Project: grakn   File: PathsQueryImpl.java   Source Code and License 5 votes vote down vote up
@Override
public List<List<Concept>> execute() {
    LOGGER.info("ShortestPathVertexProgram is called");
    long startTime = System.currentTimeMillis();

    if (sourceId == null) throw GraqlQueryException.noPathSource();
    if (destinationId == null) throw GraqlQueryException.noPathDestination();
    initSubGraph();
    getAllSubTypes();

    if (!verticesExistInSubgraph(sourceId, destinationId)) {
        throw GraqlQueryException.instanceDoesNotExist();
    }
    if (sourceId.equals(destinationId)) {
        return Collections.singletonList(Collections.singletonList(tx.get().getConcept(sourceId)));
    }

    ComputerResult result;
    Set<LabelId> subLabelIds = convertLabelsToIds(subLabels);
    try {
        result = getGraphComputer().compute(
                new ShortestPathVertexProgram(sourceId, destinationId), null, subLabelIds);
    } catch (NoResultException e) {
        LOGGER.info("ShortestPathVertexProgram is done in " + (System.currentTimeMillis() - startTime) + " ms");
        return Collections.emptyList();
    }

    Multimap<Concept, Concept> predecessorMapFromSource = getPredecessorMap(result);
    List<List<Concept>> allPaths = getAllPaths(predecessorMapFromSource);
    if (includeAttribute) { // this can be slow
        return getExtendedPaths(allPaths);
    }

    LOGGER.info("Number of paths: " + allPaths.size());
    LOGGER.info("ShortestPathVertexProgram is done in " + (System.currentTimeMillis() - startTime) + " ms");
    return allPaths;
}
 
Example 14
Project: grakn   File: PathsQueryImpl.java   Source Code and License 5 votes vote down vote up
private Multimap<Concept, Concept> getPredecessorMap(ComputerResult result) {
    Map<String, Set<String>> predecessorMapFromSource =
            result.memory().get(ShortestPathVertexProgram.PREDECESSORS_FROM_SOURCE);
    Map<String, Set<String>> predecessorMapFromDestination =
            result.memory().get(ShortestPathVertexProgram.PREDECESSORS_FROM_DESTINATION);

    Multimap<Concept, Concept> predecessors = HashMultimap.create();
    predecessorMapFromSource.forEach((id, idSet) -> idSet.forEach(id2 -> {
        predecessors.put(getConcept(id), getConcept(id2));
    }));
    predecessorMapFromDestination.forEach((id, idSet) -> idSet.forEach(id2 -> {
        predecessors.put(getConcept(id2), getConcept(id));
    }));
    return predecessors;
}
 
Example 15
Project: grakn   File: GraknSparkComputer.java   Source Code and License 5 votes vote down vote up
@Override
public Future<ComputerResult> submit() {
    this.validateStatePriorToExecution();

    return ComputerSubmissionHelper
            .runWithBackgroundThread(this::submitWithExecutor, "SparkSubmitter");
}
 
Example 16
Project: LiteGraph   File: AbstractStorageCheck.java   Source Code and License 5 votes vote down vote up
public void checkHeadMethods(final Storage storage, final String inputLocation, final String outputLocation, final Class outputGraphParserClass, final Class outputMemoryParserClass) throws Exception {
    // TEST INPUT GRAPH
    assertFalse(storage.exists(outputLocation));
    if (inputLocation.endsWith(".json") && storage.exists(inputLocation)) { // gryo is not text readable
        assertEquals(6, IteratorUtils.count(storage.head(inputLocation)));
        for (int i = 0; i < 7; i++) {
            assertEquals(i, IteratorUtils.count(storage.head(inputLocation, i)));
        }
        assertEquals(6, IteratorUtils.count(storage.head(inputLocation, 10)));
    }

    ////////////////////

    final ComputerResult result = graphProvider.getGraphComputer(graph).program(PeerPressureVertexProgram.build().create(graph)).mapReduce(ClusterCountMapReduce.build().memoryKey("clusterCount").create()).submit().get();
    // TEST OUTPUT GRAPH
    assertTrue(storage.exists(outputLocation));
    assertTrue(storage.exists(Constants.getGraphLocation(outputLocation)));
    assertEquals(6, result.graph().traversal().V().count().next().longValue());
    assertEquals(0, result.graph().traversal().E().count().next().longValue());
    assertEquals(6, result.graph().traversal().V().values("name").count().next().longValue());
    assertEquals(6, result.graph().traversal().V().values(PeerPressureVertexProgram.CLUSTER).count().next().longValue());
    assertEquals(2, result.graph().traversal().V().values(PeerPressureVertexProgram.CLUSTER).dedup().count().next().longValue());
    assertEquals(6, IteratorUtils.count(storage.head(Constants.getGraphLocation(outputLocation), outputGraphParserClass)));
    for (int i = 0; i < 7; i++) {
        assertEquals(i, IteratorUtils.count(storage.head(Constants.getGraphLocation(outputLocation), outputGraphParserClass, i)));
    }
    assertEquals(6, IteratorUtils.count(storage.head(Constants.getGraphLocation(outputLocation), outputGraphParserClass, 346)));
    /////
    // TEST MEMORY PERSISTENCE
    assertEquals(2, (int) result.memory().get("clusterCount"));
    assertTrue(storage.exists(Constants.getMemoryLocation(outputLocation, "clusterCount")));
    assertEquals(1, IteratorUtils.count(storage.head(outputLocation, "clusterCount", outputMemoryParserClass)));
    assertEquals(2, storage.head(outputLocation, "clusterCount", outputMemoryParserClass).next().getValue());
}
 
Example 17
Project: LiteGraph   File: ComputerResultStep.java   Source Code and License 5 votes vote down vote up
@Override
protected Traverser.Admin<S> processNextStart() throws NoSuchElementException {
    while (true) {
        if (this.currentIterator.hasNext())
            return this.currentIterator.next();
        else {
            final ComputerResult result = this.starts.next().get();
            this.currentIterator = attach(result.memory().<TraverserSet<S>>get(TraversalVertexProgram.HALTED_TRAVERSERS).iterator(), result.graph());
        }
    }
}
 
Example 18
Project: LiteGraph   File: PageRankVertexProgramTest.java   Source Code and License 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void shouldExecutePageRank() throws Exception {
    if (graphProvider.getGraphComputer(graph).features().supportsResultGraphPersistCombination(GraphComputer.ResultGraph.NEW, GraphComputer.Persist.VERTEX_PROPERTIES)) {
        final ComputerResult result = graph.compute(graphProvider.getGraphComputer(graph).getClass()).program(PageRankVertexProgram.build().create(graph)).submit().get();
        result.graph().traversal().V().forEachRemaining(v -> {
            assertEquals(3, v.keys().size()); // name, age/lang, pageRank
            assertTrue(v.keys().contains("name"));
            assertTrue(v.keys().contains(PageRankVertexProgram.PAGE_RANK));
            assertEquals(1, IteratorUtils.count(v.values("name")));
            assertEquals(1, IteratorUtils.count(v.values(PageRankVertexProgram.PAGE_RANK)));
            final String name = v.value("name");
            final Double pageRank = v.value(PageRankVertexProgram.PAGE_RANK);
            //System.out.println(name + "-----" + pageRank);
            if (name.equals("marko"))
                assertTrue(pageRank > 0.14 && pageRank < 0.16);
            else if (name.equals("vadas"))
                assertTrue(pageRank > 0.19 && pageRank < 0.20);
            else if (name.equals("lop"))
                assertTrue(pageRank > 0.40 && pageRank < 0.41);
            else if (name.equals("josh"))
                assertTrue(pageRank > 0.19 && pageRank < 0.20);
            else if (name.equals("ripple"))
                assertTrue(pageRank > 0.23 && pageRank < 0.24);
            else if (name.equals("peter"))
                assertTrue(pageRank > 0.14 && pageRank < 0.16);
            else
                throw new IllegalStateException("The following vertex should not exist in the graph: " + name);
        });
        assertEquals(result.memory().getIteration(), 30);
        assertEquals(result.memory().asMap().size(), 0);
    }
}
 
Example 19
Project: tinkerpop   File: AbstractStorageCheck.java   Source Code and License 5 votes vote down vote up
public void checkHeadMethods(final Storage storage, final String inputLocation, final String outputLocation, final Class outputGraphParserClass, final Class outputMemoryParserClass) throws Exception {
    // TEST INPUT GRAPH
    assertFalse(storage.exists(outputLocation));
    if (inputLocation.endsWith(".json") && storage.exists(inputLocation)) { // gryo is not text readable
        assertEquals(6, IteratorUtils.count(storage.head(inputLocation)));
        for (int i = 0; i < 7; i++) {
            assertEquals(i, IteratorUtils.count(storage.head(inputLocation, i)));
        }
        assertEquals(6, IteratorUtils.count(storage.head(inputLocation, 10)));
    }

    ////////////////////

    final ComputerResult result = graphProvider.getGraphComputer(graph).program(PeerPressureVertexProgram.build().create(graph)).mapReduce(ClusterCountMapReduce.build().memoryKey("clusterCount").create()).submit().get();
    // TEST OUTPUT GRAPH
    assertTrue(storage.exists(outputLocation));
    assertTrue(storage.exists(Constants.getGraphLocation(outputLocation)));
    assertEquals(6, result.graph().traversal().V().count().next().longValue());
    assertEquals(0, result.graph().traversal().E().count().next().longValue());
    assertEquals(6, result.graph().traversal().V().values("name").count().next().longValue());
    assertEquals(6, result.graph().traversal().V().values(PeerPressureVertexProgram.CLUSTER).count().next().longValue());
    assertEquals(2, result.graph().traversal().V().values(PeerPressureVertexProgram.CLUSTER).dedup().count().next().longValue());
    assertEquals(6, IteratorUtils.count(storage.head(Constants.getGraphLocation(outputLocation), outputGraphParserClass)));
    for (int i = 0; i < 7; i++) {
        assertEquals(i, IteratorUtils.count(storage.head(Constants.getGraphLocation(outputLocation), outputGraphParserClass, i)));
    }
    assertEquals(6, IteratorUtils.count(storage.head(Constants.getGraphLocation(outputLocation), outputGraphParserClass, 346)));
    /////
    // TEST MEMORY PERSISTENCE
    assertEquals(2, (int) result.memory().get("clusterCount"));
    assertTrue(storage.exists(Constants.getMemoryLocation(outputLocation, "clusterCount")));
    assertEquals(1, IteratorUtils.count(storage.head(outputLocation, "clusterCount", outputMemoryParserClass)));
    assertEquals(2, storage.head(outputLocation, "clusterCount", outputMemoryParserClass).next().getValue());
}
 
Example 20
Project: tinkerpop   File: ComputerResultStep.java   Source Code and License 5 votes vote down vote up
@Override
protected Traverser.Admin<S> processNextStart() throws NoSuchElementException {
    while (true) {
        if (this.currentIterator.hasNext())
            return this.currentIterator.next();
        else {
            final ComputerResult result = this.starts.next().get();
            this.currentIterator = attach(result.memory().<TraverserSet<S>>get(TraversalVertexProgram.HALTED_TRAVERSERS).iterator(), result.graph());
        }
    }
}
 
Example 21
Project: tinkerpop   File: PageRankVertexProgramTest.java   Source Code and License 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void shouldExecutePageRankWithIterationsBreak() throws Exception {
    if (graphProvider.getGraphComputer(graph).features().supportsResultGraphPersistCombination(GraphComputer.ResultGraph.NEW, GraphComputer.Persist.VERTEX_PROPERTIES)) {
        final ComputerResult result = graph.compute(graphProvider.getGraphComputer(graph).getClass()).
                program(PageRankVertexProgram.build().epsilon(0.0d).iterations(30).create(graph)).submit().get(); // by using epsilon 0.0, we guarantee iterations 30
        result.graph().traversal().V().forEachRemaining(v -> {
            assertEquals(3, v.keys().size()); // name, age/lang, pageRank
            assertTrue(v.keys().contains("name"));
            assertTrue(v.keys().contains(PageRankVertexProgram.PAGE_RANK));
            assertEquals(1, IteratorUtils.count(v.values("name")));
            assertEquals(1, IteratorUtils.count(v.values(PageRankVertexProgram.PAGE_RANK)));
            final String name = v.value("name");
            final Double pageRank = v.value(PageRankVertexProgram.PAGE_RANK);
            //System.out.println(name + "-----" + pageRank);
            if (name.equals("marko"))
                assertTrue(pageRank > 0.10 && pageRank < 0.12);
            else if (name.equals("vadas"))
                assertTrue(pageRank > 0.13 && pageRank < 0.15);
            else if (name.equals("lop"))
                assertTrue(pageRank > 0.29 && pageRank < 0.31);
            else if (name.equals("josh"))
                assertTrue(pageRank > 0.13 && pageRank < 0.15);
            else if (name.equals("ripple"))
                assertTrue(pageRank > 0.16 && pageRank < 0.18);
            else if (name.equals("peter"))
                assertTrue(pageRank > 0.10 && pageRank < 0.12);
            else
                throw new IllegalStateException("The following vertex should not exist in the graph: " + name);
        });
        assertEquals(result.memory().getIteration(), 30);
        assertEquals(result.memory().asMap().size(), 0);
    }
}
 
Example 22
Project: tinkerpop   File: PageRankVertexProgramTest.java   Source Code and License 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void shouldExecutePageRankWithEpsilonBreak() throws Exception {
    if (graphProvider.getGraphComputer(graph).features().supportsResultGraphPersistCombination(GraphComputer.ResultGraph.NEW, GraphComputer.Persist.VERTEX_PROPERTIES)) {
        final ComputerResult result = graph.compute(graphProvider.getGraphComputer(graph).getClass()).
                program(PageRankVertexProgram.build().epsilon(0.00001d).iterations(30).create(graph)).submit().get(); // by using epsilon 0.00001, we should get iterations 11
        result.graph().traversal().V().forEachRemaining(v -> {
            assertEquals(3, v.keys().size()); // name, age/lang, pageRank
            assertTrue(v.keys().contains("name"));
            assertTrue(v.keys().contains(PageRankVertexProgram.PAGE_RANK));
            assertEquals(1, IteratorUtils.count(v.values("name")));
            assertEquals(1, IteratorUtils.count(v.values(PageRankVertexProgram.PAGE_RANK)));
            final String name = v.value("name");
            final Double pageRank = v.value(PageRankVertexProgram.PAGE_RANK);
            //System.out.println(name + "-----" + pageRank);
            if (name.equals("marko"))
                assertTrue(pageRank > 0.10 && pageRank < 0.12);
            else if (name.equals("vadas"))
                assertTrue(pageRank > 0.13 && pageRank < 0.15);
            else if (name.equals("lop"))
                assertTrue(pageRank > 0.29 && pageRank < 0.31);
            else if (name.equals("josh"))
                assertTrue(pageRank > 0.13 && pageRank < 0.15);
            else if (name.equals("ripple"))
                assertTrue(pageRank > 0.16 && pageRank < 0.18);
            else if (name.equals("peter"))
                assertTrue(pageRank > 0.10 && pageRank < 0.12);
            else
                throw new IllegalStateException("The following vertex should not exist in the graph: " + name);
        });
        assertEquals(result.memory().getIteration(), 11);
        assertEquals(result.memory().asMap().size(), 0);
    }
}
 
Example 23
Project: tinkerpop   File: PageRankVertexProgramTest.java   Source Code and License 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void shouldExecutePageRankWithEnergyConservation() throws Exception {
    final ComputerResult result = graph.compute(graphProvider.getGraphComputer(graph).getClass()).program(PageRankVertexProgram.build().create(graph)).submit().get();
    final double sum = result.graph().traversal().V().values(PageRankVertexProgram.PAGE_RANK).sum().next().doubleValue();
    assertEquals(1.0d, sum, 0.01d);
}
 
Example 24
Project: grakn   File: GraknComputerImpl.java   Source Code and License 4 votes vote down vote up
@Override
public ComputerResult compute(@Nullable VertexProgram program, @Nullable MapReduce mapReduce,
                              @Nullable Set<LabelId> types) {
    return compute(program, mapReduce, types, true);
}
 
Example 25
Project: LiteGraph   File: ComputerSubmissionHelper.java   Source Code and License 4 votes vote down vote up
/**
 * Creates a {@link Executors#newSingleThreadExecutor(ThreadFactory)} configured
 * make threads that behave like the caller, invokes a closure on it, and shuts it down.
 * <p>
 * This is intended to serve as an alternative to {@link ForkJoinPool#commonPool()},
 * which is used by {@link CompletableFuture#supplyAsync(Supplier)} (among other methods).
 * The the single threaded executor created by this method contains a thread
 * with the same context classloader and thread group as the thread that called
 * this method.  Threads created in this method also have predictable behavior when
 * {@link Thread#setContextClassLoader(ClassLoader)} is invoked; threads in the
 * common pool throw a SecurityException if the JVM has a security manager configured.
 * <p>
 * The name of the thread created by this method's internal executor is the concatenation of
 * <ul>
 *     <li>the name of the thread that calls this method</li>
 *     <li>"-TP-"</li>
 *     <li>the {@code threadNameSuffix} parameter value</li>
 * </ul>
 *
 * @param closure arbitrary code that has exclusive use of the supplied executor
 * @param threadNameSuffix a string appended to the executor's thread's name
 * @return the return value of the {@code closure} parameter
 */
public static Future<ComputerResult> runWithBackgroundThread(Function<Executor, Future<ComputerResult>> closure,
                                                             String threadNameSuffix) {
    final Thread callingThread = Thread.currentThread();
    final ClassLoader classLoader = callingThread.getContextClassLoader();
    final ThreadGroup threadGroup = callingThread.getThreadGroup();
    final String threadName = callingThread.getName();
    ExecutorService submissionExecutor = null;

    try {
        submissionExecutor = Executors.newSingleThreadExecutor(runnable -> {
            Thread t = new Thread(threadGroup, runnable, threadName + "-TP-" + threadNameSuffix);
            t.setContextClassLoader(classLoader);
            return t;
        });

        return closure.apply(submissionExecutor);
    } finally {
        if (null != submissionExecutor)
            submissionExecutor.shutdown(); // do not call shutdownNow, which could prematurely terminate the closure
    }
}
 
Example 26
Project: LiteGraph   File: StringFactory.java   Source Code and License 4 votes vote down vote up
public static String computeResultString(final ComputerResult computerResult) {
    return "result" + L_BRACKET + computerResult.graph() + ',' + computerResult.memory() + R_BRACKET;
}
 
Example 27
Project: LiteGraph   File: BulkDumperVertexProgramTest.java   Source Code and License 4 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void shouldDumpWholeGraph() throws Exception {
    if (graphProvider.getGraphComputer(graph).features().supportsResultGraphPersistCombination(GraphComputer.ResultGraph.NEW, GraphComputer.Persist.EDGES)) {
        final ComputerResult result = graphProvider.getGraphComputer(graph).program(BulkDumperVertexProgram.build().create(graph)).submit().get();
        result.graph().traversal().V().forEachRemaining(v -> {
            assertEquals(2, v.keys().size());
            assertTrue(v.keys().contains("name"));
            assertTrue(v.keys().contains("age") || v.keys().contains("lang"));
            assertEquals(1, IteratorUtils.count(v.values("name")));
            assertEquals(1, IteratorUtils.count(v.values("age", "lang")));
            final String name = v.value("name");
            if (name.equals("marko")) {
                assertEquals(1, v.id());
                assertEquals("person", v.label());
                assertEquals(Integer.valueOf(29), v.value("age"));
                assertEquals(3, IteratorUtils.count(v.edges(Direction.OUT)));
                assertEquals(2, IteratorUtils.count(v.edges(Direction.OUT, "knows")));
                assertEquals(1, IteratorUtils.count(v.edges(Direction.OUT, "created")));
                assertEquals(0, IteratorUtils.count(v.edges(Direction.IN)));
            } else if (name.equals("vadas")) {
                assertEquals(2, v.id());
                assertEquals("person", v.label());
                assertEquals(Integer.valueOf(27), v.value("age"));
                assertEquals(0, IteratorUtils.count(v.edges(Direction.OUT)));
                assertEquals(1, IteratorUtils.count(v.edges(Direction.IN)));
                assertEquals(1, IteratorUtils.count(v.edges(Direction.IN, "knows")));
            } else if (name.equals("lop")) {
                assertEquals(3, v.id());
                assertEquals("software", v.label());
                assertEquals("java", v.value("lang"));
                assertEquals(0, IteratorUtils.count(v.edges(Direction.OUT)));
                assertEquals(3, IteratorUtils.count(v.edges(Direction.IN)));
                assertEquals(3, IteratorUtils.count(v.edges(Direction.IN, "created")));
            } else if (name.equals("josh")) {
                assertEquals(4, v.id());
                assertEquals("person", v.label());
                assertEquals(Integer.valueOf(32), v.value("age"));
                assertEquals(2, IteratorUtils.count(v.edges(Direction.OUT)));
                assertEquals(2, IteratorUtils.count(v.edges(Direction.OUT, "created")));
                assertEquals(1, IteratorUtils.count(v.edges(Direction.IN)));
                assertEquals(1, IteratorUtils.count(v.edges(Direction.IN, "knows")));
            } else if (name.equals("ripple")) {
                assertEquals(5, v.id());
                assertEquals("software", v.label());
                assertEquals("java", v.value("lang"));
                assertEquals(0, IteratorUtils.count(v.edges(Direction.OUT)));
                assertEquals(1, IteratorUtils.count(v.edges(Direction.IN)));
                assertEquals(1, IteratorUtils.count(v.edges(Direction.IN, "created")));
            } else if (name.equals("peter")) {
                assertEquals(6, v.id());
                assertEquals("person", v.label());
                assertEquals(Integer.valueOf(35), v.value("age"));
                assertEquals(1, IteratorUtils.count(v.edges(Direction.OUT)));
                assertEquals(1, IteratorUtils.count(v.edges(Direction.OUT, "created")));
                assertEquals(0, IteratorUtils.count(v.edges(Direction.IN)));
            } else
                throw new IllegalStateException("The following vertex should not exist in the graph: " + name);
        });
        assertEquals(3.5, (Double) result.graph().traversal().E().values("weight").sum().next(), 0.01);
        assertEquals(1.5, (Double) result.graph().traversal().E().hasLabel("knows").values("weight").sum().next(), 0.01);
        assertEquals(2.0, (Double) result.graph().traversal().E().hasLabel("created").values("weight").sum().next(), 0.01);
        assertEquals(result.memory().getIteration(), 0);
        assertEquals(result.memory().asMap().size(), 0);
    }
}
 
Example 28
Project: LiteGraph   File: GiraphGraphComputer.java   Source Code and License 4 votes vote down vote up
@Override
public Future<ComputerResult> submit() {
    super.validateStatePriorToExecution();
    return ComputerSubmissionHelper.runWithBackgroundThread(this::submitWithExecutor, "GiraphSubmitter");
}
 
Example 29
Project: LiteGraph   File: SparkGraphComputer.java   Source Code and License 4 votes vote down vote up
@Override
public Future<ComputerResult> submit() {
    this.validateStatePriorToExecution();
    return ComputerSubmissionHelper.runWithBackgroundThread(this::submitWithExecutor, "SparkSubmitter");
}
 
Example 30
Project: titan1withtp3.1   File: TitanPartitionGraphTest.java   Source Code and License 4 votes vote down vote up
private void testVertexPartitionOlap(CommitMode commitMode) throws Exception {
        Object[] options = {option(GraphDatabaseConfiguration.IDS_FLUSH), false};
        clopen(options);

//        int[] groupDegrees = {10,20,30};
        int[] groupDegrees = {2};

        int numVertices = setupGroupClusters(groupDegrees,commitMode);

        Map<Long,Integer> degreeMap = new HashMap<>(groupDegrees.length);
        for (int i = 0; i < groupDegrees.length; i++) {
            degreeMap.put(getOnlyVertex(tx.query().has("groupid","group"+i)).longId(),groupDegrees[i]);
        }

        clopen(options);

        //Test OLAP works with partitioned vertices
        TitanGraphComputer computer = graph.compute(FulgoraGraphComputer.class);
        computer.resultMode(TitanGraphComputer.ResultMode.NONE);
        computer.workers(1);
        computer.program(new OLAPTest.DegreeCounter());
        computer.mapReduce(new OLAPTest.DegreeMapper());
        ComputerResult result = computer.submit().get();

        assertTrue(result.memory().exists(OLAPTest.DegreeMapper.DEGREE_RESULT));
        Map<Long,Integer> degrees = result.memory().get(OLAPTest.DegreeMapper.DEGREE_RESULT);
        assertNotNull(degrees);
        assertEquals(numVertices,degrees.size());
        final IDManager idManager = graph.getIDManager();

        for (Map.Entry<Long,Integer> entry : degrees.entrySet()) {
            long vid = entry.getKey();
            Integer degree = entry.getValue();
            if (idManager.isPartitionedVertex(vid)) {
//                System.out.println("Partitioned: " + degree );
                assertEquals(degreeMap.get(vid),degree);
            } else {
                assertEquals(1, (long) degree);
            }
        }
    }
 
Example 31
Project: titan1.0.1.kafka   File: TitanPartitionGraphTest.java   Source Code and License 4 votes vote down vote up
private void testVertexPartitionOlap(CommitMode commitMode) throws Exception {
        Object[] options = {option(GraphDatabaseConfiguration.IDS_FLUSH), false};
        clopen(options);

//        int[] groupDegrees = {10,20,30};
        int[] groupDegrees = {2};

        int numVertices = setupGroupClusters(groupDegrees,commitMode);

        Map<Long,Integer> degreeMap = new HashMap<>(groupDegrees.length);
        for (int i = 0; i < groupDegrees.length; i++) {
            degreeMap.put(getOnlyVertex(tx.query().has("groupid","group"+i)).longId(),groupDegrees[i]);
        }

        clopen(options);

        //Test OLAP works with partitioned vertices
        TitanGraphComputer computer = graph.compute(FulgoraGraphComputer.class);
        computer.resultMode(TitanGraphComputer.ResultMode.NONE);
        computer.workers(1);
        computer.program(new OLAPTest.DegreeCounter());
        computer.mapReduce(new OLAPTest.DegreeMapper());
        ComputerResult result = computer.submit().get();

        assertTrue(result.memory().exists(OLAPTest.DegreeMapper.DEGREE_RESULT));
        Map<Long,Integer> degrees = result.memory().get(OLAPTest.DegreeMapper.DEGREE_RESULT);
        assertNotNull(degrees);
        assertEquals(numVertices,degrees.size());
        final IDManager idManager = graph.getIDManager();

        for (Map.Entry<Long,Integer> entry : degrees.entrySet()) {
            long vid = entry.getKey();
            Integer degree = entry.getValue();
            if (idManager.isPartitionedVertex(vid)) {
//                System.out.println("Partitioned: " + degree );
                assertEquals(degreeMap.get(vid),degree);
            } else {
                assertEquals(1, (long) degree);
            }
        }
    }
 
Example 32
Project: tinkerpop   File: ComputerSubmissionHelper.java   Source Code and License 4 votes vote down vote up
/**
 * Creates a {@link Executors#newSingleThreadExecutor(ThreadFactory)} configured
 * make threads that behave like the caller, invokes a closure on it, and shuts it down.
 * <p>
 * This is intended to serve as an alternative to {@link ForkJoinPool#commonPool()},
 * which is used by {@link CompletableFuture#supplyAsync(Supplier)} (among other methods).
 * The single threaded executor created by this method contains a thread
 * with the same context classloader and thread group as the thread that called
 * this method.  Threads created in this method also have predictable behavior when
 * {@link Thread#setContextClassLoader(ClassLoader)} is invoked; threads in the
 * common pool throw a SecurityException if the JVM has a security manager configured.
 * <p>
 * The name of the thread created by this method's internal executor is the concatenation of
 * <ul>
 *     <li>the name of the thread that calls this method</li>
 *     <li>"-TP-"</li>
 *     <li>the {@code threadNameSuffix} parameter value</li>
 * </ul>
 *
 * @param closure arbitrary code that has exclusive use of the supplied executor
 * @param threadNameSuffix a string appended to the executor's thread's name
 * @return the return value of the {@code closure} parameter
 */
public static Future<ComputerResult> runWithBackgroundThread(Function<Executor, Future<ComputerResult>> closure,
                                                             String threadNameSuffix) {
    final Thread callingThread = Thread.currentThread();
    final ClassLoader classLoader = callingThread.getContextClassLoader();
    final ThreadGroup threadGroup = callingThread.getThreadGroup();
    final String threadName = callingThread.getName();
    ExecutorService submissionExecutor = null;

    try {
        submissionExecutor = Executors.newSingleThreadExecutor(runnable -> {
            Thread t = new Thread(threadGroup, runnable, threadName + "-TP-" + threadNameSuffix);
            t.setContextClassLoader(classLoader);
            return t;
        });

        return closure.apply(submissionExecutor);
    } finally {
        if (null != submissionExecutor)
            submissionExecutor.shutdown(); // do not call shutdownNow, which could prematurely terminate the closure
    }
}
 
Example 33
Project: tinkerpop   File: StringFactory.java   Source Code and License 4 votes vote down vote up
public static String computeResultString(final ComputerResult computerResult) {
    return "result" + L_BRACKET + computerResult.graph() + ',' + computerResult.memory() + R_BRACKET;
}
 
Example 34
Project: tinkerpop   File: TraversalStrategiesTest.java   Source Code and License 4 votes vote down vote up
@Override
public Future<ComputerResult> submit() {
    return new CompletableFuture<>();
}
 
Example 35
Project: tinkerpop   File: BulkDumperVertexProgramTest.java   Source Code and License 4 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void shouldDumpWholeGraph() throws Exception {
    if (graphProvider.getGraphComputer(graph).features().supportsResultGraphPersistCombination(GraphComputer.ResultGraph.NEW, GraphComputer.Persist.EDGES)) {
        final ComputerResult result = graphProvider.getGraphComputer(graph).program(BulkDumperVertexProgram.build().create(graph)).submit().get();
        result.graph().traversal().V().forEachRemaining(v -> {
            assertEquals(2, v.keys().size());
            assertTrue(v.keys().contains("name"));
            assertTrue(v.keys().contains("age") || v.keys().contains("lang"));
            assertEquals(1, IteratorUtils.count(v.values("name")));
            assertEquals(1, IteratorUtils.count(v.values("age", "lang")));
            final String name = v.value("name");
            if (name.equals("marko")) {
                assertEquals("person", v.label());
                assertEquals(Integer.valueOf(29), v.value("age"));
                assertEquals(3, IteratorUtils.count(v.edges(Direction.OUT)));
                assertEquals(2, IteratorUtils.count(v.edges(Direction.OUT, "knows")));
                assertEquals(1, IteratorUtils.count(v.edges(Direction.OUT, "created")));
                assertEquals(0, IteratorUtils.count(v.edges(Direction.IN)));
            } else if (name.equals("vadas")) {
                assertEquals("person", v.label());
                assertEquals(Integer.valueOf(27), v.value("age"));
                assertEquals(0, IteratorUtils.count(v.edges(Direction.OUT)));
                assertEquals(1, IteratorUtils.count(v.edges(Direction.IN)));
                assertEquals(1, IteratorUtils.count(v.edges(Direction.IN, "knows")));
            } else if (name.equals("lop")) {
                assertEquals("software", v.label());
                assertEquals("java", v.value("lang"));
                assertEquals(0, IteratorUtils.count(v.edges(Direction.OUT)));
                assertEquals(3, IteratorUtils.count(v.edges(Direction.IN)));
                assertEquals(3, IteratorUtils.count(v.edges(Direction.IN, "created")));
            } else if (name.equals("josh")) {
                assertEquals("person", v.label());
                assertEquals(Integer.valueOf(32), v.value("age"));
                assertEquals(2, IteratorUtils.count(v.edges(Direction.OUT)));
                assertEquals(2, IteratorUtils.count(v.edges(Direction.OUT, "created")));
                assertEquals(1, IteratorUtils.count(v.edges(Direction.IN)));
                assertEquals(1, IteratorUtils.count(v.edges(Direction.IN, "knows")));
            } else if (name.equals("ripple")) {
                assertEquals("software", v.label());
                assertEquals("java", v.value("lang"));
                assertEquals(0, IteratorUtils.count(v.edges(Direction.OUT)));
                assertEquals(1, IteratorUtils.count(v.edges(Direction.IN)));
                assertEquals(1, IteratorUtils.count(v.edges(Direction.IN, "created")));
            } else if (name.equals("peter")) {
                assertEquals("person", v.label());
                assertEquals(Integer.valueOf(35), v.value("age"));
                assertEquals(1, IteratorUtils.count(v.edges(Direction.OUT)));
                assertEquals(1, IteratorUtils.count(v.edges(Direction.OUT, "created")));
                assertEquals(0, IteratorUtils.count(v.edges(Direction.IN)));
            } else
                throw new IllegalStateException("The following vertex should not exist in the graph: " + name);
        });
        assertEquals(3.5, (Double) result.graph().traversal().E().values("weight").sum().next(), 0.01);
        assertEquals(1.5, (Double) result.graph().traversal().E().hasLabel("knows").values("weight").sum().next(), 0.01);
        assertEquals(2.0, (Double) result.graph().traversal().E().hasLabel("created").values("weight").sum().next(), 0.01);
        assertEquals(result.memory().getIteration(), 0);
        assertEquals(result.memory().asMap().size(), 0);
    }
}
 
Example 36
Project: tinkerpop   File: GiraphGraphComputer.java   Source Code and License 4 votes vote down vote up
@Override
public Future<ComputerResult> submit() {
    super.validateStatePriorToExecution();
    return ComputerSubmissionHelper.runWithBackgroundThread(this::submitWithExecutor, "GiraphSubmitter");
}
 
Example 37
Project: tinkerpop   File: SparkGraphComputer.java   Source Code and License 4 votes vote down vote up
@Override
public Future<ComputerResult> submit() {
    this.validateStatePriorToExecution();
    return ComputerSubmissionHelper.runWithBackgroundThread(this::submitWithExecutor, "SparkSubmitter");
}
 
Example 38
Project: grakn   File: GraknComputer.java   Source Code and License 2 votes vote down vote up
/**
 * Execute the given vertex program using a graph computer.
 *
 * @param includesRolePlayerEdges whether the graph computer should include {@link ai.grakn.util.Schema.EdgeLabel#ROLE_PLAYER} edges
 * @param types                   instance types in the subgraph
 * @param program                 the vertex program
 * @param mapReduce               a list of mapReduce job
 * @return the result of the computation
 * @see ComputerResult
 */
@CheckReturnValue
ComputerResult compute(@Nullable VertexProgram program, @Nullable MapReduce mapReduce,
                       @Nullable Set<LabelId> types, Boolean includesRolePlayerEdges);
 
Example 39
Project: grakn   File: GraknComputer.java   Source Code and License 2 votes vote down vote up
/**
 * Execute the given vertex program using a graph computer.
 *
 * @param types     instance types in the subgraph
 * @param program   the vertex program
 * @param mapReduce a list of mapReduce job
 * @return the result of the computation
 * @see ComputerResult
 */
@CheckReturnValue
ComputerResult compute(@Nullable VertexProgram program, @Nullable MapReduce mapReduce,
                       @Nullable Set<LabelId> types);