[ 
https://issues.apache.org/jira/browse/DERBY-3907?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12664048#action_12664048
 ] 

kristwaa edited comment on DERBY-3907 at 1/15/09 1:01 AM:
-----------------------------------------------------------------

Committed patch 5a to trunk with revision 734630.

A quick comment on the following piece of code from 
EmbedResultSet.getCharacterStream:
-----
    CharacterStreamDescriptor csd = dvd.getStreamWithDescriptor();

    if (csd == null) {

        String val = dvd.getString();
        if (lmfs > 0) {
            if (val.length() > lmfs)
                val = val.substring(0, lmfs);
        }
        java.io.Reader ret = new java.io.StringReader(val);
        currentStream = ret;
        return ret;
    }

    // See if we have to enforce a max field size.
    if (lmfs > 0) {
        csd = new CharacterStreamDescriptor.Builder().copyState(csd).
                maxCharLength(lmfs).build();
    }
    java.io.Reader ret = new UTF8Reader(csd, this, syncLock);
-----

The last "if (lmfs > 0)" statement will never be run as long as 
SQLChar.getStreamWithDescriptor() returns null, because then the value will be 
materialized (SQLChar.getString()).
We can allow non-Clob values to be treated as streams as well, but I'm not sure 
it is worth it due to the limited size (max 32700 chars).
Opinons?

      was (Author: kristwaa):
    Committed patch 5a to trunk with revision 734630.

A quick comment on the following piece of code from 
EmbedResultSet.getCharacterStream:
-----
            CharacterStreamDescriptor csd = dvd.getStreamWithDescriptor();

            if (csd == null) {

                                String val = dvd.getString();
                                if (lmfs > 0) {
                                        if (val.length() > lmfs)
                                                val = val.substring(0, lmfs);
                                }
                                java.io.Reader ret = new 
java.io.StringReader(val);
                                currentStream = ret;
                                return ret;
                        }

            // See if we have to enforce a max field size.
            if (lmfs > 0) {
                csd = new CharacterStreamDescriptor.Builder().copyState(csd).
                        maxCharLength(lmfs).build();
            }
            java.io.Reader ret = new UTF8Reader(csd, this, syncLock);
-----

The last "if (lmfs < 0)" statement will never be run as long as 
SQLChar.getStreamWithDescriptor() returns null, because then the value will be 
materialized (SQLChar.getString()).
We can allow non-Clob values to be treated as streams as well, but I'm not sure 
it is worth it due to the limited size (max 32700 chars).
Opinons?
  
> Save useful length information for Clobs in store
> -------------------------------------------------
>
>                 Key: DERBY-3907
>                 URL: https://issues.apache.org/jira/browse/DERBY-3907
>             Project: Derby
>          Issue Type: Improvement
>          Components: JDBC, Store
>    Affects Versions: 10.5.0.0
>            Reporter: Kristian Waagan
>            Assignee: Kristian Waagan
>             Fix For: 10.5.0.0
>
>         Attachments: derby-3907-1a-alternative_approach.diff, 
> derby-3907-2b-header_write_preparation.diff, 
> derby-3907-2b-header_write_preparation.diff, 
> derby-3907-2b-header_write_preparation.stat, 
> derby-3907-2c-header_write_preparation-PREVIEW.diff, 
> derby-3907-2c-header_write_preparation-PREVIEW.stat, 
> derby-3907-2c-header_write_preparation.diff, 
> derby-3907-2c-header_write_preparation.diff, 
> derby-3907-2c-header_write_preparation.stat, 
> derby-3907-3a-readertoutf8stream_cleanup.diff, 
> derby-3907-3a-readertoutf8stream_cleanup.diff, 
> derby-3907-3a-readertoutf8stream_cleanup.stat, 
> derby-3907-3b-readertoutf8stream_cleanup.diff, 
> derby-3907-4a-add_getStreamWithDescriptor.diff, 
> derby-3907-4a-add_getStreamWithDescriptor.stat, 
> derby-3907-5a-use_getStreamWithDescriptor.diff, 
> derby-3907-5a-use_getStreamWithDescriptor.stat
>
>
> The store should save useful length information for Clobs. This allows the 
> length to be found without decoding the whole data stream.
> The following thread raised the issue on what information to store, and also 
> contains some background information: 
> http://www.nabble.com/Storing-length-information-for-CLOB-on-disk-tp19197535p19197535.html
> The information to store, and the exact format of it, is still to be 
> discussed/determined.
> Currently two bytes are set aside for length information, which is inadequate.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to