diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index be5fff215..e40d5b21e 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1 +1,2 @@ +- [cygnus-ngsi][ColumnAggregator] Fix lastdata when remove multiple entities by alterationType with entityDelete - [cygnus-ngsi][ColumnAggregator][LastData] Fix error when remove old values in lastData which does not exist (i.e. creating and updating entities) diff --git a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/aggregation/NGSIGenericColumnAggregator.java b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/aggregation/NGSIGenericColumnAggregator.java index e031211b9..314bf8daa 100644 --- a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/aggregation/NGSIGenericColumnAggregator.java +++ b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/aggregation/NGSIGenericColumnAggregator.java @@ -266,11 +266,20 @@ public void aggregate(NGSIEvent event) { setLastDataTimestamp(currentTS); for (String key : aggregation.keySet()) { ArrayList valueLastData = new ArrayList<>(); - if (lastData.containsKey(key)) { - valueLastData = lastData.get(key); - } else if (!lastData.containsKey(key)){ - valueLastData = new ArrayList(Collections.nCopies(numPreviousValues, null)); + if (lastDataEntityDelete) { + if (lastDataDelete.containsKey(key)) { + valueLastData = lastDataDelete.get(key); + } else if (!lastDataDelete.containsKey(key)){ + valueLastData = new ArrayList(Collections.nCopies(numPreviousValues, null)); + } + } else { + if (lastData.containsKey(key)) { + valueLastData = lastData.get(key); + } else if (!lastData.containsKey(key)) { + valueLastData = new ArrayList(Collections.nCopies(numPreviousValues, null)); + } } + valueLastData.add(aggregation.get(key).get(aggregation.get(key).size() - 1)); if (lastDataEntityDelete) { lastDataDelete.put(key, valueLastData);