summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathQuery.java11
-rw-r--r--cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathUtil.java6
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java14
-rw-r--r--cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsDataPersistenceServiceDeletePerfTest.groovy7
4 files changed, 24 insertions, 14 deletions
diff --git a/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathQuery.java b/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathQuery.java
index c9df8df90..398545526 100644
--- a/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathQuery.java
+++ b/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathQuery.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation
+ * Copyright (C) 2021-2023 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -80,4 +80,13 @@ public class CpsPathQuery {
return textFunctionConditionLeafName != null;
}
+ /**
+ * Returns boolean indicating xpath is an absolute path to a list element.
+ *
+ * @return true if xpath is an absolute path to a list element
+ */
+ public boolean isPathToListElement() {
+ return cpsPathPrefixType == ABSOLUTE && hasLeafConditions();
+ }
+
}
diff --git a/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathUtil.java b/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathUtil.java
index 60f0e2efc..bde9b0638 100644
--- a/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathUtil.java
+++ b/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathUtil.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation
+ * Copyright (C) 2022-2023 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +20,6 @@
package org.onap.cps.cpspath.parser;
-import static org.onap.cps.cpspath.parser.CpsPathPrefixType.ABSOLUTE;
-
import java.util.List;
import lombok.AccessLevel;
import lombok.Getter;
@@ -75,7 +73,7 @@ public class CpsPathUtil {
*/
public static boolean isPathToListElement(final String xpathSource) {
final CpsPathQuery cpsPathQuery = getCpsPathBuilder(xpathSource).build();
- return cpsPathQuery.getCpsPathPrefixType() == ABSOLUTE && cpsPathQuery.hasLeafConditions();
+ return cpsPathQuery.isPathToListElement();
}
/**
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 dd2d3652e..2159ceae8 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
diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsDataPersistenceServiceDeletePerfTest.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsDataPersistenceServiceDeletePerfTest.groovy
index 8e74b6222..a08d8c66d 100644
--- a/cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsDataPersistenceServiceDeletePerfTest.groovy
+++ b/cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsDataPersistenceServiceDeletePerfTest.groovy
@@ -24,15 +24,12 @@ import org.onap.cps.spi.CpsDataPersistenceService
import org.onap.cps.spi.impl.CpsPersistencePerfSpecBase
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.jdbc.Sql
-import org.springframework.util.StopWatch
class CpsDataPersistenceServiceDeletePerfTest extends CpsPersistencePerfSpecBase {
@Autowired
CpsDataPersistenceService objectUnderTest
- def stopWatch = new StopWatch()
-
@Sql([CLEAR_DATA, PERF_TEST_DATA])
def 'Create a node with many descendants (please note, subsequent tests depend on this running first).'() {
when: 'a node with a large number of descendants is created'
@@ -165,8 +162,8 @@ class CpsDataPersistenceServiceDeletePerfTest extends CpsPersistencePerfSpecBase
objectUnderTest.deleteDataNodes(PERF_DATASPACE, PERF_ANCHOR, xpathsToDelete)
stopWatch.stop()
def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
- then: 'delete duration is under 125 milliseconds'
- recordAndAssertPerformance('Batch delete 500 lists elements', 125, deleteDurationInMillis)
+ then: 'delete duration is under 60 milliseconds'
+ recordAndAssertPerformance('Batch delete 500 lists elements', 60, deleteDurationInMillis)
}
@Sql([CLEAR_DATA, PERF_TEST_DATA])