aiidateam / disk-objectstore

An implementation of an efficient "object store" (actually, a key-value store) writing files on disk and not requiring a running server
https://disk-objectstore.readthedocs.io
MIT License
15 stars 8 forks source link

Add `has_object` method to the `Container` class #45

Closed sphuber closed 4 years ago

sphuber commented 4 years ago

It would be a useful shortcut method to determine whether an object is contained within a given container.

giovannipizzi commented 4 years ago

Indeed, thanks! However since it's expensive, I'd probably add has_objects instead, that gets a list of hash keys.

giovannipizzi commented 4 years ago

I implemented the bulk method in #47. For simplicity, for now I still resort, in the end, to opening files, as the logic to avoid to do so is relatively complex. I add a performance test, so later we can decide if we need to improve performance (see #48). But at least the bulk method will open each pack file only once, so if there are many objects to check and they are mostly packed, this already gives a very nice performance boost.