Can we assign name to the serialized objects?
During serializing objects, can we assign name to different objects? So, that on the time of reading objects, i can call any object by its name and later on can access its members.
I can do it by assigning a unique field to each object and 开发者_如何学运维later compare it against that field but that will cost - O(n).
Is there any other way to fast access any particular object, serialized in a file of suppose 100 objects.
Thanks you
Put them in a map and serialise the map instead?
Why do all of the objects have to be in one stream? What if you just save each object in its own file and access the object by file name? If you really need a single file, you could archive them all in a ZIP file, and let it handle the indexing function for you.
Maybe it's overkill, but for that use case i would use a database. Something like Berkeley DB sounds appropiate:
http://download.oracle.com/docs/cd/E17277_01/html/GettingStartedGuide/index.html
精彩评论