Quote:
Do you have any written code that does ramdom
selection for large tables(3 million recs)? If you do, would post it? |
ja,
A "single shuffle" random is pretty easy to do with the
assistance of a keyed paradox table.
I've use this routine for many years but for at most 200 or
so records.
First create a paradox table with 2 keyed longint fields.
See 1) Below.
The routine first checks how many records (J) are in your
source table, then creates that many records in QSort.DB
with the 2nd field filled with the numbers 1 - J.
Note(1) - In the shuffle loop, only J-1 items are randomized.
The Jth item is the last card in the deck so to speak.
Note(2) - If it's too slow to randomize 3M records, use a
small (K) : i.e. k = j / 25 and go through the loop (k) times.
The table's last K# of records will be the one "randomized".
Note(3) - Computer rand() functions aren't very good but
the same routine given below could be used iteratively to
shuffle the deck N # of times (requires N+1 keyed fields)
which is out of the question for 3M records.
To see what happens, use much smaller J and/or K for tests.
i.e. First let J = 100 first and watch what happens in QSort.DB
And then set K = 10 and re-inspect the QSort.DB table (only
the last K recs are random).
Lastly, I highly recommend doing a run J = 300,000 and/or
K = 12,000 run to get feel for how fast/slow the routines are
before committing to 3million entries. If that takes too long,
you may want to consider creating QSort.DB in Delphi or
other external means.
Ed
--------------------------------------------
1)
QSort.DB has 2 keyed fields:
* RandOrd (LongInt)
* TblRNum (LongInt)
--------------------------------------------
var
tcS, tcQ tcursor
i,j,k,R,
RMin,RMax LongInt
endvar
tcS.open("YourOrigTableNameHere.DB")
j = tcS.nRecords()
tcS.close()
tcQ.open("QSort.DB")
tcQ.empty()
tcQ.edit()
for i from 1 to j
tcQ.InsertAfterRecord()
tcQ.(2) = i ; It's a tiny bit faster than
endfor ; tcQ."TblRNum" = i
tcQ.postrecord()
sleep(0)
k = j-1 ; **
for i from 1 to k ; **
RMin = 1
RMax = k+1
R = SmallInt (rand()*(RMax-RMin+1)+RMin)
tcQ.movetoRecord(R)
tcQ.(1) = i
endfor
tcQ.endedit()
tcQ.close()