summaryrefslogtreecommitdiffstats
path: root/cps-ri/src/main
diff options
context:
space:
mode:
authordanielhanrahan <daniel.hanrahan@est.tech>2023-02-26 14:27:06 +0000
committerdanielhanrahan <daniel.hanrahan@est.tech>2023-02-28 16:29:20 +0000
commit373cdf2e88201f4262bdb3c933a0f84a4160bf72 (patch)
treef92fefdd04367bf58a03d969ef1123e768494dfb /cps-ri/src/main
parentd7aa2fa43e3ffef8ed03c0a8688135cbd0c19f71 (diff)
Skip deleting list xpaths that are list elements
List elements cannot be lists. Filtering list elements before trying to delete lists by xpaths doubles performance when deleting list elements (which doubles performance of CM handle de-registration). Issue-ID: CPS-1511 Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech> Change-Id: Ieb6002212d006396d468f27f853708b5aa1e31f2
Diffstat (limited to 'cps-ri/src/main')
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java
index dd2d3652ea..2159ceae8a 100644
--- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java
@@ -621,17 +621,23 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService
final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
final AnchorEntity anchorEntity = anchorRepository.getByDataspaceAndName(dataspaceEntity, anchorName);
- final Collection<String> normalizedXpaths = new ArrayList<>(xpathsToDelete.size());
+ final Collection<String> normalizedXPathsToDelete = new ArrayList<>(xpathsToDelete.size());
+ final Collection<String> normalizedXpathsToPotentialLists = new ArrayList<>();
for (final String xpath : xpathsToDelete) {
try {
- normalizedXpaths.add(CpsPathUtil.getNormalizedXpath(xpath));
+ final CpsPathQuery cpsPathQuery = CpsPathUtil.getCpsPathQuery(xpath);
+ final String normalizedXpath = cpsPathQuery.getNormalizedXpath();
+ normalizedXPathsToDelete.add(normalizedXpath);
+ if (!cpsPathQuery.isPathToListElement()) {
+ normalizedXpathsToPotentialLists.add(normalizedXpath);
+ }
} catch (final PathParsingException e) {
log.debug("Error parsing xpath \"{}\": {}", xpath, e.getMessage());
}
}
- fragmentRepository.deleteByAnchorIdAndXpaths(anchorEntity.getId(), normalizedXpaths);
- fragmentRepository.deleteListsByAnchorIdAndXpaths(anchorEntity.getId(), normalizedXpaths);
+ fragmentRepository.deleteByAnchorIdAndXpaths(anchorEntity.getId(), normalizedXPathsToDelete);
+ fragmentRepository.deleteListsByAnchorIdAndXpaths(anchorEntity.getId(), normalizedXpathsToPotentialLists);
}
@Override