Jump to content

Can a StreamBase Java custom function return a Java object to EventFlow


paolo tarpanelli

Recommended Posts

Hello,

how can i return from a custom java function a class object from an external jar file.

For example: let us suppose I have a Map operator containing my custom java function (fun) whic uses a class, from an external jar file, and returns an object x and I would liket that my fun return the object x such that the output of the Map operator is the object x. How can i do it:

What type of return I need to specify in the .sbconf when I ama going to define the custom function

Thank you

best regards

Paolo

Link to comment
Share on other sites

Hi Paolo,

You can only return a Java data type that maps to a StreamBase data type and there is no defined mapping from java.lang.Object (POJO) directly to any StreamBase data type. Similarly theres no direct way for a POJO to traverse a StreamBase stream.

You could have your custom function get the values of fields in your POJO and set corresponding fields in a com.streambase.sb.Tuple and have the function return that. To return a tuple type from a custom Java plugin function you will need to implement a custom function resolver for the plugin function.

Another possibility is to serialize your POJO into a blob, but thats not very convenient in practice.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...