|
|
@ -182,22 +182,18 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
|
|
|
|
|
|
|
|
public indexContainer addEntry(String wordHash, indexEntry entry, long updateTime, boolean dhtCase) {
|
|
|
|
public indexContainer addEntry(String wordHash, indexEntry entry, long updateTime, boolean dhtCase) {
|
|
|
|
indexContainer c;
|
|
|
|
indexContainer c;
|
|
|
|
synchronized (ramCache) {
|
|
|
|
|
|
|
|
if ((c = ramCache.addEntry(wordHash, entry, updateTime, dhtCase)) == null) {
|
|
|
|
if ((c = ramCache.addEntry(wordHash, entry, updateTime, dhtCase)) == null) {
|
|
|
|
if (!dhtCase) flushControl();
|
|
|
|
if (!dhtCase) flushControl();
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return c;
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public indexContainer addEntries(indexContainer entries, long updateTime, boolean dhtCase) {
|
|
|
|
public indexContainer addEntries(indexContainer entries, long updateTime, boolean dhtCase) {
|
|
|
|
synchronized (ramCache) {
|
|
|
|
|
|
|
|
indexContainer added = ramCache.addEntries(entries, updateTime, dhtCase);
|
|
|
|
indexContainer added = ramCache.addEntries(entries, updateTime, dhtCase);
|
|
|
|
// force flush
|
|
|
|
// force flush
|
|
|
|
if (!dhtCase) flushControl();
|
|
|
|
if (!dhtCase) flushControl();
|
|
|
|
return added;
|
|
|
|
return added;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void flushCacheSome() {
|
|
|
|
public void flushCacheSome() {
|
|
|
@ -322,7 +318,6 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
public indexContainer getContainer(String wordHash, boolean deleteIfEmpty, long maxTime) {
|
|
|
|
public indexContainer getContainer(String wordHash, boolean deleteIfEmpty, long maxTime) {
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
|
|
synchronized (ramCache) {
|
|
|
|
|
|
|
|
// get from cache
|
|
|
|
// get from cache
|
|
|
|
indexContainer container = ramCache.getContainer(wordHash, true, -1);
|
|
|
|
indexContainer container = ramCache.getContainer(wordHash, true, -1);
|
|
|
|
|
|
|
|
|
|
|
@ -356,7 +351,6 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
container.add(backend.getContainer(wordHash, deleteIfEmpty, (maxTime < 0) ? -1 : maxTime), -1);
|
|
|
|
container.add(backend.getContainer(wordHash, deleteIfEmpty, (maxTime < 0) ? -1 : maxTime), -1);
|
|
|
|
return container;
|
|
|
|
return container;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Set getContainers(Set wordHashes, boolean deleteIfEmpty, boolean interruptIfEmpty, long maxTime) {
|
|
|
|
public Set getContainers(Set wordHashes, boolean deleteIfEmpty, boolean interruptIfEmpty, long maxTime) {
|
|
|
@ -365,7 +359,6 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
HashSet containers = new HashSet();
|
|
|
|
HashSet containers = new HashSet();
|
|
|
|
String singleHash;
|
|
|
|
String singleHash;
|
|
|
|
indexContainer singleContainer;
|
|
|
|
indexContainer singleContainer;
|
|
|
|
synchronized (ramCache) {
|
|
|
|
|
|
|
|
Iterator i = wordHashes.iterator();
|
|
|
|
Iterator i = wordHashes.iterator();
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
long remaining;
|
|
|
|
long remaining;
|
|
|
@ -386,7 +379,6 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
|
|
|
|
|
|
|
|
containers.add(singleContainer);
|
|
|
|
containers.add(singleContainer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return containers;
|
|
|
|
return containers;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -425,28 +417,23 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public indexContainer deleteContainer(String wordHash) {
|
|
|
|
public indexContainer deleteContainer(String wordHash) {
|
|
|
|
synchronized (ramCache) {
|
|
|
|
|
|
|
|
indexContainer c = ramCache.deleteContainer(wordHash);
|
|
|
|
indexContainer c = ramCache.deleteContainer(wordHash);
|
|
|
|
if (c == null) c = new indexRowSetContainer(wordHash);
|
|
|
|
if (c == null) c = new indexRowSetContainer(wordHash);
|
|
|
|
if (useCollectionIndex) c.add(collections.deleteContainer(wordHash), -1);
|
|
|
|
if (useCollectionIndex) c.add(collections.deleteContainer(wordHash), -1);
|
|
|
|
c.add(assortmentCluster.deleteContainer(wordHash), -1);
|
|
|
|
c.add(assortmentCluster.deleteContainer(wordHash), -1);
|
|
|
|
c.add(backend.deleteContainer(wordHash), -1);
|
|
|
|
c.add(backend.deleteContainer(wordHash), -1);
|
|
|
|
return c;
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean removeEntry(String wordHash, String urlHash, boolean deleteComplete) {
|
|
|
|
public boolean removeEntry(String wordHash, String urlHash, boolean deleteComplete) {
|
|
|
|
synchronized (ramCache) {
|
|
|
|
|
|
|
|
if (ramCache.removeEntry(wordHash, urlHash, deleteComplete)) return true;
|
|
|
|
if (ramCache.removeEntry(wordHash, urlHash, deleteComplete)) return true;
|
|
|
|
if (useCollectionIndex) {if (collections.removeEntry(wordHash, urlHash, deleteComplete)) return true;}
|
|
|
|
if (useCollectionIndex) {if (collections.removeEntry(wordHash, urlHash, deleteComplete)) return true;}
|
|
|
|
if (assortmentCluster.removeEntry(wordHash, urlHash, deleteComplete)) return true;
|
|
|
|
if (assortmentCluster.removeEntry(wordHash, urlHash, deleteComplete)) return true;
|
|
|
|
return backend.removeEntry(wordHash, urlHash, deleteComplete);
|
|
|
|
return backend.removeEntry(wordHash, urlHash, deleteComplete);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int removeEntries(String wordHash, Set urlHashes, boolean deleteComplete) {
|
|
|
|
public int removeEntries(String wordHash, Set urlHashes, boolean deleteComplete) {
|
|
|
|
int removed = 0;
|
|
|
|
int removed = 0;
|
|
|
|
synchronized (ramCache) {
|
|
|
|
|
|
|
|
removed += ramCache.removeEntries(wordHash, urlHashes, deleteComplete);
|
|
|
|
removed += ramCache.removeEntries(wordHash, urlHashes, deleteComplete);
|
|
|
|
if (removed == urlHashes.size()) return removed;
|
|
|
|
if (removed == urlHashes.size()) return removed;
|
|
|
|
if (useCollectionIndex) {
|
|
|
|
if (useCollectionIndex) {
|
|
|
@ -456,7 +443,6 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
removed += assortmentCluster.removeEntries(wordHash, urlHashes, deleteComplete);
|
|
|
|
removed += assortmentCluster.removeEntries(wordHash, urlHashes, deleteComplete);
|
|
|
|
if (removed == urlHashes.size()) return removed;
|
|
|
|
if (removed == urlHashes.size()) return removed;
|
|
|
|
removed += backend.removeEntries(wordHash, urlHashes, deleteComplete);
|
|
|
|
removed += backend.removeEntries(wordHash, urlHashes, deleteComplete);
|
|
|
|
}
|
|
|
|
|
|
|
|
return removed;
|
|
|
|
return removed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -465,9 +451,7 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
// urlHash assigned. This can only work if the entry is really fresh
|
|
|
|
// urlHash assigned. This can only work if the entry is really fresh
|
|
|
|
// and can be found in the RAM cache
|
|
|
|
// and can be found in the RAM cache
|
|
|
|
// this returns the number of deletion that had been possible
|
|
|
|
// this returns the number of deletion that had been possible
|
|
|
|
synchronized (ramCache) {
|
|
|
|
|
|
|
|
return ramCache.tryRemoveURLs(urlHash);
|
|
|
|
return ramCache.tryRemoveURLs(urlHash);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static final int RL_RAMCACHE = 0;
|
|
|
|
public static final int RL_RAMCACHE = 0;
|
|
|
@ -481,7 +465,6 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
kelondroOrder containerOrder = new indexContainerOrder((kelondroOrder) indexOrder.clone());
|
|
|
|
kelondroOrder containerOrder = new indexContainerOrder((kelondroOrder) indexOrder.clone());
|
|
|
|
containerOrder.rotate(startHash.getBytes());
|
|
|
|
containerOrder.rotate(startHash.getBytes());
|
|
|
|
TreeSet containers = new TreeSet(containerOrder);
|
|
|
|
TreeSet containers = new TreeSet(containerOrder);
|
|
|
|
synchronized (ramCache) {
|
|
|
|
|
|
|
|
Iterator i = wordContainers(startHash, resourceLevel, rot);
|
|
|
|
Iterator i = wordContainers(startHash, resourceLevel, rot);
|
|
|
|
if (resourceLevel == plasmaWordIndex.RL_RAMCACHE) count = Math.min(ramCache.wSize(), count);
|
|
|
|
if (resourceLevel == plasmaWordIndex.RL_RAMCACHE) count = Math.min(ramCache.wSize(), count);
|
|
|
|
indexContainer container;
|
|
|
|
indexContainer container;
|
|
|
@ -492,7 +475,6 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
count--;
|
|
|
|
count--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return containers;
|
|
|
|
return containers;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|