[Valentina] M:M problems

Ruslan Zasukhin sunshine at public.kherson.ua
Mon Jan 20 19:23:42 CST 2003


on 1/20/03 6:53 PM, Eric Forget at forgete at cafederic.com wrote:

>>> Also, how do you get an FBL_ArraySet with all the person of a certain group?
>> 
>> Well, Eric, note that you can work only with bitSets and arraySets to do
>> searches manually, using Find() function of VDK_Field.
>> Or you can do searches using SQL and get as result VDK_Cursor.
>> 
>> First way is MUCH FASTER, but require more work from you in coding.
>> This is like old known navigation access to records. Although one little
>> difference you work not with single current record, but with sets of
>> records.
>> 
>> In the same time, first way, allow you query only single table,
>> So if you need some kind of complex query, and you want work with complex
>> relational model, you need choose SQL.
>> 
>> Of course in sample places you can use BitSets to optimize simple searches.
>> 
>> --------
>> So, how to get ArraySet of all person of specific group:
>> Very simple. You need touch only one table
>> 
>> FBL_ArraySet* FindPersonsOfGroup( FBL_REC_ID inGroupRecID )
>> {
>>   BitSet* s1 = mGroupPerson.mGroupPtr.Find( &inGroupRecID );
>> 
>>   FBL_AraySet* res = new FBL_ArraySet( s1->getCount() );
>>   
>>   // now you have set of records for this group,
>>   // and you need just iterate it, and extract RecIDs of Persons.
>> 
>>   BitSetIterator it( *s1 );
>>   FBL_REC_ID gp = it.First(); // this is RecID of GroupPerson table.
>>   while( gp )
>>   {
>>       if( mGroupPerson.GoTo( gp ) )
>>       {
>>           res->Add( mGroupPerson.mPersonPtr );
>>       }
>> 
>>       gp = it.Next();
>>   }
>> 
>>   return res;
>> }
> 
> I'm just wondering, if I have a very big table, it will be fast anyway? How
> about the memory occupied?

What exactly fast ?

Find() yes.

Iteration of table take time of course. The more records you read from disk
the more time you need.

But believe me, Valentina will give you fastest access for above operation,
because it keep fields in separate files. So when you iterate field...

Aha, aha. In my example I do Goto for Table itself.
This is where VDK_Cursor can be faster.
Look, if you have table with 20 fields, but SELECT only 2 fields, cursor
iterate only these 2 fields from disk. Speed up is 10 times comparing to
other dbs.

And I wonder now, why I have not add to VDK_Field a GoTo() function.
It seems in ver 2.0 I already have it.


> Also, I need the array to be sorted. How I should do it?

Sort by what ?

If simply by values that are stored in array then -- arr.Sort().

> Finally, if I create an FBL_AraySet from a FBL_BitSet like this:
> 
> mGroupArray = mReceipe.Sort(allSet, mGroup.mName, true);
> 
> It looks like I have to keep alive allSet until mGroupArray is not deleted.
> Otherwise, mGroupArray becomes corrupted, isn't it?

Of course no.

We need to economy memory :-)

-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://listserv.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list