Author | Message |
---|---|
ptran6
Posts: 25
|
Posted 22:22 Nov 15, 2010 |
Dr. Sun, you said that we will lose points if we iterate backwards and keep all the records in memory in order to iterate forward later. But what if we iterate backwards and somehow keep all the positions of the records rather than the records themselves? Is that okay? |
cysun
Posts: 2935
|
Posted 23:15 Nov 15, 2010 |
No. There's no guarantee that the size of all the "positions" will be under 1 block. |
ptran6
Posts: 25
|
Posted 12:21 Nov 16, 2010 |
So it seems the only way to do this is to modify the LogMgr to write the log differently (i.e. for each record, write the position of the next record as well as the position of the previous record). Is that the way you want us to do it? If so, then wouldn't that corrupt the log file? Because some of the records were written the original way, and some will be written using the new approach. |
cysun
Posts: 2935
|
Posted 14:31 Nov 16, 2010 |
The SimpleDB log format is designed to make backward scan easier, but it doesn't mean it's impossible to use it for forward scan. There are several different ways to do forward scan in the homework assignment: 1. As you said, you can modify the log format so that it's easy to do both backward and forward scan. If you take this approach, you can delete the whole database and start fresh so you won't have mixed block formats in the same log file. You are not working on a production system so you don't need to preserve existing data. 2. You can also do what you mentioned before - backward scan first, keep the "positions", then forward scan. Note that if you do this, you must do it one block at a time, i.e. at any time you only keep the "positions" of the records in one block, which will take very little extra space. 3. And yes, you can do forward scan with the original log format. The coding is a bit tricky but it's very much doable. |
ptran6
Posts: 25
|
Posted 14:50 Nov 16, 2010 |
Okay, thank you for your help, Dr. Sun. |