Derby
  1. Derby
  2. DERBY-4241

Improve transition from read-only to writable Clob representation

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 10.5.1.1, 10.6.1.0
    • Fix Version/s: 10.7.1.1
    • Component/s: JDBC
    • Labels:
      None
    • Bug behavior facts:
      Performance

      Description

      When a store stream Clob is going to be modified, it will be written out to the temporary area of Derby and represented as a TemporaryClob.
      The transfer of the data is done in a sub-optimal manner for two reasons;
      o for transfer of the complete Clob, the copy method operates on the byte level and we're not able to save the character length.
      o for transfer of parts of the Clob (i.e. truncation), we have to first decode the UTF-8 encoding to find the byte count and then transfer the same bytes.

      I intend to do the following two changes;
      1) Add a getCharLengthIfKnow-method to InternalClob.
      2) Add a UTF-8 aware copy method to LOBStreamControl.

      When a complete Clob is to be copied, code like this will be executed;
      cachedCharLength = internalClob.getLengthIfKnown();
      if (cachedCharLength > 0)
      // use existing byte-oriented copy method for best performance (copy until EOF)
      else
      cachedCharLength = control.copyUTF8Data()

      When parts of a Clob is to be copied, we always use the UTF-8 aware copy method, but we also do a cheap range check.
      cachedCharLength = internalClob.getLengthIfKnown();
      if (cachedCharLength > 0 && requestedLength > cachedCharLength)
      throw EOFException();
      if (cachedCharLength == requestedLength)
      // use existing byte-oriented copy method for best performance (copy until EOF)
      else
      cachedCharLength = control.copyUTF8Data(requestedLength);

      Adding the UTF-8 aware copy method was started under DERBY-4023, including comments on the first revision of a patch.

      1. better.txt
        4 kB
        Kristian Waagan
      2. derby-4241-1a-InternalClob.getLengthIfKnown.diff
        3 kB
        Kristian Waagan
      3. derby-4241-2a-utf8AwareCopy.diff
        11 kB
        Kristian Waagan
      4. derby-4241-2b-utf8AwareCopy.diff
        12 kB
        Kristian Waagan
      5. derby-4241-32core-cmt.txt
        5 kB
        Kristian Waagan

        Issue Links

          Activity

          Kristian Waagan created issue -
          Kristian Waagan made changes -
          Field Original Value New Value
          Status Open [ 1 ] In Progress [ 3 ]
          Kristian Waagan made changes -
          Kristian Waagan made changes -
          Derby Info [Patch Available]
          Kristian Waagan made changes -
          Attachment derby-4241-2a-utf8AwareCopy.diff [ 12408817 ]
          Kristian Waagan made changes -
          Parent DERBY-4023 [ 12412580 ]
          Issue Type Sub-task [ 7 ] Improvement [ 4 ]
          Kristian Waagan made changes -
          Link This issue is related to DERBY-4023 [ DERBY-4023 ]
          Kristian Waagan made changes -
          Status In Progress [ 3 ] Open [ 1 ]
          Kristian Waagan made changes -
          Attachment better.txt [ 12447698 ]
          Attachment derby-4241-32core-cmt.txt [ 12447699 ]
          Kristian Waagan made changes -
          Attachment derby-4241-2b-utf8AwareCopy.diff [ 12448196 ]
          Kristian Waagan made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Issue & fix info [Patch Available]
          Fix Version/s 10.7.0.0 [ 12314971 ]
          Resolution Fixed [ 1 ]
          Kristian Waagan made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Rick Hillegas made changes -
          Fix Version/s 10.7.1.1 [ 12315564 ]
          Fix Version/s 10.7.1.0 [ 12314971 ]
          Gavin made changes -
          Workflow jira [ 12464084 ] Default workflow, editable Closed status [ 12800251 ]

            People

            • Assignee:
              Kristian Waagan
              Reporter:
              Kristian Waagan
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development