| Message |
That's right. No matter how big the file is, it'll be 4k. And if you ever have 4k+1 of actual size, the file will take up 8k. This doesn't matter a lot for large files (what is 4k when you already have 10mb?) but it really kills on the smaller files like the ones you have.
BerkeleyDB provides a simple table storage mechanism. You define key-value pairs. It's not a 'database' in the SQL sense of the term. That is, you can't have multiple columns in your tables, etc. You just have unique key to value.
In your case, the key could be the player name, and the value could be the quest data. You could even, conceivably, store the file you're currently writing to disk in string form in the database; you would load that string and parse it using the code you already have.
The advantage to using BerkeleyDB for you would be that you wouldn't get the massive overhead of storing lots of small files. In parallel, however, you'll have to deal with the BerkeleyDB stuff, making sure you open/close the file correctly. I remember from using BerkeleyDBXML (an actual XML database built around BerkeleyDB) that it wasn't very tolerant of crashes; if the database wasn't closed properly you couldn't open it without doing some voodoo on it first. BerkeleyDB is supposed to be fairly lightweight; I've seen it used in many places but have never used it myself. My suggestion would be to check it out and see if it seems reasonable.
If that doesn't work, my suggestion would be to either find another library, or write some code that stores quest data in groups. For example, all players whose names start with 'a' could be in one file. That will help a great deal with your overhead problem. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | top |
|