use of org.apache.hadoop.io.serializer.Serializer in project angel by Tencent.
the class SplitClassification method serialize.
@SuppressWarnings({ "rawtypes", "unchecked" })
public void serialize(DataOutputStream output) throws IOException {
output.writeBoolean(useNewAPI);
if (useNewAPI) {
int size = splitsNewAPI.size();
output.writeInt(size);
output.writeInt(locations.length);
for (int i = 0; i < locations.length; i++) {
output.writeUTF(locations[i]);
}
if (size > 0) {
output.writeUTF(splitsNewAPI.get(0).getClass().getName());
SerializationFactory factory = new SerializationFactory(new Configuration());
Serializer serializer = factory.getSerializer(splitsNewAPI.get(0).getClass());
serializer.open(output);
for (int i = 0; i < size; i++) {
serializer.serialize(splitsNewAPI.get(i));
}
}
} else {
int size = splitsOldAPI.size();
output.writeInt(size);
output.writeInt(locations.length);
for (int i = 0; i < size; i++) {
output.writeUTF(locations[i]);
}
if (size > 0) {
output.writeUTF(splitsOldAPI.get(0).getClass().getName());
SerializationFactory factory = new SerializationFactory(new Configuration());
Serializer serializer = factory.getSerializer(splitsOldAPI.get(0).getClass());
serializer.open(output);
for (int i = 0; i < size; i++) {
serializer.serialize(splitsOldAPI.get(i));
}
}
}
}
Aggregations