rmatharu commented on a change in pull request #1010: SAMZA-2176: Ignore the
keys with serialized null values from the coordinator stream.
URL: https://github.com/apache/samza/pull/1010#discussion_r279037353
##########
File path:
samza-core/src/main/java/org/apache/samza/container/LocalityManager.java
##########
@@ -63,9 +64,11 @@ public LocalityManager(MetadataStore metadataStore) {
metadataStore.all().forEach((containerId, valueBytes) -> {
if (valueBytes != null) {
String locationId = valueSerde.fromBytes(valueBytes);
- Map<String, String> values = new HashMap<>();
- values.put(SetContainerHostMapping.HOST_KEY, locationId);
- allMappings.put(containerId, values);
+ if (StringUtils.isNotBlank(locationId)) {
Review comment:
It appears that we're invoking StringUtils.isNotBlank immediately after
<serde>.fromBytes().
Is it possible to create a wrapper for serde and call this method there.
Then you check like so:
```
String locationId = new MySerdeWrapper(valueSerde).fromBytes(valueBytes);
public class MySerdeWrapper {
public Deserializer deserializer;
public MySerdeWrapper(Deserializer deserializer) {
this.deserializer = deserializer;
}
public Optional<String> fromBytes(byte[] bytes) {
return StringUtils.isNotBlank(deserializer.fromBytes(bytes)) ?
Optional.of(deserializer.fromBytes(bytes)) : Optional.empty();
}
}```
----------------------------------------------------------------
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]
With regards,
Apache Git Services