Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
fix for last commit and more testing stub
orbiter84e37387a2e5
diff --git a/source/de/anomic/kelondro/index/Column.java b/source/de/anomic/kelondro/index/Column.javaindex b8848b1d8..16031fbdd 100644--- a/source/de/anomic/kelondro/index/Column.java+++ b/source/de/anomic/kelondro/index/Column.java@@ -43,8 +43,11 @@ public class Column {public static final int encoder_b256 = 2;public static final int encoder_bytes = 3;- public int celltype, cellwidth, encoder;- public String nickname, description;+ public int cellwidth;+ public final String nickname;+ protected final int celltype;+ protected final int encoder;+ protected final String description;public Column(final String nickname, final int celltype, final int encoder, final int cellwidth, final String description) {this.celltype = celltype;@@ -169,7 +172,7 @@ public class Column {else if (this.celltype == celltype_boolean) this.encoder = encoder_bytes;else if (this.celltype == celltype_binary) this.encoder = encoder_bytes;else if (this.celltype == celltype_string) this.encoder = encoder_bytes;- else if (this.celltype == celltype_cardinal) throw new kelondroException("kelondroColumn - encoder missing for cell " + this.nickname);+ else throw new kelondroException("kelondroColumn - encoder missing for cell " + this.nickname);}} else {if (this.celltype == celltype_cardinal) throw new kelondroException("kelondroColumn - encoder missing for cell " + this.nickname);@@ -188,12 +191,6 @@ public class Column {}}- public void setAttributes(final String nickname, final int celltype, final int encoder) {- this.celltype = celltype;- this.encoder = encoder;- this.nickname = nickname;- }-public String toString() {final StringBuilder s = new StringBuilder();switch (celltype) {diff --git a/source/de/anomic/kelondro/index/IntegerHandleIndex.java b/source/de/anomic/kelondro/index/IntegerHandleIndex.javaindex 76c576f2d..5e49f966a 100644--- a/source/de/anomic/kelondro/index/IntegerHandleIndex.java+++ b/source/de/anomic/kelondro/index/IntegerHandleIndex.java@@ -34,6 +34,7 @@ import java.io.InputStream;import java.io.OutputStream;import java.util.ArrayList;import java.util.Iterator;+import java.util.Random;import java.util.concurrent.ArrayBlockingQueue;import java.util.concurrent.BlockingQueue;import java.util.concurrent.Callable;@@ -42,8 +43,10 @@ import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;import java.util.concurrent.Future;+import de.anomic.kelondro.order.Base64Order;import de.anomic.kelondro.order.ByteOrder;import de.anomic.kelondro.order.CloneableIterator;+import de.anomic.yacy.dht.FlatWordPartitionScheme;public class IntegerHandleIndex {@@ -314,4 +317,19 @@ public class IntegerHandleIndex {}}++ public static void main(String[] args) {+ int count = (args.length == 0) ? 100000 : Integer.parseInt(args[0]);+ IntegerHandleIndex idx = new IntegerHandleIndex(12, Base64Order.enhancedCoder, 100000);+ Random r = new Random(0);+ long start = System.currentTimeMillis();+ try {+ for (int i = 0; i < count; i++) {+ idx.inc(FlatWordPartitionScheme.positionToHash(r.nextInt(count / 32)).getBytes());+ }+ } catch (IOException e) {+ e.printStackTrace();+ }+ System.out.println("Result: " + (((long) count) * 1000L / (System.currentTimeMillis() - start)) + " inc per second; " + count + " loops.");+ }}diff --git a/source/de/anomic/kelondro/index/Row.java b/source/de/anomic/kelondro/index/Row.javaindex 493f00adc..a6c4ae4c4 100644--- a/source/de/anomic/kelondro/index/Row.java+++ b/source/de/anomic/kelondro/index/Row.java@@ -63,7 +63,7 @@ public final class Row {this.colstart = new int[row.length];int os = 0;for (int i = 0; i < row.length; i++) {- this.colstart[i] = this.objectsize;+ this.colstart[i] = os;os+= this.row[i].cellwidth;}this.objectsize = os;@@ -97,7 +97,7 @@ public final class Row {this.colstart = new int[row.length];int os = 0;for (int i = 0; i < l.size(); i++) {- this.colstart[i] = this.objectsize;+ this.colstart[i] = os;this.row[i] = l.get(i);os += this.row[i].cellwidth;}diff --git a/source/de/anomic/kelondro/table/FlexTable.java b/source/de/anomic/kelondro/table/FlexTable.javaindex 3052adc05..2279649df 100644--- a/source/de/anomic/kelondro/table/FlexTable.java+++ b/source/de/anomic/kelondro/table/FlexTable.java@@ -73,7 +73,7 @@ public class FlexTable extends FlexWidthArray implements ObjectIndex {}minimumSpace = Math.max(minimumSpace, super.size());try {- final long neededRAM = 10 * 1024 * 104 + (long) ((super.row().column(0).cellwidth + 4) * minimumSpace * RowCollection.growfactor);+ final long neededRAM = 10 * 1024 * 104 + (long) ((super.row().primaryKeyLength + 4) * minimumSpace * RowCollection.growfactor);final File newpath = new File(path, tablename);final File indexfile = new File(newpath, "col.000.index");@@ -112,7 +112,7 @@ public class FlexTable extends FlexWidthArray implements ObjectIndex {} catch (final IOException e) {if (resetOnFail) {RAMIndex = true;- index = new IntegerHandleIndex(super.row().column(0).cellwidth, super.rowdef.objectOrder, 0);+ index = new IntegerHandleIndex(super.row().primaryKeyLength, super.rowdef.objectOrder, 0);} else {throw new kelondroException(e.getMessage());}@@ -122,7 +122,7 @@ public class FlexTable extends FlexWidthArray implements ObjectIndex {public void clear() throws IOException {super.reset();RAMIndex = true;- index = new IntegerHandleIndex(super.row().column(0).cellwidth, super.rowdef.objectOrder, 0);+ index = new IntegerHandleIndex(super.row().primaryKeyLength, super.rowdef.objectOrder, 0);}public static int staticSize(final File path, final String tablename) {@@ -130,7 +130,7 @@ public class FlexTable extends FlexWidthArray implements ObjectIndex {}public static int staticRAMIndexNeed(final File path, final String tablename, final Row rowdef) {- return (int) ((rowdef.column(0).cellwidth + 4) * staticSize(path, tablename) * RowCollection.growfactor);+ return (int) ((rowdef.primaryKeyLength + 4) * staticSize(path, tablename) * RowCollection.growfactor);}public boolean hasRAMIndex() {@@ -148,7 +148,7 @@ public class FlexTable extends FlexWidthArray implements ObjectIndex {private IntegerHandleIndex initializeRamIndex(final int initialSpace) {final int space = Math.max(super.col[0].size(), initialSpace) + 1;if (space < 0) throw new kelondroException("wrong space: " + space);- final IntegerHandleIndex ri = new IntegerHandleIndex(super.row().column(0).cellwidth, super.rowdef.objectOrder, space);+ final IntegerHandleIndex ri = new IntegerHandleIndex(super.row().primaryKeyLength, super.rowdef.objectOrder, space);final Iterator<Node> content = super.col[0].contentNodes(-1);Node node;int i;