* @return Size of partitions for this worker
*/
public int addVertex(PartitionOwner partitionOwner,
Vertex<I, V, E> vertex) {
// Get the data collection
ExtendedDataOutput partitionData =
getData(partitionOwner.getPartitionId());
int taskId = partitionOwner.getWorkerInfo().getTaskId();
int originalSize = 0;
if (partitionData == null) {
partitionData = getConf().createExtendedDataOutput(
getInitialBufferSize(taskId));
setData(partitionOwner.getPartitionId(), partitionData);
} else {
originalSize = partitionData.getPos();
}
try {
WritableUtils.<I, V, E>writeVertexToDataOutput(
partitionData, vertex, getConf());
} catch (IOException e) {
throw new IllegalStateException("addVertex: Failed to serialize", e);
}
// Update the size of cached, outgoing data per worker
return incrDataSize(taskId, partitionData.getPos() - originalSize);
}