Is there anyway to make view indexing (Emitter) faster on Android?

50 views
Skip to first unread message

John Bibal III

unread,
Mar 30, 2014, 3:18:00 AM3/30/14
to mobile-c...@googlegroups.com
Hi,

I'm trying to index 104,000 documents containing 2 properties (name, id) and it takes me 7-8 minutes to index all 104,000 documents.

Here is my code:

com.couchbase.lite.View view = database.getView("companyName");

        view.setMap(new Mapper() {

                     @Override

                      public void map(Map<String, Object> document, Emitter emitter) {

                               List<Object> compoundKey = new ArrayList<Object>();

                            compoundKey.add(document.get("companyName"));

                          compoundKey.add(document.get("id"));

                           emitter.emit(compoundKey, null);

                       }

              }, "1.5");

                Query query = view.createQuery();

               query.setLimit(40);

            QueryEnumerator rowEnum;

               try {

                  rowEnum = query.run();

                       if (rowEnum.getCount() > 0) {

                          for (int x = 0; x < 40; x++) {

                                 QueryRow row = rowEnum.getRow(x);

                                      companyList.add(row);

                          }

                      }

              } catch (CouchbaseLiteException e) {

                   // TODO Auto-generated catch block

                     e.printStackTrace();

               }


Is there anyway to make this faster? On iOS it goes on significantly faster, on basically the same code flow.

Any ideas to point me in the right direction is greatly appreciated.

Thanks
 

Andrew Reslan

unread,
Mar 31, 2014, 12:33:57 PM3/31/14
to mobile-c...@googlegroups.com
Using your Map function on 100K docs on a Nexus 5, indexing completes in 94 seconds.

What hardware are you using when running your performance tests?

Andy

Andrew Reslan

unread,
Mar 31, 2014, 12:57:42 PM3/31/14
to mobile-c...@googlegroups.com
I had a typo in my doc generation code so companyName did not get emitted, after correcting this, indexing takes 220 seconds on a Nexus 5.

Index time is being measured using   view.updateIndex(); rather than running a query and iterating over the results.

Andy
Reply all
Reply to author
Forward
0 new messages