Click here to Skip to main content
15,890,438 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: OracleDataReader GetChars method only buffering half the characters Pin
Aaron Rosenthal23-Jul-15 6:11
Aaron Rosenthal23-Jul-15 6:11 
GeneralRe: OracleDataReader GetChars method only buffering half the characters Pin
Richard Deeming23-Jul-15 6:20
mveRichard Deeming23-Jul-15 6:20 
GeneralRe: OracleDataReader GetChars method only buffering half the characters Pin
Aaron Rosenthal23-Jul-15 6:24
Aaron Rosenthal23-Jul-15 6:24 
SuggestionRe: OracleDataReader GetChars method only buffering half the characters Pin
Richard Deeming23-Jul-15 6:25
mveRichard Deeming23-Jul-15 6:25 
AnswerRe: OracleDataReader GetChars method only buffering half the characters Pin
Richard Deeming23-Jul-15 6:37
mveRichard Deeming23-Jul-15 6:37 
GeneralRe: OracleDataReader GetChars method only buffering half the characters Pin
Aaron Rosenthal23-Jul-15 8:02
Aaron Rosenthal23-Jul-15 8:02 
GeneralRe: OracleDataReader GetChars method only buffering half the characters Pin
Eddy Vluggen23-Jul-15 9:19
professionalEddy Vluggen23-Jul-15 9:19 
GeneralRe: OracleDataReader GetChars method only buffering half the characters Pin
Richard Deeming23-Jul-15 9:50
mveRichard Deeming23-Jul-15 9:50 
The code from my version (slightly tidied up) looks like:
C#
// OracleDataReader.GetChars:
public override long GetChars(int i, long fieldOffset, char[] buffer2, int bufferoffset, int length)
{
    // Pre-condition checks omitted
    return this._columnInfo[i].GetChars(this._buffer, fieldOffset, buffer2, bufferoffset, length);
}

// OracleColumn.GetChars:
internal long GetChars(NativeBuffer_RowBuffer buffer, long fieldOffset, char[] destinationBuffer, int destinationOffset, int length)
{
    // Pre-condition checks omitted
    
    int result;
    if (this.IsLob)
    {
        // The OP said it's a CLOB column, so we're in this branch.
        using (OracleLob oracleLob = new OracleLob(this._lobLocator))
        {
            string str = (string) oracleLob.Value;
            int length1 = str.Length;
            int startIndex = (int)fieldOffset;
            result = length1 - startIndex;
            if (destinationBuffer != null)
            {
                result = Math.Min(result, length);
                if (0 < result) Buffer.BlockCopy(str.ToCharArray(startIndex, result), 0, destinationBuffer, destinationOffset, result);
            }
        }
    }
    else
    {
        // Omitted
    }
    
    return (long) Math.Max(0, result);
}

// OracleLob.Value:
public object Value
{
    get
    {
        // Pre-condition checks omitted
        
        long num = this._currentPosition;
        try
        {
            this.Seek(0L, SeekOrigin.Begin);
            if (this._lobType == OracleType.Blob || this._lobType == OracleType.BFile)
            {
                // Code to read and return a byte array omitted, since we're read a CLOB.
            }
            
            return new StreamReader(this, Encoding.Unicode).ReadToEnd();
        }
        finally
        {
            this._currentPosition = num;
        }
    }
}

So basically:
  1. The OracleLob.Value property reads the entire CLOB value into memory as a string;
  2. The OracleColumn.GetChars method calls ToCharArray which copies (a portion of) the string to a new array;
  3. It then uses Buffer.BlockCopy to copy the characters from the new array to the destinationBuffer array;


It's not quite as bad as I thought - it's only copying a portion of the string to a new array when it calls ToCharArray, rather than the whole string.

But it's still pretty bad compared to using a StreamReader over the OracleLob object. Smile | :)



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: OracleDataReader GetChars method only buffering half the characters Pin
Eddy Vluggen23-Jul-15 10:27
professionalEddy Vluggen23-Jul-15 10:27 
QuestionHow to rename texts in a Standart Browse File / Browse Folder Dialog Pin
satc22-Jul-15 4:14
satc22-Jul-15 4:14 
AnswerRe: How to rename texts in a Standart Browse File / Browse Folder Dialog Pin
Eddy Vluggen22-Jul-15 4:38
professionalEddy Vluggen22-Jul-15 4:38 
GeneralRe: How to rename texts in a Standart Browse File / Browse Folder Dialog Pin
satc22-Jul-15 20:02
satc22-Jul-15 20:02 
GeneralRe: How to rename texts in a Standart Browse File / Browse Folder Dialog Pin
Eddy Vluggen22-Jul-15 21:40
professionalEddy Vluggen22-Jul-15 21:40 
QuestionA validation information inside a zip file Pin
satc22-Jul-15 2:43
satc22-Jul-15 2:43 
AnswerRe: A validation information inside a zip file Pin
Eddy Vluggen22-Jul-15 3:51
professionalEddy Vluggen22-Jul-15 3:51 
AnswerRe: A validation information inside a zip file Pin
Dave Kreskowiak22-Jul-15 3:53
mveDave Kreskowiak22-Jul-15 3:53 
GeneralRe: A validation information inside a zip file Pin
satc26-Jul-15 0:11
satc26-Jul-15 0:11 
GeneralRe: A validation information inside a zip file Pin
Dave Kreskowiak26-Jul-15 3:39
mveDave Kreskowiak26-Jul-15 3:39 
QuestionHelp with datetime Pin
jkirkerx21-Jul-15 10:58
professionaljkirkerx21-Jul-15 10:58 
AnswerRe: Help with datetime Pin
Dave Kreskowiak21-Jul-15 11:56
mveDave Kreskowiak21-Jul-15 11:56 
GeneralRe: Help with datetime Pin
jkirkerx21-Jul-15 13:05
professionaljkirkerx21-Jul-15 13:05 
SuggestionRe: Help with datetime Pin
Ralf Meier21-Jul-15 21:28
mveRalf Meier21-Jul-15 21:28 
SuggestionRe: Help with datetime Pin
Richard Deeming22-Jul-15 1:40
mveRichard Deeming22-Jul-15 1:40 
GeneralRe: Help with datetime Pin
jkirkerx22-Jul-15 6:00
professionaljkirkerx22-Jul-15 6:00 
QuestionVb.net - Datagridview not populated Pin
Marcus Genovese16-Jul-15 23:45
Marcus Genovese16-Jul-15 23:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.