ShardedValue[] shardedValues = new ShardedValue[entities.size()];
int totalSize = 0;
int index = 0;
for (Key key : keys) {
Entity entity = entities.get(key);
ShardedValue shardedValue = new ShardedValue(entity);
shardedValues[index++] = shardedValue;
totalSize += shardedValue.getValue().length;
}
byte[] totalBytes = new byte[totalSize];
int offset = 0;
for (ShardedValue shardedValue : shardedValues) {
byte[] shardBytes = shardedValue.getValue();
System.arraycopy(shardBytes, 0, totalBytes, offset, shardBytes.length);
offset += shardBytes.length;
}
return SerializationUtils.deserialize(totalBytes);
}