|
|
@ -38,7 +38,6 @@ import de.anomic.kelondro.kelondroFixedWidthArray;
|
|
|
|
import de.anomic.kelondro.kelondroMScoreCluster;
|
|
|
|
import de.anomic.kelondro.kelondroMScoreCluster;
|
|
|
|
import de.anomic.kelondro.kelondroNaturalOrder;
|
|
|
|
import de.anomic.kelondro.kelondroNaturalOrder;
|
|
|
|
import de.anomic.kelondro.kelondroRow;
|
|
|
|
import de.anomic.kelondro.kelondroRow;
|
|
|
|
import de.anomic.plasma.plasmaWordIndexAssortment;
|
|
|
|
|
|
|
|
import de.anomic.server.logging.serverLog;
|
|
|
|
import de.anomic.server.logging.serverLog;
|
|
|
|
import de.anomic.yacy.yacySeedDB;
|
|
|
|
import de.anomic.yacy.yacySeedDB;
|
|
|
|
|
|
|
|
|
|
|
@ -46,6 +45,11 @@ public final class indexRAMCacheRI implements indexRI {
|
|
|
|
|
|
|
|
|
|
|
|
// environment constants
|
|
|
|
// environment constants
|
|
|
|
public static final long wCacheMaxAge = 1000 * 60 * 30; // milliseconds; 30 minutes
|
|
|
|
public static final long wCacheMaxAge = 1000 * 60 * 30; // milliseconds; 30 minutes
|
|
|
|
|
|
|
|
public static final kelondroRow bufferStructureBasis = new kelondroRow(
|
|
|
|
|
|
|
|
"byte[] wordhash-" + indexEntryAttribute.wordHashLength + ", " +
|
|
|
|
|
|
|
|
"Cardinal occ-4 {b256}, " +
|
|
|
|
|
|
|
|
"Cardinal time-8 {b256}, " +
|
|
|
|
|
|
|
|
"byte[] urlprops-" + indexURLEntry.urlEntryRow.objectsize());
|
|
|
|
|
|
|
|
|
|
|
|
// class variables
|
|
|
|
// class variables
|
|
|
|
private final File databaseRoot;
|
|
|
|
private final File databaseRoot;
|
|
|
@ -98,7 +102,7 @@ public final class indexRAMCacheRI implements indexRI {
|
|
|
|
File indexDumpFile = new File(databaseRoot, indexArrayFileName);
|
|
|
|
File indexDumpFile = new File(databaseRoot, indexArrayFileName);
|
|
|
|
if (indexDumpFile.exists()) indexDumpFile.delete();
|
|
|
|
if (indexDumpFile.exists()) indexDumpFile.delete();
|
|
|
|
kelondroFixedWidthArray dumpArray = null;
|
|
|
|
kelondroFixedWidthArray dumpArray = null;
|
|
|
|
dumpArray = new kelondroFixedWidthArray(indexDumpFile, plasmaWordIndexAssortment.bufferStructureBasis, 0);
|
|
|
|
dumpArray = new kelondroFixedWidthArray(indexDumpFile, bufferStructureBasis, 0);
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
long messageTime = System.currentTimeMillis() + 5000;
|
|
|
|
long messageTime = System.currentTimeMillis() + 5000;
|
|
|
|
long wordsPerSecond = 0, wordcount = 0, urlcount = 0;
|
|
|
|
long wordsPerSecond = 0, wordcount = 0, urlcount = 0;
|
|
|
@ -127,8 +131,7 @@ public final class indexRAMCacheRI implements indexRI {
|
|
|
|
row.setCol(0, wordHash.getBytes());
|
|
|
|
row.setCol(0, wordHash.getBytes());
|
|
|
|
row.setCol(1, kelondroNaturalOrder.encodeLong(container.size(), 4));
|
|
|
|
row.setCol(1, kelondroNaturalOrder.encodeLong(container.size(), 4));
|
|
|
|
row.setCol(2, kelondroNaturalOrder.encodeLong(updateTime, 8));
|
|
|
|
row.setCol(2, kelondroNaturalOrder.encodeLong(updateTime, 8));
|
|
|
|
row.setCol(3, iEntry.urlHash().getBytes());
|
|
|
|
row.setCol(3, iEntry.toKelondroEntry().bytes());
|
|
|
|
row.setCol(4, iEntry.toEncodedByteArrayForm(false));
|
|
|
|
|
|
|
|
dumpArray.set((int) urlcount++, row);
|
|
|
|
dumpArray.set((int) urlcount++, row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -152,7 +155,7 @@ public final class indexRAMCacheRI implements indexRI {
|
|
|
|
private long restore() throws IOException {
|
|
|
|
private long restore() throws IOException {
|
|
|
|
File indexDumpFile = new File(databaseRoot, indexArrayFileName);
|
|
|
|
File indexDumpFile = new File(databaseRoot, indexArrayFileName);
|
|
|
|
if (!(indexDumpFile.exists())) return 0;
|
|
|
|
if (!(indexDumpFile.exists())) return 0;
|
|
|
|
kelondroFixedWidthArray dumpArray = new kelondroFixedWidthArray(indexDumpFile, plasmaWordIndexAssortment.bufferStructureBasis, 0);
|
|
|
|
kelondroFixedWidthArray dumpArray = new kelondroFixedWidthArray(indexDumpFile, bufferStructureBasis, 0);
|
|
|
|
log.logConfig("restore array dump of index cache '" + indexArrayFileName + "', " + dumpArray.size() + " word/URL relations");
|
|
|
|
log.logConfig("restore array dump of index cache '" + indexArrayFileName + "', " + dumpArray.size() + " word/URL relations");
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
long messageTime = System.currentTimeMillis() + 5000;
|
|
|
|
long messageTime = System.currentTimeMillis() + 5000;
|
|
|
@ -168,10 +171,10 @@ public final class indexRAMCacheRI implements indexRI {
|
|
|
|
while (i.hasNext()) {
|
|
|
|
while (i.hasNext()) {
|
|
|
|
// get out one entry
|
|
|
|
// get out one entry
|
|
|
|
row = (kelondroRow.Entry) i.next();
|
|
|
|
row = (kelondroRow.Entry) i.next();
|
|
|
|
if ((row == null) || (row.empty(0)) || (row.empty(3)) || (row.empty(4))) continue;
|
|
|
|
if ((row == null) || (row.empty(0)) || (row.empty(3))) continue;
|
|
|
|
wordHash = row.getColString(0, "UTF-8");
|
|
|
|
wordHash = row.getColString(0, "UTF-8");
|
|
|
|
//creationTime = kelondroRecords.bytes2long(row[2]);
|
|
|
|
//creationTime = kelondroRecords.bytes2long(row[2]);
|
|
|
|
wordEntry = new indexURLEntry(row.getColString(3, null), row.getColString(4, null));
|
|
|
|
wordEntry = new indexURLEntry(row.getColBytes(3));
|
|
|
|
// store to cache
|
|
|
|
// store to cache
|
|
|
|
addEntry(wordHash, wordEntry, startTime, false);
|
|
|
|
addEntry(wordHash, wordEntry, startTime, false);
|
|
|
|
urlCount++;
|
|
|
|
urlCount++;
|
|
|
|