From 0b60b9bf51f61536ad6099d5a6172be0941f33b6 Mon Sep 17 00:00:00 2001 From: hermens Date: Tue, 14 Feb 2006 13:06:32 +0000 Subject: [PATCH] *) Remove entries from AssortmentCluster before reinserting the rest into the ramCache git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1640 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/plasma/plasmaWordIndex.java | 7 +++++-- source/de/anomic/plasma/plasmaWordIndexCache.java | 2 +- .../de/anomic/plasma/plasmaWordIndexEntryContainer.java | 9 ++++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.java index 6b3b26d6e..fd2795e54 100644 --- a/source/de/anomic/plasma/plasmaWordIndex.java +++ b/source/de/anomic/plasma/plasmaWordIndex.java @@ -335,8 +335,11 @@ public final class plasmaWordIndex { int removed = 0; removed += ramCache.removeEntries(wordHash, urlHashes, deleteComplete); plasmaWordIndexEntryContainer container = assortmentCluster.removeFromAll(wordHash, -1); - if (container != null) this.addEntries(container, System.currentTimeMillis(), false); - removed = backend.removeEntries(wordHash, urlHashes, deleteComplete); + if (container != null) { + removed += container.removeEntries(wordHash, urlHashes, deleteComplete); + if (container.size() != 0) this.addEntries(container, System.currentTimeMillis(), false); + } + removed += backend.removeEntries(wordHash, urlHashes, deleteComplete); return removed; } diff --git a/source/de/anomic/plasma/plasmaWordIndexCache.java b/source/de/anomic/plasma/plasmaWordIndexCache.java index 6fa44b4c4..36a09a475 100644 --- a/source/de/anomic/plasma/plasmaWordIndexCache.java +++ b/source/de/anomic/plasma/plasmaWordIndexCache.java @@ -309,7 +309,7 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface { synchronized (cache) { plasmaWordIndexEntryContainer c = (plasmaWordIndexEntryContainer) deleteContainer(wordHash); if (c != null) { - for (int i = 0; i < urlHashes.length; i++) count += (c.remove(urlHashes[i]) == null) ? 0 : 1; + count = c.removeEntries(wordHash, urlHashes, deleteComplete); if (c.size() != 0) this.addEntries(c, System.currentTimeMillis(), false); } } diff --git a/source/de/anomic/plasma/plasmaWordIndexEntryContainer.java b/source/de/anomic/plasma/plasmaWordIndexEntryContainer.java index 28a05e7a1..831e22d68 100644 --- a/source/de/anomic/plasma/plasmaWordIndexEntryContainer.java +++ b/source/de/anomic/plasma/plasmaWordIndexEntryContainer.java @@ -144,7 +144,14 @@ public final class plasmaWordIndexEntryContainer implements Comparable { public plasmaWordIndexEntry remove(String urlHash) { return (plasmaWordIndexEntry) container.remove(urlHash); } - + + public int removeEntries(String wordHash, String[] urlHashes, boolean deleteComplete) { + if (!wordHash.equals(this.wordHash)) return 0; + int count = 0; + for (int i = 0; i < urlHashes.length; i++) count += (remove(urlHashes[i]) == null) ? 0 : 1; + return count; + } + public Iterator entries() { // returns an iterator of plasmaWordIndexEntry objects return container.values().iterator();