You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by Frédéric SOUCHU <Fr...@ingenico.com> on 2015/07/30 18:52:31 UTC
OData V4 ‘streaming’ serialization?
It appears that the OData 4 Java library is first producing an in-memory stream from the result set and then dumps the stream to the HTTP output.
See:
public void writeReadEntitySet(EdmEntityType entityType, EntityCollection entitySet)
throws SerializerException {
…
// write the whole collection to response
this.response.setContent(this.serializer.entityCollection(metadata, entityType, entitySet, this.options).getContent());
…
}
If I am reading the code correctly, I find that extremely low performing and prone to out of memory errors.
Why not provide the HTTP response stream to the serializer.
As far I can see, there is no need for 'seek' behavior while serializing.
Regards,
Frederic
Re: OData V4 ‘streaming’ serialization?
Posted by Ramesh Reddy <ra...@redhat.com>.
IMO, it may be much simpler to consider your CSV output in Edm.Stream property in entity or return of a Function and return the payload as you describe.
----- Original Message -----
> I have a case where the frontend is producing a large CSV from an OData
> service.
> The current implementation "forces" the OData producer to buffer everything
> in memory before dumping the content to the HTTP stream.
> If the payload is quite large, I'll get a) an out of memory exception and/or
> a HTTP timeout...
>
> As Ramesh pointed out, that's 'unfortunately' expected to be able to output a
> readable error message.
>
> I'll look into writing a custom serializer backed up by a 'on the fly'
> stream.
> (possibly going to support CSV output directly - with some severe limitations
> vs. ODATA specs, skipping the JSON->CSV pass)
>
> Frederic
>
> -----Original Message-----
> From: mibo [mailto:mibo@apache.org]
> Sent: 31 July 2015 15:41
> To: user@olingo.apache.org
> Subject: Re: OData V4 ‘streaming’ serialization?
>
> Hi Frederic and all others,
>
> Perhaps I did not fully understand your use case, but as Ramesh mentioned in
> the OData specification the HTTP status codes are used to convey success
> (e.g. 200, 202, 204) or other state (e.g. 404, 415). In this point OData
> behaves very much like REST.
> And for the case of performance and handling of streams you could take a look
> into the „core“ library and the „Processor“ interfaces.
> With those you have full control of the according request and response
> streams as well as to option to use your own serializer/deserializer.
> However, if you find any performance bootlenecks or other curiosities do not
> hesitate to ask or create an issue. Only this way we can discuss and improve
> the library ;o)
>
> Best Regards,
> Michael
>
> > Am 31.07.2015 um 15:05 schrieb Ramesh Reddy <ra...@redhat.com>:
> >
> >
> >
> > Thanks for confirming even if that's limiting the scope of the Olingo
> > implementation to 'toy' projects.
> >
> > As for:
> > except in situations of error, where you need to revert what you wrote
> > to the stream to add the error I realize the specification did not
> > understand the performance implication of the {error} message :[ Using HTTP
> > error code and semantic would have been a better option here.
> > I am not sure I understand your comment, OData spec heavily does depend on
> > the HTTP status codes to convey various success and failure modes, the
> > text is there is explain to the application what the underlying reason,
> > which is also equally important to the clients calling the service. As I
> > mention if you implement server side batching correctly it is not a huge
> > issue, I would like to think of it as buffering the contents before
> > writing to the stream. This does become issue with Edm.Stream/Media
> > properties, but for that you can use the stream directly.
> >
> > Alternatively, Olingo framework does give an option to use your own
> > serializer that can be another option.
> >
> > Regards,
> > Frederic
> >
> > From: Ramesh Reddy [mailto:rareddy@redhat.com]
> > Sent: 30 July 2015 19:20
> > To: user@olingo.apache.org
> > Subject: Re: OData V4 ‘streaming’ serialization?
> >
> > It appears that the OData 4 Java library is first producing an in-memory
> > stream from the result set and then dumps the stream to the HTTP output.
> > See:
> > public void writeReadEntitySet(EdmEntityType entityType, EntityCollection
> > entitySet)
> > throws SerializerException {
> > …
> > // write the whole collection to response
> > this.response.setContent(this.serializer.entityCollection(metadata,
> > entityType, entitySet, this.options).getContent());
> > …
> > }
> > If I am reading the code correctly, I find that extremely low performing
> > and prone to out of memory errors.
> > Note you are only dealing with set of results that are in the batch if you
> > implemented server side batching. Another trick I used in my
> > implementation is, I extended the EntityCollection such that it works like
> > an iterator.
> >
> > Why not provide the HTTP response stream to the serializer.
> > As far I can see, there is no need for 'seek' behavior while serializing.
> > Yes, that would be better, except in situations of error, where you need to
> > revert what you wrote to the stream to add the error contents.
>
>
RE: OData V4 ‘streaming’ serialization?
Posted by Frédéric SOUCHU <Fr...@ingenico.com>.
I have a case where the frontend is producing a large CSV from an OData service.
The current implementation "forces" the OData producer to buffer everything in memory before dumping the content to the HTTP stream.
If the payload is quite large, I'll get a) an out of memory exception and/or a HTTP timeout...
As Ramesh pointed out, that's 'unfortunately' expected to be able to output a readable error message.
I'll look into writing a custom serializer backed up by a 'on the fly' stream.
(possibly going to support CSV output directly - with some severe limitations vs. ODATA specs, skipping the JSON->CSV pass)
Frederic
-----Original Message-----
From: mibo [mailto:mibo@apache.org]
Sent: 31 July 2015 15:41
To: user@olingo.apache.org
Subject: Re: OData V4 ‘streaming’ serialization?
Hi Frederic and all others,
Perhaps I did not fully understand your use case, but as Ramesh mentioned in the OData specification the HTTP status codes are used to convey success (e.g. 200, 202, 204) or other state (e.g. 404, 415). In this point OData behaves very much like REST.
And for the case of performance and handling of streams you could take a look into the „core“ library and the „Processor“ interfaces.
With those you have full control of the according request and response streams as well as to option to use your own serializer/deserializer.
However, if you find any performance bootlenecks or other curiosities do not hesitate to ask or create an issue. Only this way we can discuss and improve the library ;o)
Best Regards,
Michael
> Am 31.07.2015 um 15:05 schrieb Ramesh Reddy <ra...@redhat.com>:
>
>
>
> Thanks for confirming even if that's limiting the scope of the Olingo implementation to 'toy' projects.
>
> As for:
> except in situations of error, where you need to revert what you wrote
> to the stream to add the error I realize the specification did not
> understand the performance implication of the {error} message :[ Using HTTP error code and semantic would have been a better option here.
> I am not sure I understand your comment, OData spec heavily does depend on the HTTP status codes to convey various success and failure modes, the text is there is explain to the application what the underlying reason, which is also equally important to the clients calling the service. As I mention if you implement server side batching correctly it is not a huge issue, I would like to think of it as buffering the contents before writing to the stream. This does become issue with Edm.Stream/Media properties, but for that you can use the stream directly.
>
> Alternatively, Olingo framework does give an option to use your own serializer that can be another option.
>
> Regards,
> Frederic
>
> From: Ramesh Reddy [mailto:rareddy@redhat.com]
> Sent: 30 July 2015 19:20
> To: user@olingo.apache.org
> Subject: Re: OData V4 ‘streaming’ serialization?
>
> It appears that the OData 4 Java library is first producing an in-memory stream from the result set and then dumps the stream to the HTTP output.
> See:
> public void writeReadEntitySet(EdmEntityType entityType, EntityCollection entitySet)
> throws SerializerException {
> …
> // write the whole collection to response
> this.response.setContent(this.serializer.entityCollection(metadata, entityType, entitySet, this.options).getContent());
> …
> }
> If I am reading the code correctly, I find that extremely low performing and prone to out of memory errors.
> Note you are only dealing with set of results that are in the batch if you implemented server side batching. Another trick I used in my implementation is, I extended the EntityCollection such that it works like an iterator.
>
> Why not provide the HTTP response stream to the serializer.
> As far I can see, there is no need for 'seek' behavior while serializing.
> Yes, that would be better, except in situations of error, where you need to revert what you wrote to the stream to add the error contents.
Re: OData V4 ‘streaming’ serialization?
Posted by mibo <mi...@apache.org>.
Hi Frederic and all others,
Perhaps I did not fully understand your use case, but as Ramesh mentioned in the OData specification the HTTP status codes are used to convey success (e.g. 200, 202, 204) or other state (e.g. 404, 415). In this point OData behaves very much like REST.
And for the case of performance and handling of streams you could take a look into the „core“ library and the „Processor“ interfaces.
With those you have full control of the according request and response streams as well as to option to use your own serializer/deserializer.
However, if you find any performance bootlenecks or other curiosities do not hesitate to ask or create an issue. Only this way we can discuss and improve the library ;o)
Best Regards,
Michael
> Am 31.07.2015 um 15:05 schrieb Ramesh Reddy <ra...@redhat.com>:
>
>
>
> Thanks for confirming even if that's limiting the scope of the Olingo implementation to 'toy' projects.
>
> As for:
> except in situations of error, where you need to revert what you wrote to the stream to add the error
> I realize the specification did not understand the performance implication of the {error} message :[
> Using HTTP error code and semantic would have been a better option here.
> I am not sure I understand your comment, OData spec heavily does depend on the HTTP status codes to convey various success and failure modes, the text is there is explain to the application what the underlying reason, which is also equally important to the clients calling the service. As I mention if you implement server side batching correctly it is not a huge issue, I would like to think of it as buffering the contents before writing to the stream. This does become issue with Edm.Stream/Media properties, but for that you can use the stream directly.
>
> Alternatively, Olingo framework does give an option to use your own serializer that can be another option.
>
> Regards,
> Frederic
>
> From: Ramesh Reddy [mailto:rareddy@redhat.com]
> Sent: 30 July 2015 19:20
> To: user@olingo.apache.org
> Subject: Re: OData V4 ‘streaming’ serialization?
>
> It appears that the OData 4 Java library is first producing an in-memory stream from the result set and then dumps the stream to the HTTP output.
> See:
> public void writeReadEntitySet(EdmEntityType entityType, EntityCollection entitySet)
> throws SerializerException {
> …
> // write the whole collection to response
> this.response.setContent(this.serializer.entityCollection(metadata, entityType, entitySet, this.options).getContent());
> …
> }
> If I am reading the code correctly, I find that extremely low performing and prone to out of memory errors.
> Note you are only dealing with set of results that are in the batch if you implemented server side batching. Another trick I used in my implementation is, I extended the EntityCollection such that it works like an iterator.
>
> Why not provide the HTTP response stream to the serializer.
> As far I can see, there is no need for 'seek' behavior while serializing.
> Yes, that would be better, except in situations of error, where you need to revert what you wrote to the stream to add the error contents.
Re: OData V4 ‘streaming’ serialization?
Posted by Ramesh Reddy <ra...@redhat.com>.
----- Original Message -----
> Thanks for confirming even if that's limiting the scope of the Olingo
> implementation to 'toy' projects.
> As for:
> except in situations of error, where you need to revert what you wrote to the
> stream to add the error
> I realize the specification did not understand the performance implication of
> the {error} message :[
> Using HTTP error code and semantic would have been a better option here.
I am not sure I understand your comment, OData spec heavily does depend on the HTTP status codes to convey various success and failure modes, the text is there is explain to the application what the underlying reason, which is also equally important to the clients calling the service. As I mention if you implement server side batching correctly it is not a huge issue, I would like to think of it as buffering the contents before writing to the stream. This does become issue with Edm.Stream/Media properties, but for that you can use the stream directly.
Alternatively, Olingo framework does give an option to use your own serializer that can be another option.
> Regards,
> Frederic
> From: Ramesh Reddy [mailto:rareddy@redhat.com]
> Sent: 30 July 2015 19:20
> To: user@olingo.apache.org
> Subject: Re: OData V4 ‘streaming’ serialization?
> ----- Original Message -----
> > It appears that the OData 4 Java library is first producing an in-memory
> > stream from the result set and then dumps the stream to the HTTP output.
>
> > See:
>
> > public void writeReadEntitySet (EdmEntityType entityType , EntityCollection
> > entitySet )
>
> > throws SerializerException {
>
> > …
>
> > // write the whole collection to response
>
> > this . response .setContent( this . serializer .entityCollection( metadata
> > ,
> > entityType , entitySet , this . options ).getContent());
>
> > …
>
> > }
>
> > If I am reading the code correctly, I find that extremely low performing
> > and
> > prone to out of memory errors.
>
> Note you are only dealing with set of results that are in the batch if you
> implemented server side batching. Another trick I used in my implementation
> is, I extended the EntityCollection such that it works like an iterator.
> > Why not provide the HTTP response stream to the serializer.
>
> > As far I can see, there is no need for 'seek' behavior while serializing.
>
> Yes, that would be better, except in situations of error, where you need to
> revert what you wrote to the stream to add the error contents.
RE: OData V4 ‘streaming’ serialization?
Posted by Frédéric SOUCHU <Fr...@ingenico.com>.
Thanks for confirming even if that's limiting the scope of the Olingo implementation to 'toy' projects.
As for:
except in situations of error, where you need to revert what you wrote to the stream to add the error
I realize the specification did not understand the performance implication of the {error} message :[
Using HTTP error code and semantic would have been a better option here.
Regards,
Frederic
From: Ramesh Reddy [mailto:rareddy@redhat.com]
Sent: 30 July 2015 19:20
To: user@olingo.apache.org
Subject: Re: OData V4 ‘streaming’ serialization?
________________________________
It appears that the OData 4 Java library is first producing an in-memory stream from the result set and then dumps the stream to the HTTP output.
See:
public void writeReadEntitySet(EdmEntityType entityType, EntityCollection entitySet)
throws SerializerException {
…
// write the whole collection to response
this.response.setContent(this.serializer.entityCollection(metadata, entityType, entitySet, this.options).getContent());
…
}
If I am reading the code correctly, I find that extremely low performing and prone to out of memory errors.
Note you are only dealing with set of results that are in the batch if you implemented server side batching. Another trick I used in my implementation is, I extended the EntityCollection such that it works like an iterator.
Why not provide the HTTP response stream to the serializer.
As far I can see, there is no need for 'seek' behavior while serializing.
Yes, that would be better, except in situations of error, where you need to revert what you wrote to the stream to add the error contents.
Re: OData V4 ‘streaming’ serialization?
Posted by Ramesh Reddy <ra...@redhat.com>.
----- Original Message -----
> It appears that the OData 4 Java library is first producing an in-memory
> stream from the result set and then dumps the stream to the HTTP output.
> See:
> public void writeReadEntitySet (EdmEntityType entityType , EntityCollection
> entitySet )
> throws SerializerException {
> …
> // write the whole collection to response
> this . response .setContent( this . serializer .entityCollection( metadata ,
> entityType , entitySet , this . options ).getContent());
> …
> }
> If I am reading the code correctly, I find that extremely low performing and
> prone to out of memory errors.
Note you are only dealing with set of results that are in the batch if you implemented server side batching. Another trick I used in my implementation is, I extended the EntityCollection such that it works like an iterator.
> Why not provide the HTTP response stream to the serializer.
> As far I can see, there is no need for 'seek' behavior while serializing.
Yes, that would be better, except in situations of error, where you need to revert what you wrote to the stream to add the error contents.