Sequential TFile

In the class description for TFile it states that it can be used in a sequential mode without using the Key list.

" A ROOT file is designed such that one can write in the file in pure
sequential mode (case of BATCH jobs). In this case, the file may be
read sequentially again without using the file index written
at the end of the file. In case of a job crash, all the information
on the file is therefore protected."

Are there any examples of this? I have searched and found none. I have written my own attempt at this with one process writing as another process reads from the same file. I use the functions ReadBuffer() and seek() to read from the file, and ReadKeyBuffer() to load the keys and the GetSeekKey() and GetNbytes() to index for the next ReadBuffer(). In general this work rather well, with a few significant exceptions. The first is that I can not open a Root file without it attempting to generate the KeyList using the Recover() method. I have no method to inhibit this behavior. The second problem is that in order to get the location of the first TKey I have to read in the code that the offset is 100 and enter this in my code by hand. There is no method that I see to get this number as a user of the TFile class. If I could fix these two problems I would be set as the rest of it works great.

I have attempted another method of repeatedly making the Key List with the SaveSelf() and ReadKeys() methods, but this has bigger problems. First I have to keep generating the key list each time I read from the file. This is unnecessary overhead that I don’t want. The second bigger problem is that the ReadKeys() method deletes the key list (fKeys) each time starting fresh. This means if I just want to keep up with what is new in the file, it seem I would have to reindex though the TList of keys each time. My first method of using the raw TKeys is much more efficient and I would prefer a solution like that.

Any help would be greatly appreciated.



I think that the example you are looking for is the Recover method itself.

I am curious to know why you are trying to use this technique (aka what is the higher level problem you are trying to solve).

For your developement purpose it seems that the best way would be to continue prototyping by either modifying TFile directly and/or inheriting from it. Once you have successfully found everything that you need tune/modified to support your use case, we’ll be happy to take a look toward incorporating in the CVS repository.