docarray.array.storage.base.getsetdel module#
- class docarray.array.storage.base.getsetdel.BaseGetSetDelMixin[source]#
Bases:
ABC
Provide abstract methods and derived methods for
__getitem__
,__setitem__
and__delitem__
Note
- The following methods must be implemented:
_get_doc_by_id()
_set_doc_by_id()
_del_doc_by_id()
Keep in mind that these methods above ** must not ** handle offset2id of the DocumentArray.
- These methods are actually wrapped by the following methods which handle the offset2id:
_set_doc()
_del_doc()
_del_all_docs()
Therefore, you should make sure to use the wrapper methods in case you expect offset2id to be updated, and use the inner methods in case you don’t want to handle offset2id (for example, if you want to handle it in a later step)
Other methods implemented a generic-but-slow version that leverage the methods above. Please override those methods in the subclass whenever a more efficient implementation is available. Mainly, if the backend storage supports operations in batches, you can implement the following methods:
_get_docs_by_ids()
_set_docs_by_ids()
_del_docs_by_ids()
_clear_storage()
Likewise, the methods above do not handle offset2id. They are wrapped by the following methods that update the offset2id in a single step:
_set_docs()
_del_docs()
_del_all_docs()