From dd27ce7216c4c915e7b0f558f1287c4aead84b9c Mon Sep 17 00:00:00 2001 From: orbiter Date: Sun, 2 Nov 2008 23:53:09 +0000 Subject: [PATCH] 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 --- .../de/anomic/kelondro/kelondroEcoTable.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/source/de/anomic/kelondro/kelondroEcoTable.java b/source/de/anomic/kelondro/kelondroEcoTable.java index e7f84eb29..c55dac2a6 100644 --- a/source/de/anomic/kelondro/kelondroEcoTable.java +++ b/source/de/anomic/kelondro/kelondroEcoTable.java @@ -62,7 +62,7 @@ public class kelondroEcoTable implements kelondroIndex { public static final int tailCacheUsageAuto = 2; 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; kelondroBytesIntMap index; kelondroBufferedEcoFS file; @@ -157,12 +157,10 @@ public class kelondroEcoTable implements kelondroIndex { // write the tail into the table table.addUnique(taildef.newEntry(record, rowdef.primaryKeyLength, true)); - /* - if ((i % 10000) == 0) { - System.out.print('.'); - System.out.flush(); + if (abandonTable()) { + table = null; + break; } - */ } } @@ -216,6 +214,11 @@ public class kelondroEcoTable implements kelondroIndex { 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 * @param file: the eco-file @@ -278,6 +281,7 @@ public class kelondroEcoTable implements kelondroIndex { if (table != null) { assert table.size() == i; table.addUnique(taildef.newEntry(row.bytes(), rowdef.primaryKeyLength, true)); + if (abandonTable()) table = null; } file.add(row.bytes(), 0); 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 - table = new kelondroRowSet(taildef, 1); + table = (table == null) ? null : new kelondroRowSet(taildef, 1); index = new kelondroBytesIntMap(rowdef.primaryKeyLength, rowdef.objectOrder, 1); }