Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ODS-6551] Support feature for optimized use of serialized aggregate data #1184

Merged
merged 46 commits into from
Nov 22, 2024

Conversation

gmcelhanon
Copy link
Contributor

@gmcelhanon gmcelhanon commented Nov 9, 2024

@gmcelhanon gmcelhanon force-pushed the ODS-6551 branch 2 times, most recently from 41e95cf to 5e8ad8a Compare November 12, 2024 20:34
@gmcelhanon gmcelhanon marked this pull request as ready for review November 20, 2024 04:32
@gmcelhanon gmcelhanon requested a review from a team as a code owner November 20, 2024 04:32
Copy link
Contributor Author

@gmcelhanon gmcelhanon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments to help with code review.

@@ -292,11 +292,6 @@ protected override void Load(ContainerBuilder builder)
.As<IResourceValidator>()
.SingleInstance();

builder.RegisterType<NoEntityExtensionsFactory>()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of this interface is now protected by feature checks -- no need for a placeholder component/registration.

@@ -47,6 +48,13 @@ public override void ApplyConfigurationSpecificRegistrations(ContainerBuilder bu
.As<IEntityExtensionRegistrar>()
.SingleInstance();

// Set feature-specific static resolvers
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than setting the statics for these components in OdsStartupBase, they are now done here in the feature-specific module.

.As<IEntityDeserializer>()
.SingleInstance();

builder.RegisterType<PersonSurrogateIdMutator>()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These components handle lookup of USIs and DescriptorIds on Person types and Descriptor entities (respectively). They use the resolver/cache facilities when the values are needed after subsequent deserialization after initial creation (where they are not available to be serialized into the AggregateData column until after the entity is already INSERTed).

@@ -197,6 +211,11 @@ protected override void Load(ContainerBuilder builder)
.As<ISessionFactory>()
.SingleInstance();

builder.Register(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This component is needed in new locations to enable deserialized entities to be reassociated with the current NHibernate session.


namespace EdFi.Ods.Common.Database;

public static class ColumnNames
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Providing a location for commonly used column names to avoid expansion of embedded string values throughout the code.

@@ -90,7 +92,10 @@ await _container.Resolve<IApplicationRunner>()
{
var baseException = e.GetBaseException() ?? e;

_logger.Error(baseException.Message);
// Save the last exception in a static property to make it available for subsequent inspection.
LastException = e;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure we make the exception available to the calling code when we complete the call (from unit tests).

@@ -206,23 +211,27 @@ namespace EdFi.Ods.Entities.NHibernate.BusAggregate.Sample
/// <summary>
/// Represents a read-only reference to the <see cref="Bus"/> entity.
/// </summary>
[MessagePackObject]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reference Data is serialized so that we don't have to look up the Id/Discriminator values separately. Full support of links is coming with ODS-6557.

@@ -536,8 +553,10 @@ public BusRoute()
// Primary Key
// -------------------------------------------------------------
[DomainSignature]
[Key(6)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aggregate root entities start their key values at 6 due to inherited properties that are already marked for serialization.

@@ -629,6 +660,7 @@ public virtual int? StaffClassificationDescriptorId
private int? _staffClassificationDescriptorId;
private string _staffClassificationDescriptor;

[IgnoreMember]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We serialize descriptor Ids, not the full URI. It's definitive and more compact.

@@ -673,6 +706,7 @@ public virtual int? StaffUSI
private int? _staffUSI;
private string _staffUniqueId;

[IgnoreMember]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We serialize USIs not UniqueIds. It's definitive and more compact.

# Conflicts:
#	Utilities/CodeGeneration/EdFi.Ods.CodeGen.Tests/Approval/5.2.0/DataStandard_520_ApprovalTests.Verify.Standard_Std_5.2.0_Models_Entities_Entities.generated.approved.cs
…roblems with single process-based code generation of multiple standards.

Attach test reports from CodeGen processing for better error reporting.
Exceptions occurring during code generation are now exposed to tests via a static LastException property.
…e key is defined on the base type so that query based on AK values can be properly constructed. Updated approval tests.
… during GetByKey where item has been reloaded through deserialization and the serialized data doesn't include the CreateDate value.
… "role" name for obtaining the NHibernate persister.
…(even before they are assigned by NHibernate), Student/Descriptor surrogate key resolution, and other edge case scenarios (like correct support for implicit extensions).
…sisted USIs to be cleared, causing authorization failures.
…iately, and failing to resolve deserialized USIs into UniqueIds correctly.
…erived types when collections are inherited from a base type.
…g surrogate ids after deserialization when the entity doesn't have it serialized yet.
…Hibernate in case of deserialization failure.
… to allow them to surface during Postman test execution.
…serializing data created without the extensions.
…timized around serialized data feature setting.
Comment on lines +34 to +39
// Maps the CreatedByOwnershipTokenID column dynamically
// Requires there be a property on the base entity already
// nHibernate wraps property getter exception in PropertyAccessException if any
// underlying mapped properties are set to access "none", due to an invoke exception being triggered.
// generated = "always" to avoid nHibernate trying to set values for it
// <property name="CreatedByOwnershipTokenID" column="ChangeVersion" type="long" not-null="true" generated="always" />
Copy link
Contributor

@axelmarquezh axelmarquezh Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: This comment doesn't reflect the reality, seems to have been copy/pasted.

@mjaksn mjaksn merged commit aa35e6e into main Nov 22, 2024
41 checks passed
@mjaksn mjaksn deleted the ODS-6551 branch November 22, 2024 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants