Class AbstractMapper<TModel>
Provides all abstract implementation shared by all just-in-time compiled individual mapper
for the IGeneratedEntityLogger mapper interface.
Inheritance
System.Object
AbstractMapper<TModel>
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: Mars.Core.Data.Compiler
Assembly: Mars.Core.dll
Syntax
[MessagePackObject(false)]
public abstract class AbstractMapper<TModel> : AbstractJitMapper, IGeneratedLogger<TModel>, IOutputLogger
Type Parameters
Name | Description |
---|---|
TModel |
Remarks
Beside preventing duplicate code, the idea is to reduce to overhead coming from the JIT
compilation step by reducing the amount of generated (potential duplicate) code.
Fields
| Improve this Doc View SourceBsonDocument
Provides all abstract implementation shared by all just-in-time compiled individual mapper
for the IGeneratedEntityLogger mapper interface.
Declaration
protected BsonDocument BsonDocument
Field Value
Type | Description |
---|---|
MongoDB.Bson.BsonDocument |
Remarks
Beside preventing duplicate code, the idea is to reduce to overhead coming from the JIT
compilation step by reducing the amount of generated (potential duplicate) code.
|
Improve this Doc
View Source
CompressionOptions
The compression options when the SerializeCompressed()
or SerializeToJsonCompressed() is used.
Declaration
protected static readonly MessagePackSerializerOptions CompressionOptions
Field Value
Type | Description |
---|---|
MessagePack.MessagePackSerializerOptions |
Remarks
Do not make this option object private, since it is used by the JIT generated sub types.
|
Improve this Doc
View Source
Frame
Provides all abstract implementation shared by all just-in-time compiled individual mapper
for the IGeneratedEntityLogger mapper interface.
Declaration
protected DataFrame Frame
Field Value
Type | Description |
---|---|
DataFrame |
Remarks
Beside preventing duplicate code, the idea is to reduce to overhead coming from the JIT
compilation step by reducing the amount of generated (potential duplicate) code.
Properties
| Improve this Doc View SourceDateTime
Specifies the current realtime reference
Declaration
[Key(2)]
[JsonProperty(PropertyName = "dateTime", NullValueHandling = NullValueHandling.Ignore)]
[BsonElement("dateTime")]
[BsonIgnoreIfNull]
[Column("DateTime")]
public virtual DateTime? DateTime { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.DateTime> |
Remarks
Beside preventing duplicate code, the idea is to reduce to overhead coming from the JIT
compilation step by reducing the amount of generated (potential duplicate) code.
|
Improve this Doc
View Source
Entity
The associated entity model object (either an agent or a layer)
Is refined implemented in IGeneratedEntityLogger.
Declaration
[IgnoreMember]
[JsonIgnore]
[NotMapped]
[BsonIgnore]
public virtual TModel Entity { get; set; }
Property Value
Type | Description |
---|---|
TModel |
Remarks
Beside preventing duplicate code, the idea is to reduce to overhead coming from the JIT
compilation step by reducing the amount of generated (potential duplicate) code.
|
Improve this Doc
View Source
Id
Gets the Id of the entity which is cared by this mapping proxy
Declaration
[IgnoreMember]
[JsonIgnore]
[BsonIgnore]
[NotMapped]
public Guid Id { get; set; }
Property Value
Type | Description |
---|---|
System.Guid |
Remarks
Beside preventing duplicate code, the idea is to reduce to overhead coming from the JIT
compilation step by reducing the amount of generated (potential duplicate) code.
|
Improve this Doc
View Source
IdString
Gets the id as a string of this entity
Declaration
[Key(4)]
[JsonProperty(PropertyName = "id")]
[BsonElement("id")]
[BsonIgnoreIfNull]
[Column("ID")]
public virtual string IdString { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
Beside preventing duplicate code, the idea is to reduce to overhead coming from the JIT
compilation step by reducing the amount of generated (potential duplicate) code.
|
Improve this Doc
View Source
RId
Represents the identity column for relational mapping
Declaration
[JsonIgnore]
[BsonIgnore]
[IgnoreMember]
[Column("RID")]
public virtual long RId { get; set; }
Property Value
Type | Description |
---|---|
System.Int64 |
Remarks
This property is not intended to be used from outside.
|
Improve this Doc
View Source
Step
Specifies the current step of this mapper
Declaration
[Key(1)]
[JsonProperty(PropertyName = "step")]
[BsonElement("step")]
[Column("Step")]
public virtual long Step { get; set; }
Property Value
Type | Description |
---|---|
System.Int64 |
Remarks
Beside preventing duplicate code, the idea is to reduce to overhead coming from the JIT
compilation step by reducing the amount of generated (potential duplicate) code.
|
Improve this Doc
View Source
Tick
Specifies the current tick of this mapper
Declaration
[Key(0)]
[JsonProperty(PropertyName = "tick")]
[BsonElement("tick")]
[Column("Tick")]
public virtual long Tick { get; set; }
Property Value
Type | Description |
---|---|
System.Int64 |
Remarks
Beside preventing duplicate code, the idea is to reduce to overhead coming from the JIT
compilation step by reducing the amount of generated (potential duplicate) code.
Methods
| Improve this Doc View SourceInitialize()
Performs a deferred initialization of this entity-specific mapper.
This makes it possible to assign properties with values before
(e.g., the concrete entity ).
Declaration
public override void Initialize()
Overrides
Remarks
This method should always be used when something have to be implemented within the constructor scope.
|
Improve this Doc
View Source
IsSerializable()
Checks for the current instance, based on precondition whether this instance shall be persisted or not.
Declaration
public virtual bool IsSerializable()
Returns
Type | Description |
---|---|
System.Boolean | Returns true when the instance can be serialized otherwise false |
Remarks
Beside preventing duplicate code, the idea is to reduce to overhead coming from the JIT
compilation step by reducing the amount of generated (potential duplicate) code.
|
Improve this Doc
View Source
Serialize()
Serialize the snapshot of an agent with output properties as a MessagePack
formatted byte field, encoded in hex. Instead of creating a new DataFrame struct
the primitive output properties will be serialized directly. This MessagePack format
is much more smaller and faster than just to use the SerializeToFrame()
method, but for the client within the database or in the client programme (with another language)
there an explicit MessagePack deserialization step necessary.
MessagePack specification
https://msgpack.org
.Net binding of MessagePack with all options described
https://github.com/neuecc/MessagePack-CSharp#performance
Declaration
public abstract byte[] Serialize()
Returns
Type | Description |
---|---|
System.Byte[] | A System.Byte array in MessagePack format |
Remarks
Beside preventing duplicate code, the idea is to reduce to overhead coming from the JIT
compilation step by reducing the amount of generated (potential duplicate) code.
|
Improve this Doc
View Source
Serialize(Stream)
Serialize the output properties of the associated entity instance into MessagePack format
similar to and pass it directly into a stream (e.g. Kafka, or
WebSocket)
with no intermediate overhead. Consumer of this stream the MessagePack shall be aware
that they need to deserialize it explicitly according to the MessagePack specification.
Declaration
public abstract void Serialize(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream to pass the packed frame of the output properties. |
Remarks
Beside preventing duplicate code, the idea is to reduce to overhead coming from the JIT
compilation step by reducing the amount of generated (potential duplicate) code.
|
Improve this Doc
View Source
SerializeCompressed()
Serialize the snapshot of an agent with output properties as a MessagePack
formatted byte field, encoded in hex and compressed by the LZ4 compression algorithm.
Instead of creating a new DataFrame struct
the primitive output properties will be serialized directly. This MessagePack format
is much more smaller and faster than just to use the SerializeToFrame()
method, but for the client within the database or in the client programme (with another language)
there an explicit MessagePack deserialization step necessary.
MessagePack specification
https://msgpack.org
LZ4 compression algorithm
https://en.wikipedia.org/wiki/LZ4_(compression_algorithm)
.Net binding of MessagePack with all options described
https://github.com/neuecc/MessagePack-CSharp#performance
Declaration
public abstract byte[] SerializeCompressed()
Returns
Type | Description |
---|---|
System.Byte[] | A System.Byte array in MessagePack format compressed by the LZ4 algorithm. |
Remarks
Beside preventing duplicate code, the idea is to reduce to overhead coming from the JIT
compilation step by reducing the amount of generated (potential duplicate) code.
|
Improve this Doc
View Source
SerializeCompressed(Stream)
Serialize the output properties of the associated entity instance into a and pass it directly into a stream (e.g. Kafka, or
WebSocket)
with no intermediate overhead. Consumer of this stream the MessagePack shall be aware
that they need to deserialize it explicitly according to the MessagePack specification.
LZ4
compression
MessagePack
similar to Declaration
public abstract void SerializeCompressed(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream to pass the compressed frame of the output properties. |
Remarks
When the JSON output shall used, an extra LZ4 decompression step have first to be applied.
|
Improve this Doc
View Source
SerializeProperties()
Serialize the values of all output properties by returning the actual value as an iterator.
Declaration
public abstract IEnumerable<(string, object, Type)> SerializeProperties()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.ValueTuple<System.String, System.Object, System.Type>> | Returns an iterator containing each output property value with the associated name, and the corresponding data type of this property. When no output properties are registered, then the iterator returns nothing. |
Remarks
This method can be used to get the concrete values of an entity or layer or to generate the schema by using
the returned property names.
|
Improve this Doc
View Source
SerializePropertyValues()
Serialize the values of all output properties by returning the actual value as an iterator.
Declaration
public abstract IEnumerable<object> SerializePropertyValues()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Object> | Returns an iterator containing each output property value. |
Remarks
Beside preventing duplicate code, the idea is to reduce to overhead coming from the JIT
compilation step by reducing the amount of generated (potential duplicate) code.
|
Improve this Doc
View Source
SerializeToDocument()
Serialize this instance of the proxy with the corresponding output
properties described in TypeElement into a MongoDb
conforming MongoDB.Bson.BsonDocument which is reused for each tick.
Declaration
public virtual BsonDocument SerializeToDocument()
Returns
Type | Description |
---|---|
MongoDB.Bson.BsonDocument |
Remarks
Beside preventing duplicate code, the idea is to reduce to overhead coming from the JIT
compilation step by reducing the amount of generated (potential duplicate) code.
|
Improve this Doc
View Source
SerializeToFrame()
Generates a full-state message of this simulation object in form of new created DataFrame object.
This contains the spatial and temporal reference as well as all active output properties of this agent type.
Declaration
public virtual DataFrame SerializeToFrame()
Returns
Type | Description |
---|---|
DataFrame | A JSON-compliant output for all agent states. |
Remarks
Beside preventing duplicate code, the idea is to reduce to overhead coming from the JIT
compilation step by reducing the amount of generated (potential duplicate) code.
|
Improve this Doc
View Source
SerializeToJson()
Serialize the output properties directly as a JSON suited document.
Based on the output configuration SimulationConfig, in default case,
this DOES NOT include the property names as keys.
Declaration
public abstract string SerializeToJson()
Returns
Type | Description |
---|---|
System.String | A JSON formatted string of all output properties for the associated agent. |
Remarks
Beside preventing duplicate code, the idea is to reduce to overhead coming from the JIT
compilation step by reducing the amount of generated (potential duplicate) code.
|
Improve this Doc
View Source
SerializeToJsonCompressed()
Serialize the output properties to
L4Z
compressed JSON document.
Based on the output configuration SimulationConfig, in default case,
this DOES NOT include the property names as keys.
Declaration
public abstract string SerializeToJsonCompressed()
Returns
Type | Description |
---|---|
System.String | A JSON formatted string of all output properties for the associated agent. |
Remarks
When the JSON output shall used, an extra LZ4 decompression step have first to be applied.
|
Improve this Doc
View Source
SerializeValueFor(String)
Serializes the value for the given
propertyName
or returns null otherwise.
Declaration
public abstract object SerializeValueFor(string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyName | The property to access. |
Returns
Type | Description |
---|---|
System.Object | Returns the value or null when the property is not available. |
Remarks
Beside preventing duplicate code, the idea is to reduce to overhead coming from the JIT
compilation step by reducing the amount of generated (potential duplicate) code.