/** * Add data to the cache. * * @param workerInfo the remote worker destination * @param partitionId the remote Partition this message belongs to * @param destVertexId vertex id that is ultimate destination * @param data Data to send to remote worker * @return Size of messages for the worker. */ public int addData(WorkerInfo workerInfo, int partitionId, I destVertexId, T data) { // Get the data collection VertexIdData<I, T> partitionData = getPartitionData(workerInfo, partitionId); int originalSize = partitionData.getSize(); partitionData.add(destVertexId, data); // Update the size of cached, outgoing data per worker return incrDataSize(workerInfo.getTaskId(), partitionData.getSize() - originalSize); }
/** * This method is similar to the method above, * but use a serialized id to replace original I type * destVertexId. * * @param workerInfo The remote worker destination * @param partitionId The remote Partition this message belongs to * @param serializedId The byte array to store the serialized target vertex id * @param idPos The length of bytes of serialized id in the byte array above * @param data Data to send to remote worker * @return The number of bytes added to the target worker */ public int addData(WorkerInfo workerInfo, int partitionId, byte[] serializedId, int idPos, T data) { // Get the data collection VertexIdData<I, T> partitionData = getPartitionData(workerInfo, partitionId); int originalSize = partitionData.getSize(); partitionData.add(serializedId, idPos, data); // Update the size of cached, outgoing data per worker return incrDataSize(workerInfo.getTaskId(), partitionData.getSize() - originalSize); }