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

SO-2124 - Request sct ids at once during bulk requests #121

Merged
merged 12 commits into from
Nov 22, 2016

Conversation

nagyo
Copy link
Member

@nagyo nagyo commented Nov 21, 2016

@cmark cmark self-assigned this Nov 22, 2016
@@ -104,4 +104,7 @@ private Object executeNext(TransactionContext context) {
return CommitResult.class;
}

public Request<TransactionContext, ?> getNext() {
Copy link
Member

Choose a reason for hiding this comment

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

Add javadoc for all public/protected methods, please.

void setIdGenerationStrategy(final IdGenerationStrategy idGenerationStrategy) {
@Override
@JsonIgnore
public void setIdGenerationStrategy(final IdGenerationStrategy idGenerationStrategy) {
Copy link
Member

Choose a reason for hiding this comment

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

Abstract classes should have either abstract or final methods, nothing in between (preferably). Mark this method final.

String componentId = getIdGenerationStrategy().generate(context);

try {
checkComponentExists(context, componentId);
Copy link
Member

Choose a reason for hiding this comment

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

Checking component IDs per item can be the next performance bottleneck. Let's have a chat about this.

}

if (Iterators.size(idsToUse) != 0) {
throw new RuntimeException("More SNOMED CT ids have been requested than the amount of create requests");
Copy link
Member

Choose a reason for hiding this comment

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

I think a Preconditions.checkState() would be better here, since this is more of a programming error than a runtime error.

}
}

return null;
Copy link
Member

Choose a reason for hiding this comment

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

It is better to return empty collection instances than nulls.

} else if (input instanceof SnomedRelationshipCreateRequest) {
return ComponentCategory.RELATIONSHIP;
}
throw new IllegalArgumentException(String.format("Unknown create request type: %s", input.getClass().getName()));
Copy link
Member

Choose a reason for hiding this comment

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

Throw BadRequestException instead of IllegalArgumentExceptions in from Request implementations.

@@ -26,6 +26,8 @@

IdGenerationStrategy getIdGenerationStrategy();

void setIdGenerationStrategy(IdGenerationStrategy idGenerationStrategy);
Copy link
Member

Choose a reason for hiding this comment

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

Request objects should look like immutable objects from the client's perspective.
It is safe to cast to BaseSnomedComponentCreateRequest in implementation classes like in the IdRequest, thus this public setter method can be removed.

@@ -56,4 +118,52 @@ public CommitResult execute(BranchContext context) {
}
}

private String getNamespace(final SnomedComponentCreateRequest createRequest) {
final IdGenerationStrategy idGenerationStrategy = createRequest.getIdGenerationStrategy();
if (idGenerationStrategy instanceof ReservingIdStrategy) {
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure this is the only strategy implementation used by SnomedComponentCreateRequest classes?

- added javadoc
- remove setter from SnomedComponentCreateRequest
- make setIdGenerationStrategy method final
- throw proper exceptions
- return empty map when collecting create requests
- ensure unique id allocation

https://snowowl.atlassian.net/browse/SO-2124
return context.service(RevisionIndex.class).read(context.branch().path(), new RevisionIndexRead<Collection<String>>() {
@Override
public Collection<String> execute(final RevisionSearcher index) throws IOException {
final Hits<? extends SnomedComponentDocument> hits = index.searcher()
Copy link
Member

Choose a reason for hiding this comment

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

This will return all revisions for a single ID, use RevisionSearcher.search(...) instead of the raw searcher.
Also you can use the already opened RevisionSearcher instance via context.service(RevisionSearcher.class).

@nagyo nagyo merged commit a17ec60 into develop Nov 22, 2016
@cmark cmark deleted the issue/SO-2124-Request_sct_ids_in_bulk branch June 19, 2017 10:41
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.

2 participants