Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
enhanced local search speed. The ranking process is now 6 times faster that before.
orbiter6eaa5a0e64b6
diff --git a/build.properties b/build.propertiesindex 735d2af6b..7984715a0 100644--- a/build.properties+++ b/build.properties@@ -3,7 +3,7 @@ javacSource=1.4javacTarget=1.4# Release Configuration-releaseVersion=0.551+releaseVersion=0.552releaseFile=yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gzproReleaseFile=yacy_pro_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gzreleaseFileParentDir=yacydiff --git a/htroot/CrawlURLFetch_p.java b/htroot/CrawlURLFetch_p.javaindex 107703cab..5e19f2d02 100644--- a/htroot/CrawlURLFetch_p.java+++ b/htroot/CrawlURLFetch_p.java@@ -465,7 +465,7 @@ public class CrawlURLFetch_p {return getListServletURL(ys.getPublicAddress(), MODE_LIST, this.count, yacyCore.seedDB.mySeed().hash);}- private int stackURLs(ArrayList /*of yacyURL*/ urls) throws InterruptedException {+ private int stackURLs(ArrayList /*of yacyURL*/ urls) {this.lastFailed = 0;this.lastFetchedURLs = 0;this.failed.clear();diff --git a/htroot/IndexCreateIndexingQueue_p.java b/htroot/IndexCreateIndexingQueue_p.javaindex f3a4e9010..ad57f0944 100644--- a/htroot/IndexCreateIndexingQueue_p.java+++ b/htroot/IndexCreateIndexingQueue_p.java@@ -43,7 +43,6 @@// javac -classpath .:../classes IndexCreate_p.java// if the shell's current path is HTROOT-import java.io.IOException;import java.util.ArrayList;import java.util.Iterator;@@ -179,7 +178,6 @@ public class IndexCreateIndexingQueue_p {yacySeed initiatorSeed, executorSeed;int j=0;for (int i = switchboard.crawlQueues.errorURL.stackSize() - 1; i >= (switchboard.crawlQueues.errorURL.stackSize() - showRejectedCount); i--) {- try {entry = switchboard.crawlQueues.errorURL.top(i);url = entry.url();if (url == null) continue;@@ -195,9 +193,6 @@ public class IndexCreateIndexingQueue_p {prop.put("rejected_list_"+j+"_dark", dark ? "1" : "0");dark = !dark;j++;- } catch (IOException e) {- e.printStackTrace();- }}prop.put("rejected_list", j);}diff --git a/htroot/QuickCrawlLink_p.java b/htroot/QuickCrawlLink_p.javaindex 8e0e41d97..537178685 100644--- a/htroot/QuickCrawlLink_p.java+++ b/htroot/QuickCrawlLink_p.java@@ -176,8 +176,7 @@ public class QuickCrawlLink_p {// stack URLString reasonString = null;- try {- reasonString = switchboard.crawlStacker.stackCrawl(+ reasonString = switchboard.crawlStacker.stackCrawl(crawlingStartURL,null,yacyCore.seedDB.mySeed().hash,@@ -186,9 +185,6 @@ public class QuickCrawlLink_p {0,pe);- } catch (InterruptedException e) {- reasonString = "Server shutdown in progess";- }// validate rejection reasonif (reasonString == null) {diff --git a/htroot/Ranking_p.java b/htroot/Ranking_p.javaindex 9f253cde2..1923cd43d 100644--- a/htroot/Ranking_p.java+++ b/htroot/Ranking_p.java@@ -131,10 +131,7 @@ public class Ranking_p {if ((post == null) || (env == null)) {// we create empty entries for template stringsfinal serverObjects prop = defaultValues();- plasmaSearchRankingProfile ranking =- (sb.getConfig("rankingProfile", "").length() == 0) ?- new plasmaSearchRankingProfile(plasmaSearchQuery.CONTENTDOM_TEXT) :- new plasmaSearchRankingProfile("", crypt.simpleDecode(sb.getConfig("rankingProfile", ""), null));+ plasmaSearchRankingProfile ranking = sb.getRanking();putRanking(prop, ranking, "local");return prop;}diff --git a/htroot/yacy/crawlOrder.java b/htroot/yacy/crawlOrder.javaindex a56efea78..791d1828b 100644--- a/htroot/yacy/crawlOrder.java+++ b/htroot/yacy/crawlOrder.java@@ -249,11 +249,8 @@ public final class crawlOrder {// stack urlswitchboard.getLog().logFinest("crawlOrder: stack: url='" + url + "'");String reasonString = null;- try {- reasonString = switchboard.crawlStacker.stackCrawl(url, referrer, iam, "REMOTE-CRAWLING", new Date(), 0, switchboard.defaultRemoteProfile);- } catch (InterruptedException e) {- reasonString = "Shutdown in progress";- }+ reasonString = switchboard.crawlStacker.stackCrawl(url, referrer, iam, "REMOTE-CRAWLING", new Date(), 0, switchboard.defaultRemoteProfile);+if (reasonString == null) {// liftoff!response = "stacked";diff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.javaindex e25f172d6..d84160faa 100644--- a/htroot/yacy/transferRWI.java+++ b/htroot/yacy/transferRWI.java@@ -52,6 +52,7 @@ import java.util.List;import de.anomic.http.httpHeader;import de.anomic.index.indexRWIEntry;+import de.anomic.index.indexRWIRowEntry;import de.anomic.plasma.plasmaSwitchboard;import de.anomic.plasma.urlPattern.plasmaURLPattern;import de.anomic.server.serverCore;@@ -153,7 +154,7 @@ public final class transferRWI {}wordHash = estring.substring(0, p);wordhashes[received] = wordHash;- iEntry = new indexRWIEntry(estring.substring(p));+ iEntry = new indexRWIRowEntry(estring.substring(p));urlHash = iEntry.urlHash();// block blacklisted entriesdiff --git a/htroot/yacysearch.java b/htroot/yacysearch.javaindex b157076b9..a97cbe1c1 100644--- a/htroot/yacysearch.java+++ b/htroot/yacysearch.java@@ -59,7 +59,6 @@ import de.anomic.plasma.plasmaCondenser;import de.anomic.plasma.plasmaParserDocument;import de.anomic.plasma.plasmaSearchEvent;import de.anomic.plasma.plasmaSearchQuery;-import de.anomic.plasma.plasmaSearchRankingProfile;import de.anomic.plasma.plasmaSearchProcessing;import de.anomic.plasma.plasmaSnippetCache;import de.anomic.plasma.plasmaSwitchboard;@@ -68,7 +67,6 @@ import de.anomic.server.serverDate;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;import de.anomic.server.logging.serverLog;-import de.anomic.tools.crypt;import de.anomic.tools.yFormatter;import de.anomic.yacy.yacyCore;import de.anomic.yacy.yacyNewsPool;@@ -269,7 +267,6 @@ public class yacysearch {"",20,constraint);- plasmaSearchRankingProfile ranking = (sb.getConfig("rankingProfile", "").length() == 0) ? new plasmaSearchRankingProfile(contentdomCode) : new plasmaSearchRankingProfile("", crypt.simpleDecode(sb.getConfig("rankingProfile", ""), null));plasmaSearchProcessing localTiming = new plasmaSearchProcessing(4 * theQuery.maximumTime / 10, theQuery.displayResults());String client = (String) header.get("CLIENTIP"); // the search client who initiated the search@@ -289,7 +286,7 @@ public class yacysearch {theQuery.setOffset(0); // in case that this is a new search, always start without a offsetoffset = 0;}- plasmaSearchEvent theSearch = plasmaSearchEvent.getEvent(theQuery, ranking, localTiming, sb.wordIndex, (sb.isRobinsonMode()) ? sb.clusterhashes : null, false, null);+ plasmaSearchEvent theSearch = plasmaSearchEvent.getEvent(theQuery, sb.getRanking(), localTiming, sb.wordIndex, (sb.isRobinsonMode()) ? sb.clusterhashes : null, false, null);// generate result objectserverLog.logFine("LOCAL_SEARCH", "SEARCH TIME AFTER ORDERING OF SEARCH RESULTS: " + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds");diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.javaindex cb664456d..9cbd82cc9 100644--- a/htroot/yacysearchitem.java+++ b/htroot/yacysearchitem.java@@ -36,7 +36,7 @@ import de.anomic.http.httpHeader;import de.anomic.kelondro.kelondroMSetTools;import de.anomic.kelondro.kelondroNaturalOrder;import de.anomic.plasma.plasmaSearchEvent;-import de.anomic.plasma.plasmaSearchPreOrder;+import de.anomic.plasma.plasmaSearchRankingProcess;import de.anomic.plasma.plasmaSearchQuery;import de.anomic.plasma.plasmaSearchRankingProfile;import de.anomic.plasma.plasmaSnippetCache;@@ -208,7 +208,7 @@ public class yacysearchitem {prop.put("content_urlhexhash", yacySeed.b64Hash2hexHash(result.hash()));prop.putHTML("content_urlname", nxTools.shortenURLString(result.urlname(), urllength));prop.put("content_date", plasmaSwitchboard.dateString(result.modified()));- prop.put("content_ybr", plasmaSearchPreOrder.ybr(result.hash()));+ prop.put("content_ybr", plasmaSearchRankingProcess.ybr(result.hash()));prop.putNum("content_size", result.filesize());TreeSet[] query = theQuery.queryWords();diff --git a/source/de/anomic/data/SitemapParser.java b/source/de/anomic/data/SitemapParser.javaindex 8bb15650d..851b840b8 100644--- a/source/de/anomic/data/SitemapParser.java+++ b/source/de/anomic/data/SitemapParser.java@@ -298,8 +298,7 @@ public class SitemapParser extends DefaultHandler {// URL needs to crawledString error = null;- try {- error = this.switchboard.crawlStacker.stackCrawl(+ error = this.switchboard.crawlStacker.stackCrawl(url,null, // this.siteMapURL.toString(),yacyCore.seedDB.mySeed().hash,@@ -308,9 +307,6 @@ public class SitemapParser extends DefaultHandler {0,this.crawlingProfile);- } catch (InterruptedException e) {- throw new SAXException ("Parsing interrupted", e);- }if (error != null) {try {diff --git a/source/de/anomic/index/indexContainer.java b/source/de/anomic/index/indexContainer.javaindex 9ee1ec67f..df8f30263 100644--- a/source/de/anomic/index/indexContainer.java+++ b/source/de/anomic/index/indexContainer.java@@ -72,18 +72,17 @@ public class indexContainer extends kelondroRowSet {public void add(indexRWIEntry entry) {// add without double-occurrence test- assert entry.toKelondroEntry().objectsize() == super.rowdef.objectsize();+ assert entry.toKelondroEntry().objectsize() == super.rowdef.objectsize;this.addUnique(entry.toKelondroEntry());}public void add(indexRWIEntry entry, long updateTime) {// add without double-occurrence test- assert entry.toKelondroEntry().objectsize() == super.rowdef.objectsize();+ assert entry.toKelondroEntry().objectsize() == super.rowdef.objectsize;this.add(entry);this.lastTimeWrote = updateTime;}-public static final indexContainer mergeUnique(indexContainer a, boolean aIsClone, indexContainer b, boolean bIsClone) {if ((aIsClone) && (bIsClone)) {if (a.size() > b.size()) return (indexContainer) mergeUnique(a, b); else return (indexContainer) mergeUnique(b, a);@@ -100,20 +99,20 @@ public class indexContainer extends kelondroRowSet {}public indexRWIEntry put(indexRWIEntry entry) {- assert entry.toKelondroEntry().objectsize() == super.rowdef.objectsize();+ assert entry.toKelondroEntry().objectsize() == super.rowdef.objectsize;kelondroRow.Entry r = super.put(entry.toKelondroEntry());if (r == null) return null;- return new indexRWIEntry(r);+ return new indexRWIRowEntry(r);}public boolean putRecent(indexRWIEntry entry) {- assert entry.toKelondroEntry().objectsize() == super.rowdef.objectsize();+ assert entry.toKelondroEntry().objectsize() == super.rowdef.objectsize;// returns true if the new entry was added, false if it already existedkelondroRow.Entry oldEntryRow = this.put(entry.toKelondroEntry());if (oldEntryRow == null) {return true;} else {- indexRWIEntry oldEntry = new indexRWIEntry(oldEntryRow);+ indexRWIEntry oldEntry = new indexRWIRowEntry(oldEntryRow);if (entry.isOlder(oldEntry)) { // A more recent Entry is already in this containerthis.put(oldEntry.toKelondroEntry()); // put it backreturn false;@@ -145,13 +144,13 @@ public class indexContainer extends kelondroRowSet {public indexRWIEntry get(String urlHash) {kelondroRow.Entry entry = this.get(urlHash.getBytes());if (entry == null) return null;- return new indexRWIEntry(entry);+ return new indexRWIRowEntry(entry);}public indexRWIEntry remove(String urlHash) {kelondroRow.Entry entry = remove(urlHash.getBytes(), true);if (entry == null) return null;- return new indexRWIEntry(entry);+ return new indexRWIRowEntry(entry);}public int removeEntries(Set urlHashes) {@@ -181,7 +180,7 @@ public class indexContainer extends kelondroRowSet {public Object next() {kelondroRow.Entry rentry = (kelondroRow.Entry) rowEntryIterator.next();if (rentry == null) return null;- return new indexRWIEntry(rentry);+ return new indexRWIRowEntry(rentry);}public void remove() {@@ -320,7 +319,7 @@ public class indexContainer extends kelondroRowSet {assert (keylength == i2.rowdef.width(0));indexContainer conj = new indexContainer(null, i1.rowdef, 0); // start with empty search resultif (!((i1.rowdef.getOrdering().signature().equals(i2.rowdef.getOrdering().signature())) &&- (i1.rowdef.primaryKey() == i2.rowdef.primaryKey()))) return conj; // ordering must be equal+ (i1.rowdef.primaryKeyIndex == i2.rowdef.primaryKeyIndex))) return conj; // ordering must be equalIterator e1 = i1.entries();Iterator e2 = i2.entries();int c;@@ -395,7 +394,7 @@ public class indexContainer extends kelondroRowSet {int keylength = pivot.rowdef.width(0);assert (keylength == excl.rowdef.width(0));if (!((pivot.rowdef.getOrdering().signature().equals(excl.rowdef.getOrdering().signature())) &&- (pivot.rowdef.primaryKey() == excl.rowdef.primaryKey()))) return pivot; // ordering must be equal+ (pivot.rowdef.primaryKeyIndex == excl.rowdef.primaryKeyIndex))) return pivot; // ordering must be equalIterator e1 = pivot.entries();Iterator e2 = excl.entries();int c;diff --git a/source/de/anomic/index/indexRAMRI.java b/source/de/anomic/index/indexRAMRI.javaindex f0481a1d5..c2706db5e 100644--- a/source/de/anomic/index/indexRAMRI.java+++ b/source/de/anomic/index/indexRAMRI.java@@ -84,7 +84,7 @@ 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 session@@ -215,7 +215,7 @@ public final class indexRAMRI implements indexRI {if ((row == null) || (row.empty(0)) || (row.empty(3))) continue;wordHash = row.getColString(0, "UTF-8");//creationTime = kelondroRecords.bytes2long(row[2]);- wordEntry = new indexRWIEntry(row.getColBytes(3));+ wordEntry = new indexRWIRowEntry(row.getColBytes(3));// store to cacheaddEntry(wordHash, wordEntry, startTime, false);urlCount++;diff --git a/source/de/anomic/index/indexRWIEntry.java b/source/de/anomic/index/indexRWIEntry.javaindex 345206463..194d632bc 100644--- a/source/de/anomic/index/indexRWIEntry.java+++ b/source/de/anomic/index/indexRWIEntry.java@@ -1,6 +1,6 @@// indexRWIEntry.java-// (C) 2006 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany-// first published 20.05.2006 on http://www.anomic.de+// (C) 2007 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany+// first published 07.11.2007 on http://www.anomic.de//// This is a part of YaCy, a peer-to-peer based web search engine//@@ -26,69 +26,11 @@package de.anomic.index;-import de.anomic.kelondro.kelondroBase64Order;import de.anomic.kelondro.kelondroBitfield;-import de.anomic.kelondro.kelondroColumn;-import de.anomic.kelondro.kelondroRow;import de.anomic.kelondro.kelondroRow.Entry;-import de.anomic.plasma.plasmaWordIndex;-import de.anomic.yacy.yacySeedDB;-public class indexRWIEntry implements Cloneable {+public interface indexRWIEntry {- // this object stores attributes to URL references inside RWI collections--- public static kelondroRow urlEntryRow = new kelondroRow(new kelondroColumn[]{- new kelondroColumn("h", kelondroColumn.celltype_string, kelondroColumn.encoder_bytes, yacySeedDB.commonHashLength, "urlhash"),- new kelondroColumn("a", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "lastModified"),- new kelondroColumn("s", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "freshUntil"),- new kelondroColumn("u", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "wordsInTitle"),- new kelondroColumn("w", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "wordsInText"),- new kelondroColumn("p", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "phrasesInText"),- new kelondroColumn("d", kelondroColumn.celltype_binary, kelondroColumn.encoder_bytes, 1, "doctype"),- new kelondroColumn("l", kelondroColumn.celltype_string, kelondroColumn.encoder_bytes, 2, "language"),- new kelondroColumn("x", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "llocal"),- new kelondroColumn("y", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "lother"),- new kelondroColumn("m", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "urlLength"),- new kelondroColumn("n", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "urlComps"),- new kelondroColumn("g", kelondroColumn.celltype_binary, kelondroColumn.encoder_bytes, 1, "typeofword"),- new kelondroColumn("z", kelondroColumn.celltype_bitfield, kelondroColumn.encoder_bytes, 4, "flags"),- new kelondroColumn("c", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "hitcount"),- new kelondroColumn("t", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "posintext"),- new kelondroColumn("r", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "posinphrase"),- 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 properties- private static final int col_urlhash = 0; // h 12 the url hash b64-encoded- private static final int col_lastModified = 1; // a 2 last-modified time of the document where word appears- private static final int col_freshUntil = 2; // s 2 TTL for the word, so it can be removed easily if the TTL is short- private static final int col_wordsInTitle = 3; // u 1 words in description/length (longer are better?)- private static final int col_wordsInText = 4; // w 2 total number of words in document- private static final int col_phrasesInText = 5; // p 2 total number of phrases in document- private static final int col_doctype = 6; // d 1 type of document- private static final int col_language = 7; // l 2 (guessed) language of document- private static final int col_llocal = 8; // x 1 outlinks to same domain- private static final int col_lother = 9; // y 1 outlinks to other domain- private static final int col_urlLength = 10; // m 1 byte-length of complete URL- private static final int col_urlComps = 11; // n 1 number of path components-- // dynamic properties- private static final int col_typeofword = 12; // g 1 grammatical classification- private static final int col_flags = 13; // z 4 b64-encoded appearance flags (24 bit, see definition below)- private static final int col_hitcount = 14; // c 1 number of occurrences of this word in text- private static final int col_posintext = 15; // t 2 first appearance of word in text- private static final int col_posinphrase = 16; // r 1 position of word in its phrase- private static final int col_posofphrase = 17; // o 1 number of the phrase where word appears- private static final int col_worddistance = 18; // i 1 initial zero; may be used as reserve: is filled during search- private static final int col_reserve = 19; // k 1 reserve-// appearance flags, used in RWI entry// the flags 0..23 are identical to the category flags in plasmaCondenserpublic static final int flag_app_url = 24; // word appears in url@@ -97,249 +39,57 @@ public class indexRWIEntry implements Cloneable {public static final int flag_app_tags = 27; // word appears in header tagspublic static final int flag_app_reference = 28; // word appears in anchor description text (the reference to an url), or any alternative text field of a linkpublic static final int flag_app_emphasized = 29; // word is emphasized in text (i.e. bold, italics, special size)-- private kelondroRow.Entry entry;-- public indexRWIEntry(String urlHash,- int urlLength, // byte-length of complete URL- int urlComps, // number of path components- int titleLength, // length of description/length (longer are better?)- int hitcount, // how often appears this word in the text- int wordcount, // total number of words- int phrasecount, // total number of phrases- int posintext, // position of word in all words- int posinphrase, // position of word in its phrase- int posofphrase, // number of the phrase where word appears- int worddistance, // word distance; this is 0 by default, and set to the difference of posintext from two indexes if these are combined (simultanous search). If stored, this shows that the result was obtained by remote search- int sizeOfPage, // # of bytes of the page TODO: not needed any more- long lastmodified, // last-modified time of the document where word appears- long updatetime, // update time; this is needed to compute a TTL for the word, so it can be removed easily if the TTL is short- String language, // (guessed) language of document- char doctype, // type of document- int outlinksSame, // outlinks to same domain- int outlinksOther, // outlinks to other domain- kelondroBitfield flags // attributes to the url and to the word according the url- ) {- assert (urlHash.length() == 12) : "urlhash = " + urlHash;- if ((language == null) || (language.length() != urlEntryRow.width(col_language))) language = "uk";- this.entry = urlEntryRow.newEntry();- int mddlm = plasmaWordIndex.microDateDays(lastmodified);- int mddct = plasmaWordIndex.microDateDays(updatetime);- this.entry.setCol(col_urlhash, urlHash, null);- this.entry.setCol(col_lastModified, mddlm);- this.entry.setCol(col_freshUntil, Math.max(0, mddlm + (mddct - mddlm) * 2)); // TTL computation- this.entry.setCol(col_wordsInTitle, titleLength / 6); // word count estimation; TODO: change value handover to number of words- this.entry.setCol(col_wordsInText, wordcount);- this.entry.setCol(col_phrasesInText, phrasecount);- this.entry.setCol(col_doctype, new byte[]{(byte) doctype});- this.entry.setCol(col_language, language, null);- this.entry.setCol(col_llocal, outlinksSame);- this.entry.setCol(col_lother, outlinksOther);- this.entry.setCol(col_urlLength, urlLength);- this.entry.setCol(col_urlComps, urlComps);- this.entry.setCol(col_typeofword, new byte[]{(byte) 0}); // TODO: grammatical classification- this.entry.setCol(col_flags, flags.bytes());- this.entry.setCol(col_hitcount, hitcount);- this.entry.setCol(col_posintext, posintext);- this.entry.setCol(col_posinphrase, posinphrase);- this.entry.setCol(col_posofphrase, posofphrase);- this.entry.setCol(col_worddistance, worddistance);- this.entry.setCol(col_reserve, 0);- }-- public indexRWIEntry(String urlHash, String code) {- // the code is the external form of the row minus the leading urlHash entry- this.entry = urlEntryRow.newEntry((urlHash + code).getBytes());- }-- public indexRWIEntry(String external) {- this.entry = urlEntryRow.newEntry(external, true);- }-- public indexRWIEntry(byte[] row) {- this.entry = urlEntryRow.newEntry(row);- }-- public indexRWIEntry(kelondroRow.Entry rentry) {- // FIXME: see if cloning is necessary- this.entry = rentry;- }+ public String toPropertyForm();- public static int days(long time) {- // calculates the number of days since 1.1.1970 and returns this as 4-byte array- return (int) (time / 86400000);- }-- public Object clone() {- byte[] b = new byte[urlEntryRow.objectsize()];- System.arraycopy(entry.bytes(), 0, b, 0, urlEntryRow.objectsize());- return new indexRWIEntry(b);- }-- public String toPropertyForm() {- return entry.toPropertyForm(true, true, false);- }-- public Entry toKelondroEntry() {- return this.entry;- }+ public Entry toKelondroEntry();- public String urlHash() {- return this.entry.getColString(col_urlhash, null);- }+ public String urlHash();- public int quality() {- return 0; // not used any more- }+ public int quality();- public int virtualAge() {- return (int) this.entry.getColLong(col_lastModified); // this is the time in MicoDateDays format- }+ public int virtualAge();- public long lastModified() {- return plasmaWordIndex.reverseMicroDateDays((int) this.entry.getColLong(col_lastModified));- }+ public long lastModified();- public long freshUntil() {- return plasmaWordIndex.reverseMicroDateDays((int) this.entry.getColLong(col_freshUntil));- }+ public long freshUntil();- public int hitcount() {- return (int) this.entry.getColLong(col_hitcount);- }+ public int hitcount();- public int posintext() {- return (int) this.entry.getColLong(col_posintext);- }+ public int posintext();- public int posinphrase() {- return (int) this.entry.getColLong(col_posinphrase);- }+ public int posinphrase();- public int posofphrase() {- return (int) this.entry.getColLong(col_posofphrase);- }+ public int posofphrase();- public int wordsintext() {- return (int) this.entry.getColLong(col_wordsInText);- }+ public int wordsintext();- public int phrasesintext() {- return (int) this.entry.getColLong(col_phrasesInText);- }+ public int phrasesintext();- public String getLanguage() {- return this.entry.getColString(col_language, null);- }+ public String getLanguage();- public char getType() {- return (char) this.entry.getColByte(col_doctype);- }+ public char getType();- public int wordsintitle() {- return (int) this.entry.getColLong(col_wordsInTitle);- }-- public int llocal() {- return (int) this.entry.getColLong(col_llocal);- }-- public int lother() {- return (int) this.entry.getColLong(col_lother);- }+ public int wordsintitle();- public int urllength() {- return (int) this.entry.getColLong(col_urlLength);- }+ public int llocal();- public int urlcomps() {- return (int) this.entry.getColLong(col_urlComps);- }+ public int lother();- public kelondroBitfield flags() {- return new kelondroBitfield(this.entry.getColBytes(col_flags));- }-- public String toString() {- return toPropertyForm();- }-- public static indexRWIEntry combineDistance(indexRWIEntry ie1, indexRWIEntry ie2) {- // returns a modified entry of the first argument- ie1.entry.setCol(col_worddistance, ie1.worddistance() + ie2.worddistance() + Math.abs(ie1.posintext() - ie2.posintext()));- ie1.entry.setCol(col_posintext, Math.min(ie1.posintext(), ie2.posintext()));- ie1.entry.setCol(col_posinphrase, (ie1.posofphrase() == ie2.posofphrase()) ? ie1.posofphrase() : 0 /*unknown*/);- ie1.entry.setCol(col_posofphrase, Math.min(ie1.posofphrase(), ie2.posofphrase()));- ie1.entry.setCol(col_wordsInText, (ie1.wordsintext() + ie2.wordsintext()) / 2);- return ie1;- }-- public void combineDistance(indexRWIEntry oe) {- combineDistance(this, oe);- }-- public int worddistance() {- return (int) this.entry.getColLong(col_worddistance);- }+ public int urllength();- public static final void min(indexRWIEntry t, indexRWIEntry other) {- int v;- long w;- if (t.hitcount() > (v = other.hitcount())) t.entry.setCol(col_hitcount, other.hitcount());- if (t.wordsintext() > (v = other.wordsintext())) t.entry.setCol(col_wordsInText, v);- if (t.phrasesintext() > (v = other.phrasesintext())) t.entry.setCol(col_phrasesInText, v);- if (t.posintext() > (v = other.posintext())) t.entry.setCol(col_posintext, v);- if (t.posinphrase() > (v = other.posinphrase())) t.entry.setCol(col_posinphrase, v);- if (t.posofphrase() > (v = other.posofphrase())) t.entry.setCol(col_posofphrase, v);- if (t.worddistance() > (v = other.worddistance())) t.entry.setCol(col_worddistance, v);- if (t.lastModified() > (w = other.lastModified())) t.entry.setCol(col_lastModified, w);- if (t.urllength() > (v = other.urllength())) t.entry.setCol(col_urlLength, v);- if (t.urlcomps() > (v = other.urlcomps())) t.entry.setCol(col_urlComps, v);- if (t.wordsintitle() > (v = other.wordsintitle())) t.entry.setCol(col_wordsInTitle, v);- }+ public int urlcomps();- public static final void max(indexRWIEntry t, indexRWIEntry other) {- int v;- long w;- if (t.hitcount() < (v = other.hitcount())) t.entry.setCol(col_hitcount, v);- if (t.wordsintext() < (v = other.wordsintext())) t.entry.setCol(col_wordsInText, v);- if (t.phrasesintext() < (v = other.phrasesintext())) t.entry.setCol(col_phrasesInText, v);- if (t.posintext() < (v = other.posintext())) t.entry.setCol(col_posintext, v);- if (t.posinphrase() < (v = other.posinphrase())) t.entry.setCol(col_posinphrase, v);- if (t.posofphrase() < (v = other.posofphrase())) t.entry.setCol(col_posofphrase, v);- if (t.worddistance() < (v = other.worddistance())) t.entry.setCol(col_worddistance, v);- if (t.lastModified() < (w = other.lastModified())) t.entry.setCol(col_lastModified, w);- if (t.urllength() < (v = other.urllength())) t.entry.setCol(col_urlLength, v);- if (t.urlcomps() < (v = other.urlcomps())) t.entry.setCol(col_urlComps, v);- if (t.wordsintitle() < (v = other.wordsintitle())) t.entry.setCol(col_wordsInTitle, v);- }+ public kelondroBitfield flags();+ public String toString();- public void min(indexRWIEntry other) {- min(this, other);- }+ public void combineDistance(indexRWIEntry oe);- public void max(indexRWIEntry other) {- max(this, other);- }+ public int worddistance();- public boolean isNewer(indexRWIEntry other) {- if (other == null) return true;- if (this.lastModified() > other.lastModified()) return true;- if (this.lastModified() == other.lastModified()) {- if (this.quality() > other.quality()) return true;- }- return false;- }+ public boolean isNewer(indexRWIEntry other);- public boolean isOlder(indexRWIEntry other) {- if (other == null) return false;- if (this.lastModified() < other.lastModified()) return true;- if (this.lastModified() == other.lastModified()) {- if (this.quality() < other.quality()) return true;- }- return false;- }+ public boolean isOlder(indexRWIEntry other);}\ No newline at end of filediff --git a/source/de/anomic/index/indexRWIEntryOrder.java b/source/de/anomic/index/indexRWIEntryOrder.javanew file mode 100644index 000000000..fda5be6c5--- /dev/null+++ b/source/de/anomic/index/indexRWIEntryOrder.java@@ -0,0 +1,180 @@+// indexRWIEntryOrder.java+// (C) 2007 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany+// first published 07.11.2007 on http://yacy.net+//+// This is a part of YaCy, a peer-to-peer based web search engine+//+// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $+// $LastChangedRevision: 1986 $+// $LastChangedBy: orbiter $+//+// LICENSE+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++package de.anomic.index;++import de.anomic.kelondro.kelondroAbstractOrder;+import de.anomic.kelondro.kelondroBitfield;+import de.anomic.kelondro.kelondroOrder;+import de.anomic.plasma.plasmaCondenser;+import de.anomic.plasma.plasmaSearchRankingProcess;+import de.anomic.plasma.plasmaSearchRankingProfile;+import de.anomic.yacy.yacyURL;++public class indexRWIEntryOrder extends kelondroAbstractOrder implements kelondroOrder {+ private indexRWIVarEntry min, max;+ private plasmaSearchRankingProfile ranking;++ private static final int processors = Runtime.getRuntime().availableProcessors(); // for multiprocessor support, used during normalization++ public indexRWIEntryOrder(plasmaSearchRankingProfile profile) {+ this.min = null;+ this.max = null;+ this.ranking = profile;+ }++ public void extend(indexContainer container) {+ assert (container != null);++ //long s0 = System.currentTimeMillis();+ if ((processors > 1) && (container.size() > 10000)) {+ // run minmax with two threads+ int middle = container.size() / 2;+ minmaxfinder mmf0 = new minmaxfinder(container, 0, middle);+ mmf0.start(); // fork here+ minmaxfinder mmf1 = new minmaxfinder(container, middle, container.size());+ mmf1.run(); // execute other fork in this thread+ if (this.min == null) this.min = mmf1.entryMin; else indexRWIVarEntry.min(this.min, mmf1.entryMin);+ if (this.max == null) this.max = mmf1.entryMax; else indexRWIVarEntry.max(this.max, mmf1.entryMax);+ try {mmf0.join();} catch (InterruptedException e) {} // wait for fork thread to finish+ if (this.min == null) this.min = mmf0.entryMin; else indexRWIVarEntry.min(this.min, mmf0.entryMin);+ if (this.max == null) this.max = mmf0.entryMax; else indexRWIVarEntry.max(this.max, mmf0.entryMax);+ //long s1= System.currentTimeMillis(), sc = Math.max(1, s1 - s0);+ //System.out.println("***DEBUG*** indexRWIEntry.Order (2-THREADED): " + sc + " milliseconds for " + container.size() + " entries, " + (container.size() / sc) + " entries/millisecond");+ } else {+ // run minmax in one thread+ minmaxfinder mmf = new minmaxfinder(container, 0, container.size());+ mmf.run(); // execute without multi-threading+ if (this.min == null) this.min = mmf.entryMin; else indexRWIVarEntry.min(this.min, mmf.entryMin);+ if (this.max == null) this.max = mmf.entryMax; else indexRWIVarEntry.max(this.max, mmf.entryMax);+ //long s1= System.currentTimeMillis(), sc = Math.max(1, s1 - s0);+ //System.out.println("***DEBUG*** indexRWIEntry.Order (ONETHREAD): " + sc + " milliseconds for " + container.size() + " entries, " + (container.size() / sc) + " entries/millisecond");+ }+ }++ public Object clone() {+ return null;+ }++ public long cardinal(byte[] key) {+ return cardinal(new indexRWIRowEntry(key));+ }++ public long cardinal(indexRWIEntry t) {+ //return Long.MAX_VALUE - preRanking(ranking, iEntry, this.entryMin, this.entryMax, this.searchWords);+ // the normalizedEntry must be a normalized indexEntry+ kelondroBitfield flags = t.flags();+ long r = ((255 - yacyURL.domLengthNormalized(t.urlHash())) << ranking.coeff_domlength)+ + ((255 - (plasmaSearchRankingProcess.ybr(t.urlHash()) << 4 )) << ranking.coeff_ybr)+ + ((255 - (((t.virtualAge() - min.virtualAge() ) << 8) / (1 + max.virtualAge() - min.virtualAge()) )) << ranking.coeff_date)+ + ( (((t.wordsintitle() - min.wordsintitle() ) << 8) / (1 + max.wordsintitle() - min.wordsintitle()) ) << ranking.coeff_wordsintitle)+ + ( (((t.wordsintext() - min.wordsintext() ) << 8) / (1 + max.wordsintext() - min.wordsintext()) ) << ranking.coeff_wordsintext)+ + ( (((t.phrasesintext()- min.phrasesintext()) << 8) / (1 + max.phrasesintext()- min.phrasesintext()) ) << ranking.coeff_phrasesintext)+ + ( (((t.llocal() - min.llocal() ) << 8) / (1 + max.llocal() - min.llocal()) ) << ranking.coeff_llocal)+ + ( (((t.lother() - min.lother() ) << 8) / (1 + max.lother() - min.lother()) ) << ranking.coeff_lother)+ + ( (((t.hitcount() - min.hitcount() ) << 8) / (1 + max.hitcount() - min.hitcount()) ) << ranking.coeff_hitcount)+ + ((255 - (((t.urllength() - min.urllength() ) << 8) / (1 + max.urllength() - min.urllength()) )) << ranking.coeff_urllength)+ + ((255 - (((t.urlcomps() - min.urlcomps() ) << 8) / (1 + max.urlcomps() - min.urlcomps()) )) << ranking.coeff_urlcomps)+ + ((255 - (((t.posintext() - min.posintext() ) << 8) / (1 + max.posintext() - min.posintext()) )) << ranking.coeff_posintext)+ + ((255 - (((t.posofphrase() - min.posofphrase() ) << 8) / (1 + max.posofphrase() - min.posofphrase()) )) << ranking.coeff_posofphrase)+ + ((255 - (((t.posinphrase() - min.posinphrase() ) << 8) / (1 + max.posinphrase() - min.posinphrase()) )) << ranking.coeff_posinphrase)+ + ((255 - (((t.worddistance() - min.worddistance() ) << 8) / (1 + max.worddistance() - min.worddistance()) )) << ranking.coeff_worddistance)+ + (((flags.get(indexRWIEntry.flag_app_url)) ? 255 << ranking.coeff_appurl : 0))+ + (((flags.get(indexRWIEntry.flag_app_descr)) ? 255 << ranking.coeff_appdescr : 0))+ + (((flags.get(indexRWIEntry.flag_app_author)) ? 255 << ranking.coeff_appauthor : 0))+ + (((flags.get(indexRWIEntry.flag_app_tags)) ? 255 << ranking.coeff_apptags : 0))+ + (((flags.get(indexRWIEntry.flag_app_reference)) ? 255 << ranking.coeff_appref : 0))+ + (((flags.get(indexRWIEntry.flag_app_emphasized)) ? 255 << ranking.coeff_appemph : 0))+ + (((flags.get(plasmaCondenser.flag_cat_indexof)) ? 255 << ranking.coeff_catindexof : 0))+ + (((flags.get(plasmaCondenser.flag_cat_hasimage)) ? 255 << ranking.coeff_cathasimage : 0))+ + (((flags.get(plasmaCondenser.flag_cat_hasaudio)) ? 255 << ranking.coeff_cathasaudio : 0))+ + (((flags.get(plasmaCondenser.flag_cat_hasvideo)) ? 255 << ranking.coeff_cathasvideo : 0))+ + (((flags.get(plasmaCondenser.flag_cat_hasapp)) ? 255 << ranking.coeff_cathasapp : 0))+ + (((yacyURL.probablyRootURL(t.urlHash())) ? 15 << ranking.coeff_urllength : 0));+ //if (searchWords != null) r += (yacyURL.probablyWordURL(t.urlHash(), searchWords) != null) ? 256 << ranking.coeff_appurl : 0;++ return Long.MAX_VALUE - r; // returns a reversed number: the lower the number the better the ranking. This is used for simple sorting with a TreeMap+ }++ public int compare(Object a, Object b) {+ if ((a instanceof indexRWIEntry) && (b instanceof indexRWIEntry)) {+ return compare((indexRWIEntry) a, (indexRWIEntry) b);+ } else {+ return super.compare(a, b);+ }+ }++ public int compare(indexRWIEntry a, indexRWIEntry b) {+ return 0;+ }++ public int compare(byte[] a, byte[] b) {+ return compare(new indexRWIRowEntry(a), new indexRWIRowEntry(b));+ }++ public int compare(byte[] a, int aoffset, int alength, byte[] b, int boffset, int blength) {+ return compare(new indexRWIRowEntry(a, aoffset, false), new indexRWIRowEntry(b, boffset, false));+ }++ public String signature() {+ return "rx";+ }++ public boolean wellformed(byte[] a) {+ return true;+ }++ public boolean wellformed(byte[] a, int astart, int alength) {+ return true;+ }++ public static class minmaxfinder extends Thread {++ private indexRWIVarEntry entryMin, entryMax;+ private indexContainer container;+ private int start, end;++ public minmaxfinder(indexContainer container, int start /*including*/, int end /*excluding*/) {+ this.container = container;+ this.start = start;+ this.end = end;+ }++ public void run() {+ // find min/max to obtain limits for normalization+ this.entryMin = null;+ this.entryMax = null;+ indexRWIRowEntry iEntry;+ int p = this.start;+ while (p < this.end) {+ iEntry = new indexRWIRowEntry(container.get(p++));+ if (this.entryMin == null) this.entryMin = new indexRWIVarEntry(iEntry); else indexRWIVarEntry.min(this.entryMin, iEntry);+ if (this.entryMax == null) this.entryMax = new indexRWIVarEntry(iEntry); else indexRWIVarEntry.max(this.entryMax, iEntry);+ }+ }+ }++}diff --git a/source/de/anomic/index/indexRWIRowEntry.java b/source/de/anomic/index/indexRWIRowEntry.javanew file mode 100644index 000000000..721b8d48f--- /dev/null+++ b/source/de/anomic/index/indexRWIRowEntry.java@@ -0,0 +1,307 @@+// indexRWIRowEntry.java+// (C) 2006 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany+// first published 20.05.2006 on http://yacy.net+//+// This is a part of YaCy, a peer-to-peer based web search engine+//+// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $+// $LastChangedRevision: 1986 $+// $LastChangedBy: orbiter $+//+// LICENSE+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++package de.anomic.index;++import de.anomic.kelondro.kelondroBase64Order;+import de.anomic.kelondro.kelondroBitfield;+import de.anomic.kelondro.kelondroColumn;+import de.anomic.kelondro.kelondroRow;+import de.anomic.kelondro.kelondroRow.Entry;+import de.anomic.plasma.plasmaWordIndex;+import de.anomic.yacy.yacySeedDB;++public final class indexRWIRowEntry implements indexRWIEntry {++ // this object stores attributes to URL references inside RWI collections++ public static kelondroRow urlEntryRow = new kelondroRow(new kelondroColumn[]{+ new kelondroColumn("h", kelondroColumn.celltype_string, kelondroColumn.encoder_bytes, yacySeedDB.commonHashLength, "urlhash"),+ new kelondroColumn("a", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "lastModified"),+ new kelondroColumn("s", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "freshUntil"),+ new kelondroColumn("u", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "wordsInTitle"),+ new kelondroColumn("w", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "wordsInText"),+ new kelondroColumn("p", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "phrasesInText"),+ new kelondroColumn("d", kelondroColumn.celltype_binary, kelondroColumn.encoder_bytes, 1, "doctype"),+ new kelondroColumn("l", kelondroColumn.celltype_string, kelondroColumn.encoder_bytes, 2, "language"),+ new kelondroColumn("x", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "llocal"),+ new kelondroColumn("y", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "lother"),+ new kelondroColumn("m", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "urlLength"),+ new kelondroColumn("n", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "urlComps"),+ new kelondroColumn("g", kelondroColumn.celltype_binary, kelondroColumn.encoder_bytes, 1, "typeofword"),+ new kelondroColumn("z", kelondroColumn.celltype_bitfield, kelondroColumn.encoder_bytes, 4, "flags"),+ new kelondroColumn("c", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "hitcount"),+ new kelondroColumn("t", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "posintext"),+ new kelondroColumn("r", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "posinphrase"),+ 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 properties+ private static final int col_urlhash = 0; // h 12 the url hash b64-encoded+ private static final int col_lastModified = 1; // a 2 last-modified time of the document where word appears+ private static final int col_freshUntil = 2; // s 2 TTL for the word, so it can be removed easily if the TTL is short+ private static final int col_wordsInTitle = 3; // u 1 words in description/length (longer are better?)+ private static final int col_wordsInText = 4; // w 2 total number of words in document+ private static final int col_phrasesInText = 5; // p 2 total number of phrases in document+ private static final int col_doctype = 6; // d 1 type of document+ private static final int col_language = 7; // l 2 (guessed) language of document+ private static final int col_llocal = 8; // x 1 outlinks to same domain+ private static final int col_lother = 9; // y 1 outlinks to other domain+ private static final int col_urlLength = 10; // m 1 byte-length of complete URL+ private static final int col_urlComps = 11; // n 1 number of path components++ // dynamic properties+ private static final int col_typeofword = 12; // g 1 grammatical classification+ private static final int col_flags = 13; // z 4 b64-encoded appearance flags (24 bit, see definition below)+ private static final int col_hitcount = 14; // c 1 number of occurrences of this word in text+ private static final int col_posintext = 15; // t 2 first appearance of word in text+ private static final int col_posinphrase = 16; // r 1 position of word in its phrase+ private static final int col_posofphrase = 17; // o 1 number of the phrase where word appears+ private static final int col_worddistance = 18; // i 1 initial zero; may be used as reserve: is filled during search+ private static final int col_reserve = 19; // k 1 reserve++ // appearance flags, used in RWI entry+ // the flags 0..23 are identical to the category flags in plasmaCondenser+ public static final int flag_app_url = 24; // word appears in url+ public static final int flag_app_descr = 25; // word appears in headline (or any description part)+ public static final int flag_app_author = 26; // word appears in author+ public static final int flag_app_tags = 27; // word appears in header tags+ public static final int flag_app_reference = 28; // word appears in anchor description text (the reference to an url), or any alternative text field of a link+ public static final int flag_app_emphasized = 29; // word is emphasized in text (i.e. bold, italics, special size)++ private kelondroRow.Entry entry;++ public indexRWIRowEntry(String urlHash,+ int urlLength, // byte-length of complete URL+ int urlComps, // number of path components+ int titleLength, // length of description/length (longer are better?)+ int hitcount, // how often appears this word in the text+ int wordcount, // total number of words+ int phrasecount, // total number of phrases+ int posintext, // position of word in all words+ int posinphrase, // position of word in its phrase+ int posofphrase, // number of the phrase where word appears+ int worddistance, // word distance; this is 0 by default, and set to the difference of posintext from two indexes if these are combined (simultanous search). If stored, this shows that the result was obtained by remote search+ int sizeOfPage, // # of bytes of the page TODO: not needed any more+ long lastmodified, // last-modified time of the document where word appears+ long updatetime, // update time; this is needed to compute a TTL for the word, so it can be removed easily if the TTL is short+ String language, // (guessed) language of document+ char doctype, // type of document+ int outlinksSame, // outlinks to same domain+ int outlinksOther, // outlinks to other domain+ kelondroBitfield flags // attributes to the url and to the word according the url+ ) {++ assert (urlHash.length() == 12) : "urlhash = " + urlHash;+ if ((language == null) || (language.length() != urlEntryRow.width(col_language))) language = "uk";+ this.entry = urlEntryRow.newEntry();+ int mddlm = plasmaWordIndex.microDateDays(lastmodified);+ int mddct = plasmaWordIndex.microDateDays(updatetime);+ this.entry.setCol(col_urlhash, urlHash, null);+ this.entry.setCol(col_lastModified, mddlm);+ this.entry.setCol(col_freshUntil, Math.max(0, mddlm + (mddct - mddlm) * 2)); // TTL computation+ this.entry.setCol(col_wordsInTitle, titleLength / 6); // word count estimation; TODO: change value handover to number of words+ this.entry.setCol(col_wordsInText, wordcount);+ this.entry.setCol(col_phrasesInText, phrasecount);+ this.entry.setCol(col_doctype, new byte[]{(byte) doctype});+ this.entry.setCol(col_language, language, null);+ this.entry.setCol(col_llocal, outlinksSame);+ this.entry.setCol(col_lother, outlinksOther);+ this.entry.setCol(col_urlLength, urlLength);+ this.entry.setCol(col_urlComps, urlComps);+ this.entry.setCol(col_typeofword, new byte[]{(byte) 0}); // TODO: grammatical classification+ this.entry.setCol(col_flags, flags.bytes());+ this.entry.setCol(col_hitcount, hitcount);+ this.entry.setCol(col_posintext, posintext);+ this.entry.setCol(col_posinphrase, posinphrase);+ this.entry.setCol(col_posofphrase, posofphrase);+ this.entry.setCol(col_worddistance, worddistance);+ this.entry.setCol(col_reserve, 0);+ }++ public indexRWIRowEntry(String urlHash, String code) {+ // the code is the external form of the row minus the leading urlHash entry+ this.entry = urlEntryRow.newEntry((urlHash + code).getBytes());+ }++ public indexRWIRowEntry(String external) {+ this.entry = urlEntryRow.newEntry(external, true);+ }++ public indexRWIRowEntry(byte[] row) {+ this.entry = urlEntryRow.newEntry(row);+ }++ public indexRWIRowEntry(byte[] row, int offset, boolean clone) {+ this.entry = urlEntryRow.newEntry(row, offset, clone);+ }++ public indexRWIRowEntry(kelondroRow.Entry rentry) {+ // FIXME: see if cloning is necessary+ this.entry = rentry;+ }++ public static int days(long time) {+ // calculates the number of days since 1.1.1970 and returns this as 4-byte array+ return (int) (time / 86400000);+ }++ public Object clone() {+ byte[] b = new byte[urlEntryRow.objectsize];+ System.arraycopy(entry.bytes(), 0, b, 0, urlEntryRow.objectsize);+ return new indexRWIRowEntry(b);+ }++ public String toPropertyForm() {+ return entry.toPropertyForm(true, true, false);+ }++ public Entry toKelondroEntry() {+ return this.entry;+ }++ public String urlHash() {+ return this.entry.getColString(col_urlhash, null);+ }++ public int quality() {+ return 0; // not used any more+ }++ public int virtualAge() {+ return (int) this.entry.getColLong(col_lastModified); // this is the time in MicoDateDays format+ }++ public long lastModified() {+ return plasmaWordIndex.reverseMicroDateDays((int) this.entry.getColLong(col_lastModified));+ }++ public long freshUntil() {+ return plasmaWordIndex.reverseMicroDateDays((int) this.entry.getColLong(col_freshUntil));+ }++ public int hitcount() {+ return (int) this.entry.getColLong(col_hitcount);+ }++ public int posintext() {+ return (int) this.entry.getColLong(col_posintext);+ }++ public int posinphrase() {+ return (int) this.entry.getColLong(col_posinphrase);+ }++ public int posofphrase() {+ return (int) this.entry.getColLong(col_posofphrase);+ }++ public int wordsintext() {+ return (int) this.entry.getColLong(col_wordsInText);+ }++ public int phrasesintext() {+ return (int) this.entry.getColLong(col_phrasesInText);+ }++ public String getLanguage() {+ return this.entry.getColString(col_language, null);+ }++ public char getType() {+ return (char) this.entry.getColByte(col_doctype);+ }++ public int wordsintitle() {+ return (int) this.entry.getColLong(col_wordsInTitle);+ }++ public int llocal() {+ return (int) this.entry.getColLong(col_llocal);+ }++ public int lother() {+ return (int) this.entry.getColLong(col_lother);+ }++ public int urllength() {+ return (int) this.entry.getColLong(col_urlLength);+ }++ public int urlcomps() {+ return (int) this.entry.getColLong(col_urlComps);+ }++ public kelondroBitfield flags() {+ return new kelondroBitfield(this.entry.getColBytes(col_flags));+ }++ public String toString() {+ return toPropertyForm();+ }++ public static indexRWIEntry combineDistance(indexRWIRowEntry ie1, indexRWIEntry ie2) {+ // returns a modified entry of the first argument+ ie1.entry.setCol(col_worddistance, ie1.worddistance() + ie2.worddistance() + Math.abs(ie1.posintext() - ie2.posintext()));+ ie1.entry.setCol(col_posintext, Math.min(ie1.posintext(), ie2.posintext()));+ ie1.entry.setCol(col_posinphrase, (ie1.posofphrase() == ie2.posofphrase()) ? ie1.posofphrase() : 0 /*unknown*/);+ ie1.entry.setCol(col_posofphrase, Math.min(ie1.posofphrase(), ie2.posofphrase()));+ ie1.entry.setCol(col_wordsInText, (ie1.wordsintext() + ie2.wordsintext()) / 2);+ return ie1;+ }++ public void combineDistance(indexRWIEntry oe) {+ combineDistance(this, oe);+ }++ public int worddistance() {+ return (int) this.entry.getColLong(col_worddistance);+ }++ public boolean isNewer(indexRWIEntry other) {+ if (other == null) return true;+ if (this.lastModified() > other.lastModified()) return true;+ if (this.lastModified() == other.lastModified()) {+ if (this.quality() > other.quality()) return true;+ }+ return false;+ }++ public boolean isOlder(indexRWIEntry other) {+ if (other == null) return false;+ if (this.lastModified() < other.lastModified()) return true;+ if (this.lastModified() == other.lastModified()) {+ if (this.quality() < other.quality()) return true;+ }+ return false;+ }++}\ No newline at end of filediff --git a/source/de/anomic/index/indexRWIVarEntry.java b/source/de/anomic/index/indexRWIVarEntry.javanew file mode 100644index 000000000..113db6b52--- /dev/null+++ b/source/de/anomic/index/indexRWIVarEntry.java@@ -0,0 +1,211 @@+// indexRWIVarEntry.java+// (C) 2007 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany+// first published 07.11.2007 on http://yacy.net+//+// This is a part of YaCy, a peer-to-peer based web search engine+//+// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $+// $LastChangedRevision: 1986 $+// $LastChangedBy: orbiter $+//+// LICENSE+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++package de.anomic.index;++import de.anomic.kelondro.kelondroBitfield;+import de.anomic.kelondro.kelondroRow.Entry;++public class indexRWIVarEntry implements indexRWIEntry {++ public kelondroBitfield flags;+ public long freshUntil, lastModified;+ public String language, urlHash;+ public char type;+ public int hitcount, llocal, lother, phrasesintext, posintext,+ posinphrase, posofphrase,+ quality, urlcomps, urllength, virtualAge,+ worddistance, wordsintext, wordsintitle;++ public indexRWIVarEntry(indexRWIRowEntry e) {+ this.flags = e.flags();+ this.freshUntil = e.freshUntil();+ this.lastModified = e.lastModified();+ this.language = e.getLanguage();+ this.urlHash = e.urlHash();+ this.type = e.getType();+ this.hitcount = e.hitcount();+ this.llocal = e.llocal();+ this.lother = e.lother();+ this.phrasesintext = e.phrasesintext();+ this.posintext = e.posintext();+ this.posinphrase = e.posinphrase();+ this.posofphrase= e.posofphrase();+ this.quality = e.quality();+ this.urlcomps = e.urlcomps();+ this.urllength = e.urllength();+ this.virtualAge = e.virtualAge();+ this.worddistance = e.worddistance();+ this.wordsintext = e.wordsintext();+ this.wordsintitle = e.wordsintitle();+ }++ public void combineDistance(indexRWIEntry oe) {+ }++ public kelondroBitfield flags() {+ return flags;+ }++ public long freshUntil() {+ return freshUntil;+ }++ public String getLanguage() {+ return language;+ }++ public char getType() {+ return type;+ }++ public int hitcount() {+ return hitcount;+ }++ public boolean isNewer(indexRWIEntry other) {+ // TODO Auto-generated method stub+ return false;+ }++ public boolean isOlder(indexRWIEntry other) {+ // TODO Auto-generated method stub+ return false;+ }++ public long lastModified() {+ return lastModified;+ }++ public int llocal() {+ return llocal;+ }++ public int lother() {+ return lother;+ }++ public int phrasesintext() {+ return phrasesintext;+ }++ public int posinphrase() {+ return posinphrase;+ }++ public int posintext() {+ return posintext;+ }++ public int posofphrase() {+ return posofphrase;+ }++ public int quality() {+ return quality;+ }++ public Entry toKelondroEntry() {+ // TODO Auto-generated method stub+ return null;+ }++ public String toPropertyForm() {+ // TODO Auto-generated method stub+ return null;+ }++ public String urlHash() {+ return urlHash;+ }++ public int urlcomps() {+ return urlcomps;+ }++ public int urllength() {+ return urllength;+ }++ public int virtualAge() {+ return virtualAge;+ }++ public int worddistance() {+ return worddistance;+ }++ public int wordsintext() {+ return wordsintext;+ }++ public int wordsintitle() {+ return wordsintitle;+ }++ public static final void min(indexRWIVarEntry t, indexRWIEntry other) {+ int v;+ long w;+ if (t.hitcount() > (v = other.hitcount())) t.hitcount = v;+ if (t.llocal() > (v = other.llocal())) t.llocal = v;+ if (t.lother() > (v = other.lother())) t.lother = v;+ if (t.quality() > (v = other.quality())) t.quality = v;+ if (t.virtualAge() > (v = other.virtualAge())) t.virtualAge = v;+ if (t.wordsintext() > (v = other.wordsintext())) t.wordsintext = v;+ if (t.phrasesintext() > (v = other.phrasesintext())) t.phrasesintext = v;+ if (t.posintext() > (v = other.posintext())) t.posintext = v;+ if (t.posinphrase() > (v = other.posinphrase())) t.posinphrase = v;+ if (t.posofphrase() > (v = other.posofphrase())) t.posofphrase = v;+ if (t.worddistance() > (v = other.worddistance())) t.worddistance = v;+ if (t.lastModified() > (w = other.lastModified())) t.lastModified = w;+ if (t.freshUntil() > (w = other.freshUntil())) t.freshUntil = w;+ if (t.urllength() > (v = other.urllength())) t.urllength = v;+ if (t.urlcomps() > (v = other.urlcomps())) t.urlcomps = v;+ if (t.wordsintitle() > (v = other.wordsintitle())) t.wordsintitle = v;+ }++ public static final void max(indexRWIVarEntry t, indexRWIEntry other) {+ int v;+ long w;+ if (t.hitcount() < (v = other.hitcount())) t.hitcount = v;+ if (t.llocal() < (v = other.llocal())) t.llocal = v;+ if (t.lother() < (v = other.lother())) t.lother = v;+ if (t.quality() < (v = other.quality())) t.quality = v;+ if (t.virtualAge() < (v = other.virtualAge())) t.virtualAge = v;+ if (t.wordsintext() < (v = other.wordsintext())) t.wordsintext = v;+ if (t.phrasesintext() < (v = other.phrasesintext())) t.phrasesintext = v;+ if (t.posintext() < (v = other.posintext())) t.posintext = v;+ if (t.posinphrase() < (v = other.posinphrase())) t.posinphrase = v;+ if (t.posofphrase() < (v = other.posofphrase())) t.posofphrase = v;+ if (t.worddistance() < (v = other.worddistance())) t.worddistance = v;+ if (t.lastModified() < (w = other.lastModified())) t.lastModified = w;+ if (t.freshUntil() < (w = other.freshUntil())) t.freshUntil = w;+ if (t.urllength() < (v = other.urllength())) t.urllength = v;+ if (t.urlcomps() < (v = other.urlcomps())) t.urlcomps = v;+ if (t.wordsintitle() < (v = other.wordsintitle())) t.wordsintitle = v;+ }++}diff --git a/source/de/anomic/index/indexURLEntry.java b/source/de/anomic/index/indexURLEntry.javaindex bbc0cefcb..cc0a41ed8 100644--- a/source/de/anomic/index/indexURLEntry.java+++ b/source/de/anomic/index/indexURLEntry.java@@ -236,7 +236,7 @@ public class indexURLEntry {this.word = null;if (prop.containsKey("word")) throw new kelondroException("old database structure is not supported");if (prop.containsKey("wi")) {- this.word = new indexRWIEntry(kelondroBase64Order.enhancedCoder.decodeString(prop.getProperty("wi", "")));+ this.word = new indexRWIRowEntry(kelondroBase64Order.enhancedCoder.decodeString(prop.getProperty("wi", "")));}}diff --git a/source/de/anomic/kelondro/kelondroAbstractRecords.java b/source/de/anomic/kelondro/kelondroAbstractRecords.javaindex 002340989..f7d6b7a85 100644--- a/source/de/anomic/kelondro/kelondroAbstractRecords.java+++ b/source/de/anomic/kelondro/kelondroAbstractRecords.java@@ -210,13 +210,13 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {if (chunk == null) {chunk = spaceChunk;}- assert (chunk.length == ROW.objectsize()) : "chunk.length = " + chunk.length + ", ROW.objectsize() = " + ROW.objectsize();+ assert (chunk.length == ROW.objectsize) : "chunk.length = " + chunk.length + ", ROW.objectsize() = " + ROW.objectsize;//synchronized (USAGE) {synchronized (entryFile) {if (USAGE.FREEC == 0) {// generate new entryint index = USAGE.allCount();- entryFile.write(seekpos(index) + overhead, chunk, 0, ROW.objectsize()); // occupy space, othervise the USAGE computaton does not work+ entryFile.write(seekpos(index) + overhead, chunk, 0, ROW.objectsize); // occupy space, othervise the USAGE computaton does not workUSAGE.USEDC++;writeused(false);return index;@@ -251,7 +251,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {}USAGE.writeused(false);USAGE.writefree();- entryFile.write(seekpos(index) + overhead, chunk, 0, ROW.objectsize()); // overwrite space+ entryFile.write(seekpos(index) + overhead, chunk, 0, ROW.objectsize); // overwrite spacereturn index;}}@@ -418,7 +418,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {// store dynamic run-time datathis.overhead = this.OHBYTEC + 4 * this.OHHANDLEC;- this.recordsize = this.overhead + ROW.objectsize();+ this.recordsize = this.overhead + ROW.objectsize;this.headchunksize = overhead + ROW.width(0);this.tailchunksize = this.recordsize - this.headchunksize;this.spaceChunk = fillSpaceChunk(recordsize);@@ -564,7 +564,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {// assign remaining values that are only present at run-timethis.overhead = OHBYTEC + 4 * OHHANDLEC;- this.recordsize = this.overhead + ROW.objectsize();+ this.recordsize = this.overhead + ROW.objectsize;this.headchunksize = this.overhead + this.ROW.width(0);this.tailchunksize = this.recordsize - this.headchunksize;this.spaceChunk = fillSpaceChunk(recordsize);diff --git a/source/de/anomic/kelondro/kelondroAttrSeq.java b/source/de/anomic/kelondro/kelondroAttrSeq.javaindex a90414f19..83efcd4b2 100644--- a/source/de/anomic/kelondro/kelondroAttrSeq.java+++ b/source/de/anomic/kelondro/kelondroAttrSeq.java@@ -274,8 +274,8 @@ public class kelondroAttrSeq {String pivot = structure.substring(0, p);structure = structure.substring(p + 5);kelondroColumn a = new kelondroColumn(pivot);- pivot_name = a.nickname();- pivot_len = a.cellwidth();+ pivot_name = a.nickname;+ pivot_len = a.cellwidth;// parse property part definition:p = structure.indexOf(",'|'");@@ -295,8 +295,8 @@ public class kelondroAttrSeq {p = 0;for (int i = 0; i < l.size(); i++) {a = (kelondroColumn) l.get(i);- prop_names[i] = a.nickname();- prop_len[i] = a.cellwidth();+ prop_names[i] = a.nickname;+ prop_len[i] = a.cellwidth;prop_pos[i] = p;p += prop_len[i];}@@ -316,8 +316,8 @@ public class kelondroAttrSeq {p = 0;for (int i = 0; i < l.size(); i++) {a = (kelondroColumn) l.get(i);- seq_names[i] = a.nickname();- seq_len[i] = a.cellwidth();+ seq_names[i] = a.nickname;+ seq_len[i] = a.cellwidth;seq_pos[i] = p;p += seq_len[i];}diff --git a/source/de/anomic/kelondro/kelondroBinSearch.java b/source/de/anomic/kelondro/kelondroBinSearch.javaindex 7a8d791e6..84c636c57 100644--- a/source/de/anomic/kelondro/kelondroBinSearch.java+++ b/source/de/anomic/kelondro/kelondroBinSearch.java@@ -50,7 +50,6 @@ public class kelondroBinSearch {private byte[] chunks;private int chunksize;- private byte[] buffer;private int count;private kelondroOrder objectOrder = new kelondroNaturalOrder(true);@@ -58,7 +57,6 @@ public class kelondroBinSearch {this.chunks = chunks;this.chunksize = chunksize;this.count = chunks.length / chunksize;- this.buffer = new byte[chunksize];}public boolean contains(byte[] t) {@@ -68,11 +66,11 @@ public class kelondroBinSearch {private synchronized boolean contains(byte[] t, int beginPos, int endPos) {// the endPos is exclusive, beginPos is inclusive// this method is synchronized to make the use of the buffer possible+ assert t.length == this.chunksize;if (beginPos >= endPos) return false;int pivot = (beginPos + endPos) / 2;if ((pivot < 0) || (pivot >= this.count)) return false;- selectBuffer(pivot);- int c = objectOrder.compare(buffer, t);+ int c = objectOrder.compare(this.chunks, pivot * this.chunksize, this.chunksize, t, 0, t.length);if (c == 0) return true;if (c < 0) /* buffer < t */ return contains(t, pivot + 1, endPos);if (c > 0) /* buffer > t */ return contains(t, beginPos, pivot);@@ -88,10 +86,6 @@ public class kelondroBinSearch {System.arraycopy(this.chunks, element * this.chunksize, a, 0, chunksize);return a;}-- private void selectBuffer(int element) {- System.arraycopy(this.chunks, element * this.chunksize, this.buffer, 0, chunksize);- }public static void main(String[] args) {String s = "4CEvsI8FRczRBo_ApRCkwfEbFLn1pIFXg39QGMgj5RHM6HpIMJq67QX3M5iQYr_LyI_5aGDaa_bYbRgJ9XnQjpmq6QkOoGWAoEaihRqhV3kItLFHjRtqauUR";diff --git a/source/de/anomic/kelondro/kelondroBitfield.java b/source/de/anomic/kelondro/kelondroBitfield.javaindex 9f8b6518d..f968df6cf 100644--- a/source/de/anomic/kelondro/kelondroBitfield.java+++ b/source/de/anomic/kelondro/kelondroBitfield.java@@ -63,7 +63,7 @@ public class kelondroBitfield implements Cloneable {public void set(int pos, boolean value) {assert (pos >= 0);- int slot = pos / 8;+ int slot = pos >> 3; // /8if (slot >= bb.length) {// extend capacitybyte[] nb = new byte[slot + 1];@@ -81,13 +81,13 @@ public class kelondroBitfield implements Cloneable {public boolean get(int pos) {assert (pos >= 0);- int slot = pos / 8;+ int slot = pos >> 3; // /8if (slot > bb.length) return false;return (bb[slot] & (1 << (pos % 8))) > 0;}public int length() {- return bb.length * 8;+ return bb.length << 3;}public String exportB64() {diff --git a/source/de/anomic/kelondro/kelondroCache.java b/source/de/anomic/kelondro/kelondroCache.javaindex 35b1d0c0a..636aae599 100644--- a/source/de/anomic/kelondro/kelondroCache.java+++ b/source/de/anomic/kelondro/kelondroCache.java@@ -74,7 +74,7 @@ public class kelondroCache implements kelondroIndex {}private void init() {- this.keyrow = new kelondroRow(new kelondroColumn[]{index.row().column(index.row().primaryKey)}, index.row().objectOrder, index.row().primaryKey);+ this.keyrow = new kelondroRow(new kelondroColumn[]{index.row().column(index.row().primaryKeyIndex)}, index.row().objectOrder, 0);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;@@ -93,7 +93,7 @@ public class kelondroCache implements kelondroIndex {}public final int cacheObjectChunkSize() {- return index.row().objectsize();+ return index.row().objectsize;}public int writeBufferSize() {@@ -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.row().primaryKey));+ delete.add(row.getPrimaryKeyBytes());this.index.addUnique(row);this.cacheFlush++;}@@ -218,7 +218,7 @@ public class kelondroCache implements kelondroIndex {kelondroRow.Entry row;while ((i.hasNext()) && (maxcount-- > 0)) {row = (kelondroRow.Entry) i.next();- delete.add(row.getColBytes(index.row().primaryKey));+ delete.add(row.getPrimaryKeyBytes());this.index.addUnique(row);this.cacheFlush++;}@@ -364,7 +364,7 @@ public class kelondroCache implements kelondroIndex {assert (row.columns() == row().columns());//assert (!(serverLog.allZero(row.getColBytes(index.primarykey()))));- byte[] key = row.getColBytes(index.row().primaryKey);+ byte[] key = row.getPrimaryKeyBytes();checkHitSpace();// remove entry from miss- and hit-cache@@ -462,7 +462,7 @@ public class kelondroCache implements kelondroIndex {assert (row.columns() == row().columns());//assert (!(serverLog.allZero(row.getColBytes(index.primarykey()))));- byte[] key = row.getColBytes(index.row().primaryKey);+ byte[] key = row.getPrimaryKeyBytes();checkHitSpace();// remove entry from miss- and hit-cache@@ -514,7 +514,7 @@ public class kelondroCache implements kelondroIndex {assert (writeBufferUnique == null);assert (writeBufferDoubles == null);- byte[] key = row.getColBytes(index.row().primaryKey);+ byte[] key = row.getPrimaryKeyBytes();checkHitSpace();// remove entry from miss- and hit-cache@@ -585,7 +585,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.row().primaryKey)));+ kelondroRow.Entry dummy = readMissCache.put(readMissCache.row().newEntry(entry.getPrimaryKeyBytes()));if (dummy == null) this.hasnotUnique++; else this.hasnotDouble++;}return entry;@@ -593,7 +593,7 @@ public class kelondroCache implements kelondroIndex {if ((writeBufferDoubles != null) && (writeBufferDoubles.size() > 0)) {Entry entry = writeBufferDoubles.removeOne();- byte[] key = entry.getColBytes(index.row().primaryKey);+ byte[] key = entry.getPrimaryKeyBytes();if (readMissCache != null) {kelondroRow.Entry dummy = readMissCache.put(readMissCache.row().newEntry(key));if (dummy == null) this.hasnotUnique++; else this.hasnotDouble++;@@ -604,7 +604,7 @@ public class kelondroCache implements kelondroIndex {Entry entry = index.removeOne();if (entry == null) return null;- byte[] key = entry.getColBytes(index.row().primaryKey);+ byte[] key = entry.getPrimaryKeyBytes();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/kelondroCachedRecords.java b/source/de/anomic/kelondro/kelondroCachedRecords.javaindex 8aa5f3c48..8d884189f 100644--- a/source/de/anomic/kelondro/kelondroCachedRecords.java+++ b/source/de/anomic/kelondro/kelondroCachedRecords.java@@ -500,7 +500,7 @@ public class kelondroCachedRecords extends kelondroAbstractRecords implements kepublic synchronized void setValueRow(byte[] row) throws IOException {// if the index is defined, then write values directly to the file, else only to the object- if ((row != null) && (row.length != ROW.objectsize())) throw new IOException("setValueRow with wrong (" + row.length + ") row length instead correct: " + ROW.objectsize());+ if ((row != null) && (row.length != ROW.objectsize)) throw new IOException("setValueRow with wrong (" + row.length + ") row length instead correct: " + ROW.objectsize);// set valuesif (this.handle.index != kelondroHandle.NUL) {@@ -532,7 +532,7 @@ public class kelondroCachedRecords extends kelondroAbstractRecords implements ke}// create return value- byte[] row = new byte[ROW.objectsize()];+ byte[] row = new byte[ROW.objectsize];// read keySystem.arraycopy(headChunk, overhead, row, 0, ROW.width(0));diff --git a/source/de/anomic/kelondro/kelondroCollectionIndex.java b/source/de/anomic/kelondro/kelondroCollectionIndex.javaindex 9bcfc3165..ec0060bc5 100644--- a/source/de/anomic/kelondro/kelondroCollectionIndex.java+++ b/source/de/anomic/kelondro/kelondroCollectionIndex.java@@ -206,7 +206,7 @@ public class kelondroCollectionIndex {//kelondroIndex theindex = new kelondroFlexTable(path, filenameStub + ".index", preloadTime, indexRow(keylength, indexOrder), true);// save/check property file for this array- File propfile = propertyFile(path, filenameStub, loadfactor, rowdef.objectsize());+ File propfile = propertyFile(path, filenameStub, loadfactor, rowdef.objectsize);Map props = new HashMap();if (propfile.exists()) {props = serverFileUtils.loadHashMap(propfile);@@ -224,11 +224,11 @@ public class kelondroCollectionIndex {}private kelondroFixedWidthArray openArrayFile(int partitionNumber, int serialNumber, boolean create) throws IOException {- File f = arrayFile(path, filenameStub, loadfactor, payloadrow.objectsize(), partitionNumber, serialNumber);+ File f = arrayFile(path, filenameStub, loadfactor, payloadrow.objectsize, partitionNumber, serialNumber);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);@@ -299,7 +299,7 @@ public class kelondroCollectionIndex {// the collection is newint partitionNumber = arrayIndex(collection.size());kelondroRow.Entry indexrow = index.row().newEntry();- kelondroFixedWidthArray array = getArray(partitionNumber, serialNumber, this.payloadrow.objectsize());+ kelondroFixedWidthArray array = getArray(partitionNumber, serialNumber, this.payloadrow.objectsize);// define rowkelondroRow.Entry arrayEntry = array.row().newEntry();@@ -311,7 +311,7 @@ public class kelondroCollectionIndex {// store the new row number in the indexindexrow.setCol(idx_col_key, key);- indexrow.setCol(idx_col_chunksize, this.payloadrow.objectsize());+ indexrow.setCol(idx_col_chunksize, this.payloadrow.objectsize);indexrow.setCol(idx_col_chunkcount, collection.size());indexrow.setCol(idx_col_clusteridx, (byte) partitionNumber);indexrow.setCol(idx_col_flags, (byte) 0);@@ -497,15 +497,15 @@ public class kelondroCollectionIndex {if (oldPartitionNumber == newPartitionNumber) {array_replace(key, collection, indexrow,- oldPartitionNumber, serialNumber, this.payloadrow.objectsize(),+ oldPartitionNumber, serialNumber, this.payloadrow.objectsize,oldrownumber); // modifies indexrow} else {array_remove(- oldPartitionNumber, serialNumber, this.payloadrow.objectsize(),+ oldPartitionNumber, serialNumber, this.payloadrow.objectsize,oldrownumber);array_add(key, collection, indexrow,- newPartitionNumber, serialNumber, this.payloadrow.objectsize()); // modifies indexrow+ newPartitionNumber, serialNumber, this.payloadrow.objectsize); // modifies indexrow}if ((int) indexrow.getColLong(idx_col_chunkcount) != collection.size())@@ -619,7 +619,7 @@ public class kelondroCollectionIndex {*/} else {array_remove(- oldPartitionNumber, oldSerialNumber, this.payloadrow.objectsize(),+ oldPartitionNumber, oldSerialNumber, this.payloadrow.objectsize,oldrownumber);actionList = (ArrayList) array_add_map.get(new Integer(newPartitionNumber));@@ -637,9 +637,9 @@ public class kelondroCollectionIndex {// memory protection: flush collected collectionsif (serverMemory.available() < minMem()) {// emergency flush- indexrows_existing.addAll(array_replace_multiple(array_replace_map, 0, this.payloadrow.objectsize()));+ indexrows_existing.addAll(array_replace_multiple(array_replace_map, 0, this.payloadrow.objectsize));array_replace_map = new TreeMap(); // delete references- indexrows_existing.addAll(array_add_multiple(array_add_map, 0, this.payloadrow.objectsize()));+ indexrows_existing.addAll(array_add_multiple(array_add_map, 0, this.payloadrow.objectsize));array_add_map = new TreeMap(); // delete references//if (!madegc) {// prevent that this flush is made again even when there is enough memory@@ -652,9 +652,9 @@ public class kelondroCollectionIndex {}// finallly flush the collected collections- indexrows_existing.addAll(array_replace_multiple(array_replace_map, 0, this.payloadrow.objectsize()));+ indexrows_existing.addAll(array_replace_multiple(array_replace_map, 0, this.payloadrow.objectsize));array_replace_map = new TreeMap(); // delete references- indexrows_existing.addAll(array_add_multiple(array_add_map, 0, this.payloadrow.objectsize()));+ indexrows_existing.addAll(array_add_multiple(array_add_map, 0, this.payloadrow.objectsize));array_add_map = new TreeMap(); // delete references// write new containers@@ -715,15 +715,15 @@ public class kelondroCollectionIndex {if (oldPartitionNumber == newPartitionNumber) {array_replace(key, collection, indexrow,- oldPartitionNumber, oldSerialNumber, this.payloadrow.objectsize(),+ oldPartitionNumber, oldSerialNumber, this.payloadrow.objectsize,oldrownumber); // modifies indexrow} else {array_remove(- oldPartitionNumber, oldSerialNumber, this.payloadrow.objectsize(),+ oldPartitionNumber, oldSerialNumber, this.payloadrow.objectsize,oldrownumber);array_add(key, collection, indexrow,- newPartitionNumber, oldSerialNumber, this.payloadrow.objectsize()); // modifies indexrow+ newPartitionNumber, oldSerialNumber, this.payloadrow.objectsize); // modifies indexrow}final int collectionsize = collection.size(); // extra variable for easier debugging@@ -862,15 +862,15 @@ public class kelondroCollectionIndex {if (oldPartitionNumber == newPartitionNumber) {array_replace(key, oldcollection, indexrow,- oldPartitionNumber, serialNumber, this.payloadrow.objectsize(),+ oldPartitionNumber, serialNumber, this.payloadrow.objectsize,oldrownumber); // modifies indexrow} else {array_remove(- oldPartitionNumber, serialNumber, this.payloadrow.objectsize(),+ oldPartitionNumber, serialNumber, this.payloadrow.objectsize,oldrownumber);array_add(key, oldcollection, indexrow,- newPartitionNumber, serialNumber, this.payloadrow.objectsize()); // modifies indexrow+ newPartitionNumber, serialNumber, this.payloadrow.objectsize); // modifies indexrow}index.put(indexrow); // write modified indexrowreturn removed;@@ -941,7 +941,7 @@ public class kelondroCollectionIndex {// store the row number in the index; this may be a double-entry, but better than nothingkelondroRow.Entry indexEntry = index.row().newEntry();indexEntry.setCol(idx_col_key, arrayrow.getColBytes(0));- indexEntry.setCol(idx_col_chunksize, this.payloadrow.objectsize());+ indexEntry.setCol(idx_col_chunksize, this.payloadrow.objectsize);indexEntry.setCol(idx_col_chunkcount, collection.size());indexEntry.setCol(idx_col_clusteridx, (byte) clusteridx);indexEntry.setCol(idx_col_flags, (byte) 0);diff --git a/source/de/anomic/kelondro/kelondroColumn.java b/source/de/anomic/kelondro/kelondroColumn.javaindex 1d0f01033..18760e287 100644--- a/source/de/anomic/kelondro/kelondroColumn.java+++ b/source/de/anomic/kelondro/kelondroColumn.java@@ -41,8 +41,8 @@ public class kelondroColumn {public static final int encoder_b256 = 2;public static final int encoder_bytes = 3;- private int celltype, cellwidth, encoder;- private String nickname, description;+ public int celltype, cellwidth, encoder;+ public String nickname, description;public kelondroColumn(String nickname, int celltype, int encoder, int cellwidth, String description) {this.celltype = celltype;@@ -191,26 +191,6 @@ public class kelondroColumn {this.encoder = encoder;this.nickname = nickname;}-- public int celltype() {- return this.celltype;- }-- public int cellwidth() {- return this.cellwidth;- }-- public int encoder() {- return this.encoder;- }-- public String nickname() {- return this.nickname;- }-- public String description() {- return this.description;- }public String toString() {StringBuffer s = new StringBuffer();diff --git a/source/de/anomic/kelondro/kelondroEcoRecords.java b/source/de/anomic/kelondro/kelondroEcoRecords.javaindex 1c99d893f..586779c6b 100644--- a/source/de/anomic/kelondro/kelondroEcoRecords.java+++ b/source/de/anomic/kelondro/kelondroEcoRecords.java@@ -91,7 +91,7 @@ public class kelondroEcoRecords extends kelondroAbstractRecords {// create chunksthis.ohChunk = new byte[overhead];- this.bodyChunk = new byte[ROW.objectsize()];+ this.bodyChunk = new byte[ROW.objectsize];for (int i = this.ohChunk.length - 1; i >= 0; i--) this.ohChunk[i] = (byte) 0xff;if (rowinstance == null) {for (int i = this.bodyChunk.length - 1; i >= 0; i--) this.bodyChunk[i] = (byte) 0xff;@@ -130,12 +130,12 @@ public class kelondroEcoRecords extends kelondroAbstractRecords {} else { */// create empty chunksthis.ohChunk = new byte[overhead];- this.bodyChunk = new byte[ROW.objectsize()];+ this.bodyChunk = new byte[ROW.objectsize];// write content to chunksif (bulkchunk != null) {if (overhead > 0) System.arraycopy(bulkchunk, offset, this.ohChunk, 0, overhead);- System.arraycopy(bulkchunk, offset + overhead, this.bodyChunk, 0, ROW.objectsize());+ System.arraycopy(bulkchunk, offset + overhead, this.bodyChunk, 0, ROW.objectsize);}//}@@ -161,7 +161,7 @@ public class kelondroEcoRecords extends kelondroAbstractRecords {// read recordthis.ohChunk = new byte[overhead];- this.bodyChunk = new byte[ROW.objectsize()];+ this.bodyChunk = new byte[ROW.objectsize];if (overhead > 0) entryFile.readFully(seekpos(this.handle), this.ohChunk, 0, overhead);entryFile.readFully(seekpos(this.handle) + overhead, this.bodyChunk, 0, this.bodyChunk.length);@@ -210,7 +210,7 @@ public class kelondroEcoRecords extends kelondroAbstractRecords {public synchronized void setValueRow(byte[] row) throws IOException {// if the index is defined, then write values directly to the file, else only to the object- if ((row != null) && (row.length != ROW.objectsize())) throw new IOException("setValueRow with wrong (" + row.length + ") row length instead correct: " + ROW.objectsize());+ if ((row != null) && (row.length != ROW.objectsize)) throw new IOException("setValueRow with wrong (" + row.length + ") row length instead correct: " + ROW.objectsize);// set valuesif (this.handle.index != kelondroHandle.NUL) {@@ -234,7 +234,7 @@ public class kelondroEcoRecords extends kelondroAbstractRecords {if (this.bodyChunk == null) {// load all values from the database file- this.bodyChunk = new byte[ROW.objectsize()];+ this.bodyChunk = new byte[ROW.objectsize];// read valuesentryFile.readFully(seekpos(this.handle) + (long) overhead, this.bodyChunk, 0, this.bodyChunk.length);}@@ -261,8 +261,8 @@ public class kelondroEcoRecords extends kelondroAbstractRecords {// save tailif ((this.bodyChunk != null) && (this.bodyChanged)) {//System.out.println("WRITET(" + filename + ", " + (seekpos(this.handle) + headchunksize) + ", " + this.tailChunk.length + ")");- assert (this.bodyChunk == null) || (this.bodyChunk.length == ROW.objectsize());- entryFile.write(seekpos(this.handle) + overhead, (this.bodyChunk == null) ? new byte[ROW.objectsize()] : this.bodyChunk);+ assert (this.bodyChunk == null) || (this.bodyChunk.length == ROW.objectsize);+ entryFile.write(seekpos(this.handle) + overhead, (this.bodyChunk == null) ? new byte[ROW.objectsize] : this.bodyChunk);this.bodyChanged = false;}diff --git a/source/de/anomic/kelondro/kelondroFlexTable.java b/source/de/anomic/kelondro/kelondroFlexTable.javaindex c0bb3c604..bf8571c4d 100644--- a/source/de/anomic/kelondro/kelondroFlexTable.java+++ b/source/de/anomic/kelondro/kelondroFlexTable.java@@ -60,7 +60,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr}try {- long neededRAM = (long) ((super.row().column(0).cellwidth() + 4) * super.size() * kelondroRowCollection.growfactor);+ long neededRAM = (long) ((super.row().column(0).cellwidth + 4) * super.size() * kelondroRowCollection.growfactor);File newpath = new File(path, tablename);File indexfile = new File(newpath, "col.000.index");@@ -103,7 +103,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr// generate new index fileSystem.out.println("*** Generating File index for " + size() + " entries from " + indexfile);System.out.println("*** Cause: too less RAM (" + serverMemory.available() + " Bytes) configured. Assign at least " + (neededRAM / 1024 / 1024) + " MB more RAM to enable a RAM index.");- ki = initializeTreeIndex(indexfile, preloadTime, rowdef.objectOrder, rowdef.primaryKey);+ ki = initializeTreeIndex(indexfile, preloadTime, rowdef.objectOrder);System.out.println(" -done-");System.out.println(ki.size() + " entries indexed from " + super.col[0].size() + " keys.");@@ -119,7 +119,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr} catch (IOException e) {if (resetOnFail) {RAMIndex = true;- index = new kelondroBytesIntMap(super.row().column(0).cellwidth(), super.rowdef.objectOrder, 0);+ index = new kelondroBytesIntMap(super.row().column(0).cellwidth, super.rowdef.objectOrder, 0);} else {throw new kelondroException(e.getMessage());}@@ -129,7 +129,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrpublic void reset() throws IOException {super.reset();RAMIndex = true;- index = new kelondroBytesIntMap(super.row().column(0).cellwidth(), super.rowdef.objectOrder, 0);+ index = new kelondroBytesIntMap(super.row().column(0).cellwidth, super.rowdef.objectOrder, 0);}public static int staticSize(File path, String tablename) {@@ -137,7 +137,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr}public static int staticRAMIndexNeed(File path, String tablename, kelondroRow rowdef) {- return (int) ((rowdef.column(0).cellwidth() + 4) * staticSize(path, tablename) * kelondroRowSet.growfactor);+ return (int) ((rowdef.column(0).cellwidth + 4) * staticSize(path, tablename) * kelondroRowSet.growfactor);}public boolean hasRAMIndex() {@@ -155,7 +155,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrprivate kelondroBytesIntMap initializeRamIndex() {int space = super.col[0].size() + 1;if (space < 0) throw new kelondroException("wrong space: " + space);- kelondroBytesIntMap ri = new kelondroBytesIntMap(super.row().column(0).cellwidth(), super.rowdef.objectOrder, space);+ kelondroBytesIntMap ri = new kelondroBytesIntMap(super.row().column(0).cellwidth, super.rowdef.objectOrder, space);Iterator content = super.col[0].contentNodes(-1);kelondroNode node;int i;@@ -179,8 +179,8 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrreturn ri;}- private kelondroIndex initializeTreeIndex(File indexfile, long preloadTime, kelondroOrder objectOrder, int primaryKey) throws IOException {- kelondroIndex treeindex = new kelondroCache(new kelondroTree(indexfile, true, preloadTime, treeIndexRow(rowdef.width(0), objectOrder), 2, 80), true, false);+ private kelondroIndex initializeTreeIndex(File indexfile, long preloadTime, kelondroOrder objectOrder) throws IOException {+ kelondroIndex treeindex = new kelondroCache(new kelondroTree(indexfile, true, preloadTime, treeIndexRow(rowdef.primaryKeyLength, objectOrder), 2, 80), true, false);Iterator content = super.col[0].contentNodes(-1);kelondroNode node;kelondroRow.Entry indexentry;@@ -218,7 +218,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr// so the size may be smaller than an index to a row entrykelondroRow.Entry result = super.get(pos);assert result != null;- assert rowdef.objectOrder.compare(result.getColBytes(rowdef.primaryKey), key) == 0 : "key and row does not match; key = " + serverLog.arrayList(key, 0, key.length) + " row.key = " + serverLog.arrayList(result.getColBytes(rowdef.primaryKey), 0, rowdef.width(rowdef.primaryKey));+ assert rowdef.objectOrder.compare(result.getPrimaryKeyBytes(), key) == 0 : "key and row does not match; key = " + serverLog.arrayList(key, 0, key.length) + " row.key = " + serverLog.arrayList(result.getPrimaryKeyBytes(), 0, rowdef.primaryKeyLength);return result;}@@ -283,7 +283,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrreturn null;}assert oldentry != null : "overwrite of empty position " + pos + ", index management must have failed before";- assert rowdef.objectOrder.compare(oldentry.getColBytes(rowdef.primaryKey), key) == 0 : "key and row does not match; key = " + serverLog.arrayList(key, 0, key.length) + " row.key = " + serverLog.arrayList(oldentry.getColBytes(rowdef.primaryKey), 0, rowdef.width(rowdef.primaryKey));+ assert rowdef.objectOrder.compare(oldentry.getPrimaryKeyBytes(), key) == 0 : "key and row does not match; key = " + serverLog.arrayList(key, 0, key.length) + " row.key = " + serverLog.arrayList(oldentry.getPrimaryKeyBytes(), 0, rowdef.primaryKeyLength);super.set(pos, row);assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();return oldentry;@@ -327,7 +327,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrreturn null;}assert r != null : "r == null"; // should be avoided with path above- assert rowdef.objectOrder.compare(r.getColBytes(rowdef.primaryKey), key) == 0 : "key and row does not match; key = " + serverLog.arrayList(key, 0, key.length) + " row.key = " + serverLog.arrayList(r.getColBytes(rowdef.primaryKey), 0, rowdef.width(rowdef.primaryKey));+ assert rowdef.objectOrder.compare(r.getPrimaryKeyBytes(), key) == 0 : "key and row does not match; key = " + serverLog.arrayList(key, 0, key.length) + " row.key = " + serverLog.arrayList(r.getPrimaryKeyBytes(), 0, rowdef.primaryKeyLength);super.remove(i);assert super.get(i) == null : "i = " + i + ", get(i) = " + serverLog.arrayList(super.get(i).bytes(), 0, 12);assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();diff --git a/source/de/anomic/kelondro/kelondroHashtable.java b/source/de/anomic/kelondro/kelondroHashtable.javaindex c8680935a..6b63a2eb3 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, rowdef.objectOrder, rowdef.primaryKey);+ return new kelondroRow(newCol, rowdef.objectOrder, rowdef.primaryKeyIndex);}public static int power2(int x) {diff --git a/source/de/anomic/kelondro/kelondroNaturalOrder.java b/source/de/anomic/kelondro/kelondroNaturalOrder.javaindex cf8997d7d..fac233958 100644--- a/source/de/anomic/kelondro/kelondroNaturalOrder.java+++ b/source/de/anomic/kelondro/kelondroNaturalOrder.java@@ -47,7 +47,7 @@ package de.anomic.kelondro;import java.util.Comparator;-public class kelondroNaturalOrder extends kelondroAbstractOrder implements kelondroOrder, Comparator, Cloneable {+public final class kelondroNaturalOrder extends kelondroAbstractOrder implements kelondroOrder, Comparator, Cloneable {public static final kelondroOrder naturalOrder = new kelondroNaturalOrder(true);@@ -55,6 +55,7 @@ public class kelondroNaturalOrder extends kelondroAbstractOrder implements kelonthis.asc = ascending;this.zero = null;}+public boolean wellformed(byte[] a) {return true;}@@ -127,7 +128,7 @@ public class kelondroNaturalOrder extends kelondroAbstractOrder implements kelonpublic final static long decodeLong(byte[] s, int offset, int length) {if (s == null) return 0;long c = 0;- int m = Math.min(s.length, offset + length);+ final int m = Math.min(s.length, offset + length);while (offset < m) c = (c << 8) | ((long) s[offset++] & 0xFF);return c;}@@ -152,8 +153,8 @@ public class kelondroNaturalOrder extends kelondroAbstractOrder implements kelonpublic final int compare0(byte[] a, int aoffset, int alength, byte[] b, int boffset, int blength) {if (zero == null) return compares(a, aoffset, alength, b, boffset, blength);// we have an artificial start point. check all combinations- int az = compares(a, aoffset, alength, zero, 0, zero.length); // -1 if a < z; 0 if a == z; 1 if a > z- int bz = compares(b, boffset, blength, zero, 0, zero.length); // -1 if b < z; 0 if b == z; 1 if b > z+ final int az = compares(a, aoffset, alength, zero, 0, zero.length); // -1 if a < z; 0 if a == z; 1 if a > z+ final int bz = compares(b, boffset, blength, zero, 0, zero.length); // -1 if b < z; 0 if b == z; 1 if b > zif (az == bz) return compares(a, aoffset, alength, b, boffset, blength);return sig(az - bz);}@@ -184,28 +185,6 @@ public class kelondroNaturalOrder extends kelondroAbstractOrder implements kelonreturn 0;}- /*- public static final int compares(byte[] a, byte[] b) {- int i = 0;- final int al = a.length;- final int bl = b.length;- final int len = (al > bl) ? bl : al;- while (i < len) {- if (a[i] > b[i]) return 1;- if (a[i] < b[i]) return -1;- // else the bytes are equal and it may go on yet undecided- i++;- }- // check if we have a zero-terminated equality- if ((i == al) && (i < bl) && (b[i] == 0)) return 0;- if ((i == bl) && (i < al) && (a[i] == 0)) return 0;- // no, decide by length- if (al > bl) return 1;- if (al < bl) return -1;- // no, they are equal- return 0;- }- */public static void main(String[] args) {byte[] t = new byte[12];for (int i = 0; i < 12; i++) t[i] = (byte) 255;diff --git a/source/de/anomic/kelondro/kelondroRow.java b/source/de/anomic/kelondro/kelondroRow.javaindex 5b5354d1d..b00e18662 100644--- a/source/de/anomic/kelondro/kelondroRow.java+++ b/source/de/anomic/kelondro/kelondroRow.java@@ -36,13 +36,13 @@ import java.util.StringTokenizer;import de.anomic.server.serverByteBuffer;import de.anomic.server.logging.serverLog;-public class kelondroRow {+public final class kelondroRow {protected kelondroColumn[] row;protected int[] colstart;- protected int objectsize;protected kelondroOrder objectOrder;- protected int primaryKey;+ public int objectsize;+ public int primaryKeyIndex, primaryKeyLength;protected Map nickref = null; // a mapping from nicknames to Object[2]{kelondroColumn, Integer(colstart)}public kelondroRow(kelondroColumn[] row, kelondroOrder objectOrder, int primaryKey) {@@ -50,19 +50,19 @@ public class kelondroRow {this.row = row;assert (objectOrder != null);this.objectOrder = objectOrder;- this.primaryKey = primaryKey;this.colstart = new int[row.length];this.objectsize = 0;for (int i = 0; i < row.length; i++) {this.colstart[i] = this.objectsize;- this.objectsize += this.row[i].cellwidth();+ this.objectsize += this.row[i].cellwidth;}+ this.primaryKeyIndex = primaryKey;+ this.primaryKeyLength = (primaryKey < 0) ? this.objectsize : row[primaryKeyIndex].cellwidth;}public kelondroRow(String structure, kelondroOrder objectOrder, int primaryKey) {assert (objectOrder != null);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>@@ -87,53 +87,52 @@ public class kelondroRow {for (int i = 0; i < l.size(); i++) {this.colstart[i] = this.objectsize;this.row[i] = (kelondroColumn) l.get(i);- this.objectsize += this.row[i].cellwidth();+ this.objectsize += this.row[i].cellwidth;}+ this.primaryKeyIndex = primaryKey;+ this.primaryKeyLength = (primaryKey < 0) ? this.objectsize : row[primaryKeyIndex].cellwidth;}- public void setOrdering(kelondroOrder objectOrder, int primaryKey) {+ public final void setOrdering(kelondroOrder objectOrder, int primaryKey) {assert (objectOrder != null);this.objectOrder = objectOrder;- this.primaryKey = primaryKey;+ this.primaryKeyIndex = primaryKey;+ this.primaryKeyLength = (primaryKey < 0) ? this.objectsize : row[primaryKeyIndex].cellwidth;}- public kelondroOrder getOrdering() {+ public final kelondroOrder getOrdering() {return this.objectOrder;}-- public int primaryKey() {- return this.primaryKey;- }- protected void genNickRef() {+ protected final void genNickRef() {if (nickref != null) return;nickref = new HashMap(row.length);- for (int i = 0; i < row.length; i++) nickref.put(row[i].nickname(), new Object[]{row[i], new Integer(colstart[i])});+ for (int i = 0; i < row.length; i++) nickref.put(row[i].nickname, new Object[]{row[i], new Integer(colstart[i])});}- public int columns() {+ public final int columns() {return this.row.length;}-- public int objectsize() {+ /*+ public final int objectsize() {return this.objectsize;}-- public kelondroColumn column(int col) {+ */+ public final kelondroColumn column(int col) {return row[col];}- public int width(int column) {- return this.row[column].cellwidth();+ public final int width(int column) {+ return this.row[column].cellwidth;}- public int[] widths() {+ public final int[] widths() {int[] w = new int[this.row.length];- for (int i = 0; i < this.row.length; i++) w[i] = row[i].cellwidth();+ for (int i = 0; i < this.row.length; i++) w[i] = row[i].cellwidth;return w;}- public String toString() {+ public final String toString() {StringBuffer s = new StringBuffer();s.append(row[0].toString());for (int i = 1; i < row.length; i++) {@@ -143,51 +142,51 @@ public class kelondroRow {return new String(s);}- public Entry newEntry() {+ public final Entry newEntry() {return new Entry();}- public Entry newEntry(byte[] rowinstance) {+ public final Entry newEntry(byte[] rowinstance) {if (rowinstance == null) return null;//assert (rowinstance[0] != 0);- assert (this.objectOrder.wellformed(rowinstance, 0, row[0].cellwidth())) : "rowinstance[0] = " + serverLog.arrayList(rowinstance, 0, row[0].cellwidth());- if (!(this.objectOrder.wellformed(rowinstance, 0, row[0].cellwidth()))) return null;+ assert (this.objectOrder.wellformed(rowinstance, 0, row[0].cellwidth)) : "rowinstance[0] = " + serverLog.arrayList(rowinstance, 0, row[0].cellwidth);+ if (!(this.objectOrder.wellformed(rowinstance, 0, row[0].cellwidth))) return null;return new Entry(rowinstance, false);}- public Entry newEntry(Entry oldrow, int fromColumn) {+ public final Entry newEntry(Entry oldrow, int fromColumn) {if (oldrow == null) return null;assert (oldrow.getColBytes(0)[0] != 0);- assert (this.objectOrder.wellformed(oldrow.getColBytes(0), 0, row[0].cellwidth()));+ assert (this.objectOrder.wellformed(oldrow.getColBytes(0), 0, row[0].cellwidth));return new Entry(oldrow, fromColumn, false);}- public Entry newEntry(byte[] rowinstance, int start, boolean clone) {+ public final Entry newEntry(byte[] rowinstance, int start, boolean clone) {if (rowinstance == null) return null;//assert (rowinstance[0] != 0);- assert (this.objectOrder.wellformed(rowinstance, start, row[0].cellwidth()));+ assert (this.objectOrder.wellformed(rowinstance, start, row[0].cellwidth));// this method offers the option to clone the content// this is necessary if it is known that the underlying byte array may change and therefore// the reference to the byte array does not contain the original contentreturn new Entry(rowinstance, start, clone);}- public Entry newEntry(byte[][] cells) {+ public final Entry newEntry(byte[][] cells) {if (cells == null) return null;assert (cells[0][0] != 0);- assert (this.objectOrder.wellformed(cells[0], 0, row[0].cellwidth()));+ assert (this.objectOrder.wellformed(cells[0], 0, row[0].cellwidth));return new Entry(cells);}- public Entry newEntry(String external, boolean decimalCardinal) {+ public final Entry newEntry(String external, boolean decimalCardinal) {if (external == null) return null;return new Entry(external, decimalCardinal);}- public EntryIndex newEntryIndex(byte[] rowinstance, int index) {+ public final EntryIndex newEntryIndex(byte[] rowinstance, int index) {if (rowinstance == null) return null;assert (rowinstance[0] != 0);- assert (this.objectOrder.wellformed(rowinstance, 0, row[0].cellwidth()));+ assert (this.objectOrder.wellformed(rowinstance, 0, row[0].cellwidth));return new EntryIndex(rowinstance, index);}@@ -230,7 +229,7 @@ public class kelondroRow {int cs, cw;for (int i = 0; i < row.length; i++) {cs = colstart[i];- cw = row[i].cellwidth();+ cw = row[i].cellwidth;if ((i >= cols.length) || (cols[i] == null)) {for (int j = 0; j < cw; j++) this.rowinstance[cs + j] = 0;} else {@@ -258,23 +257,23 @@ public class kelondroRow {if (p + 1 == elts[i].length())setCol(nick, null);else {- if ((decimalCardinal) && (row[i].celltype() == kelondroColumn.celltype_cardinal)) {+ if ((decimalCardinal) && (row[i].celltype == kelondroColumn.celltype_cardinal)) {try {setCol(nick, Long.parseLong(elts[i].substring(p + 1).trim()));} catch (NumberFormatException e) {- serverLog.logSevere("kelondroRow", "NumberFormatException for celltype_cardinal; row = " + i + ", celltype = " + row[i].celltype() + ", encoder = " + row[i].encoder() + ", value = '" + elts[i].substring(p + 1).trim() + "'");+ serverLog.logSevere("kelondroRow", "NumberFormatException for celltype_cardinal; row = " + i + ", celltype = " + row[i].celltype + ", encoder = " + row[i].encoder + ", value = '" + elts[i].substring(p + 1).trim() + "'");setCol(nick, 0);}- } else if ((decimalCardinal) && (row[i].celltype() == kelondroColumn.celltype_binary)) {- assert row[i].cellwidth() == 1;+ } else if ((decimalCardinal) && (row[i].celltype == kelondroColumn.celltype_binary)) {+ assert row[i].cellwidth == 1;try {setCol(nick, new byte[]{(byte) Integer.parseInt(elts[i].substring(p + 1).trim())});} catch (NumberFormatException e) {- serverLog.logSevere("kelondroRow", "NumberFormatException for celltype_binary; row = " + i + ", celltype = " + row[i].celltype() + ", encoder = " + row[i].encoder() + ", value = '" + elts[i].substring(p + 1).trim() + "'");+ serverLog.logSevere("kelondroRow", "NumberFormatException for celltype_binary; row = " + i + ", celltype = " + row[i].celltype + ", encoder = " + row[i].encoder + ", value = '" + elts[i].substring(p + 1).trim() + "'");setCol(nick, new byte[]{0});}- } else if ((decimalCardinal) && (row[i].celltype() == kelondroColumn.celltype_bitfield)) {- setCol(nick, (new kelondroBitfield(row[i].cellwidth(), elts[i].substring(p + 1).trim())).bytes());+ } else if ((decimalCardinal) && (row[i].celltype == kelondroColumn.celltype_bitfield)) {+ setCol(nick, (new kelondroBitfield(row[i].cellwidth, elts[i].substring(p + 1).trim())).bytes());} else {setCol(nick, elts[i].substring(p + 1).trim().getBytes());}@@ -283,23 +282,23 @@ public class kelondroRow {}}- protected int colstart(int column) {+ protected final int colstart(int column) {return colstart[column];}- protected int cellwidth(int column) {- return row[column].cellwidth();+ protected final int cellwidth(int column) {+ return row[column].cellwidth;}- public int compareTo(Object o) {+ public final int compareTo(Object o) {if (objectOrder == null) throw new kelondroException("objects cannot be compared, no order given");if (o instanceof Entry) {- return objectOrder.compare(getColBytes(primaryKey), ((Entry) o).getColBytes(primaryKey));+ return objectOrder.compare(this.getPrimaryKeyBytes(), ((Entry) o).getPrimaryKeyBytes());}throw new UnsupportedOperationException("works only for kelondroRow.Entry objects");}- public byte[] bytes() {+ public final byte[] bytes() {if ((offset == 0) && (rowinstance.length == objectsize)) {return rowinstance;} else {@@ -309,50 +308,50 @@ public class kelondroRow {}}- public void writeToArray(byte[] target, int targetOffset) {+ public final void writeToArray(byte[] target, int targetOffset) {// this method shall replace the byte()s where possible, bacause it may reduce the number of new byte[] allocationsassert (targetOffset + objectsize <= target.length) : "targetOffset = " + targetOffset + ", target.length = " + target.length + ", objectsize = " + objectsize;System.arraycopy(rowinstance, offset, target, targetOffset, objectsize);}- public int columns() {+ public final int columns() {return row.length;}- public int objectsize() {+ public final int objectsize() {return objectsize;}- public boolean empty(int column) {+ public final boolean empty(int column) {return rowinstance[offset + colstart[column]] == 0;}- public void setCol(String nickname, char c) {+ public final void setCol(String nickname, char c) {if (nickref == null) genNickRef();Object[] ref = (Object[]) nickref.get(nickname);if (ref == null) return;rowinstance[offset + ((Integer) ref[1]).intValue()] = (byte) c;}- public void setCol(String nickname, byte[] cell) {+ public final void setCol(String nickname, byte[] cell) {if (nickref == null) genNickRef();Object[] ref = (Object[]) nickref.get(nickname);if (ref == null) return;kelondroColumn col = (kelondroColumn) ref[0];- setCol(col.encoder(), ((Integer) ref[1]).intValue(), col.cellwidth(), cell);+ setCol(col.encoder, ((Integer) ref[1]).intValue(), col.cellwidth, cell);}- public void setCol(int column, byte[] cell) {- setCol(row[column].encoder(), colstart[column], row[column].cellwidth(), cell);+ public final void setCol(int column, byte[] cell) {+ setCol(row[column].encoder, colstart[column], row[column].cellwidth, cell);}- public void setCol(int column, char[] cell) {+ public final void setCol(int column, char[] cell) {int clstrt = colstart[column];for (int i = 0; i < cell.length; i++) rowinstance[offset + clstrt + i] = (byte) cell[i];- for (int i = cell.length; i < row[column].cellwidth(); i++) rowinstance[offset + clstrt + i] = 0;+ for (int i = cell.length; i < row[column].cellwidth; i++) rowinstance[offset + clstrt + i] = 0;}- private void setCol(int encoding, int clstrt, int length, byte[] cell) {+ private final void setCol(int encoding, int clstrt, int length, byte[] cell) {if (cell == null) {while (length-- > 0) rowinstance[offset + clstrt + length] = 0;} else {@@ -366,11 +365,11 @@ public class kelondroRow {}}- public void setCol(int column, byte c) {+ public final void setCol(int column, byte c) {rowinstance[offset + colstart[column]] = c;}- public void setCol(int column, String cell, String encoding) {+ public final void setCol(int column, String cell, String encoding) {if (encoding == null)setCol(column, cell.getBytes());else@@ -381,7 +380,7 @@ public class kelondroRow {}}- public void setCol(String nick, String cell, String encoding) {+ public final void setCol(String nick, String cell, String encoding) {if (encoding == null)setCol(nick, cell.getBytes());else@@ -392,20 +391,20 @@ public class kelondroRow {}}- public void setCol(String nickname, long cell) {+ public final void setCol(String nickname, long cell) {if (nickref == null) genNickRef();Object[] ref = (Object[]) nickref.get(nickname);if (ref == null) return;kelondroColumn col = (kelondroColumn) ref[0];- setCol(col.encoder(), offset + ((Integer) ref[1]).intValue(), col.cellwidth(), cell);+ setCol(col.encoder, offset + ((Integer) ref[1]).intValue(), col.cellwidth, cell);}- public void setCol(int column, long cell) {+ public final void setCol(int column, long cell) {// uses the column definition to choose the right encoding- setCol(row[column].encoder(), offset + colstart[column], row[column].cellwidth(), cell);+ setCol(row[column].encoder, offset + colstart[column], row[column].cellwidth, cell);}- private void setCol(int encoder, int offset, int length, long cell) {+ private final void setCol(int encoder, int offset, int length, long cell) {switch (encoder) {case kelondroColumn.encoder_none:throw new kelondroException("ROW", "setColLong has celltype none, no encoder given");@@ -420,29 +419,29 @@ public class kelondroRow {}}- public byte[] getCol(String nickname, byte[] dflt) {+ public final byte[] getCol(String nickname, byte[] dflt) {if (nickref == null) genNickRef();Object[] ref = (Object[]) nickref.get(nickname);if (ref == null) return dflt;kelondroColumn col = (kelondroColumn) ref[0];- byte[] cell = new byte[col.cellwidth()];+ byte[] cell = new byte[col.cellwidth];System.arraycopy(rowinstance, offset + ((Integer) ref[1]).intValue(), cell, 0, cell.length);return cell;}- public String getColString(String nickname, String dflt, String encoding) {+ public final String getColString(String nickname, String dflt, String encoding) {if (nickref == null) genNickRef();Object[] ref = (Object[]) nickref.get(nickname);if (ref == null) return dflt;kelondroColumn col = (kelondroColumn) ref[0];- return getColString(col.encoder(), ((Integer) ref[1]).intValue(), col.cellwidth(), encoding);+ return getColString(col.encoder, ((Integer) ref[1]).intValue(), col.cellwidth, encoding);}- public String getColString(int column, String encoding) {- return getColString(row[column].encoder(), colstart[column], row[column].cellwidth(), encoding);+ public final String getColString(int column, String encoding) {+ return getColString(row[column].encoder, colstart[column], row[column].cellwidth, encoding);}- private String getColString(int encoder, int clstrt, int length, String encoding) {+ private final String getColString(int encoder, int clstrt, int length, String encoding) {if (rowinstance[offset + clstrt] == 0) return null;if (length > rowinstance.length - offset - clstrt) length = rowinstance.length - offset - clstrt;while ((length > 0) && (rowinstance[offset + clstrt + length - 1] == 0)) length--;@@ -457,31 +456,29 @@ public class kelondroRow {}}- public long getColLong(String nickname, long dflt) {+ public final long getColLong(String nickname, long dflt) {if (nickref == null) genNickRef();Object[] ref = (Object[]) nickref.get(nickname);if (ref == null) return dflt;kelondroColumn col = (kelondroColumn) ref[0];int clstrt = ((Integer) ref[1]).intValue();- return getColLong(col.encoder(), clstrt, col.cellwidth());+ return getColLong(col.encoder, clstrt, col.cellwidth);}- public long getColLong(int column) {+ public final long getColLong(int column) {// uses the column definition to choose the right encoding- return getColLong(row[column].encoder(), colstart[column], row[column].cellwidth());+ return getColLong(row[column].encoder, colstart[column], row[column].cellwidth);}protected final long getColLong(int encoder, int clstrt, int length) {- // start - fix for badly stored parameters- if ((length >= 3) && (rowinstance[offset + clstrt] == '[') && (rowinstance[offset + clstrt + 1] == 'B') && (rowinstance[offset + clstrt + 2] == '@')) return 0;- if ((length == 2) && (rowinstance[offset + clstrt] == '[') && (rowinstance[offset + clstrt + 1] == 'B')) return 0;- if ((length == 1) && (rowinstance[offset + clstrt] == '[')) return 0;- // stop - fix for badly stored parameters- switch (encoder) {+ switch (encoder) {case kelondroColumn.encoder_none:throw new kelondroException("ROW", "getColLong has celltype none, no encoder given");case kelondroColumn.encoder_b64e:// start - fix for badly stored parameters+ if ((length >= 3) && (rowinstance[offset + clstrt] == '[') && (rowinstance[offset + clstrt + 1] == 'B') && (rowinstance[offset + clstrt + 2] == '@')) return 0;+ if ((length == 2) && (rowinstance[offset + clstrt] == '[') && (rowinstance[offset + clstrt + 1] == 'B')) return 0;+ if ((length == 1) && (rowinstance[offset + clstrt] == '[')) return 0;boolean maxvalue = true;for (int i = 0; i < length; i++) if (rowinstance[offset + clstrt + i] != '_') {maxvalue = false; break;}if (maxvalue) return 0;@@ -495,52 +492,60 @@ public class kelondroRow {throw new kelondroException("ROW", "getColLong did not find appropriate encoding");}- public byte getColByte(String nickname, byte dflt) {+ public final byte getColByte(String nickname, byte dflt) {if (nickref == null) genNickRef();Object[] ref = (Object[]) nickref.get(nickname);if (ref == null) return dflt;return rowinstance[offset + ((Integer) ref[1]).intValue()];}- public byte getColByte(int column) {+ public final byte getColByte(int column) {return rowinstance[offset + colstart[column]];}- public byte[] getColBytes(int column) {- assert offset + colstart[column] + row[column].cellwidth() <= rowinstance.length :- "column = " + column + ", offset = " + offset + ", colstart[column] = " + colstart[column] + ", row[column].cellwidth() = " + row[column].cellwidth() + ", rowinstance.length = " + rowinstance.length;- byte[] c = new byte[row[column].cellwidth()];- System.arraycopy(rowinstance, offset + colstart[column], c, 0, row[column].cellwidth());+ public final byte[] getPrimaryKeyBytes() {+ byte[] c = new byte[primaryKeyLength];+ System.arraycopy(rowinstance, offset + ((primaryKeyIndex < 0) ? 0 : colstart[primaryKeyIndex]), c, 0, primaryKeyLength);+ return c;+ }++ public final byte[] getColBytes(int column) {+ assert offset + colstart[column] + row[column].cellwidth <= rowinstance.length :+ "column = " + column + ", offset = " + offset + ", colstart[column] = " + colstart[column] + ", row[column].cellwidth() = " + row[column].cellwidth + ", rowinstance.length = " + rowinstance.length;+ int w = row[column].cellwidth;+ byte[] c = new byte[w];+ System.arraycopy(rowinstance, offset + colstart[column], c, 0, w);return c;}- public char[] getColChars(int column) {- char[] c = new char[row[column].cellwidth()];- System.arraycopy(rowinstance, offset + colstart[column], c, 0, row[column].cellwidth());+ public final char[] getColChars(int column) {+ int w = row[column].cellwidth;+ char[] c = new char[w];+ System.arraycopy(rowinstance, offset + colstart[column], c, 0, w);return c;}- public void writeToArray(int column, byte[] target, int targetOffset) {+ public final void writeToArray(int column, byte[] target, int targetOffset) {// this method shall replace the getColBytes where possible, bacause it may reduce the number of new byte[] allocations- assert (targetOffset + row[column].cellwidth() <= target.length) : "targetOffset = " + targetOffset + ", target.length = " + target.length + ", row[column].cellwidth() = " + row[column].cellwidth();- System.arraycopy(rowinstance, offset + colstart[column], target, targetOffset, row[column].cellwidth());+ assert (targetOffset + row[column].cellwidth <= target.length) : "targetOffset = " + targetOffset + ", target.length = " + target.length + ", row[column].cellwidth() = " + row[column].cellwidth;+ System.arraycopy(rowinstance, offset + colstart[column], target, targetOffset, row[column].cellwidth);}- public String toPropertyForm(boolean includeBraces, boolean decimalCardinal, boolean longname) {+ public final String toPropertyForm(boolean includeBraces, boolean decimalCardinal, boolean longname) {serverByteBuffer bb = new serverByteBuffer();if (includeBraces) bb.append('{');for (int i = 0; i < row.length; i++) {- bb.append((longname) ? row[i].description() : row[i].nickname());+ bb.append((longname) ? row[i].description : row[i].nickname);bb.append('=');- if ((decimalCardinal) && (row[i].celltype() == kelondroColumn.celltype_cardinal)) {+ if ((decimalCardinal) && (row[i].celltype == kelondroColumn.celltype_cardinal)) {bb.append(Long.toString(getColLong(i)));- } else if ((decimalCardinal) && (row[i].celltype() == kelondroColumn.celltype_bitfield)) {+ } else if ((decimalCardinal) && (row[i].celltype == kelondroColumn.celltype_bitfield)) {bb.append((new kelondroBitfield(getColBytes(i))).exportB64());- } else if ((decimalCardinal) && (row[i].celltype() == kelondroColumn.celltype_binary)) {- assert row[i].cellwidth() == 1;+ } else if ((decimalCardinal) && (row[i].celltype == kelondroColumn.celltype_binary)) {+ assert row[i].cellwidth == 1;bb.append(Integer.toString((0xff & getColByte(i))));} else {- bb.append(rowinstance, offset + colstart[i], row[i].cellwidth());+ bb.append(rowinstance, offset + colstart[i], row[i].cellwidth);}if (i < row.length - 1) {bb.append(',');@@ -552,7 +557,7 @@ public class kelondroRow {return bb.toString();}- public String toString() {+ public final String toString() {return toPropertyForm(true, false, false);}@@ -583,20 +588,20 @@ public class kelondroRow {return x;}- public boolean subsumes(kelondroRow otherRow) {+ public final boolean subsumes(kelondroRow otherRow) {// returns true, if this row has at least all columns as the other row// and possibly some moreif (this.objectsize < otherRow.objectsize) return false;for (int i = 0; i < otherRow.row.length; i++) {- if ((this.row[i].cellwidth() == otherRow.row[i].cellwidth()) &&- (this.row[i].celltype() == kelondroColumn.celltype_bitfield) &&- (otherRow.row[i].celltype() == kelondroColumn.celltype_binary)) continue;+ if ((this.row[i].cellwidth == otherRow.row[i].cellwidth) &&+ (this.row[i].celltype == kelondroColumn.celltype_bitfield) &&+ (otherRow.row[i].celltype == kelondroColumn.celltype_binary)) continue;if (!(this.row[i].equals(otherRow.row[i]))) return false;}return true;}- public boolean equals(kelondroRow otherRow) {+ public final boolean equals(kelondroRow otherRow) {if (this.objectsize != otherRow.objectsize) return false;for (int i = 0; i < otherRow.row.length; i++) {if (!(this.row[i].equals(otherRow.row[i]))) return false;diff --git a/source/de/anomic/kelondro/kelondroRowCollection.java b/source/de/anomic/kelondro/kelondroRowCollection.javaindex 786e2bf1c..6ebd745a2 100644--- a/source/de/anomic/kelondro/kelondroRowCollection.java+++ b/source/de/anomic/kelondro/kelondroRowCollection.java@@ -63,7 +63,7 @@ public class kelondroRowCollection {public kelondroRowCollection(kelondroRow rowdef, int objectCount) {this.rowdef = rowdef;- this.chunkcache = new byte[objectCount * rowdef.objectsize()];+ this.chunkcache = new byte[objectCount * rowdef.objectsize];this.chunkcount = 0;this.sortBound = 0;this.lastTimeRead = System.currentTimeMillis();@@ -100,8 +100,8 @@ public class kelondroRowCollection {if (oldOrder == null) oldOrder = kelondroBase64Order.bySignature(sortOrderKey);}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 order does not match with new order; objectOrder.signature = " + rowdef.objectOrder.signature() + ", oldOrder.signature = " + oldOrder.signature());+ if (rowdef.primaryKeyIndex != (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;@@ -159,7 +159,7 @@ public class kelondroRowCollection {entry.setCol(exp_last_read, daysSince2000(this.lastTimeRead));entry.setCol(exp_last_wrote, daysSince2000(this.lastTimeWrote));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_col, this.rowdef.primaryKeyIndex);entry.setCol(exp_order_bound, this.sortBound);entry.setCol(exp_collection, this.chunkcache);return entry.bytes();@@ -174,7 +174,7 @@ public class kelondroRowCollection {}private final void ensureSize(int elements) {- int needed = elements * rowdef.objectsize();+ int needed = elements * rowdef.objectsize;if (chunkcache.length >= needed) return;byte[] newChunkcache = new byte[(int) (needed * growfactor)]; // increase spaceSystem.arraycopy(chunkcache, 0, newChunkcache, 0, chunkcache.length);@@ -182,77 +182,14 @@ public class kelondroRowCollection {newChunkcache = null;}- /*- private static final Object[] arraydepot = new Object[]{new byte[0]};-- private final void ensureSize(int elements) {- int needed = elements * rowdef.objectsize();- if (chunkcache.length >= needed) return;- long neededRAM = (long) (needed * growfactor);- long availableRAM = serverMemory.available();- //if ((safemode) && (neededRAM > availableRAM)) throw new kelondroMemoryProtectionException("rowCollection temporary chunkcache", neededRAM, availableRAM);-- if (neededRAM > availableRAM) {- // go into safe mode: use the arraydepot- synchronized (arraydepot) {- if (((byte[]) arraydepot[0]).length >= neededRAM) {- System.out.println("ensureSize case 1");- // use the depot to increase the chunkcache- byte[] newChunkcache = (byte[]) arraydepot[0];- System.arraycopy(chunkcache, 0, newChunkcache, 0, chunkcache.length);- // safe the chunkcache for later use in arraydepot- arraydepot[0] = chunkcache;- chunkcache = newChunkcache;- newChunkcache = null;- } else {- System.out.println("ensureSize case 2");- // this is the critical part: we need more RAM.- // do a buffering using the arraydepot- byte[] buffer0 = (byte[]) arraydepot[0];- byte[] buffer1 = new byte[chunkcache.length - buffer0.length];- // first copy the previous chunkcache to the two buffers- System.arraycopy(chunkcache, 0, buffer0, 0, buffer0.length);- System.arraycopy(chunkcache, buffer0.length, buffer1, 0, buffer1.length);- // then free the previous chunkcache and replace it with a new array at target size- chunkcache = null; // hand this over to GC- chunkcache = new byte[(int) neededRAM];- System.arraycopy(buffer0, 0, chunkcache, 0, buffer0.length);- System.arraycopy(buffer1, 0, chunkcache, buffer0.length, buffer1.length);- // then move the bigger buffer into the arraydepot- if (buffer0.length > buffer1.length) {- arraydepot[0] = buffer0;- } else {- arraydepot[1] = buffer1;- }- buffer0 = null;- buffer1 = null;- }- }- } else {- // there is enough memory available- byte[] newChunkcache = new byte[(int) neededRAM]; // increase space- System.arraycopy(chunkcache, 0, newChunkcache, 0, chunkcache.length);- // safe the chunkcache for later use in arraydepot- synchronized (arraydepot) {- if (((byte[]) arraydepot[0]).length < chunkcache.length) {- System.out.println("ensureSize case 0");- arraydepot[0] = chunkcache;- }- }- chunkcache = newChunkcache;- newChunkcache = null;- }- }- */-public final long memoryNeededForGrow() {- return (long) ((((long) (chunkcount + 1)) * ((long) rowdef.objectsize())) * growfactor);+ return (long) ((((long) (chunkcount + 1)) * ((long) rowdef.objectsize)) * growfactor);}public synchronized void trim(boolean plusGrowFactor) {if (chunkcache.length == 0)return;- int needed = chunkcount * rowdef.objectsize();+ int needed = chunkcount * rowdef.objectsize;if (plusGrowFactor)needed = (int) (needed * growfactor);if (needed >= chunkcache.length)@@ -283,15 +220,15 @@ public class kelondroRowCollection {assert (index * rowdef.objectsize < chunkcache.length);if ((chunkcache == null) || (rowdef == null)) return null; // case may appear during shutdownif (index >= chunkcount) return null;- if (index * rowdef.objectsize() >= chunkcache.length) return null;+ if (index * rowdef.objectsize >= chunkcache.length) return null;this.lastTimeRead = System.currentTimeMillis();- return rowdef.newEntry(chunkcache, index * rowdef.objectsize(), true);+ return rowdef.newEntry(chunkcache, index * rowdef.objectsize, true);}public synchronized final void set(int index, kelondroRow.Entry a) {assert (index >= 0) : "set: access with index " + index + " is below zero";ensureSize(index + 1);- a.writeToArray(chunkcache, index * rowdef.objectsize());+ a.writeToArray(chunkcache, index * rowdef.objectsize);if (index >= chunkcount) chunkcount = index + 1;this.lastTimeWrote = System.currentTimeMillis();}@@ -302,7 +239,7 @@ public class kelondroRowCollection {if (index < chunkcount) {// make roomensureSize(chunkcount + 1);- System.arraycopy(chunkcache, rowdef.objectsize() * index, chunkcache, rowdef.objectsize() * (index + 1), (chunkcount - index) * rowdef.objectsize());+ System.arraycopy(chunkcache, rowdef.objectsize * index, chunkcache, rowdef.objectsize * (index + 1), (chunkcount - index) * rowdef.objectsize);chunkcount++;}// insert entry into gap@@ -336,9 +273,9 @@ public class kelondroRowCollection {return; // TODO: this is temporary; remote peers may still submit bad entries}assert (!(bugappearance(a, astart, alength))) : "a = " + serverLog.arrayList(a, astart, alength);- int l = Math.min(rowdef.objectsize(), Math.min(alength, a.length - astart));+ int l = Math.min(rowdef.objectsize, Math.min(alength, a.length - astart));ensureSize(chunkcount + 1);- System.arraycopy(a, astart, chunkcache, rowdef.objectsize() * chunkcount, l);+ System.arraycopy(a, astart, chunkcache, rowdef.objectsize * chunkcount, l);chunkcount++;this.lastTimeWrote = System.currentTimeMillis();}@@ -357,9 +294,9 @@ public class kelondroRowCollection {public synchronized final void addAllUnique(kelondroRowCollection c) {if (c == null) return;- assert(rowdef.objectsize() == c.rowdef.objectsize());+ assert(rowdef.objectsize == c.rowdef.objectsize);ensureSize(chunkcount + c.size());- System.arraycopy(c.chunkcache, 0, chunkcache, rowdef.objectsize() * chunkcount, rowdef.objectsize() * c.size());+ System.arraycopy(c.chunkcache, 0, chunkcache, rowdef.objectsize * chunkcount, rowdef.objectsize * c.size());chunkcount += c.size();}@@ -381,17 +318,17 @@ public class kelondroRowCollection {if (keepOrder && (p < sortBound)) {// remove by shift (quite expensive for big collections)System.arraycopy(- chunkcache, (p + 1) * this.rowdef.objectsize(),- chunkcache, p * this.rowdef.objectsize(),- (chunkcount - p - 1) * this.rowdef.objectsize());+ chunkcache, (p + 1) * this.rowdef.objectsize,+ chunkcache, p * this.rowdef.objectsize,+ (chunkcount - p - 1) * this.rowdef.objectsize);sortBound--;} else {// remove by copying the top-element to the remove positionif (p != chunkcount - 1) {System.arraycopy(- chunkcache, (chunkcount - 1) * this.rowdef.objectsize(),- chunkcache, p * this.rowdef.objectsize(),- this.rowdef.objectsize());+ chunkcache, (chunkcount - 1) * this.rowdef.objectsize,+ chunkcache, p * this.rowdef.objectsize,+ this.rowdef.objectsize);}// we moved the last element to the remove position: (p+1)st element// only the first p elements keep their order (element p is already outside the order)@@ -551,17 +488,17 @@ public class kelondroRowCollection {private final int swap(int i, int j, int p) {if (i == j) return p;- if ((this.chunkcount + 1) * this.rowdef.objectsize() < this.chunkcache.length) {+ if ((this.chunkcount + 1) * this.rowdef.objectsize < this.chunkcache.length) {// there is space in the chunkcache that we can use as buffer- System.arraycopy(chunkcache, this.rowdef.objectsize() * i, chunkcache, chunkcache.length - this.rowdef.objectsize(), this.rowdef.objectsize());- System.arraycopy(chunkcache, this.rowdef.objectsize() * j, chunkcache, this.rowdef.objectsize() * i, this.rowdef.objectsize());- System.arraycopy(chunkcache, chunkcache.length - this.rowdef.objectsize(), chunkcache, this.rowdef.objectsize() * j, this.rowdef.objectsize());+ System.arraycopy(chunkcache, this.rowdef.objectsize * i, chunkcache, chunkcache.length - this.rowdef.objectsize, this.rowdef.objectsize);+ System.arraycopy(chunkcache, this.rowdef.objectsize * j, chunkcache, this.rowdef.objectsize * i, this.rowdef.objectsize);+ System.arraycopy(chunkcache, chunkcache.length - this.rowdef.objectsize, chunkcache, this.rowdef.objectsize * j, this.rowdef.objectsize);} else {// allocate a chunk to use as buffer- byte[] a = new byte[this.rowdef.objectsize()];- System.arraycopy(chunkcache, this.rowdef.objectsize() * i, a, 0, this.rowdef.objectsize());- System.arraycopy(chunkcache, this.rowdef.objectsize() * j, chunkcache, this.rowdef.objectsize() * i, this.rowdef.objectsize());- System.arraycopy(a, 0, chunkcache, this.rowdef.objectsize() * j, this.rowdef.objectsize());+ byte[] a = new byte[this.rowdef.objectsize];+ System.arraycopy(chunkcache, this.rowdef.objectsize * i, a, 0, this.rowdef.objectsize);+ System.arraycopy(chunkcache, this.rowdef.objectsize * j, chunkcache, this.rowdef.objectsize * i, this.rowdef.objectsize);+ System.arraycopy(a, 0, chunkcache, this.rowdef.objectsize * j, this.rowdef.objectsize);}if (i == p) return j; else if (j == p) return i; else return p;}@@ -598,39 +535,38 @@ public class kelondroRowCollection {}private final int compare(int i, int j) {- assert (chunkcount * this.rowdef.objectsize() <= chunkcache.length) : "chunkcount = " + chunkcount + ", objsize = " + this.rowdef.objectsize() + ", chunkcache.length = " + chunkcache.length;+ 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.rowdef.objectOrder != null);if (i == j) return 0;- 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");+ assert (this.rowdef.primaryKeyIndex == 0) : "this.sortColumn = " + this.rowdef.primaryKeyIndex;+ int colstart = (this.rowdef.primaryKeyIndex < 0) ? 0 : this.rowdef.colstart[this.rowdef.primaryKeyIndex];+ assert (!bugappearance(chunkcache, i * this.rowdef.objectsize + colstart, this.rowdef.primaryKeyLength));+ assert (!bugappearance(chunkcache, j * this.rowdef.objectsize + colstart, this.rowdef.primaryKeyLength));int c = this.rowdef.objectOrder.compare(chunkcache,- i * this.rowdef.objectsize() + colstart,- keylength,+ i * this.rowdef.objectsize + colstart,+ this.rowdef.primaryKeyLength,chunkcache,- j * this.rowdef.objectsize() + colstart,- keylength);+ j * this.rowdef.objectsize + colstart,+ this.rowdef.primaryKeyLength);return c;}protected synchronized int compare(byte[] a, int astart, int alength, int chunknumber) {assert (chunknumber < chunkcount);- 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));+ int l = Math.min(this.rowdef.primaryKeyLength, Math.min(a.length - astart, alength));+ return rowdef.objectOrder.compare(a, astart, l, chunkcache, chunknumber * this.rowdef.objectsize + ((rowdef.primaryKeyIndex < 0) ? 0 : this.rowdef.colstart[rowdef.primaryKeyIndex]), this.rowdef.primaryKeyLength);}protected synchronized 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[rowdef.primaryKey];- final int len = Math.min(this.rowdef.width(rowdef.primaryKey), Math.min(alength, a.length - astart));+ int p = chunknumber * this.rowdef.objectsize + ((rowdef.primaryKeyIndex < 0) ? 0 : this.rowdef.colstart[rowdef.primaryKeyIndex]);+ final int len = Math.min(this.rowdef.primaryKeyLength, Math.min(alength, a.length - astart));while (i < len) if (a[astart + i++] != chunkcache[p++]) return false;- return ((len == this.rowdef.width(rowdef.primaryKey)) || (chunkcache[len] == 0)) ;+ return ((len == this.rowdef.primaryKeyLength) || (chunkcache[len] == 0)) ;}public synchronized void close() {diff --git a/source/de/anomic/kelondro/kelondroRowSet.java b/source/de/anomic/kelondro/kelondroRowSet.javaindex 7b281c431..2a1e6117c 100644--- a/source/de/anomic/kelondro/kelondroRowSet.java+++ b/source/de/anomic/kelondro/kelondroRowSet.java@@ -64,8 +64,8 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndpublic void setOrdering(kelondroOrder newOrder, int newColumn) {assert newOrder != null;if ((rowdef.objectOrder == null) ||- (!(rowdef.objectOrder.signature().equals(newOrder.signature()))) ||- (newColumn != rowdef.primaryKey)) {+ (!(rowdef.objectOrder.signature().equals(newOrder.signature()))) ||+ (newColumn != rowdef.primaryKeyIndex)) {rowdef.setOrdering(newOrder, newColumn);this.sortBound = 0;}@@ -103,12 +103,12 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndpublic synchronized kelondroRow.Entry put(kelondroRow.Entry entry) {assert (entry != null);- assert (entry.getColBytes(rowdef.primaryKey) != null);+ assert (entry.getPrimaryKeyBytes() != null);//assert (!(serverLog.allZero(entry.getColBytes(super.sortColumn))));long handle = profile.startWrite();int index = -1;kelondroRow.Entry oldentry = null;- index = find(entry.bytes(), super.rowdef.colstart[rowdef.primaryKey], super.rowdef.width(rowdef.primaryKey));+ index = find(entry.bytes(), (rowdef.primaryKeyIndex < 0) ? 0 :super.rowdef.colstart[rowdef.primaryKeyIndex], super.rowdef.primaryKeyLength);if (index < 0) {super.addUnique(entry);} else {@@ -128,7 +128,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd//System.out.println("remove: chunk found at index position (after remove) " + index + ", inset=" + serverLog.arrayList(super.chunkcache, super.rowdef.objectsize() * index, length) + ", searchkey=" + serverLog.arrayList(a, start, length));int findagainindex = find(a, start, length);//System.out.println("kelondroRowSet.remove");- assert findagainindex < 0 : "remove: chunk found again at index position (after remove) " + findagainindex + ", index(before) = " + index + ", inset=" + serverLog.arrayList(super.chunkcache, super.rowdef.objectsize() * findagainindex, length) + ", searchkey=" + serverLog.arrayList(a, start, length); // check if the remove worked+ assert findagainindex < 0 : "remove: chunk found again at index position (after remove) " + findagainindex + ", index(before) = " + index + ", inset=" + serverLog.arrayList(super.chunkcache, super.rowdef.objectsize * findagainindex, length) + ", searchkey=" + serverLog.arrayList(a, start, length); // check if the remove workedreturn entry;}diff --git a/source/de/anomic/kelondro/kelondroTree.java b/source/de/anomic/kelondro/kelondroTree.javaindex 53c2bbb8e..bc48ddbef 100644--- a/source/de/anomic/kelondro/kelondroTree.java+++ b/source/de/anomic/kelondro/kelondroTree.java@@ -342,7 +342,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexpublic kelondroRow.Entry put(kelondroRow.Entry newrow) throws IOException {assert (newrow != null);assert (newrow.columns() == row().columns());- assert (!(serverLog.allZero(newrow.getColBytes(super.row().primaryKey))));+ assert (!(serverLog.allZero(newrow.getPrimaryKeyBytes())));assert newrow.objectsize() <= super.row().objectsize;// Associates the specified value with the specified key in this mapkelondroRow.Entry result = null;diff --git a/source/de/anomic/plasma/crawler/plasmaHTTPLoader.java b/source/de/anomic/plasma/crawler/plasmaHTTPLoader.javaindex dd225b421..4c0309bf4 100644--- a/source/de/anomic/plasma/crawler/plasmaHTTPLoader.java+++ b/source/de/anomic/plasma/crawler/plasmaHTTPLoader.java@@ -345,8 +345,9 @@ public final class plasmaHTTPLoader {failreason = plasmaCrawlEURL.DENIED_NO_ROUTE_TO_HOST;} else if ((e instanceof UnknownHostException) ||((errorMsg != null) && (errorMsg.indexOf("unknown host") >= 0))) {- this.log.logWarning("CRAWLER Unknown host in URL '" + entry.url().toString() + "'. " +- "Referer URL: " + ((entry.referrerhash() == null) ? "Unknown" : sb.getURL(entry.referrerhash()).toNormalform(true, true)));+ yacyURL u = (entry.referrerhash() == null) ? null : sb.getURL(entry.referrerhash());+ this.log.logWarning("CRAWLER Unknown host in URL '" + entry.url() + "'. " ++ "Referer URL: " + ((u == null) ? "Unknown" : u.toNormalform(true, true)));failreason = plasmaCrawlEURL.DENIED_UNKNOWN_HOST;} else if (e instanceof java.net.BindException) {this.log.logWarning("CRAWLER BindException detected while trying to download content from '" + entry.url().toString() +diff --git a/source/de/anomic/plasma/plasmaCrawlStacker.java b/source/de/anomic/plasma/plasmaCrawlStacker.javaindex 3de20e195..4ccf35a65 100644--- a/source/de/anomic/plasma/plasmaCrawlStacker.java+++ b/source/de/anomic/plasma/plasmaCrawlStacker.java@@ -343,7 +343,7 @@ public final class plasmaCrawlStacker extends Thread {return new plasmaCrawlEntry(entry);}- public String stackCrawl(yacyURL url, String referrerhash, String initiatorHash, String name, Date loadDate, int currentdepth, plasmaCrawlProfile.entry profile) throws InterruptedException {+ public String stackCrawl(yacyURL url, String referrerhash, String initiatorHash, String name, Date loadDate, int currentdepth, plasmaCrawlProfile.entry profile) {// stacks a crawl item. The position can also be remote// returns null if successful, a reason string if not successful//this.log.logFinest("stackCrawl: nexturlString='" + nexturlString + "'");@@ -363,7 +363,7 @@ public final class plasmaCrawlStacker extends Thread {return stackCrawl(entry);}- public String stackCrawl(plasmaCrawlEntry entry) throws InterruptedException {+ public String stackCrawl(plasmaCrawlEntry entry) {// stacks a crawl item. The position can also be remote// returns null if successful, a reason string if not successful//this.log.logFinest("stackCrawl: nexturlString='" + nexturlString + "'");diff --git a/source/de/anomic/plasma/plasmaCrawlZURL.java b/source/de/anomic/plasma/plasmaCrawlZURL.javaindex f98d20119..3d6d08a3c 100644--- a/source/de/anomic/plasma/plasmaCrawlZURL.java+++ b/source/de/anomic/plasma/plasmaCrawlZURL.java@@ -49,7 +49,7 @@ public class plasmaCrawlZURL {"Cardinal workdate-8 {b256}, " + // the time when the url was last time tried to load"Cardinal workcount-4 {b256}, " + // number of load retries"String anycause-80, " + // string describing load failure- "byte[] entry-" + plasmaCrawlEntry.rowdef.objectsize(), // extra space+ "byte[] entry-" + plasmaCrawlEntry.rowdef.objectsize, // extra spacekelondroBase64Order.enhancedCoder,0);@@ -106,7 +106,7 @@ public class plasmaCrawlZURL {stack.add(e.hash());}- public Entry top(int pos) throws IOException {+ public Entry top(int pos) {String urlhash = (String) stack.get(pos);if (urlhash == null) return null;return getEntry(urlhash);diff --git a/source/de/anomic/plasma/plasmaRankingCRProcess.java b/source/de/anomic/plasma/plasmaRankingCRProcess.javaindex a8996f36c..cd9ccaece 100644--- a/source/de/anomic/plasma/plasmaRankingCRProcess.java+++ b/source/de/anomic/plasma/plasmaRankingCRProcess.java@@ -208,7 +208,7 @@ public class plasmaRankingCRProcess {acc_entry = acc.row().newEntry();acc_entry.setCol("Referee", key, null);for (int i = 1; i < acc.row().columns(); i++) {- acc_entry.setCol(i, new_entry.getAttr(acc.row().column(i).nickname(), 0));+ acc_entry.setCol(i, new_entry.getAttr(acc.row().column(i).nickname, 0));}seq.put(key.getBytes(), new_entry.getSeqCollection());FUDate = plasmaWordIndex.microDateHoursInt(System.currentTimeMillis()); // first update datediff --git a/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java b/source/de/anomic/plasma/plasmaRankingRCIEvaluation.javaindex 2ee68a7e1..c5ae283f5 100644--- a/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java+++ b/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java@@ -227,7 +227,7 @@ public class plasmaRankingRCIEvaluation {File root_path = new File(args[1]);// load a partition table- plasmaSearchPreOrder.loadYBR(new File(root_path, "ranking/YBR"), 16);+ plasmaSearchRankingProcess.loadYBR(new File(root_path, "ranking/YBR"), 16);// load domain list and generate hash index for domainsHashMap dommap = genReverseDomHash(new File(root_path, "domlist.txt"));@@ -236,8 +236,8 @@ public class plasmaRankingRCIEvaluation {String hash, dom;for (int i = 0; i < 9; i++) {System.out.print("YBR-" + i + ": ");- for (int j = 0; j < plasmaSearchPreOrder.ybrTables[i].size(); j++) {- hash = new String(plasmaSearchPreOrder.ybrTables[i].get(j));+ for (int j = 0; j < plasmaSearchRankingProcess.ybrTables[i].size(); j++) {+ hash = new String(plasmaSearchRankingProcess.ybrTables[i].get(j));dom = (String) dommap.get(hash);if (dom == null) System.out.print("[" + hash + "], "); else System.out.print(dom + ", ");}diff --git a/source/de/anomic/plasma/plasmaSearchContainer.java b/source/de/anomic/plasma/plasmaSearchContainer.javadeleted file mode 100644index de3f41232..000000000--- a/source/de/anomic/plasma/plasmaSearchContainer.java+++ /dev/null@@ -1,181 +0,0 @@-// plasmaSearchContainer.java-// (C) 2007 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany-// first published 29.8.2007 on http://yacy.net-//-// This is a part of YaCy, a peer-to-peer based web search engine-//-// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $-// $LastChangedRevision: 1986 $-// $LastChangedBy: orbiter $-//-// LICENSE-//-// This program is free software; you can redistribute it and/or modify-// it under the terms of the GNU General Public License as published by-// the Free Software Foundation; either version 2 of the License, or-// (at your option) any later version.-//-// This program is distributed in the hope that it will be useful,-// but WITHOUT ANY WARRANTY; without even the implied warranty of-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-// GNU General Public License for more details.-//-// You should have received a copy of the GNU General Public License-// along with this program; if not, write to the Free Software-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA---package de.anomic.plasma;--import java.util.HashSet;-import java.util.Iterator;-import java.util.Set;-import java.util.TreeSet;--import de.anomic.htmlFilter.htmlFilterContentScraper;-import de.anomic.index.indexContainer;-import de.anomic.index.indexRWIEntry;-import de.anomic.kelondro.kelondroMScoreCluster;--public class plasmaSearchContainer {-- private indexRWIEntry entryMin, entryMax;- private indexContainer container;- private plasmaSearchRankingProfile ranking;- private TreeSet searchedWords;- private int globalcount;- private HashSet urlhashes; // set for double-check- private kelondroMScoreCluster ref; // reference score computation for the commonSense heuristic- private plasmaSearchQuery query;--- public plasmaSearchContainer(plasmaSearchQuery query, plasmaSearchRankingProfile ranking, TreeSet searchedWords) {- this(query, ranking, searchedWords, plasmaWordIndex.emptyContainer(null, 0));- }-- public plasmaSearchContainer(plasmaSearchQuery query, plasmaSearchRankingProfile ranking, TreeSet searchedWords, indexContainer presortedContainer) {- // only for sorted containers- this.entryMin = null;- this.entryMax = null;- this.container = presortedContainer;- this.ranking = ranking;- this.searchedWords = searchedWords;- this.globalcount = 0;- this.urlhashes = new HashSet();- this.ref = new kelondroMScoreCluster();- this.query = query;- }-- public void insert(indexRWIEntry entry, boolean local) {- // add the entry to the container into a position in such a way, that the container stays sorted- assert (entry != null);-- // make a double-check: because different peers may have computed different ranking attributes,- // the double check cannot be made using the ranking and the insert position- if (urlhashes.contains(entry.urlHash())) return;- urlhashes.add(entry.urlHash());-- // find new min/max borders- if (this.entryMin == null) this.entryMin = (indexRWIEntry) entry.clone(); else this.entryMin.min(entry);- if (this.entryMax == null) this.entryMax = (indexRWIEntry) entry.clone(); else this.entryMax.max(entry);- long pivot = this.ranking.preRanking(entry, this.entryMin, this.entryMax, this.searchedWords);-- // insert the entry- int insertPosition = insertPosition(pivot);-- // insert at found position- container.insertUnique(insertPosition, entry.toKelondroEntry());-- // update counter- if (!local) this.globalcount++;-- }-- public void insert(indexContainer c, boolean local, boolean presorted) {- if ((this.container.size() == 0) && (presorted)) {- this.container = c;- if (!local) this.globalcount = c.size();- } else {- Iterator i = c.entries();- while (i.hasNext()) {- insert((indexRWIEntry) i.next(), local);- }- }- }-- private int insertPosition(long pivotRanking) {- return insertPosition(pivotRanking, 0, container.size());- }-- private int insertPosition(long pivotRanking, int left /*including*/, int right /*excluding*/) {- if (right - left < 10) {- // do iterative search, less overhead- for (int i = left; i < right; i++) {- if (this.ranking.preRanking(new indexRWIEntry(container.get(i)), this.entryMin, this.entryMax, this.searchedWords) < pivotRanking) {- // we found the right insert position- return i;- }- }- return right;- }- // find recursively- int middle = (left + right) / 2;- if (this.ranking.preRanking(new indexRWIEntry(container.get(middle)), this.entryMin, this.entryMax, this.searchedWords) < pivotRanking) {- // must be on the left side- return insertPosition(pivotRanking, left, middle);- } else {- // must be on the right side- return insertPosition(pivotRanking, middle + 1, right);- }- }-- public indexRWIEntry remove(String urlHash) {- return this.container.remove(urlHash);- }-- public int removeEntries(Set urlHashes) {- return this.container.removeEntries(urlHashes);- }-- public indexContainer container() {- return this.container;- }-- public int getGlobalCount() {- return this.globalcount;- }-- public Set getReferences(int count) {- // create a list of words that had been computed by statistics over all- // words that appeared in the url or the description of all urls- Object[] refs = ref.getScores(count, false, 2, Integer.MAX_VALUE);- TreeSet s = new TreeSet(String.CASE_INSENSITIVE_ORDER);- for (int i = 0; i < refs.length; i++) {- s.add((String) refs[i]);- }- return s;- }-- public void addReferences(String[] words) {- String word;- for (int i = 0; i < words.length; i++) {- word = words[i].toLowerCase();- if ((word.length() > 2) &&- ("http_html_php_ftp_www_com_org_net_gov_edu_index_home_page_for_usage_the_and_".indexOf(word) < 0) &&- (!(query.queryHashes.contains(plasmaCondenser.word2hash(word)))))- ref.incScore(word);- }- }-- protected void addReferences(plasmaSearchEvent.ResultEntry resultEntry) {- // take out relevant information for reference computation- if ((resultEntry.url() == null) || (resultEntry.title() == null)) return;- String[] urlcomps = htmlFilterContentScraper.urlComps(resultEntry.url().toNormalform(true, true)); // word components of the url- String[] descrcomps = resultEntry.title().toLowerCase().split(htmlFilterContentScraper.splitrex); // words in the description-- // add references- addReferences(urlcomps);- addReferences(descrcomps);- }--}diff --git a/source/de/anomic/plasma/plasmaSearchEvent.java b/source/de/anomic/plasma/plasmaSearchEvent.javaindex 16cf6f4a4..0a392069c 100644--- a/source/de/anomic/plasma/plasmaSearchEvent.java+++ b/source/de/anomic/plasma/plasmaSearchEvent.java@@ -41,7 +41,6 @@ import de.anomic.index.indexRWIEntry;import de.anomic.index.indexURLEntry;import de.anomic.kelondro.kelondroBitfield;import de.anomic.kelondro.kelondroMSetTools;-import de.anomic.kelondro.kelondroRow;import de.anomic.server.logging.serverLog;import de.anomic.yacy.yacyCore;import de.anomic.yacy.yacyDHTAction;@@ -55,12 +54,13 @@ public final class plasmaSearchEvent {public static String lastEventID = "";private static HashMap lastEvents = new HashMap(); // a cache for objects from this class: re-use old search requestspublic static final long eventLifetime = 600000; // the time an event will stay in the cache, 10 Minutes+ private static final int max_results_preparation = 200;private long eventTime;private plasmaSearchQuery query;private plasmaSearchRankingProfile ranking;private plasmaWordIndex wordIndex;- private plasmaSearchContainer rankedCache; // ordered search results, grows dynamically as all the query threads enrich this container+ private plasmaSearchRankingProcess rankedCache; // ordered search results, grows dynamically as all the query threads enrich this containerprivate Map rcAbstracts; // cache for index abstracts; word:TreeMap mapping where the embedded TreeMap is a urlhash:peerlist relationprivate plasmaSearchProcessing process;private yacySearch[] primarySearchThreads, secondarySearchThreads;@@ -117,7 +117,7 @@ public final class plasmaSearchEvent {long start = System.currentTimeMillis();if ((query.domType == plasmaSearchQuery.SEARCHDOM_GLOBALDHT) ||(query.domType == plasmaSearchQuery.SEARCHDOM_CLUSTERALL)) {- this.rankedCache = new plasmaSearchContainer(query, ranking, plasmaSearchQuery.cleanQuery(query.queryString)[0]);+ this.rankedCache = new plasmaSearchRankingProcess(query, process, ranking, max_results_preparation);int fetchpeers = (int) (query.maximumTime / 500L); // number of target peers; means 10 peers in 10 secondsif (fetchpeers > 50) fetchpeers = 50;@@ -191,13 +191,8 @@ public final class plasmaSearchEvent {searchContainerMaps[1].values(),query.maxDistance);this.localcount = rcLocal.size();- plasmaSearchPreOrder sort = new plasmaSearchPreOrder(query, process, ranking, rcLocal);-- process.startTimer();- rcLocal = sort.strippedContainer(200);- process.yield("result strip", rcLocal.size());-- this.rankedCache = new plasmaSearchContainer(query, ranking, plasmaSearchQuery.cleanQuery(query.queryString)[0], rcLocal);+ this.rankedCache = new plasmaSearchRankingProcess(query, process, ranking, max_results_preparation);+ this.rankedCache.insert(rcLocal, true);}if (query.onlineSnippetFetch) {@@ -209,33 +204,36 @@ public final class plasmaSearchEvent {}} else {// prepare result vector directly without worker threads- int rankedIndex = 0;process.startTimer();-- while ((rankedIndex < rankedCache.container().size()) && (resultList.size() < (query.neededResults()))) {- // fetch next entry to work on- indexContainer c = rankedCache.container();- indexRWIEntry entry = new indexRWIEntry(c.get(rankedIndex++));- indexURLEntry page = wordIndex.loadedURL.load(entry.urlHash(), entry);+ indexRWIEntry entry;+ indexURLEntry page;+ ResultEntry resultEntry;+ synchronized (rankedCache) {+ Iterator indexRWIEntryIterator = rankedCache.entries();+ while ((indexRWIEntryIterator.hasNext()) && (resultList.size() < (query.neededResults()))) {+ // fetch next entry+ entry = (indexRWIEntry) indexRWIEntryIterator.next();+ page = wordIndex.loadedURL.load(entry.urlHash(), entry);- if (page == null) {- registerFailure(entry.urlHash(), "url does not exist in lurl-db");- continue;- }+ if (page == null) {+ registerFailure(entry.urlHash(), "url does not exist in lurl-db");+ continue;+ }- ResultEntry resultEntry = obtainResultEntry(page, (snippetComputationAllTime < 300) ? 1 : 0);- if (resultEntry == null) continue; // the entry had some problems, cannot be used- urlRetrievalAllTime += resultEntry.dbRetrievalTime;- snippetComputationAllTime += resultEntry.snippetComputationTime;+ resultEntry = obtainResultEntry(page, (snippetComputationAllTime < 300) ? 1 : 0);+ if (resultEntry == null) continue; // the entry had some problems, cannot be used+ urlRetrievalAllTime += resultEntry.dbRetrievalTime;+ snippetComputationAllTime += resultEntry.snippetComputationTime;- // place the result to the result vector- synchronized (resultList) {- resultList.add(resultEntry);- }+ // place the result to the result vector+ synchronized (resultList) {+ resultList.add(resultEntry);+ }- // add references- synchronized (rankedCache) {- rankedCache.addReferences(resultEntry);+ // add references+ synchronized (rankedCache) {+ rankedCache.addReferences(resultEntry);+ }}}process.yield("offline snippet fetch", resultList.size());@@ -248,7 +246,6 @@ public final class plasmaSearchEvent {lastEvents.put(query.id(), this);lastEventID = query.id();}-private class localSearchProcess extends Thread {@@ -296,10 +293,8 @@ public final class plasmaSearchEvent {// sort the local containers and truncate it to a limited count,// so following sortings together with the global results will be fast- plasmaSearchPreOrder firstsort = new plasmaSearchPreOrder(query, process, ranking, rcLocal);- rcLocal = firstsort.strippedContainer(200);synchronized (rankedCache) {- rankedCache.insert(rcLocal, true, true);+ rankedCache.insert(rcLocal, true);}}}@@ -473,6 +468,7 @@ public final class plasmaSearchEvent {public yacySearch[] getPrimarySearchThreads() {return primarySearchThreads;}+public yacySearch[] getSecondarySearchThreads() {return secondarySearchThreads;}@@ -580,7 +576,7 @@ public final class plasmaSearchEvent {try {Thread.sleep(100);} catch (InterruptedException e) {}continue;} else {- // we will not see that there core more results in+ // we will not see that there come more results inbreak;}}@@ -613,14 +609,14 @@ public final class plasmaSearchEvent {private indexRWIEntry nextOrder() {synchronized (rankedCache) {- indexContainer c = rankedCache.container();- kelondroRow.Entry entry;+ Iterator i = rankedCache.entries();+ indexRWIEntry entry;String urlhash;- for (int i = 0; i < c.size(); i++) {- entry = c.get(i);- urlhash = new String(entry.getColBytes(0));+ while (i.hasNext()) {+ entry = (indexRWIEntry) i.next();+ urlhash = entry.urlHash();if ((anyFailureWith(urlhash)) || (anyWorkerWith(urlhash)) || (anyResultWith(urlhash))) continue;- return new indexRWIEntry(entry);+ return entry;}}return null; // no more entries availablediff --git a/source/de/anomic/plasma/plasmaSearchPreOrder.java b/source/de/anomic/plasma/plasmaSearchPreOrder.javadeleted file mode 100644index 1ccb91eeb..000000000--- a/source/de/anomic/plasma/plasmaSearchPreOrder.java+++ /dev/null@@ -1,256 +0,0 @@-// plasmaSearchPreOrder.java-// ------------------------// part of YACY-// (C) by Michael Peter Christen; [email protected]-// first published on http://www.anomic.de-// Frankfurt, Germany, 2005-// Created: 23.10.2005-//-// This program is free software; you can redistribute it and/or modify-// it under the terms of the GNU General Public License as published by-// the Free Software Foundation; either version 2 of the License, or-// (at your option) any later version.-//-// This program is distributed in the hope that it will be useful,-// but WITHOUT ANY WARRANTY; without even the implied warranty of-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-// GNU General Public License for more details.-//-// You should have received a copy of the GNU General Public License-// along with this program; if not, write to the Free Software-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA-//-// Using this software in any meaning (reading, learning, copying, compiling,-// running) means that you agree that the Author(s) is (are) not responsible-// for cost, loss of data or any harm that may be caused directly or indirectly-// by usage of this softare or this documentation. The usage of this software-// is on your own risk. The installation and usage (starting/running) of this-// software may allow other people or application to access your computer and-// any attached devices and is highly dependent on the configuration of the-// software which must be done by the user of the software; the author(s) is-// (are) also not responsible for proper configuration and usage of the-// software, even if provoked by documentation provided together with-// the software.-//-// Any changes to this file according to the GPL as documented in the file-// gpl.txt aside this file in the shipment you received can be done to the-// lines that follows this copyright notice here, but changes must not be-// done inside the copyright notive above. A re-distribution must contain-// the intact and unchanged copyright notice.-// Contributions and changes to the program code must be marked as such.---package de.anomic.plasma;--import java.io.File;-import java.io.IOException;-import java.util.HashSet;-import java.util.Iterator;-import java.util.Map;-import java.util.TreeMap;-import java.util.TreeSet;--import de.anomic.index.indexContainer;-import de.anomic.index.indexRWIEntry;-import de.anomic.kelondro.kelondroBinSearch;-import de.anomic.server.serverCodings;-import de.anomic.server.serverFileUtils;-import de.anomic.yacy.yacyURL;--public final class plasmaSearchPreOrder {-- public static kelondroBinSearch[] ybrTables = null; // block-rank tables- private static boolean useYBR = true;-- private indexRWIEntry entryMin, entryMax;- private TreeMap pageAcc; // key = order hash; value = plasmaLURL.entry- private plasmaSearchQuery query;- private plasmaSearchRankingProfile ranking;- private int filteredCount;-- public plasmaSearchPreOrder() {- this.entryMin = null;- this.entryMax = null;- this.pageAcc = new TreeMap();- this.query = null;- this.ranking = null;- }-- public plasmaSearchPreOrder(plasmaSearchQuery query, plasmaSearchProcessing process, plasmaSearchRankingProfile ranking, indexContainer container) {- // we collect the urlhashes and construct a list with urlEntry objects- // attention: if minEntries is too high, this method will not terminate within the maxTime-- this.query = query;- this.ranking = ranking;-- assert (container != null);-- process.startTimer();-- // first pass: find min/max to obtain limits for normalization- Iterator i = container.entries();- int count = 0;- this.entryMin = null;- this.entryMax = null;- indexRWIEntry iEntry;- while (i.hasNext()) {- iEntry = (indexRWIEntry) i.next();- if (this.entryMin == null) this.entryMin = (indexRWIEntry) iEntry.clone(); else this.entryMin.min(iEntry);- if (this.entryMax == null) this.entryMax = (indexRWIEntry) iEntry.clone(); else this.entryMax.max(iEntry);- count++;- }-- // second pass: normalize entries and get ranking- i = container.entries();- this.pageAcc = new TreeMap();- TreeSet searchWords = plasmaSearchQuery.cleanQuery(query.queryString)[0];- for (int j = 0; j < count; j++) {- iEntry = (indexRWIEntry) i.next();- 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 constraint- if (query.contentdom != plasmaSearchQuery.CONTENTDOM_TEXT) {- if ((query.contentdom == plasmaSearchQuery.CONTENTDOM_AUDIO) && (!(iEntry.flags().get(plasmaCondenser.flag_cat_hasaudio)))) continue;- if ((query.contentdom == plasmaSearchQuery.CONTENTDOM_VIDEO) && (!(iEntry.flags().get(plasmaCondenser.flag_cat_hasvideo)))) continue;- if ((query.contentdom == plasmaSearchQuery.CONTENTDOM_IMAGE) && (!(iEntry.flags().get(plasmaCondenser.flag_cat_hasimage)))) continue;- if ((query.contentdom == plasmaSearchQuery.CONTENTDOM_APP ) && (!(iEntry.flags().get(plasmaCondenser.flag_cat_hasapp )))) continue;- }- pageAcc.put(serverCodings.encodeHex(Long.MAX_VALUE - this.ranking.preRanking(iEntry, this.entryMin, this.entryMax, searchWords), 16) + iEntry.urlHash(), iEntry);- }- this.filteredCount = pageAcc.size();-- if (container.size() > query.neededResults()) remove(true, true);-- process.yield(plasmaSearchProcessing.PRESORT, container.size());- }-- public int filteredCount() {- return this.filteredCount;- }-- private void remove(boolean rootDomExt, boolean doubleDom) {- // this removes all refererences to urls that are extended paths of existing 'RootDom'-urls- if (pageAcc.size() <= query.neededResults()) return;- HashSet rootDoms = new HashSet();- HashSet doubleDoms = new HashSet();- Iterator i = pageAcc.entrySet().iterator();- Map.Entry entry;- indexRWIEntry iEntry;- String hashpart;- boolean isWordRootURL;- TreeSet querywords = plasmaSearchQuery.cleanQuery(query.queryString())[0];- while (i.hasNext()) {- if (pageAcc.size() <= query.neededResults()) break;- entry = (Map.Entry) i.next();- iEntry = (indexRWIEntry) entry.getValue();- hashpart = iEntry.urlHash().substring(6);- isWordRootURL = yacyURL.isWordRootURL(iEntry.urlHash(), querywords);- if (isWordRootURL) {- rootDoms.add(hashpart);- } else {- if (((rootDomExt) && (rootDoms.contains(hashpart))) ||- ((doubleDom) && (doubleDoms.contains(hashpart)))) {- i.remove();- }- }- doubleDoms.add(hashpart);- }- }-- public static void loadYBR(File rankingPath, int count) {- // load ranking tables- if (rankingPath.exists()) {- ybrTables = new kelondroBinSearch[count];- String ybrName;- File f;- try {- for (int i = 0; i < count; i++) {- ybrName = "YBR-4-" + serverCodings.encodeHex(i, 2) + ".idx";- f = new File(rankingPath, ybrName);- if (f.exists()) {- ybrTables[i] = new kelondroBinSearch(serverFileUtils.read(f), 6);- } else {- ybrTables[i] = null;- }- }- } catch (IOException e) {- ybrTables = null;- }- } else {- ybrTables = null;- }- }-- public static boolean canUseYBR() {- return ybrTables != null;- }-- public static boolean isUsingYBR() {- return useYBR;- }-- public static void switchYBR(boolean usage) {- useYBR = usage;- }-- public plasmaSearchPreOrder cloneSmart() {- // clones only the top structure- plasmaSearchPreOrder theClone = new plasmaSearchPreOrder();- theClone.query = this.query;- theClone.ranking = this.ranking;- theClone.pageAcc = (TreeMap) this.pageAcc.clone();- return theClone;- }-- private boolean hasNext() {- return pageAcc.size() > 0;- }-- private Object[] /*{indexEntry, Long}*/ next() {- String top = (String) pageAcc.firstKey();- //System.out.println("preorder-key: " + top);- Long preranking;- try {- preranking = new Long(Long.MAX_VALUE - Long.parseLong(top.substring(0, 16), 16)); // java.lang.NumberFormatException: For input string: "8000000000020b17" ???- } catch (NumberFormatException e) {- e.printStackTrace();- preranking = new Long(0);- }- return new Object[]{(indexRWIEntry) pageAcc.remove(top), preranking};- }-- public indexContainer strippedContainer(int count) {- // return an indexContainer with a limited number of results- indexContainer container = plasmaWordIndex.emptyContainer(null, count);- Object[] o;- indexRWIEntry entry;- while ((count-- > 0) && (hasNext())) {- o = next();- entry = (indexRWIEntry) o[0];- container.addUnique(entry.toKelondroEntry());- }- return container;- }-- public indexRWIEntry[] getNormalizer() {- return new indexRWIEntry[] {entryMin, entryMax};- }-- public static int ybr_p(String urlHash) {- return 16 * (16 - ybr(urlHash));- }-- public static int ybr(String urlHash) {- if (ybrTables == null) return 16;- if (!(useYBR)) return 16;- final String domHash = urlHash.substring(6);- for (int i = 0; i < ybrTables.length; i++) {- if ((ybrTables[i] != null) && (ybrTables[i].contains(domHash.getBytes()))) {- //System.out.println("YBR FOUND: " + urlHash + " (" + i + ")");- return i;- }- }- //System.out.println("NOT FOUND: " + urlHash);- return 16;- }--}diff --git a/source/de/anomic/plasma/plasmaSearchProcessing.java b/source/de/anomic/plasma/plasmaSearchProcessing.javaindex 38e753744..8f417bc38 100644--- a/source/de/anomic/plasma/plasmaSearchProcessing.java+++ b/source/de/anomic/plasma/plasmaSearchProcessing.java@@ -135,7 +135,6 @@ public class plasmaSearchProcessing implements Cloneable {return yield.size();}- // collectionpublic Map[] localSearchContainers(plasmaSearchQuery query,plasmaWordIndex wordIndex,@@ -160,7 +159,6 @@ public class plasmaSearchProcessing implements Cloneable {return new Map[]{inclusionContainers, exclusionContainers};}- // joinpublic indexContainer localSearchJoinExclude(Collection includeContainers,Collection excludeContainers,diff --git a/source/de/anomic/plasma/plasmaSearchRankingProcess.java b/source/de/anomic/plasma/plasmaSearchRankingProcess.javanew file mode 100644index 000000000..4c36908b1--- /dev/null+++ b/source/de/anomic/plasma/plasmaSearchRankingProcess.java@@ -0,0 +1,294 @@+// plasmaSearchRankingProcess.java+// (C) 2007 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany+// first published 07.11.2007 on http://yacy.net+//+// This is a part of YaCy, a peer-to-peer based web search engine+//+// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $+// $LastChangedRevision: 1986 $+// $LastChangedBy: orbiter $+//+// LICENSE+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++package de.anomic.plasma;++import java.io.File;+import java.io.IOException;+import java.util.HashMap;+import java.util.HashSet;+import java.util.Iterator;+import java.util.Map;+import java.util.Set;+import java.util.TreeMap;+import java.util.TreeSet;++import de.anomic.htmlFilter.htmlFilterContentScraper;+import de.anomic.index.indexContainer;+import de.anomic.index.indexRWIEntry;+import de.anomic.index.indexRWIEntryOrder;+import de.anomic.kelondro.kelondroBinSearch;+import de.anomic.kelondro.kelondroMScoreCluster;+import de.anomic.server.serverCodings;+import de.anomic.server.serverFileUtils;+import de.anomic.yacy.yacyURL;++public final class plasmaSearchRankingProcess {++ public static kelondroBinSearch[] ybrTables = null; // block-rank tables+ private static boolean useYBR = true;++ private TreeMap pageAcc; // key = ranking (Long); value = indexRWIEntry+ private plasmaSearchQuery query;+ private plasmaSearchRankingProfile ranking;+ private int filteredCount;+ private indexRWIEntryOrder order;+ private plasmaSearchProcessing process;+ private int maxentries;+ private int globalcount;+ private HashMap urlhashes; // map for double-check; String/Long relation, addresses ranking number (backreference for deletion)+ private kelondroMScoreCluster ref; // reference score computation for the commonSense heuristic++ public plasmaSearchRankingProcess(plasmaSearchQuery query, plasmaSearchProcessing process, plasmaSearchRankingProfile ranking, int maxentries) {+ // we collect the urlhashes and construct a list with urlEntry objects+ // attention: if minEntries is too high, this method will not terminate within the maxTime+ this.pageAcc = new TreeMap();+ this.process = process;+ this.order = null;+ this.query = query;+ this.ranking = ranking;+ this.maxentries = maxentries;+ this.globalcount = 0;+ this.urlhashes = new HashMap();+ this.ref = new kelondroMScoreCluster();+ }++ public void insert(indexContainer container, boolean local) {+ // we collect the urlhashes and construct a list with urlEntry objects+ // attention: if minEntries is too high, this method will not terminate within the maxTime++ assert (container != null);++ process.startTimer();+ if (this.order == null) {+ this.order = new indexRWIEntryOrder(ranking);+ }+ this.order.extend(container);+ process.yield("normalizing", container.size());++ /*+ container.setOrdering(o, 0);+ container.sort();+ */++ // normalize entries and get ranking+ process.startTimer();+ Iterator i = container.entries();+ this.pageAcc = new TreeMap();+ indexRWIEntry iEntry, l;+ long biggestEntry = 0;+ //long s0 = System.currentTimeMillis();+ Long r;+ while (i.hasNext()) {+ iEntry = (indexRWIEntry) i.next();+ if (iEntry.urlHash().length() != container.row().primaryKeyLength) continue;++ r = new Long(order.cardinal(iEntry));+ if ((pageAcc.size() >= maxentries) && (r.longValue() > biggestEntry)) continue;++ // check constraints+ if ((!(query.constraint.equals(plasmaSearchQuery.catchall_constraint))) && (!(iEntry.flags().allOf(query.constraint)))) continue; // filter out entries that do not match the search constraint+ if (query.contentdom != plasmaSearchQuery.CONTENTDOM_TEXT) {+ if ((query.contentdom == plasmaSearchQuery.CONTENTDOM_AUDIO) && (!(iEntry.flags().get(plasmaCondenser.flag_cat_hasaudio)))) continue;+ if ((query.contentdom == plasmaSearchQuery.CONTENTDOM_VIDEO) && (!(iEntry.flags().get(plasmaCondenser.flag_cat_hasvideo)))) continue;+ if ((query.contentdom == plasmaSearchQuery.CONTENTDOM_IMAGE) && (!(iEntry.flags().get(plasmaCondenser.flag_cat_hasimage)))) continue;+ if ((query.contentdom == plasmaSearchQuery.CONTENTDOM_APP ) && (!(iEntry.flags().get(plasmaCondenser.flag_cat_hasapp )))) continue;+ }+ if (pageAcc.size() < maxentries) {+ if (urlhashes.containsKey(iEntry.urlHash())) continue;+ while (pageAcc.containsKey(r)) r = new Long(r.longValue() + 1);+ pageAcc.put(r, iEntry);+ } else {+ if (r.longValue() > biggestEntry) {+ continue;+ } else {+ if (urlhashes.containsKey(iEntry.urlHash())) continue;+ l = (indexRWIEntry) pageAcc.remove((Long) pageAcc.lastKey());+ urlhashes.remove(l.urlHash());+ while (pageAcc.containsKey(r)) r = new Long(r.longValue() + 1);+ pageAcc.put(r, iEntry);+ biggestEntry = order.cardinal((indexRWIEntry) pageAcc.get(pageAcc.lastKey()));+ }+ }+ urlhashes.put(iEntry.urlHash(), r);++ // increase counter for statistics+ if (!local) this.globalcount++;+ }+ this.filteredCount = pageAcc.size();+ //long sc = Math.max(1, System.currentTimeMillis() - s0);+ //System.out.println("###DEBUG### time to sort " + container.size() + " entries to " + this.filteredCount + ": " + sc + " milliseconds, " + (container.size() / sc) + " entries/millisecond, ranking = " + tc);++ if (container.size() > query.neededResults()) remove(true, true);++ process.yield(plasmaSearchProcessing.PRESORT, container.size());+ }++ public int size() {+ assert pageAcc.size() == urlhashes.size();+ return pageAcc.size();+ }++ public int filteredCount() {+ return this.filteredCount;+ }++ public int getGlobalCount() {+ return this.globalcount;+ }++ public indexRWIEntry remove(String urlHash) {+ Long r = (Long) urlhashes.get(urlHash);+ if (r == null) return null;+ assert pageAcc.containsKey(r);+ indexRWIEntry iEntry = (indexRWIEntry) pageAcc.remove(r);+ urlhashes.remove(urlHash);+ return iEntry;+ }++ public Iterator entries() {+ // returns an iterator of indexRWIEntry objects in the ranked order, best entry first+ return this.pageAcc.values().iterator();+ }++ public Set getReferences(int count) {+ // create a list of words that had been computed by statistics over all+ // words that appeared in the url or the description of all urls+ Object[] refs = ref.getScores(count, false, 2, Integer.MAX_VALUE);+ TreeSet s = new TreeSet(String.CASE_INSENSITIVE_ORDER);+ for (int i = 0; i < refs.length; i++) {+ s.add((String) refs[i]);+ }+ return s;+ }++ public void addReferences(String[] words) {+ String word;+ for (int i = 0; i < words.length; i++) {+ word = words[i].toLowerCase();+ if ((word.length() > 2) &&+ ("http_html_php_ftp_www_com_org_net_gov_edu_index_home_page_for_usage_the_and_".indexOf(word) < 0) &&+ (!(query.queryHashes.contains(plasmaCondenser.word2hash(word)))))+ ref.incScore(word);+ }+ }++ protected void addReferences(plasmaSearchEvent.ResultEntry resultEntry) {+ // take out relevant information for reference computation+ if ((resultEntry.url() == null) || (resultEntry.title() == null)) return;+ String[] urlcomps = htmlFilterContentScraper.urlComps(resultEntry.url().toNormalform(true, true)); // word components of the url+ String[] descrcomps = resultEntry.title().toLowerCase().split(htmlFilterContentScraper.splitrex); // words in the description++ // add references+ addReferences(urlcomps);+ addReferences(descrcomps);+ }++ public indexRWIEntryOrder getOrder() {+ return this.order;+ }++ private void remove(boolean rootDomExt, boolean doubleDom) {+ // this removes all refererences to urls that are extended paths of existing 'RootDom'-urls+ if (pageAcc.size() <= query.neededResults()) return;+ HashSet rootDoms = new HashSet();+ HashSet doubleDoms = new HashSet();+ Iterator i = pageAcc.entrySet().iterator();+ Map.Entry entry;+ indexRWIEntry iEntry;+ String hashpart;+ boolean isWordRootURL;+ TreeSet querywords = plasmaSearchQuery.cleanQuery(query.queryString())[0];+ while (i.hasNext()) {+ if (pageAcc.size() <= query.neededResults()) break;+ entry = (Map.Entry) i.next();+ iEntry = (indexRWIEntry) entry.getValue();+ hashpart = iEntry.urlHash().substring(6);+ isWordRootURL = yacyURL.isWordRootURL(iEntry.urlHash(), querywords);+ if (isWordRootURL) {+ rootDoms.add(hashpart);+ } else {+ if (((rootDomExt) && (rootDoms.contains(hashpart))) ||+ ((doubleDom) && (doubleDoms.contains(hashpart)))) {+ i.remove();+ }+ }+ doubleDoms.add(hashpart);+ }+ }++ public static void loadYBR(File rankingPath, int count) {+ // load ranking tables+ if (rankingPath.exists()) {+ ybrTables = new kelondroBinSearch[count];+ String ybrName;+ File f;+ try {+ for (int i = 0; i < count; i++) {+ ybrName = "YBR-4-" + serverCodings.encodeHex(i, 2) + ".idx";+ f = new File(rankingPath, ybrName);+ if (f.exists()) {+ ybrTables[i] = new kelondroBinSearch(serverFileUtils.read(f), 6);+ } else {+ ybrTables[i] = null;+ }+ }+ } catch (IOException e) {+ ybrTables = null;+ }+ } else {+ ybrTables = null;+ }+ }++ public static boolean canUseYBR() {+ return ybrTables != null;+ }++ public static boolean isUsingYBR() {+ return useYBR;+ }++ public static void switchYBR(boolean usage) {+ useYBR = usage;+ }++ public static int ybr(String urlHash) {+ // returns the YBR value in a range of 0..15, where 0 means best ranking and 15 means worst ranking+ if (ybrTables == null) return 15;+ if (!(useYBR)) return 15;+ final String domHash = urlHash.substring(6);+ for (int i = 0; i < ybrTables.length; i++) {+ if ((ybrTables[i] != null) && (ybrTables[i].contains(domHash.getBytes()))) {+ //System.out.println("YBR FOUND: " + urlHash + " (" + i + ")");+ return i;+ }+ }+ //System.out.println("NOT FOUND: " + urlHash);+ return 15;+ }++}diff --git a/source/de/anomic/plasma/plasmaSearchRankingProfile.java b/source/de/anomic/plasma/plasmaSearchRankingProfile.javaindex 89ef1abdd..277a2d34a 100644--- a/source/de/anomic/plasma/plasmaSearchRankingProfile.java+++ b/source/de/anomic/plasma/plasmaSearchRankingProfile.java@@ -45,12 +45,8 @@ import java.util.HashMap;import java.util.Iterator;import java.util.Map;import java.util.Set;-import java.util.TreeSet;import de.anomic.htmlFilter.htmlFilterContentScraper;-import de.anomic.index.indexRWIEntry;-import de.anomic.yacy.yacyURL;-import de.anomic.kelondro.kelondroBitfield;public class plasmaSearchRankingProfile {@@ -86,7 +82,7 @@ public class plasmaSearchRankingProfile {public static final String DESCRCOMPINTOPLIST = "descrcompintoplist";public static final String PREFER = "prefer";- private int+ public intcoeff_domlength, coeff_ybr, coeff_date, coeff_wordsintitle, coeff_wordsintext, coeff_phrasesintext,coeff_llocal, coeff_lother, coeff_urllength, coeff_urlcomps, coeff_hitcount,coeff_posintext, coeff_posofphrase, coeff_posinphrase, coeff_worddistance,@@ -249,44 +245,6 @@ public class plasmaSearchRankingProfile {return new String(ext);}- public long preRanking(indexRWIEntry t, indexRWIEntry min, indexRWIEntry max, TreeSet searchedWords) {- // the normalizedEntry must be a normalized indexEntry- long ranking = 0;- ranking += (256 - yacyURL.domLengthNormalized(t.urlHash())) << coeff_domlength;- ranking += plasmaSearchPreOrder.ybr_p(t.urlHash()) << coeff_ybr;- ranking += (255 - (255 * (t.virtualAge() - min.virtualAge() ) / (1 + max.virtualAge() - min.virtualAge())) ) << coeff_date;- ranking += (255 * (t.wordsintitle() - min.wordsintitle() ) / (1 + max.wordsintitle() - min.wordsintitle())) << coeff_wordsintitle;- ranking += (255 * (t.wordsintext() - min.wordsintext() ) / (1 + max.wordsintext() - min.wordsintext())) << coeff_wordsintext;- ranking += (255 * (t.phrasesintext()- min.phrasesintext()) / (1 + max.phrasesintext()- min.phrasesintext())) << coeff_phrasesintext;- ranking += t.llocal() << coeff_llocal;- ranking += t.lother() << coeff_lother;- ranking += (255 - (255 * (t.urllength() - min.urllength() ) / (1 + max.urllength() - min.urllength())) ) << coeff_urllength;- ranking += (255 - (255 * (t.urlcomps() - min.urlcomps() ) / (1 + max.urlcomps() - min.urlcomps())) ) << coeff_urlcomps;- ranking += (255 * (t.hitcount() - min.hitcount() ) / (1 + max.hitcount() - min.hitcount())) << coeff_hitcount;- ranking += (255 - (255 * (t.posintext() - min.posintext() ) / (1 + max.posintext() - min.posintext())) ) << coeff_posintext;- ranking += (255 - (255 * (t.posofphrase() - min.posofphrase() ) / (1 + max.posofphrase() - min.posofphrase())) ) << coeff_posofphrase;- ranking += (255 - (255 * (t.posinphrase() - min.posinphrase() ) / (1 + max.posinphrase() - min.posinphrase())) ) << coeff_posinphrase;- ranking += (255 - (255 * (t.worddistance() - min.worddistance() ) / (1 + max.worddistance() - min.worddistance()))) << coeff_worddistance;-- kelondroBitfield flags = t.flags();- ranking += (flags.get(indexRWIEntry.flag_app_url)) ? 256 << coeff_appurl : 0;- ranking += (flags.get(indexRWIEntry.flag_app_descr)) ? 256 << coeff_appdescr : 0;- ranking += (flags.get(indexRWIEntry.flag_app_author)) ? 256 << coeff_appauthor : 0;- ranking += (flags.get(indexRWIEntry.flag_app_tags)) ? 256 << coeff_apptags : 0;- ranking += (flags.get(indexRWIEntry.flag_app_reference)) ? 256 << coeff_appref : 0;- ranking += (flags.get(indexRWIEntry.flag_app_emphasized)) ? 256 << coeff_appemph : 0;- ranking += (flags.get(plasmaCondenser.flag_cat_indexof)) ? 256 << coeff_catindexof : 0;- ranking += (flags.get(plasmaCondenser.flag_cat_hasimage)) ? 256 << coeff_cathasimage : 0;- ranking += (flags.get(plasmaCondenser.flag_cat_hasaudio)) ? 256 << coeff_cathasaudio : 0;- ranking += (flags.get(plasmaCondenser.flag_cat_hasvideo)) ? 256 << coeff_cathasvideo : 0;- ranking += (flags.get(plasmaCondenser.flag_cat_hasapp)) ? 256 << coeff_cathasapp : 0;-- ranking += (yacyURL.probablyRootURL(t.urlHash())) ? 16 << coeff_urllength : 0;- if (searchedWords != null) ranking += (yacyURL.probablyWordURL(t.urlHash(), searchedWords) != null) ? 256 << coeff_appurl : 0;-- return ranking;- }-public long postRanking(plasmaSearchQuery query,Set topwords,diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.javaindex 838705cb4..a34282c02 100644--- a/source/de/anomic/plasma/plasmaSwitchboard.java+++ b/source/de/anomic/plasma/plasmaSwitchboard.java@@ -143,6 +143,7 @@ import de.anomic.http.httpd;import de.anomic.http.httpdRobotsTxtConfig;import de.anomic.index.indexContainer;import de.anomic.index.indexRWIEntry;+import de.anomic.index.indexRWIRowEntry;import de.anomic.index.indexURLEntry;import de.anomic.kelondro.kelondroBitfield;import de.anomic.kelondro.kelondroCache;@@ -167,6 +168,7 @@ import de.anomic.server.serverSemaphore;import de.anomic.server.serverSwitch;import de.anomic.server.serverThread;import de.anomic.server.logging.serverLog;+import de.anomic.tools.crypt;import de.anomic.yacy.yacyURL;import de.anomic.yacy.yacyVersion;import de.anomic.yacy.yacyClient;@@ -1046,7 +1048,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser// load ranking tablesFile YBRPath = new File(rootPath, "ranking/YBR");if (YBRPath.exists()) {- plasmaSearchPreOrder.loadYBR(YBRPath, 15);+ plasmaSearchRankingProcess.loadYBR(YBRPath, 15);}// read memory amount@@ -1502,6 +1504,14 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serreturn null;}+ public plasmaSearchRankingProfile getRanking() {+ return (getConfig("rankingProfile", "").length() == 0) ?+ new plasmaSearchRankingProfile(plasmaSearchQuery.CONTENTDOM_TEXT) :+ new plasmaSearchRankingProfile("", crypt.simpleDecode(sb.getConfig("rankingProfile", ""), null));+ }+++/*** This method changes the HTCache size.<br>* @param newCacheSize in MB@@ -2344,7 +2354,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serString word = (String) wentry.getKey();wordStat = (plasmaCondenser.wordStatProp) wentry.getValue();String wordHash = plasmaCondenser.word2hash(word);- indexRWIEntry wordIdxEntry = new indexRWIEntry(+ indexRWIEntry wordIdxEntry = new indexRWIRowEntry(urlHash,urlLength, urlComps,wordStat.count,diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.javaindex e17c28812..7ac04862c 100644--- a/source/de/anomic/plasma/plasmaWordIndex.java+++ b/source/de/anomic/plasma/plasmaWordIndex.java@@ -43,6 +43,7 @@ import de.anomic.index.indexContainerOrder;import de.anomic.index.indexRAMRI;import de.anomic.index.indexRI;import de.anomic.index.indexRWIEntry;+import de.anomic.index.indexRWIRowEntry;import de.anomic.index.indexURLEntry;import de.anomic.kelondro.kelondroBase64Order;import de.anomic.kelondro.kelondroCloneableIterator;@@ -74,13 +75,13 @@ public final class plasmaWordIndex implements indexRI {public plasmaWordIndex(File indexPrimaryRoot, File indexSecondaryRoot, long preloadTime, serverLog log) {File textindexcache = new File(indexPrimaryRoot, "PUBLIC/TEXT/RICACHE");if (!(textindexcache.exists())) textindexcache.mkdirs();- this.dhtOutCache = new indexRAMRI(textindexcache, indexRWIEntry.urlEntryRow, wCacheMaxChunk, wCacheMaxAge, "dump1.array", log);- this.dhtInCache = new indexRAMRI(textindexcache, indexRWIEntry.urlEntryRow, wCacheMaxChunk, wCacheMaxAge, "dump2.array", log);+ this.dhtOutCache = new indexRAMRI(textindexcache, indexRWIRowEntry.urlEntryRow, wCacheMaxChunk, wCacheMaxAge, "dump1.array", log);+ this.dhtInCache = new indexRAMRI(textindexcache, indexRWIRowEntry.urlEntryRow, wCacheMaxChunk, wCacheMaxAge, "dump2.array", log);// create collections storage pathFile textindexcollections = new File(indexPrimaryRoot, "PUBLIC/TEXT/RICOLLECTION");if (!(textindexcollections.exists())) textindexcollections.mkdirs();- this.collections = new indexCollectionRI(textindexcollections, "collection", preloadTime, maxCollectionPartition, indexRWIEntry.urlEntryRow);+ this.collections = new indexCollectionRI(textindexcollections, "collection", preloadTime, maxCollectionPartition, indexRWIRowEntry.urlEntryRow);// create LURL-dbloadedURL = new plasmaCrawlLURL(indexSecondaryRoot, preloadTime);@@ -129,7 +130,7 @@ public final class plasmaWordIndex implements indexRI {public long dhtCacheSizeBytes(boolean in) {// calculate the real size in bytes of DHT-In/Out-Cachelong cacheBytes = 0;- long entryBytes = indexRWIEntry.urlEntryRow.objectsize();+ long entryBytes = indexRWIRowEntry.urlEntryRow.objectsize;indexRAMRI cache = (in ? dhtInCache : dhtOutCache);synchronized (cache) {Iterator it = cache.wordContainers(null, false);@@ -171,7 +172,7 @@ public final class plasmaWordIndex implements indexRI {}public static indexContainer emptyContainer(String wordHash, int elementCount) {- return new indexContainer(wordHash, indexRWIEntry.urlEntryRow, elementCount);+ return new indexContainer(wordHash, indexRWIRowEntry.urlEntryRow, elementCount);}public void addEntry(String wordHash, indexRWIEntry entry, long updateTime, boolean dhtInCase) {@@ -189,7 +190,7 @@ public final class plasmaWordIndex implements indexRI {}public void addEntries(indexContainer entries, long updateTime, boolean dhtInCase) {- assert (entries.row().objectsize() == indexRWIEntry.urlEntryRow.objectsize());+ assert (entries.row().objectsize == indexRWIRowEntry.urlEntryRow.objectsize);// set dhtInCase depending on wordHashif ((!dhtInCase) && (yacyDHTAction.shallBeOwnWord(entries.getWordHash()))) dhtInCase = true;@@ -298,7 +299,7 @@ public final class plasmaWordIndex implements indexRI {word = (String) wentry.getKey();wprop = (plasmaCondenser.wordStatProp) wentry.getValue();assert (wprop.flags != null);- ientry = new indexRWIEntry(url.hash(),+ ientry = new indexRWIRowEntry(url.hash(),urlLength, urlComps, (document == null) ? urlLength : document.getTitle().length(),wprop.count,condenser.words().size(),@@ -406,7 +407,7 @@ public final class plasmaWordIndex implements indexRI {public indexContainer deleteContainer(String wordHash) {indexContainer c = new indexContainer(wordHash,- indexRWIEntry.urlEntryRow,+ indexRWIRowEntry.urlEntryRow,dhtInCache.sizeContainer(wordHash) + dhtOutCache.sizeContainer(wordHash) + collections.indexSize(wordHash));synchronized (dhtInCache) {diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.javaindex 1ee0814cf..babbea9b0 100644--- a/source/de/anomic/yacy/yacyClient.java+++ b/source/de/anomic/yacy/yacyClient.java@@ -59,7 +59,7 @@ import de.anomic.index.indexURLEntry;import de.anomic.kelondro.kelondroBase64Order;import de.anomic.kelondro.kelondroBitfield;import de.anomic.plasma.plasmaCondenser;-import de.anomic.plasma.plasmaSearchContainer;+import de.anomic.plasma.plasmaSearchRankingProcess;import de.anomic.plasma.plasmaSearchProcessing;import de.anomic.plasma.plasmaSearchRankingProfile;import de.anomic.plasma.plasmaSnippetCache;@@ -345,7 +345,7 @@ public final class yacyClient {int partitions,yacySeed target,plasmaWordIndex wordIndex,- plasmaSearchContainer containerCache,+ plasmaSearchRankingProcess containerCache,Map abstractCache,plasmaURLPattern blacklist,plasmaSearchRankingProfile rankingProfile,@@ -516,7 +516,7 @@ public final class yacyClient {// store remote result to local result containersynchronized (containerCache) {// insert one container into the search result buffer- containerCache.insert(container[0], false, false); // one is enough+ containerCache.insert(container[0], false); // one is enough// integrate remote topwordsString references = (String) result.get("references");diff --git a/source/de/anomic/yacy/yacySearch.java b/source/de/anomic/yacy/yacySearch.javaindex fe3e1db38..b7a45b574 100644--- a/source/de/anomic/yacy/yacySearch.java+++ b/source/de/anomic/yacy/yacySearch.java@@ -52,7 +52,7 @@ import java.util.TreeMap;import de.anomic.kelondro.kelondroBitfield;import de.anomic.kelondro.kelondroMScoreCluster;-import de.anomic.plasma.plasmaSearchContainer;+import de.anomic.plasma.plasmaSearchRankingProcess;import de.anomic.plasma.plasmaSearchQuery;import de.anomic.plasma.plasmaSearchRankingProfile;import de.anomic.plasma.plasmaWordIndex;@@ -65,7 +65,7 @@ public class yacySearch extends Thread {final private boolean global;final private int partitions;final private plasmaWordIndex wordIndex;- final private plasmaSearchContainer containerCache;+ final private plasmaSearchRankingProcess containerCache;final private Map abstractCache;final private plasmaURLPattern blacklist;final private yacySeed targetPeer;@@ -77,7 +77,7 @@ public class yacySearch extends Thread {public yacySearch(String wordhashes, String excludehashes, String urlhashes, String prefer, String filter, int count, int maxDistance,boolean global, int partitions, yacySeed targetPeer, plasmaWordIndex wordIndex,- plasmaSearchContainer containerCache, Map abstractCache,+ plasmaSearchRankingProcess containerCache, Map abstractCache,plasmaURLPattern blacklist,plasmaSearchRankingProfile rankingProfile,kelondroBitfield constraint) {@@ -247,7 +247,7 @@ public class yacySearch extends Thread {String wordhashes, String excludehashes, String urlhashes,String prefer, String filter, int count, int maxDist,plasmaWordIndex wordIndex,- plasmaSearchContainer containerCache, Map abstractCache,+ plasmaSearchRankingProcess containerCache, Map abstractCache,int targets, plasmaURLPattern blacklist,plasmaSearchRankingProfile rankingProfile,kelondroBitfield constraint, TreeMap clusterselection) {@@ -271,7 +271,7 @@ public class yacySearch extends Thread {public static yacySearch secondaryRemoteSearch(String wordhashes, String excludehashes, String urlhashes,plasmaWordIndex wordIndex,- plasmaSearchContainer containerCache,+ plasmaSearchRankingProcess containerCache,String targethash, plasmaURLPattern blacklist,plasmaSearchRankingProfile rankingProfile,kelondroBitfield constraint, TreeMap clusterselection) {diff --git a/source/de/anomic/yacy/yacyURL.java b/source/de/anomic/yacy/yacyURL.javaindex e8581b008..1aab2683f 100644--- a/source/de/anomic/yacy/yacyURL.java+++ b/source/de/anomic/yacy/yacyURL.java@@ -1052,7 +1052,7 @@ public class yacyURL {}public static int domLengthNormalized(String urlHash) {- return 255 * domLengthEstimation(urlHash) / 30;+ return domLengthEstimation(urlHash) << 8 / 20;}public static final int domDomain(String urlHash) {