Search Param Matcher Performance Improvement (#5999)
* filter function added * spotless
This commit is contained in:
parent
87fab18123
commit
d2923da62b
|
@ -22,12 +22,15 @@ package ca.uhn.fhir.jpa.searchparam.matcher;
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
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.jpa.searchparam.extractor.ResourceIndexedSearchParams;
|
||||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SearchParamMatcher {
|
public class SearchParamMatcher {
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -48,9 +51,16 @@ public class SearchParamMatcher {
|
||||||
return InMemoryMatchResult.successfulMatch();
|
return InMemoryMatchResult.successfulMatch();
|
||||||
}
|
}
|
||||||
ResourceIndexedSearchParams resourceIndexedSearchParams =
|
ResourceIndexedSearchParams resourceIndexedSearchParams =
|
||||||
myIndexedSearchParamExtractor.extractIndexedSearchParams(theResource, null);
|
myIndexedSearchParamExtractor.extractIndexedSearchParams(
|
||||||
|
theResource, null, getFilter(theSearchParameterMap));
|
||||||
RuntimeResourceDefinition resourceDefinition = myFhirContext.getResourceDefinition(theResource);
|
RuntimeResourceDefinition resourceDefinition = myFhirContext.getResourceDefinition(theResource);
|
||||||
return myInMemoryResourceMatcher.match(
|
return myInMemoryResourceMatcher.match(
|
||||||
theSearchParameterMap, theResource, resourceDefinition, resourceIndexedSearchParams);
|
theSearchParameterMap, theResource, resourceDefinition, resourceIndexedSearchParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ISearchParamExtractor.ISearchParamFilter getFilter(SearchParameterMap searchParameterMap) {
|
||||||
|
return theSearchParams -> theSearchParams.stream()
|
||||||
|
.filter(runtimeSearchParam -> searchParameterMap.keySet().contains(runtimeSearchParam.getName()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue