*) Bugfix: Prevent wordIndex.getContainer() from returning and even manipulating

the containers from the ram cache. Return a new container instead.
*) Speedup flushFromMem by reducing the number of searches in the TreeMap



git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1604 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
hermens 19 years ago
parent a1e1aa039c
commit 954f02d22e

@ -364,13 +364,12 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface {
plasmaWordIndexEntryContainer container = null; plasmaWordIndexEntryContainer container = null;
long time; long time;
synchronized (cache) { synchronized (cache) {
// get the container // get the container and remove it from cache
container = (plasmaWordIndexEntryContainer) this.cache.get(key); container = (plasmaWordIndexEntryContainer) this.cache.remove(key);
if (container == null) return 0; // flushing of nonexisting key if (container == null) return 0; // flushing of nonexisting key
time = getUpdateTime(key); time = container.updated();
// remove it from the cache // remove it from the MScoreClusters
cache.remove(key);
hashScore.deleteScore(key); hashScore.deleteScore(key);
hashDate.deleteScore(key); hashDate.deleteScore(key);
} }
@ -411,9 +410,15 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface {
plasmaWordIndexEntryContainer container; plasmaWordIndexEntryContainer container;
synchronized (cache) { synchronized (cache) {
container = new plasmaWordIndexEntryContainer(wordHash);
// get from cache // get from cache
container = (plasmaWordIndexEntryContainer) cache.get(wordHash); // We must not use the container from cache to store everything we find, as that
if (container == null) container = new plasmaWordIndexEntryContainer(wordHash); // container remains linked to in the cache and might be changed later while the
// returned container is still in use.
// e.g. indexTransfer might keep this container for minutes while several new pages
// could be added to the index, possibly with the same words that have been selected
// for transfer
container.add((plasmaWordIndexEntryContainer) cache.get(wordHash));
// get from assortments // get from assortments
container.add(assortmentCluster.getFromAll(wordHash, (maxTime < 0) ? -1 : maxTime / 2)); container.add(assortmentCluster.getFromAll(wordHash, (maxTime < 0) ? -1 : maxTime / 2));

Loading…
Cancel
Save