copy patch question: byte format and efficiency - Mailing list pgsql-jdbc

From Georg Hintermaier
Subject copy patch question: byte format and efficiency
Date
Msg-id plgmt19tcfquvm9nvgjoun3amq03e58utc@4ax.com
Whole thread Raw
List pgsql-jdbc
Hi,
I am trying to stream selected columns of a file into the database.
I am reading the file in with a BufferedReader wrapped FileReader.
In a class implementing the InputStream interface I am filtering
out the columns I like (to my luck only ints and floats) and write
them into a ByteBuffer.

The problem I discovered is that the format of the ByteBuffer
is very different from the format that is used and works e.g.
in the unit tests used in the copy patch.

There the data is encoded into a ByteArrayOutputStream via a
PrintStream and the ResultingByteArray is used in the constructor
of an InputStream.

Questions:
Am I on the right track in general or is there a more efficient way?
I was also thinking about subclassing FilterInputStream, but
then I would have to construct the ints and floats myself.

How can I encode the ints and floats into the byteArray (or a
different buffer) in an efficient way in the correct format?

thanks
georg

pgsql-jdbc by date:

Previous
From: Philip Yarra
Date:
Subject: Re: Postgres-JDBC question
Next
From: Georg Hintermaier
Date:
Subject: Re: copy patch question: byte format and efficiency