Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
some redesign of the handling of the index for kelondroFlexTable
orbiter872eb46cb985
diff --git a/source/dbtest.java b/source/dbtest.javaindex 3324b1a1e..63e8514a6 100644--- a/source/dbtest.java+++ b/source/dbtest.java@@ -599,9 +599,9 @@ final class dbTable implements kelondroIndex {}}- public synchronized void putMultiple(List rows, Date entryDate) throws IOException {+ public synchronized void putMultiple(List rows) throws IOException {Iterator i = rows.iterator();- while (i.hasNext()) put((Entry) i.next(), entryDate);+ while (i.hasNext()) put((Entry) i.next());}public kelondroRow.Entry put(kelondroRow.Entry row, Date entryDate) throws IOException {@@ -644,7 +644,7 @@ final class dbTable implements kelondroIndex {throw new UnsupportedOperationException();}- public synchronized void addUniqueMultiple(List rows, Date entryDate) throws IOException {+ public synchronized void addUniqueMultiple(List rows) throws IOException {throw new UnsupportedOperationException();}diff --git a/source/de/anomic/kelondro/kelondroBytesIntMap.java b/source/de/anomic/kelondro/kelondroBytesIntMap.javaindex aa5a92e55..7cb5df5ce 100644--- a/source/de/anomic/kelondro/kelondroBytesIntMap.java+++ b/source/de/anomic/kelondro/kelondroBytesIntMap.java@@ -36,6 +36,10 @@ public class kelondroBytesIntMap {this.ki = ki;}+ public kelondroBytesIntMap(int keylength, kelondroOrder objectOrder, int space) {+ this.ki = new kelondroRowSet(new kelondroRow(new kelondroColumn[]{new kelondroColumn("key", kelondroColumn.celltype_binary, kelondroColumn.encoder_bytes, keylength, "key"), new kelondroColumn("int c-4 {b256}")}, objectOrder, 0), space);+ }+public kelondroRow row() throws IOException {return ki.row();}@@ -108,4 +112,12 @@ public class kelondroBytesIntMap {ki.close();}+ public synchronized void sort() {+ if (ki instanceof kelondroRowSet) ((kelondroRowSet) ki).sort();+ }++ public synchronized void uniq(long time) {+ if (ki instanceof kelondroRowSet) ((kelondroRowSet) ki).uniq(time);+ }+}diff --git a/source/de/anomic/kelondro/kelondroCache.java b/source/de/anomic/kelondro/kelondroCache.javaindex 30c817ea3..752ef7b32 100644--- a/source/de/anomic/kelondro/kelondroCache.java+++ b/source/de/anomic/kelondro/kelondroCache.java@@ -242,26 +242,35 @@ public class kelondroCache implements kelondroIndex {((writeBufferDoubles == null) ? 0 : writeBufferDoubles.size());}- private void checkMissSpace() {- if ((readMissCache != null) && (cacheGrowStatus() < 1)) {- readMissCache.clear();+ private boolean checkMissSpace() {+ // returns true if it is allowed to write into this cache+ if (cacheGrowStatus() < 1) {+ if (readMissCache != null) {+ readMissCache.clear();+ }+ return false;}+ return true;}- private void checkHitSpace() throws IOException {- int s = sumRecords();- if (cacheGrowStatus() < 2) {flushDoubles(s / 4); s = sumRecords();}- if (cacheGrowStatus() < 2) {flushUnique(s / 4); s = sumRecords();}- if ((cacheGrowStatus() < 2) && (readHitCache != null)) {- readHitCache.clear();- }- if (cacheGrowStatus() < 1) {+ private boolean checkHitSpace() throws IOException {+ // returns true if it is allowed to write into this cache+ int status = cacheGrowStatus();+ if (status < 1) {flushUnique();flushDoubles();if (readHitCache != null) {readHitCache.clear();}+ return false;+ }+ if (status < 2) {+ int s = sumRecords();+ flushDoubles(s / 4);+ flushUnique(s / 4);+ if (readHitCache != null) readHitCache.clear();}+ return true;}public synchronized void close() {@@ -327,15 +336,13 @@ public class kelondroCache implements kelondroIndex {entry = index.get(key);// learn from resultif (entry == null) {- checkMissSpace();- if (readMissCache != null) {+ if ((checkMissSpace()) && (readMissCache != null)) {kelondroRow.Entry dummy = readMissCache.put(readMissCache.row().newEntry(key));if (dummy == null) this.hasnotUnique++; else this.hasnotDouble++;}return null;} else {- checkHitSpace();- if (readHitCache != null) {+ if ((checkHitSpace()) && (readHitCache != null)) {kelondroRow.Entry dummy = readHitCache.put(entry);if (dummy == null) this.writeUnique++; else this.writeDouble++;}@@ -343,6 +350,11 @@ public class kelondroCache implements kelondroIndex {}}+ public synchronized void putMultiple(List rows) throws IOException {+ Iterator i = rows.iterator();+ while (i.hasNext()) put ((Entry) i.next());+ }+public synchronized void putMultiple(List rows, Date entryDate) throws IOException {Iterator i = rows.iterator();while (i.hasNext()) put ((Entry) i.next(), entryDate);@@ -443,6 +455,8 @@ public class kelondroCache implements kelondroIndex {// a put with a date is bad for the cache: the date cannot be handled// The write buffer does not work here, because it does not store dates.+ throw new UnsupportedOperationException("put with date is inefficient in kelondroCache");+ /*if (entryDate == null) return put(row);assert (row != null);@@ -467,6 +481,7 @@ public class kelondroCache implements kelondroIndex {if (dummy == null) this.writeUnique++; else this.writeDouble++;}return entry;+ */}public synchronized void addUnique(Entry row) throws IOException {@@ -543,9 +558,9 @@ public class kelondroCache implements kelondroIndex {}}- public synchronized void addUniqueMultiple(List rows, Date entryDate) throws IOException {+ public synchronized void addUniqueMultiple(List rows) throws IOException {Iterator i = rows.iterator();- while (i.hasNext()) addUnique((Entry) i.next(), entryDate);+ while (i.hasNext()) addUnique((Entry) i.next());}public synchronized Entry remove(byte[] key) throws IOException {diff --git a/source/de/anomic/kelondro/kelondroCollectionIndex.java b/source/de/anomic/kelondro/kelondroCollectionIndex.javaindex 2eaba5931..f3b485705 100644--- a/source/de/anomic/kelondro/kelondroCollectionIndex.java+++ b/source/de/anomic/kelondro/kelondroCollectionIndex.java@@ -30,7 +30,6 @@ import java.io.IOException;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Calendar;-import java.util.Date;import java.util.GregorianCalendar;import java.util.HashMap;import java.util.Iterator;@@ -200,6 +199,7 @@ public class kelondroCollectionIndex {long preloadTime, int loadfactor, kelondroRow rowdef) throws IOException {// open/create index tablekelondroIndex theindex = new kelondroCache(new kelondroFlexTable(path, filenameStub + ".index", preloadTime, indexRow(keylength, indexOrder), true), true, false);+ //kelondroIndex theindex = new kelondroFlexTable(path, filenameStub + ".index", preloadTime, indexRow(keylength, indexOrder), true);// save/check property file for this arrayFile propfile = propertyFile(path, filenameStub, loadfactor, rowdef.objectsize());@@ -672,8 +672,8 @@ public class kelondroCollectionIndex {}// write index entries- index.putMultiple(indexrows_existing, new Date()); // write modified indexrows in optimized manner- index.addUniqueMultiple(indexrows_new, new Date()); // write new indexrows in optimized manner+ index.putMultiple(indexrows_existing); // write modified indexrows in optimized manner+ index.addUniqueMultiple(indexrows_new); // write new indexrows in optimized manner}public synchronized void merge(indexContainer container) throws IOException, kelondroOutOfLimitsException {diff --git a/source/de/anomic/kelondro/kelondroFlexSplitTable.java b/source/de/anomic/kelondro/kelondroFlexSplitTable.javaindex 97560521b..3699f1653 100644--- a/source/de/anomic/kelondro/kelondroFlexSplitTable.java+++ b/source/de/anomic/kelondro/kelondroFlexSplitTable.java@@ -195,7 +195,7 @@ public class kelondroFlexSplitTable implements kelondroIndex {return (kelondroRow.Entry) keeper[1];}- public synchronized void putMultiple(List rows, Date entryDate) throws IOException {+ public synchronized void putMultiple(List rows) throws IOException {throw new UnsupportedOperationException("not yet implemented");}@@ -247,7 +247,12 @@ public class kelondroFlexSplitTable implements kelondroIndex {table = new kelondroFlexTable(path, tablename + "." + suffix, -1, rowdef, true);tables.put(suffix, table);}- table.addUnique(row, entryDate);+ table.addUnique(row);+ }++ public synchronized void addUniqueMultiple(List rows) throws IOException {+ Iterator i = rows.iterator();+ while (i.hasNext()) addUnique((kelondroRow.Entry) i.next());}public synchronized void addUniqueMultiple(List rows, Date entryDate) throws IOException {diff --git a/source/de/anomic/kelondro/kelondroFlexTable.java b/source/de/anomic/kelondro/kelondroFlexTable.javaindex 3f884d634..3e2c65310 100644--- a/source/de/anomic/kelondro/kelondroFlexTable.java+++ b/source/de/anomic/kelondro/kelondroFlexTable.java@@ -64,7 +64,6 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrFile newpath = new File(path, tablename);File indexfile = new File(newpath, "col.000.index");- kelondroIndex ki = null;String description = "";description = new String(this.col[0].getDescription());int p = description.indexOf(';', 4);@@ -84,21 +83,21 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr// fill the indexSystem.out.print("*** Loading RAM index for " + size() + " entries from "+ newpath);- ki = initializeRamIndex();+ index = initializeRamIndex();System.out.println(" -done-");- System.out.println(ki.size()+ System.out.println(index.size()+ " index entries initialized and sorted from "+ super.col[0].size() + " keys.");RAMIndex = true;- index = new kelondroBytesIntMap(ki);tableTracker.put(this.filename(), this);} else {// too less ram for a ram index+ kelondroIndex ki;if (indexfile.exists()) {// use existing index fileSystem.out.println("*** Using File index " + indexfile);- ki = new kelondroCache(kelondroTree.open(indexfile, true, preloadTime, treeIndexRow(rowdef.width(0), rowdef.objectOrder, rowdef.primaryKey), 2, 80), true, false);+ ki = new kelondroCache(kelondroTree.open(indexfile, true, preloadTime, treeIndexRow(rowdef.width(0), rowdef.objectOrder), 2, 80), true, false);RAMIndex = false;} else {// generate new index file@@ -120,11 +119,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr} catch (IOException e) {if (resetOnFail) {RAMIndex = true;- try {- index = new kelondroBytesIntMap(new kelondroRowSet(new kelondroRow(new kelondroColumn[]{super.row().column(0), new kelondroColumn("int c-4 {b256}")}, super.rowdef.objectOrder, super.rowdef.primaryKey), 100));- } catch (IOException e1) {- throw new kelondroException(e1.getMessage());- }+ index = new kelondroBytesIntMap(super.row().column(0).cellwidth(), super.rowdef.objectOrder, 0);} else {throw new kelondroException(e.getMessage());}@@ -134,7 +129,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrpublic void reset() throws IOException {super.reset();RAMIndex = true;- index = new kelondroBytesIntMap(new kelondroRowSet(new kelondroRow(new kelondroColumn[]{super.row().column(0), new kelondroColumn("int c-4 {b256}")}, super.rowdef.objectOrder, super.rowdef.primaryKey), 100));+ index = new kelondroBytesIntMap(super.row().column(0).cellwidth(), super.rowdef.objectOrder, 0);}public static int staticSize(File path, String tablename) {@@ -157,13 +152,12 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrreturn index.geti(key) >= 0;}- private kelondroIndex initializeRamIndex() {+ private kelondroBytesIntMap initializeRamIndex() {int space = super.col[0].size() + 1;if (space < 0) throw new kelondroException("wrong space: " + space);- kelondroRowSet ri = new kelondroRowSet(new kelondroRow(new kelondroColumn[]{super.row().column(0), new kelondroColumn("int c-4 {b256}")}, super.rowdef.objectOrder, super.rowdef.primaryKey), space);+ kelondroBytesIntMap ri = new kelondroBytesIntMap(super.row().column(0).cellwidth(), super.rowdef.objectOrder, space);Iterator content = super.col[0].contentNodes(-1);kelondroRecords.Node node;- kelondroRow.Entry indexentry;int i;byte[] key;while (content.hasNext()) {@@ -171,11 +165,8 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondri = node.handle().hashCode();key = node.getKey();assert (key != null) : "DEBUG: empty key in initializeRamIndex"; // should not happen; if it does, it is an error of the condentNodes iterator- indexentry = ri.row().newEntry();- indexentry.setCol(0, key);- indexentry.setCol(1, i);//System.out.println("ENTRY: " + serverLog.arrayList(indexentry.bytes(), 0, indexentry.objectsize()));- ri.addUnique(indexentry);+ try { ri.addi(key, i); } catch (IOException e) {} // no IOException can happen hereif ((i % 10000) == 0) {System.out.print('.');System.out.flush();@@ -191,7 +182,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr}private kelondroIndex initializeTreeIndex(File indexfile, long preloadTime, kelondroOrder objectOrder, int primaryKey) throws IOException {- kelondroIndex treeindex = new kelondroCache(new kelondroTree(indexfile, true, preloadTime, treeIndexRow(rowdef.width(0), objectOrder, primaryKey), 2, 80), true, false);+ kelondroIndex treeindex = new kelondroCache(new kelondroTree(indexfile, true, preloadTime, treeIndexRow(rowdef.width(0), objectOrder), 2, 80), true, false);Iterator content = super.col[0].contentNodes(-1);kelondroRecords.Node node;kelondroRow.Entry indexentry;@@ -215,8 +206,8 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrreturn treeindex;}- private static final kelondroRow treeIndexRow(int keywidth, kelondroOrder objectOrder, int primaryKey) {- return new kelondroRow("byte[] key-" + keywidth + ", int reference-4 {b256}", objectOrder, primaryKey);+ private static final kelondroRow treeIndexRow(int keywidth, kelondroOrder objectOrder) {+ return new kelondroRow("byte[] key-" + keywidth + ", int reference-4 {b256}", objectOrder, 0);}public synchronized kelondroRow.Entry get(byte[] key) throws IOException {@@ -232,7 +223,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrreturn result;}- public synchronized void putMultiple(List rows, Date entryDate) throws IOException {+ public synchronized void putMultiple(List rows) throws IOException {// put a list of entries in a ordered way.// this should save R/W head positioning timeIterator i = rows.iterator();@@ -256,7 +247,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrsuper.setMultiple(old_rows_ordered);// write new entries to index- addUniqueMultiple(new_rows_sequential, entryDate);+ addUniqueMultiple(new_rows_sequential);assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();}@@ -298,18 +289,13 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrreturn oldentry;}- public synchronized void addUnique(kelondroRow.Entry row, Date entryDate) throws IOException {- assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();- addUnique(row);- }-public synchronized void addUnique(kelondroRow.Entry row) throws IOException {assert row.objectsize() == this.rowdef.objectsize;assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();index.addi(row.getColBytes(0), super.add(row));}- public synchronized void addUniqueMultiple(List rows, Date entryDate) throws IOException {+ public synchronized void addUniqueMultiple(List rows) throws IOException {// add a list of entries in a ordered way.// this should save R/W head positioning timeTreeMap indexed_result = super.addMultiple(rows);diff --git a/source/de/anomic/kelondro/kelondroIndex.java b/source/de/anomic/kelondro/kelondroIndex.javaindex d44cfc090..c04082321 100644--- a/source/de/anomic/kelondro/kelondroIndex.java+++ b/source/de/anomic/kelondro/kelondroIndex.java@@ -64,10 +64,9 @@ public interface kelondroIndex {public kelondroRow.Entry get(byte[] key) throws IOException;public kelondroRow.Entry put(kelondroRow.Entry row) throws IOException;public kelondroRow.Entry put(kelondroRow.Entry row, Date entryDate) throws IOException;- public void putMultiple(List /* of kelondroRow.Entry*/ rows, Date entryDate) throws IOException; // for R/W head path optimization+ public void putMultiple(List /* of kelondroRow.Entry*/ rows) throws IOException; // for R/W head path optimizationpublic void addUnique(kelondroRow.Entry row) throws IOException; // no double-check- public void addUnique(kelondroRow.Entry row, Date entryDate) throws IOException; // no double-check- public void addUniqueMultiple(List /* of kelondroRow.Entry*/ rows, Date entryDate) throws IOException; // no double-check+ public void addUniqueMultiple(List /* of kelondroRow.Entry*/ rows) throws IOException; // no double-checkpublic kelondroRow.Entry remove(byte[] key) throws IOException;public kelondroRow.Entry removeOne() throws IOException;public kelondroCloneableIterator rows(boolean up, byte[] firstKey) throws IOException;diff --git a/source/de/anomic/kelondro/kelondroRowCollection.java b/source/de/anomic/kelondro/kelondroRowCollection.javaindex fa29055b6..fc017a5ab 100644--- a/source/de/anomic/kelondro/kelondroRowCollection.java+++ b/source/de/anomic/kelondro/kelondroRowCollection.java@@ -26,7 +26,6 @@ package de.anomic.kelondro;import java.io.File;import java.io.IOException;-import java.util.Date;import java.util.Iterator;import java.util.List;import java.util.Set;@@ -182,7 +181,68 @@ public class kelondroRowCollection {chunkcache = newChunkcache;newChunkcache = null;}+ /*+ private static final Object[] arraydepot = new Object[]{new byte[0]};+ private final void ensureSize(int elements) {+ int needed = elements * rowdef.objectsize();+ if (chunkcache.length >= needed) return;+ long neededRAM = (long) (needed * growfactor);+ long availableRAM = serverMemory.available();+ //if ((safemode) && (neededRAM > availableRAM)) throw new kelondroMemoryProtectionException("rowCollection temporary chunkcache", neededRAM, availableRAM);++ if (neededRAM > availableRAM) {+ // go into safe mode: use the arraydepot+ synchronized (arraydepot) {+ if (((byte[]) arraydepot[0]).length >= neededRAM) {+ System.out.println("ensureSize case 1");+ // use the depot to increase the chunkcache+ byte[] newChunkcache = (byte[]) arraydepot[0];+ System.arraycopy(chunkcache, 0, newChunkcache, 0, chunkcache.length);+ // safe the chunkcache for later use in arraydepot+ arraydepot[0] = chunkcache;+ chunkcache = newChunkcache;+ newChunkcache = null;+ } else {+ System.out.println("ensureSize case 2");+ // this is the critical part: we need more RAM.+ // do a buffering using the arraydepot+ byte[] buffer0 = (byte[]) arraydepot[0];+ byte[] buffer1 = new byte[chunkcache.length - buffer0.length];+ // first copy the previous chunkcache to the two buffers+ System.arraycopy(chunkcache, 0, buffer0, 0, buffer0.length);+ System.arraycopy(chunkcache, buffer0.length, buffer1, 0, buffer1.length);+ // then free the previous chunkcache and replace it with a new array at target size+ chunkcache = null; // hand this over to GC+ chunkcache = new byte[(int) neededRAM];+ System.arraycopy(buffer0, 0, chunkcache, 0, buffer0.length);+ System.arraycopy(buffer1, 0, chunkcache, buffer0.length, buffer1.length);+ // then move the bigger buffer into the arraydepot+ if (buffer0.length > buffer1.length) {+ arraydepot[0] = buffer0;+ } else {+ arraydepot[1] = buffer1;+ }+ buffer0 = null;+ buffer1 = null;+ }+ }+ } else {+ // there is enough memory available+ byte[] newChunkcache = new byte[(int) neededRAM]; // increase space+ System.arraycopy(chunkcache, 0, newChunkcache, 0, chunkcache.length);+ // safe the chunkcache for later use in arraydepot+ synchronized (arraydepot) {+ if (((byte[]) arraydepot[0]).length < chunkcache.length) {+ System.out.println("ensureSize case 0");+ arraydepot[0] = chunkcache;+ }+ }+ chunkcache = newChunkcache;+ newChunkcache = null;+ }+ }+ */public final long memoryNeededForGrow() {return (long) ((((long) (chunkcount + 1)) * ((long) rowdef.objectsize())) * growfactor);}@@ -235,15 +295,12 @@ public class kelondroRowCollection {}public synchronized void addUnique(kelondroRow.Entry row) {- byte[] r = row.bytes();+ byte[] r = row.bytes();addUnique(r, 0, r.length);}-- public synchronized void addUnique(kelondroRow.Entry row, Date entryDate) {- addUnique(row);- }- public synchronized void addUniqueMultiple(List rows, Date entryDate) throws IOException {+ public synchronized void addUniqueMultiple(List rows) throws IOException {+ assert this.sortBound == 0 : "sortBound = " + this.sortBound + ", chunkcount = " + this.chunkcount;Iterator i = rows.iterator();while (i.hasNext()) addUnique((kelondroRow.Entry) i.next());}@@ -325,6 +382,7 @@ public class kelondroRowCollection {}public synchronized void clear() {+ if (this.chunkcache.length == 0) return;this.chunkcache = new byte[0];this.chunkcount = 0;this.sortBound = 0;diff --git a/source/de/anomic/kelondro/kelondroRowSet.java b/source/de/anomic/kelondro/kelondroRowSet.javaindex d5af7e5d0..838839e29 100644--- a/source/de/anomic/kelondro/kelondroRowSet.java+++ b/source/de/anomic/kelondro/kelondroRowSet.java@@ -92,9 +92,9 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndreturn entry;}- public synchronized void putMultiple(List rows, Date entryDate) throws IOException {+ public synchronized void putMultiple(List rows) throws IOException {Iterator i = rows.iterator();- while (i.hasNext()) put((kelondroRow.Entry) i.next(), entryDate);+ while (i.hasNext()) put((kelondroRow.Entry) i.next());}public kelondroRow.Entry put(kelondroRow.Entry row, Date entryDate) {@@ -127,6 +127,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndsuper.removeRow(index);//System.out.println("remove: chunk found at index position (after remove) " + index + ", inset=" + serverLog.arrayList(super.chunkcache, super.rowdef.objectsize() * index, length) + ", searchkey=" + serverLog.arrayList(a, start, length));int findagainindex = find(a, start, length);+ //System.out.println("kelondroRowSet.remove");assert findagainindex < 0 : "remove: chunk found again at index position (after remove) " + findagainindex + ", index(before) = " + index + ", inset=" + serverLog.arrayList(super.chunkcache, super.rowdef.objectsize() * findagainindex, length) + ", searchkey=" + serverLog.arrayList(a, start, length); // check if the remove workedreturn entry;}@@ -212,6 +213,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd}public synchronized Iterator rows() {+ // iterates kelondroRow.Entry - type entriessort();return super.rows();}@@ -267,6 +269,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndpublic static void main(String[] args) {// sort/uniq-test+ /*kelondroRow rowdef = new kelondroRow("Cardinal key-4 {b256}, byte[] payload-1", kelondroNaturalOrder.naturalOrder, 0);kelondroRowSet rs = new kelondroRowSet(rowdef, 0);Random random = new Random(0);@@ -282,32 +285,34 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndSystem.out.println("after sort, before uniq, size = " + rs.size());rs.uniq(10000);System.out.println("after uniq, size = " + rs.size());+ */- /*String[] test = { "eins", "zwei", "drei", "vier", "fuenf", "sechs", "sieben", "acht", "neun", "zehn" };- kelondroRowSet c = new kelondroRowSet(new kelondroRow(new int[]{10, 3}));- c.setOrdering(kelondroNaturalOrder.naturalOrder, 0);- for (int i = 0; i < test.length; i++) c.add(test[i].getBytes());- for (int i = 0; i < test.length; i++) c.add(test[i].getBytes());- c.shape();- c.removeMarked("fuenf".getBytes(), 0, 5);- Iterator i = c.elements();+ kelondroRowSet d = new kelondroRowSet(new kelondroRow("byte[] key-10, Cardinal x-4 {b256}", kelondroNaturalOrder.naturalOrder, 0), 0);+ d.setOrdering(kelondroNaturalOrder.naturalOrder, 0);+ for (int ii = 0; ii < test.length; ii++) d.add(test[ii].getBytes());+ for (int ii = 0; ii < test.length; ii++) d.add(test[ii].getBytes());+ d.sort();+ d.remove("fuenf".getBytes(), 0, 5);+ Iterator ii = d.rows();String s;System.out.print("INPUT-ITERATOR: ");- while (i.hasNext()) {- s = new String((byte[]) i.next()).trim();+ kelondroRow.Entry entry;+ while (ii.hasNext()) {+ entry = (kelondroRow.Entry) ii.next();+ s = new String((byte[]) entry.getColBytes(0)).trim();System.out.print(s + ", ");- if (s.equals("drei")) i.remove();+ if (s.equals("drei")) ii.remove();}System.out.println("");- System.out.println("INPUT-TOSTRING: " + c.toString());- c.shape();- System.out.println("SORTED : " + c.toString());- c.uniq();- System.out.println("UNIQ : " + c.toString());- c.trim();- System.out.println("TRIM : " + c.toString());- */+ System.out.println("INPUT-TOSTRING: " + d.toString());+ d.sort();+ System.out.println("SORTED : " + d.toString());+ d.uniq(10000);+ System.out.println("UNIQ : " + d.toString());+ d.trim(false);+ System.out.println("TRIM : " + d.toString());+/*// second test@@ -375,7 +380,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndbyte[] key;int testsize = 5000;byte[][] delkeys = new byte[testsize / 5][];- random = new Random(0);+ Random random = new Random(0);for (int i = 0; i < testsize; i++) {key = randomHash(random);if (i % 5 != 0) continue;diff --git a/source/de/anomic/kelondro/kelondroSplittedTree.java b/source/de/anomic/kelondro/kelondroSplittedTree.javaindex 01643fd14..548e976ce 100644--- a/source/de/anomic/kelondro/kelondroSplittedTree.java+++ b/source/de/anomic/kelondro/kelondroSplittedTree.java@@ -118,7 +118,7 @@ public class kelondroSplittedTree implements kelondroIndex {return ktfs[partition(key)].get(key);}- public synchronized void putMultiple(List rows, Date entryDate) throws IOException {+ public synchronized void putMultiple(List rows) throws IOException {Iterator i = rows.iterator();kelondroRow.Entry row;ArrayList[] parts = new ArrayList[ktfs.length];@@ -127,7 +127,7 @@ public class kelondroSplittedTree implements kelondroIndex {row = (kelondroRow.Entry) i.next();parts[partition(row.getColBytes(0))].add(row);}- for (int j = 0; j < ktfs.length; j++) ktfs[j].putMultiple(parts[j], entryDate);+ for (int j = 0; j < ktfs.length; j++) ktfs[j].putMultiple(parts[j]);}public kelondroRow.Entry put(kelondroRow.Entry row, Date entryDate) throws IOException {@@ -142,7 +142,7 @@ public class kelondroSplittedTree implements kelondroIndex {throw new UnsupportedOperationException();}- public synchronized void addUniqueMultiple(List rows, Date entryDate) throws IOException {+ public synchronized void addUniqueMultiple(List rows) throws IOException {throw new UnsupportedOperationException();}diff --git a/source/de/anomic/kelondro/kelondroTree.java b/source/de/anomic/kelondro/kelondroTree.javaindex 2a70faf06..caded0e96 100644--- a/source/de/anomic/kelondro/kelondroTree.java+++ b/source/de/anomic/kelondro/kelondroTree.java@@ -333,9 +333,9 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {return (lc.equals(childn.handle()));}- public synchronized void putMultiple(List rows, Date entryDate) throws IOException {+ public synchronized void putMultiple(List rows) throws IOException {Iterator i = rows.iterator();- while (i.hasNext()) put ((Entry) i.next(), entryDate);+ while (i.hasNext()) put ((Entry) i.next());}public kelondroRow.Entry put(kelondroRow.Entry row, Date entryDate) throws IOException {@@ -491,9 +491,9 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {this.put(row, entryDate);}- public synchronized void addUniqueMultiple(List rows, Date entryDate) throws IOException {+ public synchronized void addUniqueMultiple(List rows) throws IOException {Iterator i = rows.iterator();- while (i.hasNext()) addUnique((kelondroRow.Entry) i.next(), entryDate);+ while (i.hasNext()) addUnique((kelondroRow.Entry) i.next());}private void assignChild(Node parentNode, Node childNode, int childType) throws IOException {