[Pljava-dev] VarLenTuple example code

From: thomas at tada(dot)se (Thomas Hallgren)
To:
Subject: [Pljava-dev] VarLenTuple example code
Date: 2006-10-01 13:31:54
Message-ID: 451FC34A.5070803@tada.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

Markus Schaber wrote:
> I'd prefer to have a CharSequence in both places (especially as we could
> use a StringBuilder in output then), but as they're @since 1.5, String
> seems the better choice.
>
>
Yes, I thought about that too. Another thing that could be used is the
java.io.Reader/Writer but it would only be beneficial for very large
types. For smaller types we 'd probably loose performance and definitely
use simplicity.

>> public static void receive(SQLData input, SQLData output) throws
>> SQLException { ... }
>> public static void send(SQLData input, SQLData output) throws
>> SQLException { ... }
>>
>
> Did you mean SQLInput/SQLOutput instead of SQLData here?
>
>
Doh, of course!

>> // The SQLData interface
>> //
>> public void readSQL(SQLData input, String typename) throws SQLException
>> { ... }
>> public void writeSQL(SQLData output) throws SQLException { ... }
>>
>
> SQLInput/SQLOutput here, too, I guess. :-)
>
>
Yes.

> There's one little problem I currently see: We'll need 2 implementations
> of SQLInput and SQLOutput. One for machine endianness (to parse C), and
> one for network byte order (to parse D).
>
>
You mean B here, right?

> Or maybe we have both a Big and Little endian implementation, and the
> UDT[] syntax contains a hint on which byte order to use (Big=Network,
> Little, Native=whatever the machine has), with the defaults of Network
> for B and Native for C.
>
>
I agree that we need two implementations but I think the choice witch
one to use should be made by PL/Java at all times. The end user doesn't
need to be exposed to this and PL/Java will always know what it wraps.
Why introduce the complexity?

> Having two fixed-endian implementations will even be more efficient
> compared to the current one that has an if() in every method, in case
> the Jit does not grasp it.
>
>
Right. And another thing that struck me is that since all calls origin
from C-code, and since the backend is inherently single-threaded, it
would be OK to use one singleton instances of each type. If we do that,
no objects need to be created when doing send/receive.

> Btw, do you have any idea if and how other databases implement the UDT
> mapping for java?
>
>
I've done some experimenting with Oracle. They are much closer to the
SQL 2003 standard where you actually define types along with attributes,
methods, and constructors. I've brought it up with the PostgreSQL
community a couple of times but they hasn't shown much interest so far.
I should mention that the Oracle experiments was performed five years
ago so a lot might have happened since.

Regards,
Thomas Hallgren

In response to

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Markus Schaber 2006-10-01 18:16:28 [Pljava-dev] VarLenTuple example code
Previous Message Markus Schaber 2006-10-01 12:38:37 [Pljava-dev] VarLenTuple example code