Skip to content

Commit

Permalink
*) Bugfix: Prevent wordIndex.getContainer() from returning and even m…
Browse files Browse the repository at this point in the history
…anipulating

   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
  • Loading branch information
hermens committed Feb 11, 2006
1 parent a1e1aa0 commit 954f02d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions source/de/anomic/plasma/plasmaWordIndexCache.java
Expand Up @@ -364,13 +364,12 @@ private int flushFromMem(String key) {
plasmaWordIndexEntryContainer container = null;
long time;
synchronized (cache) {
// get the container
container = (plasmaWordIndexEntryContainer) this.cache.get(key);
// get the container and remove it from cache
container = (plasmaWordIndexEntryContainer) this.cache.remove(key);
if (container == null) return 0; // flushing of nonexisting key
time = getUpdateTime(key);
time = container.updated();

// remove it from the cache
cache.remove(key);
// remove it from the MScoreClusters
hashScore.deleteScore(key);
hashDate.deleteScore(key);
}
Expand Down Expand Up @@ -411,9 +410,15 @@ public plasmaWordIndexEntryContainer getContainer(String wordHash, boolean delet

plasmaWordIndexEntryContainer container;
synchronized (cache) {
container = new plasmaWordIndexEntryContainer(wordHash);
// get from cache
container = (plasmaWordIndexEntryContainer) cache.get(wordHash);
if (container == null) container = new plasmaWordIndexEntryContainer(wordHash);
// We must not use the container from cache to store everything we find, as that
// 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
container.add(assortmentCluster.getFromAll(wordHash, (maxTime < 0) ? -1 : maxTime / 2));
Expand Down

0 comments on commit 954f02d

Please sign in to comment.