Skip to content

Instantly share code, notes, and snippets.

@charles-tan
Created March 4, 2024 20:43
Show Gist options
  • Save charles-tan/fa63b4e4b66bbe885d76318d9a4b1740 to your computer and use it in GitHub Desktop.
Save charles-tan/fa63b4e4b66bbe885d76318d9a4b1740 to your computer and use it in GitHub Desktop.
@Override
public byte[] serialize(KafkaPartitionSplit split) throws IOException {
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(baos)) {
out.writeUTF(split.getTopic());
out.writeInt(split.getPartition());
out.writeLong(split.getStartingOffset());
out.writeLong(split.getStoppingOffset().orElse(KafkaPartitionSplit.NO_STOPPING_OFFSET));
out.flush();
return baos.toByteArray();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment