merlimat closed pull request #1372: Add byte array to built-in SerDe types for Pulsar Functions URL: https://github.com/apache/incubator-pulsar/pull/1372
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/pulsar-functions/api-java/src/main/java/org/apache/pulsar/functions/api/utils/DefaultSerDe.java b/pulsar-functions/api-java/src/main/java/org/apache/pulsar/functions/api/utils/DefaultSerDe.java index 30a740e10..88e3f60ed 100644 --- a/pulsar-functions/api-java/src/main/java/org/apache/pulsar/functions/api/utils/DefaultSerDe.java +++ b/pulsar-functions/api-java/src/main/java/org/apache/pulsar/functions/api/utils/DefaultSerDe.java @@ -32,6 +32,7 @@ public class DefaultSerDe implements SerDe<Object> { private static final Set<Class> supportedInputTypes = new HashSet<>(Arrays.asList( + byte[].class, Integer.class, Double.class, Long.class, @@ -49,7 +50,10 @@ public DefaultSerDe(Class type) { @Override public Object deserialize(byte[] input) { String data = new String(input, StandardCharsets.UTF_8); - if (type.equals(Integer.class)) { + + if (type.equals(byte[].class)) { + return input; + } else if (type.equals(Integer.class)) { return Integer.valueOf(data); } else if (type.equals(Double.class)) { return Double.valueOf(data); @@ -70,7 +74,9 @@ public Object deserialize(byte[] input) { @Override public byte[] serialize(Object input) { - if (type.equals(Integer.class)) { + if (type.equals(byte[].class)) { + return (byte[]) input; + } else if (type.equals(Integer.class)) { return ((Integer) input).toString().getBytes(StandardCharsets.UTF_8); } else if (type.equals(Double.class)) { return ((Double) input).toString().getBytes(StandardCharsets.UTF_8); ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services