Skip to content

Commit

Permalink
Merge pull request #2357 from telefonicaid/fix/event_multiple_delete_…
Browse files Browse the repository at this point in the history
…lastdatadelete

Fix/event multiple delete lastdatadelete
  • Loading branch information
fgalan authored Mar 8, 2024
2 parents 93f11cb + 4003e46 commit ad238b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,20 @@ public void aggregate(NGSIEvent event) {
setLastDataTimestamp(currentTS);
for (String key : aggregation.keySet()) {
ArrayList<JsonElement> valueLastData = new ArrayList<>();
if (lastData.containsKey(key)) {
valueLastData = lastData.get(key);
} else if (!lastData.containsKey(key)){
valueLastData = new ArrayList<JsonElement>(Collections.nCopies(numPreviousValues, null));
if (lastDataEntityDelete) {
if (lastDataDelete.containsKey(key)) {
valueLastData = lastDataDelete.get(key);
} else if (!lastDataDelete.containsKey(key)){
valueLastData = new ArrayList<JsonElement>(Collections.nCopies(numPreviousValues, null));
}
} else {
if (lastData.containsKey(key)) {
valueLastData = lastData.get(key);
} else if (!lastData.containsKey(key)) {
valueLastData = new ArrayList<JsonElement>(Collections.nCopies(numPreviousValues, null));
}
}

valueLastData.add(aggregation.get(key).get(aggregation.get(key).size() - 1));
if (lastDataEntityDelete) {
lastDataDelete.put(key, valueLastData);
Expand Down

0 comments on commit ad238b7

Please sign in to comment.