Looking for Code Example: Modifying Query Results

5 views
Skip to first unread message

Philip Weaver

unread,
Apr 14, 2009, 9:06:47 PM4/14/09
to dovetaildb-discuss
Phillip, will you provide a code example of how to modify query results on the server just before returning them to the client.


Philip Weaver

unread,
Apr 14, 2009, 9:10:27 PM4/14/09
to dovetaildb-discuss
AbstractResultMap.getClassName and AbstractResultMap. getDefaultValue appear to be defined as a ResultList. That could be part of the problem I'm seeing. I was also seeing a JavaException when I was calling ResultList.length().

Philip Weaver

unread,
Apr 14, 2009, 9:30:22 PM4/14/09
to dovetaildb-discuss
Well, when I embrace what you've provided in map (and reduce), life is easier. Kudos. Yet I did have lots of trouble interacting with the results after calling _server.inner.query

Phil

On Tue, Apr 14, 2009 at 8:06 PM, Philip Weaver <phil...@gmail.com> wrote:

psch...@gmail.com

unread,
Apr 16, 2009, 12:06:47 AM4/16/09
to dovetaildb-discuss
Thanks for the information: your diagnosis is right on track.

Indeed; object property deletion for objects returned by query() is
not functioning in the current version. I'm uploading a patch v0.3.8
right now which should fix this and a few different but similar bugs.
To upgrade, for most releases (this one included), you can simply copy
the 0.3.8 dovetaildb.jar on top of your existing one and restart the
server. I suspect there's more issues lurking out there, though.
Generally speaking, the stuff coming out of query() will work similar
to real javascript arrays and objects, but many functions are missing
or just blow up. In particular, most of the methods normally
available on arrays are missing, like push(). I'll need to do a more
thorough audit soon to ensure these look as much like real javascript
objects as possible.

As an aside, you might wonder why we don't simply copy all the data
into native javascript types ... ultimately, it's because the result
list you get back is a lazy list - it doesn't actually read the query
results until you request a property that requires it,
(like .length). This laziness lets you run big queries without
needing to buffer the entire result set in memory (provided you don't
need to do something in javascript that would realize the entire
list).

Further, note that you can always copy the data into native types if
you like (and do it only in the cases where you aren't concerned about
large result sets).


On Apr 14, 9:30 pm, Philip Weaver <philma...@gmail.com> wrote:
> Well, when I embrace what you've provided in map (and reduce), life is
> easier. Kudos. Yet I did have lots of trouble interacting with the results
> after calling _server.inner.query
> Phil
>
Reply all
Reply to author
Forward
0 new messages