Object serialization and splitting

Hello,

I am wondering how to write an object (inheriting from TObject) exceeding 1GB in a root file.
I have this 4GB object currently in the root memory but root crashes when I call the Write() function.

In my case, I can maybe subdivide my object which contains 2 huge vector, but it would not be very easy to merge after that… and by summing up those objects in total I would require 8GB in total.

Would it be possible to serialiaze this object and split it by package of 1GB for example ?
Doing this at lower level would be more general maybe and less risky.

Depending on the actual structure of the object and the content of vector, the easiest is likely to store that object as part of a maximal split branch in a TTree with a single entry. In this case each data member of the object and each data member of the content of the vector would be stored ‘indepedently’.

Cheers,
Philippe.

Hi,

Yes I though about that, but in fact it cannot be transformed in such object I think. At least I cannot replace it by TTree

In fact I have set of variables var=(x1,x2,x3,…) I just increament a counter corresponding to the index of the variable in my vector. I guess by using TNtuple or TTree it will dramatically increase the size of my object propotionnally to the size of the tree.

In my case I already determined the size of my vector contained in my object when I declare it.
So if I have at start a 4GB size object, I will stay within 4GB.

but in fact it cannot be transformed in such object I think. At least I cannot replace it by TTree

I was not clear enough.

Where as you do something like

SomeClass object;
....
directory->Write(&object);

I recommend you do:

SomeClass object;
....
TTree *t = new TTree("holder","just one entry");
t->SetDirectory(directory);
t->Branch("object.",&object); // Defaults to maximum splitting.
t->Fill();
t->GetFile()->Write();
delete t;  // or reuse.

Cheers,
Philippe.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.