Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
refactoring: find a better way to store BLOBs; generalize current BLOG data structure (kelondroDyn) and prepare it to replace it with something better. The best candidate is the kelondroHeap, which will become the kelondroBLOBHeap; removed also some never-used classes
orbiter3330181aa02c
diff --git a/source/de/anomic/crawler/CrawlProfile.java b/source/de/anomic/crawler/CrawlProfile.javaindex 6d6a955e2..debe12dc1 100644--- a/source/de/anomic/crawler/CrawlProfile.java+++ b/source/de/anomic/crawler/CrawlProfile.java@@ -50,7 +50,7 @@ import java.util.Map;import de.anomic.kelondro.kelondroBase64Order;import de.anomic.kelondro.kelondroCloneableIterator;-import de.anomic.kelondro.kelondroDyn;+import de.anomic.kelondro.kelondroBLOBTree;import de.anomic.kelondro.kelondroException;import de.anomic.kelondro.kelondroMapObjects;import de.anomic.kelondro.kelondroNaturalOrder;@@ -68,7 +68,7 @@ public class CrawlProfile {public CrawlProfile(File file) {this.profileTableFile = file;profileTableFile.getParentFile().mkdirs();- kelondroDyn dyn = new kelondroDyn(profileTableFile, true, true, yacySeedDB.commonHashLength, 2000, '#', kelondroNaturalOrder.naturalOrder, false, false, true);+ kelondroBLOBTree dyn = new kelondroBLOBTree(profileTableFile, true, true, yacySeedDB.commonHashLength, 2000, '#', kelondroNaturalOrder.naturalOrder, false, false, true);profileTable = new kelondroMapObjects(dyn, 500);}@@ -77,7 +77,7 @@ public class CrawlProfile {if (profileTable != null) profileTable.close();if (!(profileTableFile.delete())) throw new RuntimeException("cannot delete crawl profile database");profileTableFile.getParentFile().mkdirs();- kelondroDyn dyn = new kelondroDyn(profileTableFile, true, true, yacySeedDB.commonHashLength, 2000, '#', kelondroNaturalOrder.naturalOrder, false, false, true);+ kelondroBLOBTree dyn = new kelondroBLOBTree(profileTableFile, true, true, yacySeedDB.commonHashLength, 2000, '#', kelondroNaturalOrder.naturalOrder, false, false, true);profileTable = new kelondroMapObjects(dyn, 500);}diff --git a/source/de/anomic/crawler/RobotsTxt.java b/source/de/anomic/crawler/RobotsTxt.javaindex f40a4d6e6..ab178e231 100644--- a/source/de/anomic/crawler/RobotsTxt.java+++ b/source/de/anomic/crawler/RobotsTxt.java@@ -54,7 +54,7 @@ import java.util.HashMap;import java.util.Iterator;import java.util.LinkedList;-import de.anomic.kelondro.kelondroDyn;+import de.anomic.kelondro.kelondroBLOBTree;import de.anomic.kelondro.kelondroException;import de.anomic.kelondro.kelondroMapObjects;import de.anomic.kelondro.kelondroNaturalOrder;@@ -69,7 +69,7 @@ public class RobotsTxt {public RobotsTxt(File robotsTableFile) {this.robotsTableFile = robotsTableFile;robotsTableFile.getParentFile().mkdirs();- robotsTable = new kelondroMapObjects(new kelondroDyn(robotsTableFile, true, true, 256, 512, '_', kelondroNaturalOrder.naturalOrder, false, false, true), 100);+ robotsTable = new kelondroMapObjects(new kelondroBLOBTree(robotsTableFile, true, true, 256, 512, '_', kelondroNaturalOrder.naturalOrder, false, false, true), 100);}private void resetDatabase() {@@ -77,7 +77,7 @@ public class RobotsTxt {if (robotsTable != null) robotsTable.close();if (!(robotsTableFile.delete())) throw new RuntimeException("cannot delete robots.txt database");robotsTableFile.getParentFile().mkdirs();- robotsTable = new kelondroMapObjects(new kelondroDyn(robotsTableFile, true, true, 256, 512, '_', kelondroNaturalOrder.naturalOrder, false, false, true), 100);+ robotsTable = new kelondroMapObjects(new kelondroBLOBTree(robotsTableFile, true, true, 256, 512, '_', kelondroNaturalOrder.naturalOrder, false, false, true), 100);}public void clear() throws IOException {diff --git a/source/de/anomic/data/blogBoard.java b/source/de/anomic/data/blogBoard.javaindex 8d1ee892a..fbbdddb77 100644--- a/source/de/anomic/data/blogBoard.java+++ b/source/de/anomic/data/blogBoard.java@@ -66,7 +66,7 @@ import org.w3c.dom.NodeList;import org.xml.sax.SAXException;import de.anomic.kelondro.kelondroBase64Order;-import de.anomic.kelondro.kelondroDyn;+import de.anomic.kelondro.kelondroBLOBTree;import de.anomic.kelondro.kelondroException;import de.anomic.kelondro.kelondroMapObjects;import de.anomic.kelondro.kelondroNaturalOrder;@@ -83,7 +83,7 @@ public class blogBoard {public blogBoard(File actpath) {new File(actpath.getParent()).mkdir();if (database == null) {- database = new kelondroMapObjects(new kelondroDyn(actpath, true, true, keyLength, recordSize, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 500);+ database = new kelondroMapObjects(new kelondroBLOBTree(actpath, true, true, keyLength, recordSize, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 500);}}public int size() {diff --git a/source/de/anomic/data/blogBoardComments.java b/source/de/anomic/data/blogBoardComments.javaindex d7fe72a20..8003d22a5 100644--- a/source/de/anomic/data/blogBoardComments.java+++ b/source/de/anomic/data/blogBoardComments.java@@ -65,7 +65,7 @@ import org.w3c.dom.NodeList;import org.xml.sax.SAXException;import de.anomic.kelondro.kelondroBase64Order;-import de.anomic.kelondro.kelondroDyn;+import de.anomic.kelondro.kelondroBLOBTree;import de.anomic.kelondro.kelondroMapObjects;import de.anomic.kelondro.kelondroNaturalOrder;import de.anomic.server.logging.serverLog;@@ -85,7 +85,7 @@ public class blogBoardComments {public blogBoardComments(File actpath) {new File(actpath.getParent()).mkdir();if (database == null) {- database = new kelondroMapObjects(new kelondroDyn(actpath, true, true, keyLength, recordSize, '_', kelondroNaturalOrder.naturalOrder, false, false, false), 500);+ database = new kelondroMapObjects(new kelondroBLOBTree(actpath, true, true, keyLength, recordSize, '_', kelondroNaturalOrder.naturalOrder, false, false, false), 500);}}public int size() {diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.javaindex 37d47ab7d..c2b08932f 100644--- a/source/de/anomic/data/bookmarksDB.java+++ b/source/de/anomic/data/bookmarksDB.java@@ -76,7 +76,7 @@ import de.anomic.htmlFilter.htmlFilterContentScraper;import de.anomic.htmlFilter.htmlFilterWriter;import de.anomic.index.indexWord;import de.anomic.kelondro.kelondroCloneableIterator;-import de.anomic.kelondro.kelondroDyn;+import de.anomic.kelondro.kelondroBLOBTree;import de.anomic.kelondro.kelondroException;import de.anomic.kelondro.kelondroMapObjects;import de.anomic.kelondro.kelondroNaturalOrder;@@ -116,17 +116,17 @@ public class bookmarksDB {tagCache=new HashMap<String, Tag>();bookmarksFile.getParentFile().mkdirs();//this.bookmarksTable = new kelondroMap(kelondroDyn.open(bookmarksFile, bufferkb * 1024, preloadTime, 12, 256, '_', true, false));- this.bookmarksTable = new kelondroObjects(new kelondroDyn(bookmarksFile, true, true, 12, 256, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 1000);+ this.bookmarksTable = new kelondroObjects(new kelondroBLOBTree(bookmarksFile, true, true, 12, 256, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 1000);// tagstagsFile.getParentFile().mkdirs();boolean tagsFileExisted = tagsFile.exists();- this.tagsTable = new kelondroMapObjects(new kelondroDyn(tagsFile, true, true, 12, 256, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 500);+ this.tagsTable = new kelondroMapObjects(new kelondroBLOBTree(tagsFile, true, true, 12, 256, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 500);if (!tagsFileExisted) rebuildTags();// datesboolean datesExisted = datesFile.exists();- this.datesTable = new kelondroMapObjects(new kelondroDyn(datesFile, true, true, 20, 256, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 500);+ this.datesTable = new kelondroMapObjects(new kelondroBLOBTree(datesFile, true, true, 20, 256, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 500);if (!datesExisted) rebuildDates();}diff --git a/source/de/anomic/data/messageBoard.java b/source/de/anomic/data/messageBoard.javaindex 70c98384f..3c000bb97 100644--- a/source/de/anomic/data/messageBoard.java+++ b/source/de/anomic/data/messageBoard.java@@ -50,7 +50,7 @@ import java.util.Iterator;import java.util.TimeZone;import de.anomic.kelondro.kelondroBase64Order;-import de.anomic.kelondro.kelondroDyn;+import de.anomic.kelondro.kelondroBLOBTree;import de.anomic.kelondro.kelondroMapObjects;import de.anomic.kelondro.kelondroNaturalOrder;@@ -72,7 +72,7 @@ public class messageBoard {public messageBoard(File path) {new File(path.getParent()).mkdir();if (database == null) {- database = new kelondroMapObjects(new kelondroDyn(path, true, true, categoryLength + dateFormat.length() + 2, recordSize, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 500);+ database = new kelondroMapObjects(new kelondroBLOBTree(path, true, true, categoryLength + dateFormat.length() + 2, recordSize, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 500);}sn = 0;}diff --git a/source/de/anomic/data/userDB.java b/source/de/anomic/data/userDB.javaindex 523ab928b..af3bbfb35 100644--- a/source/de/anomic/data/userDB.java+++ b/source/de/anomic/data/userDB.java@@ -57,7 +57,7 @@ import java.util.Random;import de.anomic.http.httpHeader;import de.anomic.kelondro.kelondroBase64Order;import de.anomic.kelondro.kelondroCloneableIterator;-import de.anomic.kelondro.kelondroDyn;+import de.anomic.kelondro.kelondroBLOBTree;import de.anomic.kelondro.kelondroException;import de.anomic.kelondro.kelondroMapObjects;import de.anomic.kelondro.kelondroNaturalOrder;@@ -76,7 +76,7 @@ public final class userDB {public userDB(File userTableFile) {this.userTableFile = userTableFile;userTableFile.getParentFile().mkdirs();- this.userTable = new kelondroMapObjects(new kelondroDyn(userTableFile, true, true, 128, 256, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 10);+ this.userTable = new kelondroMapObjects(new kelondroBLOBTree(userTableFile, true, true, 128, 256, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 10);}void resetDatabase() {@@ -84,7 +84,7 @@ public final class userDB {if (userTable != null) userTable.close();if (!(userTableFile.delete())) throw new RuntimeException("cannot delete user database");userTableFile.getParentFile().mkdirs();- userTable = new kelondroMapObjects(new kelondroDyn(userTableFile, true, true, 256, 512, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 10);+ userTable = new kelondroMapObjects(new kelondroBLOBTree(userTableFile, true, true, 256, 512, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 10);}public void close() {diff --git a/source/de/anomic/data/wikiBoard.java b/source/de/anomic/data/wikiBoard.javaindex 4889c93d3..ab7bf9984 100644--- a/source/de/anomic/data/wikiBoard.java+++ b/source/de/anomic/data/wikiBoard.java@@ -50,7 +50,7 @@ import java.util.Iterator;import java.util.TimeZone;import de.anomic.kelondro.kelondroBase64Order;-import de.anomic.kelondro.kelondroDyn;+import de.anomic.kelondro.kelondroBLOBTree;import de.anomic.kelondro.kelondroMapObjects;import de.anomic.kelondro.kelondroNaturalOrder;@@ -73,11 +73,11 @@ public class wikiBoard {public wikiBoard(File actpath, File bkppath) {new File(actpath.getParent()).mkdirs();if (datbase == null) {- datbase = new kelondroMapObjects(new kelondroDyn(actpath, true, true, keyLength, recordSize, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 500);+ datbase = new kelondroMapObjects(new kelondroBLOBTree(actpath, true, true, keyLength, recordSize, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 500);}new File(bkppath.getParent()).mkdirs();if (bkpbase == null) {- bkpbase = new kelondroMapObjects(new kelondroDyn(bkppath, true, true, keyLength + dateFormat.length(), recordSize, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 500);+ bkpbase = new kelondroMapObjects(new kelondroBLOBTree(bkppath, true, true, keyLength + dateFormat.length(), recordSize, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 500);}}diff --git a/source/de/anomic/kelondro/kelondroBLOB.java b/source/de/anomic/kelondro/kelondroBLOB.javanew file mode 100644index 000000000..5ac48e25a--- /dev/null+++ b/source/de/anomic/kelondro/kelondroBLOB.java@@ -0,0 +1,44 @@+// kelondroBLOB.java+// (C) 2008 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany+// first published 08.06.2008 on http://yacy.net+//+// This is a part of YaCy, a peer-to-peer based web search engine+//+// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $+// $LastChangedRevision: 1986 $+// $LastChangedBy: orbiter $+//+// LICENSE+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++package de.anomic.kelondro;++import java.io.IOException;++public interface kelondroBLOB {++ public int keylength();+ public void clear() throws IOException;+ public int size();+ public kelondroCloneableIterator<String> keys(boolean up, boolean rotating) throws IOException;+ public byte[] get(String key, int pos, int len) throws IOException;+ public void put(String key, int pos, byte[] b, int off, int len) throws IOException;+ public void remove(String key) throws IOException;+ public boolean exist(String key) throws IOException;+ public kelondroRA getRA(String filekey);+ public void close();++}diff --git a/source/de/anomic/kelondro/kelondroDyn.java b/source/de/anomic/kelondro/kelondroBLOBTree.javasimilarity index 73%rename from source/de/anomic/kelondro/kelondroDyn.javarename to source/de/anomic/kelondro/kelondroBLOBTree.javaindex c09f39e32..b1be0d41e 100644--- a/source/de/anomic/kelondro/kelondroDyn.java+++ b/source/de/anomic/kelondro/kelondroBLOBTree.java@@ -1,11 +1,15 @@-// kelondroDyn.java-// ------------------------// part of The Kelondro Database-// (C) by Michael Peter Christen; [email protected]-// first published on http://www.anomic.de-// Frankfurt, Germany, 2004-// last major change: 09.02.2004+// kelondroBLOBTree.java+// (C) 2004 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany+// first published 09.02.2004 (as "kelondroDyn.java") on http://yacy.net//+// This is a part of YaCy, a peer-to-peer based web search engine+//+// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $+// $LastChangedRevision: 1986 $+// $LastChangedBy: orbiter $+//+// LICENSE+//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or@@ -19,25 +23,6 @@// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA-//-// Using this software in any meaning (reading, learning, copying, compiling,-// running) means that you agree that the Author(s) is (are) not responsible-// for cost, loss of data or any harm that may be caused directly or indirectly-// by usage of this softare or this documentation. The usage of this software-// is on your own risk. The installation and usage (starting/running) of this-// software may allow other people or application to access your computer and-// any attached devices and is highly dependent on the configuration of the-// software which must be done by the user of the software; the author(s) is-// (are) also not responsible for proper configuration and usage of the-// software, even if provoked by documentation provided together with-// the software.-//-// Any changes to this file according to the GPL as documented in the file-// gpl.txt aside this file in the shipment you received can be done to the-// lines that follows this copyright notice here, but changes must not be-// done inside the copyright notive above. A re-distribution must contain-// the intact and unchanged copyright notice.-// Contributions and changes to the program code must be marked as such./*This class extends the kelondroTree and adds dynamic data handling@@ -58,7 +43,7 @@ import java.io.FileOutputStream;import java.io.IOException;import java.util.Iterator;-public class kelondroDyn {+public class kelondroBLOBTree implements kelondroBLOB {private static final int counterlen = 8;private static final int EcoFSBufferSize = 20;@@ -71,7 +56,7 @@ public class kelondroDyn {private kelondroObjectBuffer buffer;private kelondroRow rowdef;- public kelondroDyn(File file, boolean useNodeCache, boolean useObjectCache, int key,+ public kelondroBLOBTree(File file, boolean useNodeCache, boolean useObjectCache, int key,int nodesize, char fillChar, kelondroByteOrder objectOrder, boolean usetree, boolean writebuffer, boolean resetOnFail) {// creates or opens a dynamic treerowdef = new kelondroRow("byte[] key-" + (key + counterlen) + ", byte[] node-" + nodesize, objectOrder, 0);@@ -129,14 +114,11 @@ public class kelondroDyn {this.buffer = new kelondroObjectBuffer(name);}- public kelondroRow row() {- return this.rowdef;+ public int keylength() {+ return this.rowdef.primaryKeyLength;}- public synchronized int sizeDyn() {- //this.segmentCount = 0;- //Iterator i = keys(true); while (i.hasNext()) segmentCount++;- //return segmentCount;+ public synchronized int size() {return index.size();}@@ -146,32 +128,32 @@ public class kelondroDyn {return s;}- private byte[] dynKey(String key, int record) {+ private byte[] elementKey(String key, int record) {if (key.length() > keylen) throw new RuntimeException("key len (" + key.length() + ") out of limit (" + keylen + "): '" + key + "'");while (key.length() < keylen) key = key + fillChar;key = key + counter(record);return key.getBytes();}- protected String origKey(byte[] rawKey) {+ private String origKey(byte[] rawKey) {int n = keylen - 1;if (n >= rawKey.length) n = rawKey.length - 1;while ((n > 0) && (rawKey[n] == (byte) fillChar)) n--;return new String(rawKey, 0, n + 1);}- public class dynKeyIterator implements kelondroCloneableIterator<String> {+ public class keyIterator implements kelondroCloneableIterator<String> {// the iterator iterates all keyskelondroCloneableIterator<kelondroRow.Entry> ri;String nextKey;- public dynKeyIterator(kelondroCloneableIterator<kelondroRow.Entry> iter) {+ public keyIterator(kelondroCloneableIterator<kelondroRow.Entry> iter) {ri = iter;nextKey = n();}- public dynKeyIterator clone(Object modifier) {- return new dynKeyIterator(ri.clone(modifier));+ public keyIterator clone(Object modifier) {+ return new keyIterator(ri.clone(modifier));}public boolean hasNext() {@@ -212,15 +194,15 @@ public class kelondroDyn {}}- public synchronized kelondroCloneableIterator<String> dynKeys(boolean up, boolean rotating) throws IOException {+ public synchronized kelondroCloneableIterator<String> keys(boolean up, boolean rotating) throws IOException {// iterates only the keys of the Nodes// enumerated objects are of type String- dynKeyIterator i = new dynKeyIterator(index.rows(up, null));+ keyIterator i = new keyIterator(index.rows(up, null));if (rotating) return new kelondroRotateIterator<String>(i, null, index.size()); else return i;}- public synchronized dynKeyIterator dynKeys(boolean up, byte[] firstKey) throws IOException {- return new dynKeyIterator(index.rows(up, firstKey));+ public synchronized keyIterator keys(boolean up, byte[] firstKey) throws IOException {+ return new keyIterator(index.rows(up, firstKey));}private byte[] getValueCached(byte[] key) throws IOException {@@ -245,26 +227,26 @@ public class kelondroDyn {}}- public synchronized int getDyn(String key, int pos) throws IOException {+ private synchronized int get(String key, int pos) throws IOException {int reccnt = pos / reclen;// read within a single record- byte[] buf = getValueCached(dynKey(key, reccnt));+ byte[] buf = getValueCached(elementKey(key, reccnt));if (buf == null) return -1;int recpos = pos % reclen;if (buf.length <= recpos) return -1;return buf[recpos] & 0xFF;}- public synchronized byte[] getDyn(String key, int pos, int len) throws IOException {+ public synchronized byte[] get(String key, int pos, int len) throws IOException {int recpos = pos % reclen;int reccnt = pos / reclen;byte[] segment1;// read first within a single recordif ((recpos == 0) && (reclen == len)) {- segment1 = getValueCached(dynKey(key, reccnt));+ segment1 = getValueCached(elementKey(key, reccnt));if (segment1 == null) return null;} else {- byte[] buf = getValueCached(dynKey(key, reccnt));+ byte[] buf = getValueCached(elementKey(key, reccnt));if (buf == null) return null;if (buf.length < reclen) {byte[] buff = new byte[reclen];@@ -290,7 +272,7 @@ public class kelondroDyn {// segment 1 in record <reccnt> : start = recpos, length = reclen - recpos// segment 2 in record <reccnt>+1: start = 0, length = len - reclen + recpos// recursively step further- byte[] segment2 = getDyn(key, pos + segment1.length, len - segment1.length);+ byte[] segment2 = get(key, pos + segment1.length, len - segment1.length);if (segment2 == null) return segment1;// now combine the two segments into the resultbyte[] result = new byte[segment1.length + segment2.length];@@ -299,21 +281,21 @@ public class kelondroDyn {return result;}- public synchronized void putDyn(String key, int pos, byte[] b, int off, int len) throws IOException {+ public synchronized void put(String key, int pos, byte[] b, int off, int len) throws IOException {int recpos = pos % reclen;int reccnt = pos / reclen;byte[] buf;// first write current recordif ((recpos == 0) && (reclen == len)) {if (off == 0) {- setValueCached(dynKey(key, reccnt), b);+ setValueCached(elementKey(key, reccnt), b);} else {buf = new byte[len];System.arraycopy(b, off, buf, 0, len);- setValueCached(dynKey(key, reccnt), b);+ setValueCached(elementKey(key, reccnt), b);}} else {- buf = getValueCached(dynKey(key, reccnt));+ buf = getValueCached(elementKey(key, reccnt));if (buf == null) {buf = new byte[reclen];} else if (buf.length < reclen) {@@ -328,11 +310,11 @@ public class kelondroDyn {System.arraycopy(b, off, buf, recpos, len);elseSystem.arraycopy(b, off, buf, recpos, reclen - recpos);- setValueCached(dynKey(key, reccnt), buf);+ setValueCached(elementKey(key, reccnt), buf);}// if more records are necessary, write to them also recursivelyif (recpos + len > reclen) {- putDyn(key, pos + reclen - recpos, b, off + reclen - recpos, len - reclen + recpos);+ put(key, pos + reclen - recpos, b, off + reclen - recpos, len - reclen + recpos);}}@@ -341,7 +323,7 @@ public class kelondroDyn {if (key == null) return;int recpos = 0;byte[] k;- while (index.get(k = dynKey(key, recpos)) != null) {+ while (index.get(k = elementKey(key, recpos)) != null) {index.remove(k, false);buffer.remove(k);recpos++;@@ -349,8 +331,8 @@ public class kelondroDyn {//segmentCount--; writeSegmentCount();}- public synchronized boolean existsDyn(String key) throws IOException {- return (key != null) && (getValueCached(dynKey(key, 0)) != null);+ public synchronized boolean exist(String key) throws IOException {+ return (key != null) && (getValueCached(elementKey(key, 0)) != null);}public synchronized kelondroRA getRA(String filekey) {@@ -378,18 +360,18 @@ public class kelondroDyn {}public int read() throws IOException {- return getDyn(filekey, seekpos++);+ return get(filekey, seekpos++);}public void write(int i) throws IOException {byte[] b = new byte[1];b[0] = (byte) i;- putDyn(filekey, seekpos++, b, 0, 1);+ put(filekey, seekpos++, b, 0, 1);}public int read(byte[] b, int off, int len) throws IOException {int l = Math.min(b.length - off, len);- byte[] buf = getDyn(filekey, seekpos, l);+ byte[] buf = get(filekey, seekpos, l);if (buf == null) return -1;l = Math.min(buf.length, l);System.arraycopy(buf, 0, b, off, l);@@ -398,7 +380,7 @@ public class kelondroDyn {}public void write(byte[] b, int off, int len) throws IOException {- putDyn(filekey, seekpos, b, off, len);+ put(filekey, seekpos, b, off, len);seekpos += len;}@@ -412,12 +394,12 @@ public class kelondroDyn {}- public synchronized void writeFile(String key, File f) throws IOException {+ public static void writeFile(kelondroBLOB blob, String key, File f) throws IOException {// reads a file from the FS and writes it into the databasekelondroRA kra = null;FileInputStream fis = null;try {- kra = getRA(key);+ kra = blob.getRA(key);byte[] buffer = new byte[1024];byte[] result = new byte[(int) f.length()];fis = new FileInputStream(f);@@ -443,12 +425,12 @@ public class kelondroDyn {}}- public synchronized void readFile(String key, File f) throws IOException {+ public static void readFile(kelondroBLOB blob, String key, File f) throws IOException {// reads a file from the DB and writes it to the FSkelondroRA kra = null;FileOutputStream fos = null;try {- kra = getRA(key);+ kra = blob.getRA(key);byte[] result = kra.readArray();fos = new FileOutputStream(f);fos.write(result);@@ -479,9 +461,9 @@ public class kelondroDyn {if (args.length == 1) {// open a db and list keystry {- kelondroDyn kd = new kelondroDyn(new File(args[0]), true, true, 4 ,100, '_', kelondroNaturalOrder.naturalOrder, false, false, true);- System.out.println(kd.sizeDyn() + " elements in DB");- Iterator<String> i = kd.dynKeys(true, false);+ kelondroBLOBTree kd = new kelondroBLOBTree(new File(args[0]), true, true, 4 ,100, '_', kelondroNaturalOrder.naturalOrder, false, false, true);+ System.out.println(kd.size() + " elements in DB");+ Iterator<String> i = kd.keys(true, false);while (i.hasNext())System.out.println(i.next());kd.close();@@ -494,23 +476,23 @@ public class kelondroDyn {File db = new File(args[1]);String key = args[2];File f = new File(args[3]);- kelondroDyn kd;+ kelondroBLOBTree kd;try {- kd = new kelondroDyn(db, true, true, 80, 200, '_', kelondroNaturalOrder.naturalOrder, false, false, true);+ kd = new kelondroBLOBTree(db, true, true, 80, 200, '_', kelondroNaturalOrder.naturalOrder, false, false, true);if (writeFile)- kd.readFile(key, f);+ readFile(kd, key, f);else- kd.writeFile(key, f);+ writeFile(kd, key, f);} catch (IOException e) {System.out.println("ERROR: " + e.toString());}}}- public static int countElementsDyn(kelondroDyn t) {+ public static int countElements(kelondroBLOBTree t) {int count = 0;try {- Iterator<String> iter = t.dynKeys(true, false);+ Iterator<String> iter = t.keys(true, false);while (iter.hasNext()) {count++; if (iter.next() == null) System.out.println("ERROR! null element found");}return count;} catch (IOException e) {diff --git a/source/de/anomic/kelondro/kelondroDynTree.java b/source/de/anomic/kelondro/kelondroDynTree.javadeleted file mode 100644index 5ec671e46..000000000--- a/source/de/anomic/kelondro/kelondroDynTree.java+++ /dev/null@@ -1,322 +0,0 @@-// kelondroDynTree.java-// ------------------------// part of The Kelondro Database-// (C) by Michael Peter Christen; [email protected]-// first published on http://www.anomic.de-// Frankfurt, Germany, 2004-// last major change: 20.09.2004-//-// This program is free software; you can redistribute it and/or modify-// it under the terms of the GNU General Public License as published by-// the Free Software Foundation; either version 2 of the License, or-// (at your option) any later version.-//-// This program is distributed in the hope that it will be useful,-// but WITHOUT ANY WARRANTY; without even the implied warranty of-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-// GNU General Public License for more details.-//-// You should have received a copy of the GNU General Public License-// along with this program; if not, write to the Free Software-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA-//-// Using this software in any meaning (reading, learning, copying, compiling,-// running) means that you agree that the Author(s) is (are) not responsible-// for cost, loss of data or any harm that may be caused directly or indirectly-// by usage of this softare or this documentation. The usage of this software-// is on your own risk. The installation and usage (starting/running) of this-// software may allow other people or application to access your computer and-// any attached devices and is highly dependent on the configuration of the-// software which must be done by the user of the software; the author(s) is-// (are) also not responsible for proper configuration and usage of the-// software, even if provoked by documentation provided together with-// the software.-//-// Any changes to this file according to the GPL as documented in the file-// gpl.txt aside this file in the shipment you received can be done to the-// lines that follows this copyright notice here, but changes must not be-// done inside the copyright notive above. A re-distribution must contain-// the intact and unchanged copyright notice.-// Contributions and changes to the program code must be marked as such.--/*- */--package de.anomic.kelondro;--import java.io.File;-import java.io.IOException;-import java.util.HashMap;-import java.util.Iterator;--public class kelondroDynTree {-- // basic data structures- private kelondroRow rowdef;- private kelondroDyn table;- private HashMap<String, kelondroRA> treeRAHandles;- private File file;-- // some properties to control caching and buffering- //private int maxcountCache = 1000, maxsizeCache = 100;- private int maxcountBuffer = 1000, maxsizeBuffer = 100;- //private long maxageCache = 60000, cycletimeCache = 10000;- private long maxageBuffer = 60000, cycletimeBuffer = 10000;-- // data structures for the cache and buffer- private HashMap<String, treeBuffer> buffer;- private HashMap<String, treeCache> cache;- private long cycleBuffer;-- public kelondroDynTree(File file, int keylength, int nodesize, kelondroRow rowdef, char fillChar, boolean resetOnFail) {- // creates or opens a DynTree- this.file = file;- this.rowdef = rowdef;- this.buffer = new HashMap<String, treeBuffer>();- this.cache = new HashMap<String, treeCache>();- //this.cycleCache = Long.MIN_VALUE;- this.cycleBuffer = Long.MIN_VALUE;- this.table = new kelondroDyn(file, true, true, keylength, nodesize, fillChar, rowdef.objectOrder, true, false, resetOnFail);- this.treeRAHandles = new HashMap<String, kelondroRA>();- }-- public void close() throws IOException {- Iterator<String> e = treeRAHandles.keySet().iterator();- while (e.hasNext()) closeTree(e.next());- int size = table.sizeDyn();- table.close();- if (size == 0) this.file.delete();- }-- public void setWriteBufferAttr(int maxcount, int maxsize, long maxage, long cycletime) {- maxcountBuffer = maxcount;- maxsizeBuffer = maxsize;- maxageBuffer = maxage;- cycletimeBuffer = cycletime;- }-- protected boolean existsTree(String key) throws IOException {- return table.existsDyn(key);- }-- protected kelondroTree newTree(String key) throws IOException {- if (table.existsDyn(key)) throw new IOException("table " + key + " already exists.");- kelondroRA ra = table.getRA(key); // works always, even with no-existing entry- treeRAHandles.put(key, ra);- try {- return new kelondroTree(ra, this.file.getCanonicalPath() + "#" + key, true, 0, rowdef, false);- } catch (RuntimeException e) {- throw new IOException(e.getMessage());- }- }-- protected kelondroTree getTree(String key) throws IOException {- if (table.existsDyn(key)) {- kelondroRA ra = table.getRA(key);- treeRAHandles.put(key, ra);- return new kelondroTree(ra, this.file.getCanonicalPath() + "#" + key, true, 0);- }- return null;- }-- protected void closeTree(String key) throws IOException {- kelondroRA ra = treeRAHandles.get(key);- if (ra != null) {- ra.close();- treeRAHandles.remove(key);- }- }-- protected void removeTree(String key) throws IOException {- kelondroRA ra = treeRAHandles.get(key);- if (ra != null) {- ra.close();- treeRAHandles.remove(key);- }- table.remove(key);- }--- /*******************************************************/-- protected class treeCache {-- private String tablename;- private HashMap<String, kelondroRow.Entry> tcache;- public long timestamp;-- treeCache(String tablename) {- this.tablename = tablename;- this.tcache = new HashMap<String, kelondroRow.Entry>(); // for key-row relations- this.timestamp = Long.MAX_VALUE; // to flag no-update- }-- public kelondroRow.Entry get(byte[] key) throws IOException {- kelondroRow.Entry entry = tcache.get(new String(key));- if (entry == null) {- kelondroTree t = getTree(this.tablename);- entry = t.get(key);- t.close();- this.tcache.put(new String(key), entry);- this.timestamp = System.currentTimeMillis();- }- return entry;- }-- protected void put(kelondroRow.Entry entry) { // this is only used internal- this.tcache.put(entry.getColString(0, null), entry);- this.timestamp = System.currentTimeMillis();- }-- protected void remove(byte[] key) {- this.tcache.remove(new String(key));- this.timestamp = System.currentTimeMillis();- }- }-- protected class treeBuffer {-- private String tablename;- protected HashMap<String, kelondroRow.Entry> tbuffer;- public long timestamp;-- treeBuffer(String tablename) {- this.tablename = tablename;- this.tbuffer = new HashMap<String, kelondroRow.Entry>(); // for key-row relations- this.timestamp = Long.MAX_VALUE; // to flag no-update- }-- public void put(kelondroRow.Entry entry) {- this.tbuffer.put(entry.getColString(0, null), entry);- this.timestamp = System.currentTimeMillis();- }-- public void remove(byte[] key) {- this.tbuffer.remove(new String(key));- this.timestamp = System.currentTimeMillis();- }-- protected void flush() throws IOException {- this.timestamp = System.currentTimeMillis();- if (this.tbuffer.size() == 0) return;- Iterator<String> e = this.tbuffer.keySet().iterator();- kelondroTree t = getTree(this.tablename);- kelondroRow.Entry entry;- String key;- while (e.hasNext()) {- key = e.next();- entry = this.tbuffer.get(key);- t.put(entry);- }- t.close();- }- }-- /*******************************************************/--- // read cached- public synchronized kelondroRow.Entry get(String tablename, byte[] key) throws IOException {- treeCache tc = cache.get(table);//FIXME shouldn't this be tablename (key is a String) - danielr 2008-06-06- if (tc == null) {- tc = new treeCache(tablename);- cache.put(tablename, tc);- }- return tc.get(key);- }-- // write buffered- public synchronized void put(String tablename, kelondroRow.Entry newrow) {- treeBuffer tb = buffer.get(tablename);- if (tb == null) {- tb = new treeBuffer(tablename);- }- treeCache tc = cache.get(table);- if (tc == null) {- tc = new treeCache(tablename);- cache.put(tablename, tc);- }- tb.put(newrow);- tc.put(newrow);- flushBuffer();- }-- public synchronized void remove(String tablename, byte[] key) {- treeBuffer tb = buffer.get(tablename);- if (tb == null) {- tb = new treeBuffer(tablename);- }- treeCache tc = cache.get(table);- if (tc == null) {- tc = new treeCache(tablename);- cache.put(tablename, tc);- }- tb.remove(key);- tc.remove(key);- flushBuffer();- }-- public synchronized void removeAll(String tablename) throws IOException {- buffer.remove(table);- cache.remove(table);- kelondroTree t = getTree(tablename);- t.removeAll();- flushBuffer();- }-- // clean-up method for buffer:- private void flushBuffer() {- if ((System.currentTimeMillis() - this.cycleBuffer < this.cycletimeBuffer) &&- (buffer.size() < this.maxcountBuffer)) return;- this.cycleBuffer = System.currentTimeMillis();- // collect all buffers which have a time > maxageBuffer- Iterator<String> e = buffer.keySet().iterator();- String tablename;- treeBuffer tb;- while (e.hasNext()) {- tablename = e.next();- tb = buffer.get(tablename);- if ((System.currentTimeMillis() - tb.timestamp > this.maxageBuffer) ||- (tb.tbuffer.size() > this.maxsizeBuffer) ||- (buffer.size() > this.maxcountBuffer)) {- try {tb.flush();} catch (IOException ee) {}- tb = null;- buffer.remove(tablename);- }- }- }--- /*******************************************************/-- public static void main(String[] args) {- // test app- try {- System.out.println("start");- File file = new File("D:\\bin\\testDyn.db");- if (file.exists()) {- kelondroDynTree dt = new kelondroDynTree(file, 16, 512, new kelondroRow("byte[] a-10, byte[] b-20, byte[] c-30", kelondroNaturalOrder.naturalOrder, 0), '_', true);- System.out.println("opened: table keylength=" + dt.table.row().width(0) + ", sectorsize=" + dt.table.row().width(1) + ", " + dt.table.sizeDyn() + " entries.");- } else {- kelondroDynTree dt = new kelondroDynTree(file, 16, 512, new kelondroRow("byte[] a-10, byte[] b-20, byte[] c-30", kelondroNaturalOrder.naturalOrder, 0), '_', true);- String name;- kelondroTree t;- kelondroRow.Entry line;- for (int i = 1; i < 100; i++) {- name = "test" + i;- t = dt.newTree(name);- line = t.row().newEntry(new byte[][] {"".getBytes(), "abc".getBytes(), "def".getBytes()});- for (int j = 1; j < 10; j++) {- line.setCol(0, ("entry" + j).getBytes());- t.put(line);- }- dt.closeTree(name);- }- }- System.out.println("finished");- } catch (IOException e) {- e.printStackTrace();- }- }--}diff --git a/source/de/anomic/kelondro/kelondroMapObjects.java b/source/de/anomic/kelondro/kelondroMapObjects.javaindex 339776b17..321ecb65c 100644--- a/source/de/anomic/kelondro/kelondroMapObjects.java+++ b/source/de/anomic/kelondro/kelondroMapObjects.java@@ -41,12 +41,12 @@ public class kelondroMapObjects extends kelondroObjects {private HashMap<String, Object> accMap; // to store accumulations of specific fieldsprivate int elementCount;- public kelondroMapObjects(kelondroDyn dyn, int cachesize) {+ public kelondroMapObjects(kelondroBLOBTree dyn, int cachesize) {this(dyn, cachesize, null, null, null, null, null);}@SuppressWarnings({ "unchecked", "null" })- public kelondroMapObjects(kelondroDyn dyn, int cachesize, String[] sortfields, String[] longaccfields, String[] doubleaccfields, Method externalInitializer, Object externalHandler) {+ public kelondroMapObjects(kelondroBLOBTree dyn, int cachesize, String[] sortfields, String[] longaccfields, String[] doubleaccfields, Method externalInitializer, Object externalHandler) {super(dyn, cachesize);// create fast ordering clusters and acc fields@@ -85,7 +85,7 @@ public class kelondroMapObjects extends kelondroObjects {// fill cluster and accumulator with valuesif ((sortfields != null) || (longaccfields != null) || (doubleaccfields != null)) try {- kelondroCloneableIterator<String> it = dyn.dynKeys(true, false);+ kelondroCloneableIterator<String> it = dyn.keys(true, false);String mapname;Object cell;long valuel;diff --git a/source/de/anomic/kelondro/kelondroMapTable.java b/source/de/anomic/kelondro/kelondroMapTable.javaindex de07de9ea..752e6ebd4 100644--- a/source/de/anomic/kelondro/kelondroMapTable.java+++ b/source/de/anomic/kelondro/kelondroMapTable.java@@ -76,9 +76,9 @@ public class kelondroMapTable {if (mTables.containsKey(tablename)) throw new RuntimeException("kelondroTables.declareMap: table '" + tablename + "' declared twice.");if (tTables.containsKey(tablename)) throw new RuntimeException("kelondroTables.declareMap: table '" + tablename + "' declared already in other context.");File tablefile = new File(tablesPath, "table." + tablename + ".mdb");- kelondroDyn dyn;+ kelondroBLOBTree dyn;if (!(tablefile.exists())) tablefile.getParentFile().mkdirs();- dyn = new kelondroDyn(tablefile, true, true, keysize, nodesize, fillChar, objectOrder, true, false, resetOnFail);+ dyn = new kelondroBLOBTree(tablefile, true, true, keysize, nodesize, fillChar, objectOrder, true, false, resetOnFail);kelondroMapObjects map = new kelondroMapObjects(dyn, cacheslots, sortfields, longaccfields, doubleaccfields, null, null);mTables.put(tablename, map);}diff --git a/source/de/anomic/kelondro/kelondroObjects.java b/source/de/anomic/kelondro/kelondroObjects.javaindex 539dc97f2..4b6b79fea 100644--- a/source/de/anomic/kelondro/kelondroObjects.java+++ b/source/de/anomic/kelondro/kelondroObjects.java@@ -33,15 +33,15 @@ import java.util.Iterator;public class kelondroObjects {- private kelondroDyn dyn;+ private kelondroBLOBTree blob;private kelondroMScoreCluster<String> cacheScore;private HashMap<String, kelondroObjectsEntry> cache;private long startup;private int cachesize;- public kelondroObjects(kelondroDyn dyn, int cachesize) {- this.dyn = dyn;+ public kelondroObjects(kelondroBLOBTree blob, int cachesize) {+ this.blob = blob;this.cache = new HashMap<String, kelondroObjectsEntry>();this.cacheScore = new kelondroMScoreCluster<String>();this.startup = System.currentTimeMillis();@@ -49,13 +49,13 @@ public class kelondroObjects {}public void clear() throws IOException {- this.dyn.clear();+ this.blob.clear();this.cache = new HashMap<String, kelondroObjectsEntry>();this.cacheScore = new kelondroMScoreCluster<String>();}public int keySize() {- return dyn.row().width(0);+ return blob.keylength();}public synchronized void set(String key, kelondroObjectsEntry newMap) throws IOException {@@ -65,7 +65,7 @@ public class kelondroObjects {if (cacheScore == null) return; // may appear during shutdown// write entry- kelondroRA kra = dyn.getRA(key);+ kelondroRA kra = blob.getRA(key);newMap.write(kra);kra.close();@@ -86,7 +86,7 @@ public class kelondroObjects {cache.remove(key);// remove from file- dyn.remove(key);+ blob.remove(key);}public synchronized kelondroObjectsEntry get(final String key) throws IOException {@@ -102,10 +102,10 @@ public class kelondroObjects {if (map != null) return map;// load map from kra- if (!(dyn.existsDyn(key))) return null;+ if (!(blob.exist(key))) return null;// read object- kelondroRA kra = dyn.getRA(key);+ kelondroRA kra = blob.getRA(key);map = new kelondroObjectsMapEntry(kra);kra.close();@@ -134,13 +134,13 @@ public class kelondroObjects {public synchronized kelondroCloneableIterator<String> keys(final boolean up, final boolean rotating) throws IOException {// simple enumeration of key names without special ordering- return dyn.dynKeys(up, rotating);+ return blob.keys(up, rotating);}public synchronized kelondroCloneableIterator<String> keys(final boolean up, final boolean rotating, final byte[] firstKey, final byte[] secondKey) throws IOException {// simple enumeration of key names without special ordering- kelondroCloneableIterator<String> i = dyn.dynKeys(up, firstKey);- if (rotating) return new kelondroRotateIterator<String>(i, secondKey, dyn.sizeDyn()); else return i;+ kelondroCloneableIterator<String> i = blob.keys(up, firstKey);+ if (rotating) return new kelondroRotateIterator<String>(i, secondKey, blob.size()); else return i;}@@ -153,7 +153,7 @@ public class kelondroObjects {}public synchronized int size() {- return dyn.sizeDyn();+ return blob.size();}public void close() {@@ -164,7 +164,7 @@ public class kelondroObjects {cacheScore = null;// close file- dyn.close();+ blob.close();}public class objectIterator implements Iterator<kelondroObjectsEntry> {diff --git a/source/de/anomic/plasma/plasmaHTCache.java b/source/de/anomic/plasma/plasmaHTCache.javaindex 593edc01a..3abb6d4f3 100644--- a/source/de/anomic/plasma/plasmaHTCache.java+++ b/source/de/anomic/plasma/plasmaHTCache.java@@ -72,7 +72,7 @@ import java.util.regex.Pattern;import de.anomic.crawler.CrawlProfile;import de.anomic.http.httpHeader;import de.anomic.kelondro.kelondroBase64Order;-import de.anomic.kelondro.kelondroDyn;+import de.anomic.kelondro.kelondroBLOBTree;import de.anomic.kelondro.kelondroMScoreCluster;import de.anomic.kelondro.kelondroMapObjects;import de.anomic.plasma.cache.IResourceInfo;@@ -279,7 +279,7 @@ public final class plasmaHTCache {private static void openResponseHeaderDB() {// open the response header databaseFile dbfile = new File(cachePath, DB_NAME);- responseHeaderDB = new kelondroMapObjects(new kelondroDyn(dbfile, true, true, yacySeedDB.commonHashLength, 150, '#', kelondroBase64Order.enhancedCoder, false, false, true), 500);+ responseHeaderDB = new kelondroMapObjects(new kelondroBLOBTree(dbfile, true, true, yacySeedDB.commonHashLength, 150, '#', kelondroBase64Order.enhancedCoder, false, false, true), 500);}private static void deleteOldHTCache(File directory) {diff --git a/source/de/anomic/plasma/plasmaWordConnotation.java b/source/de/anomic/plasma/plasmaWordConnotation.javadeleted file mode 100644index 3729892d5..000000000--- a/source/de/anomic/plasma/plasmaWordConnotation.java+++ /dev/null@@ -1,102 +0,0 @@-// plasmaWordCon.java-// ------------------------// part of The Kelondro Database-// (C) by Michael Peter Christen; [email protected]-// first published on http://www.anomic.de-// Frankfurt, Germany, 2004-// last major change: 22.09.2004-//-// This program is free software; you can redistribute it and/or modify-// it under the terms of the GNU General Public License as published by-// the Free Software Foundation; either version 2 of the License, or-// (at your option) any later version.-//-// This program is distributed in the hope that it will be useful,-// but WITHOUT ANY WARRANTY; without even the implied warranty of-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-// GNU General Public License for more details.-//-// You should have received a copy of the GNU General Public License-// along with this program; if not, write to the Free Software-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA-//-// Using this software in any meaning (reading, learning, copying, compiling,-// running) means that you agree that the Author(s) is (are) not responsible-// for cost, loss of data or any harm that may be caused directly or indirectly-// by usage of this softare or this documentation. The usage of this software-// is on your own risk. The installation and usage (starting/running) of this-// software may allow other people or application to access your computer and-// any attached devices and is highly dependent on the configuration of the-// software which must be done by the user of the software; the author(s) is-// (are) also not responsible for proper configuration and usage of the-// software, even if provoked by documentation provided together with-// the software.-//-// Any changes to this file according to the GPL as documented in the file-// gpl.txt aside this file in the shipment you received can be done to the-// lines that follows this copyright notice here, but changes must not be-// done inside the copyright notive above. A re-distribution must contain-// the intact and unchanged copyright notice.-// Contributions and changes to the program code must be marked as such.--/*- */---package de.anomic.plasma;--import java.io.File;-import java.io.IOException;--import de.anomic.kelondro.kelondroDynTree;-import de.anomic.kelondro.kelondroNaturalOrder;-import de.anomic.kelondro.kelondroRow;--public class plasmaWordConnotation {-- private static final int wordlength = 32;- private static final int countlength = 4;- private static final int nodesize = 4048;- private kelondroDynTree refDB;-- public plasmaWordConnotation(File refDBfile, char fillChar) {- refDB = new kelondroDynTree(refDBfile, wordlength, nodesize, new kelondroRow("byte[] word-" + wordlength + ", Cardinal count-" + countlength, kelondroNaturalOrder.naturalOrder, 0), fillChar, true);- }-- private void addSingleRef(String word, String reference) throws IOException {- //word = word.toLowerCase();- //reference = reference.toLowerCase();- // TODO what if there is no record? Should a new one be created? danielr 2008-06-06- kelondroRow.Entry record = refDB.get(word, reference.getBytes());- if(record != null) {- final long c = record.getColLong(1) + 1;- record.setCol(1, c);- }- refDB.put(word, record);-// long c;-// if (record == null) c = 0; else c = record.getColLong(1);-// record.setCol(1, c++);-// refDB.put(word, record);- }-- public void addSentence(String[] words) throws IOException {- for (int i = 0; i < words.length; i++) words[i] = words[i].toLowerCase();- for (int i = 0; i < words.length; i++) {- for (int j = 0; j < words.length; j++) {- if ((i != j) && (words[i].length() > 2) && (words[j].length() > 2))- addSingleRef(words[i], words[j]);- }- }- }-- public void addSentence(String sentence) throws IOException {- addSentence(sentence.split(" "));- }-- /*- public String[] getConnotation(String word, int count) {- TreeMap map = new TreeMap();- return null;- }- */-}diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.javaindex 11dac1c13..f14075c40 100644--- a/source/de/anomic/yacy/yacySeedDB.java+++ b/source/de/anomic/yacy/yacySeedDB.java@@ -66,7 +66,7 @@ import de.anomic.http.httpHeader;import de.anomic.http.httpd;import de.anomic.http.httpdAlternativeDomainNames;import de.anomic.kelondro.kelondroBase64Order;-import de.anomic.kelondro.kelondroDyn;+import de.anomic.kelondro.kelondroBLOBTree;import de.anomic.kelondro.kelondroException;import de.anomic.kelondro.kelondroMScoreCluster;import de.anomic.kelondro.kelondroMapObjects;@@ -258,11 +258,11 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {initializeHandlerMethod = null;}try {- return new kelondroMapObjects(new kelondroDyn(seedDBFile, true, true, commonHashLength, 480, '#', kelondroBase64Order.enhancedCoder, usetree, false, true), 500, sortFields, longaccFields, doubleaccFields, initializeHandlerMethod, this);+ return new kelondroMapObjects(new kelondroBLOBTree(seedDBFile, true, true, commonHashLength, 480, '#', kelondroBase64Order.enhancedCoder, usetree, false, true), 500, sortFields, longaccFields, doubleaccFields, initializeHandlerMethod, this);} catch (Exception e) {// try again- kelondroDyn.delete(seedDBFile);- return new kelondroMapObjects(new kelondroDyn(seedDBFile, true, true, commonHashLength, 480, '#', kelondroBase64Order.enhancedCoder, usetree, false, true), 500, sortFields, longaccFields, doubleaccFields, initializeHandlerMethod, this);+ kelondroBLOBTree.delete(seedDBFile);+ return new kelondroMapObjects(new kelondroBLOBTree(seedDBFile, true, true, commonHashLength, 480, '#', kelondroBase64Order.enhancedCoder, usetree, false, true), 500, sortFields, longaccFields, doubleaccFields, initializeHandlerMethod, this);}}diff --git a/source/yacy.java b/source/yacy.javaindex c595fec12..7586edd3b 100644--- a/source/yacy.java+++ b/source/yacy.java@@ -79,7 +79,7 @@ import de.anomic.index.indexRepositoryReference;import de.anomic.index.indexURLReference;import de.anomic.index.indexWord;import de.anomic.kelondro.kelondroBase64Order;-import de.anomic.kelondro.kelondroDyn;+import de.anomic.kelondro.kelondroBLOBTree;import de.anomic.kelondro.kelondroMScoreCluster;import de.anomic.kelondro.kelondroMapObjects;import de.anomic.kelondro.kelondroRowCollection;@@ -898,7 +898,7 @@ public final class yacy {String[] dbFileNames = {"seed.new.db","seed.old.db","seed.pot.db"};for (int i=0; i < dbFileNames.length; i++) {File dbFile = new File(yacyDBPath,dbFileNames[i]);- kelondroMapObjects db = new kelondroMapObjects(new kelondroDyn(dbFile, true, true, yacySeedDB.commonHashLength, 480, '#', kelondroBase64Order.enhancedCoder, true, false, true), 500, yacySeedDB.sortFields, yacySeedDB.longaccFields, yacySeedDB.doubleaccFields, null, null);+ kelondroMapObjects db = new kelondroMapObjects(new kelondroBLOBTree(dbFile, true, true, yacySeedDB.commonHashLength, 480, '#', kelondroBase64Order.enhancedCoder, true, false, true), 500, yacySeedDB.sortFields, yacySeedDB.longaccFields, yacySeedDB.doubleaccFields, null, null);kelondroMapObjects.mapIterator it;it = db.maps(true, false);