How to sort b sequence? FW: Order of returned VArraySet rids when using FindLinked with a VArraySet arg.

Ruslan Zasukhin sunshine at public.kherson.ua
Thu Dec 15 12:16:53 CST 2005


On 12/15/05 3:38 AM, "Ed Kleban" <Ed at Kleban.com> wrote:

> I have two tables.
> 
> The first is TblItems  which has some miscellaneous fields.
> 
> The second is TblTree which keeps the MANY:MANY parent/child
> releationships and and sequence order of children for the records in
> TblItems.   
> 
> TblTree has 3 fields:
> 
>     fTreeParent as VObjectPtr  // Rid of parent in TblItems
>     fTreeChild as VObjectPtr   // Rid of child in TblItems
>     fTreeSeq as UShort         // Relative sequence number of child.
> 
> So I now want to implement a method that will return a list of the children
> in sequence order for a given parent.
> 
> First I get all the children records for a given parent:
> 
>     treeRidSet = TblTree.fTreeParent.FindLinked( _
>                        parentItemRid,TblTree, TblItems )

treeRidSet -- this is ArraySet. ok

> What I would like to then do is:
> 
>     // Sort records by sequence number:
>     orderedTreeRidSet = TblTree.Sort( treeRidSet, TblTree.fTreeSeq )

MISTAKE!

    treeRidSet -- is set of records for table TblItems.

So you cannot use it in TblTree.Sort()
 
>     // Retrieve TblItem Rids in the current sorted order:
>     orderedItemRidSet = _
>         TblTree.vlChildToItemLink.FindLinkedAsArraySet( _
>             orderedTreeRidSet, TblTree, TblItems )
> 
> However, there is no such call as FindLlinkedAsArraySet, and I'm not sure it
> would preserve the inSet order if there was.

You mean function which convert
    ArraySet of T1 into ArraySet of T2 ?
 
Yes there is no such method. Up to know I was need only
    BitSet of T1 into BitSet of T2

> So how do I do this?  I guess I could try and retrieve the child links
> first:
> 
 >     unorderedChildBitSet = _
>         TblTree.vlChildToItemLink.FindLinkedAsBitSet( _
>             treeRidSet, TblTree, TblItems)
> 
>     // Perform painful, expensive conversion from BitSet to ArraySet
>     unorderedChildArraySet = VArraySet( unorderedChildBitSet )
> 
> But then how do I sort these based on the order of TblTree records in
> orderedTreeRidSet ?
> 
> This one just has me stumped.  The only solutions that come to mind are:
> 
> 1) Do all this much more slowly in SQL.  Yuck.

I think this is only a way until we give you power of BinaryLink Ordered
 
> 2) Combine the TblTree fields into TblItems where I have a sufficent set of
> API calls to make this work... But now that TblTree is managing MANY:MANY
> parent/child relationships his just isn't feasible.

right
 
> 3) Convince to you write ASAP a FindLinkedAsArraySet method that preserves
> the same order of records in the VArraySet result as the same order in the
> passed inSet argument.

You have see mistake above?

So you need do 2 such conversions.

    find items
    convert to tree
    sort
    convert to items

Now tell me, that BinaryLinks with order beat
ANYTHING that RDBMS world can offer :-))


-- 
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