PhoneGap pre-built database, how-to?

52 views
Skip to first unread message

Gilbert Pleczynski

unread,
Mar 25, 2015, 1:34:20 PM3/25/15
to mobile-c...@googlegroups.com
Is there any documentation on this?
I need to build an iOS and Android app with a pre-built DB. The initial load of 70k docs is just too slow. 

Jens Alfke

unread,
Mar 25, 2015, 1:51:54 PM3/25/15
to mobile-c...@googlegroups.com

> On Mar 25, 2015, at 10:32 AM, Gilbert Pleczynski <gplec...@gmail.com> wrote:
>
> Is there any documentation on this?
> I need to build an iOS and Android app with a pre-built DB. The initial load of 70k docs is just too slow.

If you’re not using _bulk_docs to store the docs in the database, try that first. It will speed things up a lot.

If you do need to go to a pre-built db, there isn’t any JavaScript API for it. You’ll have to add native code, probably by modifying and re-building the CBL plugin.

—Jens

Gilbert Pleczynski

unread,
Mar 25, 2015, 4:46:28 PM3/25/15
to mobile-c...@googlegroups.com
How do I know if it is using _bulk_docs to store the docs? 
I am only having trouble with Android. The initial sync with iOS is about 60 seconds. Android is taking close to an hour. I have tried both platforms on simulators and real devices with the same results. iPhone quick, Android slow. 

Watching the logs I see the following for about 60 seconds until it gets up to the current seq number.

D/ChangeTracker( 4997): com.couchbase.lite.replicator.ChangeTracker@46ae26e: changeTrackerReceivedChange: {seq=29063, id=bk::0801485479::19, changes=[{rev=1-11fff18b55062758eff5f9da8737c2b1}]}


V
/Sync    ( 4997): com.couchbase.lite.replicator.PullerInternal@df58c58: addToInbox() calling updateActive()
V
/Sync    ( 4997): com.couchbase.lite.replicator.PullerInternal@df58c58: updateActive() called
D
/Sync    ( 4997): changeTrackerReceivedChange: {seq=33333, id=bk::1597491330::19, changes=[{rev=1-64fd2e4b908cdd9090a50693cddebcdf}]}
D
/Sync    ( 4997): com.couchbase.lite.replicator.PullerInternal@df58c58: adding rev to inbox {bk::1597491330::19 #1-64fd2e4b908cdd9090a50693cddebcdf}
V
/Sync    ( 4997): com.couchbase.lite.replicator.PullerInternal@df58c58: changeTrackerReceivedChange() incrementing changesCount by 1
V
/Sync    ( 4997): com.couchbase.lite.replicator.PullerInternal@df58c58: Incrementing changesCount count from 14019 by adding 1 -> 14020
V
/Sync    ( 4997): com.couchbase.lite.replicator.PullerInternal@df58c58: addToInbox() called, rev: {bk::1597491330::19 #1-64fd2e4b908cdd9090a50693cddebcdf}.


Then I get the below for upwards of 60 minutes or until it crashes from being out of memory.
V/Sync    ( 4997): com.couchbase.lite.replicator.BulkDownloader@3cf72832: Starting new document; headers ={Content-Type=application/json}
V
/Sync    ( 4997): com.couchbase.lite.replicator.BulkDownloader@3cf72832: Starting new document; ID=null
V
/Sync    ( 4997): com.couchbase.lite.replicator.BulkDownloader@3cf72832: Finished document


I
/CBLite  ( 4997): CBLManagerWorkExecutor Begin transaction (level 2)
I
/CBLite  ( 4997): CBLManagerWorkExecutor Committing transaction (level 2)
V
/Sync    ( 4997): com.couchbase.lite.replicator.PullerInternal@df58c58: inserting bk::0714838578::19 [1-ecba7aaa5d48b4dd20faa293031e7dc8]

Jens Alfke

unread,
Mar 25, 2015, 9:29:38 PM3/25/15
to mobile-c...@googlegroups.com

On Mar 25, 2015, at 1:46 PM, Gilbert Pleczynski <gplec...@gmail.com> wrote:

How do I know if it is using _bulk_docs to store the docs? 

Oh, you’re replicating the docs. I thought you meant you were loading them from some local data file.

Yes, the Android replicator inserts docs in bulk. It’s slower than the iOS one for a number of reasons related to Android platform APIs and being written in Java instead of native code, but Hideki is working hard on speeding it up for the next major release.

—Jens

Hideki Itakura

unread,
Mar 27, 2015, 1:17:30 AM3/27/15
to mobile-c...@googlegroups.com
Hi Gilbert Pleczynski,

Couchbase Lite Android master branch has fix for pull replication slowness. 
As we built PhoneGapPlugin from master branch just for testing purpose, please try it if you would like.

Please follow steps to update PhoneGap plugin:

1. Download PhoneGapPlugin and Extract
2. Download couchbase-lite-java-listener-0.0.0-505.jar
3. Download couchbase-lite-java-javascript-0.0.0-505.jar
4. Move to your PhoneGap app folder
5. Update Plugin
phonegap plugin rm com.couchbase.lite.phonegap
phonegap plugin add ~/Downloads/Couchbase-Lite-PhoneGap-Plugin_1.0.4-47-56 <-- where you extract
phonegap platform rm android
mv ./couchbase-lite-java-javascript-0.0.0-505.jar ./plugins/com.couchbase.lite.phonegap/lib/android/
mv ./couchbase-lite-java-listener-0.0.0-505.jar ./plugins/com.couchbase.lite.phonegap/lib/android/
6. Add following two lines in plugin.xml
    <source-file src="lib/android/couchbase-lite-java-javascript-0.0.0-505.jar" target-dir="libs"/>
    <source-file src="lib/android/couchbase-lite-java-listener-0.0.0-505.jar" target-dir="libs"/>
7. Update plugin continue
phonegap platform add android
8. Run Android PhoneGap app
phonegap run android --verbose

Note: couchbase-lite-java-javascript-0.0.0-505.jar and couchbase-lite-java-listener-0.0.0-505.jar should be in the PhoneGapPlugin, but we have build issue now. 

Hope this helps you

Thanks!
Hideki

Hideki Itakura

unread,
Apr 1, 2015, 3:37:13 PM4/1/15
to mobile-c...@googlegroups.com
Hi Gilbert,

Previous PhoneGapBuild has some issue. If you are still working for PhoneGapPlugin, please try following newly build PhoneGapPlugin.


Download Link:

Command to update plugin:
```
phonegap plugin rm com.couchbase.lite.phonegap
phonegap plugin add ~/Downloads/Couchbase-Lite-PhoneGap-Plugin_1.0.4-47-61
phonegap platform rm android
phonegap platform add android
phonegap run android
phonegap run android --verbose
```

Hope this build helps you!

Thanks,
Hideki
Reply all
Reply to author
Forward
0 new messages