From 25070822a52cae1241a0d7bb9bd35a2a77d1c58a Mon Sep 17 00:00:00 2001 From: orbiter Date: Thu, 5 Apr 2007 19:08:59 +0000 Subject: [PATCH] fix for http://www.yacy-forum.de/viewtopic.php?p=33925#33925 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3551 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/kelondro/kelondroDyn.java | 8 ++++++++ source/de/anomic/kelondro/kelondroFlexTable.java | 10 +++++++++- source/de/anomic/kelondro/kelondroFlexWidthArray.java | 2 +- source/de/anomic/yacy/yacySeedDB.java | 7 ++++--- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/source/de/anomic/kelondro/kelondroDyn.java b/source/de/anomic/kelondro/kelondroDyn.java index ebe428f67..f5d270e7b 100644 --- a/source/de/anomic/kelondro/kelondroDyn.java +++ b/source/de/anomic/kelondro/kelondroDyn.java @@ -109,6 +109,14 @@ public class kelondroDyn { buffer = new kelondroObjectBuffer(file.toString()); } + public static final void delete(File file, boolean usetree) { + if (usetree) { + file.delete(); + } else { + kelondroFlexTable.delete(file.getParentFile(), file.getName()); + } + } + public void reset() throws IOException { String name = this.index.filename(); this.index.reset(); diff --git a/source/de/anomic/kelondro/kelondroFlexTable.java b/source/de/anomic/kelondro/kelondroFlexTable.java index 08b27cc44..ed640f211 100644 --- a/source/de/anomic/kelondro/kelondroFlexTable.java +++ b/source/de/anomic/kelondro/kelondroFlexTable.java @@ -52,7 +52,14 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr // if the ram is not sufficient, a tree file is generated // if, and only if a tree file exists, the preload time is applied super(path, tablename, rowdef, resetOnFail); - try { + if ((super.col[0].size() < 0) && (resetOnFail)) try { + super.reset(); + } catch (IOException e2) { + e2.printStackTrace(); + throw new kelondroException(e2.getMessage()); + } + + try { long neededRAM = (long) ((super.row().column(0).cellwidth() + 4) * super.size() * kelondroRowCollection.growfactor); File newpath = new File(path, tablename); @@ -65,6 +72,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr System.out.println("*** Last Startup time: " + stt + " milliseconds"); long start = System.currentTimeMillis(); + if (serverMemory.available(neededRAM, true)) { // we can use a RAM index diff --git a/source/de/anomic/kelondro/kelondroFlexWidthArray.java b/source/de/anomic/kelondro/kelondroFlexWidthArray.java index c19faeeba..e60630524 100644 --- a/source/de/anomic/kelondro/kelondroFlexWidthArray.java +++ b/source/de/anomic/kelondro/kelondroFlexWidthArray.java @@ -187,7 +187,7 @@ public class kelondroFlexWidthArray implements kelondroArray { } public void close() { - synchronized (col) { + if (col != null) synchronized (col) { for (int i = 0; i < col.length; i++) { if (col[i] != null) { // a column can be null, this is normal diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.java index 10d7ba459..a75a24068 100644 --- a/source/de/anomic/yacy/yacySeedDB.java +++ b/source/de/anomic/yacy/yacySeedDB.java @@ -173,6 +173,7 @@ public final class yacySeedDB { } private synchronized kelondroMapObjects openSeedTable(File seedDBFile) { + final boolean usetree = false; new File(seedDBFile.getParent()).mkdirs(); Class[] args; try { @@ -192,11 +193,11 @@ public final class yacySeedDB { initializeHandlerMethod = null; } try { - return new kelondroMapObjects(new kelondroDyn(seedDBFile, true, true, preloadTime / 3, commonHashLength, 480, '#', false, false, true), 500, sortFields, longaccFields, doubleaccFields, initializeHandlerMethod, this); + return new kelondroMapObjects(new kelondroDyn(seedDBFile, true, true, preloadTime / 3, commonHashLength, 480, '#', usetree, false, true), 500, sortFields, longaccFields, doubleaccFields, initializeHandlerMethod, this); } catch (Exception e) { - seedDBFile.delete(); // try again - return new kelondroMapObjects(new kelondroDyn(seedDBFile, true, true, preloadTime / 3, commonHashLength, 480, '#', false, false, true), 500, sortFields, longaccFields, doubleaccFields, initializeHandlerMethod, this); + kelondroDyn.delete(seedDBFile, usetree); + return new kelondroMapObjects(new kelondroDyn(seedDBFile, true, true, preloadTime / 3, commonHashLength, 480, '#', usetree, false, true), 500, sortFields, longaccFields, doubleaccFields, initializeHandlerMethod, this); } }