on 04-05-2022 1:19 PM
Hi Community,
were are currently migrating various native Android Apps from SMP to BTP.
Some offline entities are used to transfer image data and we noticed a tremendous performance decrease when copying the byte stream using the BTP SDK (4.0.1).
We configure the OfflineODataDefiningQuery for the respective entities with automaticallyRetrieveStreams flag in the constructor to be true. When the initial open() request of the ODataOfflineProvider completes successfully we query the byte streams of the entities by using the /$value syntax and copy the stream to the file system, for better handling of the images during various use cases within our apps.
The code basically looks something like this.
// retrieve the stream from the ODataOfflineProvider
final DataQuery request = new DataQuery();
request.setRequestPath(resourcePath); //the resource path ends with /$value
final HttpHeaders headers = new HttpHeaders();
final RequestOptions options = new RequestOptions();
final QueryResult response = oDataOfflineProvider.executeQuery(request, headers, options);
if (response.getError() != null) {
throw new DatabaseException(response.getError());
} else {
// Copy the image data from the retrieved byte stream
InputStream src = ByteStream.toInput(response.getByteStream())
byte[] buf = new byte[1024];
int len;
try {
while((len = src.read(buf)) > 0) {
dst.write(buf, 0, len);
}
} finally {
src.close();
dst.close();
}
}
In comparison to the SMP SDK we get a really significant performance decrease:<img data-attachment="2033894" src="/storage/temp/2033894-performance-comparsion-smp-btp.png" alt="performance-comparsion-smp-btp.png" style="background-color: initial; font-family: Arial, Helvetica, Verdana, Tahoma, sans-serif; font-size: 15px; white-space: normal; color: inherit;">
The code that copies the streams as well as the other external parameters (threading model, device the code runs on, ...) has not changed.<br>
Does anybody have an idea what's going on here or how we gone fix it?
Kind regards,
Robert
I suppose you could open a "performance bug" to request for the InputStream returned by ByteStream.toInput performance to be improved.
But something that may perform better right now would be:
response.getByteStream().copyToFile(fileName)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.