Skip to content

[BI-1647] View Experiments: Observation Dataset Table#280

Merged
davedrp merged 3 commits intodevelopfrom
feature/BI-1647
Aug 22, 2023
Merged

[BI-1647] View Experiments: Observation Dataset Table#280
davedrp merged 3 commits intodevelopfrom
feature/BI-1647

Conversation

@davedrp
Copy link
Contributor

@davedrp davedrp commented Aug 7, 2023

Description

BI-1647 (View Experiments: Observation Dataset Table)

Added the ability to retrieve the GID in the additional information element of the Observation Unit.

Dependencies

bi-web: branch feature/BI-1647

Testing

see bi-web PR.

Checklist:

  • I have performed a self-review of my own code
  • I have tested my code and ensured it meets the acceptance criteria of the story
  • I have create/modified unit tests to cover this change
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to documentation
  • I have run TAF: link to TAF run

@davedrp davedrp changed the title [BI-1647] added GID to BrAPIObservationUnit [BI-1647] View Experiments: Observation Dataset Table Aug 7, 2023
@davedrp davedrp removed the request for review from dmeidlin August 7, 2023 16:37
@davedrp davedrp marked this pull request as ready for review August 7, 2023 16:38
Copy link
Contributor

@mlm483 mlm483 left a comment

Choose a reason for hiding this comment

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

  • One change requested for performance, I tested my suggested code change it was an order of magnitude faster locally for a large experiment (16731 Observations).
  • Probably out of scope for this story, but if you see an easy way to tackle this performance story I just created, please do!

Comment on lines +130 to +134
for (BrAPIObservationUnit observationUnit: observationUnits) {
String germplasmDbId = observationUnit.getGermplasmDbId();
BrAPIGermplasm germplasm = this.germplasmService.getGermplasmByDBID(program.getId(), germplasmDbId).get() ;
observationUnit.putAdditionalInfoItem("gid", germplasm.getAccessionNumber());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for (BrAPIObservationUnit observationUnit: observationUnits) {
String germplasmDbId = observationUnit.getGermplasmDbId();
BrAPIGermplasm germplasm = this.germplasmService.getGermplasmByDBID(program.getId(), germplasmDbId).get() ;
observationUnit.putAdditionalInfoItem("gid", germplasm.getAccessionNumber());
}
// Load germplasm for program into map.
// TODO: if we use redis search, that may be more efficient than loading all germplasm for the program.
HashMap<String, BrAPIGermplasm> germplasmByDbId = new HashMap<>();
this.germplasmService.getGermplasm(programId).forEach((germplasm -> germplasmByDbId.put(germplasm.getGermplasmDbId(), germplasm)));
for (BrAPIObservationUnit observationUnit: observationUnits) {
BrAPIGermplasm germplasm = germplasmByDbId.get(observationUnit.getGermplasmDbId());
observationUnit.putAdditionalInfoItem("gid", germplasm.getAccessionNumber());
}

This is loading all Germplasm in the program from the cache for each observationUnit, which really hurts performance for large datasets. I would load all germplasm for the program into a HashMap (key: germplasmDbId => value: Germplasm object) outside of the for loop and then access by key inside the loop.

I think there's an eventual desire to use something like https://redis.io/docs/interact/search-and-query/ to make more fine-grained cache retrievals, but for now, just use a HashMap.

Copy link
Member

Choose a reason for hiding this comment

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

Change looks good to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Excellent! Thank you.
Done.

Comment on lines +130 to +134
for (BrAPIObservationUnit observationUnit: observationUnits) {
String germplasmDbId = observationUnit.getGermplasmDbId();
BrAPIGermplasm germplasm = this.germplasmService.getGermplasmByDBID(program.getId(), germplasmDbId).get() ;
observationUnit.putAdditionalInfoItem("gid", germplasm.getAccessionNumber());
}
Copy link
Member

Choose a reason for hiding this comment

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

Change looks good to me

for (BrAPIObservationUnit observationUnit: observationUnits) {
String germplasmDbId = observationUnit.getGermplasmDbId();
BrAPIGermplasm germplasm = this.germplasmService.getGermplasmByDBID(program.getId(), germplasmDbId).get() ;
observationUnit.putAdditionalInfoItem("gid", germplasm.getAccessionNumber());
Copy link
Member

Choose a reason for hiding this comment

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

Can we add gid to BrAPIAdditionalInfoFields constants and use that here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks.
Done.

Copy link
Contributor

@mlm483 mlm483 left a comment

Choose a reason for hiding this comment

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

Looks good.

@davedrp davedrp merged commit 7ca8a19 into develop Aug 22, 2023
@davedrp davedrp deleted the feature/BI-1647 branch August 22, 2023 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants