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

Execute @PostLoad method after fully hydrating all entities #406

Closed
wants to merge 3 commits into from

Conversation

frant-hartm
Copy link
Contributor

@frant-hartm frant-hartm commented Sep 20, 2017

Fixes #403, performance issue when mapping large number of rows
returned.

Description

executePostLoad is executed after processing all rows
repeated iteration over accumulating nodeIds and edgeIds is then avoided

Related Issue

See #403

How Has This Been Tested?

All tests pass without modification.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@frant-hartm frant-hartm force-pushed the issue/403 branch 2 times, most recently from 2717b70 to cbf9244 Compare September 25, 2017 17:40
try {
method.invoke(instance);
} catch (IllegalAccessException | InvocationTargetException e) {
logger.error("Failed to execute post load method", e);
Copy link
Member

Choose a reason for hiding this comment

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

When the PostLoad method does not respect the "contract" (public, no arg method), low level java exceptions are thrown like IllegalArgumentException: wrong number of arguments
Maybe some guidance could be useful like "Cannot call PostLoad annotated method {method fqn}. Make sure it is public and has no arguments"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed, I have also changed it to warn as it is not a blocking error.

@@ -190,17 +232,10 @@ private void mapNodes(GraphModel graphModel, Set<Long> nodeIds) {
}
}

private void executePostLoad(Object instance) {
private void setIdentity(Object instance, Long id) {
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it dead code ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it is. Will delete.

* @param edgeIds edgeIds
*/
public void executePostLoad(Set<Long> nodeIds, Set<Long> edgeIds) {
Set<Long> seenIds = new HashSet<>();
Copy link
Member

Choose a reason for hiding this comment

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

Maybe because it's late but I don't see the purpose of seenIds as method parameters are Sets. Some old code remaining ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!! It also made me discover another but with @PostLoad method, will push fix in another commit.

@frant-hartm frant-hartm deleted the issue/403 branch September 27, 2017 10:26
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.

Performance issues on graph to entity mapping
2 participants