IdMap

class IdMap

DeserializedModel compatible 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)

__call__

Short-hand for find or search. Will fall back to search if uri is empty.

__init__

clear

Clear all mapped elements.

erase

Erase all elements assigned to document from this map.

find

Find an element at document with uri that has id.

insert_or_assign

Insert all elements from document into this map.

reserve

Reserve space for n document mappings.

search

Search across all registered documents for a matching id. This has complexity O(n) since it searches each document separately.

try_insert

Try insert all elements from document into this map.

Methods

__call__(uri: str, id: uuid.UUID) syside.Element | None

Short-hand for find or search. Will fall back to search if uri is empty.

__init__() None
clear() None

Clear all mapped elements.

erase(document: syside.Document) int

Erase all elements assigned to document from this map.

Returns the number of elements erased.

erase(uri: str) int

Erase all elements assigned to document with uri from this map.

Returns the number of elements erased.

find(uri: str, id: uuid.UUID) syside.Element | None

Find an element at document with uri that has id.

Returns the element found if any.

insert_or_assign(document: syside.Document) tuple[int, bool]

Insert all elements from document into this map.

Returns the number of elements inserted, and True if insertion took place, False if document was already mapped.

reserve(n: int) None

Reserve space for n document 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 document into this map.

Returns the number of elements inserted, and True if insertion took place. This will not override already mapped document elements.