Hi all,
I am trying to implement an order database, which stores records (typically ~500records) in line.
e.g.
order: 1 [type: 1; date: xxxxx; price: $xxx]
order: 2 [type: 4; date: xxxxx; price: $xxxxx]
order: 3 [type: 3; date: xxxxx; price: $xx]
..
order: x [type: 3; date: xxxxx; price: $xxxxxxx]
I would like to efficiently alter the content for example line #2, without reading all records into an array of order structure. How can I do this?
Cheers,
hl
But, if you're committed to this, you have two "real" choices.
1) Preset all the records to the same length so that you CAN change it in place. Actually changing the data is pretty simple if the record size doesn't change.
2) Map the file over paged memory. mmap() on unix systems. The instead of doing reads() and writes() you can treat the entire file as just a big array and let the system's page handler do all of the I/O behind the scenes.
Kdo