added control logic to ECO tables that deletes ram copies of the tables if they get too large

table copies in ram are now abandoned if less than 20 MB ram is left

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5317 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 17 years ago
parent 38e6ba5d00
commit dd27ce7216

@ -62,7 +62,7 @@ public class kelondroEcoTable implements kelondroIndex {
public static final int tailCacheUsageAuto = 2; public static final int tailCacheUsageAuto = 2;
public static final long maxarraylength = 134217727L; // that may be the maxmimum size of array length in some JVMs public static final long maxarraylength = 134217727L; // that may be the maxmimum size of array length in some JVMs
private static final long minmemremaining = 20 * 1024 * 1024; // if less than this memory is remaininig, the memory copy of a table is abandoned
kelondroRowSet table; kelondroRowSet table;
kelondroBytesIntMap index; kelondroBytesIntMap index;
kelondroBufferedEcoFS file; kelondroBufferedEcoFS file;
@ -157,12 +157,10 @@ public class kelondroEcoTable implements kelondroIndex {
// write the tail into the table // write the tail into the table
table.addUnique(taildef.newEntry(record, rowdef.primaryKeyLength, true)); table.addUnique(taildef.newEntry(record, rowdef.primaryKeyLength, true));
/* if (abandonTable()) {
if ((i % 10000) == 0) { table = null;
System.out.print('.'); break;
System.out.flush();
} }
*/
} }
} }
@ -216,6 +214,11 @@ public class kelondroEcoTable implements kelondroIndex {
tableTracker.put(tablefile.toString(), this); tableTracker.put(tablefile.toString(), this);
} }
private boolean abandonTable() {
// check if not enough memory is there to maintain a memory copy of the table
return serverMemory.available() < minmemremaining;
}
/** /**
* a KeyIterator * a KeyIterator
* @param file: the eco-file * @param file: the eco-file
@ -278,6 +281,7 @@ public class kelondroEcoTable implements kelondroIndex {
if (table != null) { if (table != null) {
assert table.size() == i; assert table.size() == i;
table.addUnique(taildef.newEntry(row.bytes(), rowdef.primaryKeyLength, true)); table.addUnique(taildef.newEntry(row.bytes(), rowdef.primaryKeyLength, true));
if (abandonTable()) table = null;
} }
file.add(row.bytes(), 0); file.add(row.bytes(), 0);
assert file.size() == index.size() + fail : "file.size() = " + file.size() + ", index.size() = " + index.size(); assert file.size() == index.size() + fail : "file.size() = " + file.size() + ", index.size() = " + index.size();
@ -571,7 +575,7 @@ public class kelondroEcoTable implements kelondroIndex {
} }
// initialize index and copy table // initialize index and copy table
table = new kelondroRowSet(taildef, 1); table = (table == null) ? null : new kelondroRowSet(taildef, 1);
index = new kelondroBytesIntMap(rowdef.primaryKeyLength, rowdef.objectOrder, 1); index = new kelondroBytesIntMap(rowdef.primaryKeyLength, rowdef.objectOrder, 1);
} }

Loading…
Cancel
Save