Jens,
I could leave with lower response time than 1 second!
I changed the Function Map to issue an object with all the values that need.
But what was really consuming was the way the List <T> was being built, 
dynamically reallocating memory.
Now I am creating with the constructor Capacity in which fill with 
QueryEnumerator.Count, as limiting the ability of the List <T>.
Retrieve the document as a JSON object and some other things.
Here's how the code looks:


                 vwMercados.SetMap ((document, emitter) => {
                     if ((document ["blativo"].ToString () == "1") && (document 
["type"].ToString () == "E")) {
                         var titulos = (JArray)document ["titulos"];
                         for (int i = 0; i < titulos.Count; i++) {
                             if (titulos [i].Value<string> ("descricao").
Equals ("MERCADOS E SUPERMERCADOS")) {
                                 var Cad = new Cadastro ();
                                 Cad.Nome = document ["nome"].ToString ();
                                 Cad.Razao = document ["razao"].ToString ();
                                 Cad.Bairro = document ["bairro"].ToString 
();
                                 Cad.Cep = document ["cep"].ToString ();
                                 Cad.Cidade = document ["cidade"].ToString 
();
                                 Cad.Complemento = document ["complemento"].
ToString ();
                                 Cad.Logradouro = document ["logradouro"].
ToString ();
                                 Cad.Nr = document ["nr"].ToString ();
                                 Cad.Produto = document ["produto"].ToString 
();
                                 Cad.Fone = document ["fone"].ToString ();
                                 emitter (titulos [i].Value<string> (
"descricao"), Cad);
                             }
                         }
                     }
                 }, ver); 


 private void carrega (out List<Cadastro> obj)
         {
             var vw = database.GetExistingView (tpTitulo);
             qry = vw.CreateQuery ();
             qry.IndexUpdateMode = IndexUpdateMode.Never;
             lines = qry.Run ();
 
             var lstRetorno = new List<Cadastro> (lines.Count);
 
             for (int i = 0; i < lines.Count; i++) {
                 var Cad = JObject.Parse (lines.GetRow (i).Value.ToString 
());
                 //var telefone = (JArray)Cad.Fone;
                 lstRetorno.Add (new Cadastro () {
                     Nome = Cad.Property ("Nome").Value.ToString (),
                     Razao = Cad.Property ("Razao").Value.ToString (),
                     Logradouro = Cad.Property ("Logradouro").Value.ToString 
(),
                     Nr = Cad.Property ("Nr").Value.ToString (),
                     Complemento = Cad.Property ("Complemento").Value.
ToString (),
                     Bairro = Cad.Property ("Bairro").Value.ToString (),
                     Cidade = Cad.Property ("Cidade").Value.ToString (),
                     Cep = Cad.Property ("Cep").Value.ToString (),
                     Produto = Cad.Property ("Produto").Value.ToString ()
                     //Fone = telefone [0].Value<string> 
("numero").ToString ()
                 });
             }
             obj = lstRetorno.GroupBy (s => s.Nome).Select (s => s.First 
()).OrderBy (o => o.Nome).ToList<Cadastro> ();
         } 


*It was very fast!*

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/bad793cd-3b71-4e9d-aac3-7e9b44a648ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to