Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5040771E5 for ; Wed, 3 Aug 2011 11:39:15 +0000 (UTC) Received: (qmail 83122 invoked by uid 500); 3 Aug 2011 11:39:13 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 82529 invoked by uid 500); 3 Aug 2011 11:39:05 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 82520 invoked by uid 99); 3 Aug 2011 11:39:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Aug 2011 11:39:03 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of rgabo@rgabostyle.com designates 209.85.161.52 as permitted sender) Received: from [209.85.161.52] (HELO mail-fx0-f52.google.com) (209.85.161.52) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Aug 2011 11:38:54 +0000 Received: by fxd18 with SMTP id 18so1278766fxd.11 for ; Wed, 03 Aug 2011 04:38:33 -0700 (PDT) Received: by 10.204.128.137 with SMTP id k9mr1957303bks.176.1312371513408; Wed, 03 Aug 2011 04:38:33 -0700 (PDT) Received: from newyork.local (catv-89-134-121-101.catv.broadband.hu [89.134.121.101]) by mx.google.com with ESMTPS id p16sm212309bku.64.2011.08.03.04.38.32 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 03 Aug 2011 04:38:32 -0700 (PDT) Date: Wed, 3 Aug 2011 13:38:31 +0200 From: Gabor Ratky To: user@couchdb.apache.org Message-ID: <309637F705ED4BCFA4F33F6C2EA577F2@rgabostyle.com> In-Reply-To: References: Subject: Re: get size of a document (with attachments) within a view function ... X-Mailer: sparrow 1.3.2 (build 814.61) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="4e393337_436c6125_d7" X-Virus-Checked: Checked by ClamAV on apache.org --4e393337_436c6125_d7 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hans, =20 the sizes (length) of the attachments are available under doc.=5Fattachme= nts. So the size of the first attachment is doc.=5Fattachments=5B'name=5F= of=5Fattachment.txt'=5D.length. You can iterate over this object easily a= nd sum up the sizes. You can also: map: ''' emit(doc.=5Fid, JSON.stringify(doc).length) for attachment=5Fname in attachments emit(doc.=5Fid, attachments=5Battachment=5Fname=5D.length) ''' reduce: '=5Fsum' and let CouchDB reduce to the sum of sizes. Gabor =20 On Wednesday, August 3, 2011 at 1:34 PM, Hans-Dieter B=C3=B6hlau 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 functi= on > and to sum up the values within the reduce step. > =20 > How can I calculate the size of a document (including attachments=21) w= ithin > the map function=3F > =20 > Thank you for help, > Hans --4e393337_436c6125_d7--