Consuming Webservice with large data volume

Asked

Viewed 566 times

6

I have a demand where I need to import a file JSON with 65k of records for my app Android,after calling my service URL REST the app starts importing the data but crashes after some time, I would like to know how to work with large volume of data in mobile applications.

Some points:

  • I’d have to split this file?

Today he’s like this :

[{"codigoTabela":0,"codigoProduto":"623261","vendaAtual":83.4012,"vendaOferta":0.0000,"dataInicioOferta":"Jan 1, 1900","dataFimOferta":"Jan 1, 1900","totalRegistros":62314},

It has how to optimize this model?

Note: This app works normally with smaller data volume.

  • 1

    Hello I think this can help you,
 
 [http://answall.com/questions/404/qual-structure-json-usar-para-large-volume-data][1]
 
 

 [1]: http://.pt.stackoverflowcom.questions/404/qual-stacklowsstructure-json-use-for-large-volume-of-data-without-loss-of-performance

1 answer

6


Simple version: Segment your result using paging. There are several ways to implement this mechanism, an example follows below.

Instead of sending 60k records, implement a process that:

  1. Store your search result temporarily on the server;
  2. Send 5k records, plus an object indicated which 'page' of the data you are seeing (zero in the case), and that there are still pages waiting for fetch on the server;
  3. Make your client get more records (page + 1);
  4. Repeat 2 and 3 until the number of pages is exhausted;
  5. Delete temporary content stored on the server.

An example of JSON with pagination control:

{
    results: [{},{},...{}],
    page: 0,
    continue: true
}

Repeat requests, and return continue: false when content runs out on the server.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.