incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Cottlehuber <d...@muse.net.nz>
Subject Re: deterministic view?
Date Wed, 25 Apr 2012 14:51:26 GMT
On 25 April 2012 15:45, Imre SZEBENYI <imre.szebenyi@szeim.com> wrote:
> Hi,
>
> We have a database with ~ 7000 documents. (machine profiles)
> There's a changelog field in the doc, and the map function
> calculates the number and the age of the disks for every day.
>
> This means that if the machine has 24 bay, then
> I will call this 24 times:
>
> emit({"diskmodel":"WDC","timestamp":1333152000000,"month":14,"datatype":"age"},1);

Hi Imre,

I assume each entry is not identical, and this is an audit trail? e.g.
if the disk in bay 3 was
replaced we'd see some different data here, right?

> On this day the machine had 24 disk, they were 14 month old.
> Because a machine usually "lives" 3 years,
> this means 3*365*24 ~ 26280 emits per document.

This feels wrong. Can you post a bit more info, include a sample doc
and your map/reduce
code? Your views must be massive, and I'm not sure why this approach
is really necessary.

> The view has a reduce function too: "_sum".
>
> We have a design document for the views, and we have 24 views in it.
> But if I put the _same_ code into a different design
> document (only one view) the results are different.
>
> I got a lot of errors like this:
>
> [Wed, 25 Apr 2012 13:10:23 GMT] [info] [<0.135.0>] OS Process #Port<0.2067>
> Log :: function raised exception (new TypeError("changelog[loopTime] is
> undefined", "", 124)) with doc._id cd1001402 HPC
> -2059631-a

What's in doc "cd1001402 HPC -2059631-a" ? Are you doing any duck-type checking
to make sure loopTime or changelog actually exists?

A nice way to test this is to open up a node or js console directly,
and run your map
function interactively:

http://wiki.apache.org/couchdb/Troubleshooting#Map.2BAC8-Reduce_debugging

> But _only_ when the "big"  design (24 views) document is recalculated.
> The "small" one is ok, and the numbers (the output) is ok too.
> Again: the same view code.
>
> Couchdb 1.1.1
>
> Any idea?
>
> Cheers,
> Imre
>
>
>
>

As Aurélien said you should be calculating time in an absolute fashion
in your views
and then doing any relation to current date/time outside couchdb. That's because
views are calculated once on first query for any added doc, and then
persisted in the
couch view files. It's not clear from your email if this is the case or not.

A+
Dave

Mime
View raw message