zruchala opened a new pull request, #52:
URL: https://github.com/apache/olingo-odata2/pull/52

   Problem:
   
   We experienced OutOfMemory exceptions when sending multiple bigger batch 
requests simultaneously. The current implementation of olingo2 requires the use 
of byte[] or stream input and also creates intermediate data in memory, which 
may be suboptimal in some situations.
   
   The change request allows data to be passed as an input stream:
   ```java
    BatchChangeSetPart changeRequest = BatchChangeSetPart.newBuilder()
                   .method("POST")
                   .uri("ServiceRequestCollection")
                   .headers(headers)
                   // use batchInputResource as a body (instead of byte[] or 
string)
                   .body(batchInputResource)
                   .build();
   ```
   
   And also changes the internal implementation to avoid loading intermadiate 
data into memory (if data exceed threshold)
   
   ```java
    static class BodyBuilder {
    ...
       public InputStream getContentAsStream() {
         try {
           return fileBuffer != null ?
             new DeleteOnCloseFileInputStream(fileBuffer) : new 
ByteArrayInputStream(getBufferContent());
         } catch (IOException exception) {
           throw new ODataRuntimeException(exception);
         }
       }
   ```
   
   To sum up, this change allows you to:
   - avoid loading payload into memory before passing batch-request to the 
olingo2 engine. You may use files or other data sources. 
   - decrease overall memory consumption, olingo2 uses disk storage internally 
if the received data exceed limit. 
   
   Changes are backwards compatible.
   
   I am attaching a sample project with a use case:
   
[olingo-stream.zip](https://github.com/apache/olingo-odata2/files/14978582/olingo-stream.zip)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@olingo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to