Fix build errors. Update containerOrd field to short instead of integer.

This commit is contained in:
Martha 2024-04-09 11:13:37 -07:00
parent 65a4fcc17f
commit 8b0441ae3e
9 changed files with 43 additions and 43 deletions

View File

@ -1785,12 +1785,12 @@ public class FhirTerser {
public static class ContainedResources extends EmbeddedResources { public static class ContainedResources extends EmbeddedResources {
private long myNextContainedId = 1; private long myNextContainedId = 1;
private Map<IBaseResource, Integer> myResourceToOrdMap; private Map<IBaseResource, Short> myResourceToOrdMap;
@Override @Override
protected void addResource(IIdType theId, IBaseResource theResource) { protected void addResource(IIdType theId, IBaseResource theResource) {
super.addResource(theId, theResource); super.addResource(theId, theResource);
int ordinal = getOrCreateResourceList().size(); short ordinal = Integer.valueOf(getOrCreateResourceList().size()).shortValue();
getOrCreateResourceToOrdMap().put(theResource, ordinal); getOrCreateResourceToOrdMap().put(theResource, ordinal);
} }
@ -1823,14 +1823,14 @@ public class FhirTerser {
return getOrCreateResourceList(); return getOrCreateResourceList();
} }
private Map<IBaseResource, Integer> getOrCreateResourceToOrdMap() { private Map<IBaseResource, Short> getOrCreateResourceToOrdMap() {
if (myResourceToOrdMap == null) { if (myResourceToOrdMap == null) {
myResourceToOrdMap = new IdentityHashMap<>(); myResourceToOrdMap = new IdentityHashMap<>();
} }
return myResourceToOrdMap; return myResourceToOrdMap;
} }
public Integer getContainedResourceOrd(IBaseResource theResource) { public Short getContainedResourceOrd(IBaseResource theResource) {
return getOrCreateResourceToOrdMap().get(theResource); return getOrCreateResourceToOrdMap().get(theResource);
} }
} }

View File

@ -45,6 +45,5 @@ public class HapiFhirMigrationTasks_V7_2 {
Builder.BuilderWithTableName tableBuilder = myVersion.onTable(idxTable); Builder.BuilderWithTableName tableBuilder = myVersion.onTable(idxTable);
tableBuilder.addColumn(subVersionName, "contained_ord").nullable().type(ColumnTypeEnum.TINYINT); tableBuilder.addColumn(subVersionName, "contained_ord").nullable().type(ColumnTypeEnum.TINYINT);
}); });
} }
} }

View File

@ -66,7 +66,7 @@ public abstract class BaseResourceIndexedSearchParam extends BaseResourceIndex {
@GenericField @GenericField
@Column(name = "CONTAINED_ORD", nullable = true) @Column(name = "CONTAINED_ORD", nullable = true)
private Integer myContainedOrd; private Short myContainedOrd;
@Override @Override
public abstract Long getId(); public abstract Long getId();
@ -143,11 +143,11 @@ public abstract class BaseResourceIndexedSearchParam extends BaseResourceIndex {
return myHashIdentity; return myHashIdentity;
} }
public Integer getContainedOrd() { public Short getContainedOrd() {
return myContainedOrd; return myContainedOrd;
} }
public void setContainedOrd(Integer theContainedOrd) { public void setContainedOrd(Short theContainedOrd) {
if (!Objects.equals(theContainedOrd, myContainedOrd)) { if (!Objects.equals(theContainedOrd, myContainedOrd)) {
myContainedOrd = theContainedOrd; myContainedOrd = theContainedOrd;
clearHashes(); clearHashes();

View File

@ -19,6 +19,7 @@
*/ */
package ca.uhn.fhir.jpa.model.entity; 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.jpa.model.search.hash.ResourceIndexHasher;
import ca.uhn.fhir.model.api.IQueryParameterType; import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.Constants;
@ -119,6 +120,19 @@ public class ResourceIndexedSearchParamToken extends BaseResourceIndexedSearchPa
*/ */
public ResourceIndexedSearchParamToken() {} 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 * Constructor
*/ */

View File

@ -48,12 +48,12 @@ public class IdentityHasher {
Object value = pd.getReadMethod().invoke(bean); Object value = pd.getReadMethod().invoke(bean);
hashValue(value, hasher); hashValue(value, hasher);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException( throw new IllegalStateException(
Msg.code(2510) + "Failed to access " + targetClass + "#" + pd.getName(), e); Msg.code(2510) + "Failed to access " + targetClass + "#" + pd.getName(), e);
} }
}); });
} catch (IntrospectionException 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(); return hasher.hash().asLong();
} }

View File

@ -143,23 +143,7 @@ public class ResourceIndexHasher {
* @return the hash value * @return the hash value
*/ */
public long hash(@Nullable RequestPartitionId theRequestPartitionId, @NotNull String... theValues) { public long hash(@Nullable RequestPartitionId theRequestPartitionId, @NotNull String... theValues) {
HashIdentity identity = new HashIdentity(theValues); return hash(theRequestPartitionId, false, 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);
} }
/** /**
@ -178,7 +162,7 @@ public class ResourceIndexHasher {
&& theRequestPartitionId != null && theRequestPartitionId != null
&& theRequestPartitionId.hasPartitionIds()) { && theRequestPartitionId.hasPartitionIds()) {
if (theRequestPartitionId.getPartitionIds().size() > 1) { 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"); + "Can not search multiple partitions when partitions are included in search hashes");
} }
Integer partitionId = theRequestPartitionId.getFirstPartitionIdOrNull(); Integer partitionId = theRequestPartitionId.getFirstPartitionIdOrNull();

View File

@ -312,7 +312,7 @@ public class SearchParamExtractorService {
} }
@Override @Override
public Integer getContainedOrd(IBaseResource theResource) { public Short getContainedOrd(IBaseResource theResource) {
return containedResources.getContainedResourceOrd(theResource); return containedResources.getContainedResourceOrd(theResource);
} }
}; };
@ -502,7 +502,7 @@ public class SearchParamExtractorService {
return theEmbeddedResources.getResource(reference.getReferenceElement()); 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.myStringParams, theContainerOrd);
setContainerOrd(theParams.myNumberParams, theContainerOrd); setContainerOrd(theParams.myNumberParams, theContainerOrd);
setContainerOrd(theParams.myQuantityParams, theContainerOrd); setContainerOrd(theParams.myQuantityParams, theContainerOrd);
@ -514,7 +514,7 @@ public class SearchParamExtractorService {
} }
private void setContainerOrd( private void setContainerOrd(
Collection<? extends BaseResourceIndexedSearchParam> theParams, Integer theContainerOrd) { Collection<? extends BaseResourceIndexedSearchParam> theParams, Short theContainerOrd) {
theParams.forEach(param -> { theParams.forEach(param -> {
param.setContainedOrd(theContainerOrd); param.setContainedOrd(theContainerOrd);
param.calculateHashes(myResourceIndexHasher); param.calculateHashes(myResourceIndexHasher);
@ -1243,7 +1243,7 @@ public class SearchParamExtractorService {
boolean isIndexOnContainedResources(); boolean isIndexOnContainedResources();
default Integer getContainedOrd(IBaseResource theResource) { default Short getContainedOrd(IBaseResource theResource) {
return null; return null;
} }
} }

View File

@ -146,14 +146,14 @@ public class ChainingR4SearchTest extends BaseJpaR4Test {
IIdType obsId = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); IIdType obsId = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
runInTransaction(()-> { runInTransaction(()-> {
Map<String, List<Integer>> containerOrdMap = new HashMap<>(); Map<String, List<Short>> containerOrdMap = new HashMap<>();
myResourceIndexedSearchParamStringDao.findAllForResourceId(obsId.getIdPartAsLong()).forEach(param -> { myResourceIndexedSearchParamStringDao.findAllForResourceId(obsId.getIdPartAsLong()).forEach(param -> {
String paramName = param.getParamName(); String paramName = param.getParamName();
if (paramName.startsWith("patient.") || paramName.startsWith("performer.")) { if (paramName.startsWith("patient.") || paramName.startsWith("performer.")) {
Integer containerOrd = param.getContainedOrd(); Short containerOrd = param.getContainedOrd();
assertNotNull(containerOrd); assertNotNull(containerOrd);
assertTrue(containerOrd > 0L); assertTrue(containerOrd > 0L);
List<Integer> list = containerOrdMap.get(paramName); List<Short> list = containerOrdMap.get(paramName);
if (list == null) { if (list == null) {
list = new ArrayList<>(); list = new ArrayList<>();
} }
@ -161,8 +161,12 @@ public class ChainingR4SearchTest extends BaseJpaR4Test {
containerOrdMap.put(paramName, list); containerOrdMap.put(paramName, list);
} }
}); });
assertThat(containerOrdMap.get("patient.family"), containsInAnyOrder(1)); List<Short> patientFamilyOrdinalList = containerOrdMap.get("patient.family");
assertThat(containerOrdMap.get("performer.family"), containsInAnyOrder(2, 3, 4)); assertNotNull(patientFamilyOrdinalList);
assertThat(patientFamilyOrdinalList, contains(1));
List<Short> performerFamilyOrdinalList = containerOrdMap.get("performer.family");
assertNotNull(performerFamilyOrdinalList);
assertThat(performerFamilyOrdinalList, containsInAnyOrder(2, 3, 4));
}); });
} }

View File

@ -135,7 +135,6 @@ public class GiantTransactionPerfTest {
private IRequestPartitionHelperSvc myRequestPartitionHelperSvc; private IRequestPartitionHelperSvc myRequestPartitionHelperSvc;
private SearchParamWithInlineReferencesExtractor mySearchParamWithInlineReferencesExtractor; private SearchParamWithInlineReferencesExtractor mySearchParamWithInlineReferencesExtractor;
private PartitionSettings myPartitionSettings; private PartitionSettings myPartitionSettings;
private ResourceIndexHasher myResourceIndexHasher;
private SearchParamExtractorService mySearchParamExtractorSvc; private SearchParamExtractorService mySearchParamExtractorSvc;
private SearchParamExtractorR4 mySearchParamExtractor; private SearchParamExtractorR4 mySearchParamExtractor;
private SearchParamRegistryImpl mySearchParamRegistry; private SearchParamRegistryImpl mySearchParamRegistry;
@ -179,8 +178,6 @@ public class GiantTransactionPerfTest {
myDaoRegistry = new DaoRegistry(ourFhirContext); myDaoRegistry = new DaoRegistry(ourFhirContext);
myPartitionSettings = new PartitionSettings(); myPartitionSettings = new PartitionSettings();
myResourceIndexHasher = new ResourceIndexHasher(myPartitionSettings, new StorageSettings());
myMetaTagSorter = new MetaTagSorterAlphabetical(); myMetaTagSorter = new MetaTagSorterAlphabetical();
myHapiTransactionService = new HapiTransactionService(); myHapiTransactionService = new HapiTransactionService();
@ -236,23 +233,25 @@ public class GiantTransactionPerfTest {
mySearchParamRegistry.setStorageSettings(myStorageSettings); mySearchParamRegistry.setStorageSettings(myStorageSettings);
mySearchParamRegistry.registerListener(); mySearchParamRegistry.registerListener();
ResourceIndexHasher resourceIndexHasher = new ResourceIndexHasher(myPartitionSettings, new StorageSettings());
mySearchParamExtractor = new SearchParamExtractorR4(); mySearchParamExtractor = new SearchParamExtractorR4();
mySearchParamExtractor.setContext(ourFhirContext); mySearchParamExtractor.setContext(ourFhirContext);
mySearchParamExtractor.setSearchParamRegistry(mySearchParamRegistry); mySearchParamExtractor.setSearchParamRegistry(mySearchParamRegistry);
mySearchParamExtractor.setStorageSettings(myStorageSettings); mySearchParamExtractor.setStorageSettings(myStorageSettings);
mySearchParamExtractor.setResourceIndexHasher(myResourceIndexHasher); mySearchParamExtractor.setResourceIndexHasher(resourceIndexHasher);
mySearchParamExtractor.start(); mySearchParamExtractor.start();
mySearchParamExtractorSvc = new SearchParamExtractorService(); mySearchParamExtractorSvc = new SearchParamExtractorService();
mySearchParamExtractorSvc.setContext(ourFhirContext); mySearchParamExtractorSvc.setContext(ourFhirContext);
mySearchParamExtractorSvc.setSearchParamExtractor(mySearchParamExtractor); mySearchParamExtractorSvc.setSearchParamExtractor(mySearchParamExtractor);
mySearchParamExtractorSvc.setStorageSettings(myStorageSettings); mySearchParamExtractorSvc.setStorageSettings(myStorageSettings);
mySearchParamExtractorSvc.setResourceIndexHasher(myResourceIndexHasher); mySearchParamExtractorSvc.setResourceIndexHasher(resourceIndexHasher);
myDaoSearchParamSynchronizer = new DaoSearchParamSynchronizer(); myDaoSearchParamSynchronizer = new DaoSearchParamSynchronizer();
myDaoSearchParamSynchronizer.setEntityManager(myEntityManager); myDaoSearchParamSynchronizer.setEntityManager(myEntityManager);
myDaoSearchParamSynchronizer.setResourceIndexHasher(myResourceIndexHasher); myDaoSearchParamSynchronizer.setResourceIndexHasher(resourceIndexHasher);
mySearchParamWithInlineReferencesExtractor = new SearchParamWithInlineReferencesExtractor(); mySearchParamWithInlineReferencesExtractor = new SearchParamWithInlineReferencesExtractor();
mySearchParamWithInlineReferencesExtractor.setStorageSettings(myStorageSettings); mySearchParamWithInlineReferencesExtractor.setStorageSettings(myStorageSettings);