Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
- generalized object order handling - controlled object order for all database tables - migrated DHT position computation to correct base64-decoded values this also closed the 'gaps' in the dht positions
orbiter773ba1e91aa7
diff --git a/htroot/Surftips.java b/htroot/Surftips.javaindex a6ac74347..2dff88b15 100644--- a/htroot/Surftips.java+++ b/htroot/Surftips.java@@ -34,6 +34,7 @@ import de.anomic.http.httpHeader;import de.anomic.plasma.plasmaURL;import de.anomic.kelondro.kelondroMScoreCluster;import de.anomic.kelondro.kelondroRow;+import de.anomic.kelondro.kelondroNaturalOrder;import de.anomic.plasma.plasmaSwitchboard;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;@@ -106,7 +107,7 @@ public class Surftips {//accumulateVotes(negativeHashes, positiveHashes, yacyNewsPool.OUTGOING_DB);//accumulateVotes(negativeHashes, positiveHashes, yacyNewsPool.PUBLISHED_DB);kelondroMScoreCluster ranking = new kelondroMScoreCluster(); // score cluster for url hashes- kelondroRow rowdef = new kelondroRow("String url-255, String title-120, String description-120, String refid-" + (yacyCore.universalDateShortPattern.length() + 12));+ kelondroRow rowdef = new kelondroRow("String url-255, String title-120, String description-120, String refid-" + (yacyCore.universalDateShortPattern.length() + 12), kelondroNaturalOrder.naturalOrder, 0);HashMap surftips = new HashMap(); // a mapping from an url hash to a kelondroRow.Entry with display propertiesaccumulateSurftips(surftips, ranking, rowdef, negativeHashes, positiveHashes, yacyNewsPool.INCOMING_DB);//accumulateSurftips(surftips, ranking, rowdef, negativeHashes, positiveHashes, yacyNewsPool.OUTGOING_DB);diff --git a/source/dbtest.java b/source/dbtest.javaindex c3ba0844d..5c2b690f3 100644--- a/source/dbtest.java+++ b/source/dbtest.java@@ -172,7 +172,7 @@ public class dbtest {profiler.start();// create the database access- kelondroRow testRow = new kelondroRow("byte[] key-" + keylength + ", byte[] dummy-" + keylength + ", value-" + valuelength);+ kelondroRow testRow = new kelondroRow("byte[] key-" + keylength + ", byte[] dummy-" + keylength + ", value-" + valuelength, kelondroBase64Order.enhancedCoder, 0);if (dbe.equals("kelondroTree")) {File tablefile = new File(tablename + ".kelondro.db");table = new kelondroCache(new kelondroTree(tablefile, buffer / 2, preload, testRow), buffer / 2, true, false);@@ -186,11 +186,11 @@ public class dbtest {}if (dbe.equals("kelondroFlexTable")) {File tablepath = new File(tablename).getParentFile();- table = new kelondroFlexTable(tablepath, new File(tablename).getName(), buffer, preload, testRow, kelondroBase64Order.enhancedCoder);+ table = new kelondroFlexTable(tablepath, new File(tablename).getName(), buffer, preload, testRow);}if (dbe.equals("kelondroFlexSplitTable")) {File tablepath = new File(tablename).getParentFile();- table = new kelondroFlexSplitTable(tablepath, new File(tablename).getName(), buffer, preload, testRow, kelondroBase64Order.enhancedCoder);+ table = new kelondroFlexSplitTable(tablepath, new File(tablename).getName(), buffer, preload, testRow);}if (dbe.equals("mysql")) {table = new dbTable("mysql", testRow);diff --git a/source/de/anomic/index/indexCachedRI.java b/source/de/anomic/index/indexCachedRI.javaindex 40bc468a3..b412be81c 100644--- a/source/de/anomic/index/indexCachedRI.java+++ b/source/de/anomic/index/indexCachedRI.java@@ -34,7 +34,6 @@ import java.util.Set;import java.util.TreeSet;import de.anomic.kelondro.kelondroMergeIterator;-import de.anomic.kelondro.kelondroNaturalOrder;import de.anomic.kelondro.kelondroOrder;import de.anomic.kelondro.kelondroRow;import de.anomic.server.logging.serverLog;@@ -270,7 +269,7 @@ public class indexCachedRI implements indexRI {return new kelondroMergeIterator(riExtern.wordContainers(startHash, false),backend.wordContainers(startHash, false),- new indexContainerOrder(kelondroNaturalOrder.naturalOrder),+ new indexContainerOrder(this.indexOrder),indexContainer.containerMergeMethod,true);}diff --git a/source/de/anomic/index/indexContainer.java b/source/de/anomic/index/indexContainer.javaindex dc8fe5960..499ba36b0 100644--- a/source/de/anomic/index/indexContainer.java+++ b/source/de/anomic/index/indexContainer.java@@ -35,7 +35,6 @@ import java.util.TreeMap;import de.anomic.kelondro.kelondroBase64Order;import de.anomic.kelondro.kelondroException;-import de.anomic.kelondro.kelondroOrder;import de.anomic.kelondro.kelondroRow;import de.anomic.kelondro.kelondroRowSet;@@ -43,23 +42,19 @@ public class indexContainer extends kelondroRowSet {private String wordHash;- public indexContainer(String wordHash, kelondroRow rowdef) {- this(wordHash, rowdef, kelondroBase64Order.enhancedCoder, 0);- }-public indexContainer(String wordHash, kelondroRowSet collection) {super(collection);this.wordHash = wordHash;}- public indexContainer(String wordHash, kelondroRow rowdef, kelondroOrder ordering, int column) {- super(rowdef, ordering, column, 0);+ public indexContainer(String wordHash, kelondroRow rowdef) {+ super(rowdef, 0);this.wordHash = wordHash;this.lastTimeWrote = 0;}public indexContainer topLevelClone() {- indexContainer newContainer = new indexContainer(this.wordHash, this.rowdef, this.sortOrder, this.sortColumn);+ indexContainer newContainer = new indexContainer(this.wordHash, this.rowdef);newContainer.add(this, -1);return newContainer;}@@ -317,8 +312,8 @@ public class indexContainer extends kelondroRowSet {int keylength = i1.rowdef.width(0);assert (keylength == i2.rowdef.width(0));indexContainer conj = new indexContainer(null, i1.rowdef); // start with empty search result- if (!((i1.order().signature().equals(i2.order().signature())) &&- (i1.primarykey() == i2.primarykey()))) return conj; // ordering must be equal+ if (!((i1.rowdef.getOrdering().signature().equals(i2.rowdef.getOrdering().signature())) &&+ (i1.rowdef.primaryKey() == i2.rowdef.primaryKey()))) return conj; // ordering must be equalIterator e1 = i1.entries();Iterator e2 = i2.entries();int c;@@ -332,7 +327,7 @@ public class indexContainer extends kelondroRowSet {while ((System.currentTimeMillis() - stamp) < time) {assert (ie1.urlHash().length() == keylength) : "ie1.urlHash() = " + ie1.urlHash();assert (ie2.urlHash().length() == keylength) : "ie2.urlHash() = " + ie2.urlHash();- c = i1.order().compare(ie1.urlHash(), ie2.urlHash());+ c = i1.rowdef.getOrdering().compare(ie1.urlHash(), ie2.urlHash());//System.out.println("** '" + ie1.getUrlHash() + "'.compareTo('" + ie2.getUrlHash() + "')="+c);if (c < 0) {if (e1.hasNext()) ie1 = (indexRWIEntry) e1.next(); else break;diff --git a/source/de/anomic/index/indexRAMRI.java b/source/de/anomic/index/indexRAMRI.javaindex 8d20646dc..70c7c323e 100644--- a/source/de/anomic/index/indexRAMRI.java+++ b/source/de/anomic/index/indexRAMRI.java@@ -33,6 +33,7 @@ import java.util.Map;import java.util.Set;import java.util.TreeMap;+import de.anomic.kelondro.kelondroBase64Order;import de.anomic.kelondro.kelondroException;import de.anomic.kelondro.kelondroFixedWidthArray;import de.anomic.kelondro.kelondroMScoreCluster;@@ -84,7 +85,8 @@ public final class indexRAMRI implements indexRI {"byte[] wordhash-" + yacySeedDB.commonHashLength + ", " +"Cardinal occ-4 {b256}, " +"Cardinal time-8 {b256}, " +- "byte[] urlprops-" + payloadrow.objectsize());+ "byte[] urlprops-" + payloadrow.objectsize(),+ kelondroBase64Order.enhancedCoder, 0);// read in dump of last sessiontry {diff --git a/source/de/anomic/index/indexRWIEntryNew.java b/source/de/anomic/index/indexRWIEntryNew.javaindex 549c0791f..d9eae2d2f 100644--- a/source/de/anomic/index/indexRWIEntryNew.java+++ b/source/de/anomic/index/indexRWIEntryNew.java@@ -27,6 +27,7 @@package de.anomic.index;+import de.anomic.kelondro.kelondroBase64Order;import de.anomic.kelondro.kelondroBitfield;import de.anomic.kelondro.kelondroColumn;import de.anomic.kelondro.kelondroException;@@ -62,7 +63,9 @@ public class indexRWIEntryNew implements Cloneable, indexRWIEntry {new kelondroColumn("o", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "posofphrase"),new kelondroColumn("i", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "worddistance"),new kelondroColumn("k", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "reserve")- });+ },+ kelondroBase64Order.enhancedCoder,+ 0);// available chars: b,e,j,q// static propertiesdiff --git a/source/de/anomic/index/indexRWIEntryOld.java b/source/de/anomic/index/indexRWIEntryOld.javaindex cb090d988..25f3a93a8 100644--- a/source/de/anomic/index/indexRWIEntryOld.java+++ b/source/de/anomic/index/indexRWIEntryOld.java@@ -27,6 +27,7 @@package de.anomic.index;+import de.anomic.kelondro.kelondroBase64Order;import de.anomic.kelondro.kelondroBitfield;import de.anomic.kelondro.kelondroColumn;import de.anomic.kelondro.kelondroRow;@@ -55,7 +56,9 @@ public class indexRWIEntryOld implements Cloneable, indexRWIEntry {new kelondroColumn("i", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b64e, 2, "worddistance"),new kelondroColumn("w", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b64e, 2, "wordcount"),new kelondroColumn("p", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b64e, 2, "phrasecount")- });+ },+ kelondroBase64Order.enhancedCoder,+ 0);private static final int col_urlhash = 0;private static final int col_quality = 1;diff --git a/source/de/anomic/index/indexURLEntryNew.java b/source/de/anomic/index/indexURLEntryNew.javaindex 809b5cc20..65616db11 100644--- a/source/de/anomic/index/indexURLEntryNew.java+++ b/source/de/anomic/index/indexURLEntryNew.java@@ -42,7 +42,9 @@ public class indexURLEntryNew implements indexURLEntry {"Cardinal limage-2 {b256}, " + // # of embedded image links"Cardinal laudio-2 {b256}, " + // # of embedded audio links; for audio: track number; for video: number of audio tracks"Cardinal lvideo-2 {b256}, " + // # of embedded video links- "Cardinal lapp-2 {b256}"); // # of embedded links to applications+ "Cardinal lapp-2 {b256}", // # of embedded links to applications+ kelondroBase64Order.enhancedCoder,+ 0);private static final int col_hash = 0;private static final int col_comp = 1;diff --git a/source/de/anomic/index/indexURLEntryOld.java b/source/de/anomic/index/indexURLEntryOld.javaindex c71e5a8e5..601fdc18d 100644--- a/source/de/anomic/index/indexURLEntryOld.java+++ b/source/de/anomic/index/indexURLEntryOld.java@@ -56,7 +56,9 @@ public class indexURLEntryOld implements indexURLEntry {"String language-2, " + // language key; mainly the TDL"byte[] doctype-1, " + //"Cardinal size-6 {b64e}, " + // size of file in bytes- "Cardinal wc-3 {b64e}"); // word count+ "Cardinal wc-3 {b64e}", // word count+ kelondroBase64Order.enhancedCoder,+ 0);private URL url;private String descr;diff --git a/source/de/anomic/kelondro/kelondroAbstractOrder.java b/source/de/anomic/kelondro/kelondroAbstractOrder.javaindex 2dc6f03eb..4b8e5e07d 100644--- a/source/de/anomic/kelondro/kelondroAbstractOrder.java+++ b/source/de/anomic/kelondro/kelondroAbstractOrder.java@@ -85,6 +85,7 @@ public abstract class kelondroAbstractOrder implements kelondroOrder {}public boolean equals(kelondroOrder otherOrder) {+ if (otherOrder == null) return false;String thisSig = this.signature();String otherSig = otherOrder.signature();if ((thisSig == null) || (otherSig == null)) return false;diff --git a/source/de/anomic/kelondro/kelondroAttrSeq.java b/source/de/anomic/kelondro/kelondroAttrSeq.javaindex 1d358b718..b1abddbab 100644--- a/source/de/anomic/kelondro/kelondroAttrSeq.java+++ b/source/de/anomic/kelondro/kelondroAttrSeq.java@@ -335,7 +335,7 @@ public class kelondroAttrSeq {rowdef.append('-');rowdef.append(seq_len[i]);}- seqrow = new kelondroRow(new String(rowdef));+ seqrow = new kelondroRow(new String(rowdef), null, 0);}public String toString() {diff --git a/source/de/anomic/kelondro/kelondroBytesIntMap.java b/source/de/anomic/kelondro/kelondroBytesIntMap.javaindex bcfbc17be..40afc43f9 100644--- a/source/de/anomic/kelondro/kelondroBytesIntMap.java+++ b/source/de/anomic/kelondro/kelondroBytesIntMap.java@@ -95,10 +95,6 @@ public class kelondroBytesIntMap {return ki.rows(up, rotating, firstKey);}- public kelondroOrder order() {- return ki.order();- }-public kelondroProfile profile() {return ki.profile();}diff --git a/source/de/anomic/kelondro/kelondroCache.java b/source/de/anomic/kelondro/kelondroCache.javaindex bfe93859c..1e7aeaf39 100644--- a/source/de/anomic/kelondro/kelondroCache.java+++ b/source/de/anomic/kelondro/kelondroCache.java@@ -57,13 +57,13 @@ public class kelondroCache implements kelondroIndex {public kelondroCache(kelondroIndex backupIndex, long buffersize, boolean read, boolean write) throws IOException {assert write == false;this.index = backupIndex;- this.keyrow = new kelondroRow(new kelondroColumn[]{index.row().column(index.primarykey())});- this.readHitCache = (read) ? new kelondroRowSet(index.row(), backupIndex.order(), backupIndex.primarykey(), 0) : null;- this.readMissCache = (read) ? new kelondroRowSet(this.keyrow, backupIndex.order(), backupIndex.primarykey(), 0) : null;- this.writeBufferUnique = (write) ? new kelondroRowSet(index.row(), backupIndex.order(), backupIndex.primarykey(), 0) : null;- this.writeBufferDoubles = (write) ? new kelondroRowSet(index.row(), backupIndex.order(), backupIndex.primarykey(), 0) : null;- this.maxmiss = (read) ? (int) (buffersize / 10 / index.row().column(index.primarykey()).cellwidth()) : 0;- this.maxrecords = (int) ((buffersize - maxmiss * index.row().column(index.primarykey()).cellwidth()) / index.row().objectsize());+ this.keyrow = new kelondroRow(new kelondroColumn[]{index.row().column(index.row().primaryKey)}, index.row().objectOrder, index.row().primaryKey);+ this.readHitCache = (read) ? new kelondroRowSet(index.row(), 0) : null;+ this.readMissCache = (read) ? new kelondroRowSet(this.keyrow, 0) : null;+ this.writeBufferUnique = (write) ? new kelondroRowSet(index.row(), 0) : null;+ this.writeBufferDoubles = (write) ? new kelondroRowSet(index.row(), 0) : null;+ this.maxmiss = (read) ? (int) (buffersize / 10 / index.row().column(index.row().primaryKey).cellwidth()) : 0;+ this.maxrecords = (int) ((buffersize - maxmiss * index.row().column(index.row().primaryKey).cellwidth()) / index.row().objectsize());this.readHit = 0;this.readMiss = 0;this.writeUnique = 0;@@ -184,7 +184,7 @@ public class kelondroCache implements kelondroIndex {kelondroRow.Entry row;while ((i.hasNext()) && (maxcount-- > 0)) {row = (kelondroRow.Entry) i.next();- delete.add(row.getColBytes(index.primarykey()));+ delete.add(row.getColBytes(index.row().primaryKey));this.index.addUnique(row);this.cacheFlush++;}@@ -217,7 +217,7 @@ public class kelondroCache implements kelondroIndex {kelondroRow.Entry row;while ((i.hasNext()) && (maxcount-- > 0)) {row = (kelondroRow.Entry) i.next();- delete.add(row.getColBytes(index.primarykey()));+ delete.add(row.getColBytes(index.row().primaryKey));this.index.addUnique(row);this.cacheFlush++;}@@ -335,20 +335,12 @@ public class kelondroCache implements kelondroIndex {}}- public kelondroOrder order() {- return index.order();- }-- public int primarykey() {- return index.primarykey();- }-public synchronized Entry put(Entry row) throws IOException {assert (row != null);assert (row.columns() == row().columns());//assert (!(serverLog.allZero(row.getColBytes(index.primarykey()))));- byte[] key = row.getColBytes(index.primarykey());+ byte[] key = row.getColBytes(index.row().primaryKey);checkHitSpace();// remove entry from miss- and hit-cache@@ -446,7 +438,7 @@ public class kelondroCache implements kelondroIndex {assert (writeBufferUnique == null);assert (writeBufferDoubles == null);- byte[] key = row.getColBytes(index.primarykey());+ byte[] key = row.getColBytes(index.row().primaryKey);checkHitSpace();// remove entry from miss- and hit-cache@@ -469,7 +461,7 @@ public class kelondroCache implements kelondroIndex {assert (row.columns() == row().columns());//assert (!(serverLog.allZero(row.getColBytes(index.primarykey()))));- byte[] key = row.getColBytes(index.primarykey());+ byte[] key = row.getColBytes(index.row().primaryKey);checkHitSpace();// remove entry from miss- and hit-cache@@ -521,7 +513,7 @@ public class kelondroCache implements kelondroIndex {assert (writeBufferUnique == null);assert (writeBufferDoubles == null);- byte[] key = row.getColBytes(index.primarykey());+ byte[] key = row.getColBytes(index.row().primaryKey);checkHitSpace();// remove entry from miss- and hit-cache@@ -591,7 +583,7 @@ public class kelondroCache implements kelondroIndex {if ((writeBufferUnique != null) && (writeBufferUnique.size() > 0)) {Entry entry = writeBufferUnique.removeOne();if (readMissCache != null) {- kelondroRow.Entry dummy = readMissCache.put(readMissCache.row().newEntry(entry.getColBytes(index.primarykey())));+ kelondroRow.Entry dummy = readMissCache.put(readMissCache.row().newEntry(entry.getColBytes(index.row().primaryKey)));if (dummy == null) this.hasnotUnique++; else this.hasnotDouble++;}return entry;@@ -599,7 +591,7 @@ public class kelondroCache implements kelondroIndex {if ((writeBufferDoubles != null) && (writeBufferDoubles.size() > 0)) {Entry entry = writeBufferDoubles.removeOne();- byte[] key = entry.getColBytes(index.primarykey());+ byte[] key = entry.getColBytes(index.row().primaryKey);if (readMissCache != null) {kelondroRow.Entry dummy = readMissCache.put(readMissCache.row().newEntry(key));if (dummy == null) this.hasnotUnique++; else this.hasnotDouble++;@@ -610,7 +602,7 @@ public class kelondroCache implements kelondroIndex {Entry entry = index.removeOne();if (entry == null) return null;- byte[] key = entry.getColBytes(index.primarykey());+ byte[] key = entry.getColBytes(index.row().primaryKey);if (readMissCache != null) {kelondroRow.Entry dummy = readMissCache.put(readMissCache.row().newEntry(key));if (dummy == null) this.hasnotUnique++; else this.hasnotDouble++;diff --git a/source/de/anomic/kelondro/kelondroCollectionIndex.java b/source/de/anomic/kelondro/kelondroCollectionIndex.javaindex 9d90484bf..3b7671021 100644--- a/source/de/anomic/kelondro/kelondroCollectionIndex.java+++ b/source/de/anomic/kelondro/kelondroCollectionIndex.java@@ -55,7 +55,7 @@ public class kelondroCollectionIndex {private static final int idx_col_lastread = 6; // a time stamp, update time in days since 1.1.2000private static final int idx_col_lastwrote = 7; // a time stamp, update time in days since 1.1.2000- private kelondroRow indexRow() {+ private static kelondroRow indexRow(int keylength, kelondroOrder payloadOrder) {return new kelondroRow("byte[] key-" + keylength + "," +"int chunksize-4 {b256}," +@@ -64,7 +64,8 @@ public class kelondroCollectionIndex {"byte flags-1 {b256}," +"int indexpos-4 {b256}," +"short lastread-2 {b256}, " +- "short lastwrote-2 {b256}"+ "short lastwrote-2 {b256}",+ payloadOrder, 0);}@@ -103,8 +104,8 @@ public class kelondroCollectionIndex {boolean ramIndexGeneration = false;boolean fileIndexGeneration = !(new File(path, filenameStub + ".index").exists());- if (ramIndexGeneration) index = new kelondroRowSet(indexRow(), indexOrder, 0, 0);- if (fileIndexGeneration) index = new kelondroFlexTable(path, filenameStub + ".index", buffersize, preloadTime, indexRow(), indexOrder);+ if (ramIndexGeneration) index = new kelondroRowSet(indexRow(keyLength, indexOrder), 0);+ if (fileIndexGeneration) index = new kelondroFlexTable(path, filenameStub + ".index", buffersize, preloadTime, indexRow(keyLength, indexOrder));// open array filesthis.arrays = new HashMap(); // all entries will be dynamically created with getArray()@@ -121,7 +122,7 @@ public class kelondroCollectionIndex {String[] list = this.path.list();kelondroFixedWidthArray array;- kelondroRow irow = indexRow();+ kelondroRow irow = indexRow(keylength, indexOrder);int t = kelondroRowCollection.daysSince2000(System.currentTimeMillis());for (int i = 0; i < list.length; i++) if (list[i].endsWith(".kca")) {@@ -182,7 +183,7 @@ public class kelondroCollectionIndex {long buffersize, long preloadTime,int loadfactor, kelondroRow rowdef) throws IOException {// open/create index table- kelondroIndex theindex = new kelondroCache(new kelondroFlexTable(path, filenameStub + ".index", buffersize / 2, preloadTime, indexRow(), indexOrder), buffersize / 2, true, false);+ kelondroIndex theindex = new kelondroCache(new kelondroFlexTable(path, filenameStub + ".index", buffersize / 2, preloadTime, indexRow(keylength, indexOrder)), buffersize / 2, true, false);// save/check property file for this arrayFile propfile = propertyFile(path, filenameStub, loadfactor, rowdef.objectsize());@@ -190,7 +191,7 @@ public class kelondroCollectionIndex {if (propfile.exists()) {props = serverFileUtils.loadHashMap(propfile);String stored_rowdef = (String) props.get("rowdef");- if ((stored_rowdef == null) || (!(rowdef.subsumes(new kelondroRow(stored_rowdef))))) {+ if ((stored_rowdef == null) || (!(rowdef.subsumes(new kelondroRow(stored_rowdef, null, 0))))) {System.out.println("FATAL ERROR: stored rowdef '" + stored_rowdef + "' does not match with new rowdef '" +rowdef + "' for array cluster '" + path + "/" + filenameStub + "'");System.exit(-1);@@ -207,7 +208,9 @@ public class kelondroCollectionIndex {int load = arrayCapacity(partitionNumber);kelondroRow rowdef = new kelondroRow("byte[] key-" + keylength + "," +- "byte[] collection-" + (kelondroRowCollection.exportOverheadSize + load * this.payloadrow.objectsize())+ "byte[] collection-" + (kelondroRowCollection.exportOverheadSize + load * this.payloadrow.objectsize()),+ index.row().objectOrder,+ 0);if ((!(f.exists())) && (!create)) return null;kelondroFixedWidthArray a = new kelondroFixedWidthArray(f, rowdef, 0);@@ -444,7 +447,7 @@ public class kelondroCollectionIndex {// read the row and define a collectionbyte[] indexkey = indexrow.getColBytes(idx_col_key);byte[] arraykey = arrayrow.getColBytes(0);- if (!(index.order().wellformed(arraykey))) {+ if (!(index.row().objectOrder.wellformed(arraykey))) {// cleanup for a bad bug that corrupted the databaseindex.remove(indexkey); // the RowCollection must be considered lostarray.remove(rownumber); // loose the RowCollection (we don't know how much is lost)@@ -452,7 +455,7 @@ public class kelondroCollectionIndex {return new kelondroRowSet(this.payloadrow, 0);}kelondroRowSet collection = new kelondroRowSet(this.payloadrow, arrayrow.getColBytes(1)); // FIXME: this does not yet work with different rowdef in case of several rowdef.objectsize()- if ((!(index.order().wellformed(indexkey))) || (index.order().compare(arraykey, indexkey) != 0)) {+ if ((!(index.row().objectOrder.wellformed(indexkey))) || (index.row().objectOrder.compare(arraykey, indexkey) != 0)) {// check if we got the right row; this row is wrong. Fix it:index.remove(indexkey); // the wrong row cannot be fixed// store the row number in the index; this may be a double-entry, but better than nothing@@ -531,7 +534,7 @@ public class kelondroCollectionIndex {public static void main(String[] args) {// define payload structure- kelondroRow rowdef = new kelondroRow("byte[] a-10, byte[] b-80");+ kelondroRow rowdef = new kelondroRow("byte[] a-10, byte[] b-80", kelondroNaturalOrder.naturalOrder, 0);File path = new File(args[0]);String filenameStub = args[1];@@ -545,12 +548,12 @@ public class kelondroCollectionIndex {4 /*loadfactor*/, rowdef);// fill index with values- kelondroRowSet collection = new kelondroRowSet(rowdef, kelondroNaturalOrder.naturalOrder, 0, 0);+ kelondroRowSet collection = new kelondroRowSet(rowdef, 0);collection.addUnique(rowdef.newEntry(new byte[][]{"abc".getBytes(), "efg".getBytes()}));collectionIndex.put("erstes".getBytes(), collection);for (int i = 0; i <= 17; i++) {- collection = new kelondroRowSet(rowdef, kelondroNaturalOrder.naturalOrder, 0, 0);+ collection = new kelondroRowSet(rowdef, 0);for (int j = 0; j < i; j++) {collection.addUnique(rowdef.newEntry(new byte[][]{("abc" + j).getBytes(), "xxx".getBytes()}));}@@ -560,7 +563,7 @@ public class kelondroCollectionIndex {// extend collections with more valuesfor (int i = 0; i <= 17; i++) {- collection = new kelondroRowSet(rowdef, kelondroNaturalOrder.naturalOrder, 0, 0);+ collection = new kelondroRowSet(rowdef, 0);for (int j = 0; j < i; j++) {collection.addUnique(rowdef.newEntry(new byte[][]{("def" + j).getBytes(), "xxx".getBytes()}));}@@ -569,7 +572,7 @@ public class kelondroCollectionIndex {// printout of indexcollectionIndex.close();- kelondroFlexTable index = new kelondroFlexTable(path, filenameStub + ".index", buffersize, preloadTime, collectionIndex.indexRow(), kelondroNaturalOrder.naturalOrder);+ kelondroFlexTable index = new kelondroFlexTable(path, filenameStub + ".index", buffersize, preloadTime, kelondroCollectionIndex.indexRow(9, kelondroNaturalOrder.naturalOrder));index.print();index.close();} catch (IOException e) {diff --git a/source/de/anomic/kelondro/kelondroDyn.java b/source/de/anomic/kelondro/kelondroDyn.javaindex 730e4c071..b7ddc4b29 100644--- a/source/de/anomic/kelondro/kelondroDyn.java+++ b/source/de/anomic/kelondro/kelondroDyn.java@@ -79,8 +79,8 @@ public class kelondroDyn {public kelondroDyn(File file, long buffersize /* bytes */, long preloadTime, int key,int nodesize, char fillChar, kelondroOrder objectOrder) throws IOException {// creates or opens a dynamic tree- rowdef = new kelondroRow("byte[] key-" + (key + counterlen) + ", byte[] node-" + nodesize);- kelondroTree tree = new kelondroTree(file, buffersize / 2, preloadTime, rowdef, objectOrder, 1, 8);+ rowdef = new kelondroRow("byte[] key-" + (key + counterlen) + ", byte[] node-" + nodesize, objectOrder, 0);+ kelondroTree tree = new kelondroTree(file, buffersize / 2, preloadTime, rowdef, 1, 8);this.index = new kelondroCache(tree, buffersize / 2, true, false);this.keylen = index.row().width(0) - counterlen;this.reclen = index.row().width(1);diff --git a/source/de/anomic/kelondro/kelondroDynTree.java b/source/de/anomic/kelondro/kelondroDynTree.javaindex 393f40f64..85f360cbe 100644--- a/source/de/anomic/kelondro/kelondroDynTree.java+++ b/source/de/anomic/kelondro/kelondroDynTree.java@@ -298,10 +298,10 @@ public class kelondroDynTree {System.out.println("start");File file = new File("D:\\bin\\testDyn.db");if (file.exists()) {- kelondroDynTree dt = new kelondroDynTree(file, 0x100000L, 0, 16, 512, new kelondroRow("byte[] a-10, byte[] b-20, byte[] c-30"), '_');+ kelondroDynTree dt = new kelondroDynTree(file, 0x100000L, 0, 16, 512, new kelondroRow("byte[] a-10, byte[] b-20, byte[] c-30", kelondroNaturalOrder.naturalOrder, 0), '_');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, 0x100000L, 0, 16, 512, new kelondroRow("byte[] a-10, byte[] b-20, byte[] c-30"), '_');+ kelondroDynTree dt = new kelondroDynTree(file, 0x100000L, 0, 16, 512, new kelondroRow("byte[] a-10, byte[] b-20, byte[] c-30", kelondroNaturalOrder.naturalOrder, 0), '_');String name;kelondroTree t;kelondroRow.Entry line;diff --git a/source/de/anomic/kelondro/kelondroFixedWidthArray.java b/source/de/anomic/kelondro/kelondroFixedWidthArray.javaindex ee6ef7ba9..b01e5bbbb 100644--- a/source/de/anomic/kelondro/kelondroFixedWidthArray.java+++ b/source/de/anomic/kelondro/kelondroFixedWidthArray.java@@ -157,7 +157,7 @@ public class kelondroFixedWidthArray extends kelondroRecords implements kelondropublic static void main(String[] args) {//File f = new File("d:\\\\mc\\privat\\fixtest.db");File f = new File("/Users/admin/fixtest.db");- kelondroRow rowdef = new kelondroRow("byte[] a-12, byte[] b-4");+ kelondroRow rowdef = new kelondroRow("byte[] a-12, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0);try {System.out.println("erster Test");f.delete();diff --git a/source/de/anomic/kelondro/kelondroFlexSplitTable.java b/source/de/anomic/kelondro/kelondroFlexSplitTable.javaindex 0d9a653f1..8c2864f12 100644--- a/source/de/anomic/kelondro/kelondroFlexSplitTable.java+++ b/source/de/anomic/kelondro/kelondroFlexSplitTable.java@@ -40,16 +40,14 @@ public class kelondroFlexSplitTable implements kelondroIndex {// the set is divided into FlexTables with different entry dateprivate HashMap tables;- private kelondroOrder objectOrder;private kelondroRow rowdef;private File path;private String tablename;private long buffersize;- public kelondroFlexSplitTable(File path, String tablename, long buffersize, long preloadTime, kelondroRow rowdef, kelondroOrder objectOrder) throws IOException {+ public kelondroFlexSplitTable(File path, String tablename, long buffersize, long preloadTime, kelondroRow rowdef) throws IOException {this.path = path;this.tablename = tablename;- this.objectOrder = objectOrder;this.rowdef = rowdef;// initialized tables map@@ -99,12 +97,12 @@ public class kelondroFlexSplitTable implements kelondroIndex {date = maxf.substring(tablename.length() + 1);if (buffersize >= maxram) {// this will cause usage of a complete RAM index- table = new kelondroCache(new kelondroFlexTable(path, maxf, maxram, preloadTime, rowdef, objectOrder), maxram / 10, true, false);+ table = new kelondroCache(new kelondroFlexTable(path, maxf, maxram, preloadTime, rowdef), maxram / 10, true, false);buffersize -= maxram;buffersize -= maxram / 10;} else {// this will cause a generation of a file index- table = new kelondroFlexTable(path, maxf, buffersize / (t.size() + 1), preloadTime, rowdef, objectOrder);+ table = new kelondroFlexTable(path, maxf, buffersize / (t.size() + 1), preloadTime, rowdef);buffersize -= buffersize / (t.size() + 1);}tables.put(date, table);@@ -129,14 +127,6 @@ public class kelondroFlexSplitTable implements kelondroIndex {return new String(suffix);}- public kelondroOrder order() {- return this.objectOrder;- }-- public int primarykey() {- return 0;- }-public synchronized int size() throws IOException {Iterator i = tables.values().iterator();int s = 0;@@ -198,7 +188,7 @@ public class kelondroFlexSplitTable implements kelondroIndex {kelondroIndex table = (kelondroIndex) tables.get(suffix);if (table == null) {// make new table- table = new kelondroFlexTable(path, tablename + "." + suffix, buffersize / (tables.size() + 1), -1, rowdef, objectOrder);+ table = new kelondroFlexTable(path, tablename + "." + suffix, buffersize / (tables.size() + 1), -1, rowdef);tables.put(suffix, table);}table.put(row);@@ -228,7 +218,7 @@ public class kelondroFlexSplitTable implements kelondroIndex {kelondroIndex table = (kelondroIndex) tables.get(suffix);if (table == null) {// make new table- table = new kelondroFlexTable(path, tablename + "." + suffix, buffersize / (tables.size() + 1), -1, rowdef, objectOrder);+ table = new kelondroFlexTable(path, tablename + "." + suffix, buffersize / (tables.size() + 1), -1, rowdef);tables.put(suffix, table);}table.addUnique(row, entryDate);diff --git a/source/de/anomic/kelondro/kelondroFlexTable.java b/source/de/anomic/kelondro/kelondroFlexTable.javaindex d20f4a2d2..6f8021807 100644--- a/source/de/anomic/kelondro/kelondroFlexTable.java+++ b/source/de/anomic/kelondro/kelondroFlexTable.java@@ -37,7 +37,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrprotected kelondroBytesIntMap index;private boolean RAMIndex;- public kelondroFlexTable(File path, String tablename, long buffersize, long preloadTime, kelondroRow rowdef, kelondroOrder objectOrder) throws IOException {+ public kelondroFlexTable(File path, String tablename, long buffersize, long preloadTime, kelondroRow rowdef) throws IOException {// the buffersize applies to a possible load of the ram-index// if the ram is not sufficient, a tree file is generated// if, and only if a tree file exists, the preload time is applied@@ -64,7 +64,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr// fill the indexSystem.out.print("*** Loading RAM index for " + size() + " entries from "+ newpath);- ki = initializeRamIndex(objectOrder);+ ki = initializeRamIndex();System.out.println(" -done-");System.out.println(ki.size()@@ -76,13 +76,13 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrif (indexfile.exists()) {// use existing index fileSystem.out.println("*** Using File index " + indexfile);- ki = new kelondroCache(kelondroTree.open(indexfile, buffersize / 3 * 2, preloadTime, treeIndexRow(rowdef.width(0)), objectOrder, 2, 80), buffersize / 3, true, false);+ ki = new kelondroCache(kelondroTree.open(indexfile, buffersize / 3 * 2, preloadTime, treeIndexRow(rowdef.width(0), rowdef.objectOrder, rowdef.primaryKey), 2, 80), buffersize / 3, true, false);RAMIndex = false;} else {// generate new index fileSystem.out.println("*** Generating File index for " + size() + " entries from " + indexfile);System.out.println("*** Cause: too less RAM (" + (buffersize / 1024 / 1024) + " MB) configured. Assign at least " + (neededRAM / 1024 / 1024) + " MB buffersize to enable a RAM index.");- ki = initializeTreeIndex(indexfile, buffersize, preloadTime, objectOrder);+ ki = initializeTreeIndex(indexfile, buffersize, preloadTime, rowdef.objectOrder, rowdef.primaryKey);System.out.println(" -done-");System.out.println(ki.size() + " entries indexed from " + super.col[0].size() + " keys.");@@ -114,10 +114,8 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrreturn index.geti(key) >= 0;}- private kelondroIndex initializeRamIndex(kelondroOrder objectOrder) {- kelondroRowSet ri = new kelondroRowSet(new kelondroRow(new kelondroColumn[]{super.row().column(0), new kelondroColumn("int c-4 {b256}")}), objectOrder, 0, 0);- //kelondroRowSet ri = new kelondroRowSet(new kelondroRow(new kelondroColumn[]{super.row().column(0), new kelondroColumn("int c-4 {b256}")}), 0);- //ri.setOrdering(objectOrder, 0);+ private kelondroIndex initializeRamIndex() {+ kelondroRowSet ri = new kelondroRowSet(new kelondroRow(new kelondroColumn[]{super.row().column(0), new kelondroColumn("int c-4 {b256}")}, super.rowdef.objectOrder, super.rowdef.primaryKey), 0);Iterator content = super.col[0].contentNodes(-1);kelondroRecords.Node node;kelondroRow.Entry indexentry;@@ -144,8 +142,8 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrreturn ri;}- private kelondroIndex initializeTreeIndex(File indexfile, long buffersize, long preloadTime, kelondroOrder objectOrder) throws IOException {- kelondroIndex treeindex = new kelondroCache(new kelondroTree(indexfile, buffersize / 3 * 2, preloadTime, treeIndexRow(rowdef.width(0)), objectOrder, 2, 80), buffersize / 3, true, false);+ private kelondroIndex initializeTreeIndex(File indexfile, long buffersize, long preloadTime, kelondroOrder objectOrder, int primaryKey) throws IOException {+ kelondroIndex treeindex = new kelondroCache(new kelondroTree(indexfile, buffersize / 3 * 2, preloadTime, treeIndexRow(rowdef.width(0), objectOrder, primaryKey), 2, 80), buffersize / 3, true, false);Iterator content = super.col[0].contentNodes(-1);kelondroRecords.Node node;kelondroRow.Entry indexentry;@@ -169,8 +167,8 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrreturn treeindex;}- private static final kelondroRow treeIndexRow(int keywidth) {- return new kelondroRow("byte[] key-" + keywidth + ", int reference-4 {b256}");+ private static final kelondroRow treeIndexRow(int keywidth, kelondroOrder objectOrder, int primaryKey) {+ return new kelondroRow("byte[] key-" + keywidth + ", int reference-4 {b256}", objectOrder, primaryKey);}public synchronized kelondroRow.Entry get(byte[] key) throws IOException {@@ -257,14 +255,6 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr}}-- public kelondroOrder order() {- return index.order();- }-- public int primarykey() {- return 0;- }public kelondroProfile profile() {return index.profile();diff --git a/source/de/anomic/kelondro/kelondroFlexWidthArray.java b/source/de/anomic/kelondro/kelondroFlexWidthArray.javaindex aa1d802c4..006b88f8b 100644--- a/source/de/anomic/kelondro/kelondroFlexWidthArray.java+++ b/source/de/anomic/kelondro/kelondroFlexWidthArray.java@@ -63,7 +63,7 @@ public class kelondroFlexWidthArray implements kelondroArray {if (propfile.exists()) {props = serverFileUtils.loadHashMap(propfile);String stored_rowdef = (String) props.get("rowdef");- if ((stored_rowdef == null) || (!(rowdef.subsumes(new kelondroRow(stored_rowdef))))) {+ if ((stored_rowdef == null) || (!(rowdef.subsumes(new kelondroRow(stored_rowdef, null, 0))))) {System.out.println("FATAL ERROR: stored rowdef '" + stored_rowdef + "' does not match with new rowdef '" +rowdef + "' for flex table '" + path + "', table " + tablename);System.exit(-1);@@ -81,7 +81,7 @@ public class kelondroFlexWidthArray implements kelondroArray {kelondroColumn columns[] = new kelondroColumn[colend - colstart + 1];for (int j = colstart; j <= colend; j++) columns[j-colstart] = rowdef.column(j);- col[colstart] = new kelondroFixedWidthArray(new File(tabledir, files[i]), new kelondroRow(columns), 16);+ col[colstart] = new kelondroFixedWidthArray(new File(tabledir, files[i]), new kelondroRow(columns, null, 0), 16);for (int j = colstart; j <= colend; j++) check = check.substring(0, j) + "X" + check.substring(j + 1);}}@@ -100,7 +100,7 @@ public class kelondroFlexWidthArray implements kelondroArray {columns[j - p] = rowdef.column(j);check = check.substring(0, j) + "X" + check.substring(j + 1);}- col[p] = new kelondroFixedWidthArray(new File(tabledir, colfilename(p, q)), new kelondroRow(columns), 16);+ col[p] = new kelondroFixedWidthArray(new File(tabledir, colfilename(p, q)), new kelondroRow(columns, null, 0), 16);}}@@ -267,7 +267,7 @@ public class kelondroFlexWidthArray implements kelondroArray {public static void main(String[] args) {//File f = new File("d:\\\\mc\\privat\\fixtest.db");File f = new File("/Users/admin/");- kelondroRow rowdef = new kelondroRow("byte[] a-12, byte[] b-4");+ kelondroRow rowdef = new kelondroRow("byte[] a-12, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0);String testname = "flextest";try {System.out.println("erster Test");diff --git a/source/de/anomic/kelondro/kelondroHashtable.java b/source/de/anomic/kelondro/kelondroHashtable.javaindex f93e9cad0..c8680935a 100644--- a/source/de/anomic/kelondro/kelondroHashtable.java+++ b/source/de/anomic/kelondro/kelondroHashtable.java@@ -176,7 +176,7 @@ public class kelondroHashtable {kelondroColumn[] newCol = new kelondroColumn[rowdef.columns() + 1];newCol[0] = new kelondroColumn("Cardinal key-4 {b256}");for (int i = 0; i < rowdef.columns(); i++) newCol[i + 1] = rowdef.column(i);- return new kelondroRow(newCol);+ return new kelondroRow(newCol, rowdef.objectOrder, rowdef.primaryKey);}public static int power2(int x) {diff --git a/source/de/anomic/kelondro/kelondroIndex.java b/source/de/anomic/kelondro/kelondroIndex.javaindex 754f5a61d..2a93665ad 100644--- a/source/de/anomic/kelondro/kelondroIndex.java+++ b/source/de/anomic/kelondro/kelondroIndex.java@@ -56,8 +56,6 @@ import java.util.Iterator;public interface kelondroIndex {- public kelondroOrder order();- public int primarykey();public int size() throws IOException;public kelondroProfile profile();public kelondroRow row() throws IOException;diff --git a/source/de/anomic/kelondro/kelondroIntBytesMap.java b/source/de/anomic/kelondro/kelondroIntBytesMap.javaindex f68dc601f..abfcfa9d5 100644--- a/source/de/anomic/kelondro/kelondroIntBytesMap.java+++ b/source/de/anomic/kelondro/kelondroIntBytesMap.java@@ -34,7 +34,7 @@ public class kelondroIntBytesMap {private kelondroIndex index;public kelondroIntBytesMap(int payloadSize, int initSize) {- index = kelondroRowSet.getRAMIndex(new kelondroRow("Cardinal key-4 {b256}, byte[] payload-" + payloadSize), initSize);+ index = new kelondroRowSet(new kelondroRow("Cardinal key-4 {b256}, byte[] payload-" + payloadSize, kelondroNaturalOrder.naturalOrder, 0), initSize);}public int size() {diff --git a/source/de/anomic/kelondro/kelondroRecords.java b/source/de/anomic/kelondro/kelondroRecords.javaindex 508575bdb..e573f7532 100644--- a/source/de/anomic/kelondro/kelondroRecords.java+++ b/source/de/anomic/kelondro/kelondroRecords.java@@ -240,7 +240,18 @@ public class kelondroRecords {initNewFile(raf, ohbytec, ohhandlec, rowdef, FHandles, txtProps, txtPropWidth, buffersize / 10);}assignRowdef(rowdef);- initCache(buffersize / 10 * 9, preloadTime);+ if (fileExisted) {+ kelondroOrder oldOrder = readOrderType();+ if ((oldOrder != null) && (!(oldOrder.equals(rowdef.objectOrder)))) {+ writeOrderType(); // write new order type+ //throw new IOException("wrong object order upon initialization. new order is " + rowdef.objectOrder.toString() + ", old order was " + oldOrder.toString());+ }+ } else {+ // create new file structure+ writeOrderType();+ }+ initCache(buffersize / 10 * 9, preloadTime);+}public kelondroRecords(kelondroRA ra, long buffersize /* bytes */, long preloadTime,@@ -254,6 +265,7 @@ public class kelondroRecords {logFailure("cannot create / " + e.getMessage());if (exitOnFail) System.exit(-1);}+ writeOrderType();initCache(buffersize / 10 * 9, preloadTime);}@@ -378,6 +390,7 @@ public class kelondroRecords {public kelondroRecords(kelondroRA ra, long buffersize, long preloadTime) throws IOException{this.filename = null;initExistingFile(ra, buffersize / 10);+ readOrderType();initCache(buffersize / 10 * 9, preloadTime);}@@ -412,7 +425,6 @@ public class kelondroRecords {for (int i = 0; i < COLDEFS.length; i++) {COLDEFS[i] = new kelondroColumn("col-" + i, kelondroColumn.celltype_binary, kelondroColumn.encoder_bytes, entryFile.readInt(POS_COLWIDTHS + 4 * i), "");}- this.ROW = new kelondroRow(COLDEFS);for (int i = 0; i < HANDLES.length; i++) {HANDLES[i] = new Handle(entryFile.readInt(POS_HANDLES + 4 * i));}@@ -420,7 +432,8 @@ public class kelondroRecords {TXTPROPS[i] = new byte[TXTPROPW];entryFile.readFully(POS_TXTPROPS + TXTPROPW * i, TXTPROPS[i], 0, TXTPROPS[i].length);}-+ this.ROW = new kelondroRow(COLDEFS, readOrderType(), 0);+// assign remaining values that are only present at run-timethis.overhead = OHBYTEC + 4 * OHHANDLEC;this.recordsize = this.overhead;@@ -429,6 +442,30 @@ public class kelondroRecords {this.tailchunksize = this.recordsize - this.headchunksize;}+ private void writeOrderType() {+ try {+ setDescription((this.ROW.objectOrder == null) ? "__".getBytes() : this.ROW.objectOrder.signature().getBytes());+ } catch (IOException e) {}+ }++ private kelondroOrder readOrderType() {+ try {+ byte[] d = getDescription();+ String s = new String(d).substring(0, 2);+ return orderBySignature(s);+ } catch (IOException e) {+ return null;+ }+ }++ public static kelondroOrder orderBySignature(String signature) {+ kelondroOrder oo = null;+ if (oo == null) oo = kelondroNaturalOrder.bySignature(signature);+ if (oo == null) oo = kelondroBase64Order.bySignature(signature);+ if (oo == null) oo = new kelondroNaturalOrder(true);+ return oo;+ }+private void initCache(long buffersize, long preloadTime) {if (buffersize <= 0) {this.cacheSize = 0;diff --git a/source/de/anomic/kelondro/kelondroRow.java b/source/de/anomic/kelondro/kelondroRow.javaindex bd006f1f6..4d30f34eb 100644--- a/source/de/anomic/kelondro/kelondroRow.java+++ b/source/de/anomic/kelondro/kelondroRow.java@@ -40,10 +40,14 @@ public class kelondroRow {protected kelondroColumn[] row;protected int[] colstart;protected int objectsize;+ protected kelondroOrder objectOrder;+ protected int primaryKey;protected Map nickref = null; // a mapping from nicknames to Object[2]{kelondroColumn, Integer(colstart)}- public kelondroRow(kelondroColumn[] row) {+ public kelondroRow(kelondroColumn[] row, kelondroOrder objectOrder, int primaryKey) {this.row = row;+ this.objectOrder = objectOrder;+ this.primaryKey = primaryKey;this.colstart = new int[row.length];this.objectsize = 0;for (int i = 0; i < row.length; i++) {@@ -52,7 +56,9 @@ public class kelondroRow {}}- public kelondroRow(String structure) {+ public kelondroRow(String structure, kelondroOrder objectOrder, int primaryKey) {+ this.objectOrder = objectOrder;+ this.primaryKey = primaryKey;// define row with row syntax// example://# Structure=<pivot-12>,'=',<UDate-3>,<VDate-3>,<LCount-2>,<GCount-2>,<ICount-2>,<DCount-2>,<TLength-3>,<WACount-3>,<WUCount-3>,<Flags-1>@@ -81,6 +87,19 @@ public class kelondroRow {}}+ public void setOrdering(kelondroOrder objectOrder, int primaryKey) {+ this.objectOrder = objectOrder;+ this.primaryKey = primaryKey;+ }++ public kelondroOrder getOrdering() {+ return this.objectOrder;+ }++ public int primaryKey() {+ return this.primaryKey;+ }+protected void genNickRef() {if (nickref != null) return;nickref = new HashMap(row.length);@@ -128,11 +147,6 @@ public class kelondroRow {return new Entry(rowinstance);}- public EntryIndex newEntry(byte[] rowinstance, int index) {- if (rowinstance == null) return null;- return new EntryIndex(rowinstance, index);- }-public Entry newEntry(byte[] rowinstance, int start, int length) {if (rowinstance == null) return null;return new Entry(rowinstance, start, length);@@ -148,6 +162,11 @@ public class kelondroRow {return new Entry(external, decimalCardinal);}+ public EntryIndex newEntry(byte[] rowinstance, int index) {+ if (rowinstance == null) return null;+ return new EntryIndex(rowinstance, index);+ }+public class Entry implements Comparable {private byte[] rowinstance;@@ -227,10 +246,11 @@ public class kelondroRow {}public int compareTo(Object o) {+ if (objectOrder == null) throw new kelondroException("objects cannot be compared, no order given");if (o instanceof Entry) {- return kelondroNaturalOrder.naturalOrder.compare(this.rowinstance, ((Entry) o).rowinstance);+ return objectOrder.compare(getColBytes(primaryKey), ((Entry) o).getColBytes(primaryKey));}- throw new UnsupportedOperationException("works only for Entry objects");+ throw new UnsupportedOperationException("works only for kelondroRow.Entry objects");}public byte[] bytes() {diff --git a/source/de/anomic/kelondro/kelondroRowCollection.java b/source/de/anomic/kelondro/kelondroRowCollection.javaindex ee0bee24a..1b27eae9f 100644--- a/source/de/anomic/kelondro/kelondroRowCollection.java+++ b/source/de/anomic/kelondro/kelondroRowCollection.java@@ -37,8 +37,6 @@ public class kelondroRowCollection {protected long lastTimeRead, lastTimeWrote;protected kelondroRow rowdef;protected int sortBound;- protected kelondroOrder sortOrder;- protected int sortColumn;private static final int exp_chunkcount = 0;private static final int exp_last_read = 1;@@ -52,8 +50,6 @@ public class kelondroRowCollection {this.rowdef = rc.rowdef;this.chunkcache = rc.chunkcache;this.chunkcount = rc.chunkcount;- this.sortColumn = rc.sortColumn;- this.sortOrder = rc.sortOrder;this.sortBound = rc.sortBound;this.lastTimeRead = rc.lastTimeRead;this.lastTimeWrote = rc.lastTimeWrote;@@ -63,19 +59,15 @@ public class kelondroRowCollection {this.rowdef = rowdef;this.chunkcache = new byte[objectCount * rowdef.objectsize()];this.chunkcount = 0;- this.sortColumn = 0;- this.sortOrder = null;this.sortBound = 0;this.lastTimeRead = System.currentTimeMillis();this.lastTimeWrote = System.currentTimeMillis();}- public kelondroRowCollection(kelondroRow rowdef, int objectCount, byte[] cache, kelondroOrder sortOrder, int sortColumn, int sortBound) {+ public kelondroRowCollection(kelondroRow rowdef, int objectCount, byte[] cache, int sortBound) {this.rowdef = rowdef;this.chunkcache = cache;this.chunkcount = objectCount;- this.sortColumn = sortColumn;- this.sortOrder = sortOrder;this.sortBound = sortBound;this.lastTimeRead = System.currentTimeMillis();this.lastTimeWrote = System.currentTimeMillis();@@ -94,13 +86,17 @@ public class kelondroRowCollection {this.lastTimeRead = (exportedCollection.getColLong(exp_last_read) + 10957) * day;this.lastTimeWrote = (exportedCollection.getColLong(exp_last_wrote) + 10957) * day;String sortOrderKey = exportedCollection.getColString(exp_order_type, null);+ kelondroOrder oldOrder = null;if ((sortOrderKey == null) || (sortOrderKey.equals("__"))) {- this.sortOrder = null;+ oldOrder = null;} else {- this.sortOrder = kelondroNaturalOrder.bySignature(sortOrderKey);- if (this.sortOrder == null) this.sortOrder = kelondroBase64Order.bySignature(sortOrderKey);+ oldOrder = kelondroNaturalOrder.bySignature(sortOrderKey);+ if (oldOrder == null) oldOrder = kelondroBase64Order.bySignature(sortOrderKey);}- this.sortColumn = (int) exportedCollection.getColLong(exp_order_col);+ if ((rowdef.objectOrder != null) && (oldOrder != null) && (!(rowdef.objectOrder.signature().equals(oldOrder.signature()))))+ throw new kelondroException("old collection order does not match with new order");+ if (rowdef.primaryKey != (int) exportedCollection.getColLong(exp_order_col))+ throw new kelondroException("old collection primary key does not match with new primary key");this.sortBound = (int) exportedCollection.getColLong(exp_order_bound);//assert (sortBound <= chunkcount) : "sortBound = " + sortBound + ", chunkcount = " + chunkcount;if (sortBound > chunkcount) {@@ -125,7 +121,8 @@ public class kelondroRowCollection {"byte[] orderkey-2," +"short ordercol-2 {b256}," +"short orderbound-2 {b256}," +- "byte[] collection-" + chunkcachelength+ "byte[] collection-" + chunkcachelength,+ null, 0);}@@ -141,8 +138,8 @@ public class kelondroRowCollection {entry.setCol(exp_chunkcount, this.chunkcount);entry.setCol(exp_last_read, daysSince2000(this.lastTimeRead));entry.setCol(exp_last_wrote, daysSince2000(this.lastTimeWrote));- entry.setCol(exp_order_type, (this.sortOrder == null) ? "__".getBytes() : this.sortOrder.signature().getBytes());- entry.setCol(exp_order_col, this.sortColumn);+ entry.setCol(exp_order_type, (this.rowdef.objectOrder == null) ? "__".getBytes() :this.rowdef.objectOrder.signature().getBytes());+ entry.setCol(exp_order_col, this.rowdef.primaryKey);entry.setCol(exp_order_bound, this.sortBound);entry.setCol(exp_collection, chunkcache);return entry.bytes();@@ -362,7 +359,7 @@ public class kelondroRowCollection {}protected final void sort() {- assert (this.sortOrder != null);+ assert (this.rowdef.objectOrder != null);if (this.sortBound == this.chunkcount) return; // this is already sorted//System.out.println("SORT(chunkcount=" + this.chunkcount + ", sortBound=" + this.sortBound + ")");if (this.sortBound > 1) {@@ -462,7 +459,7 @@ public class kelondroRowCollection {}public void uniq() {- assert (this.sortOrder != null);+ assert (this.rowdef.objectOrder != null);// removes double-occurrences of chunks// this works only if the collection was ordered with sort beforesynchronized (chunkcache) {@@ -491,14 +488,14 @@ public class kelondroRowCollection {assert (chunkcount * this.rowdef.objectsize() <= chunkcache.length) : "chunkcount = " + chunkcount + ", objsize = " + this.rowdef.objectsize() + ", chunkcache.length = " + chunkcache.length;assert (i >= 0) && (i < chunkcount) : "i = " + i + ", chunkcount = " + chunkcount;assert (j >= 0) && (j < chunkcount) : "j = " + j + ", chunkcount = " + chunkcount;- assert (this.sortOrder != null);+ assert (this.rowdef.objectOrder != null);if (i == j) return 0;- assert (this.sortColumn == 0) : "this.sortColumn = " + this.sortColumn;- int keylength = this.rowdef.width(this.sortColumn);- int colstart = this.rowdef.colstart[this.sortColumn];+ assert (this.rowdef.primaryKey == 0) : "this.sortColumn = " + this.rowdef.primaryKey;+ int keylength = this.rowdef.width(this.rowdef.primaryKey);+ int colstart = this.rowdef.colstart[this.rowdef.primaryKey];if (bugappearance(chunkcache, i * this.rowdef.objectsize() + colstart, keylength)) throw new kelondroException("bugappearance i");if (bugappearance(chunkcache, j * this.rowdef.objectsize() + colstart, keylength)) throw new kelondroException("bugappearance j");- int c = this.sortOrder.compare(+ int c = this.rowdef.objectOrder.compare(chunkcache,i * this.rowdef.objectsize() + colstart,keylength,diff --git a/source/de/anomic/kelondro/kelondroRowSet.java b/source/de/anomic/kelondro/kelondroRowSet.javaindex 3c2fca99c..131da80b7 100644--- a/source/de/anomic/kelondro/kelondroRowSet.java+++ b/source/de/anomic/kelondro/kelondroRowSet.java@@ -39,8 +39,8 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndprivate kelondroProfile profile;private TreeMap removeMarker;- public kelondroRowSet(kelondroRow rowdef, int objectCount, byte[] cache, kelondroOrder sortOrder, int sortColumn, int sortBound) {- super(rowdef, objectCount, cache, sortOrder, sortColumn, sortBound);+ public kelondroRowSet(kelondroRow rowdef, int objectCount, byte[] cache, int sortBound) {+ super(rowdef, objectCount, cache, sortBound);this.removeMarker = new TreeMap();this.profile = new kelondroProfile();}@@ -63,12 +63,6 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndthis.profile = new kelondroProfile();}- public kelondroRowSet(kelondroRow rowdef, kelondroOrder objectOrder, int orderColumn, int objectCount) {- this(rowdef, objectCount);- assert (objectOrder != null);- setOrdering(objectOrder, orderColumn);- }-public kelondroRow.Entry get(byte[] key) {return get(key, 0, key.length);}@@ -106,13 +100,13 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndpublic kelondroRow.Entry put(kelondroRow.Entry entry) {assert (entry != null);- assert (entry.getColBytes(super.sortColumn) != null);+ assert (entry.getColBytes(rowdef.primaryKey) != null);//assert (!(serverLog.allZero(entry.getColBytes(super.sortColumn))));long handle = profile.startWrite();int index = -1;kelondroRow.Entry oldentry = null;synchronized (chunkcache) {- index = find(entry.bytes(), super.rowdef.colstart[super.sortColumn], super.rowdef.width(super.sortColumn));+ index = find(entry.bytes(), super.rowdef.colstart[rowdef.primaryKey], super.rowdef.width(rowdef.primaryKey));if (isMarkedRemoved(index)) {set(index, entry);removeMarker.remove(new Integer(index));@@ -152,7 +146,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndentry = get(p);if (p < sortBound) {// mark entry as to-be-deleted- removeMarker.put(new Integer(p), entry.getColBytes(super.sortColumn));+ removeMarker.put(new Integer(p), entry.getColBytes(rowdef.primaryKey));if (removeMarker.size() > removeMaxSize) resolveMarkedRemoved();} else {// remove directly by swap@@ -171,7 +165,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd}public void shape() {- assert (this.sortOrder != null); // we cannot shape without an object order+ assert (rowdef.objectOrder != null); // we cannot shape without an object ordersynchronized (chunkcache) {try {resolveMarkedRemoved();@@ -204,7 +198,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndwhile (removeMarker.size() > 0) {nxt = (Integer) removeMarker.firstKey();a = (byte[]) removeMarker.remove(nxt);- assert kelondroNaturalOrder.compares(a, 0, a.length, get(nxt.intValue()).getColBytes(this.sortColumn), 0, a.length) == 0;+ assert kelondroNaturalOrder.compares(a, 0, a.length, get(nxt.intValue()).getColBytes(rowdef.primaryKey), 0, a.length) == 0;assert (nxt.intValue() < sortBound);super.removeShift(idx, d, nxt.intValue());idx = nxt.intValue() - d;@@ -228,29 +222,19 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd}public void setOrdering(kelondroOrder newOrder, int newColumn) {- if ((this.sortOrder == null) ||- (!(this.sortOrder.signature().equals(newOrder.signature()))) ||- (newColumn != this.sortColumn)) {+ if ((rowdef.objectOrder == null) ||+ (!(rowdef.objectOrder.signature().equals(newOrder.signature()))) ||+ (newColumn != rowdef.primaryKey)) {resolveMarkedRemoved();- this.sortOrder = newOrder;+ rowdef.setOrdering(newOrder, newColumn);this.sortBound = 0;- this.sortColumn = newColumn;}}-- public kelondroOrder order() {- return this.sortOrder;- }-- public int primarykey() {- return this.sortColumn;- }-private int find(byte[] a, int astart, int alength) {// returns the chunknumber; -1 if not found- if (this.sortOrder == null) return iterativeSearch(a, astart, alength, 0, this.chunkcount);+ if (rowdef.objectOrder == null) return iterativeSearch(a, astart, alength, 0, this.chunkcount);// check if a re-sorting make senseif ((this.chunkcount - this.sortBound) > collectionReSortLimit) shape();@@ -267,7 +251,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndprivate int iterativeSearch(byte[] key, int astart, int alength, int leftBorder, int rightBound) {// returns the chunknumber- if (this.sortOrder == null) {+ if (rowdef.objectOrder == null) {for (int i = leftBorder; i < rightBound; i++) {if (match(key, astart, alength, i)) return i;}@@ -283,7 +267,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndprivate int binarySearch(byte[] key, int astart, int alength) {// returns the exact position of the key if the key exists,// or -1 if the key does not exist- assert (this.sortOrder != null);+ assert (rowdef.objectOrder != null);int l = 0;int rbound = this.sortBound;int p = 0;@@ -302,7 +286,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd// returns the exact position of the key if the key exists,// or a position of an entry that is greater than the key if the// key does not exist- assert (this.sortOrder != null);+ assert (rowdef.objectOrder != null);int l = 0;int rbound = this.sortBound;int p = 0;@@ -319,17 +303,17 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndprivate int compare(byte[] a, int astart, int alength, int chunknumber) {assert (chunknumber < chunkcount);- int l = Math.min(this.rowdef.width(this.sortColumn), Math.min(a.length - astart, alength));- return this.sortOrder.compare(a, astart, l, chunkcache, chunknumber * this.rowdef.objectsize() + this.rowdef.colstart[this.sortColumn], this.rowdef.width(this.sortColumn));+ int l = Math.min(this.rowdef.width(rowdef.primaryKey), Math.min(a.length - astart, alength));+ return rowdef.objectOrder.compare(a, astart, l, chunkcache, chunknumber * this.rowdef.objectsize() + this.rowdef.colstart[rowdef.primaryKey], this.rowdef.width(rowdef.primaryKey));}private boolean match(byte[] a, int astart, int alength, int chunknumber) {if (chunknumber >= chunkcount) return false;int i = 0;- int p = chunknumber * this.rowdef.objectsize() + this.rowdef.colstart[this.sortColumn];- final int len = Math.min(this.rowdef.width(this.sortColumn), Math.min(alength, a.length - astart));+ int p = chunknumber * this.rowdef.objectsize() + this.rowdef.colstart[rowdef.primaryKey];+ final int len = Math.min(this.rowdef.width(rowdef.primaryKey), Math.min(alength, a.length - astart));while (i < len) if (a[astart + i++] != chunkcache[p++]) return false;- return ((len == this.rowdef.width(this.sortColumn)) || (chunkcache[len] == 0)) ;+ return ((len == this.rowdef.width(rowdef.primaryKey)) || (chunkcache[len] == 0)) ;}public kelondroProfile profile() {@@ -413,10 +397,6 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndreturn new int[]{0,0,0,0,0,0,0,0,0,0};}- public static kelondroIndex getRAMIndex(kelondroRow rowdef, int initSize) {- return new kelondroRowSet(rowdef, kelondroNaturalOrder.naturalOrder, 0, initSize);- }-public static void main(String[] args) {/*String[] test = { "eins", "zwei", "drei", "vier", "fuenf", "sechs", "sieben", "acht", "neun", "zehn" };@@ -506,7 +486,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd// remove testlong start = System.currentTimeMillis();- kelondroRowSet c = new kelondroRowSet(new kelondroRow("byte[] a-12, byte[] b-12"), 0);+ kelondroRowSet c = new kelondroRowSet(new kelondroRow("byte[] a-12, byte[] b-12", kelondroBase64Order.enhancedCoder, 0), 0);byte[] key;int testsize = 5000;byte[][] delkeys = new byte[testsize / 5][];diff --git a/source/de/anomic/kelondro/kelondroSplittedTree.java b/source/de/anomic/kelondro/kelondroSplittedTree.javaindex 70fa6737b..36c8f8cdc 100644--- a/source/de/anomic/kelondro/kelondroSplittedTree.java+++ b/source/de/anomic/kelondro/kelondroSplittedTree.java@@ -82,7 +82,7 @@ public class kelondroSplittedTree implements kelondroIndex {File f;for (int i = 0; i < forkfactor; i++) {f = dbFile(pathToFiles, filenameStub, forkfactor, rowdef.columns(), i);- ktfs[i] = kelondroTree.open(f, buffersize/forkfactor, preloadTime / forkfactor, rowdef, objectOrder, txtProps, txtPropsWidth);+ ktfs[i] = kelondroTree.open(f, buffersize/forkfactor, preloadTime / forkfactor, rowdef, txtProps, txtPropsWidth);}this.order = objectOrder;ff = forkfactor;diff --git a/source/de/anomic/kelondro/kelondroStack.java b/source/de/anomic/kelondro/kelondroStack.javaindex 02f936e1d..5ab2fec20 100644--- a/source/de/anomic/kelondro/kelondroStack.java+++ b/source/de/anomic/kelondro/kelondroStack.java@@ -364,7 +364,7 @@ public final class kelondroStack extends kelondroRecords {for (int i = 0; i < args.length; i++) System.out.print(args[i] + " ");System.out.println("");byte[] ret = null;- kelondroRow lens = new kelondroRow("byte[] key-" + Integer.parseInt(args[1]) + ", byte[] value-" + Integer.parseInt(args[2]));+ kelondroRow lens = new kelondroRow("byte[] key-" + Integer.parseInt(args[1]) + ", byte[] value-" + Integer.parseInt(args[2]), kelondroNaturalOrder.naturalOrder, 0);try {if ((args.length > 4) || (args.length < 2)) {System.err.println("usage: kelondroStack -c|-p|-v|-g|-i|-s [file]|[key [value]] <db-file>");diff --git a/source/de/anomic/kelondro/kelondroTree.java b/source/de/anomic/kelondro/kelondroTree.javaindex 6531e847e..375d9e826 100644--- a/source/de/anomic/kelondro/kelondroTree.java+++ b/source/de/anomic/kelondro/kelondroTree.java@@ -85,49 +85,40 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {// class variablesprivate final Search writeSearchObj = new Search();- protected kelondroOrder objectOrder = new kelondroNaturalOrder(true);protected kelondroOrder loopDetectionOrder = new kelondroNaturalOrder(true);protected int readAheadChunkSize = 100;protected long lastIteratorCount = readAheadChunkSize;public kelondroTree(File file, long buffersize, long preloadTime, kelondroRow rowdef) throws IOException {- this(file, buffersize, preloadTime, rowdef, new kelondroNaturalOrder(true), rowdef.columns() /* txtProps */, 80 /* txtPropWidth */);+ this(file, buffersize, preloadTime, rowdef, rowdef.columns() /* txtProps */, 80 /* txtPropWidth */);}- public kelondroTree(File file, long buffersize, long preloadTime, kelondroRow rowdef,- kelondroOrder objectOrder, int txtProps, int txtPropsWidth) throws IOException {+ public kelondroTree(File file, long buffersize, long preloadTime, kelondroRow rowdef, int txtProps, int txtPropsWidth) throws IOException {// opens an existing tree file or creates a new tree filesuper(file, buffersize, preloadTime,thisOHBytes, thisOHHandles, rowdef,thisFHandles, txtProps, txtPropsWidth);-- super.setLogger(log);- if (super.fileExisted) {- this.objectOrder = objectOrder;- kelondroOrder oldOrder = readOrderType();- if ((oldOrder != null) && (!(oldOrder.equals(objectOrder)))) throw new IOException("wrong object order upon initialization. new order is " + objectOrder.toString() + ", old order was " + oldOrder.toString());- } else {+ if (!fileExisted) {// create new file structuresetHandle(root, null); // define the root value- this.objectOrder = objectOrder;- writeOrderType();}+ super.setLogger(log);+}public static final kelondroTree open(File file, long buffersize, long preloadTime, kelondroRow rowdef) {- return open(file, buffersize, preloadTime, rowdef, new kelondroNaturalOrder(true), rowdef.columns() /* txtProps */, 80 /* txtPropWidth */);+ return open(file, buffersize, preloadTime, rowdef, rowdef.columns() /* txtProps */, 80 /* txtPropWidth */);}- public static final kelondroTree open(File file, long buffersize, long preloadTime, kelondroRow rowdef,- kelondroOrder objectOrder, int txtProps, int txtPropsWidth) {+ public static final kelondroTree open(File file, long buffersize, long preloadTime, kelondroRow rowdef, int txtProps, int txtPropsWidth) {// opens new or existing file; in case that any error occur the file is deleted again and it is tried to create the file again// if that fails, the method returns nulltry {- return new kelondroTree(file, buffersize, preloadTime, rowdef, objectOrder, txtProps, txtPropsWidth);+ return new kelondroTree(file, buffersize, preloadTime, rowdef, txtProps, txtPropsWidth);} catch (IOException e) {file.delete();try {- return new kelondroTree(file, buffersize, preloadTime, rowdef, objectOrder, txtProps, txtPropsWidth);+ return new kelondroTree(file, buffersize, preloadTime, rowdef, txtProps, txtPropsWidth);} catch (IOException ee) {log.severe("cannot open or create file " + file.toString());e.printStackTrace();@@ -154,49 +145,14 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {if (exitOnFail) System.exit(-1);throw new RuntimeException("cannot set root handle / " + e.getMessage());}- this.objectOrder = objectOrder;- writeOrderType();super.setLogger(log);}public kelondroTree(kelondroRA ra, long buffersize, long preloadTime) throws IOException {// this opens a file with an existing tree in a kelondroRAsuper(ra, buffersize, preloadTime);- readOrderType();super.setLogger(log);}-- private void writeOrderType() {- try {- super.setDescription(objectOrder.signature().getBytes());- } catch (IOException e) {}- }-- private kelondroOrder readOrderType() {- try {- byte[] d = super.getDescription();- String s = new String(d).substring(0, 2);- return orderBySignature(s);- } catch (IOException e) {- return null;- }- }-- public static kelondroOrder orderBySignature(String signature) {- kelondroOrder oo = null;- if (oo == null) oo = kelondroNaturalOrder.bySignature(signature);- if (oo == null) oo = kelondroBase64Order.bySignature(signature);- if (oo == null) oo = new kelondroNaturalOrder(true);- return oo;- }-- public kelondroOrder order() {- return this.objectOrder;- }-- public int primarykey() {- return 0;- }public void clear() throws IOException {super.clear();@@ -313,7 +269,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {return;}// System.out.println("Comparing key = '" + new String(key) + "' with '" + otherkey + "':"); // debug- c = objectOrder.compare(key, keybuffer);+ c = row().objectOrder.compare(key, keybuffer);// System.out.println(c); // debugif (c == 0) {found = true;@@ -378,7 +334,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {public kelondroRow.Entry put(kelondroRow.Entry newrow) throws IOException {assert (newrow != null);assert (newrow.columns() == row().columns());- assert (!(serverLog.allZero(newrow.getColBytes(primarykey()))));+ assert (!(serverLog.allZero(newrow.getColBytes(ROW.primaryKey))));assert newrow.bytes().length <= super.ROW.objectsize;// Associates the specified value with the specified key in this mapkelondroRow.Entry result = null;@@ -874,7 +830,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {// correct nextNode upon start// this happens, if the start node was not proper, or could not be foundwhile ((nextNode != null) && (nextNode.getKey() != null)) {- int c = objectOrder.compare(firstKey, nextNode.getKey());+ int c = ROW.objectOrder.compare(firstKey, nextNode.getKey());if (c == 0) {if (including) {break; // correct + finished@@ -912,7 +868,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {Node searchNode = getNode(searchHandle, null, 0);byte[] startKey = start.getKey();int c, ct;- while ((c = objectOrder.compare(startKey, searchNode.getKey())) != 0) {+ while ((c = ROW.objectOrder.compare(startKey, searchNode.getKey())) != 0) {// the current 'thisNode' is not the start node, put it on the stackct = (c < 0) ? leftchild : rightchild;nodeStack.addLast(new Object[]{searchNode, new Integer(ct)});@@ -1016,7 +972,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {public TreeMap rowMap(boolean up, boolean rotating, byte[] firstKey, boolean including, int count) throws IOException {// returns an ordered map of keys/row relations; key objects are of type String, value objects are of type byte[][]- kelondroOrder setOrder = (kelondroOrder) objectOrder.clone();+ kelondroOrder setOrder = (kelondroOrder) ROW.objectOrder.clone();setOrder.direction(up);setOrder.rotate(firstKey);TreeMap rows = new TreeMap(setOrder);@@ -1036,7 +992,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {public TreeSet keySet(boolean up, boolean rotating, byte[] firstKey, boolean including, int count) throws IOException {// returns an ordered set of keys; objects are of type String- kelondroOrder setOrder = (kelondroOrder) objectOrder.clone();+ kelondroOrder setOrder = (kelondroOrder) ROW.objectOrder.clone();setOrder.direction(up);setOrder.rotate(firstKey);TreeSet set = new TreeSet(setOrder);@@ -1258,7 +1214,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {// test scriptFile testFile = new File("test.db");while (testFile.exists()) testFile.delete();- kelondroTree fm = new kelondroTree(testFile, 0x100000, 10, new kelondroRow("byte[] a-4, byte[] b-4"));+ kelondroTree fm = new kelondroTree(testFile, 0x100000, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));byte[] dummy = "".getBytes();fm.put("abc0".getBytes(), dummy); fm.put("bcd0".getBytes(), dummy);fm.put("def0".getBytes(), dummy); fm.put("bab0".getBytes(), dummy);@@ -1280,7 +1236,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {ret = null;}} else if (args.length == 2) {- kelondroTree fm = new kelondroTree(new File(args[1]), 0x100000, 10, new kelondroRow("byte[] a-4, byte[] b-4"));+ kelondroTree fm = new kelondroTree(new File(args[1]), 0x100000, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));if (args[0].equals("-v")) {fm.print();ret = null;@@ -1288,11 +1244,11 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {fm.close();} else if (args.length == 3) {if (args[0].equals("-d")) {- kelondroTree fm = new kelondroTree(new File(args[1]), 0x100000, 10, new kelondroRow("byte[] a-4, byte[] b-4"));+ kelondroTree fm = new kelondroTree(new File(args[1]), 0x100000, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));fm.remove(args[2].getBytes());fm.close();} else if (args[0].equals("-i")) {- kelondroTree fm = new kelondroTree(new File(args[1]), 0x100000, 10, new kelondroRow("byte[] a-4, byte[] b-4"));+ kelondroTree fm = new kelondroTree(new File(args[1]), 0x100000, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));int i = fm.imp(new File(args[1]),";");fm.close();ret = (i + " records imported").getBytes();@@ -1315,12 +1271,12 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {if (f != null) try {f.close();}catch(Exception e){}}} else if (args[0].equals("-g")) {- kelondroTree fm = new kelondroTree(new File(args[1]), 0x100000, 10, new kelondroRow("byte[] a-4, byte[] b-4"));+ kelondroTree fm = new kelondroTree(new File(args[1]), 0x100000, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));kelondroRow.Entry ret2 = fm.get(args[2].getBytes());ret = ((ret2 == null) ? null : ret2.getColBytes(1));fm.close();} else if (args[0].equals("-n")) {- kelondroTree fm = new kelondroTree(new File(args[1]), 0x100000, 10, new kelondroRow("byte[] a-4, byte[] b-4"));+ kelondroTree fm = new kelondroTree(new File(args[1]), 0x100000, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));//byte[][] keys = fm.getSequentialKeys(args[2].getBytes(), 500, true);Iterator rowIt = fm.rows(true, false, (args[2].length() == 0) ? null : args[2].getBytes());Vector v = new Vector();@@ -1333,11 +1289,11 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {// create <keylen> <valuelen> <filename>File f = new File(args[3]);if (f.exists()) f.delete();- kelondroRow lens = new kelondroRow("byte[] key-" + Integer.parseInt(args[1]) + ", byte[] value-" + Integer.parseInt(args[2]));+ kelondroRow lens = new kelondroRow("byte[] key-" + Integer.parseInt(args[1]) + ", byte[] value-" + Integer.parseInt(args[2]), kelondroNaturalOrder.naturalOrder, 0);kelondroTree fm = new kelondroTree(f, 0x100000, 10, lens);fm.close();} else if (args[0].equals("-u")) {- kelondroTree fm = new kelondroTree(new File(args[1]), 0x100000, 10, new kelondroRow("byte[] a-4, byte[] b-4"));+ kelondroTree fm = new kelondroTree(new File(args[1]), 0x100000, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));ret = fm.put(args[1].getBytes(), args[2].getBytes());fm.close();}@@ -1396,7 +1352,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {int steps = 0;while (true) {if (testFile.exists()) testFile.delete();- tt = new kelondroTree(testFile, 200, 10, new kelondroRow("byte[] a-4, byte[] b-4"));+ tt = new kelondroTree(testFile, 200, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));steps = 10 + ((int) System.currentTimeMillis() % 7) * (((int) System.currentTimeMillis() + 17) % 11);t = s;d = "";@@ -1462,7 +1418,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {File f = new File("test.db");if (f.exists()) f.delete();try {- kelondroTree tt = new kelondroTree(f, 1000, 10, new kelondroRow("byte[] a-4, byte[] b-4"));+ kelondroTree tt = new kelondroTree(f, 1000, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));byte[] b;b = testWord('B'); tt.put(b, b); //tt.print();b = testWord('C'); tt.put(b, b); //tt.print();@@ -1527,7 +1483,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {public static kelondroTree testTree(File f, String testentities) throws IOException {if (f.exists()) f.delete();- kelondroTree tt = new kelondroTree(f, 0, 10, new kelondroRow("byte[] a-4, byte[] b-4"));+ kelondroTree tt = new kelondroTree(f, 0, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));byte[] b;for (int i = 0; i < testentities.length(); i++) {b = testWord(testentities.charAt(i));diff --git a/source/de/anomic/plasma/plasmaCrawlBalancer.java b/source/de/anomic/plasma/plasmaCrawlBalancer.javaindex ccde8689f..1aca0579f 100644--- a/source/de/anomic/plasma/plasmaCrawlBalancer.java+++ b/source/de/anomic/plasma/plasmaCrawlBalancer.java@@ -48,6 +48,7 @@ import java.util.HashMap;import java.util.Iterator;import java.util.Map;+import de.anomic.kelondro.kelondroBase64Order;import de.anomic.kelondro.kelondroRecords;import de.anomic.kelondro.kelondroRow;import de.anomic.kelondro.kelondroStack;@@ -59,7 +60,7 @@ public class plasmaCrawlBalancer {private HashMap domainStacks;public plasmaCrawlBalancer(File stackFile) {- stack = kelondroStack.open(stackFile, new kelondroRow("byte[] urlhash-" + yacySeedDB.commonHashLength));+ stack = kelondroStack.open(stackFile, new kelondroRow("byte[] urlhash-" + yacySeedDB.commonHashLength, kelondroBase64Order.enhancedCoder, 0));domainStacks = new HashMap();}diff --git a/source/de/anomic/plasma/plasmaCrawlEURL.java b/source/de/anomic/plasma/plasmaCrawlEURL.javaindex b6c805358..f5bdb38a0 100644--- a/source/de/anomic/plasma/plasmaCrawlEURL.java+++ b/source/de/anomic/plasma/plasmaCrawlEURL.java@@ -145,7 +145,9 @@ public class plasmaCrawlEURL {"Cardinal loaddate-4 {b64e}, " + // the time when the url was last time tried to load"Cardinal retrycount-2 {b64e}, " + // number of load retries"String failcause-80, " + // string describing load failure- "byte[] flags-2"); // extra space+ "byte[] flags-2", // extra space+ kelondroBase64Order.enhancedCoder,+ 0);// the class objectprivate kelondroIndex urlIndexFile = null;@@ -155,7 +157,7 @@ public class plasmaCrawlEURL {String newCacheName = "urlErr3.table";cachePath.mkdirs();try {- urlIndexFile = new kelondroFlexTable(cachePath, newCacheName, bufferkb * 0x400, preloadTime, rowdef, kelondroBase64Order.enhancedCoder);+ urlIndexFile = new kelondroFlexTable(cachePath, newCacheName, bufferkb * 0x400, preloadTime, rowdef);} catch (IOException e) {e.printStackTrace();System.exit(-1);diff --git a/source/de/anomic/plasma/plasmaCrawlLURL.java b/source/de/anomic/plasma/plasmaCrawlLURL.javaindex 3bea8a442..15f9dc59e 100644--- a/source/de/anomic/plasma/plasmaCrawlLURL.java+++ b/source/de/anomic/plasma/plasmaCrawlLURL.java@@ -65,7 +65,6 @@ import de.anomic.http.httpc.response;import de.anomic.index.indexRWIEntryNew;import de.anomic.index.indexURLEntry;import de.anomic.index.indexURLEntryNew;-import de.anomic.kelondro.kelondroBase64Order;import de.anomic.kelondro.kelondroBitfield;import de.anomic.kelondro.kelondroCache;import de.anomic.kelondro.kelondroFlexSplitTable;@@ -98,7 +97,7 @@ public final class plasmaCrawlLURL {super();try {- urlIndexFile = new kelondroFlexSplitTable(new File(indexPath, "PUBLIC/TEXT"), "urls", buffer, preloadTime, indexURLEntryNew.rowdef, kelondroBase64Order.enhancedCoder);+ urlIndexFile = new kelondroFlexSplitTable(new File(indexPath, "PUBLIC/TEXT"), "urls", buffer, preloadTime, indexURLEntryNew.rowdef);} catch (IOException e) {e.printStackTrace();System.exit(-1);diff --git a/source/de/anomic/plasma/plasmaCrawlNURL.java b/source/de/anomic/plasma/plasmaCrawlNURL.javaindex c1569f5b6..c7e3d22d9 100644--- a/source/de/anomic/plasma/plasmaCrawlNURL.java+++ b/source/de/anomic/plasma/plasmaCrawlNURL.java@@ -91,7 +91,9 @@ public class plasmaCrawlNURL {"Cardinal parentbr-3 {b64e}, " + // number of anchors of the parent"Cardinal forkfactor-4 {b64e}, " + // sum of anchors of all ancestors"byte[] flags-4, " + // flags- "String handle-4" // extra handle+ "String handle-4", // extra handle+ kelondroBase64Order.enhancedCoder,+ 0);private final plasmaCrawlBalancer coreStack; // links found by crawling to depth-1@@ -132,7 +134,7 @@ public class plasmaCrawlNURL {limitStack = new plasmaCrawlBalancer(limitStackFile);overhangStack = new plasmaCrawlBalancer(overhangStackFile);remoteStack = new plasmaCrawlBalancer(remoteStackFile);- kelondroRow rowdef = new kelondroRow("byte[] urlhash-" + yacySeedDB.commonHashLength);+ kelondroRow rowdef = new kelondroRow("byte[] urlhash-" + yacySeedDB.commonHashLength, kelondroBase64Order.enhancedCoder, 0);imageStack = kelondroStack.open(imageStackFile, rowdef);movieStack = kelondroStack.open(movieStackFile, rowdef);musicStack = kelondroStack.open(musicStackFile, rowdef);@@ -196,7 +198,7 @@ public class plasmaCrawlNURL {String newCacheName = "urlNotice5.table";cacheStacksPath.mkdirs();try {- urlIndexFile = new kelondroCache(new kelondroFlexTable(cacheStacksPath, newCacheName, bufferkb / 2 * 0x400, preloadTime, rowdef, kelondroBase64Order.enhancedCoder), bufferkb / 2 * 0x400, true, false);+ urlIndexFile = new kelondroCache(new kelondroFlexTable(cacheStacksPath, newCacheName, bufferkb / 2 * 0x400, preloadTime, rowdef), bufferkb / 2 * 0x400, true, false);} catch (IOException e) {e.printStackTrace();System.exit(-1);diff --git a/source/de/anomic/plasma/plasmaCrawlStacker.java b/source/de/anomic/plasma/plasmaCrawlStacker.javaindex 229a7100f..9dae62b7c 100644--- a/source/de/anomic/plasma/plasmaCrawlStacker.java+++ b/source/de/anomic/plasma/plasmaCrawlStacker.java@@ -685,13 +685,13 @@ public final class plasmaCrawlStacker {if (!(cacheStacksPath.exists())) cacheStacksPath.mkdir(); // make the pathif (this.dbtype == QUEUE_DB_TYPE_RAM) {- this.urlEntryCache = new kelondroRowSet(plasmaCrawlNURL.rowdef, kelondroBase64Order.enhancedCoder, 0, 0);+ this.urlEntryCache = new kelondroRowSet(plasmaCrawlNURL.rowdef, 0);}if (this.dbtype == QUEUE_DB_TYPE_FLEX) {String newCacheName = "urlPreNotice2.table";cacheStacksPath.mkdirs();try {- this.urlEntryCache = new kelondroCache(new kelondroFlexTable(cacheStacksPath, newCacheName, bufferkb / 2 * 0x400, preloadTime, plasmaCrawlNURL.rowdef, kelondroBase64Order.enhancedCoder), bufferkb / 2 * 0x400, true, false);+ this.urlEntryCache = new kelondroCache(new kelondroFlexTable(cacheStacksPath, newCacheName, bufferkb / 2 * 0x400, preloadTime, plasmaCrawlNURL.rowdef), bufferkb / 2 * 0x400, true, false);} catch (IOException e) {e.printStackTrace();System.exit(-1);diff --git a/source/de/anomic/plasma/plasmaRankingCRProcess.java b/source/de/anomic/plasma/plasmaRankingCRProcess.javaindex a6c4d5c3f..6797033ea 100644--- a/source/de/anomic/plasma/plasmaRankingCRProcess.java+++ b/source/de/anomic/plasma/plasmaRankingCRProcess.java@@ -77,11 +77,12 @@ public class plasmaRankingCRProcess {"Cardinal LCount-2 {b64e}, Cardinal GCount-2 {b64e}, Cardinal ICount-2 {b64e}, Cardinal DCount-2 {b64e}, Cardinal TLength-3 {b64e}, " +"Cardinal WACount-3 {b64e}, Cardinal WUCount-3 {b64e}, Cardinal Flags-1 {b64e}, " +"Cardinal FUDate-3 {b64e}, Cardinal FDDate-3 {b64e}, Cardinal LUDate-3 {b64e}, " +- "Cardinal UCount-2 {b64e}, Cardinal PCount-2 {b64e}, Cardinal ACount-2 {b64e}, Cardinal VCount-2 {b64e}, Cardinal Vita-2 {b64e}");- public static final kelondroRow CRG_colrow = new kelondroRow("byte[] Anchor-12");+ "Cardinal UCount-2 {b64e}, Cardinal PCount-2 {b64e}, Cardinal ACount-2 {b64e}, Cardinal VCount-2 {b64e}, Cardinal Vita-2 {b64e}",+ kelondroBase64Order.enhancedCoder, 0);+ public static final kelondroRow CRG_colrow = new kelondroRow("byte[] Anchor-12", kelondroBase64Order.enhancedCoder, 0);public static final String CRG_accname = "CRG-a-attr";public static final String CRG_seqname = "CRG-a-coli";- public static final kelondroRow RCI_coli = new kelondroRow("byte[] RefereeDom-6");+ public static final kelondroRow RCI_coli = new kelondroRow("byte[] RefereeDom-6", kelondroBase64Order.enhancedCoder, 0);public static final String RCI_colname = "RCI-a-coli";private static boolean accumulate_upd(File f, kelondroAttrSeq acc) {@@ -260,7 +261,7 @@ public class plasmaRankingCRProcess {kelondroCollectionIndex newseq = null;if (newdb) {File path = to_file.getParentFile(); // path to storage place- newacc = new kelondroFlexTable(path, CRG_accname, 128 * 1024 * 1024, -1, CRG_accrow, kelondroBase64Order.enhancedCoder);+ newacc = new kelondroFlexTable(path, CRG_accname, 128 * 1024 * 1024, -1, CRG_accrow);newseq = new kelondroCollectionIndex(path, CRG_seqname, 12, kelondroBase64Order.enhancedCoder, 128 * 1024 * 1024, -1, 2, CRG_colrow);} else {if (!(to_file.exists())) {@@ -421,7 +422,7 @@ public class plasmaRankingCRProcess {// update domain-specific entryrci_entry = rci.get(anchorDom.getBytes(), false);- if (rci_entry == null) rci_entry = new kelondroRowSet(RCI_coli, kelondroBase64Order.enhancedCoder, 0, 0);+ if (rci_entry == null) rci_entry = new kelondroRowSet(RCI_coli, 0);rci_entry.add(refereeDom.getBytes());// insert entrydiff --git a/source/de/anomic/plasma/plasmaSearchPreOrder.java b/source/de/anomic/plasma/plasmaSearchPreOrder.javaindex fefb3acb7..81f425eee 100644--- a/source/de/anomic/plasma/plasmaSearchPreOrder.java+++ b/source/de/anomic/plasma/plasmaSearchPreOrder.java@@ -99,7 +99,7 @@ public final class plasmaSearchPreOrder {this.pageAcc = new TreeMap();for (int j = 0; j < count; j++) {iEntry = (indexRWIEntry) i.next();- if (iEntry.urlHash().length() != container.row().width(container.primarykey())) continue;+ if (iEntry.urlHash().length() != container.row().width(container.row().primaryKey())) continue;if ((!(query.constraint.equals(plasmaSearchQuery.catchall_constraint))) && (!(iEntry.flags().allOf(query.constraint)))) continue; // filter out entries that do not match the search constraintif (query.contentdom != plasmaSearchQuery.CONTENTDOM_TEXT) {if ((query.contentdom == plasmaSearchQuery.CONTENTDOM_AUDIO) && (!(iEntry.flags().get(plasmaCondenser.flag_cat_hasaudio)))) continue;diff --git a/source/de/anomic/plasma/plasmaSwitchboardQueue.java b/source/de/anomic/plasma/plasmaSwitchboardQueue.javaindex cc9a139d3..d5fd9909f 100644--- a/source/de/anomic/plasma/plasmaSwitchboardQueue.java+++ b/source/de/anomic/plasma/plasmaSwitchboardQueue.java@@ -54,6 +54,7 @@ import de.anomic.plasma.plasmaURL;import de.anomic.index.indexURLEntry;import de.anomic.kelondro.kelondroBase64Order;import de.anomic.kelondro.kelondroException;+import de.anomic.kelondro.kelondroNaturalOrder;import de.anomic.kelondro.kelondroRow;import de.anomic.kelondro.kelondroStack;import de.anomic.net.URL;@@ -86,7 +87,9 @@ public class plasmaSwitchboardQueue {"String initiator-" + yacySeedDB.commonHashLength + ", " + // the crawling initiator"Cardinal depth-2 {b64e}, " + // the prefetch depth so far, starts at 0"String profile-" + plasmaCrawlProfile.crawlProfileHandleLength + ", " + // the name of the prefetch profile handle- "String urldescr-80");+ "String urldescr-80",+ kelondroNaturalOrder.naturalOrder,+ 0);private void initQueueStack() {sbQueueStack = kelondroStack.open(sbQueueStackPath, rowdef);diff --git a/source/de/anomic/plasma/plasmaWordConnotation.java b/source/de/anomic/plasma/plasmaWordConnotation.javaindex a982cdf33..0b1555c8b 100644--- a/source/de/anomic/plasma/plasmaWordConnotation.java+++ b/source/de/anomic/plasma/plasmaWordConnotation.java@@ -49,6 +49,7 @@ 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 {@@ -59,7 +60,7 @@ public class plasmaWordConnotation {private kelondroDynTree refDB;public plasmaWordConnotation(File refDBfile, int bufferkb, long preloadTime, char fillChar) throws IOException {- refDB = new kelondroDynTree(refDBfile, bufferkb * 0x400, preloadTime, wordlength, nodesize, new kelondroRow("byte[] word-" + wordlength + ", Cardinal count-" + countlength), fillChar);+ refDB = new kelondroDynTree(refDBfile, bufferkb * 0x400, preloadTime, wordlength, nodesize, new kelondroRow("byte[] word-" + wordlength + ", Cardinal count-" + countlength, kelondroNaturalOrder.naturalOrder, 0), fillChar);}private void addSingleRef(String word, String reference) throws IOException {diff --git a/source/de/anomic/plasma/plasmaWordIndexAssortment.java b/source/de/anomic/plasma/plasmaWordIndexAssortment.javaindex e0b2b0936..d423ddc98 100644--- a/source/de/anomic/plasma/plasmaWordIndexAssortment.java+++ b/source/de/anomic/plasma/plasmaWordIndexAssortment.java@@ -60,6 +60,7 @@ import de.anomic.index.indexContainer;import de.anomic.index.indexRWIEntry;import de.anomic.index.indexRWIEntryNew;import de.anomic.index.indexRWIEntryOld;+import de.anomic.kelondro.kelondroBase64Order;import de.anomic.kelondro.kelondroCache;import de.anomic.kelondro.kelondroColumn;import de.anomic.kelondro.kelondroException;@@ -92,7 +93,7 @@ public final class plasmaWordIndexAssortment {structure[2] = new kelondroColumn("Cardinal time-8 {b256}");kelondroColumn p = new kelondroColumn("byte[] urlprops-" + indexRWIEntryOld.urlEntryRow.objectsize());for (int i = 0; i < assortmentCapacity; i++) structure[3 + i] = p;- return new kelondroRow(structure);+ return new kelondroRow(structure, kelondroBase64Order.enhancedCoder, 0);}private int assortmentCapacity(int rowsize) {diff --git a/source/de/anomic/plasma/plasmaWordIndexFile.java b/source/de/anomic/plasma/plasmaWordIndexFile.javaindex 40afbd6e7..2c3c30836 100644--- a/source/de/anomic/plasma/plasmaWordIndexFile.java+++ b/source/de/anomic/plasma/plasmaWordIndexFile.java@@ -52,6 +52,7 @@ import de.anomic.index.indexContainer;import de.anomic.index.indexRWIEntry;import de.anomic.index.indexRWIEntryNew;import de.anomic.index.indexRWIEntryOld;+import de.anomic.kelondro.kelondroBase64Order;import de.anomic.kelondro.kelondroException;import de.anomic.kelondro.kelondroRow;import de.anomic.kelondro.kelondroTree;@@ -92,7 +93,8 @@ public final class plasmaWordIndexFile {long cacheSize = theLocation.length();if (cacheSize > 1048576) cacheSize = 1048576;return kelondroTree.open(theLocation, cacheSize, 0,- new kelondroRow("byte[] urlhash-" + yacySeedDB.commonHashLength + ", byte[] ba-" + (indexRWIEntryOld.urlEntryRow.objectsize() - yacySeedDB.commonHashLength)));+ new kelondroRow("byte[] urlhash-" + yacySeedDB.commonHashLength + ", byte[] ba-" + (indexRWIEntryOld.urlEntryRow.objectsize() - yacySeedDB.commonHashLength),+ kelondroBase64Order.enhancedCoder, 0));}public static File wordHash2path(File databaseRoot, String hash) {diff --git a/source/de/anomic/yacy/yacyNewsQueue.java b/source/de/anomic/yacy/yacyNewsQueue.javaindex 4e7d15dd3..5dd2ef969 100644--- a/source/de/anomic/yacy/yacyNewsQueue.java+++ b/source/de/anomic/yacy/yacyNewsQueue.java@@ -49,6 +49,7 @@ import java.io.IOException;import java.util.Date;import de.anomic.kelondro.kelondroColumn;+import de.anomic.kelondro.kelondroNaturalOrder;import de.anomic.kelondro.kelondroRow;import de.anomic.kelondro.kelondroStack;@@ -61,7 +62,9 @@ public class yacyNewsQueue {public static final kelondroRow rowdef = new kelondroRow(new kelondroColumn[]{new kelondroColumn("newsid", kelondroColumn.celltype_string, kelondroColumn.encoder_bytes, yacyNewsRecord.idLength, "id = created + originator"),new kelondroColumn("last touched", kelondroColumn.celltype_string, kelondroColumn.encoder_bytes, yacyCore.universalDateShortPattern.length(), "")- });+ },+ kelondroNaturalOrder.naturalOrder, 0+ );public yacyNewsQueue(File path, yacyNewsDB newsDB) {this.path = path;diff --git a/source/de/anomic/yacy/yacyNewsRecord.java b/source/de/anomic/yacy/yacyNewsRecord.javaindex aa3d7d2ee..23c8e2f79 100644--- a/source/de/anomic/yacy/yacyNewsRecord.java+++ b/source/de/anomic/yacy/yacyNewsRecord.java@@ -47,6 +47,7 @@ package de.anomic.yacy;import java.util.Date;import java.util.Map;+import de.anomic.kelondro.kelondroNaturalOrder;import de.anomic.kelondro.kelondroRow;import de.anomic.server.serverCodings;import de.anomic.server.serverDate;@@ -75,7 +76,8 @@ public class yacyNewsRecord {"String cat-" + categoryStringLength + "," +"String rec-" + yacyCore.universalDateShortPattern.length() + "," +"short dis-2 {b64e}," +- "String att-" + attributesMaxLength+ "String att-" + attributesMaxLength,+ kelondroNaturalOrder.naturalOrder, 0);public yacyNewsRecord(String newsString) {diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.javaindex 0f837dd49..bbf54c97c 100644--- a/source/de/anomic/yacy/yacySeed.java+++ b/source/de/anomic/yacy/yacySeed.java@@ -481,62 +481,17 @@ public class yacySeed {public final boolean isOnline(final String type) {return type.equals(yacySeed.PEERTYPE_SENIOR) || type.equals(yacySeed.PEERTYPE_PRINCIPAL);}-- public static String encodeLex(long c, int length) {- if (length < 0) { length = 0; }- final StringBuffer s = new StringBuffer();- if (c == 0) {- s.insert(0, '-');- } else {- while (c > 0) {- s.insert(0, (char) (32 + (c % 96)));- c = c / 96;- }- }- if (length != 0 && s.length() > length) {- throw new RuntimeException("encodeLex result '" + s + "' exceeds demanded length of " + length + " digits");- }- if (length == 0) { length = 1; } // rare exception for the case that c == 0- while (s.length() < length) { s.insert(0, '-'); }- return s.toString();- }-- public static long decodeLex(String s) {- long c = 0;- for (int i = 0; i < s.length(); i++) {- c = c * 96 + (byte) s.charAt(i) - 32;- }- return c;- }-- private static long maxLex(int len) {- // computes the maximum number that can be coded with a lex-encoded String of length len- long c = 0;- for (int i = 0; i < len; i++) {- c = c * 96 + 90;- }- return c;- }-- private static long minLex(int len) {- // computes the minimum number that can be coded with a lex-encoded String of length len- long c = 0;- for (int i = 0; i < len; i++) {- c = c * 96 + 13;- }- return c;- }-- public static final long minDHTNumber = minLex(9);- public static final long maxDHTDistance = maxLex(9) - yacySeed.minDHTNumber;++ public static final long minDHTNumber = kelondroBase64Order.enhancedCoder.cardinal("AAAAAAAAAAAA".getBytes());+ public static final long maxDHTDistance = Long.MAX_VALUE;public final long dhtDistance(String wordhash) {// computes a virtual distance, the result must be set in relation to maxDHTDistace// if the distance is small, this peer is more responsible for that word hash// if the distance is big, this peer is less responsible for that word hash- final long myPos = decodeLex(this.hash.substring(0, 9));- final long wordPos = decodeLex(wordhash.substring(0, 9));- return (myPos > wordPos) ? (myPos - wordPos) : (myPos + yacySeed.maxDHTDistance - wordPos);+ final long myPos = dhtPosition(this.hash);+ final long wordPos = dhtPosition(wordhash);+ return (myPos > wordPos) ? (myPos - wordPos) : (yacySeed.maxDHTDistance - wordPos + myPos);}public final long dhtPosition() {@@ -546,7 +501,7 @@ public class yacySeed {public static long dhtPosition(String ahash) {// returns an absolute value- return decodeLex(ahash.substring(0, 9)) - yacySeed.minDHTNumber;+ return kelondroBase64Order.enhancedCoder.cardinal(ahash.getBytes());}public static yacySeed genLocalSeed(plasmaSwitchboard sb) {@@ -692,22 +647,4 @@ public class yacySeed {}}-/* public static void main(String[] argv) {- try {- plasmaSwitchboard sb = new plasmaSwitchboard("../httpProxy.init", "../httpProxy.conf");- yacySeed ys = genLocalSeed(sb);- String yp, yz, yc;- System.out.println("YACY String = " + ys.toString());- System.out.println("YACY SeedStr/p = " + (yp = ys.genSeedStr('p', null)));- //System.out.println("YACY SeedStr/z = " + (yz = ys.genSeedStr('z', null)));- System.out.println("YACY SeedStr/c = " + (yc = ys.genSeedStr('c', "abc")));- System.out.println("YACY remote/p = " + genRemoteSeed(yp, null).toString());- //System.out.println("YACY remote/z = " + genRemoteSeed(yz, null).toString());- System.out.println("YACY remote/c = " + genRemoteSeed(yc, "abc").toString());- System.exit(0);- } catch (IOException e) {- e.printStackTrace();- }- } */-}