in reply to Removing the first record in a file containing fixed records
Not really without altering the structure. You can truncate files from the end, but you can't . . . precate (if I may coin a terrible word) things off the front. A kludge (although this is remotely similar to what some databases do) is to alter some part of the record to signal it as invalid (perhaps setting a field to say XXXDELETEDNOUSEXXX) and then have your downstream processing ignore these records; periodically you can have a utility "vacuum" out the deleted records by copying the live records into a new file as you mention above. Alternately if ordering of records in the file is not important you can overwrite deleted records with new ones in place (perhaps maintaining an external "free list" of offsets of deleted record slots).
Of course doing this type of thing you're already on your way towards reimplementing your own database system so you might want to consider taking that plunge and letting someone else do the heavy lifting for you and concentrate on your processing tasks.
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Removing the first record in a file containing fixed records
by Crackers2 (Parson) on Jul 18, 2008 at 00:48 UTC | |
by Perlbotics (Archbishop) on Jul 18, 2008 at 09:08 UTC | |
|
Re^2: Removing the first record in a file containing fixed records
by goibhniu (Hermit) on Jul 18, 2008 at 17:27 UTC |