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

From: schabi at logix-tt(dot)com (Markus Schaber)
To:
Subject: [Pljava-dev] readBytes() / writeBytes()
Date: 2006-09-22 13:18:56
Message-ID: 4513E2C0.3050804@logix-tt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

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
--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS

Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20060922/dbb2cdf8/attachment.bin>

In response to

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Thomas Hallgren 2006-09-22 13:29:15 [Pljava-dev] readBytes() / writeBytes()
Previous Message Markus Schaber 2006-09-22 09:18:17 [Pljava-dev] Best way to pass intermediate state