From b2191b96f631aacc0f789c21fce5876eb29bb473 Mon Sep 17 00:00:00 2001 From: "patrick.pdb" Date: Mon, 26 Aug 2024 10:07:34 -0400 Subject: [PATCH] '#2311 Properly invalidates internal unions cache after bookmark deletion and creation. --- .../src/main/java/iped/engine/data/BitmapBookmarks.java | 4 ++++ .../src/main/java/iped/engine/data/MultiBitmapBookmarks.java | 2 ++ 2 files changed, 6 insertions(+) diff --git a/iped-engine/src/main/java/iped/engine/data/BitmapBookmarks.java b/iped-engine/src/main/java/iped/engine/data/BitmapBookmarks.java index e0ca746484..6e42fa1dd1 100644 --- a/iped-engine/src/main/java/iped/engine/data/BitmapBookmarks.java +++ b/iped-engine/src/main/java/iped/engine/data/BitmapBookmarks.java @@ -185,6 +185,7 @@ public synchronized void addBookmark(List ids, int bookmark) { RoaringBitmap bookmarkBitmap = bookmarks.get(bookmark); for (Integer id : ids) { bookmarkBitmap.add(id); + //updates cache if (unionAll != null) { unionAll.add(id); } @@ -265,6 +266,8 @@ public synchronized int newBookmark(String bookmarkName) { bookmarkColors = new TreeMap(); bookmarkColors.put(bookmarkId, null); + unionAll = null;// invalidates unionAll + return bookmarkId; } @@ -279,6 +282,7 @@ public synchronized void delBookmark(int bookmark) { bookmarkColors.remove(bookmark); reportBookmarks.remove(bookmark); bookmarks.remove(bookmark); + unionAll = null;// invalidates unionAll } public synchronized void renameBookmark(int bookmarkId, String newBookmark) { diff --git a/iped-engine/src/main/java/iped/engine/data/MultiBitmapBookmarks.java b/iped-engine/src/main/java/iped/engine/data/MultiBitmapBookmarks.java index 49b064ce1a..409e2b05e9 100644 --- a/iped-engine/src/main/java/iped/engine/data/MultiBitmapBookmarks.java +++ b/iped-engine/src/main/java/iped/engine/data/MultiBitmapBookmarks.java @@ -185,6 +185,7 @@ public void removeBookmark(Set ids, String bookmarkName) { public void newBookmark(String bookmarkName) { for (IBookmarks m : map.values()) m.newBookmark(bookmarkName); + invalidadeCaches(); } public void delBookmark(String bookmarkName) { @@ -192,6 +193,7 @@ public void delBookmark(String bookmarkName) { int bookmarkId = m.getBookmarkId(bookmarkName); m.delBookmark(bookmarkId); } + invalidadeCaches(); } public void renameBookmark(String oldBookmark, String newBookmark) {