galenwarren commented on pull request #152:
URL: https://github.com/apache/flink-statefun/pull/152#issuecomment-696388005
@igalshilman Thanks!
I'll take a look at the others shortly, but wanted to quickly reply
regarding the question about Optional<String> and the serialized snapshot
format. (I can't reply to the comment itself for some reason ...) What you
propose is absolutely doable. I just wanted to make sure you're aware that the
suggested code is essentially identical to the implementation of
StringUtils.writeNullableString, which is what is currently used to write the
version 2 snapshot in MessageTypeSerializer.Snapshot.writeSnapshot, i.e.:
```
@Override
public void writeSnapshot(DataOutputView dataOutputView) throws
IOException {
// version 1
dataOutputView.writeUTF(messageFactoryKey.getType().name());
// added in version 2
StringUtils.writeNullableString(
messageFactoryKey.getCustomPayloadSerializerClassName(),
dataOutputView);
}
```
... and ...
```
public static void writeNullableString(@Nullable String str,
DataOutputView out) throws IOException {
if (str != null) {
out.writeBoolean(true);
writeString(str, out);
} else {
out.writeBoolean(false);
}
}
```
So the serialized format would already seem to be what you've requested! But
if you'd prefer it get written without using
```StringUtils.writeNullableString```, I'm happy to make that change.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]