Aug 21, 2000, 3:31 AM
Post #2 of 3
Depending on what pattern you're trying to find (a few hundred chars or possibly 100.000+ chars), you might use overlapping 'chunks'.
Re: global matching in big files
[In reply to]
- read in chars 0-99.999 and match
- keep the last 1000 (?) chars, append chars 100.000-199.999 to it and match again
- and so on
The size of the overlap would depend on your typical match, of course, so it's definitely not a good solution for ALL cases.
And you'll have to be careful of matching things that are in the overlapping part twice.
Anyway, it's just an idea - I'm not sure how this compares to gobbling up the whole file into memory, but it's definitely going to take more processing. Sleep()ing between loops or lowering the priority of that task might solve your problem too