Issue Details (XML | Word | Printable)

Key: DERBY-3768
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Kristian Waagan
Reporter: Kristian Waagan
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

Make EmbedBlob.length use skip instead of read

Created: 09/Jul/08 11:26 AM   Updated: 04/May/09 06:22 PM
Return to search
Component/s: JDBC
Affects Version/s: 10.5.1.1
Fix Version/s: 10.4.2.0, 10.5.1.1

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works derby-3768-1a-length_skip.diff 2008-07-09 11:28 AM Kristian Waagan 2 kB
File Licensed for inclusion in ASF works derby-3768-1b-length_skip.diff 2008-07-09 01:53 PM Kristian Waagan 2 kB
File Licensed for inclusion in ASF works derby-3768-2a-misc_fixes.diff 2008-07-09 02:42 PM Kristian Waagan 5 kB

Bug behavior facts: Performance
Resolution Date: 17/Jul/08 01:21 PM


 Description  « Hide
EmbedBlob.length uses read to process the whole Blob when the length has not been encoded at the head of the stream.
Using skip instead of read can lead to better performance.

I also plan to make some minor cleanups under this issue; JavaDoc and to rename a variable.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Kristian Waagan added a comment - 09/Jul/08 11:28 AM
'derby-3768-1a-length_skip.diff' replaces the read loop with a skip loop to determine the stream length. Also removes unused imports.

Patch ready for review.

Kristian Waagan added a comment - 09/Jul/08 12:57 PM
suites.All and derbyall ran without failures with Solaris 10 and Sun JDK 1.6.

Dag H. Wanvik added a comment - 09/Jul/08 12:58 PM
Patch look good to me. I only did code inspection, since I am not sure which test
best exercises this code.

The skip semantics in Java input streams is a bit broken (it may return 0 bytes
skipped more or less at will and still be compliant,
cf. http://java.sun.com/javase/6/docs/api/java/io/InputStream.html#skip(long)),
but I see you have coded it safely here, maybe it would be a good idea
to make a utility method for skipping input streams ("skipFully").

+1

Kristian Waagan added a comment - 09/Jul/08 01:53 PM
Committed revision 1b of the patch, in which the only change over 1a is the addition of an else-block, to trunk with revision 675169.

Thanks for the review Dag.
I agree the InputStream.skip contract is somewhat difficult. We already have a utility class for UTF8 streams (iapi.util.UTF8Util), so adding one for generic InputStreams is a good idea.
I created DERBY-3770 for this task.

Kristian Waagan added a comment - 09/Jul/08 02:42 PM
'derby-3768-2a-misc_fixes.diff' contains a set of small fixes:
 - JavaDoc improvements
 - set locator value explicitly to indicate default value (must not be a valid locator)
 - renamed 'myLength' to 'streamLength'
 - keep variables 'materialized' and 'streamLength' in sync
 - throw exception in second constructor (mistakenly swallowed)
 - only clear LOB mapping if a mapping has been created

Awaiting test run completion.
Patch ready for review.

Kristian Waagan added a comment - 14/Jul/08 09:46 AM
suites.All and derbyall ran without failures.

Kristian Waagan added a comment - 14/Jul/08 12:33 PM
Committed 'derby-3768-2a-misc_fixes.diff' to trunk with revision 676571.
I plan to backport these changes, and some related performance issues, to 10.4.

Kristian Waagan added a comment - 17/Jul/08 01:21 PM
Backported patches 1b and 2a to 10.4 with revision 677578.