db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@apache.org>
Subject Re: ArrayInputStream and performance
Date Tue, 28 Nov 2006 18:15:31 GMT
Knut Anders Hatlen wrote:
> Daniel John Debrunner <djd@apache.org> writes:
> 
>> Knut Anders Hatlen wrote:
>>
>>> I can't answer your question, but I will add that I find much of the
>>> code that uses ArrayInputStream very confusing. ArrayInputStream is
>>> supposed to wrap a byte array to provide encapsulation and easy access
>>> to the data through the InputStream interface. However, many (most?)
>>> of the callers inline the accesses to the data (presumably for
>>> performance reasons), so we end up with lots of methods looking like
>>> this:
>>>
>>>   public X readSomething(ArrayInputStream ais, byte[] data, int offset...) {
>>>     // lots of direct manipulation of the byte array
>>>     // ...
>>>     // ...
>>>     // ...
>>>     // finally, make sure that the state of the stream is brought to a
>>>     // consistent state:
>>>     ais.setPosition(offset + numberOfManipulatedBytes);
>>>   }
>>
>> I could only find one method that looked something like the above:
>>
>> StoredFieldHeader.readFieldLengthAndSetStreamPosition
>>
>> Could you provide a list of the others so I can see what the issue is?
> 
> You are quite right; most of the methods that inline the accesses
> don't call setPosition(). 

I'm still confused here, what do you mean by "inline the accesses".
Can you point to an example of what you mean?

I was assuming that you meant there were many cases where code accessed 
the byte array directly and using ArrayInputStream, but I don't see 
many. ArrayInputStream.getData() is only called in three places, in 
FlushedScan and Scan. Maybe I misread what you are trying to say?


Dan.


Mime
View raw message