January 13th, 2003, 07:22 PM
highly optimized file reading and writing?
I want to know if this is possible:
To write an array of data directly to the disk and then later read it back into memory without ever having to parse the data.
In more detail, the write to the disk would be an exact byte per byte copy, (done whichever way is the fastest and most optimized possible), directly from memory to disk, without worrying about data structures and variables. The read from the disk will be exactly the same, ignoring all data structures, variables, and any parsing what-so-ever. The read will directly overwrite the exact space in memory that is already declared. If this could be done, then I think this is the fastest way to store an array of data to disk that needs to be constantly reloaded into memory to be udpated and then quickly stored again.
Is this possible?
January 13th, 2003, 07:27 PM
(BTW, I know that it would be faster to simply keep the data in memory and update the data in memory and then periodically write the whole thing to disk, especially seeing that this is a webpage application, but this is not an option as I have not learned how to do this yet.)
January 13th, 2003, 08:56 PM
Yes, it is possible to do a write to disk and reread the data into a buffer. However, it sounds like you probably want to use shared memory instead, especially if you want to share some common data between multiple instances. This way, you can avoid disk I/O
Hopefully this link may prove to be useful.
January 23rd, 2003, 12:37 PM
Thanks for the link, Scorpions4ever, but I think I am going to try to save everything to disk before I learn how to code a server that handles requests and all of that.
Ok, if I can do this, can I reread the data into a buffer located in the exact space of memory as an already defined and declared array, for example?
January 23rd, 2003, 04:39 PM
Yes, you can. If you think about it, when you're reading any character string (whether from file or from console), you're putting it into an already defined and declared character array. The only thing you need to watch out for is to ensure that your buffer is large enough to contain the data that you're reading back into it.
January 24th, 2003, 12:09 PM
Excellent. This is obviously the fastest way to write data to a disc and later read it back. No parsing what-so-ever.