diff --git a/source/dbtest.java b/source/dbtest.java index be7a9c599..f8213a73a 100644 --- a/source/dbtest.java +++ b/source/dbtest.java @@ -9,6 +9,7 @@ import java.sql.DriverManager; import java.sql.PreparedStatement; import java.util.Random; import java.util.Date; +import java.util.Iterator; import de.anomic.server.serverCodings; import de.anomic.kelondro.kelondroIndex; @@ -20,12 +21,18 @@ import de.anomic.server.serverMemory; public class dbtest { public final static int keylength = 12; - public final static int valuelength = 446; // sum of all data length as defined in plasmaURL + public final static int valuelength = 223; // sum of all data length as defined in plasmaURL public final static long buffer = 8192 * 1024; // 8 MB buffer - public static byte[] dummyvalue = new byte[valuelength]; + public static byte[] dummyvalue1 = new byte[valuelength]; + public static byte[] dummyvalue2 = new byte[valuelength]; static { // fill the dummy value - for (int i = 0; i < valuelength; i++) dummyvalue[i] = '.'; + for (int i = 0; i < valuelength; i++) dummyvalue1[i] = '.'; + dummyvalue1[0] = '['; + dummyvalue1[valuelength - 1] = ']'; + for (int i = 0; i < valuelength; i++) dummyvalue2[i] = '-'; + dummyvalue2[0] = '{'; + dummyvalue2[valuelength - 1] = '}'; } public static byte[] randomHash(Random r) { @@ -55,7 +62,7 @@ public class dbtest { if (tablefile.exists()) { table = new kelondroTree(tablefile, buffer); } else { - table = new kelondroTree(tablefile, buffer, keylength, valuelength); + table = new kelondroTree(tablefile, buffer, new int[]{keylength, valuelength, valuelength}); } } @@ -81,12 +88,21 @@ public class dbtest { long randomstart = Long.parseLong(args[4]); Random random = new Random(randomstart); for (int i = 0; i < count; i++) { - table.put(new byte[][]{randomHash(random), dummyvalue}); + table.put(new byte[][]{randomHash(random), dummyvalue1, dummyvalue2}); if (i % 500 == 0) { System.out.println(i + " entries processed so far."); } } } + if (command.equals("list")) { + Iterator i = table.rows(true, false); + byte[][] row; + while (i.hasNext()) { + row = (byte[][]) i.next(); + for (int j = 0; j < row.length; j++) System.out.print(new String(row[j]) + ","); + System.out.println(); + } + } long aftercommand = System.currentTimeMillis(); @@ -116,8 +132,6 @@ public class dbtest { */ final class dbTable implements kelondroIndex { - - private final String db_driver_str_mysql = "org.gjt.mm.mysql.Driver"; private final String db_driver_str_pgsql = "org.postgresql.Driver"; @@ -211,6 +225,10 @@ final class dbTable implements kelondroIndex { return null; } + public Iterator rows(boolean up, boolean rotating) throws IOException { + // Objects are of type byte[][] + return null; + } } final class memprofiler extends Thread { diff --git a/source/de/anomic/kelondro/kelondroFScoreCluster.java b/source/de/anomic/kelondro/kelondroFScoreCluster.java index d7cf61ace..ccfe55b45 100644 --- a/source/de/anomic/kelondro/kelondroFScoreCluster.java +++ b/source/de/anomic/kelondro/kelondroFScoreCluster.java @@ -125,7 +125,7 @@ public class kelondroFScoreCluster { private class scoreIterator implements Iterator { // iteration of score objects - kelondroTree.rowIterator iterator; + Iterator iterator; public scoreIterator(boolean up, boolean rotating) throws IOException { iterator = countrefDB.rows(up, rotating); diff --git a/source/de/anomic/kelondro/kelondroIndex.java b/source/de/anomic/kelondro/kelondroIndex.java index 137652e20..18ae3ae3f 100644 --- a/source/de/anomic/kelondro/kelondroIndex.java +++ b/source/de/anomic/kelondro/kelondroIndex.java @@ -51,11 +51,12 @@ package de.anomic.kelondro; import java.io.IOException; +import java.util.Iterator; public interface kelondroIndex { public byte[][] get(byte[] key) throws IOException; public byte[][] put(byte[][] row) throws IOException; public byte[][] remove(byte[] key) throws IOException; - + public Iterator rows(boolean up, boolean rotating) throws IOException; // Objects are of type byte[][] } diff --git a/source/de/anomic/kelondro/kelondroTree.java b/source/de/anomic/kelondro/kelondroTree.java index df98b3199..69f090ae2 100644 --- a/source/de/anomic/kelondro/kelondroTree.java +++ b/source/de/anomic/kelondro/kelondroTree.java @@ -971,7 +971,7 @@ public class kelondroTree extends kelondroRecords implements Comparator, kelondr } } - public synchronized rowIterator rows(boolean up, boolean rotating) throws IOException { + public synchronized Iterator rows(boolean up, boolean rotating) throws IOException { // iterates the rows of the Nodes // enumerated objects are of type byte[][] // iterates the elements in a sorted way. diff --git a/source/de/anomic/plasma/plasmaCrawlEURL.java b/source/de/anomic/plasma/plasmaCrawlEURL.java index 0ebed064b..69940e15b 100644 --- a/source/de/anomic/plasma/plasmaCrawlEURL.java +++ b/source/de/anomic/plasma/plasmaCrawlEURL.java @@ -50,6 +50,7 @@ import java.util.Date; import java.util.Enumeration; import java.util.HashMap; import java.util.LinkedList; +import java.util.Iterator; import de.anomic.kelondro.kelondroTree; import de.anomic.server.serverCodings; @@ -257,7 +258,7 @@ public class plasmaCrawlEURL extends plasmaURL { public class kenum implements Enumeration { // enumerates entry elements - kelondroTree.rowIterator i; + Iterator i; public kenum(boolean up, boolean rotating) throws IOException { i = urlHashCache.rows(up, rotating); } diff --git a/source/de/anomic/plasma/plasmaCrawlLURL.java b/source/de/anomic/plasma/plasmaCrawlLURL.java index dbfd80d05..df13aca59 100644 --- a/source/de/anomic/plasma/plasmaCrawlLURL.java +++ b/source/de/anomic/plasma/plasmaCrawlLURL.java @@ -719,7 +719,7 @@ public final class plasmaCrawlLURL extends plasmaURL { public class kiter implements Iterator { // enumerates entry elements - kelondroTree.rowIterator i; + Iterator i; boolean error = false; public kiter(boolean up, boolean rotating) throws IOException {