Fix build errors. Update containerOrd field to short instead of integer.
This commit is contained in:
parent
65a4fcc17f
commit
8b0441ae3e
|
@ -1785,12 +1785,12 @@ public class FhirTerser {
|
|||
|
||||
public static class ContainedResources extends EmbeddedResources {
|
||||
private long myNextContainedId = 1;
|
||||
private Map<IBaseResource, Integer> myResourceToOrdMap;
|
||||
private Map<IBaseResource, Short> myResourceToOrdMap;
|
||||
|
||||
@Override
|
||||
protected void addResource(IIdType theId, IBaseResource theResource) {
|
||||
super.addResource(theId, theResource);
|
||||
int ordinal = getOrCreateResourceList().size();
|
||||
short ordinal = Integer.valueOf(getOrCreateResourceList().size()).shortValue();
|
||||
getOrCreateResourceToOrdMap().put(theResource, ordinal);
|
||||
}
|
||||
|
||||
|
@ -1823,14 +1823,14 @@ public class FhirTerser {
|
|||
return getOrCreateResourceList();
|
||||
}
|
||||
|
||||
private Map<IBaseResource, Integer> getOrCreateResourceToOrdMap() {
|
||||
private Map<IBaseResource, Short> getOrCreateResourceToOrdMap() {
|
||||
if (myResourceToOrdMap == null) {
|
||||
myResourceToOrdMap = new IdentityHashMap<>();
|
||||
}
|
||||
return myResourceToOrdMap;
|
||||
}
|
||||
|
||||
public Integer getContainedResourceOrd(IBaseResource theResource) {
|
||||
public Short getContainedResourceOrd(IBaseResource theResource) {
|
||||
return getOrCreateResourceToOrdMap().get(theResource);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,5 @@ public class HapiFhirMigrationTasks_V7_2 {
|
|||
Builder.BuilderWithTableName tableBuilder = myVersion.onTable(idxTable);
|
||||
tableBuilder.addColumn(subVersionName, "contained_ord").nullable().type(ColumnTypeEnum.TINYINT);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public abstract class BaseResourceIndexedSearchParam extends BaseResourceIndex {
|
|||
|
||||
@GenericField
|
||||
@Column(name = "CONTAINED_ORD", nullable = true)
|
||||
private Integer myContainedOrd;
|
||||
private Short myContainedOrd;
|
||||
|
||||
@Override
|
||||
public abstract Long getId();
|
||||
|
@ -143,11 +143,11 @@ public abstract class BaseResourceIndexedSearchParam extends BaseResourceIndex {
|
|||
return myHashIdentity;
|
||||
}
|
||||
|
||||
public Integer getContainedOrd() {
|
||||
public Short getContainedOrd() {
|
||||
return myContainedOrd;
|
||||
}
|
||||
|
||||
public void setContainedOrd(Integer theContainedOrd) {
|
||||
public void setContainedOrd(Short theContainedOrd) {
|
||||
if (!Objects.equals(theContainedOrd, myContainedOrd)) {
|
||||
myContainedOrd = theContainedOrd;
|
||||
clearHashes();
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
package ca.uhn.fhir.jpa.model.entity;
|
||||
|
||||
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
|
||||
import ca.uhn.fhir.jpa.model.search.hash.ResourceIndexHasher;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
|
@ -119,6 +120,19 @@ public class ResourceIndexedSearchParamToken extends BaseResourceIndexedSearchPa
|
|||
*/
|
||||
public ResourceIndexedSearchParamToken() {}
|
||||
|
||||
@Deprecated(since = "7.2")
|
||||
public ResourceIndexedSearchParamToken(
|
||||
PartitionSettings thePartitionSettings,
|
||||
String theResourceType,
|
||||
String theParamName,
|
||||
String theSystem,
|
||||
String theValue) {
|
||||
setResourceType(theResourceType);
|
||||
setParamName(theParamName);
|
||||
setSystem(theSystem);
|
||||
setValue(theValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
|
|
@ -48,12 +48,12 @@ public class IdentityHasher {
|
|||
Object value = pd.getReadMethod().invoke(bean);
|
||||
hashValue(value, hasher);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(
|
||||
throw new IllegalStateException(
|
||||
Msg.code(2510) + "Failed to access " + targetClass + "#" + pd.getName(), e);
|
||||
}
|
||||
});
|
||||
} catch (IntrospectionException e) {
|
||||
throw new RuntimeException(Msg.code(2510) + "Failed to introspect " + targetClass, e);
|
||||
throw new IllegalStateException(Msg.code(2511) + "Failed to introspect " + targetClass, e);
|
||||
}
|
||||
return hasher.hash().asLong();
|
||||
}
|
||||
|
|
|
@ -143,23 +143,7 @@ public class ResourceIndexHasher {
|
|||
* @return the hash value
|
||||
*/
|
||||
public long hash(@Nullable RequestPartitionId theRequestPartitionId, @NotNull String... theValues) {
|
||||
HashIdentity identity = new HashIdentity(theValues);
|
||||
|
||||
if (myPartitionSettings.isPartitioningEnabled()
|
||||
&& myPartitionSettings.isIncludePartitionInSearchHashes()
|
||||
&& theRequestPartitionId != null
|
||||
&& theRequestPartitionId.hasPartitionIds()) {
|
||||
if (theRequestPartitionId.getPartitionIds().size() > 1) {
|
||||
throw new InternalErrorException(Msg.code(1527)
|
||||
+ "Can not search multiple partitions when partitions are included in search hashes");
|
||||
}
|
||||
Integer partitionId = theRequestPartitionId.getFirstPartitionIdOrNull();
|
||||
identity.setPartitionId(partitionId);
|
||||
}
|
||||
|
||||
identity.setContained(false);
|
||||
|
||||
return IdentityHasher.hash(identity);
|
||||
return hash(theRequestPartitionId, false, theValues);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -178,7 +162,7 @@ public class ResourceIndexHasher {
|
|||
&& theRequestPartitionId != null
|
||||
&& theRequestPartitionId.hasPartitionIds()) {
|
||||
if (theRequestPartitionId.getPartitionIds().size() > 1) {
|
||||
throw new InternalErrorException(Msg.code(1527)
|
||||
throw new InternalErrorException(Msg.code(2512)
|
||||
+ "Can not search multiple partitions when partitions are included in search hashes");
|
||||
}
|
||||
Integer partitionId = theRequestPartitionId.getFirstPartitionIdOrNull();
|
||||
|
|
|
@ -312,7 +312,7 @@ public class SearchParamExtractorService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Integer getContainedOrd(IBaseResource theResource) {
|
||||
public Short getContainedOrd(IBaseResource theResource) {
|
||||
return containedResources.getContainedResourceOrd(theResource);
|
||||
}
|
||||
};
|
||||
|
@ -502,7 +502,7 @@ public class SearchParamExtractorService {
|
|||
return theEmbeddedResources.getResource(reference.getReferenceElement());
|
||||
}
|
||||
|
||||
private void setContainerOrd(ResourceIndexedSearchParams theParams, Integer theContainerOrd) {
|
||||
private void setContainerOrd(ResourceIndexedSearchParams theParams, Short theContainerOrd) {
|
||||
setContainerOrd(theParams.myStringParams, theContainerOrd);
|
||||
setContainerOrd(theParams.myNumberParams, theContainerOrd);
|
||||
setContainerOrd(theParams.myQuantityParams, theContainerOrd);
|
||||
|
@ -514,7 +514,7 @@ public class SearchParamExtractorService {
|
|||
}
|
||||
|
||||
private void setContainerOrd(
|
||||
Collection<? extends BaseResourceIndexedSearchParam> theParams, Integer theContainerOrd) {
|
||||
Collection<? extends BaseResourceIndexedSearchParam> theParams, Short theContainerOrd) {
|
||||
theParams.forEach(param -> {
|
||||
param.setContainedOrd(theContainerOrd);
|
||||
param.calculateHashes(myResourceIndexHasher);
|
||||
|
@ -1243,7 +1243,7 @@ public class SearchParamExtractorService {
|
|||
|
||||
boolean isIndexOnContainedResources();
|
||||
|
||||
default Integer getContainedOrd(IBaseResource theResource) {
|
||||
default Short getContainedOrd(IBaseResource theResource) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,14 +146,14 @@ public class ChainingR4SearchTest extends BaseJpaR4Test {
|
|||
|
||||
IIdType obsId = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
||||
runInTransaction(()-> {
|
||||
Map<String, List<Integer>> containerOrdMap = new HashMap<>();
|
||||
Map<String, List<Short>> containerOrdMap = new HashMap<>();
|
||||
myResourceIndexedSearchParamStringDao.findAllForResourceId(obsId.getIdPartAsLong()).forEach(param -> {
|
||||
String paramName = param.getParamName();
|
||||
if (paramName.startsWith("patient.") || paramName.startsWith("performer.")) {
|
||||
Integer containerOrd = param.getContainedOrd();
|
||||
Short containerOrd = param.getContainedOrd();
|
||||
assertNotNull(containerOrd);
|
||||
assertTrue(containerOrd > 0L);
|
||||
List<Integer> list = containerOrdMap.get(paramName);
|
||||
List<Short> list = containerOrdMap.get(paramName);
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
|
@ -161,8 +161,12 @@ public class ChainingR4SearchTest extends BaseJpaR4Test {
|
|||
containerOrdMap.put(paramName, list);
|
||||
}
|
||||
});
|
||||
assertThat(containerOrdMap.get("patient.family"), containsInAnyOrder(1));
|
||||
assertThat(containerOrdMap.get("performer.family"), containsInAnyOrder(2, 3, 4));
|
||||
List<Short> patientFamilyOrdinalList = containerOrdMap.get("patient.family");
|
||||
assertNotNull(patientFamilyOrdinalList);
|
||||
assertThat(patientFamilyOrdinalList, contains(1));
|
||||
List<Short> performerFamilyOrdinalList = containerOrdMap.get("performer.family");
|
||||
assertNotNull(performerFamilyOrdinalList);
|
||||
assertThat(performerFamilyOrdinalList, containsInAnyOrder(2, 3, 4));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -135,7 +135,6 @@ public class GiantTransactionPerfTest {
|
|||
private IRequestPartitionHelperSvc myRequestPartitionHelperSvc;
|
||||
private SearchParamWithInlineReferencesExtractor mySearchParamWithInlineReferencesExtractor;
|
||||
private PartitionSettings myPartitionSettings;
|
||||
private ResourceIndexHasher myResourceIndexHasher;
|
||||
private SearchParamExtractorService mySearchParamExtractorSvc;
|
||||
private SearchParamExtractorR4 mySearchParamExtractor;
|
||||
private SearchParamRegistryImpl mySearchParamRegistry;
|
||||
|
@ -179,8 +178,6 @@ public class GiantTransactionPerfTest {
|
|||
myDaoRegistry = new DaoRegistry(ourFhirContext);
|
||||
|
||||
myPartitionSettings = new PartitionSettings();
|
||||
myResourceIndexHasher = new ResourceIndexHasher(myPartitionSettings, new StorageSettings());
|
||||
|
||||
myMetaTagSorter = new MetaTagSorterAlphabetical();
|
||||
|
||||
myHapiTransactionService = new HapiTransactionService();
|
||||
|
@ -236,23 +233,25 @@ public class GiantTransactionPerfTest {
|
|||
mySearchParamRegistry.setStorageSettings(myStorageSettings);
|
||||
mySearchParamRegistry.registerListener();
|
||||
|
||||
ResourceIndexHasher resourceIndexHasher = new ResourceIndexHasher(myPartitionSettings, new StorageSettings());
|
||||
|
||||
mySearchParamExtractor = new SearchParamExtractorR4();
|
||||
mySearchParamExtractor.setContext(ourFhirContext);
|
||||
mySearchParamExtractor.setSearchParamRegistry(mySearchParamRegistry);
|
||||
mySearchParamExtractor.setStorageSettings(myStorageSettings);
|
||||
mySearchParamExtractor.setResourceIndexHasher(myResourceIndexHasher);
|
||||
mySearchParamExtractor.setResourceIndexHasher(resourceIndexHasher);
|
||||
mySearchParamExtractor.start();
|
||||
|
||||
mySearchParamExtractorSvc = new SearchParamExtractorService();
|
||||
mySearchParamExtractorSvc.setContext(ourFhirContext);
|
||||
mySearchParamExtractorSvc.setSearchParamExtractor(mySearchParamExtractor);
|
||||
mySearchParamExtractorSvc.setStorageSettings(myStorageSettings);
|
||||
mySearchParamExtractorSvc.setResourceIndexHasher(myResourceIndexHasher);
|
||||
mySearchParamExtractorSvc.setResourceIndexHasher(resourceIndexHasher);
|
||||
|
||||
|
||||
myDaoSearchParamSynchronizer = new DaoSearchParamSynchronizer();
|
||||
myDaoSearchParamSynchronizer.setEntityManager(myEntityManager);
|
||||
myDaoSearchParamSynchronizer.setResourceIndexHasher(myResourceIndexHasher);
|
||||
myDaoSearchParamSynchronizer.setResourceIndexHasher(resourceIndexHasher);
|
||||
|
||||
mySearchParamWithInlineReferencesExtractor = new SearchParamWithInlineReferencesExtractor();
|
||||
mySearchParamWithInlineReferencesExtractor.setStorageSettings(myStorageSettings);
|
||||
|
|
Loading…
Reference in New Issue