true stream optimizing needs subclassing java.io.InputStream

From: Michael Adler <adler(at)glimpser(dot)org>
To: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: true stream optimizing needs subclassing java.io.InputStream
Date: 2002-06-27 17:33:28
Message-ID: Pine.NEB.4.44.0206271317140.10295-100000@reva.sixgirls.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


This continues the discussion of optimizing the reading of characters from
the backend.

From what I can tell, PG_Stream.ReceiveChar() is no less efficient
(approximately) than PG_Stream.Receive(byte[] b, int off, int length). The
later is simply a wrapper around InputStream's method read(b,off,len). My
test showed little or no difference between the two methods. We would need
to override read(b,off,len) for true improvements.

from java.io.InputStream:

<snip>

The read(b, off, len) method for class InputStream simply calls the
method read() repeatedly. If the first such call results in an
IOException, that exception is returned from the call to the read(b,
off, len) method. If any subsequent call to read() results in a
IOException, the exception is caught and treated as if it were end of
file; the bytes read up to that point are stored into b and the number
of bytes read before the exception occurred is returned. Subclasses are
encouraged to provide a more efficient implementation of this method.

</snip>

I still have to test this over a modem. The high latency may demonstrate
the benefits of buffering.

Mike

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Sharon Cowling 2002-06-27 21:02:00 Connection Exception
Previous Message Tim Lucia 2002-06-27 15:41:44 Re: Interrupt execution