minos.aggregate.collections
Classes
| Incremental Set class. | |
| Incremental Set Diff class. | 
- class IncrementalSet[source]
- Bases: - DeclarativeModel,- MutableSet,- Generic[- T]- Incremental Set class. - add(value_object)[source]
- Add a value object. :param value_object: The value object to be added. :return: This method does not return anything. - Parameters
- value_object (T) – 
- Return type
- None 
 
 - discard(value_object)[source]
- Remove a value object. :param value_object: The value object to be added. :return: This method does not return anything. - Parameters
- value_object (T) – 
- Return type
- None 
 
 - diff(another)[source]
- Compute the difference between self and another entity set. :param another: Another entity set instance. :return: The difference between both entity sets. - Parameters
- another (IncrementalSet[T]) – 
- Return type
 
 - classmethod encode_schema(encoder, target, **kwargs)[source]
- Encode schema with the given encoder. - Parameters
- encoder (SchemaEncoder) – The encoder instance. 
- target (Any) – An optional pre-encoded schema. 
 
- Returns
- The encoded schema of the instance. 
- Return type
 
 - classmethod decode_schema(decoder, target, **kwargs)[source]
- Decode schema with the given encoder. - Parameters
- decoder (SchemaDecoder) – The decoder instance. 
- target (Any) – The schema to be decoded. 
 
- Returns
- The decoded schema as a type. 
- Return type
 
 - static encode_data(encoder, target, **kwargs)[source]
- Encode data with the given encoder. - Parameters
- encoder (DataEncoder) – The encoder instance. 
- target (Any) – An optional pre-encoded data. 
 
- Returns
- The encoded data of the instance. 
- Return type
 
 - classmethod decode_data(decoder, target, type_, **kwargs)[source]
- Decode data with the given decoder. - Parameters
- decoder (DataDecoder) – The decoder instance. 
- target (Any) – The data to be decoded. 
- type – The data type. 
- type_ (ModelType) – 
 
- Returns
- A decoded instance. 
- Return type
 
 - property avro_bytes: bytes
- Generate bytes representation of the current instance. - Returns
- A bytes object. 
 
 - property avro_data: dict[str, Any]
- Compute the avro data of the model. - Returns
- A dictionary object. 
 
 - avro_schema = [{'type': 'array', 'items': 'null', 'logicalType': 'minos.aggregate.collections.IncrementalSet'}]
 - property avro_str: str
- Generate bytes representation of the current instance. - Returns
- A bytes object. 
 
 - classname = 'minos.aggregate.collections.IncrementalSet'
 - clear()
- This is slow (creates N new iterators!) but effective. 
 - property fields: dict[str, minos.common.model.fields.Field]
- Fields getter 
 - classmethod from_avro(schema, data)
- Build a new instance from the - avroschema and data.
 - classmethod from_avro_bytes(raw, batch_mode=False, **kwargs)
- Build a single instance or a sequence of instances from bytes. - Parameters
- Returns
- A single instance or a sequence of instances. 
- Return type
 
 - classmethod from_avro_str(raw, **kwargs)
- Build a single instance or a sequence of instances from bytes 
 - classmethod from_model_type(model_type, *args, **kwargs)
- Build a - DeclarativeModelfrom a- ModelType.- Parameters
- model_type (ModelType) – - ModelTypeobject containing the model structure.
- args – Positional arguments to be passed to the model constructor. 
- kwargs – Named arguments to be passed to the model constructor. 
 
- Returns
- A new - DeclarativeModelinstance.
- Return type
- T 
 
 - classmethod from_typed_dict(typed_dict, *args, **kwargs)
- Build a - Modelfrom a- TypeDictand- data.- Parameters
- typed_dict (TypedDict) – - TypeDictobject containing the DTO’s structure
- args – Positional arguments to be passed to the model constructor. 
- kwargs – Named arguments to be passed to the model constructor. 
 
- Returns
- A new - DataTransferObjectinstance.
- Return type
- T 
 
 - get(k[, d]) D[k] if k in D, else d. d defaults to None.
 - isdisjoint(other)
- Return True if two sets have a null intersection. 
 - items() a set-like object providing a view on D's items
 - keys() a set-like object providing a view on D's keys
 - model_type
- alias of - IncrementalSet
 - pop()
- Return the popped value. Raise KeyError if empty. 
 - remove(value)
- Remove an element. If not a member, raise a KeyError. 
 - classmethod to_avro_bytes(models)
- Create a - bytesrepresentation of the given object instances.
 - classmethod to_avro_str(models)
- Build the avro string representation of the given object instances. 
 - type_hints = {'data': set[~T]}
 - type_hints_parameters = (~T,)
 - values() an object providing a view on D's values
 
- class IncrementalSetDiff[source]
- Bases: - DeclarativeModel- Incremental Set Diff class. - classmethod from_difference(new, old, get_fn=None)[source]
- Build a new instance from two entity sets. :param new: The new entity set. :param old: The old entity set. :param get_fn: Optional function to get entries from the set by identifier. :return: The difference between new and old. - Parameters
- new (IncrementalSet[T]) – 
- old (IncrementalSet[T]) – 
 
- Return type
 
 - __init__(*args, **kwargs)
- Class constructor. - Parameters
- kwargs – Named arguments to be set as model attributes. 
 
 - property avro_bytes: bytes
- Generate bytes representation of the current instance. - Returns
- A bytes object. 
 
 - property avro_data: dict[str, Any]
- Compute the avro data of the model. - Returns
- A dictionary object. 
 
 - avro_schema = [{'name': 'IncrementalSetDiff', 'namespace': 'minos.aggregate.collections.c26e282f-e6f6-441b-b750-6dea4fbc3db7', 'type': 'record', 'fields': [{'name': 'diffs', 'type': {'type': 'array', 'items': {'name': 'SetDiffEntry', 'namespace': '', 'type': 'record', 'fields': [{'name': 'action', 'type': {'type': 'string', 'logicalType': 'minos.aggregate.actions.Action'}}, {'name': 'entity', 'type': 'null'}]}}}]}]
 - property avro_str: str
- Generate bytes representation of the current instance. - Returns
- A bytes object. 
 
 - classname = 'minos.aggregate.collections.IncrementalSetDiff'
 - static decode_data(decoder, target, type_, **kwargs)
- Decode data with the given decoder. - Parameters
- decoder (DataDecoder) – The decoder instance. 
- target (Any) – The data to be decoded. 
- type – The data type. 
- kwargs – Additional named arguments. 
- type_ (ModelType) – 
 
- Returns
- A decoded instance. 
- Return type
 
 - static decode_schema(decoder, target, **kwargs)
- Decode schema with the given encoder. - Parameters
- decoder (SchemaDecoder) – The decoder instance. 
- target (Any) – The schema to be decoded. 
- kwargs – Additional named arguments. 
 
- Returns
- The decoded schema as a type. 
- Return type
 
 - static encode_data(encoder, target, **kwargs)
- Encode data with the given encoder. - Parameters
- encoder (DataEncoder) – The encoder instance. 
- target (Any) – An optional pre-encoded data. 
- kwargs – Additional named arguments. 
 
- Returns
- The encoded data of the instance. 
- Return type
 
 - static encode_schema(encoder, target, **kwargs)
- Encode schema with the given encoder. - Parameters
- encoder (SchemaEncoder) – The encoder instance. 
- target (Any) – An optional pre-encoded schema. 
- kwargs – Additional named arguments. 
 
- Returns
- The encoded schema of the instance. 
- Return type
 
 - property fields: dict[str, minos.common.model.fields.Field]
- Fields getter 
 - classmethod from_avro(schema, data)
- Build a new instance from the - avroschema and data.
 - classmethod from_avro_bytes(raw, batch_mode=False, **kwargs)
- Build a single instance or a sequence of instances from bytes. - Parameters
- Returns
- A single instance or a sequence of instances. 
- Return type
 
 - classmethod from_avro_str(raw, **kwargs)
- Build a single instance or a sequence of instances from bytes 
 - classmethod from_model_type(model_type, *args, **kwargs)
- Build a - DeclarativeModelfrom a- ModelType.- Parameters
- model_type (ModelType) – - ModelTypeobject containing the model structure.
- args – Positional arguments to be passed to the model constructor. 
- kwargs – Named arguments to be passed to the model constructor. 
 
- Returns
- A new - DeclarativeModelinstance.
- Return type
- T 
 
 - classmethod from_typed_dict(typed_dict, *args, **kwargs)
- Build a - Modelfrom a- TypeDictand- data.- Parameters
- typed_dict (TypedDict) – - TypeDictobject containing the DTO’s structure
- args – Positional arguments to be passed to the model constructor. 
- kwargs – Named arguments to be passed to the model constructor. 
 
- Returns
- A new - DataTransferObjectinstance.
- Return type
- T 
 
 - get(k[, d]) D[k] if k in D, else d. d defaults to None.
 - items() a set-like object providing a view on D's items
 - keys() a set-like object providing a view on D's keys
 - model_type
- alias of - IncrementalSetDiff
 - classmethod to_avro_bytes(models)
- Create a - bytesrepresentation of the given object instances.
 - classmethod to_avro_str(models)
- Build the avro string representation of the given object instances. 
 - type_hints = {'diffs': list[minos.common.model.types.model_types.SetDiffEntry]}
 - type_hints_parameters = ()
 - values() an object providing a view on D's values