Steven Tripp wrote:
> 
> I have two large files F1 (4.5 MB) and F2 (12 MB).
> 
> F1 is an index to F2.  It contains a list of words and byte offsets
> to instances of those words in F2.
> 
> They are used in this way:  Look up word in F1 and use byte offsets
> to SEEK directly to desired data in F2 (no problem).
> 
> What is the best (fastest) way to find a string in F1?  Should it be
> imported into a field first (MC seems to be crashing when I try this
> and actually I have four indexes, so this is not desirable)?  Or do
> you have to read it in from a file, line by line, and check each line
> as it comes in?

If each line in F1 contains, as first item, one word only and, as second
to the number of items in the line, the offsets of all occurences of
this word in F2 :

on preopenstack
 global VF1,VF2
 open file F1 for read
 read from file F1 until eof
 put it into VF1
 close file F1

...and so on with F2

end preopenstack

on parseindex
 global VF1,VF2
 get lineoffset(theword,VF1)
 if it is not "0" then
  repeat for each item i in line it+1 of VF1
   if i is 1 then
   else put offset i (and more) of VF2 & cr afterthereply
  end repeat

 ... and there do what you need withthereply

 else answer "no occurence found"
end parseindex

Don't use the 4 and 12 Mo files or vars as is. Metacard will be many
more efficient in parsing lot of small vars than just one big. I use
always 25 vars for 1 Mo of datas and, in using this way, answer are
coming back in just some ticks.

As Scott said, previously, arrays are the finest way to speed more and
more your searching process.

Hope this can help...

> Seems like there should be a better way.  Can matchtext be used on a file?
> 
> Steve Tripp
> 
> Archives: http://www.mail-archive.com/metacard%40lists.best.com/
> Info: http://www.xworlds.com/metacard/mailinglist.htm
> Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Regards, Pierre Sahores

CRDP de l'academie de Creteil
WEB, DB, ASP, VPN, B2B design

Archives: http://www.mail-archive.com/metacard%40lists.best.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to