Search in sources :

Example 1 with BufferedFileOutput

use of com.baidu.hugegraph.computer.core.io.BufferedFileOutput in project hugegraph-computer by hugegraph.

the class FileGraphPartition method beforeCompute.

private void beforeCompute(int superstep) throws IOException {
    this.vertexInput = new VertexInput(this.context, this.vertexFile, this.vertexCount);
    this.edgesInput = new EdgesInput(this.context, this.edgeFile);
    // Inputs of vertex, edges, status, and value.
    this.vertexInput.init();
    this.edgesInput.init();
    if (superstep != 0) {
        this.preStatusFile = this.curStatusFile;
        this.preValueFile = this.curValueFile;
        this.preStatusInput = new BufferedFileInput(this.preStatusFile);
        this.preValueInput = new BufferedFileInput(this.preValueFile);
    }
    // Outputs of vertex's status and vertex's value.
    String statusPath = this.fileGenerator.randomDirectory(STATUS, Integer.toString(superstep), Integer.toString(this.partition));
    String valuePath = this.fileGenerator.randomDirectory(VALUE, Integer.toString(superstep), Integer.toString(this.partition));
    this.curStatusFile = new File(statusPath);
    this.curValueFile = new File(valuePath);
    createFile(this.curStatusFile);
    createFile(this.curValueFile);
    this.curStatusOutput = new BufferedFileOutput(this.curStatusFile);
    this.curValueOutput = new BufferedFileOutput(this.curValueFile);
}
Also used : BufferedFileInput(com.baidu.hugegraph.computer.core.io.BufferedFileInput) BufferedFileOutput(com.baidu.hugegraph.computer.core.io.BufferedFileOutput) VertexInput(com.baidu.hugegraph.computer.core.compute.input.VertexInput) File(java.io.File) EdgesInput(com.baidu.hugegraph.computer.core.compute.input.EdgesInput)

Example 2 with BufferedFileOutput

use of com.baidu.hugegraph.computer.core.io.BufferedFileOutput in project hugegraph-computer by hugegraph.

the class FileGraphPartition method input.

protected PartitionStat input(PeekableIterator<KvEntry> vertices, PeekableIterator<KvEntry> edges) {
    try {
        createFile(this.vertexFile);
        createFile(this.edgeFile);
        BufferedFileOutput vertexOut = new BufferedFileOutput(this.vertexFile);
        BufferedFileOutput edgeOut = new BufferedFileOutput(this.edgeFile);
        while (vertices.hasNext()) {
            KvEntry entry = vertices.next();
            Pointer key = entry.key();
            Pointer value = entry.value();
            this.writeVertex(key, value, vertexOut);
            this.writeEdges(key, edges, edgeOut);
        }
        vertexOut.close();
        edgeOut.close();
    } catch (IOException e) {
        throw new ComputerException("Failed to init FileGraphPartition '%s'", e, this.partition);
    }
    return new PartitionStat(this.partition, this.vertexCount, this.edgeCount, 0L);
}
Also used : BufferedFileOutput(com.baidu.hugegraph.computer.core.io.BufferedFileOutput) PartitionStat(com.baidu.hugegraph.computer.core.graph.partition.PartitionStat) KvEntry(com.baidu.hugegraph.computer.core.store.entry.KvEntry) Pointer(com.baidu.hugegraph.computer.core.store.entry.Pointer) IOException(java.io.IOException) ComputerException(com.baidu.hugegraph.computer.core.common.exception.ComputerException)

Aggregations

BufferedFileOutput (com.baidu.hugegraph.computer.core.io.BufferedFileOutput)2 ComputerException (com.baidu.hugegraph.computer.core.common.exception.ComputerException)1 EdgesInput (com.baidu.hugegraph.computer.core.compute.input.EdgesInput)1 VertexInput (com.baidu.hugegraph.computer.core.compute.input.VertexInput)1 PartitionStat (com.baidu.hugegraph.computer.core.graph.partition.PartitionStat)1 BufferedFileInput (com.baidu.hugegraph.computer.core.io.BufferedFileInput)1 KvEntry (com.baidu.hugegraph.computer.core.store.entry.KvEntry)1 Pointer (com.baidu.hugegraph.computer.core.store.entry.Pointer)1 File (java.io.File)1 IOException (java.io.IOException)1