couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Hirst <paul.hi...@sophos.com>
Subject Re: Spontaneous reindex and View Group Indexer Finishing taking a long time
Date Fri, 01 Oct 2010 12:29:21 GMT
On Fri, 2010-10-01 at 12:19 +0100, David Coallier wrote:

> For instance, consider this document:
> {
>     _id: "xxx",
>     "name": "example1",
>     "age": 23
> }
>
> and
>
> {
>     _id: "yyy",
>     "name": "example2"
> }
>
> Then the following map and reduce functions:
> map = function(doc) {
>     emit(doc.name, doc.age);
> }

>
> This previous case is going to generate an exception in the javascript
> engine, stopping the indexing and re-spawning another process picking
> up the indexing where it was. This caused some massive interruptions
> in our indexing.

Is this true? I had naively assumed that this behaviour was a 'feature'
I could use. Ie I could avoid some if clauses and just rely on
exceptions being thrown when, for example, when a view is only
interested in certain types of document.

For example documents like

{
_id: "person_paul",
name: "paul",
lives_in: [ "city_london" ],
}
{
_id: "city_london",
info: {
city_name: "london",
population: "lots",
}
}

I has assumed it was reasonable to write a view which returns all cities
with their populations as
map = function(doc) {
  emit(doc.info.city_name, doc.info.population);
}

doc.info will be undefined for 'person' records and thus
doc.info.city_name will throw an exception.

I had assumed this would cheaply skip over 'person' records, because an
exception would be thrown but it sounds like this exception is actually
really expensive?

Can anyone clarify?

Thanks.


Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom.
Company Reg No 2096520. VAT Reg No GB 348 3873 20.

Mime
View raw message