#1
  1. No Profile Picture
    matthewdoucette.com
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2002
    Posts
    635
    Rep Power
    13

    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?
    Matthew Doucette / Xona.com
  2. #2
  3. No Profile Picture
    matthewdoucette.com
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2002
    Posts
    635
    Rep Power
    13
    (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.)
    Matthew Doucette / Xona.com
  4. #3
  5. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,638
    Rep Power
    4247
    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.
  6. #4
  7. No Profile Picture
    matthewdoucette.com
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2002
    Posts
    635
    Rep Power
    13
    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.

    Originally posted by Scorpions4ever
    Yes, it is possible to do a write to disk and reread the data into a buffer.
    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?
    Matthew Doucette / Xona.com
  8. #5
  9. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,638
    Rep Power
    4247
    Originally posted by Doucette
    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?
    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.
  10. #6
  11. No Profile Picture
    matthewdoucette.com
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2002
    Posts
    635
    Rep Power
    13
    Excellent. This is obviously the fastest way to write data to a disc and later read it back. No parsing what-so-ever.
    Matthew Doucette / Xona.com

IMN logo majestic logo threadwatch logo seochat tools logo