How to create a realm transaction on the same thread from several webservice results











up vote
1
down vote

favorite












We have a big amount of data to insert into a realm database. The data are coming from several webservices for a total amount of 100Mb to 1Gb.
We need to store each result from network with a transaction. If all the webservices are downloaded successfully, after a post-process we commit the database.



Due to the fact that realm for that transaction requires to work on the same thread and that the webservice are asynchrone, the problem we are facing is that we are not able to call the same thread after a webservice result, how can we manage to handle this situation?



Note:




  • We cannot load all the data in memory -> the huge amount of data is putting at risk the memory exception


  • Storing the result of webservice response in files and loading file by file are not very efficient -> we did this but the performance are bad (we spend 30% of processing the management of the file decoding…)











share|improve this question






















  • I would create a temporal realm (you can specify the path of the realm in the Realm.Configuration when create the Realm) and when all the transactions commit, merge the temporal to the real.
    – hfehrmann
    Nov 9 at 14:27

















up vote
1
down vote

favorite












We have a big amount of data to insert into a realm database. The data are coming from several webservices for a total amount of 100Mb to 1Gb.
We need to store each result from network with a transaction. If all the webservices are downloaded successfully, after a post-process we commit the database.



Due to the fact that realm for that transaction requires to work on the same thread and that the webservice are asynchrone, the problem we are facing is that we are not able to call the same thread after a webservice result, how can we manage to handle this situation?



Note:




  • We cannot load all the data in memory -> the huge amount of data is putting at risk the memory exception


  • Storing the result of webservice response in files and loading file by file are not very efficient -> we did this but the performance are bad (we spend 30% of processing the management of the file decoding…)











share|improve this question






















  • I would create a temporal realm (you can specify the path of the realm in the Realm.Configuration when create the Realm) and when all the transactions commit, merge the temporal to the real.
    – hfehrmann
    Nov 9 at 14:27















up vote
1
down vote

favorite









up vote
1
down vote

favorite











We have a big amount of data to insert into a realm database. The data are coming from several webservices for a total amount of 100Mb to 1Gb.
We need to store each result from network with a transaction. If all the webservices are downloaded successfully, after a post-process we commit the database.



Due to the fact that realm for that transaction requires to work on the same thread and that the webservice are asynchrone, the problem we are facing is that we are not able to call the same thread after a webservice result, how can we manage to handle this situation?



Note:




  • We cannot load all the data in memory -> the huge amount of data is putting at risk the memory exception


  • Storing the result of webservice response in files and loading file by file are not very efficient -> we did this but the performance are bad (we spend 30% of processing the management of the file decoding…)











share|improve this question













We have a big amount of data to insert into a realm database. The data are coming from several webservices for a total amount of 100Mb to 1Gb.
We need to store each result from network with a transaction. If all the webservices are downloaded successfully, after a post-process we commit the database.



Due to the fact that realm for that transaction requires to work on the same thread and that the webservice are asynchrone, the problem we are facing is that we are not able to call the same thread after a webservice result, how can we manage to handle this situation?



Note:




  • We cannot load all the data in memory -> the huge amount of data is putting at risk the memory exception


  • Storing the result of webservice response in files and loading file by file are not very efficient -> we did this but the performance are bad (we spend 30% of processing the management of the file decoding…)








ios swift realm






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 8 at 15:17









Nicolas Lauquin

1,03221121




1,03221121












  • I would create a temporal realm (you can specify the path of the realm in the Realm.Configuration when create the Realm) and when all the transactions commit, merge the temporal to the real.
    – hfehrmann
    Nov 9 at 14:27




















  • I would create a temporal realm (you can specify the path of the realm in the Realm.Configuration when create the Realm) and when all the transactions commit, merge the temporal to the real.
    – hfehrmann
    Nov 9 at 14:27


















I would create a temporal realm (you can specify the path of the realm in the Realm.Configuration when create the Realm) and when all the transactions commit, merge the temporal to the real.
– hfehrmann
Nov 9 at 14:27






I would create a temporal realm (you can specify the path of the realm in the Realm.Configuration when create the Realm) and when all the transactions commit, merge the temporal to the real.
– hfehrmann
Nov 9 at 14:27



















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53210710%2fhow-to-create-a-realm-transaction-on-the-same-thread-from-several-webservice-res%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53210710%2fhow-to-create-a-realm-transaction-on-the-same-thread-from-several-webservice-res%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Landwehr

Reims

Schenkenzell