getExistingView("name/view") different from REST? working?

167 views
Skip to first unread message

Michael Hines

unread,
Jun 5, 2014, 11:51:59 PM6/5/14
to mobile-c...@googlegroups.com
Hi,

I started up couchbase lite successfully with a listener on android. Then, I successfully pull-replicated from a remote couchdb server. (Almost 2000 documents).

I am able to query a view from the REST api, but I'm having trouble using "getExistingView()" from Java - it's not returning any results.

Here's my investigation:

First, I get a list of views from the listener REST api running on the phone:


Which returns:
 
{"offset":0,"total_rows":6,"rows":[{"id":"_design/accounts","value":{"_conflicts":[],"rev":"1-52d520c5c33807ae8c71ad15fa5529c3"},"key":"_design/accounts"},{"id":"_design/memorized","value":{"_conflicts":[],"rev":"2-465c63a40e9333efca703f50651a0a2d"},"key":"_design/memorized"},{"id":"_design/mergegroups","value":{"_conflicts":[],"rev":"1-0936d2b16110ecdabfb0b0df1f5ee77f"},"key":"_design/mergegroups"},{"id":"_design/splits","value":{"_conflicts":[],"rev":"1-5ce461648a3220fcc1eeaa470be88c0e"},"key":"_design/splits"},{"id":"_design/stories","value":{"_conflicts":[],"rev":"23-47ed99b6c1b1fa7819962b26231b03d1"},"key":"_design/stories"},{"id":"_design/tonechanges","value":{"_conflicts":[],"rev":"1-defef51d1191b22534854ca476fec30b"},"key":"_design/tonechanges"}]}

OK, great! The one I'm interested in is "accounts", so I query that with the rest API:


Which returns: 

{"views":{"all":{"map":"function(doc) { if (doc._id.indexOf('MICA:accounts:') != -1) { emit(doc._id.replace('MICA:accounts:', ''), doc); } }"}},"language":"javascript","_rev":"1-52d520c5c33807ae8c71ad15fa5529c3","_id":"_design/accounts"}

Ok, excellent, so I now, I want to run a query on the first view "accounts/all" mapper, so I do:

http://192.168.1.79:5984/mica/_design/accounts/_view/all

This crunches for a while an I see a lot of garbage collection messages on the phone via adb logcat,
and then the browser fails and returns:

{"error":"not_found","reason":"Router unable to route request to do_GET_DesignDocumentjava.lang.reflect.InvocationTargetException"}

(What in the world does that mean?)

So, I start thinking, "OK, maybe querying from the listener's not so stable",
so, instead I try the Java getExistingView() function:

View v = database.getExistingView("accounts/all");

But this returns null.

So sad. =(

Is there some alternative mapping to reference an existing view that was replicated from another location? How exactly is this view supposed to be looked up in Java? 

Thanks, everyone.

- Michael Hines

Michael Hines

unread,
Jun 6, 2014, 12:16:55 AM6/6/14
to mobile-c...@googlegroups.com
Little bit more information, I updated my jar files to one from Jenkins (389),
and I'm getting this error from the REST api:


W/CursorWindow(13122): Window is full: requested allocation 210689 bytes, free space 36826 bytes, window size 2097152 bytes
D/dalvikvm(13122): GC_CONCURRENT freed 4933K, 49% free 9914K/19220K, paused 5ms+2ms, total 63ms
D/dalvikvm(13122): WAIT_FOR_CONCURRENT_GC blocked 49ms
D/dalvikvm(13122): GC_CONCURRENT freed 752K, 43% free 11107K/19220K, paused 2ms+3ms, total 26ms
D/dalvikvm(13122): GC_CONCURRENT freed 1049K, 38% free 12107K/19220K, paused 2ms+2ms, total 34ms
W/CursorWindow(13122): Window is full: requested allocation 210689 bytes, free space 79518 bytes, window size 2097152 bytes
E/CursorWindow(13122): Failed to read row 23, column 0 from a CursorWindow which has 23 rows, 6 columns.
W/View    (13122): Failed to rebuild view accounts/all.  Result code: 500
I/CBLite  (13122): Acme.Utils.ThreadPool(0)-PooledThread: Acme.Serve.Serve$ServeConnection@42aa3c90 CANCEL transaction (level 1)
D/dalvikvm(13122): GC_CONCURRENT freed 4888K, 53% free 9155K/19220K, paused 3ms+4ms, total 33ms
E/Router  (13122): Router unable to route request to do_GET_DesignDocument
E/Router  (13122): java.lang.reflect.InvocationTargetException
E/Router  (13122):      at java.lang.reflect.Method.invokeNative(Native Method)
E/Router  (13122):      at java.lang.reflect.Method.invoke(Method.java:511)
E/Router  (13122):      at com.couchbase.lite.router.Router.start(Router.java:464)
E/Router  (13122):      at com.couchbase.lite.listener.LiteServlet.service(LiteServlet.java:128)
E/Router  (13122):      at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
E/Router  (13122):      at Acme.Serve.Serve$ServeConnection.runServlet(Serve.java:2251)
E/Router  (13122):      at Acme.Serve.Serve$ServeConnection.parseRequest(Serve.java:2176)
E/Router  (13122):      at Acme.Serve.Serve$ServeConnection.run(Serve.java:1988)
E/Router  (13122):      at Acme.Utils$ThreadPool$PooledThread.run(Utils.java:1223)
E/Router  (13122):      at java.lang.Thread.run(Thread.java:856)
E/Router  (13122): Caused by: java.lang.IllegalStateException: Couldn't read row 23, col 0 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.
E/Router  (13122):      at android.database.CursorWindow.nativeGetLong(Native Method)
E/Router  (13122):      at android.database.CursorWindow.getLong(CursorWindow.java:511)
E/Router  (13122):      at android.database.AbstractWindowedCursor.getLong(AbstractWindowedCursor.java:75)
E/Router  (13122):      at com.couchbase.lite.android.AndroidSQLiteStorageEngine$SQLiteCursorWrapper.getLong(AndroidSQLiteStorageEngine.java:198)
E/Router  (13122):      at com.couchbase.lite.View.updateIndex(View.java:484)
E/Router  (13122):      at com.couchbase.lite.router.Router.queryDesignDoc(Router.java:1683)
E/Router  (13122):      at com.couchbase.lite.router.Router.do_GET_DesignDocument(Router.java:1714)
E/Router  (13122):      ... 10 more

Michael Hines

unread,
Jun 6, 2014, 10:14:54 AM6/6/14
to mobile-c...@googlegroups.com
There error I'm getting seems to be consistent with this issue: https://github.com/couchbase/couchbase-lite-android/issues/210

Help =)

Traun Leyden

unread,
Jun 6, 2014, 11:55:54 AM6/6/14
to mobile-c...@googlegroups.com

Yes, can you post a bug for that?

The most important thing to add in the issue is clear steps to reproduce.  It would be even better if you could provide sample docs on a public CouchDB server that reproduce the problem.

--
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 mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/cc38d446-8844-4a28-90c1-61db00ca1cee%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Traun Leyden

unread,
Jun 6, 2014, 11:59:15 AM6/6/14
to mobile-c...@googlegroups.com
Oh wait, I see you updated issue #210.  Nevermind.

Michael R. Hines

unread,
Jun 6, 2014, 9:33:28 PM6/6/14
to mobile-c...@googlegroups.com
Yeah, google also responded to the bug (it's a bug affecting versions
4.1 through 4.2.2). It's unbelievable that their answer was simply
"Unfortunately, no." - they are assuming the manufacturer will update
the devices to 4.4 eventually.

It seems insane that anyone developing an APK that encounters this bug
would just be excluded from a whole class of devices running these
android versions.

- Michael
Reply all
Reply to author
Forward
0 new messages