incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans-Dieter Böhlau <boehlau...@googlemail.com>
Subject Re: get size of a document (with attachments) within a view function ...
Date Wed, 03 Aug 2011 15:49:01 GMT
Sounds good, thank you! I'll make a try.

2011/8/3 Gabor Ratky <rgabo@rgabostyle.com>

>  Hans,
>
> the sizes (length) of the attachments are available under doc._attachments.
> So the size of the first attachment is
> doc._attachments['name_of_attachment.txt'].length. You can iterate over this
> object easily and sum up the sizes. You can also:
>
> map: '''
> emit(doc._id, JSON.stringify(doc).length)
> for attachment_name in attachments
> emit(doc._id, attachments[attachment_name].length)
> '''
>
> reduce: '_sum'
>
> and let CouchDB reduce to the sum of sizes.
>
> Gabor
>
>
> On Wednesday, August 3, 2011 at 1:34 PM, Hans-Dieter Böhlau wrote:
>
> > Hi *,
> > I'd like to calculate the size of a number of documents within a view ...
> to
> > estimate the download-volume for the replication to client side.
> > My idea is to calculate the size of each document within the map function
> > and to sum up the values within the reduce step.
> >
> > How can I calculate the size of a document (including attachments!)
> within
> > the map function?
> >
> > Thank you for help,
> > Hans
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message