|
|
|
@ -58,17 +58,32 @@ import java.net.URL;
|
|
|
|
|
|
|
|
|
|
import de.anomic.htmlFilter.htmlFilterContentScraper;
|
|
|
|
|
import de.anomic.kelondro.kelondroBase64Order;
|
|
|
|
|
import de.anomic.kelondro.kelondroException;
|
|
|
|
|
import de.anomic.kelondro.kelondroMergeIterator;
|
|
|
|
|
import de.anomic.kelondro.kelondroNaturalOrder;
|
|
|
|
|
import de.anomic.server.logging.serverLog;
|
|
|
|
|
|
|
|
|
|
public final class plasmaWordIndex {
|
|
|
|
|
|
|
|
|
|
private static final String indexAssortmentClusterPath = "ACLUSTER";
|
|
|
|
|
private static final int assortmentCount = 64;
|
|
|
|
|
|
|
|
|
|
private final File databaseRoot;
|
|
|
|
|
private final plasmaWordIndexCache ramCache;
|
|
|
|
|
private final plasmaWordIndexAssortmentCluster assortmentCluster;
|
|
|
|
|
private int assortmentBufferSize; //kb
|
|
|
|
|
private final plasmaWordIndexClassicDB backend;
|
|
|
|
|
|
|
|
|
|
public plasmaWordIndex(File databaseRoot, int bufferkb, serverLog log) {
|
|
|
|
|
this.databaseRoot = databaseRoot;
|
|
|
|
|
plasmaWordIndexClassicDB fileDB = new plasmaWordIndexClassicDB(databaseRoot, log);
|
|
|
|
|
this.ramCache = new plasmaWordIndexCache(databaseRoot, fileDB, bufferkb, log);
|
|
|
|
|
this.backend = new plasmaWordIndexClassicDB(databaseRoot, log);
|
|
|
|
|
this.ramCache = new plasmaWordIndexCache(databaseRoot, log);
|
|
|
|
|
|
|
|
|
|
// create new assortment cluster path
|
|
|
|
|
File assortmentClusterPath = new File(databaseRoot, indexAssortmentClusterPath);
|
|
|
|
|
if (!(assortmentClusterPath.exists())) assortmentClusterPath.mkdirs();
|
|
|
|
|
this.assortmentBufferSize = bufferkb;
|
|
|
|
|
this.assortmentCluster = new plasmaWordIndexAssortmentCluster(assortmentClusterPath, assortmentCount, assortmentBufferSize, log);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public File getRoot() {
|
|
|
|
@ -83,26 +98,59 @@ public final class plasmaWordIndex {
|
|
|
|
|
return ramCache.wordCacheRAMSize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int[] assortmentSizes() {
|
|
|
|
|
return ramCache.assortmentsSizes();
|
|
|
|
|
public int[] assortmentsSizes() {
|
|
|
|
|
return assortmentCluster.sizes();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int[] assortmentsCacheChunkSizeAvg() {
|
|
|
|
|
return ramCache.assortmentsCacheChunkSizeAvg();
|
|
|
|
|
return assortmentCluster.cacheChunkSizeAvg();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int[] assortmentsCacheFillStatusCml() {
|
|
|
|
|
return ramCache.assortmentsCacheFillStatusCml();
|
|
|
|
|
return assortmentCluster.cacheFillStatusCml();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setMaxWords(int maxWordsLow, int maxWordsHigh) {
|
|
|
|
|
ramCache.setMaxWords(maxWordsLow, maxWordsHigh);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int addEntries(plasmaWordIndexEntryContainer entries, boolean highPriority) {
|
|
|
|
|
return ramCache.addEntries(entries, System.currentTimeMillis(), highPriority);
|
|
|
|
|
public int addEntries(plasmaWordIndexEntryContainer entries, long updateTime, boolean highPriority) {
|
|
|
|
|
int added = ramCache.addEntries(entries, updateTime, highPriority);
|
|
|
|
|
|
|
|
|
|
// force flush
|
|
|
|
|
if (highPriority) {
|
|
|
|
|
if (ramCache.size() > ramCache.getMaxWordsHigh()) {
|
|
|
|
|
while (ramCache.size() + 500 > ramCache.getMaxWordsHigh()) {
|
|
|
|
|
try { Thread.sleep(10); } catch (InterruptedException e) { }
|
|
|
|
|
flushCacheToBackend(ramCache.bestFlushWordHash());
|
|
|
|
|
}}
|
|
|
|
|
} else {
|
|
|
|
|
if (ramCache.size() > ramCache.getMaxWordsLow()) {
|
|
|
|
|
while (ramCache.size() + 500 > ramCache.getMaxWordsLow()) {
|
|
|
|
|
try { Thread.sleep(10); } catch (InterruptedException e) { }
|
|
|
|
|
flushCacheToBackend(ramCache.bestFlushWordHash());
|
|
|
|
|
}}
|
|
|
|
|
}
|
|
|
|
|
return added;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void flushCacheToBackend(String wordHash) {
|
|
|
|
|
plasmaWordIndexEntryContainer c = ramCache.deleteContainer(wordHash);
|
|
|
|
|
plasmaWordIndexEntryContainer feedback = assortmentCluster.storeTry(wordHash, c);
|
|
|
|
|
if (feedback != null) {
|
|
|
|
|
backend.addEntries(feedback, System.currentTimeMillis(), true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int addEntriesBackend(plasmaWordIndexEntryContainer entries) {
|
|
|
|
|
plasmaWordIndexEntryContainer feedback = assortmentCluster.storeTry(entries.wordHash(), entries);
|
|
|
|
|
if (feedback == null) {
|
|
|
|
|
return entries.size();
|
|
|
|
|
} else {
|
|
|
|
|
return backend.addEntries(feedback, -1, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static final int hour = 3600000;
|
|
|
|
|
private static final int day = 86400000;
|
|
|
|
|
|
|
|
|
@ -171,25 +219,55 @@ public final class plasmaWordIndex {
|
|
|
|
|
language,
|
|
|
|
|
doctype,
|
|
|
|
|
true);
|
|
|
|
|
addEntries(plasmaWordIndexEntryContainer.instantContainer(wordHash, System.currentTimeMillis(), ientry), false);
|
|
|
|
|
addEntries(plasmaWordIndexEntryContainer.instantContainer(wordHash, System.currentTimeMillis(), ientry), System.currentTimeMillis(), false);
|
|
|
|
|
}
|
|
|
|
|
// System.out.println("DEBUG: plasmaSearch.addPageIndex: added " +
|
|
|
|
|
// condenser.getWords().size() + " words, flushed " + c + " entries");
|
|
|
|
|
return condenser.RESULT_SIMI_WORDS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int indexSize(String wordHash) {
|
|
|
|
|
return ramCache.indexSize(wordHash);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public plasmaWordIndexEntryContainer getContainer(String wordHash, boolean deleteIfEmpty, long maxTime) {
|
|
|
|
|
return ramCache.getContainer(wordHash, deleteIfEmpty, maxTime);
|
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
plasmaWordIndexEntryContainer container = new plasmaWordIndexEntryContainer(wordHash);
|
|
|
|
|
// get from cache
|
|
|
|
|
// 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(ramCache.getContainer(wordHash, true));
|
|
|
|
|
|
|
|
|
|
// get from assortments
|
|
|
|
|
container.add(assortmentCluster.getFromAll(wordHash, (maxTime < 0) ? -1 : maxTime / 2));
|
|
|
|
|
|
|
|
|
|
// get from backend
|
|
|
|
|
if (maxTime > 0) {
|
|
|
|
|
maxTime = maxTime - (System.currentTimeMillis() - start);
|
|
|
|
|
if (maxTime < 0)
|
|
|
|
|
maxTime = 100;
|
|
|
|
|
}
|
|
|
|
|
container.add(backend.getContainer(wordHash, deleteIfEmpty, (maxTime < 0) ? -1 : maxTime));
|
|
|
|
|
return container;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public plasmaWordIndexEntity getEntity(String wordHash, boolean deleteIfEmpty, long maxTime) {
|
|
|
|
|
return ramCache.getEntity(wordHash, deleteIfEmpty, maxTime);
|
|
|
|
|
// this possibly creates an index file in the back-end
|
|
|
|
|
// the index file is opened and returned as entity object
|
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
|
flushCacheToBackend(wordHash);
|
|
|
|
|
if (maxTime < 0) {
|
|
|
|
|
flushFromAssortmentCluster(wordHash, -1);
|
|
|
|
|
} else {
|
|
|
|
|
long remaining = maxTime - (System.currentTimeMillis() - start);
|
|
|
|
|
if (remaining > 0)
|
|
|
|
|
flushFromAssortmentCluster(wordHash, remaining);
|
|
|
|
|
}
|
|
|
|
|
long r = maxTime - (System.currentTimeMillis() - start);
|
|
|
|
|
return backend.getEntity(wordHash, deleteIfEmpty, (r < 0) ? 0 : r);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Set getContainers(Set wordHashes, boolean deleteIfEmpty, boolean interruptIfEmpty, long maxTime) {
|
|
|
|
|
|
|
|
|
|
// retrieve entities that belong to the hashes
|
|
|
|
@ -218,42 +296,23 @@ public final class plasmaWordIndex {
|
|
|
|
|
return containers;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
public Set getEntities(Set wordHashes, boolean deleteIfEmpty, boolean interruptIfEmpty, long maxTime) {
|
|
|
|
|
|
|
|
|
|
// retrieve entities that belong to the hashes
|
|
|
|
|
HashSet entities = new HashSet();
|
|
|
|
|
String singleHash;
|
|
|
|
|
plasmaWordIndexEntity singleEntity;
|
|
|
|
|
Iterator i = wordHashes.iterator();
|
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
|
long remaining;
|
|
|
|
|
while (i.hasNext()) {
|
|
|
|
|
// check time
|
|
|
|
|
remaining = maxTime - (System.currentTimeMillis() - start);
|
|
|
|
|
//if ((maxTime > 0) && (remaining <= 0)) break;
|
|
|
|
|
|
|
|
|
|
// get next hash:
|
|
|
|
|
singleHash = (String) i.next();
|
|
|
|
|
|
|
|
|
|
// retrieve index
|
|
|
|
|
singleEntity = getEntity(singleHash, deleteIfEmpty, (maxTime < 0) ? -1 : remaining / (wordHashes.size() - entities.size()));
|
|
|
|
|
|
|
|
|
|
// check result
|
|
|
|
|
if (((singleEntity == null) || (singleEntity.size() == 0)) && (interruptIfEmpty)) return new HashSet();
|
|
|
|
|
|
|
|
|
|
entities.add(singleEntity);
|
|
|
|
|
}
|
|
|
|
|
return entities;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public int size() {
|
|
|
|
|
return ramCache.size();
|
|
|
|
|
return java.lang.Math.max(assortmentCluster.sizeTotal(),
|
|
|
|
|
java.lang.Math.max(backend.size(), ramCache.size()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int removeEntries(String wordHash, String[] urlHashes, boolean deleteComplete) {
|
|
|
|
|
return ramCache.removeEntries(wordHash, urlHashes, deleteComplete);
|
|
|
|
|
public int indexSize(String wordHash) {
|
|
|
|
|
int size = 0;
|
|
|
|
|
try {
|
|
|
|
|
plasmaWordIndexEntity entity = backend.getEntity(wordHash, true, -1);
|
|
|
|
|
if (entity != null) {
|
|
|
|
|
size += entity.size();
|
|
|
|
|
entity.close();
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {}
|
|
|
|
|
size += assortmentCluster.indexSize(wordHash);
|
|
|
|
|
size += ramCache.indexSize(wordHash);
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void intermission(long pause) {
|
|
|
|
@ -262,28 +321,85 @@ public final class plasmaWordIndex {
|
|
|
|
|
|
|
|
|
|
public void close(int waitingBoundSeconds) {
|
|
|
|
|
ramCache.close(waitingBoundSeconds);
|
|
|
|
|
assortmentCluster.close();
|
|
|
|
|
backend.close(10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void deleteIndex(String wordHash) {
|
|
|
|
|
ramCache.deleteIndex(wordHash);
|
|
|
|
|
ramCache.deleteContainer(wordHash);
|
|
|
|
|
assortmentCluster.removeFromAll(wordHash, -1);
|
|
|
|
|
backend.deleteIndex(wordHash);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public synchronized int removeEntries(String wordHash, String[] urlHashes, boolean deleteComplete) {
|
|
|
|
|
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);
|
|
|
|
|
return removed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean flushFromAssortmentCluster(String key, long maxTime) {
|
|
|
|
|
// this should only be called if the assortment shall be deleted or returned in an index entity
|
|
|
|
|
if (maxTime > 0) maxTime = 8 * maxTime / 10; // reserve time for later adding to backend
|
|
|
|
|
plasmaWordIndexEntryContainer container = assortmentCluster.removeFromAll(key, maxTime);
|
|
|
|
|
if (container == null) {
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
// we have a non-empty entry-container
|
|
|
|
|
// integrate it to the backend
|
|
|
|
|
return backend.addEntries(container, container.updated(), true) > 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static final int RL_RAMCACHE = 0;
|
|
|
|
|
public static final int RL_FILECACHE = 1;
|
|
|
|
|
public static final int RL_ASSORTMENTS = 2;
|
|
|
|
|
public static final int RL_WORDFILES = 3;
|
|
|
|
|
|
|
|
|
|
public Iterator wordHashes(String startHash, int resourceLevel, boolean up, boolean rot) {
|
|
|
|
|
if (rot) return new rotatingWordIterator(startHash, resourceLevel, up);
|
|
|
|
|
else return new correctedWordIterator(startHash, resourceLevel, up, rot); // use correction until bug is found
|
|
|
|
|
public Iterator wordHashes(String startHash, int resourceLevel, boolean rot) {
|
|
|
|
|
if (rot) return new rotatingWordIterator(startHash, resourceLevel);
|
|
|
|
|
else return new correctedWordIterator(startHash, resourceLevel, rot); // use correction until bug is found
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Iterator wordHashesX(String startWordHash, int resourceLevel, boolean rot) {
|
|
|
|
|
if (resourceLevel == plasmaWordIndex.RL_RAMCACHE) {
|
|
|
|
|
return ramCache.wordHashes(startWordHash, rot);
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
if (resourceLevel == plasmaWordIndex.RL_FILECACHE) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
if (resourceLevel == plasmaWordIndex.RL_ASSORTMENTS) {
|
|
|
|
|
return new kelondroMergeIterator(
|
|
|
|
|
ramCache.wordHashes(startWordHash, rot),
|
|
|
|
|
assortmentCluster.hashConjunction(startWordHash, true, rot),
|
|
|
|
|
kelondroNaturalOrder.naturalOrder,
|
|
|
|
|
true);
|
|
|
|
|
}
|
|
|
|
|
if (resourceLevel == plasmaWordIndex.RL_WORDFILES) {
|
|
|
|
|
return new kelondroMergeIterator(
|
|
|
|
|
new kelondroMergeIterator(
|
|
|
|
|
ramCache.wordHashes(startWordHash, rot),
|
|
|
|
|
assortmentCluster.hashConjunction(startWordHash, true, rot),
|
|
|
|
|
kelondroNaturalOrder.naturalOrder,
|
|
|
|
|
true),
|
|
|
|
|
backend.wordHashes(startWordHash, true, false),
|
|
|
|
|
kelondroNaturalOrder.naturalOrder,
|
|
|
|
|
true);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final class correctedWordIterator implements Iterator {
|
|
|
|
|
Iterator iter;
|
|
|
|
|
String nextWord;
|
|
|
|
|
|
|
|
|
|
public correctedWordIterator(String firstWord, int resourceLevel, boolean up, boolean rotating) {
|
|
|
|
|
iter = ramCache.wordHashes(firstWord, resourceLevel, up, rotating);
|
|
|
|
|
public correctedWordIterator(String firstWord, int resourceLevel, boolean rotating) {
|
|
|
|
|
iter = wordHashesX(firstWord, resourceLevel, rotating);
|
|
|
|
|
try {
|
|
|
|
|
nextWord = (iter.hasNext()) ? (String) iter.next() : null;
|
|
|
|
|
boolean corrected = true;
|
|
|
|
@ -291,18 +407,13 @@ public final class plasmaWordIndex {
|
|
|
|
|
while ((nextWord != null) && (corrected) && (cc < 50)) {
|
|
|
|
|
int c = firstWord.compareTo(nextWord);
|
|
|
|
|
corrected = false;
|
|
|
|
|
if ((c > 0) && (up)) {
|
|
|
|
|
if (c > 0) {
|
|
|
|
|
// firstKey > nextNode.getKey()
|
|
|
|
|
//System.out.println("CORRECTING WORD ITERATOR: firstWord=" + firstWord + ", nextWord=" + nextWord);
|
|
|
|
|
nextWord = (iter.hasNext()) ? (String) iter.next() : null;
|
|
|
|
|
corrected = true;
|
|
|
|
|
cc++;
|
|
|
|
|
}
|
|
|
|
|
if ((c < 0) && (!(up))) {
|
|
|
|
|
nextWord = (iter.hasNext()) ? (String) iter.next() : null;
|
|
|
|
|
corrected = true;
|
|
|
|
|
cc++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (java.util.ConcurrentModificationException e) {
|
|
|
|
|
nextWord = null;
|
|
|
|
@ -336,12 +447,10 @@ public final class plasmaWordIndex {
|
|
|
|
|
private class rotatingWordIterator implements Iterator {
|
|
|
|
|
Iterator i;
|
|
|
|
|
int resourceLevel;
|
|
|
|
|
boolean up;
|
|
|
|
|
|
|
|
|
|
public rotatingWordIterator(String startWordHash, int resourceLevel, boolean up) {
|
|
|
|
|
this.up = up;
|
|
|
|
|
public rotatingWordIterator(String startWordHash, int resourceLevel) {
|
|
|
|
|
this.resourceLevel = resourceLevel;
|
|
|
|
|
i = new correctedWordIterator(startWordHash, resourceLevel, up, false);
|
|
|
|
|
i = new correctedWordIterator(startWordHash, resourceLevel, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void finalize() {
|
|
|
|
@ -351,7 +460,7 @@ public final class plasmaWordIndex {
|
|
|
|
|
public boolean hasNext() {
|
|
|
|
|
if (i.hasNext()) return true;
|
|
|
|
|
else {
|
|
|
|
|
i = new correctedWordIterator((up)?"------------":"zzzzzzzzzzzz", resourceLevel, up, false);
|
|
|
|
|
i = new correctedWordIterator("------------", resourceLevel, false);
|
|
|
|
|
return i.hasNext();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -365,9 +474,6 @@ public final class plasmaWordIndex {
|
|
|
|
|
}
|
|
|
|
|
} // class rotatingWordIterator
|
|
|
|
|
|
|
|
|
|
public Object migrateWords2Assortment(String wordHash) throws IOException {
|
|
|
|
|
return ramCache.migrateWords2Assortment(wordHash);
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
public Iterator fileIterator(String startHash, boolean up, boolean deleteEmpty) {
|
|
|
|
|
return new iterateFiles(startHash, up, deleteEmpty);
|
|
|
|
@ -481,12 +587,65 @@ public final class plasmaWordIndex {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Object migrateWords2Assortment(String wordhash) throws IOException {
|
|
|
|
|
// returns the number of entries that had been added to the assortments
|
|
|
|
|
// can be negative if some assortments have been moved to the backend
|
|
|
|
|
File db = plasmaWordIndexEntity.wordHash2path(databaseRoot, wordhash);
|
|
|
|
|
if (!(db.exists())) return "not available";
|
|
|
|
|
plasmaWordIndexEntity entity = null;
|
|
|
|
|
try {
|
|
|
|
|
entity = new plasmaWordIndexEntity(databaseRoot, wordhash, true);
|
|
|
|
|
int size = entity.size();
|
|
|
|
|
if (size > assortmentCluster.clusterCapacity) {
|
|
|
|
|
// this will be too big to integrate it
|
|
|
|
|
entity.close(); entity = null;
|
|
|
|
|
return "too big";
|
|
|
|
|
} else {
|
|
|
|
|
// take out all words from the assortment to see if it fits
|
|
|
|
|
// together with the extracted assortment
|
|
|
|
|
plasmaWordIndexEntryContainer container = assortmentCluster.removeFromAll(wordhash, -1);
|
|
|
|
|
if (size + container.size() > assortmentCluster.clusterCapacity) {
|
|
|
|
|
// this will also be too big to integrate, add to entity
|
|
|
|
|
entity.addEntries(container);
|
|
|
|
|
entity.close(); entity = null;
|
|
|
|
|
return new Integer(-container.size());
|
|
|
|
|
} else {
|
|
|
|
|
// the combined container will fit, read the container
|
|
|
|
|
try {
|
|
|
|
|
Iterator entries = entity.elements(true);
|
|
|
|
|
plasmaWordIndexEntry entry;
|
|
|
|
|
while (entries.hasNext()) {
|
|
|
|
|
entry = (plasmaWordIndexEntry) entries.next();
|
|
|
|
|
// System.out.println("ENTRY = " + entry.getUrlHash());
|
|
|
|
|
container.add(new plasmaWordIndexEntry[]{entry}, System.currentTimeMillis());
|
|
|
|
|
}
|
|
|
|
|
// we have read all elements, now delete the entity
|
|
|
|
|
entity.deleteComplete();
|
|
|
|
|
entity.close(); entity = null;
|
|
|
|
|
// integrate the container into the assortments; this will work
|
|
|
|
|
assortmentCluster.storeTry(wordhash, container);
|
|
|
|
|
return new Integer(size);
|
|
|
|
|
} catch (kelondroException e) {
|
|
|
|
|
// database corrupted, we simply give up the database and delete it
|
|
|
|
|
try {entity.close();} catch (Exception ee) {} entity = null;
|
|
|
|
|
try {db.delete();} catch (Exception ee) {}
|
|
|
|
|
return "database corrupted; deleted";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
if (entity != null) try {entity.close();}catch(Exception e){}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
// System.out.println(kelondroMSetTools.fastStringComparator(true).compare("RwGeoUdyDQ0Y", "rwGeoUdyDQ0Y"));
|
|
|
|
|
// System.out.println(new Date(reverseMicroDateDays(microDateDays(System.currentTimeMillis()))));
|
|
|
|
|
|
|
|
|
|
plasmaWordIndex index = new plasmaWordIndex(new File("D:\\dev\\proxy\\DATA\\PLASMADB"), 555, new serverLog("TESTAPP"));
|
|
|
|
|
Iterator iter = index.wordHashes("5A8yhZMh_Kmv", plasmaWordIndex.RL_WORDFILES, true, true);
|
|
|
|
|
Iterator iter = index.wordHashes("5A8yhZMh_Kmv", plasmaWordIndex.RL_WORDFILES, true);
|
|
|
|
|
while (iter.hasNext()) {
|
|
|
|
|
System.out.println("File: " + (String) iter.next());
|
|
|
|
|
}
|
|
|
|
|