From 6dc679785f59888adc0d1c0a50f262c70ec94dd6 Mon Sep 17 00:00:00 2001 From: orbiter Date: Wed, 23 Jan 2008 20:18:36 +0000 Subject: [PATCH] - fixed bad sort behavior of kelondroRowSet, in this case: no sort at all! see http://forum.yacy-websuche.de/viewtopic.php?p=4841#p4841 - some memory calculation enhancements in kelondroFlex and a little bit more logging git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4378 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/kelondro/kelondroFlexTable.java | 8 ++++---- source/de/anomic/kelondro/kelondroRowSet.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/de/anomic/kelondro/kelondroFlexTable.java b/source/de/anomic/kelondro/kelondroFlexTable.java index cf89c10ba..12d6644b4 100644 --- a/source/de/anomic/kelondro/kelondroFlexTable.java +++ b/source/de/anomic/kelondro/kelondroFlexTable.java @@ -59,9 +59,9 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr e2.printStackTrace(); throw new kelondroException(e2.getMessage()); } - + minimumSpace = Math.max(minimumSpace, super.size()); try { - long neededRAM = (long) ((super.row().column(0).cellwidth + 4) * Math.max(super.size(), minimumSpace) * kelondroRowCollection.growfactor); + long neededRAM = 10 * 1024 * 104 + (long) ((super.row().column(0).cellwidth + 4) * minimumSpace * kelondroRowCollection.growfactor); File newpath = new File(path, tablename); File indexfile = new File(newpath, "col.000.index"); @@ -72,7 +72,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr System.out.println("*** Last Startup time: " + stt + " milliseconds"); long start = System.currentTimeMillis(); - if (serverMemory.request(neededRAM, true)) { + if (serverMemory.request(neededRAM, false)) { // we can use a RAM index if (indexfile.exists()) { // delete existing index file @@ -81,7 +81,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr } // fill the index - System.out.print("*** Loading RAM index for " + size() + " entries from " + newpath); + System.out.print("*** Loading RAM index for " + size() + " entries from " + newpath + "; available RAM = " + (serverMemory.available() >> 20) + " MB, allocating " + (neededRAM >> 20) + " MB for index."); index = initializeRamIndex(minimumSpace); System.out.println(" -done-"); diff --git a/source/de/anomic/kelondro/kelondroRowSet.java b/source/de/anomic/kelondro/kelondroRowSet.java index a13438b9b..11296db64 100644 --- a/source/de/anomic/kelondro/kelondroRowSet.java +++ b/source/de/anomic/kelondro/kelondroRowSet.java @@ -107,13 +107,13 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd long handle = profile.startWrite(); int index = -1; kelondroRow.Entry oldentry = null; + // when reaching a specific amount of un-sorted entries, re-sort all + if ((this.chunkcount - this.sortBound) > collectionReSortLimit) { + sort(); + } index = find(entry.bytes(), (rowdef.primaryKeyIndex < 0) ? 0 :super.rowdef.colstart[rowdef.primaryKeyIndex], super.rowdef.primaryKeyLength); if (index < 0) { super.addUnique(entry); - // when reaching a specific amount of un-sorted entries, re-sort all - if ((this.chunkcount - this.sortBound) > collectionReSortLimit) { - sort(); - } } else { oldentry = get(index); set(index, entry);