-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Support Pulsar Message as function input #4313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an integration test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sijie as mentioned in the description of the PR, once everyone is on board with this approach I will add the tests for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sijie I have added the tests
| Type actualInputType = ((ParameterizedType) collectionType).getActualTypeArguments()[0]; | ||
| typeArgs[0] = (Class<?>) actualInputType; | ||
| } | ||
| if(typeArgs[0].equals(Message.class)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats the plan for adding this support to window function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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