db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dag.Wan...@Sun.COM (Dag H. Wanvik)
Subject Re: Inserting large LOB as a stream...
Date Tue, 16 Feb 2010 21:51:55 GMT
Mamta Satoor <msatoor@gmail.com> writes:


> trying to see if I can run this with limited heap to do the insert
>         ps.setBinaryStream(1, new LoopingAlphabetStream(300000*1024),
> 300000*1024);

You shold be able to insert, yes, cf. BlobMemTest running as part of
the lowmem suite

org.apache.derbyTesting.functionTests.tests.memory._Suite

cf. junit-lowmem ant target.

Dag

>
>
> On Tue, Feb 16, 2010 at 11:54 AM, Mamta Satoor <msatoor@gmail.com> wrote:
>> Yes, I just ran into it and trying it. thanks, Dag.
>>
>> On Tue, Feb 16, 2010 at 11:51 AM, Dag H. Wanvik <Dag.Wanvik@sun.com> wrote:
>>> Mamta Satoor <msatoor@gmail.com> writes:
>>>
>>>
>>>> Hi,
>>>>
>>>> I am working on writing a test for INSERT statement which will cause
>>>> INSERT trigger to fire. The INSERT is being done into a table with a
>>>> large BLOB column. The table definition looks as follows create table
>>>> table1 (id int, status smallint, bl blob(2G))
>>>>
>>>> My goal is to run this INSERT statement inside a java program with a
>>>> limited heap to see if I will run into any OOMs during trigger
>>>> execution because we are trying to stream the data into memory. The
>>>> way I am trying to insert large LOB is as follows
>>>>               System.out.println("Inserting into table1 to cause insert
trigger to fire");
>>>>               PreparedStatement ps = conn.prepareStatement(
>>>>                       "insert into table1(id, status, bl) values(101,
0, ?)");
>>>>               byte[] arr = new byte[300000*1024];
>>>>               for (int i = 0; i < arr.length; i++)
>>>>               arr[i] = (byte)4;
>>>>               ps.setBinaryStream(1, new ByteArrayInputStream(arr),
arr.length);
>>>>               ps.executeUpdate();
>>>>               conn.commit();
>>>> But the above code runs into OOM for byte[] arr = new
>>>> byte[300000*1024]; because I do not have enough heap available. I was
>>>> wondering if there was a way for me to use a stream to insert a pretty
>>>> large LOB into my table without having a physical file on the disk
>>>> from which I will stream the data in. I do not care about the actual
>>>> data. As shown above, I am just inserting a large quantity of (byte)4
>>>> in the LOB. Would appreciate if anyone knows of a way for me to stream
>>>> large data into LOB while running with limited heap.
>>>
>>> You might use the same method as used in BlobMemTest, perhaps?
>>> (LoopingAlphabetStream).
>>>
>>> Thanks,
>>> Dag
>>>
>>
>

-- 
Dag H. Wanvik, staff engineer
Sun Microsystems, Java Core and Desktop - Java DB/Derby
Haakon VII gt. 7b, N-7485 Trondheim, Norway
Tel: x43496/+47 73842196, Fax:  +47 73842101
Sun IM: dw136674, Yahoo IM: dag_h_wanvik

Mime
View raw message