[Pljava-dev] VarLenTuple example code

From: schabi at logix-tt(dot)com (Markus Schaber)
To:
Subject: [Pljava-dev] VarLenTuple example code
Date: 2006-10-01 12:38:37
Message-ID: 451FB6CD.7070808@logix-tt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

Hi, Thomas,

Thomas Hallgren wrote:

> I.e. a fullblown type implementation would then have 6 methods (4
> static) and look like this:
>
> // The new static interface
> //
> public static void input(String input, SQLData output) throws
> SQLException { ... }
> public static String output(SQLData input) throws SQLException { ... }

Using a String in input/output looks like a good compromise between
usability and speed.

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.

> 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?

> // 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. :-)

And a simple mapping for an existing Datatype still needs to implement
only those two, excellent.

> What do you think?

I think it's a good idea. Someone who wants to have the object
representation in input/output and/or send/receive can still use the
readSQL/writeSQL methods of an instance he created itsself. I'll recode
my VarLenTuple example to work this way, and explain the alternatives
using comments.

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).

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.

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.

Btw, do you have any idea if and how other databases implement the UDT
mapping for java?

Thanks,
Markus

In response to

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Thomas Hallgren 2006-10-01 13:31:54 [Pljava-dev] VarLenTuple example code
Previous Message Thomas Hallgren 2006-10-01 11:53:52 [Pljava-dev] VarLenTuple example code