Skip to content

Instantly share code, notes, and snippets.

@charles-tan
Created March 4, 2024 20:45
Show Gist options
  • Save charles-tan/5eb7155c07c21040a7cad34639e3cfd1 to your computer and use it in GitHub Desktop.
Save charles-tan/5eb7155c07c21040a7cad34639e3cfd1 to your computer and use it in GitHub Desktop.
public static <T> void writeVersionAndSerialize(
SimpleVersionedSerializer<T> serializer, T datum, DataOutputView out)
throws IOException {
checkNotNull(serializer, "serializer");
checkNotNull(datum, "datum");
checkNotNull(out, "out");
final byte[] data = serializer.serialize(datum);
out.writeInt(serializer.getVersion());
out.writeInt(data.length);
out.write(data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment