in reply to Message Board Mangling
What you're talking about is being able to re-order existing records. The best strategy for this might be to use a single BerkeleyDB database, and re-define the keys from time to time to re-define the order of the posts. So in the value of each record, you maintain the time of the post (so you can get latest-first), and the ID or quality ranking of the poster, as well as the messsage. You generate your keys to the most significant few (say, 4) bytes supply a serial number that gives the number of re-order passes. This way, as you re-order records, they go to the end of the database, and you can then delete them from the beginning.
Each time you re-order, you do this:
increment the re-order sequence number For each record that was not re-ordered this time through, read the record re-compute the key based on the age and poster ID write the new key/value pair (with the new re-order number) delete the old key/value pair
The beauty of this is that BerkeleyDB will efficiently reclaim the file space with a minimum of work. When you have new messages, you just give them a key that will allow you to find them before the previous messages (cursors in BerkeleyDB can go forwards (DB_NEXT) or backwards (DB_PREV)).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Message Board Mangling
by achiles (Novice) on Jul 12, 2001 at 15:20 UTC | |
by achiles (Novice) on Jul 12, 2001 at 16:01 UTC | |
by Thathom (Acolyte) on Jul 13, 2001 at 01:00 UTC |