From user-return-17338-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Wed Aug 3 15:49:31 2011 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 0588B7399 for ; Wed, 3 Aug 2011 15:49:31 +0000 (UTC) Received: (qmail 23868 invoked by uid 500); 3 Aug 2011 15:49:29 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 23748 invoked by uid 500); 3 Aug 2011 15:49:28 -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 23739 invoked by uid 99); 3 Aug 2011 15:49:28 -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 15:49:28 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of boehlau.hd@googlemail.com designates 209.85.220.196 as permitted sender) Received: from [209.85.220.196] (HELO mail-vx0-f196.google.com) (209.85.220.196) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Aug 2011 15:49:22 +0000 Received: by vxi39 with SMTP id 39so62127vxi.11 for ; Wed, 03 Aug 2011 08:49:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=86MePN8JigFGyaEMM2KEKJb95+xjeoAw9/IP2+HV3gI=; b=RJqjf3r3bloMVFSc1WLubkrMQ7qsOdmKKCqZg/LrTlcSR42Nn/SN1eXlJDw4UaAnOa 2JzT9upgsoXZPbU4KqU+VNLO8r7zZedYTzpXy/e+Do0sx1YyDWkqM+xFXcutzGDKjdKy e4kR/0xmrGdgoSI1wqe0rslnrFTX2A5Zz18cs= MIME-Version: 1.0 Received: by 10.52.113.167 with SMTP id iz7mr5228779vdb.444.1312386541438; Wed, 03 Aug 2011 08:49:01 -0700 (PDT) Received: by 10.220.157.9 with HTTP; Wed, 3 Aug 2011 08:49:01 -0700 (PDT) In-Reply-To: <309637F705ED4BCFA4F33F6C2EA577F2@rgabostyle.com> References: <309637F705ED4BCFA4F33F6C2EA577F2@rgabostyle.com> Date: Wed, 3 Aug 2011 17:49:01 +0200 Message-ID: Subject: Re: get size of a document (with attachments) within a view function ... From: =?ISO-8859-1?Q?Hans=2DDieter_B=F6hlau?= To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=bcaec54861de9c474204a99bcd25 X-Virus-Checked: Checked by ClamAV on apache.org --bcaec54861de9c474204a99bcd25 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Sounds good, thank you! I'll make a try. 2011/8/3 Gabor Ratky > Hans, > > the sizes (length) of the attachments are available under doc._attachment= s. > So the size of the first attachment is > doc._attachments['name_of_attachment.txt'].length. You can iterate over t= his > 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=F6hlau 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. > > > > How can I calculate the size of a document (including attachments!) > within > > the map function? > > > > Thank you for help, > > Hans > > --bcaec54861de9c474204a99bcd25--