Return-Path: X-Original-To: apmail-jackrabbit-oak-dev-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9D40FD4C7 for ; Wed, 17 Oct 2012 09:04:01 +0000 (UTC) Received: (qmail 3051 invoked by uid 500); 17 Oct 2012 09:04:00 -0000 Delivered-To: apmail-jackrabbit-oak-dev-archive@jackrabbit.apache.org Received: (qmail 2951 invoked by uid 500); 17 Oct 2012 09:04:00 -0000 Mailing-List: contact oak-dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-dev@jackrabbit.apache.org Received: (qmail 2935 invoked by uid 99); 17 Oct 2012 09:04:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Oct 2012 09:04:00 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of stefan.guggisberg@gmail.com designates 209.85.214.170 as permitted sender) Received: from [209.85.214.170] (HELO mail-ob0-f170.google.com) (209.85.214.170) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Oct 2012 09:03:53 +0000 Received: by mail-ob0-f170.google.com with SMTP id ni5so15178937obc.1 for ; Wed, 17 Oct 2012 02:03:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=BtyZwWsGEIc9TIxUF2NoSeMaJVbMPq1215nUfty8c84=; b=oXEKithzhjQQsJTiis+RlKdwjWB6WosnQrUVGl7vuVQr5Xw5oWiTHbaxgyLMzXaIyM bcJzyKjjlXjcZ8GOagG2iIZi8POUg+R0S+ZvJRA+frzRfvTZdQvmvonAEIzcGZLNi2TX ddF+P+tM2yh2D3zjB+yii/uOWSoXs4mKzYiUgxleSAvUBAjENOa5oOv/m6frhkhvcFUS oWrOVUaQ1gmHd7zS7yM9xrA1Yo4S1eRWjuiM4rINnTgK21pIiENSKYnNfIMeJCFR2c2D 7sC8RRNnPmbGmtDc1JTqOr0XGRTfrfIQglGikwEHVNCBP44ojpG6NFaSq3rsJ2LjWon/ CPoA== MIME-Version: 1.0 Received: by 10.182.10.71 with SMTP id g7mr14504687obb.84.1350464612954; Wed, 17 Oct 2012 02:03:32 -0700 (PDT) Received: by 10.76.73.129 with HTTP; Wed, 17 Oct 2012 02:03:32 -0700 (PDT) In-Reply-To: <507E6F78.5030602@apache.org> References: <507E6F78.5030602@apache.org> Date: Wed, 17 Oct 2012 11:03:32 +0200 Message-ID: Subject: Re: [MongoMK] Reading blobs incrementally From: Stefan Guggisberg To: oak-dev@jackrabbit.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Wed, Oct 17, 2012 at 10:42 AM, Michael D=FCrig wrot= e: > > I wonder why the Microkernel API has an asymmetry here: for writing a bin= ary > you can pass a stream where as for reading you need to pass a byte array. the write method implies a content-addressable storage for blobs, i.e. identical binary content is identified by identical identifiers. the identifier needs to be computed from the entire blob content. that's why the signature takes a stream rather than supporting chunked writes. cheers stefan > > Michael > > > On 26.9.12 8:38, Mete Atamel wrote: >> >> Hi, >> >> I realized that MicroKernelIT#testBlobs takes a while to complete on >> MongoMK. This is partly due to how the test was written and partly due t= o >> how the blob read offset is implemented in MongoMK. I'm looking for >> feedback on where to fix this. >> >> To give you an idea on testBlobs, it first writes a blob using MK. Then, >> it verifies that the blob bytes were written correctly by reading the bl= ob >> from MK. However, blob read from MK is not done in one shot. Instead, it= 's >> done via this input stream: >> >> InputStream in2 =3D new BufferedInputStream(new MicroKernelInputStream(m= k, >> id)); >> >> >> MicroKernelInputStream reads from the MK and BufferedInputStream buffers >> the reads in 8K chunks. Then, there's a while loop with in2.read() to re= ad >> the blob fully. This makes a call to MicroKernel#read method with the >> right offset for every 8K chunk until the blob bytes are fully read. >> >> This is not a problem for small blob sizes but for bigger blob sizes, >> reading 8K chunks can be slow because in MongoMK, every read with offset >> triggers the following: >> -Find the blob from GridFS >> -Retrieve its input stream >> -Skip to the right offset >> -Read 8K >> -Close the input stream >> >> I could fix this by changing the test to read the blob bytes in one shot >> and then do the comparison. However, I was wondering if we should also >> work on an optimization for successive reads from the blob with >> incremental offsets? Maybe we could keep the input stream of recently re= ad >> blobs around for some time before closing them? >> >> Best, >> Mete >> >> >