Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

refactoring of index management: url storage is part of index management; moved plasmaURL to indexURL

orbiter90d569d70fc2
diff --git a/htroot/CacheAdmin_p.java b/htroot/CacheAdmin_p.java
index 7434a343a..77db799d4 100644
--- a/htroot/CacheAdmin_p.java
+++ b/htroot/CacheAdmin_p.java
@@ -55,10 +55,10 @@ import java.util.TreeSet;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterOutputStream;
import de.anomic.http.httpHeader;
+import de.anomic.index.indexURL;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.plasma.plasmaURL;
import de.anomic.server.serverCore;
import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
@@ -102,7 +102,7 @@ public class CacheAdmin_p {
info.ensureCapacity(40000);
try {
- final httpHeader fileheader = switchboard.cacheManager.getCachedResponse(plasmaURL.urlHash(url));
+ final httpHeader fileheader = switchboard.cacheManager.getCachedResponse(indexURL.urlHash(url));
info.append("<b>HTTP Header:</b><br>").append(formatHeader(fileheader)).append("<br>");
final String ff = file.toString();
final int dotpos = ff.lastIndexOf('.');
diff --git a/htroot/IndexControl_p.java b/htroot/IndexControl_p.java
index c140706df..076986017 100644
--- a/htroot/IndexControl_p.java
+++ b/htroot/IndexControl_p.java
@@ -58,9 +58,9 @@ import java.util.TreeMap;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.http.httpHeader;
import de.anomic.index.indexEntryAttribute;
+import de.anomic.index.indexURL;
import de.anomic.plasma.plasmaCrawlLURL;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.plasma.plasmaURL;
import de.anomic.plasma.plasmaWordIndex;
import de.anomic.plasma.plasmaWordIndexEntryInstance;
import de.anomic.plasma.plasmaWordIndexEntryContainer;
@@ -305,7 +305,7 @@ public class IndexControl_p {
if (post.containsKey("urlstringsearch")) {
try {
URL url = new URL(urlstring);
- urlhash = plasmaURL.urlHash(url);
+ urlhash = indexURL.urlHash(url);
prop.put("urlhash", urlhash);
plasmaCrawlLURL.Entry entry = switchboard.urlPool.loadedURL.getEntry(urlhash, null);
prop.put("result", genUrlProfile(switchboard, entry, urlhash));
diff --git a/htroot/IndexCreate_p.java b/htroot/IndexCreate_p.java
index 5a4928ded..c56761207 100644
--- a/htroot/IndexCreate_p.java
+++ b/htroot/IndexCreate_p.java
@@ -58,9 +58,9 @@ import de.anomic.data.wikiCode;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterOutputStream;
import de.anomic.http.httpHeader;
+import de.anomic.index.indexURL;
import de.anomic.plasma.plasmaCrawlProfile;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.plasma.plasmaURL;
import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -159,7 +159,7 @@ public class IndexCreate_p {
} else try {
// stack request
// first delete old entry, if exists
- String urlhash = plasmaURL.urlHash(crawlingStart);
+ String urlhash = indexURL.urlHash(crawlingStart);
switchboard.urlPool.loadedURL.remove(urlhash);
switchboard.urlPool.noticeURL.remove(urlhash);
switchboard.urlPool.errorURL.remove(urlhash);
@@ -196,7 +196,7 @@ public class IndexCreate_p {
prop.put("error_reasonString", reasonString);
switchboard.urlPool.errorURL.newEntry(crawlingStartURL, null, yacyCore.seedDB.mySeed.hash, yacyCore.seedDB.mySeed.hash,
- crawlingStartURL.getHost(), reasonString, new bitfield(plasmaURL.urlFlagLength), false);
+ crawlingStartURL.getHost(), reasonString, new bitfield(indexURL.urlFlagLength), false);
}
} catch (Exception e) {
// mist
@@ -260,7 +260,7 @@ public class IndexCreate_p {
c++;
} else {
switchboard.urlPool.errorURL.newEntry(nexturlURL, null, yacyCore.seedDB.mySeed.hash, yacyCore.seedDB.mySeed.hash,
- (String) e.getValue(), rejectReason, new bitfield(plasmaURL.urlFlagLength), false);
+ (String) e.getValue(), rejectReason, new bitfield(indexURL.urlFlagLength), false);
}
}
@@ -482,8 +482,8 @@ public class IndexCreate_p {
//table += "Sorry, cannot show any crawl output now because the system is not completely initialised. Please re-try.";
prop.put("error", 3);
} else {
- Enumeration crawlavail = yacyCore.dhtAgent.getAcceptRemoteCrawlSeeds(plasmaURL.dummyHash, true);
- Enumeration crawlpendi = yacyCore.dhtAgent.getAcceptRemoteCrawlSeeds(plasmaURL.dummyHash, false);
+ Enumeration crawlavail = yacyCore.dhtAgent.getAcceptRemoteCrawlSeeds(indexURL.dummyHash, true);
+ Enumeration crawlpendi = yacyCore.dhtAgent.getAcceptRemoteCrawlSeeds(indexURL.dummyHash, false);
if ((!(crawlavail.hasMoreElements())) && (!(crawlpendi.hasMoreElements()))) {
prop.put("remoteCrawlPeers", 0); //no peers availible
} else {
diff --git a/htroot/PerformanceMemory_p.java b/htroot/PerformanceMemory_p.java
index 5c19c9d63..65b896e18 100644
--- a/htroot/PerformanceMemory_p.java
+++ b/htroot/PerformanceMemory_p.java
@@ -48,8 +48,8 @@ import java.util.Map;
import java.io.File;
import de.anomic.http.httpHeader;
+import de.anomic.index.indexURL;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.plasma.plasmaURL;
import de.anomic.server.serverMemory;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -278,13 +278,13 @@ public class PerformanceMemory_p {
// other caching structures
long amount = sb.urlPool.errorURL.existsIndexSize();
prop.put("eurl.existsIndexAmount",Long.toString(amount));
- prop.put("eurl.existsIndexSize",serverMemory.bytesToString(amount*(2*plasmaURL.urlHashLength+28)));
+ prop.put("eurl.existsIndexSize",serverMemory.bytesToString(amount*(2*indexURL.urlHashLength+28)));
amount = sb.urlPool.noticeURL.existsIndexSize();
prop.put("nurl.existsIndexAmount",Long.toString(amount));
- prop.put("nurl.existsIndexSize",serverMemory.bytesToString(amount*(2*plasmaURL.urlHashLength+28)));
+ prop.put("nurl.existsIndexSize",serverMemory.bytesToString(amount*(2*indexURL.urlHashLength+28)));
amount = sb.urlPool.loadedURL.existsIndexSize();
prop.put("lurl.existsIndexAmount",Long.toString(amount));
- prop.put("lurl.existsIndexSize",serverMemory.bytesToString(amount*(2*plasmaURL.urlHashLength+28)));
+ prop.put("lurl.existsIndexSize",serverMemory.bytesToString(amount*(2*indexURL.urlHashLength+28)));
// return rewrite values for templates
return prop;
diff --git a/htroot/QuickCrawlLink_p.java b/htroot/QuickCrawlLink_p.java
index caaad4e85..0cf825359 100644
--- a/htroot/QuickCrawlLink_p.java
+++ b/htroot/QuickCrawlLink_p.java
@@ -56,9 +56,9 @@ import java.util.Date;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.http.httpHeader;
+import de.anomic.index.indexURL;
import de.anomic.plasma.plasmaCrawlProfile;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.plasma.plasmaURL;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.yacy.yacyCore;
@@ -149,7 +149,7 @@ public class QuickCrawlLink_p {
return prop;
}
- String urlhash = plasmaURL.urlHash(crawlingStart);
+ String urlhash = indexURL.urlHash(crawlingStart);
switchboard.urlPool.loadedURL.remove(urlhash);
switchboard.urlPool.noticeURL.remove(urlhash);
switchboard.urlPool.errorURL.remove(urlhash);
diff --git a/htroot/htdocsdefault/dir.java b/htroot/htdocsdefault/dir.java
index 06a41607e..53c50c924 100644
--- a/htroot/htdocsdefault/dir.java
+++ b/htroot/htdocsdefault/dir.java
@@ -59,11 +59,11 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import de.anomic.http.httpHeader;
import de.anomic.index.indexEntryAttribute;
+import de.anomic.index.indexURL;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.plasma.plasmaCondenser;
import de.anomic.plasma.plasmaCrawlLURL;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.plasma.plasmaURL;
import de.anomic.server.serverCodings;
import de.anomic.server.serverCore;
import de.anomic.server.serverFileUtils;
@@ -482,7 +482,7 @@ public class dir {
public static void deletePhrase(plasmaSwitchboard switchboard, String urlstring, String phrase, String descr) {
try {
- final String urlhash = plasmaURL.urlHash(new URL(urlstring));
+ final String urlhash = indexURL.urlHash(new URL(urlstring));
final Iterator words = plasmaCondenser.getWords(("yacyshare " + phrase + " " + descr).getBytes("UTF-8"));
Map.Entry entry;
while (words.hasNext()) {
diff --git a/htroot/xml/bookmarks/posts/delete_p.java b/htroot/xml/bookmarks/posts/delete_p.java
index 99945a1e9..2d9fdea76 100644
--- a/htroot/xml/bookmarks/posts/delete_p.java
+++ b/htroot/xml/bookmarks/posts/delete_p.java
@@ -43,8 +43,8 @@
package xml.bookmarks.posts;
import de.anomic.http.httpHeader;
+import de.anomic.index.indexURL;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.plasma.plasmaURL;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -54,7 +54,7 @@ public class delete_p {
plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
serverObjects prop = new serverObjects();
if(post!= null){
- if( post.containsKey("url") && switchboard.bookmarksDB.removeBookmark(plasmaURL.urlHash(post.get("url", "nourl"))) ){
+ if( post.containsKey("url") && switchboard.bookmarksDB.removeBookmark(indexURL.urlHash(post.get("url", "nourl"))) ){
prop.put("result", 1);
}else if(post.containsKey("urlhash") && switchboard.bookmarksDB.removeBookmark(post.get("urlhash", "nohash"))){
prop.put("result", 1);
diff --git a/htroot/xml/snippet.java b/htroot/xml/snippet.java
index 941bb5684..87e4e4184 100644
--- a/htroot/xml/snippet.java
+++ b/htroot/xml/snippet.java
@@ -6,11 +6,11 @@ import java.util.Set;
import java.util.TreeSet;
import de.anomic.http.httpHeader;
+import de.anomic.index.indexURL;
import de.anomic.kelondro.kelondroMSetTools;
import de.anomic.plasma.plasmaSearchQuery;
import de.anomic.plasma.plasmaSnippetCache;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.plasma.plasmaURL;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -46,7 +46,7 @@ public class snippet {
} else {
prop.put("text", snippet.getError());
}
- prop.put("urlHash",plasmaURL.urlHash(url));
+ prop.put("urlHash",indexURL.urlHash(url));
// return rewrite properties
diff --git a/htroot/yacy/crawlOrder.java b/htroot/yacy/crawlOrder.java
index 49d90130a..7cad3b892 100644
--- a/htroot/yacy/crawlOrder.java
+++ b/htroot/yacy/crawlOrder.java
@@ -50,9 +50,9 @@ import java.util.ArrayList;
import java.util.Date;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.http.httpHeader;
+import de.anomic.index.indexURL;
import de.anomic.plasma.plasmaCrawlLURL;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.plasma.plasmaURL;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.tools.crypt;
@@ -245,7 +245,7 @@ public final class crawlOrder {
reason = reasonString;
// send lurl-Entry as response
try {
- plasmaCrawlLURL.Entry entry = switchboard.urlPool.loadedURL.getEntry(plasmaURL.urlHash(url), null);
+ plasmaCrawlLURL.Entry entry = switchboard.urlPool.loadedURL.getEntry(indexURL.urlHash(url), null);
response = "double";
switchboard.urlPool.loadedURL.notifyGCrawl(entry.hash(), iam, youare);
lurl = crypt.simpleEncode(entry.toString());
diff --git a/htroot/yacy/crawlReceipt.java b/htroot/yacy/crawlReceipt.java
index 2f982ef46..218fcb6b3 100644
--- a/htroot/yacy/crawlReceipt.java
+++ b/htroot/yacy/crawlReceipt.java
@@ -49,10 +49,10 @@
import java.io.IOException;
import de.anomic.http.httpHeader;
+import de.anomic.index.indexURL;
import de.anomic.plasma.plasmaCrawlNURL;
import de.anomic.plasma.plasmaCrawlLURL;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.plasma.plasmaURL;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.server.logging.serverLog;
@@ -133,8 +133,8 @@ public final class crawlReceipt {
switchboard.urlPool.loadedURL.stackEntry(entry, youare, iam, 1);
// generating url hash
- String newUrlHash = plasmaURL.urlHash(entry.url());
- String oldUrlHash = plasmaURL.oldurlHash(entry.url());
+ String newUrlHash = indexURL.urlHash(entry.url());
+ String oldUrlHash = indexURL.oldurlHash(entry.url());
// removing URL from notice URL
switchboard.urlPool.noticeURL.remove(newUrlHash);
@@ -148,7 +148,7 @@ public final class crawlReceipt {
} else {
try {
plasmaCrawlNURL.Entry en = switchboard.urlPool.noticeURL.getEntry(receivedUrlhash);
- switchboard.urlPool.errorURL.newEntry(en.url(), en.referrerHash(), en.initiator(), iam, en.name(), result + ":" + reason, new bitfield(plasmaURL.urlFlagLength), false);
+ switchboard.urlPool.errorURL.newEntry(en.url(), en.referrerHash(), en.initiator(), iam, en.name(), result + ":" + reason, new bitfield(indexURL.urlFlagLength), false);
switchboard.urlPool.noticeURL.remove(receivedUrlhash);
} catch (IOException e) {
diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.java
index b7d6334ee..9a76513e6 100644
--- a/source/de/anomic/data/bookmarksDB.java
+++ b/source/de/anomic/data/bookmarksDB.java
@@ -70,10 +70,10 @@ import org.xml.sax.SAXException;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterOutputStream;
import de.anomic.index.indexEntryAttribute;
+import de.anomic.index.indexURL;
import de.anomic.kelondro.kelondroDyn;
import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroMap;
-import de.anomic.plasma.plasmaURL;
import de.anomic.server.serverFileUtils;
import de.anomic.server.logging.serverLog;
@@ -740,7 +740,7 @@ public class bookmarksDB {
if(!url.toLowerCase().startsWith("http://")){
url="http://"+url;
}
- this.urlHash=plasmaURL.urlHash(url);
+ this.urlHash=indexURL.urlHash(url);
mem=new HashMap();
mem.put(BOOKMARK_URL, url);
this.timestamp=System.currentTimeMillis();
diff --git a/source/de/anomic/http/httpdProxyHandler.java b/source/de/anomic/http/httpdProxyHandler.java
index d54aad270..b4aa58a28 100644
--- a/source/de/anomic/http/httpdProxyHandler.java
+++ b/source/de/anomic/http/httpdProxyHandler.java
@@ -92,10 +92,10 @@ import java.util.zip.GZIPOutputStream;
import de.anomic.htmlFilter.htmlFilterContentTransformer;
import de.anomic.htmlFilter.htmlFilterOutputStream;
import de.anomic.htmlFilter.htmlFilterTransformer;
+import de.anomic.index.indexURL;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.plasma.plasmaURL;
import de.anomic.server.serverCore;
import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
@@ -410,7 +410,7 @@ public final class httpdProxyHandler extends httpdAbstractHandler implements htt
// decide wether to use a cache entry or connect to the network
File cacheFile = cacheManager.getCachePath(url);
- String urlHash = plasmaURL.urlHash(url);
+ String urlHash = indexURL.urlHash(url);
httpHeader cachedResponseHeader = cacheManager.getCachedResponse(urlHash);
boolean cacheExists = ((cacheFile.isFile()) && (cachedResponseHeader != null));
diff --git a/source/de/anomic/index/indexEntryPrototype.java b/source/de/anomic/index/indexEntryPrototype.java
index 89b51917d..1c0d98687 100644
--- a/source/de/anomic/index/indexEntryPrototype.java
+++ b/source/de/anomic/index/indexEntryPrototype.java
@@ -26,7 +26,7 @@
package de.anomic.index;
-import de.anomic.plasma.plasmaURL;
+//import de.anomic.plasma.plasmaURL;
import de.anomic.plasma.plasmaWordIndex;
public abstract class indexEntryPrototype implements indexEntry {
@@ -142,7 +142,7 @@ public abstract class indexEntryPrototype implements indexEntry {
}
public int domlengthNormalized() {
- return 255 * plasmaURL.domLengthEstimation(this.urlHash) / 30;
+ return 255 * indexURL.domLengthEstimation(this.urlHash) / 30;
}
public static void main(String[] args) {
diff --git a/source/de/anomic/index/indexURL.java b/source/de/anomic/index/indexURL.java
new file mode 100644
index 000000000..0048c0ddf
--- /dev/null
+++ b/source/de/anomic/index/indexURL.java
@@ -0,0 +1,540 @@
+package de.anomic.index;
+
+import java.io.IOException;
+import java.lang.Boolean;
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.text.SimpleDateFormat;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import de.anomic.htmlFilter.htmlFilterContentScraper;
+import de.anomic.kelondro.kelondroBase64Order;
+import de.anomic.kelondro.kelondroTree;
+import de.anomic.server.serverCodings;
+import de.anomic.yacy.yacySeedDB;
+
+public class indexURL {
+
+ // day formatter for entry export
+ protected static final SimpleDateFormat shortDayFormatter = new SimpleDateFormat("yyyyMMdd");
+
+ // statics for value lengths
+ public static final int urlHashLength = yacySeedDB.commonHashLength; // 12
+ public static final int urlStringLength = 256;// not too short for links without parameters
+ public static final int urlDescrLength = 80; // The headline of a web page (meta-tag or <h1>)
+ public static final int urlNameLength = 40; // the tag content between <a> and </a>
+ public static final int urlErrorLength = 20; // a reason description for unavailable urls
+ public static final int urlDateLength = 4; // any date, shortened
+ public static final int urlCopyCountLength = 2; // counter for numbers of copies of this index
+ public static final int urlFlagLength = 2; // any stuff
+ public static final int urlQualityLength = 3; // taken from heuristic
+ public static final int urlLanguageLength = 2; // taken from TLD suffix as quick-hack
+ public static final int urlDoctypeLength = 1; // taken from extension
+ public static final int urlSizeLength = 6; // the source size, from cache
+ public static final int urlWordCountLength = 3; // the number of words, from condenser
+ public static final int urlCrawlProfileHandleLength = 4; // name of the prefetch profile
+ public static final int urlCrawlDepthLength = 2; // prefetch depth, first is '0'
+ public static final int urlParentBranchesLength = 3; // number of anchors of the parent
+ public static final int urlForkFactorLength = 4; // sum of anchors of all ancestors
+ public static final int urlRetryLength = 2; // number of load retries
+ public static final int urlHostLength = 8; // the host as struncated name
+ public static final int urlHandleLength = 4; // a handle
+
+ private static final String[] TLD_NorthAmericaOceania={
+ // primary english-speaking countries
+ // english-speaking countries from central america are also included
+ // includes also dutch and french colonies in the caribbean sea
+ "EDU=US Educational",
+ "GOV=US Government",
+ "MIL=US Military",
+ "NET=Network",
+ "ORG=Non-Profit Organization",
+ "AG=Antigua and Barbuda",
+ "AI=Anguilla",
+ "AU=Australia",
+ "BB=Barbados",
+ "BZ=Belize",
+ "BM=Bermuda",
+ "BS=Bahamas",
+ "CA=Canada",
+ "DM=Dominica",
+ "GD=Grenada",
+ "GP=Guadeloupe",
+ "KY=Cayman Islands",
+ "NZ=New Zealand (Aotearoa)",
+ "PM=St. Pierre and Miquelon",
+ "US=United States",
+ "VC=Saint Vincent and the Grenadines",
+ "VG=Virgin Islands (British)",
+ "VI=Virgin Islands (U.S.)",
+ "VU=Vanuatu",
+ "WF=Wallis and Futuna Islands",
+ "WS=Samoa"
+ };
+ private static final String[] TLD_MiddleSouthAmerica = {
+ // primary spanish and portugese-speaking
+ "AR=Argentina",
+ "AW=Aruba",
+ "BR=Brazil",
+ "BO=Bolivia",
+ "CL=Chile",
+ "CO=Colombia",
+ "CR=Costa Rica",
+ "CU=Cuba",
+ "DO=Dominican Republic",
+ "EC=Ecuador",
+ "GF=French Guiana",
+ "FK=Falkland Islands (Malvinas)",
+ "GY=Guyana",
+ "HN=Honduras",
+ "JM=Jamaica",
+ "MX=Mexico",
+ "NI=Nicaragua",
+ "PA=Panama",
+ "PE=Peru",
+ "PY=Paraguay",
+ "SR=Suriname",
+ "SV=El Salvador",
+ "UY=Uruguay",
+ "VE=Venezuela"
+ };
+ private static final String[] TLD_EuropaRussia = {
+ // includes also countries that are mainly french- dutch- speaking
+ // and culturally close to europe
+ "AD=Andorra",
+ "AL=Albania",
+ "AT=Austria",
+ "BA=Bosnia and Herzegovina",
+ "BE=Belgium",
+ "BG=Bulgaria",
+ "CH=Switzerland",
+ "CS=Czechoslovakia (former)",
+ "CZ=Czech Republic",
+ "CY=Cyprus",
+ "DE=Germany",
+ "DK=Denmark",
+ "ES=Spain",
+ "EE=Estonia",
+ "FI=Finland",
+ "FR=France",
+ "FX=France, Metropolitan",
+ "GB=Great Britain (UK)",
+ "GI=Gibraltar",
+ "GL=Greenland",
+ "GR=Greece",
+ "HR=Croatia (Hrvatska)",
+ "HU=Hungary",
+ "IE=Ireland",
+ "IS=Iceland",
+ "IT=Italy",
+ "LI=Liechtenstein",
+ "LT=Lithuania",
+ "LU=Luxembourg",
+ "LV=Latvia",
+ "MD=Moldova",
+ "MC=Monaco",
+ "MK=Macedonia",
+ "MN=Mongolia",
+ "MT=Malta",
+ "NATO=Nato field",
+ "NL=Netherlands",
+ "NO=Norway",
+ "PL=Poland",
+ "PT=Portugal",
+ "RO=Romania",
+ "RU=Russia",
+ "SE=Sweden",
+ "SI=Slovenia",
+ "SK=Slovak Republic",
+ "SU=USSR (former)",
+ "UK=United Kingdom",
+ "VA=Vatican City State (Holy See)",
+ "YU=Yugoslavia"
+ };
+ private static final String[] TLD_MiddleEastWestAsia = {
+ "AE=United Arab Emirates",
+ "AF=Afghanistan",
+ "AZ=Azerbaijan",
+ "BH=Bahrain",
+ "IL=Israel",
+ "IQ=Iraq",
+ "IR=Iran",
+ "PK=Pakistan",
+ "YE=Yemen"
+ };
+ private static final String[] TLD_SouthEastAsia = {
+ "BD=Bangladesh",
+ "BT=Bhutan",
+ "CN=China",
+ "HK=Hong Kong",
+ "ID=Indonesia",
+ "IN=India",
+ "NP=Nepal",
+ "JP=Japan",
+ "KH=Cambodia",
+ "KP=Korea (North)",
+ "KR=Korea (South)",
+ "LK=Sri Lanka",
+ "SG=Singapore",
+ "VN=Viet Nam"
+ };
+ private static final String[] TLD_Africa = {
+ "AO=Angola",
+ "BF=Burkina Faso",
+ "BI=Burundi",
+ "BJ=Benin",
+ "BW=Botswana",
+ "CF=Central African Republic",
+ "CG=Congo",
+ "CI=Cote D'Ivoire (Ivory Coast)",
+ "CM=Cameroon",
+ "DZ=Algeria",
+ "EG=Egypt",
+ "EH=Western Sahara",
+ "ER=Eritrea",
+ "ET=Ethiopia",
+ "GA=Gabon",
+ "GH=Ghana",
+ "GM=Gambia",
+ "GN=Guinea",
+ "KE=Kenya",
+ "LR=Liberia",
+ "LS=Lesotho",
+ "LY=Libya",
+ "MA=Morocco",
+ "MG=Madagascar",
+ "ML=Mali",
+ "MR=Mauritania",
+ "MU=Mauritius",
+ "MW=Malawi",
+ "MZ=Mozambique",
+ "NA=Namibia",
+ "NE=Niger",
+ "NG=Nigeria",
+ "RE=Reunion",
+ "RW=Rwanda",
+ "SH=St. Helena",
+ "SL=Sierra Leone",
+ "SN=Senegal",
+ "SO=Somalia",
+ "ST=Sao Tome and Principe",
+ "SZ=Swaziland",
+ "TG=Togo",
+ "TN=Tunisia",
+ "TZ=Tanzania",
+ "UG=Uganda",
+ "ZA=South Africa",
+ "ZM=Zambia",
+ "ZR=Zaire",
+ "ZW=Zimbabwe",
+ "YT=Mayotte"
+ };
+ private static final String[] TLD_Generic = {
+ "COM=US Commercial",
+ "AERO=",
+ "BIZ=",
+ "COOP=",
+ "INFO=",
+ "MUSEUM=",
+ "NAME=",
+ "PRO=",
+ "ARPA=",
+ "INT=International",
+ "ARPA=Arpanet"
+ };
+ private static final String[] TLD_Unassigned = {
+ "AQ=Antarctica",
+ "NT=Neutral Zone"
+ };
+
+ /*
+ http://www.odci.gov/cia/publications/factbook/
+ http://en.wikipedia.org/wiki/List_of_countries_by_continent
+ "AM=Armenia",
+ "AN=Netherlands Antilles",
+ "AS=American Samoa",
+ "BN=Brunei Darussalam",
+ "BV=Bouvet Island",
+ "BY=Belarus",
+ "CC=Cocos (Keeling) Islands",
+ "CK=Cook Islands",
+ "CV=Cape Verde",
+ "CX=Christmas Island",
+ "DJ=Djibouti",
+ "FJ=Fiji",
+ "FM=Micronesia",
+ "FO=Faroe Islands",
+ "GE=Georgia",
+ "GQ=Equatorial Guinea",
+ "GS=S. Georgia and S. Sandwich Isls.",
+ "GT=Guatemala",
+ "GU=Guam",
+ "GW=Guinea-Bissau",
+ "HM=Heard and McDonald Islands",
+ "HT=Haiti",
+ "IO=British Indian Ocean Territory",
+ "JO=Jordan",
+ "KG=Kyrgyzstan",
+ "KI=Kiribati",
+ "KM=Comoros",
+ "KN=Saint Kitts and Nevis",
+ "KW=Kuwait",
+ "KZ=Kazakhstan",
+ "LA=Laos",
+ "LB=Lebanon",
+ "LC=Saint Lucia",
+ "MH=Marshall Islands",
+ "MM=Myanmar",
+ "MO=Macau",
+ "MP=Northern Mariana Islands",
+ "MQ=Martinique",
+ "MS=Montserrat",
+ "MV=Maldives",
+ "MY=Malaysia",
+ "NC=New Caledonia",
+ "NF=Norfolk Island",
+ "NR=Nauru",
+ "NU=Niue",
+ "OM=Oman",
+ "PF=French Polynesia",
+ "PG=Papua New Guinea",
+ "PH=Philippines",
+ "PN=Pitcairn",
+ "PR=Puerto Rico",
+ "PW=Palau",
+ "QA=Qatar",
+ "SA=Saudi Arabia",
+ "Sb=Solomon Islands",
+ "SC=Seychelles",
+ "SD=Sudan",
+ "SJ=Svalbard and Jan Mayen Islands",
+ "SM=San Marino",
+ "SY=Syria",
+ "TC=Turks and Caicos Islands",
+ "TD=Chad",
+ "TF=French Southern Territories",
+ "TH=Thailand",
+ "TJ=Tajikistan",
+ "TK=Tokelau",
+ "TM=Turkmenistan",
+ "TO=Tonga",
+ "TP=East Timor",
+ "TR=Turkey",
+ "TT=Trinidad and Tobago",
+ "TV=Tuvalu",
+ "TW=Taiwan",
+ "UA=Ukraine",
+ "UM=US Minor Outlying Islands",
+ "UZ=Uzbekistan",
+ */
+
+ /* TLDs:
+ aero, biz, com, coop, edu, gov, info, int, mil, museum, name, net, org, pro, arpa
+ AC, AD, AE, AERO, AF, AG, AI, AL, AM, AN, AO, AQ, AR, ARPA, AS, AT, AU, AW, AZ,
+ BA, BB, BD, BE, BF, BG, BH, BI, BIZ, BJ, BM, BN, BO, BR, BS, BT, BV, BW, BY, BZ,
+ CA, CC, CD, CF, CG, CH, CI, CK, CL, CM, CN, CO, COM, COOP, CR, CU, CV, CX, CY, CZ,
+ DE, DJ, DK, DM, DO, DZ, EC, EDU, EE, EG, ER, ES, ET, EU, FI, FJ, FK, FM, FO, FR,
+ GA, GB, GD, GE, GF, GG, GH, GI, GL, GM, GN, GOV, GP, GQ, GR, GS, GT, GU, GW, GY,
+ HK, HM, HN, HR, HT, HU, ID, IE, IL, IM, IN, INFO, INT, IO, IQ, IR, IS, IT,
+ JE, JM, JO, JOBS, JP, KE, KG, KH, KI, KM, KN, KR, KW, KY, KZ,
+ LA, LB, LC, LI, LK, LR, LS, LT, LU, LV, LY,
+ MA, MC, MD, MG, MH, MIL, MK, ML, MM, MN, MO, MOBI, MP, MQ, MR, MS, MT, MU, MUSEUM, MV, MW, MX, MY, MZ,
+ NA, NAME, NC, NE, NET, NF, NG, NI, NL, NO, NP, NR, NU, NZ, OM, ORG,
+ PA, PE, PF, PG, PH, PK, PL, PM, PN, PR, PRO, PS, PT, PW, PY, QA, RE, RO, RU, RW,
+ SA, SB, SC, SD, SE, SG, SH, SI, SJ, SK, SL, SM, SN, SO, SR, ST, SU, SV, SY, SZ,
+ TC, TD, TF, TG, TH, TJ, TK, TL, TM, TN, TO, TP, TR, TRAVEL, TT, TV, TW, TZ,
+ UA, UG, UK, UM, US, UY, UZ, VA, VC, VE, VG, VI, VN, VU, WF, WS, YE, YT, YU, ZA, ZM, ZW
+ */
+
+ public static String dummyHash;
+ private static HashMap TLDID = new HashMap();
+ private static HashMap TLDName = new HashMap();
+ private static void insertTLDProps(String[] TLDList, int id) {
+ int p;
+ String tld, name;
+ Integer ID = new Integer(id);
+ for (int i = 0; i < TLDList.length; i++) {
+ p = TLDList[i].indexOf('=');
+ if (p > 0) {
+ tld = TLDList[i].substring(0, p).toLowerCase();
+ name = TLDList[i].substring(p + 1);
+ TLDID.put(tld, ID);
+ TLDName.put(tld, name);
+ }
+ }
+ }
+ static {
+ // create a dummy hash
+ dummyHash = "";
+ for (int i = 0; i < urlHashLength; i++) dummyHash += "-";
+
+ // assign TLD-ids and names
+ insertTLDProps(TLD_EuropaRussia, 0);
+ insertTLDProps(TLD_MiddleSouthAmerica, 1);
+ insertTLDProps(TLD_SouthEastAsia, 2);
+ insertTLDProps(TLD_MiddleEastWestAsia, 3);
+ insertTLDProps(TLD_NorthAmericaOceania, 4);
+ insertTLDProps(TLD_Africa, 5);
+ insertTLDProps(TLD_Generic, 6);
+ insertTLDProps(TLD_Unassigned, 7);
+ }
+
+
+ // the class object
+ public kelondroTree urlHashCache;
+ public final HashMap existsIndex; // allow subclasses to access the existsIndex during Entry.store()
+
+ public indexURL() {
+ urlHashCache = null;
+ existsIndex = new HashMap();
+ }
+
+ public int size() {
+ return urlHashCache.size();
+ }
+
+ public void close() throws IOException {
+ if (urlHashCache != null) urlHashCache.close();
+ }
+
+ public boolean exists(String urlHash) {
+ synchronized (existsIndex) {
+ Boolean existsInIndex = (Boolean) existsIndex.get(urlHash);
+ if (existsInIndex != null) return existsInIndex.booleanValue();
+ try {
+ if (urlHashCache.get(urlHash.getBytes()) != null) {
+ existsIndex.put(urlHash, Boolean.TRUE);
+ return true;
+ } else {
+ existsIndex.put(urlHash, Boolean.FALSE);
+ return false;
+ }
+ } catch (IOException e) {
+ return false;
+ }
+ }
+ }
+
+ public long existsIndexSize() {
+ return this.existsIndex.size();
+ }
+
+ public boolean remove(String urlHash) {
+ synchronized (existsIndex) {
+ try {
+ Boolean existsInIndex = (Boolean) existsIndex.remove(urlHash);
+ if (existsInIndex == null) existsInIndex = Boolean.FALSE;
+ boolean existsInCache = (this.urlHashCache.remove(urlHash.getBytes()) != null);
+ existsIndex.put(urlHash, Boolean.FALSE);
+ return existsInIndex.booleanValue() || existsInCache;
+ } catch (IOException e) {
+ return false;
+ }
+ }
+ }
+
+ public void clearExistsIndex() {
+ synchronized (existsIndex) {
+ existsIndex.clear();
+ }
+ }
+
+ public static final int flagTypeID(String hash) {
+ return (kelondroBase64Order.enhancedCoder.decodeByte(hash.charAt(11)) & 32) >> 5;
+ }
+ public static final int flagTLDID(String hash) {
+ return (kelondroBase64Order.enhancedCoder.decodeByte(hash.charAt(11)) & 28) >> 2;
+ }
+ public static final int flagLengthID(String hash) {
+ return (kelondroBase64Order.enhancedCoder.decodeByte(hash.charAt(11)) & 3);
+ }
+
+ public static final String urlHash(String url) {
+ if ((url == null) || (url.length() == 0)) return null;
+ try {
+ return urlHash(new URL(url));
+ } catch (MalformedURLException e) {
+ return null;
+ }
+ }
+ public static final String urlHash(URL url) {
+ if (url == null) return null;
+ String host = url.getHost().toLowerCase();
+ int p = host.lastIndexOf('.');
+ String tld = "", dom = tld;
+ if (p > 0) {
+ tld = host.substring(p + 1);
+ dom = host.substring(0, p);
+ }
+ Integer ID = (Integer) TLDID.get(tld);
+ int id = (ID == null) ? 7 : ID.intValue();
+ boolean isHTTP = url.getProtocol().equals("http");
+ p = dom.lastIndexOf('.'); // locate subdomain
+ String subdom = "";
+ if (p > 0) {
+ subdom = dom.substring(0, p);
+ dom = dom.substring(p + 1);
+ }
+ int port = url.getPort();
+ if (port <= 0) {
+ if (isHTTP) {
+ port = 80;
+ } else if (url.getProtocol().equalsIgnoreCase("https")) {
+ port = 443;
+ } else {
+ port = 21;
+ }
+ }
+ String path = url.getPath();
+ if (path.startsWith("/")) path = path.substring(1);
+ if (path.endsWith("/")) path = path.substring(0, path.length() - 1);
+ p = path.indexOf('/');
+ String rootpath = "";
+ if (p > 0) {
+ rootpath = path.substring(0, p);
+ }
+ // we collected enough information to compute the fragments that are basis for hashes
+ int l = dom.length();
+ int domlengthKey = (l <= 8) ? 0 : (l <= 12) ? 1 : (l <= 16) ? 2 : 3;
+ byte flagbyte = (byte) (((isHTTP) ? 0 : 32) | (id << 2) | domlengthKey);
+ // form the 'local' part of the hash
+ String hash3 = kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(htmlFilterContentScraper.urlNormalform(url))).substring(0, 5);
+ char hash2 = kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(subdom + ":" + port + ":" + rootpath)).charAt(0);
+ // form the 'global' part of the hash
+ String hash1 = kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(url.getProtocol() + ":" + host + ":" + port)).substring(0, 5);
+ char hash0 = kelondroBase64Order.enhancedCoder.encodeByte(flagbyte);
+ // combine the hashes
+ return hash3 + hash2 + hash1 + hash0;
+ }
+
+ public static final int domLengthEstimation(String urlHash) {
+ // generates an estimation of the original domain length
+ int flagbyte = kelondroBase64Order.enhancedCoder.decodeByte(urlHash.charAt(11));
+ int domLengthKey = flagbyte & 3;
+ switch (domLengthKey) {
+ case 0: return 4;
+ case 1: return 10;
+ case 2: return 14;
+ case 3: return 20;
+ }
+ return 20;
+ }
+
+ public static final String oldurlHash(URL url) {
+ if (url == null) return null;
+ String hash = kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(htmlFilterContentScraper.urlNormalform(url))).substring(0, urlHashLength);
+ return hash;
+ }
+
+ public static final String oldurlHash(String url) {
+ if ((url == null) || (url.length() < 10)) return null;
+ String hash = kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(htmlFilterContentScraper.urlNormalform(null, url))).substring(0, urlHashLength);
+ return hash;
+ }
+
+ public Iterator urlHashes(String urlHash, boolean up) throws IOException {
+ return urlHashCache.keys(up, false, urlHash.getBytes());
+ }
+
+}
diff --git a/source/de/anomic/plasma/plasmaCrawlBalancer.java b/source/de/anomic/plasma/plasmaCrawlBalancer.java
index 1a707d54a..67c5465c2 100644
--- a/source/de/anomic/plasma/plasmaCrawlBalancer.java
+++ b/source/de/anomic/plasma/plasmaCrawlBalancer.java
@@ -48,6 +48,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.ArrayList;
+import de.anomic.index.indexURL;
import de.anomic.kelondro.kelondroRecords;
import de.anomic.kelondro.kelondroStack;
@@ -61,10 +62,10 @@ public class plasmaCrawlBalancer {
try {
stack = new kelondroStack(stackFile, buffersize);
} catch (IOException e) {
- stack = new kelondroStack(stackFile, buffersize, new int[] {plasmaURL.urlHashLength}, true);
+ stack = new kelondroStack(stackFile, buffersize, new int[] {indexURL.urlHashLength}, true);
}
} else {
- stack = new kelondroStack(stackFile, buffersize, new int[] {plasmaURL.urlHashLength}, true);
+ stack = new kelondroStack(stackFile, buffersize, new int[] {indexURL.urlHashLength}, true);
}
domainStacks = new HashMap();
}
diff --git a/source/de/anomic/plasma/plasmaCrawlEURL.java b/source/de/anomic/plasma/plasmaCrawlEURL.java
index 73f32a75e..d8a9e3436 100644
--- a/source/de/anomic/plasma/plasmaCrawlEURL.java
+++ b/source/de/anomic/plasma/plasmaCrawlEURL.java
@@ -53,11 +53,12 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.Iterator;
+import de.anomic.index.indexURL;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroTree;
import de.anomic.tools.bitfield;
-public class plasmaCrawlEURL extends plasmaURL {
+public class plasmaCrawlEURL extends indexURL {
private LinkedList rejectedStack = new LinkedList(); // strings: url
diff --git a/source/de/anomic/plasma/plasmaCrawlLURL.java b/source/de/anomic/plasma/plasmaCrawlLURL.java
index 3b55a34f2..3c31c9050 100644
--- a/source/de/anomic/plasma/plasmaCrawlLURL.java
+++ b/source/de/anomic/plasma/plasmaCrawlLURL.java
@@ -65,6 +65,7 @@ import java.util.Locale;
import java.util.Properties;
import de.anomic.http.httpc;
+import de.anomic.index.indexURL;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroTree;
import de.anomic.plasma.plasmaHTCache;
@@ -76,7 +77,7 @@ import de.anomic.tools.nxTools;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacySeed;
-public final class plasmaCrawlLURL extends plasmaURL {
+public final class plasmaCrawlLURL extends indexURL {
// result stacks;
// these have all entries of form
diff --git a/source/de/anomic/plasma/plasmaCrawlNURL.java b/source/de/anomic/plasma/plasmaCrawlNURL.java
index 9dfcce647..f4323d66e 100644
--- a/source/de/anomic/plasma/plasmaCrawlNURL.java
+++ b/source/de/anomic/plasma/plasmaCrawlNURL.java
@@ -52,6 +52,7 @@ import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
+import de.anomic.index.indexURL;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroRecords;
@@ -60,7 +61,7 @@ import de.anomic.kelondro.kelondroTree;
import de.anomic.server.logging.serverLog;
import de.anomic.tools.bitfield;
-public class plasmaCrawlNURL extends plasmaURL {
+public class plasmaCrawlNURL extends indexURL {
public static final int STACK_TYPE_NULL = 0; // do not stack
public static final int STACK_TYPE_CORE = 1; // put on local stack
@@ -126,23 +127,23 @@ public class plasmaCrawlNURL extends plasmaURL {
if (imageStackFile.exists()) try {
imageStack = new kelondroStack(imageStackFile, 0);
} catch (IOException e) {
- imageStack = new kelondroStack(imageStackFile, 0, new int[] {plasmaURL.urlHashLength}, true);
+ imageStack = new kelondroStack(imageStackFile, 0, new int[] {indexURL.urlHashLength}, true);
} else {
- imageStack = new kelondroStack(imageStackFile, 0, new int[] {plasmaURL.urlHashLength}, true);
+ imageStack = new kelondroStack(imageStackFile, 0, new int[] {indexURL.urlHashLength}, true);
}
if (movieStackFile.exists()) try {
movieStack = new kelondroStack(movieStackFile, 0);
} catch (IOException e) {
- movieStack = new kelondroStack(movieStackFile, 0, new int[] {plasmaURL.urlHashLength}, true);
+ movieStack = new kelondroStack(movieStackFile, 0, new int[] {indexURL.urlHashLength}, true);
} else {
- movieStack = new kelondroStack(movieStackFile, 0, new int[] {plasmaURL.urlHashLength}, true);
+ movieStack = new kelondroStack(movieStackFile, 0, new int[] {indexURL.urlHashLength}, true);
}
if (musicStackFile.exists()) try {
musicStack = new kelondroStack(musicStackFile, 0);
} catch (IOException e) {
- musicStack = new kelondroStack(musicStackFile, 0, new int[] {plasmaURL.urlHashLength}, true);
+ musicStack = new kelondroStack(musicStackFile, 0, new int[] {indexURL.urlHashLength}, true);
} else {
- musicStack = new kelondroStack(musicStackFile, 0, new int[] {plasmaURL.urlHashLength}, true);
+ musicStack = new kelondroStack(musicStackFile, 0, new int[] {indexURL.urlHashLength}, true);
}
// init stack Index
diff --git a/source/de/anomic/plasma/plasmaCrawlProfile.java b/source/de/anomic/plasma/plasmaCrawlProfile.java
index 4b226375f..74c33429a 100644
--- a/source/de/anomic/plasma/plasmaCrawlProfile.java
+++ b/source/de/anomic/plasma/plasmaCrawlProfile.java
@@ -48,6 +48,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
+import de.anomic.index.indexURL;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroDyn;
import de.anomic.kelondro.kelondroException;
@@ -68,10 +69,10 @@ public class plasmaCrawlProfile {
dyn = new kelondroDyn(file, bufferkb * 1024, '#');
} catch (IOException e) {
profileTableFile.delete();
- dyn = new kelondroDyn(file, bufferkb * 1024, plasmaURL.urlCrawlProfileHandleLength, 2000, '#', true);
+ dyn = new kelondroDyn(file, bufferkb * 1024, indexURL.urlCrawlProfileHandleLength, 2000, '#', true);
} else {
profileTableFile.getParentFile().mkdirs();
- dyn = new kelondroDyn(file, bufferkb * 1024, plasmaURL.urlCrawlProfileHandleLength, 2000, '#', true);
+ dyn = new kelondroDyn(file, bufferkb * 1024, indexURL.urlCrawlProfileHandleLength, 2000, '#', true);
}
profileTable = new kelondroMap(dyn);
domsCache = new HashMap();
@@ -94,7 +95,7 @@ public class plasmaCrawlProfile {
if (profileTable != null) try { profileTable.close(); } catch (IOException e) {}
if (!(profileTableFile.delete())) throw new RuntimeException("cannot delete crawl profile database");
profileTableFile.getParentFile().mkdirs();
- profileTable = new kelondroMap(new kelondroDyn(profileTableFile, bufferkb * 1024, plasmaURL.urlCrawlProfileHandleLength, 2000, '#', true));
+ profileTable = new kelondroMap(new kelondroDyn(profileTableFile, bufferkb * 1024, indexURL.urlCrawlProfileHandleLength, 2000, '#', true));
}
public void close() {
@@ -255,7 +256,7 @@ public class plasmaCrawlProfile {
boolean storeHTCache, boolean storeTXCache,
boolean localIndexing, boolean remoteIndexing,
boolean xsstopw, boolean xdstopw, boolean xpstopw) {
- String handle = kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(Long.toString(System.currentTimeMillis()))).substring(0, plasmaURL.urlCrawlProfileHandleLength);
+ String handle = kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(Long.toString(System.currentTimeMillis()))).substring(0, indexURL.urlCrawlProfileHandleLength);
mem = new HashMap();
mem.put("handle", handle);
mem.put("name", name);
diff --git a/source/de/anomic/plasma/plasmaCrawlStacker.java b/source/de/anomic/plasma/plasmaCrawlStacker.java
index 27cca74f1..e13518fd6 100644
--- a/source/de/anomic/plasma/plasmaCrawlStacker.java
+++ b/source/de/anomic/plasma/plasmaCrawlStacker.java
@@ -59,6 +59,7 @@ import org.apache.commons.pool.impl.GenericObjectPool;
import de.anomic.data.robotsParser;
import de.anomic.http.httpc;
+import de.anomic.index.indexURL;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroTree;
@@ -240,7 +241,7 @@ public final class plasmaCrawlStacker {
}
*/
URL nexturl = null, referrerURL = null;
- if ((initiatorHash == null) || (initiatorHash.length() == 0)) initiatorHash = plasmaURL.dummyHash;
+ if ((initiatorHash == null) || (initiatorHash.length() == 0)) initiatorHash = indexURL.dummyHash;
if (referrerString != null) {
try {
referrerURL = new URL(referrerString);
@@ -249,7 +250,7 @@ public final class plasmaCrawlStacker {
referrerString = null;
}
}
- String referrerHash = (referrerString==null)?null:plasmaURL.urlHash(referrerString);
+ String referrerHash = (referrerString==null)?null:indexURL.urlHash(referrerString);
try {
nexturl = new URL(nexturlString);
} catch (MalformedURLException e) {
@@ -340,7 +341,7 @@ public final class plasmaCrawlStacker {
return reason;
}
- String nexturlhash = plasmaURL.urlHash(nexturl);
+ String nexturlhash = indexURL.urlHash(nexturl);
String dbocc = this.sb.urlPool.exists(nexturlhash);
plasmaCrawlLURL.Entry oldEntry = null;
if (dbocc != null) try {
@@ -376,7 +377,7 @@ public final class plasmaCrawlStacker {
}
// store information
- boolean local = ((initiatorHash.equals(plasmaURL.dummyHash)) || (initiatorHash.equals(yacyCore.seedDB.mySeed.hash)));
+ boolean local = ((initiatorHash.equals(indexURL.dummyHash)) || (initiatorHash.equals(yacyCore.seedDB.mySeed.hash)));
boolean global =
(profile != null) &&
(profile.remoteIndexing()) /* granted */ &&
@@ -434,17 +435,17 @@ public final class plasmaCrawlStacker {
int forkfactor) {
try {
// create new entry and store it into database
- this.urlHash = plasmaURL.urlHash(urlString);
+ this.urlHash = indexURL.urlHash(urlString);
this.initiator = initiator;
this.url = urlString;
- this.referrerHash = (referrerUrlString == null) ? plasmaURL.dummyHash : plasmaURL.urlHash(referrerUrlString);
+ this.referrerHash = (referrerUrlString == null) ? indexURL.dummyHash : indexURL.urlHash(referrerUrlString);
this.name = (name == null) ? "" : name;
this.loaddate = (loaddate == null) ? new Date() : loaddate;
this.profileHandle = profileHandle; // must not be null
this.depth = depth;
this.anchors = anchors;
this.forkfactor = forkfactor;
- this.flags = new bitfield(plasmaURL.urlFlagLength);
+ this.flags = new bitfield(indexURL.urlFlagLength);
this.handle = 0;
} catch (Exception e) {
e.printStackTrace();
@@ -459,7 +460,7 @@ public final class plasmaCrawlStacker {
this.urlHash = urlHash;
this.initiator = new String(entryBytes[1], "UTF-8");
this.url = new String(entryBytes[2], "UTF-8").trim();
- this.referrerHash = (entryBytes[3]==null) ? plasmaURL.dummyHash : new String(entryBytes[3], "UTF-8");
+ this.referrerHash = (entryBytes[3]==null) ? indexURL.dummyHash : new String(entryBytes[3], "UTF-8");
this.name = (entryBytes[4] == null) ? "" : new String(entryBytes[4], "UTF-8").trim();
this.loaddate = new Date(86400000 * kelondroBase64Order.enhancedCoder.decodeLong(new String(entryBytes[5], "UTF-8")));
this.profileHandle = (entryBytes[6] == null) ? null : new String(entryBytes[6], "UTF-8").trim();
@@ -509,7 +510,7 @@ public final class plasmaCrawlStacker {
str.append("urlHash: ").append(urlHash==null ? "null" : urlHash).append(" | ")
.append("initiator: ").append(initiator==null?"null":initiator).append(" | ")
.append("url: ").append(url==null?"null":url).append(" | ")
- .append("referrer: ").append((referrerHash == null) ? plasmaURL.dummyHash : referrerHash).append(" | ")
+ .append("referrer: ").append((referrerHash == null) ? indexURL.dummyHash : referrerHash).append(" | ")
.append("name: ").append((name == null) ? "null" : name).append(" | ")
.append("loaddate: ").append((loaddate == null) ? new Date() : loaddate).append(" | ")
.append("profile: ").append(profileHandle==null?"null":profileHandle).append(" | ")
@@ -522,7 +523,7 @@ public final class plasmaCrawlStacker {
public byte[][] getBytes() {
// stores the values from the object variables into the database
- String loaddatestr = kelondroBase64Order.enhancedCoder.encodeLong(loaddate.getTime() / 86400000, plasmaURL.urlDateLength);
+ String loaddatestr = kelondroBase64Order.enhancedCoder.encodeLong(loaddate.getTime() / 86400000, indexURL.urlDateLength);
// store the hash in the hash cache
// even if the entry exists, we simply overwrite it
@@ -534,9 +535,9 @@ public final class plasmaCrawlStacker {
this.name.getBytes(),
loaddatestr.getBytes(),
(this.profileHandle == null) ? null : this.profileHandle.getBytes(),
- kelondroBase64Order.enhancedCoder.encodeLong(this.depth, plasmaURL.urlCrawlDepthLength).getBytes(),
- kelondroBase64Order.enhancedCoder.encodeLong(this.anchors, plasmaURL.urlParentBranchesLength).getBytes(),
- kelondroBase64Order.enhancedCoder.encodeLong(this.forkfactor, plasmaURL.urlForkFactorLength).getBytes(),
+ kelondroBase64Order.enhancedCoder.encodeLong(this.depth, indexURL.urlCrawlDepthLength).getBytes(),
+ kelondroBase64Order.enhancedCoder.encodeLong(this.anchors, indexURL.urlParentBranchesLength).getBytes(),
+ kelondroBase64Order.enhancedCoder.encodeLong(this.forkfactor, indexURL.urlForkFactorLength).getBytes(),
this.flags.getBytes(),
normalizeHandle(this.handle).getBytes()
};
@@ -545,7 +546,7 @@ public final class plasmaCrawlStacker {
private String normalizeHandle(int h) {
String d = Integer.toHexString(h);
- while (d.length() < plasmaURL.urlHandleLength) d = "0" + d;
+ while (d.length() < indexURL.urlHandleLength) d = "0" + d;
return d;
}
}
@@ -942,7 +943,7 @@ public final class plasmaCrawlStacker {
yacyCore.seedDB.mySeed.hash,
this.theMsg.name,
rejectReason,
- new bitfield(plasmaURL.urlFlagLength),
+ new bitfield(indexURL.urlFlagLength),
false
);
}
diff --git a/source/de/anomic/plasma/plasmaCrawlWorker.java b/source/de/anomic/plasma/plasmaCrawlWorker.java
index 6b22d0205..0c4325be7 100644
--- a/source/de/anomic/plasma/plasmaCrawlWorker.java
+++ b/source/de/anomic/plasma/plasmaCrawlWorker.java
@@ -58,6 +58,7 @@ import de.anomic.http.httpHeader;
import de.anomic.http.httpRemoteProxyConfig;
import de.anomic.http.httpc;
import de.anomic.http.httpdProxyHandler;
+import de.anomic.index.indexURL;
import de.anomic.server.serverSystem;
import de.anomic.server.logging.serverLog;
import de.anomic.tools.bitfield;
@@ -318,7 +319,7 @@ public final class plasmaCrawlWorker extends Thread {
yacyCore.seedDB.mySeed.hash,
name,
"denied_(url_in_blacklist)",
- new bitfield(plasmaURL.urlFlagLength),
+ new bitfield(indexURL.urlFlagLength),
true
);
return null;
@@ -451,7 +452,7 @@ public final class plasmaCrawlWorker extends Thread {
}
// generating url hash
- String urlhash = plasmaURL.urlHash(redirectionUrl);
+ String urlhash = indexURL.urlHash(redirectionUrl);
// removing url from loader queue
plasmaCrawlLoader.switchboard.urlPool.noticeURL.remove(urlhash);
diff --git a/source/de/anomic/plasma/plasmaHTCache.java b/source/de/anomic/plasma/plasmaHTCache.java
index 2b3f4f1bb..1d5387cc2 100644
--- a/source/de/anomic/plasma/plasmaHTCache.java
+++ b/source/de/anomic/plasma/plasmaHTCache.java
@@ -57,6 +57,7 @@ import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.http.httpc;
import de.anomic.http.httpHeader;
import de.anomic.index.indexEntryAttribute;
+import de.anomic.index.indexURL;
import de.anomic.kelondro.kelondroDyn;
import de.anomic.kelondro.kelondroMap;
import de.anomic.kelondro.kelondroMScoreCluster;
@@ -157,7 +158,7 @@ public final class plasmaHTCache {
if (dbfile.exists())
this.responseHeaderDB = new kelondroMap(new kelondroDyn(dbfile, bufferkb * 0x400, '#'));
else
- this.responseHeaderDB = new kelondroMap(new kelondroDyn(dbfile, bufferkb * 0x400, plasmaURL.urlHashLength, 150, '#', false));
+ this.responseHeaderDB = new kelondroMap(new kelondroDyn(dbfile, bufferkb * 0x400, indexURL.urlHashLength, 150, '#', false));
} catch (IOException e) {
this.log.logSevere("the request header database could not be opened: " + e.getMessage());
System.exit(0);
@@ -288,7 +289,7 @@ public final class plasmaHTCache {
try {
// As the file is gone, the entry in responseHeader.db is not needed anymore
this.log.logFinest("Trying to remove responseHeader from URL: " + url.toString());
- this.responseHeaderDB.remove(plasmaURL.urlHash(url));
+ this.responseHeaderDB.remove(indexURL.urlHash(url));
} catch (IOException e) {
this.log.logInfo("IOExeption removing response header from DB: " + e.getMessage(), e);
}
@@ -337,7 +338,7 @@ public final class plasmaHTCache {
// As the file is gone, the entry in responseHeader.db is not needed anymore
this.log.logFinest("Trying to remove responseHeader for URL: " +
getURL(this.cachePath ,obj).toString());
- this.responseHeaderDB.remove(plasmaURL.urlHash(getURL(this.cachePath ,obj)));
+ this.responseHeaderDB.remove(indexURL.urlHash(getURL(this.cachePath ,obj)));
} catch (IOException e) {
this.log.logInfo("IOExeption removing response header from DB: " +
e.getMessage(), e);
@@ -736,7 +737,7 @@ public final class plasmaHTCache {
}
this.name = name;
this.cacheFile = getCachePath(this.url);
- this.nomalizedURLHash = plasmaURL.urlHash(this.nomalizedURLString);
+ this.nomalizedURLHash = indexURL.urlHash(this.nomalizedURLString);
// assigned:
this.initDate = initDate;
diff --git a/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java b/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java
index a8c08e4b7..77564f2b3 100644
--- a/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java
+++ b/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java
@@ -54,6 +54,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.TreeSet;
+import de.anomic.index.indexURL;
import de.anomic.kelondro.kelondroAttrSeq;
import de.anomic.server.serverCodings;
import de.anomic.server.serverFileUtils;
@@ -175,8 +176,8 @@ public class plasmaRankingRCIEvaluation {
dom = (String) i.next();
if (dom.startsWith("www.")) dom = dom.substring(4);
try {
- dommap.put(plasmaURL.urlHash(new URL("http://" + dom)).substring(6), dom);
- dommap.put(plasmaURL.urlHash(new URL("http://www." + dom)).substring(6), "www." + dom);
+ dommap.put(indexURL.urlHash(new URL("http://" + dom)).substring(6), dom);
+ dommap.put(indexURL.urlHash(new URL("http://www." + dom)).substring(6), "www." + dom);
} catch (MalformedURLException e) {}
}
return dommap;
diff --git a/source/de/anomic/plasma/plasmaSearchResult.java b/source/de/anomic/plasma/plasmaSearchResult.java
index bc91d9b9b..d111810bc 100644
--- a/source/de/anomic/plasma/plasmaSearchResult.java
+++ b/source/de/anomic/plasma/plasmaSearchResult.java
@@ -56,6 +56,7 @@ import de.anomic.kelondro.kelondroMScoreCluster;
import de.anomic.server.serverCodings;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.index.indexEntryAttribute;
+import de.anomic.index.indexURL;
public final class plasmaSearchResult {
@@ -281,14 +282,14 @@ public final class plasmaSearchResult {
String[] paths1 = new String[urls.length]; for (int i = 0; i < urls.length; i++) {
fill = ""; for (int j = 0; j < 35 - urls[i].toString().length(); j++) fill +=" ";
paths1[i] = urlPath(urls[i]);
- hash = plasmaURL.urlHash(urls[i]);
- System.out.println("paths1[" + urls[i] + fill +"] = " + hash + ", typeID=" + plasmaURL.flagTypeID(hash) + ", tldID=" + plasmaURL.flagTLDID(hash) + ", lengthID=" + plasmaURL.flagLengthID(hash) + " / " + paths1[i]);
+ hash = indexURL.urlHash(urls[i]);
+ System.out.println("paths1[" + urls[i] + fill +"] = " + hash + ", typeID=" + indexURL.flagTypeID(hash) + ", tldID=" + indexURL.flagTLDID(hash) + ", lengthID=" + indexURL.flagLengthID(hash) + " / " + paths1[i]);
}
String[] paths2 = new String[urls.length]; for (int i = 0; i < urls.length; i++) {
fill = ""; for (int j = 0; j < 35 - urls[i].toString().length(); j++) fill +=" ";
paths2[i] = shortenPath(paths1[i]);
- hash = plasmaURL.urlHash(urls[i]);
- System.out.println("paths2[" + urls[i] + fill + "] = " + hash + ", typeID=" + plasmaURL.flagTypeID(hash) + ", tldID=" + plasmaURL.flagTLDID(hash) + ", lengthID=" + plasmaURL.flagLengthID(hash) + " / " + paths2[i]);
+ hash = indexURL.urlHash(urls[i]);
+ System.out.println("paths2[" + urls[i] + fill + "] = " + hash + ", typeID=" + indexURL.flagTypeID(hash) + ", tldID=" + indexURL.flagTLDID(hash) + ", lengthID=" + indexURL.flagLengthID(hash) + " / " + paths2[i]);
}
} catch (MalformedURLException e) {
e.printStackTrace();
diff --git a/source/de/anomic/plasma/plasmaSnippetCache.java b/source/de/anomic/plasma/plasmaSnippetCache.java
index 26c1b54cc..9c3593d14 100644
--- a/source/de/anomic/plasma/plasmaSnippetCache.java
+++ b/source/de/anomic/plasma/plasmaSnippetCache.java
@@ -56,6 +56,7 @@ import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacySearch;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.index.indexEntryAttribute;
+import de.anomic.index.indexURL;
public class plasmaSnippetCache {
@@ -143,7 +144,7 @@ public class plasmaSnippetCache {
public boolean existsInCache(URL url, Set queryhashes) {
String hashes = yacySearch.set2string(queryhashes);
- return retrieveFromCache(hashes, plasmaURL.urlHash(url)) != null;
+ return retrieveFromCache(hashes, indexURL.urlHash(url)) != null;
}
public result retrieve(URL url, Set queryhashes, boolean fetchOnline, int snippetMaxLength) {
@@ -152,7 +153,7 @@ public class plasmaSnippetCache {
//System.out.println("found no queryhashes for URL retrieve " + url);
return new result(null, ERROR_NO_HASH_GIVEN, "no query hashes given");
}
- String urlhash = plasmaURL.urlHash(url);
+ String urlhash = indexURL.urlHash(url);
// try to get snippet from snippetCache
int source = SOURCE_CACHE;
@@ -363,7 +364,7 @@ public class plasmaSnippetCache {
if (header == null) {
try {
- header = this.cacheManager.getCachedResponse(plasmaURL.urlHash(url));
+ header = this.cacheManager.getCachedResponse(indexURL.urlHash(url));
} catch (IOException e) {}
}
diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java
index 27f1777a7..52f29a31e 100644
--- a/source/de/anomic/plasma/plasmaSwitchboard.java
+++ b/source/de/anomic/plasma/plasmaSwitchboard.java
@@ -131,6 +131,7 @@ import de.anomic.http.httpHeader;
import de.anomic.http.httpRemoteProxyConfig;
import de.anomic.http.httpc;
import de.anomic.index.indexEntryAttribute;
+import de.anomic.index.indexURL;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroMSetTools;
@@ -828,7 +829,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
}
// enqueue for further crawling
- enQueue(this.sbQueue.newEntry(entry.url, plasmaURL.urlHash(entry.referrerURL()),
+ enQueue(this.sbQueue.newEntry(entry.url, indexURL.urlHash(entry.referrerURL()),
entry.requestHeader.ifModifiedSince(), entry.requestHeader.containsKey(httpHeader.COOKIE),
entry.initiator(), entry.depth, entry.profile.handle(),
entry.name()
@@ -1211,7 +1212,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
boolean tryRemote = ((urlPool.noticeURL.stackSize(plasmaCrawlNURL.STACK_TYPE_CORE) != 0) || (sbQueue.size() != 0)) &&
(profile.remoteIndexing()) &&
(urlEntry.initiator() != null) &&
- // (!(urlEntry.initiator().equals(plasmaURL.dummyHash))) &&
+ // (!(urlEntry.initiator().equals(indexURL.dummyHash))) &&
((yacyCore.seedDB.mySeed.isSenior()) || (yacyCore.seedDB.mySeed.isPrincipal()));
if (tryRemote) {
boolean success = processRemoteCrawlTrigger(urlEntry);
@@ -1321,8 +1322,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
// 6) local fetching for global crawling (other known or unknwon initiator)
int processCase = 0;
yacySeed initiator = null;
- String initiatorHash = (entry.proxy()) ? plasmaURL.dummyHash : entry.initiator();
- if (initiatorHash.equals(plasmaURL.dummyHash)) {
+ String initiatorHash = (entry.proxy()) ? indexURL.dummyHash : entry.initiator();
+ if (initiatorHash.equals(indexURL.dummyHash)) {
// proxy-load
processCase = 4;
} else if (initiatorHash.equals(yacyCore.seedDB.mySeed.hash)) {
@@ -1394,7 +1395,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
// rejectReason = stackCrawl(nexturlstring, entry.normalizedURLString(), initiatorHash, (String) e.getValue(), loadDate, entry.depth() + 1, entry.profile());
// if (rejectReason == null) { c++; } else {
// urlPool.errorURL.newEntry(new URL(nexturlstring), entry.normalizedURLString(), entry.initiator(), yacyCore.seedDB.mySeed.hash,
- // (String) e.getValue(), rejectReason, new bitfield(plasmaURL.urlFlagLength), false);
+ // (String) e.getValue(), rejectReason, new bitfield(indexURL.urlFlagLength), false);
// }
}
log.logInfo("CRAWL: ADDED " + hl.size() + " LINKS FROM " + entry.normalizedURLString() +
@@ -1406,8 +1407,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
String descr = document.getMainLongTitle();
String referrerHash;
URL referrerURL = entry.referrerURL();
- referrerHash = plasmaURL.urlHash(referrerURL);
- if (referrerHash == null) referrerHash = plasmaURL.dummyHash;
+ referrerHash = indexURL.urlHash(referrerURL);
+ if (referrerHash == null) referrerHash = indexURL.dummyHash;
String noIndexReason = "unspecified";
if (processCase == 4) {
@@ -1563,9 +1564,9 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
} else {
log.logInfo("Not indexed any word in URL " + entry.url() + "; cause: " + noIndexReason);
urlPool.errorURL.newEntry(entry.url(), referrerHash,
- ((entry.proxy()) ? plasmaURL.dummyHash : entry.initiator()),
+ ((entry.proxy()) ? indexURL.dummyHash : entry.initiator()),
yacyCore.seedDB.mySeed.hash,
- descr, noIndexReason, new bitfield(plasmaURL.urlFlagLength), true);
+ descr, noIndexReason, new bitfield(indexURL.urlFlagLength), true);
if ((processCase == 6) && (initiator != null)) {
yacyClient.crawlReceipt(initiator, "crawl", "rejected", noIndexReason, null, "");
}
@@ -1606,7 +1607,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
int GCount = 0;
int LCount = 0;
while (it.hasNext()) {
- nexturlhash = plasmaURL.urlHash((String) ((Map.Entry) it.next()).getKey());
+ nexturlhash = indexURL.urlHash((String) ((Map.Entry) it.next()).getKey());
if (nexturlhash != null) {
if (nexturlhash.substring(6).equals(lhp)) {
cpl.append(nexturlhash.substring(0, 6));
@@ -1681,7 +1682,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
URL refererURL = null;
String refererHash = urlEntry.referrerHash();
- if ((refererHash != null) && (!refererHash.equals(plasmaURL.dummyHash))) try {
+ if ((refererHash != null) && (!refererHash.equals(indexURL.dummyHash))) try {
refererURL = this.urlPool.getURL(refererHash);
} catch (IOException e) {
refererURL = null;
@@ -1711,7 +1712,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
log.logFine("ERROR: plasmaSwitchboard.processRemoteCrawlTrigger - url is null. name=" + urlEntry.name());
return true;
}
- String urlhash = plasmaURL.urlHash(urlEntry.url());
+ String urlhash = indexURL.urlHash(urlEntry.url());
// check remote crawl
yacySeed remoteSeed = yacyCore.dhtAgent.getCrawlSeed(urlhash);
@@ -1963,7 +1964,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
// method for index deletion
public int removeAllUrlReferences(URL url, boolean fetchOnline) {
- return removeAllUrlReferences(plasmaURL.urlHash(url), fetchOnline);
+ return removeAllUrlReferences(indexURL.urlHash(url), fetchOnline);
}
public int removeAllUrlReferences(String urlhash, boolean fetchOnline) {
@@ -1991,7 +1992,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
}
public int removeReferences(URL url, Set words) {
- return removeReferences(plasmaURL.urlHash(url), words);
+ return removeReferences(indexURL.urlHash(url), words);
}
public int removeReferences(final String urlhash, final Set words) {
diff --git a/source/de/anomic/plasma/plasmaSwitchboardQueue.java b/source/de/anomic/plasma/plasmaSwitchboardQueue.java
index cd353475b..95f37523d 100644
--- a/source/de/anomic/plasma/plasmaSwitchboardQueue.java
+++ b/source/de/anomic/plasma/plasmaSwitchboardQueue.java
@@ -46,6 +46,7 @@ package de.anomic.plasma;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.http.httpHeader;
+import de.anomic.index.indexURL;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroStack;
@@ -83,25 +84,25 @@ public class plasmaSwitchboardQueue {
} catch (IOException e) {
sbQueueStackPath.delete();
sbQueueStack = new kelondroStack(sbQueueStackPath, 0, new int[] {
- plasmaURL.urlStringLength,
- plasmaURL.urlHashLength,
+ indexURL.urlStringLength,
+ indexURL.urlHashLength,
11,
1,
yacySeedDB.commonHashLength,
- plasmaURL.urlCrawlDepthLength,
- plasmaURL.urlCrawlProfileHandleLength,
- plasmaURL.urlDescrLength
+ indexURL.urlCrawlDepthLength,
+ indexURL.urlCrawlProfileHandleLength,
+ indexURL.urlDescrLength
}, true);
} else {
sbQueueStack = new kelondroStack(sbQueueStackPath, 0, new int[] {
- plasmaURL.urlStringLength,
- plasmaURL.urlHashLength,
+ indexURL.urlStringLength,
+ indexURL.urlHashLength,
11,
1,
yacySeedDB.commonHashLength,
- plasmaURL.urlCrawlDepthLength,
- plasmaURL.urlCrawlProfileHandleLength,
- plasmaURL.urlDescrLength
+ indexURL.urlCrawlDepthLength,
+ indexURL.urlCrawlProfileHandleLength,
+ indexURL.urlDescrLength
}, true);
}
}
@@ -119,12 +120,12 @@ public class plasmaSwitchboardQueue {
public void push(Entry entry) throws IOException {
sbQueueStack.push(new byte[][]{
entry.url.toString().getBytes(),
- (entry.referrerHash == null) ? plasmaURL.dummyHash.getBytes() : entry.referrerHash.getBytes(),
+ (entry.referrerHash == null) ? indexURL.dummyHash.getBytes() : entry.referrerHash.getBytes(),
kelondroBase64Order.enhancedCoder.encodeLong((entry.ifModifiedSince == null) ? 0 : entry.ifModifiedSince.getTime(), 11).getBytes(),
new byte[]{entry.flags},
- (entry.initiator == null) ? plasmaURL.dummyHash.getBytes() : entry.initiator.getBytes(),
- kelondroBase64Order.enhancedCoder.encodeLong((long) entry.depth, plasmaURL.urlCrawlDepthLength).getBytes(),
- (entry.profileHandle == null) ? plasmaURL.dummyHash.getBytes() : entry.profileHandle.getBytes(),
+ (entry.initiator == null) ? indexURL.dummyHash.getBytes() : entry.initiator.getBytes(),
+ kelondroBase64Order.enhancedCoder.encodeLong((long) entry.depth, indexURL.urlCrawlDepthLength).getBytes(),
+ (entry.profileHandle == null) ? indexURL.dummyHash.getBytes() : entry.profileHandle.getBytes(),
(entry.anchorName == null) ? "-".getBytes() : entry.anchorName.getBytes()
});
}
@@ -265,7 +266,7 @@ public class plasmaSwitchboardQueue {
}
public String urlHash() {
- return plasmaURL.urlHash(url);
+ return indexURL.urlHash(url);
}
public boolean requestedWithCookie() {
@@ -277,7 +278,7 @@ public class plasmaSwitchboardQueue {
}
public boolean proxy() {
- return (initiator == null) || (initiator.equals(plasmaURL.dummyHash));
+ return (initiator == null) || (initiator.equals(indexURL.dummyHash));
}
public String initiator() {
@@ -299,7 +300,7 @@ public class plasmaSwitchboardQueue {
public httpHeader responseHeader() {
if (responseHeader == null) try {
- responseHeader = htCache.getCachedResponse(plasmaURL.urlHash(url));
+ responseHeader = htCache.getCachedResponse(indexURL.urlHash(url));
} catch (IOException e) {
serverLog.logSevere("PLASMA", "responseHeader: failed to get header", e);
return null;
@@ -309,7 +310,7 @@ public class plasmaSwitchboardQueue {
public URL referrerURL() {
if (referrerURL == null) {
- if ((referrerHash == null) || (referrerHash.equals(plasmaURL.dummyHash))) return null;
+ if ((referrerHash == null) || (referrerHash.equals(indexURL.dummyHash))) return null;
try {
referrerURL = lurls.getEntry(referrerHash, null).url();
} catch (IOException e) {
diff --git a/source/de/anomic/plasma/plasmaURL.java b/source/de/anomic/plasma/plasmaURL.java
deleted file mode 100644
index c60a9d2be..000000000
--- a/source/de/anomic/plasma/plasmaURL.java
+++ /dev/null
@@ -1,581 +0,0 @@
-// plasmaURL.java
-// -----------------------
-// part of YaCy
-// (C) by Michael Peter Christen; [email protected]
-// first published on http://www.anomic.de
-// Frankfurt, Germany, 2004
-// last major change: 09.08.2004
-//
-// 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.IOException;
-import java.lang.Boolean;
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.text.SimpleDateFormat;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import de.anomic.htmlFilter.htmlFilterContentScraper;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroTree;
-import de.anomic.server.serverCodings;
-import de.anomic.yacy.yacySeedDB;
-
-public class plasmaURL {
-
- // day formatter for entry export
- protected static final SimpleDateFormat shortDayFormatter = new SimpleDateFormat("yyyyMMdd");
-
- // statics for value lengths
- public static final int urlHashLength = yacySeedDB.commonHashLength; // 12
- public static final int urlStringLength = 256;// not too short for links without parameters
- public static final int urlDescrLength = 80; // The headline of a web page (meta-tag or <h1>)
- public static final int urlNameLength = 40; // the tag content between <a> and </a>
- public static final int urlErrorLength = 20; // a reason description for unavailable urls
- public static final int urlDateLength = 4; // any date, shortened
- public static final int urlCopyCountLength = 2; // counter for numbers of copies of this index
- public static final int urlFlagLength = 2; // any stuff
- public static final int urlQualityLength = 3; // taken from heuristic
- public static final int urlLanguageLength = 2; // taken from TLD suffix as quick-hack
- public static final int urlDoctypeLength = 1; // taken from extension
- public static final int urlSizeLength = 6; // the source size, from cache
- public static final int urlWordCountLength = 3; // the number of words, from condenser
- public static final int urlCrawlProfileHandleLength = 4; // name of the prefetch profile
- public static final int urlCrawlDepthLength = 2; // prefetch depth, first is '0'
- public static final int urlParentBranchesLength = 3; // number of anchors of the parent
- public static final int urlForkFactorLength = 4; // sum of anchors of all ancestors
- public static final int urlRetryLength = 2; // number of load retries
- public static final int urlHostLength = 8; // the host as struncated name
- public static final int urlHandleLength = 4; // a handle
-
- private static final String[] TLD_NorthAmericaOceania={
- // primary english-speaking countries
- // english-speaking countries from central america are also included
- // includes also dutch and french colonies in the caribbean sea
- "EDU=US Educational",
- "GOV=US Government",
- "MIL=US Military",
- "NET=Network",
- "ORG=Non-Profit Organization",
- "AG=Antigua and Barbuda",
- "AI=Anguilla",
- "AU=Australia",
- "BB=Barbados",
- "BZ=Belize",
- "BM=Bermuda",
- "BS=Bahamas",
- "CA=Canada",
- "DM=Dominica",
- "GD=Grenada",
- "GP=Guadeloupe",
- "KY=Cayman Islands",
- "NZ=New Zealand (Aotearoa)",
- "PM=St. Pierre and Miquelon",
- "US=United States",
- "VC=Saint Vincent and the Grenadines",
- "VG=Virgin Islands (British)",
- "VI=Virgin Islands (U.S.)",
- "VU=Vanuatu",
- "WF=Wallis and Futuna Islands",
- "WS=Samoa"
- };
- private static final String[] TLD_MiddleSouthAmerica = {
- // primary spanish and portugese-speaking
- "AR=Argentina",
- "AW=Aruba",
- "BR=Brazil",
- "BO=Bolivia",
- "CL=Chile",
- "CO=Colombia",
- "CR=Costa Rica",
- "CU=Cuba",
- "DO=Dominican Republic",
- "EC=Ecuador",
- "GF=French Guiana",
- "FK=Falkland Islands (Malvinas)",
- "GY=Guyana",
- "HN=Honduras",
- "JM=Jamaica",
- "MX=Mexico",
- "NI=Nicaragua",
- "PA=Panama",
- "PE=Peru",
- "PY=Paraguay",
- "SR=Suriname",
- "SV=El Salvador",
- "UY=Uruguay",
- "VE=Venezuela"
- };
- private static final String[] TLD_EuropaRussia = {
- // includes also countries that are mainly french- dutch- speaking
- // and culturally close to europe
- "AD=Andorra",
- "AL=Albania",
- "AT=Austria",
- "BA=Bosnia and Herzegovina",
- "BE=Belgium",
- "BG=Bulgaria",
- "CH=Switzerland",
- "CS=Czechoslovakia (former)",
- "CZ=Czech Republic",
- "CY=Cyprus",
- "DE=Germany",
- "DK=Denmark",
- "ES=Spain",
- "EE=Estonia",
- "FI=Finland",
- "FR=France",
- "FX=France, Metropolitan",
- "GB=Great Britain (UK)",
- "GI=Gibraltar",
- "GL=Greenland",
- "GR=Greece",
- "HR=Croatia (Hrvatska)",
- "HU=Hungary",
- "IE=Ireland",
- "IS=Iceland",
- "IT=Italy",
- "LI=Liechtenstein",
- "LT=Lithuania",
- "LU=Luxembourg",
- "LV=Latvia",
- "MD=Moldova",
- "MC=Monaco",
- "MK=Macedonia",
- "MN=Mongolia",
- "MT=Malta",
- "NATO=Nato field",
- "NL=Netherlands",
- "NO=Norway",
- "PL=Poland",
- "PT=Portugal",
- "RO=Romania",
- "RU=Russia",
- "SE=Sweden",
- "SI=Slovenia",
- "SK=Slovak Republic",
- "SU=USSR (former)",
- "UK=United Kingdom",
- "VA=Vatican City State (Holy See)",
- "YU=Yugoslavia"
- };
- private static final String[] TLD_MiddleEastWestAsia = {
- "AE=United Arab Emirates",
- "AF=Afghanistan",
- "AZ=Azerbaijan",
- "BH=Bahrain",
- "IL=Israel",
- "IQ=Iraq",
- "IR=Iran",
- "PK=Pakistan",
- "YE=Yemen"
- };
- private static final String[] TLD_SouthEastAsia = {
- "BD=Bangladesh",
- "BT=Bhutan",
- "CN=China",
- "HK=Hong Kong",
- "ID=Indonesia",
- "IN=India",
- "NP=Nepal",
- "JP=Japan",
- "KH=Cambodia",
- "KP=Korea (North)",
- "KR=Korea (South)",
- "LK=Sri Lanka",
- "SG=Singapore",
- "VN=Viet Nam"
- };
- private static final String[] TLD_Africa = {
- "AO=Angola",
- "BF=Burkina Faso",
- "BI=Burundi",
- "BJ=Benin",
- "BW=Botswana",
- "CF=Central African Republic",
- "CG=Congo",
- "CI=Cote D'Ivoire (Ivory Coast)",
- "CM=Cameroon",
- "DZ=Algeria",
- "EG=Egypt",
- "EH=Western Sahara",
- "ER=Eritrea",
- "ET=Ethiopia",
- "GA=Gabon",
- "GH=Ghana",
- "GM=Gambia",
- "GN=Guinea",
- "KE=Kenya",
- "LR=Liberia",
- "LS=Lesotho",
- "LY=Libya",
- "MA=Morocco",
- "MG=Madagascar",
- "ML=Mali",
- "MR=Mauritania",
- "MU=Mauritius",
- "MW=Malawi",
- "MZ=Mozambique",
- "NA=Namibia",
- "NE=Niger",
- "NG=Nigeria",
- "RE=Reunion",
- "RW=Rwanda",
- "SH=St. Helena",
- "SL=Sierra Leone",
- "SN=Senegal",
- "SO=Somalia",
- "ST=Sao Tome and Principe",
- "SZ=Swaziland",
- "TG=Togo",
- "TN=Tunisia",
- "TZ=Tanzania",
- "UG=Uganda",
- "ZA=South Africa",
- "ZM=Zambia",
- "ZR=Zaire",
- "ZW=Zimbabwe",
- "YT=Mayotte"
- };
- private static final String[] TLD_Generic = {
- "COM=US Commercial",
- "AERO=",
- "BIZ=",
- "COOP=",
- "INFO=",
- "MUSEUM=",
- "NAME=",
- "PRO=",
- "ARPA=",
- "INT=International",
- "ARPA=Arpanet"
- };
- private static final String[] TLD_Unassigned = {
- "AQ=Antarctica",
- "NT=Neutral Zone"
- };
-
- /*
- http://www.odci.gov/cia/publications/factbook/
- http://en.wikipedia.org/wiki/List_of_countries_by_continent
- "AM=Armenia",
- "AN=Netherlands Antilles",
- "AS=American Samoa",
- "BN=Brunei Darussalam",
- "BV=Bouvet Island",
- "BY=Belarus",
- "CC=Cocos (Keeling) Islands",
- "CK=Cook Islands",
- "CV=Cape Verde",
- "CX=Christmas Island",
- "DJ=Djibouti",
- "FJ=Fiji",
- "FM=Micronesia",
- "FO=Faroe Islands",
- "GE=Georgia",
- "GQ=Equatorial Guinea",
- "GS=S. Georgia and S. Sandwich Isls.",
- "GT=Guatemala",
- "GU=Guam",
- "GW=Guinea-Bissau",
- "HM=Heard and McDonald Islands",
- "HT=Haiti",
- "IO=British Indian Ocean Territory",
- "JO=Jordan",
- "KG=Kyrgyzstan",
- "KI=Kiribati",
- "KM=Comoros",
- "KN=Saint Kitts and Nevis",
- "KW=Kuwait",
- "KZ=Kazakhstan",
- "LA=Laos",
- "LB=Lebanon",
- "LC=Saint Lucia",
- "MH=Marshall Islands",
- "MM=Myanmar",
- "MO=Macau",
- "MP=Northern Mariana Islands",
- "MQ=Martinique",
- "MS=Montserrat",
- "MV=Maldives",
- "MY=Malaysia",
- "NC=New Caledonia",
- "NF=Norfolk Island",
- "NR=Nauru",
- "NU=Niue",
- "OM=Oman",
- "PF=French Polynesia",
- "PG=Papua New Guinea",
- "PH=Philippines",
- "PN=Pitcairn",
- "PR=Puerto Rico",
- "PW=Palau",
- "QA=Qatar",
- "SA=Saudi Arabia",
- "Sb=Solomon Islands",
- "SC=Seychelles",
- "SD=Sudan",
- "SJ=Svalbard and Jan Mayen Islands",
- "SM=San Marino",
- "SY=Syria",
- "TC=Turks and Caicos Islands",
- "TD=Chad",
- "TF=French Southern Territories",
- "TH=Thailand",
- "TJ=Tajikistan",
- "TK=Tokelau",
- "TM=Turkmenistan",
- "TO=Tonga",
- "TP=East Timor",
- "TR=Turkey",
- "TT=Trinidad and Tobago",
- "TV=Tuvalu",
- "TW=Taiwan",
- "UA=Ukraine",
- "UM=US Minor Outlying Islands",
- "UZ=Uzbekistan",
- */
-
- /* TLDs:
- aero, biz, com, coop, edu, gov, info, int, mil, museum, name, net, org, pro, arpa
- AC, AD, AE, AERO, AF, AG, AI, AL, AM, AN, AO, AQ, AR, ARPA, AS, AT, AU, AW, AZ,
- BA, BB, BD, BE, BF, BG, BH, BI, BIZ, BJ, BM, BN, BO, BR, BS, BT, BV, BW, BY, BZ,
- CA, CC, CD, CF, CG, CH, CI, CK, CL, CM, CN, CO, COM, COOP, CR, CU, CV, CX, CY, CZ,
- DE, DJ, DK, DM, DO, DZ, EC, EDU, EE, EG, ER, ES, ET, EU, FI, FJ, FK, FM, FO, FR,
- GA, GB, GD, GE, GF, GG, GH, GI, GL, GM, GN, GOV, GP, GQ, GR, GS, GT, GU, GW, GY,
- HK, HM, HN, HR, HT, HU, ID, IE, IL, IM, IN, INFO, INT, IO, IQ, IR, IS, IT,
- JE, JM, JO, JOBS, JP, KE, KG, KH, KI, KM, KN, KR, KW, KY, KZ,
- LA, LB, LC, LI, LK, LR, LS, LT, LU, LV, LY,
- MA, MC, MD, MG, MH, MIL, MK, ML, MM, MN, MO, MOBI, MP, MQ, MR, MS, MT, MU, MUSEUM, MV, MW, MX, MY, MZ,
- NA, NAME, NC, NE, NET, NF, NG, NI, NL, NO, NP, NR, NU, NZ, OM, ORG,
- PA, PE, PF, PG, PH, PK, PL, PM, PN, PR, PRO, PS, PT, PW, PY, QA, RE, RO, RU, RW,
- SA, SB, SC, SD, SE, SG, SH, SI, SJ, SK, SL, SM, SN, SO, SR, ST, SU, SV, SY, SZ,
- TC, TD, TF, TG, TH, TJ, TK, TL, TM, TN, TO, TP, TR, TRAVEL, TT, TV, TW, TZ,
- UA, UG, UK, UM, US, UY, UZ, VA, VC, VE, VG, VI, VN, VU, WF, WS, YE, YT, YU, ZA, ZM, ZW
- */
-
- public static String dummyHash;
- private static HashMap TLDID = new HashMap();
- private static HashMap TLDName = new HashMap();
- private static void insertTLDProps(String[] TLDList, int id) {
- int p;
- String tld, name;
- Integer ID = new Integer(id);
- for (int i = 0; i < TLDList.length; i++) {
- p = TLDList[i].indexOf('=');
- if (p > 0) {
- tld = TLDList[i].substring(0, p).toLowerCase();
- name = TLDList[i].substring(p + 1);
- TLDID.put(tld, ID);
- TLDName.put(tld, name);
- }
- }
- }
- static {
- // create a dummy hash
- dummyHash = "";
- for (int i = 0; i < urlHashLength; i++) dummyHash += "-";
-
- // assign TLD-ids and names
- insertTLDProps(TLD_EuropaRussia, 0);
- insertTLDProps(TLD_MiddleSouthAmerica, 1);
- insertTLDProps(TLD_SouthEastAsia, 2);
- insertTLDProps(TLD_MiddleEastWestAsia, 3);
- insertTLDProps(TLD_NorthAmericaOceania, 4);
- insertTLDProps(TLD_Africa, 5);
- insertTLDProps(TLD_Generic, 6);
- insertTLDProps(TLD_Unassigned, 7);
- }
-
-
- // the class object
- public kelondroTree urlHashCache;
- public final HashMap existsIndex; // allow subclasses to access the existsIndex during Entry.store()
-
- public plasmaURL() {
- urlHashCache = null;
- existsIndex = new HashMap();
- }
-
- public int size() {
- return urlHashCache.size();
- }
-
- public void close() throws IOException {
- if (urlHashCache != null) urlHashCache.close();
- }
-
- public boolean exists(String urlHash) {
- synchronized (existsIndex) {
- Boolean existsInIndex = (Boolean) existsIndex.get(urlHash);
- if (existsInIndex != null) return existsInIndex.booleanValue();
- try {
- if (urlHashCache.get(urlHash.getBytes()) != null) {
- existsIndex.put(urlHash, Boolean.TRUE);
- return true;
- } else {
- existsIndex.put(urlHash, Boolean.FALSE);
- return false;
- }
- } catch (IOException e) {
- return false;
- }
- }
- }
-
- public long existsIndexSize() {
- return this.existsIndex.size();
- }
-
- public boolean remove(String urlHash) {
- synchronized (existsIndex) {
- try {
- Boolean existsInIndex = (Boolean) existsIndex.remove(urlHash);
- if (existsInIndex == null) existsInIndex = Boolean.FALSE;
- boolean existsInCache = (this.urlHashCache.remove(urlHash.getBytes()) != null);
- existsIndex.put(urlHash, Boolean.FALSE);
- return existsInIndex.booleanValue() || existsInCache;
- } catch (IOException e) {
- return false;
- }
- }
- }
-
- public void clearExistsIndex() {
- synchronized (existsIndex) {
- existsIndex.clear();
- }
- }
-
- public static final int flagTypeID(String hash) {
- return (kelondroBase64Order.enhancedCoder.decodeByte(hash.charAt(11)) & 32) >> 5;
- }
- public static final int flagTLDID(String hash) {
- return (kelondroBase64Order.enhancedCoder.decodeByte(hash.charAt(11)) & 28) >> 2;
- }
- public static final int flagLengthID(String hash) {
- return (kelondroBase64Order.enhancedCoder.decodeByte(hash.charAt(11)) & 3);
- }
-
- public static final String urlHash(String url) {
- if ((url == null) || (url.length() == 0)) return null;
- try {
- return urlHash(new URL(url));
- } catch (MalformedURLException e) {
- return null;
- }
- }
- public static final String urlHash(URL url) {
- if (url == null) return null;
- String host = url.getHost().toLowerCase();
- int p = host.lastIndexOf('.');
- String tld = "", dom = tld;
- if (p > 0) {
- tld = host.substring(p + 1);
- dom = host.substring(0, p);
- }
- Integer ID = (Integer) TLDID.get(tld);
- int id = (ID == null) ? 7 : ID.intValue();
- boolean isHTTP = url.getProtocol().equals("http");
- p = dom.lastIndexOf('.'); // locate subdomain
- String subdom = "";
- if (p > 0) {
- subdom = dom.substring(0, p);
- dom = dom.substring(p + 1);
- }
- int port = url.getPort();
- if (port <= 0) {
- if (isHTTP) {
- port = 80;
- } else if (url.getProtocol().equalsIgnoreCase("https")) {
- port = 443;
- } else {
- port = 21;
- }
- }
- String path = url.getPath();
- if (path.startsWith("/")) path = path.substring(1);
- if (path.endsWith("/")) path = path.substring(0, path.length() - 1);
- p = path.indexOf('/');
- String rootpath = "";
- if (p > 0) {
- rootpath = path.substring(0, p);
- }
- // we collected enough information to compute the fragments that are basis for hashes
- int l = dom.length();
- int domlengthKey = (l <= 8) ? 0 : (l <= 12) ? 1 : (l <= 16) ? 2 : 3;
- byte flagbyte = (byte) (((isHTTP) ? 0 : 32) | (id << 2) | domlengthKey);
- // form the 'local' part of the hash
- String hash3 = kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(htmlFilterContentScraper.urlNormalform(url))).substring(0, 5);
- char hash2 = kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(subdom + ":" + port + ":" + rootpath)).charAt(0);
- // form the 'global' part of the hash
- String hash1 = kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(url.getProtocol() + ":" + host + ":" + port)).substring(0, 5);
- char hash0 = kelondroBase64Order.enhancedCoder.encodeByte(flagbyte);
- // combine the hashes
- return hash3 + hash2 + hash1 + hash0;
- }
-
- public static final int domLengthEstimation(String urlHash) {
- // generates an estimation of the original domain length
- int flagbyte = kelondroBase64Order.enhancedCoder.decodeByte(urlHash.charAt(11));
- int domLengthKey = flagbyte & 3;
- switch (domLengthKey) {
- case 0: return 4;
- case 1: return 10;
- case 2: return 14;
- case 3: return 20;
- }
- return 20;
- }
-
- public static final String oldurlHash(URL url) {
- if (url == null) return null;
- String hash = kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(htmlFilterContentScraper.urlNormalform(url))).substring(0, urlHashLength);
- return hash;
- }
-
- public static final String oldurlHash(String url) {
- if ((url == null) || (url.length() < 10)) return null;
- String hash = kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(htmlFilterContentScraper.urlNormalform(null, url))).substring(0, urlHashLength);
- return hash;
- }
-
- public Iterator urlHashes(String urlHash, boolean up) throws IOException {
- return urlHashCache.keys(up, false, urlHash.getBytes());
- }
-
-}
diff --git a/source/de/anomic/plasma/plasmaURLPool.java b/source/de/anomic/plasma/plasmaURLPool.java
index 276c14140..b5a06390f 100644
--- a/source/de/anomic/plasma/plasmaURLPool.java
+++ b/source/de/anomic/plasma/plasmaURLPool.java
@@ -48,6 +48,8 @@ import java.net.URL;
import java.io.File;
import java.io.IOException;
+import de.anomic.index.indexURL;
+
public class plasmaURLPool {
@@ -72,7 +74,7 @@ public class plasmaURLPool {
}
public URL getURL(String urlhash) throws IOException {
- if (urlhash.equals(plasmaURL.dummyHash)) return null;
+ if (urlhash.equals(indexURL.dummyHash)) return null;
plasmaCrawlNURL.Entry ne = noticeURL.getEntry(urlhash);
if (ne != null) return ne.url();
try {
diff --git a/source/de/anomic/plasma/plasmaWordIndexEntity.java b/source/de/anomic/plasma/plasmaWordIndexEntity.java
index 4ad314f06..4c2f8968d 100644
--- a/source/de/anomic/plasma/plasmaWordIndexEntity.java
+++ b/source/de/anomic/plasma/plasmaWordIndexEntity.java
@@ -47,6 +47,8 @@ package de.anomic.plasma;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
+
+import de.anomic.index.indexURL;
import de.anomic.kelondro.kelondroTree;
import de.anomic.kelondro.kelondroException;
import de.anomic.server.logging.serverLog;
@@ -90,10 +92,10 @@ public final class plasmaWordIndexEntity {
kt = new kelondroTree(theLocation, cacheSize, kelondroTree.defaultObjectCachePercent);
} catch (IOException e) {
theLocation.delete();
- kt = new kelondroTree(theLocation, cacheSize, kelondroTree.defaultObjectCachePercent, plasmaURL.urlHashLength, plasmaWordIndexEntryInstance.encodedStringFormLength(), false);
+ kt = new kelondroTree(theLocation, cacheSize, kelondroTree.defaultObjectCachePercent, indexURL.urlHashLength, plasmaWordIndexEntryInstance.encodedStringFormLength(), false);
} else {
// create new index file
- kt = new kelondroTree(theLocation, cacheSize, kelondroTree.defaultObjectCachePercent, plasmaURL.urlHashLength, plasmaWordIndexEntryInstance.encodedStringFormLength(), false);
+ kt = new kelondroTree(theLocation, cacheSize, kelondroTree.defaultObjectCachePercent, indexURL.urlHashLength, plasmaWordIndexEntryInstance.encodedStringFormLength(), false);
}
return kt; // everyone who get this should close it when finished!
}
diff --git a/source/de/anomic/plasma/plasmaWordIndexEntryInstance.java b/source/de/anomic/plasma/plasmaWordIndexEntryInstance.java
index 9dc680d7c..6dc52bc96 100644
--- a/source/de/anomic/plasma/plasmaWordIndexEntryInstance.java
+++ b/source/de/anomic/plasma/plasmaWordIndexEntryInstance.java
@@ -53,6 +53,7 @@ import java.util.Properties;
import de.anomic.index.indexEntry;
import de.anomic.index.indexEntryAttribute;
import de.anomic.index.indexEntryPrototype;
+import de.anomic.index.indexURL;
import de.anomic.kelondro.kelondroBase64Order;
public final class plasmaWordIndexEntryInstance extends indexEntryPrototype implements Cloneable, indexEntry {
@@ -89,7 +90,7 @@ public final class plasmaWordIndexEntryInstance extends indexEntryPrototype impl
// - boolean: appearance attributes: title, appears in header, anchor-descr, image-tag etc
// - boolean: URL attributes
- if ((language == null) || (language.length() != plasmaURL.urlLanguageLength)) language = "uk";
+ if ((language == null) || (language.length() != indexURL.urlLanguageLength)) language = "uk";
this.urlHash = urlHash;
this.hitcount = hitcount;
this.wordcount = wordcount;
@@ -163,7 +164,7 @@ public final class plasmaWordIndexEntryInstance extends indexEntryPrototype impl
// if you need a complete dump, use toExternalForm()
StringBuffer buf = new StringBuffer(encodedStringFormLength());
- buf.append(kelondroBase64Order.enhancedCoder.encodeLongSmart(this.quality, plasmaURL.urlQualityLength))
+ buf.append(kelondroBase64Order.enhancedCoder.encodeLongSmart(this.quality, indexURL.urlQualityLength))
.append(kelondroBase64Order.enhancedCoder.encodeLongSmart(plasmaWordIndex.microDateDays(this.lastModified), 3))
.append(kelondroBase64Order.enhancedCoder.encodeLongSmart(this.hitcount, 2))
.append(new String(this.language))
@@ -193,7 +194,7 @@ public final class plasmaWordIndexEntryInstance extends indexEntryPrototype impl
str.append("{")
.append( "h=").append(this.urlHash)
- .append(",q=").append(kelondroBase64Order.enhancedCoder.encodeLongSmart(this.quality, plasmaURL.urlQualityLength))
+ .append(",q=").append(kelondroBase64Order.enhancedCoder.encodeLongSmart(this.quality, indexURL.urlQualityLength))
.append(",a=").append(kelondroBase64Order.enhancedCoder.encodeLongSmart(plasmaWordIndex.microDateDays(this.lastModified), 3))
.append(",c=").append(kelondroBase64Order.enhancedCoder.encodeLongSmart(this.hitcount, 2))
.append(",l=").append(new String(this.language))
diff --git a/source/de/anomic/urlRedirector/urlRedirectord.java b/source/de/anomic/urlRedirector/urlRedirectord.java
index 744e1e642..73952b169 100644
--- a/source/de/anomic/urlRedirector/urlRedirectord.java
+++ b/source/de/anomic/urlRedirector/urlRedirectord.java
@@ -11,10 +11,10 @@ import java.util.Date;
import de.anomic.data.userDB;
import de.anomic.http.httpHeader;
import de.anomic.http.httpc;
+import de.anomic.index.indexURL;
import de.anomic.plasma.plasmaCrawlProfile;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.plasma.plasmaURL;
import de.anomic.server.serverCore;
import de.anomic.server.serverHandler;
import de.anomic.server.logging.serverLog;
@@ -189,7 +189,7 @@ public class urlRedirectord implements serverHandler {
header.mime())
) {
// first delete old entry, if exists
- String urlhash = plasmaURL.urlHash(this.nextURL);
+ String urlhash = indexURL.urlHash(this.nextURL);
switchboard.urlPool.loadedURL.remove(urlhash);
switchboard.urlPool.noticeURL.remove(urlhash);
switchboard.urlPool.errorURL.remove(urlhash);
diff --git a/source/yacy.java b/source/yacy.java
index 4f54f22d3..ecc50a8cf 100644
--- a/source/yacy.java
+++ b/source/yacy.java
@@ -73,12 +73,12 @@ import de.anomic.http.httpdFileHandler;
import de.anomic.http.httpdProxyHandler;
import de.anomic.http.httpc.response;
import de.anomic.index.indexEntryAttribute;
+import de.anomic.index.indexURL;
import de.anomic.kelondro.kelondroDyn;
import de.anomic.kelondro.kelondroMScoreCluster;
import de.anomic.kelondro.kelondroMap;
import de.anomic.plasma.plasmaCrawlLURL;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.plasma.plasmaURL;
import de.anomic.plasma.plasmaURLPool;
import de.anomic.plasma.plasmaWordIndex;
import de.anomic.plasma.plasmaWordIndexAssortment;
@@ -628,7 +628,7 @@ public final class yacy {
kelondroMScoreCluster hs = new kelondroMScoreCluster();
while (ef.hasMoreElements()) {
f = (File) ef.nextElement();
- h = f.getName().substring(0, plasmaURL.urlHashLength);
+ h = f.getName().substring(0, indexURL.urlHashLength);
hs.addScore(h, (int) f.length());
}