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);
}
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);
}
Aggregations