diff options
author | danielhanrahan <daniel.hanrahan@est.tech> | 2024-04-26 10:09:54 +0100 |
---|---|---|
committer | danielhanrahan <daniel.hanrahan@est.tech> | 2024-04-26 10:48:29 +0100 |
commit | 2830723b8c5d5bb40c171c88f055adbc1a808f68 (patch) | |
tree | dd32cb1b04c1724614c9f3f7bdc683a1be09e803 /cps-ri/src | |
parent | 2b979f63a4020b65a2a85ecdb2bfa2b970eb9f76 (diff) |
Faster module searches (CPS-2190 #3)
This greatly improves performance of module searches by eliminating
unneeded SQL queries via Hibernate lazy fetching.
Issue-ID: CPS-2190
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
Change-Id: Ie9e65017d0027366456f1741cc37b10679317b25
Diffstat (limited to 'cps-ri/src')
-rwxr-xr-x | cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java | 7 | ||||
-rwxr-xr-x | cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java | 16 |
2 files changed, 11 insertions, 12 deletions
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java index d697fd53fc..56a046496e 100755 --- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java @@ -131,11 +131,10 @@ public class CpsAdminPersistenceServiceImpl implements CpsAdminPersistenceServic } @Override - public Collection<Anchor> queryAnchors(final String dataspaceName, final Collection<String> inputModuleNames) { + public Collection<String> queryAnchorNames(final String dataspaceName, final Collection<String> inputModuleNames) { final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName); - final Collection<AnchorEntity> anchorEntities = anchorRepository - .getAnchorsByDataspaceIdAndModuleNames(dataspaceEntity.getId(), inputModuleNames, inputModuleNames.size()); - return anchorEntities.stream().map(CpsAdminPersistenceServiceImpl::toAnchor).collect(Collectors.toSet()); + return anchorRepository.getAnchorNamesByDataspaceIdAndModuleNames(dataspaceEntity.getId(), inputModuleNames, + inputModuleNames.size()); } @Override diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java index 19646c5239..d78a016c2e 100755 --- a/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java @@ -72,7 +72,7 @@ public interface AnchorRepository extends JpaRepository<AnchorEntity, Long> { @Query(value = """ SELECT - anchor.* + anchor.name FROM yang_resource JOIN schema_set_yang_resources ON schema_set_yang_resources.yang_resource_id = yang_resource.id @@ -89,15 +89,15 @@ public interface AnchorRepository extends JpaRepository<AnchorEntity, Long> { HAVING COUNT(DISTINCT module_name) = :sizeOfModuleNames """, nativeQuery = true) - Collection<AnchorEntity> getAnchorsByDataspaceIdAndModuleNames(@Param("dataspaceId") int dataspaceId, - @Param("moduleNames") String[] moduleNames, - @Param("sizeOfModuleNames") int sizeOfModuleNames); + Collection<String> getAnchorNamesByDataspaceIdAndModuleNames(@Param("dataspaceId") int dataspaceId, + @Param("moduleNames") String[] moduleNames, + @Param("sizeOfModuleNames") int sizeOfModuleNames); - default Collection<AnchorEntity> getAnchorsByDataspaceIdAndModuleNames(final int dataspaceId, - final Collection<String> moduleNames, - final int sizeOfModuleNames) { + default Collection<String> getAnchorNamesByDataspaceIdAndModuleNames(final int dataspaceId, + final Collection<String> moduleNames, + final int sizeOfModuleNames) { final String[] moduleNamesArray = moduleNames.toArray(new String[0]); - return getAnchorsByDataspaceIdAndModuleNames(dataspaceId, moduleNamesArray, sizeOfModuleNames); + return getAnchorNamesByDataspaceIdAndModuleNames(dataspaceId, moduleNamesArray, sizeOfModuleNames); } @Modifying |