Re: Constructing sequences
- Posted by "Igor Kachan" <kinz at peterlink.ru> Jun 29, 2005
- 604 views
Derek Parnell wrote: > > Mario Steele wrote: > > > > Allright, > > > > Considering someone posted something about file i/o (Including Kat), about this, and > > the overwhelming evidence that pre-allocation is best way to go, here should be an > > extreamly fast version of loading a file into Memory (AKA Sequence): > > It seems that a lot of people have missed the original poster's point. > Or maybe its just me But the way I read it is that they were trying > to load each LINE of a text file into its own sub-sequence, rather than > load the entire file into one single sequence. Thus a file with twenty > lines would create twenty sub-sequences. > > Rob Craig's code is about the best so far for doing that, though I'm sure > it could still be tweaked a bit more. What to me, I try to answer the following Gordon's question: GW>> I am reading the data records in from a file so I don't see an GW>> obvious way I could build the whole sequence at once. Wouldn't GW>> I have to temporariliy store the records in another sequence, GW>> incurring the same 'append' overhead anyway? Really, the way with the *file size* is absent in the original RDS documents, as far as I can see, so it is not *obvious way*, I think. But these ways exist. So, any one can place a big file into single sequence at once and do all he/she wants with that sequence - scan, find CR/LF, make lines, records, parse them etc etc. Mario takes this point in his attention too, I think. Matt's approach is the simplest one - just create a sequence with some extra elements to place a big file without risk to go away from the sequence space while reading a file. Regards, Igor Kachan kinz at peterlink.ru