Search in sources :

Example 1 with ComputerOutput

use of com.baidu.hugegraph.computer.core.output.ComputerOutput in project hugegraph-computer by hugegraph.

the class FileGraphPartition method output.

protected PartitionStat output() {
    ComputerOutput output = this.context.config().createObject(ComputerOptions.OUTPUT_CLASS);
    output.init(this.context.config(), this.partition);
    try {
        this.beforeOutput();
    } catch (IOException e) {
        throw new ComputerException("Error occurred when beforeOutput", e);
    }
    Value result = this.context.config().createObject(ComputerOptions.ALGORITHM_RESULT_CLASS);
    while (this.vertexInput.hasNext()) {
        Vertex vertex = this.vertexInput.next();
        this.readVertexStatusAndValue(vertex, result);
        Edges edges = this.edgesInput.edges(this.vertexInput.idPointer());
        vertex.edges(edges);
        output.write(vertex);
    }
    try {
        this.afterOutput();
    } catch (IOException e) {
        throw new ComputerException("Error occurred when afterOutput", e);
    }
    output.close();
    return new PartitionStat(this.partition, this.vertexCount, this.edgeCount, 0L);
}
Also used : Vertex(com.baidu.hugegraph.computer.core.graph.vertex.Vertex) PartitionStat(com.baidu.hugegraph.computer.core.graph.partition.PartitionStat) Value(com.baidu.hugegraph.computer.core.graph.value.Value) IOException(java.io.IOException) Edges(com.baidu.hugegraph.computer.core.graph.edge.Edges) ComputerException(com.baidu.hugegraph.computer.core.common.exception.ComputerException) ComputerOutput(com.baidu.hugegraph.computer.core.output.ComputerOutput)

Example 2 with ComputerOutput

use of com.baidu.hugegraph.computer.core.output.ComputerOutput in project hugegraph-computer by hugegraph.

the class MasterService method outputstep.

/**
 * Wait the workers write result back. After this, the job is finished
 * successfully.
 */
private void outputstep() {
    LOG.info("{} MasterService outputstep started", this);
    this.bsp4Master.waitWorkersOutputDone();
    // Merge output files of multiple partitions
    ComputerOutput output = this.config.createObject(ComputerOptions.OUTPUT_CLASS);
    output.mergePartitions(this.config);
    LOG.info("{} MasterService outputstep finished", this);
}
Also used : ComputerOutput(com.baidu.hugegraph.computer.core.output.ComputerOutput)

Aggregations

ComputerOutput (com.baidu.hugegraph.computer.core.output.ComputerOutput)2 ComputerException (com.baidu.hugegraph.computer.core.common.exception.ComputerException)1 Edges (com.baidu.hugegraph.computer.core.graph.edge.Edges)1 PartitionStat (com.baidu.hugegraph.computer.core.graph.partition.PartitionStat)1 Value (com.baidu.hugegraph.computer.core.graph.value.Value)1 Vertex (com.baidu.hugegraph.computer.core.graph.vertex.Vertex)1 IOException (java.io.IOException)1