private static class TemporaryClob.CharToBytePositionCache
extends java.lang.Object
The implementation is very simple and is basically intended to speed up writing a sequence of consequtive characters one character at a time. Even though this should be avoided if possible, the penalty of updating a large Clob this way and finding the correct byte position by navigating from the start of the byte stream each time is so severe that a simple caching mechanism should be in place. Note that for other encodings than UTF-8, this might not be a problem if the mapping between character position and byte position is one-to-one.
Note that to ensure consistency between character and byte positions, access to this class must be synchronized externally to avoid caller 1 getting the character position, then caller 2 updates the cached values and then caller 1 gets the updated byte position.
Constructor | Description |
---|---|
CharToBytePositionCache() |
Modifier and Type | Method | Description |
---|---|---|
(package private) long |
getBytePos() |
Returns the last cached byte position.
|
(package private) long |
getCharPos() |
Returns the last cached character position.
|
(package private) void |
reset() |
Resets the position cache.
|
(package private) void |
updateCachedPos(long charPos,
long bytePos) |
Updates the position cache.
|
long getBytePos()
long getCharPos()
void updateCachedPos(long charPos, long bytePos)
charPos
- the character position to cache the byte position forbytePos
- byte position for the specified character positionvoid reset()
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.