Search Param Matcher Performance Improvement (#5999)

* filter function added

* spotless
This commit is contained in:
Ahmet Melih Aydoğdu 2024-06-17 12:17:49 +02:00 committed by GitHub
parent 87fab18123
commit d2923da62b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 1 deletions

View File

@ -22,12 +22,15 @@ package ca.uhn.fhir.jpa.searchparam.matcher;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.jpa.searchparam.extractor.ISearchParamExtractor;
import ca.uhn.fhir.jpa.searchparam.extractor.ResourceIndexedSearchParams;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.stream.Collectors;
@Service
public class SearchParamMatcher {
@Autowired
@ -48,9 +51,16 @@ public class SearchParamMatcher {
return InMemoryMatchResult.successfulMatch();
}
ResourceIndexedSearchParams resourceIndexedSearchParams =
myIndexedSearchParamExtractor.extractIndexedSearchParams(theResource, null);
myIndexedSearchParamExtractor.extractIndexedSearchParams(
theResource, null, getFilter(theSearchParameterMap));
RuntimeResourceDefinition resourceDefinition = myFhirContext.getResourceDefinition(theResource);
return myInMemoryResourceMatcher.match(
theSearchParameterMap, theResource, resourceDefinition, resourceIndexedSearchParams);
}
private ISearchParamExtractor.ISearchParamFilter getFilter(SearchParameterMap searchParameterMap) {
return theSearchParams -> theSearchParams.stream()
.filter(runtimeSearchParam -> searchParameterMap.keySet().contains(runtimeSearchParam.getName()))
.collect(Collectors.toList());
}
}