[ROOT] / doc / toc / ARCCore / Class / PExact<TEnumType>

.ctor , GetPVDirect , SetPVDirect , Storage , ToString , TryGetPVDirect


Very MemoryConsumption efficient alternative to PRich.
Typically used to store entities like 'Customer', 'Product', 'Order' and so on

Has some limitations in the sense that can only store an exact number of properties (assumed to come from one specific PropertyKeyEnum), and only use PK as key.

Values are stored 'directly', that is, without packing inside a PValue<T>. (in other words, values are unpacked as they are received (by call to -GetV-), and packed again (by PackObjectForStorageInEntityObject) before being sent.
If PValueEmpty is received from outside, it is treated as 'not-existing' (stored internally as null)

Note that from 22 Jan 2022 PExact contains the following high performance alternatives to standard PropertyAccess:
SetPVDirect, GetPVDirect and TryGetPVDirect.
This avoids the performance overhead of unpacking and packing as described above.

TODO: The high-performance alternatives describes above TODO: are not described in ARCDoc yet (see Documentator).
TODO: One could argue that they should make PExact perform faster than PRich (in addition to using less memory as already mentioned),
TODO: but this has not been tested properly as of Jan 2022.
TODO: (Initial evaluation did not show any dramatic change, or actually any change at all).
TODO: It is possible that the necessary boxing / unboxing is what impacts performance most. For value types
TODO: it could quite possibly be more efficient to actually store PValue directly, in order to avoid boxing / unboxing.
TODO: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/types/boxing-and-unboxing

Use this class as basis for your 'entity' classes when you know exact what you want to store in them and when you do not need to store any meta-data like Cid, Created for each property.

The only memory overhead of this class compared to a 'traditional' C# class (with ordinary properties) should be the overhead for the Storage array instance (24 extra bytes).
(with the exception of boxing / unboxing for value types of course.).

See also MemoryConsumption.

See ARCDoc, class Orange for example implementation.

NOTE: Metadata at the entity level, like Cid and Created is only
NOTE: allowed as long as corresponding enum-members for the specific generic type parameter EnumType exists.

See also -ICreated, a dummy interface signifying that implementing class has the ability to store (in-memory) metadata Created

TODO: This class is currently (as of Mar 2021) unable to store properties of type IP, that is, when packing / unpacking is not needed.
TODO: Some workarounds could be to explicit recognize PValue<T> / PValueEmpty as the ones to be unpacked, and
TODO: store all other properties (of IP) directly.


Some examples of advantages of this class compared to PRich:

Example 1: A small sample of about 832 000 PropertyStreamLine with data for about 16 000 customers (three properties, first name, last name and email) and 43 000 payments (about 21 properties each).
42% reduction in RAM usage and a 16% reduction in CPU time for initial reading of all data into memory.
Dataset occupied 43 MB on disk and 59 MB in RAM.
(Note: Example given is without any speed performance improvement through avoiding the pack / unpack cycle. (see speed improvements done on Jan 17 2022))


.ctorSet capacity to the number of members in the PropertyKeyEnum for this class (minus the __invalid-value)
GetPVDirectHigh performance alternative to TryGetP, accessing Storage more direct.
SetPVDirectHigh performance alternative to TrySetP, accessing Storage more direct.
StorageUses int-value of __enum minus 1 as index.
ToStringTODO: Decide on what we actually want with ToString for this class.
TryGetPVDirectHigh performance alternative to TryGetP, accessing Storage more direct.

Details

Generated 2024-04-20 13:51:09.964 UTC