Lists: | pljava-dev |
---|
From: | yazuna at gmail(dot)com (Krzysztof) |
---|---|
To: | |
Subject: | [Pljava-dev] Returning complex complex objects |
Date: | 2010-12-16 13:52:40 |
Message-ID: | AANLkTinMRakduYUS3jN+1ZD1dv5G+TpPPy-bOV7Dxc-y@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pljava-dev |
Hello Johann,
That's really good news, especially if this could be made robust! I will
think of some ORM code (and maybe JPA plugin) that would create or re-use
existing Java classes to be populated by such call.
Thanks!
Krzysztof
Hi Krzysztof,
>
> On Mon, Dec 13, 2010 at 4:45 PM, Krzysztof <yazuna at gmail.com> wrote:
> > Hello Johann,
> > Certainly, the example of functionality is listed below - I was away
> > from any Postgres console at the time of writing and I rather meant
> > passing complex object to plJava, not getting from:
> > <sql>
> > -- nested, complex types handling...
> >
> > create type B as ( b_val float8,b2_val int)
> > create type C as (c1_val float8, c2_val float8);
> >
> > -- create complex, nested type
> > create type complexA as (
> > ? ? ? ?b B,
> > ? ? ? ?c C,
> > ? ? ? ?a_val int)
>
> Given the types above,
>
> public static int complexParam( ResultSet receiver[] )
> throws SQLException
> {
> for ( int i = 0; i < receiver.length; i++ )
> {
> ResultSet b = (ResultSet)receiver[ i ].getObject( 1 );
> double b_val = b.getDouble( 1 );
> int b2_val = b.getInt( 2 );
>
> ResultSet c = (ResultSet)receiver[ i ].getObject( 2 );
> double c1_val = c.getDouble( 1 );
> double c2_val = c.getDouble( 2 );
>
> int a = receiver[ i ].getInt( 3 );
> ;
> }
>
> return 0;
> }
>
> will handle the following select statement.
> > select complexParam(array_agg(((0.1,i)::B,(0.1,10/i)::C,i)::complexA))
> ?from
> > generate_series (1,10) i;
>
> However, you'll get quite a few lines of
> WARNING: TupleDesc reference leak: TupleDesc 124e930 (139827,-1)
> still referenced
>
> Which I'll be working on soon.
>
> If you run into convoluted examples where the the template above
> doesn't get you started just ask again.
>
>
> Johann
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20101216/e068871b/attachment.html>
From: | johann at myrkraverk(dot)com (Johann 'Myrkraverk' Oskarsson) |
---|---|
To: | |
Subject: | [Pljava-dev] Returning complex complex objects |
Date: | 2010-12-21 00:27:39 |
Message-ID: | AANLkTik8NjJ-3GeUxOGeaQaJ35Bp8_Yi9dhA+Ji7tMPe@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pljava-dev |
Hi Krzysztof,
>> However, you'll get quite a few lines of
>> WARNING: ?TupleDesc reference leak: TupleDesc 124e930 (139827,-1)
>> still referenced
This is not really anything to worry about. The TupleDescs are freed
in a finalizer which will be run "sometime in the future." There is a
chance it's using the wrong free function and if so I expect to have
that patched before X-mas.
I do feel it's a bit "unprofessional" to have such warnings as it
gives the impression there may be a bug somewhere. It is possible to
keep track of the TupleDesc objecs in a separate data structure and
dispose of them when the Java function returns. I can provide a patch
for this in the near future if there is any wish for it. Let me know.
Johann