[Pljava-dev] readBytes() / writeBytes()

From: thomas at tada(dot)se (Thomas Hallgren)
To:
Subject: [Pljava-dev] readBytes() / writeBytes()
Date: 2006-09-22 13:29:15
Message-ID: 4513E52B.5080108@tada.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

Hi Markus,
I should have checked before I spoke. I see now that the implementation
is incorrect. The intended functionality should of course be that the 4
byte integer is intact when present and that all endianness is taken
care of. This is a bug of course and I'll fix that eventually. Sorry for
the confusion.

Regards,
Thomas Hallgren

Markus Schaber wrote:
> Hi, Thomas,
>
> Thomas Hallgren wrote:
>
>
>> AFAIK, they all start with a 4 byte header denoting the length. So
>> your mapping starts by doing a readInt() and then you base the rest
>> on that.
>>
>
> From my tests, that 4 byte header is cut of, the SQLInput starts at the
> first "real" data byte.
>
>
>>> As it looks now, my only possibility seems to find out the native
>>> endianness of the machine, and then read the data byte-for-byte via
>>> readByte(), and then put it together for myself. Most of the code
>>> should be copyable from the WKB parsers I've already written, so no
>>> real effort, but I'm still afraid that calling a native function
>>> per byte will not perform best.
>>>
>>>
>> You should not bother with endianess. The implementation deals with
>> that.
>>
>
> At leas on my machine (i386 architecture), the doubles I read in get
> scrambled when using readDouble(). However, when I swap the bytes, I get
> the correct results. From looking at the code, readDouble() & co seem to
> assume network byte order, instead of using the native endianness of the
> machine. But for reading PostGIS geometry data, I've to parse the native
> format, as that is what the C code uses.
>
> So I will resort to read byte-for-byte.
>
> Thanks for your patience,
> Markus
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Pljava-dev mailing list
> Pljava-dev at gborg.postgresql.org
> http://gborg.postgresql.org/mailman/listinfo/pljava-dev
>

In response to

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Markus Schaber 2006-09-22 14:22:24 [Pljava-dev] readBytes() / writeBytes()
Previous Message Markus Schaber 2006-09-22 13:18:56 [Pljava-dev] readBytes() / writeBytes()