Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need to improve algorithm for sorting on long string
Message
From
25/06/2003 19:27:40
 
 
To
18/06/2003 10:33:20
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00800928
Message ID:
00804041
Views:
28
Fabio,

Thanks. I will give this a try.


>Hi David,
>
>if you want order a Memo field you can use this code.
>
>This is a hashing methods.
>
>I try for 100000 records with memo >7000 chars;
>i think limit is 254*254=64516 chars.
>
>The limit is need to add a Integer field ( pos ) to support memo order Index.
>
>
>* Table for test
>CREATE CURSOR test (f1 M,pos I)
>
>INSERT INTO test (f1) values(REPLICATE('Z',500)+REPLICATE('1',RAND()*500))
>INSERT INTO test (f1) values(REPLICATE('A',500)+REPLICATE('2',RAND()*500))
>INSERT INTO test (f1) values(REPLICATE('Z',500)+REPLICATE('1',RAND()*500))
>INSERT INTO test (f1) values(REPLICATE('A',500)+REPLICATE('0',RAND()*500))
>
>* Init: build a CursorIndex with table boolmarks
>* and split Memo in string
>
>SELECT RECNO() bookMark;
>,LEFT(f1,254);
>,LEFT(SUBSTR(f1,255),254);
>,LEFT(SUBSTR(f1,509),254);
>,LEFT(SUBSTR(f1,763),254);
>FROM Test ORDER BY 2,3,4,5 INTO CURSOR OrdMemo
>
>* Index BookMark for relation
>
>INDEX ON bookMark TAG RX
>
>SELECT Test
>
>* join table with Index
>
>SET RELATION TO RECNO() INTO OrdMemo
>
>* fill order field
>
>REPLACE pos WITH RECNO('OrdMemo') ALL
>
>* release temporary index
>
>USE IN OrdMemo
>
>* build memo index with hashing keys
>
>INDEX ON pos TAG IXMemo
>
>BROWSE
>
>
>You can build mixed index: Memo,Chars,Date,Numeric,....
>
>Fabio
Previous
Reply
Map
View

Click here to load this message in the networking platform