Support Pulsar Message as function input - #4313
Conversation
|
@ConcurrencyPractitioner please also take a look |
| import org.apache.pulsar.functions.api.Function; | ||
|
|
||
|
|
||
| public class MessageInputFunction implements Function<Message<String>, String> { |
There was a problem hiding this comment.
Can you add an integration test for this?
There was a problem hiding this comment.
@sijie as mentioned in the description of the PR, once everyone is on board with this approach I will add the tests for this
| Type actualInputType = ((ParameterizedType) collectionType).getActualTypeArguments()[0]; | ||
| typeArgs[0] = (Class<?>) actualInputType; | ||
| } | ||
| if(typeArgs[0].equals(Message.class)) { |
There was a problem hiding this comment.
whats the plan for adding this support to window function?
There was a problem hiding this comment.
we will probably have to change the interface from
public interface WindowFunction<I, O> {
O process(Collection<Record<I>> input, WindowContext context) throws Exception;
}
to
public interface WindowFunction<I, O> {
O process(Collection<I> input, WindowContext context) throws Exception;
}
And support "I" as Record for BC and support "I" as Message.
|
Sure, I have no problem with this. Thanks for picking this up. :) |
|
rerun cpp tests |
|
@srkukarni @sijie can you look at this again? Thanks |
|
Alternatively, instead of allowing user's to be able to have Message as input to a function, a simpler approach of we would be just to add this API to Context: and the Impl would be: There also isn't any good way (without breaking BC) for the WindowFunction API to support Message as a input since the WindowFunction API is I don't think it makes much sense to do We would have to change the interface (BC breaking) to: To support Message as a input Alternatively, we can change the API for WindowFunction to be something like and you can do or in the WindowContext we implement a method like |
|
The simplest and non-BC-breaking approach I can think of for Functions and WindowFunctions: just to add these getter methods to Context and WindowContext: and |
|
@jerrypeng What about the message type? I believe |
|
@merlimat that is correct which is a con for that approach. |
|
@sijie @srkukarni @merlimat what we can do is this: simpler approach that solves all our problems |
|
+1 for #4341 |
Motivation
Support Message object as function input so that users can get all of the attributes of the Message.
Implementing this for windowed function is a more complicated and will discuss/implement after this
If everyone is ok with this approach then I will add tests
Discussions about this was done in:
#4127