Loading a Record

Ruslan Zasukhin sunshine at public.kherson.ua
Sun Feb 5 22:59:23 CST 2006


On 2/5/06 5:13 PM, "Philip Mötteli" <philip.moetteli at econophone.ch> wrote:

Hi Philip,

>> No. you do not load anything manually!
>> 
>> After put_RecID( 10 ) Valentina already have load this record into
>> fields.
>> You can just read values of fields.
> 
> Great!

> When is the memory occupied by the values of those fields released or
> changed (overwritten)? How long can I keep a pointer to those memory
> blocks given to me by "I_Value.begin()" and be sure, that the memory
> is accessible and contains the right value? Should I copy them
> immediately to be sure to keep the right value?

> As I understand, if the VSDKC++ does not overwrite this part of the
> memory (e. g. with the next "I_Table.put_RecID()") and automatic
> garbage collection is used, these memory blocks should be valid and
> contain the right values, as long as I keep a pointer to them?

NO. 

Each change of record do load values into the same buffers.

It is implemented like this:

Class VField
{
    I_Value_Ptr     mpValue;
}


Class Value_Long
{
    long        mValue;
}

Class Value_String
{
    char*       mpBegin;
    char*       mpBufferEnd;
    char*       mpEnd;
}

You can see all values in the Vshard/FBL/publ/Values folder.

So we do not go so deeply with garbage collections.
Each value simply have static own buffer.

But you should not keep pointers to this buffer!
You should not even keep pointers to

        I_Value_Ptr pValue = pField->get_Value();

Because soon we can optimize performance, so get_Value()
Will return each time other value.

This is because in fact Field keep 2 values:

    mpValue and 
    mpPrevValue.


So rule for work is next:

    You have Db. 
    You have Tables and Cursors.
    You have fileds.

You say:

    Table/Cursor go to that record.
    Now you can read/write its values:

        Table->get_Field(i)->get_Value()->get_String()

If you have direct pointers to fields then simple:

        pField()->get_Value()->get_String()
        pField()->get_Value()->get_ULong()
        ...



-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]




More information about the Valentina mailing list