use of com.baidu.hugegraph.computer.core.graph.partition.PartitionStat 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);
}
use of com.baidu.hugegraph.computer.core.graph.partition.PartitionStat in project hugegraph-computer by hugegraph.
the class ComputeManager method output.
public void output() {
// TODO: Write results back parallel
for (FileGraphPartition partition : this.partitions.values()) {
PartitionStat stat = partition.output();
LOG.info("Output partition {} complete, stat='{}'", partition.partition(), stat);
}
}
use of com.baidu.hugegraph.computer.core.graph.partition.PartitionStat in project hugegraph-computer by hugegraph.
the class WorkerStatTest method testEquals.
@Test
public void testEquals() {
PartitionStat stat1 = new PartitionStat(0, 1L, 2L, 0L);
PartitionStat stat2 = new PartitionStat(1, 4L, 3L, 2L);
WorkerStat workerStat1 = new WorkerStat();
workerStat1.add(stat1);
workerStat1.add(stat2);
WorkerStat workerStat2 = new WorkerStat();
workerStat2.add(stat1);
workerStat2.add(stat2);
WorkerStat workerStat3 = new WorkerStat();
Assert.assertEquals(workerStat1, workerStat2);
Assert.assertNotEquals(workerStat1, workerStat3);
Assert.assertNotEquals(workerStat1, new Object());
}
use of com.baidu.hugegraph.computer.core.graph.partition.PartitionStat in project hugegraph-computer by hugegraph.
the class WorkerStatTest method testConstructor.
@Test
public void testConstructor() {
WorkerStat workerStat1 = new WorkerStat();
PartitionStat stat1 = new PartitionStat(0, 1L, 2L, 0L);
PartitionStat stat2 = new PartitionStat(1, 4L, 3L, 2L);
workerStat1.add(stat1);
workerStat1.add(stat2);
Assert.assertEquals(2, workerStat1.size());
Assert.assertEquals(stat1, workerStat1.get(0));
Assert.assertEquals(stat2, workerStat1.get(1));
WorkerStat workerStat2 = new WorkerStat(1);
Assert.assertEquals(1, workerStat2.workerId());
Assert.assertEquals(0, workerStat2.size());
}
use of com.baidu.hugegraph.computer.core.graph.partition.PartitionStat in project hugegraph-computer by hugegraph.
the class WorkerStatTest method testHashCode.
@Test
public void testHashCode() {
PartitionStat stat1 = new PartitionStat(0, 1L, 2L, 0L);
PartitionStat stat2 = new PartitionStat(1, 4L, 3L, 2L);
WorkerStat workerStat1 = new WorkerStat(1);
workerStat1.add(stat1);
workerStat1.add(stat2);
WorkerStat workerStat2 = new WorkerStat(1);
workerStat2.add(stat1);
workerStat2.add(stat2);
WorkerStat workerStat3 = new WorkerStat(2);
Assert.assertEquals(workerStat1.hashCode(), workerStat2.hashCode());
Assert.assertNotEquals(workerStat1.hashCode(), workerStat3.hashCode());
}
Aggregations