|
|
|
@ -200,9 +200,9 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void flushCacheSome() {
|
|
|
|
|
int flushCount = ramCache.wSize() / 500;
|
|
|
|
|
int flushCount = ramCache.wSize() / 350;
|
|
|
|
|
if (flushCount > 80) flushCount = 80;
|
|
|
|
|
if (flushCount < 10) flushCount = Math.min(10, ramCache.wSize());
|
|
|
|
|
if (flushCount < 20) flushCount = Math.min(20, ramCache.wSize());
|
|
|
|
|
flushCache(flushCount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -321,6 +321,7 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
|
public indexContainer getContainer(String wordHash, boolean deleteIfEmpty, long maxTime) {
|
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
synchronized (ramCache) {
|
|
|
|
|
// get from cache
|
|
|
|
|
indexContainer container = ramCache.getContainer(wordHash, true, -1);
|
|
|
|
|
|
|
|
|
@ -355,6 +356,7 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
|
container.add(backend.getContainer(wordHash, deleteIfEmpty, (maxTime < 0) ? -1 : maxTime), -1);
|
|
|
|
|
return container;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Set getContainers(Set wordHashes, boolean deleteIfEmpty, boolean interruptIfEmpty, long maxTime) {
|
|
|
|
|
|
|
|
|
@ -362,6 +364,7 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
|
HashSet containers = new HashSet();
|
|
|
|
|
String singleHash;
|
|
|
|
|
indexContainer singleContainer;
|
|
|
|
|
synchronized (ramCache) {
|
|
|
|
|
Iterator i = wordHashes.iterator();
|
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
|
long remaining;
|
|
|
|
@ -382,10 +385,12 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
|
|
|
|
|
|
containers.add(singleContainer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return containers;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int size() {
|
|
|
|
|
synchronized (ramCache) {
|
|
|
|
|
if (useCollectionIndex)
|
|
|
|
|
return java.lang.Math.max(collections.size(),
|
|
|
|
|
java.lang.Math.max(assortmentCluster.size(),
|
|
|
|
@ -394,9 +399,11 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
|
return java.lang.Math.max(assortmentCluster.size(),
|
|
|
|
|
java.lang.Math.max(backend.size(), ramCache.size()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int indexSize(String wordHash) {
|
|
|
|
|
int size = 0;
|
|
|
|
|
synchronized (ramCache) {
|
|
|
|
|
try {
|
|
|
|
|
plasmaWordIndexFile entity = backend.getEntity(wordHash, true, -1);
|
|
|
|
|
if (entity != null) {
|
|
|
|
@ -407,15 +414,18 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
|
if (useCollectionIndex) size += collections.indexSize(wordHash);
|
|
|
|
|
size += assortmentCluster.indexSize(wordHash);
|
|
|
|
|
size += ramCache.indexSize(wordHash);
|
|
|
|
|
}
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public synchronized void close(int waitingBoundSeconds) {
|
|
|
|
|
synchronized (ramCache) {
|
|
|
|
|
ramCache.close(waitingBoundSeconds);
|
|
|
|
|
if (useCollectionIndex) collections.close(-1);
|
|
|
|
|
assortmentCluster.close(-1);
|
|
|
|
|
backend.close(10);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public synchronized indexContainer deleteContainer(String wordHash) {
|
|
|
|
|
synchronized (ramCache) {
|
|
|
|
@ -458,8 +468,10 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
|
// urlHash assigned. This can only work if the entry is really fresh
|
|
|
|
|
// and can be found in the RAM cache
|
|
|
|
|
// this returns the number of deletion that had been possible
|
|
|
|
|
synchronized (ramCache) {
|
|
|
|
|
return ramCache.tryRemoveURLs(urlHash);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static final int RL_RAMCACHE = 0;
|
|
|
|
|
public static final int RL_COLLECTIONS = 1; // the new index structure
|
|
|
|
@ -472,6 +484,7 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
|
kelondroOrder containerOrder = new indexContainerOrder((kelondroOrder) indexOrder.clone());
|
|
|
|
|
containerOrder.rotate(startHash.getBytes());
|
|
|
|
|
TreeSet containers = new TreeSet(containerOrder);
|
|
|
|
|
synchronized (ramCache) {
|
|
|
|
|
Iterator i = wordContainers(startHash, resourceLevel, rot);
|
|
|
|
|
if (resourceLevel == plasmaWordIndex.RL_RAMCACHE) count = Math.min(ramCache.wSize(), count);
|
|
|
|
|
indexContainer container;
|
|
|
|
@ -482,6 +495,7 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
|
|
|
|
|
count--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return containers;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|