X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 464F25E40BB for ; Fri, 20 Aug 2004 06:59:23 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39492-05 for ; Fri, 20 Aug 2004 09:59:15 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 88E8C5E40AC for ; Fri, 20 Aug 2004 06:59:14 -0300 (ADT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=opencloud.com) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1By6B0-0001Xt-00; Fri, 20 Aug 2004 21:59:14 +1200 Message-ID: <4125CB6F.5040003@opencloud.com> Date: Fri, 20 Aug 2004 21:59:11 +1200 From: Oliver Jowett User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Mikko T." Cc: pgsql-jdbc@postgresql.org Subject: Re: OutOfMemory when inserting stream of unknown length References: <41251B4C.9020205@opencloud.com> <4125C871.1070608@opencloud.com> In-Reply-To: <4125C871.1070608@opencloud.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/116 X-Sequence-Number: 10838 Oliver Jowett wrote: > Mikko T. wrote: > >> But now the current implementation forces the user of the >> setBinaryStream to buffer all bytes to memory just to know how many >> bytes the stream will actually hold. And after that it can already >> call setBytes thus making the whole setBinaryStream useless when the >> stream length is not known beforehand. > > > Not true -- consider the case where you know the length but the data is > held out of heap (for example, a large NIO buffer or a file on disk). Eh, sorry, I misread your last sentence. Certainly if you don't know the length then you have to buffer internally and setBinaryStream() is of no use. The common case I've seen so far on the list is inserting from a file. It seems much less common to not know the length of your stream ahead of time.. -O