IdMap
- class IdMap
DeserializedModelcompatible mapping for elements. This will typically be used for linking pending references:map = IdMap() models_reports = [ deserializer.accept(document, my_reader(input), DESERIALIZE_STANDARD) for document, input in zip(documents, inputs) ] for document in documents: map.insert_or_assign(document) reports_linked = [model.link(map) for model, _ in models_reports]
Members defined in
IdMap(9 members)
Short-hand for
findorsearch. Will fall back tosearchifuriis empty.
Clear all mapped elements.
Erase all elements assigned to
documentfrom this map.
Find an element at document with
urithat hasid.
Insert all elements from
documentinto this map.
Reserve space for
ndocument mappings.
Search across all registered documents for a matching id. This has complexity O(n) since it searches each document separately.
Try insert all elements from
documentinto this map. Methods
- __call__(uri: str, id: uuid.UUID) syside.Element | None
Short-hand for
findorsearch. Will fall back tosearchifuriis empty.
- __init__() None
- clear() None
Clear all mapped elements.
- erase(document: syside.Document) int
Erase all elements assigned to
documentfrom this map.Returns the number of elements erased.
- erase(uri: str) int
Erase all elements assigned to document with
urifrom this map.Returns the number of elements erased.
- find(uri: str, id: uuid.UUID) syside.Element | None
Find an element at document with
urithat hasid.Returns the element found if any.
- insert_or_assign(document: syside.Document) tuple[int, bool]
Insert all elements from
documentinto this map.Returns the number of elements inserted, and
Trueif insertion took place,Falseifdocumentwas already mapped.
- reserve(n: int) None
Reserve space for
ndocument mappings.
- search(id: uuid.UUID) syside.Element | None
Search across all registered documents for a matching id. This has complexity O(n) since it searches each document separately.
Returns the element found if any.
- try_insert(document: syside.Document) tuple[int, bool]
Try insert all elements from
documentinto this map.Returns the number of elements inserted, and
Trueif insertion took place. This will not override already mapped document elements.