Skip to content

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

continuing String-hash - to - byte[]-hash redesign that was started in SVN 6775

orbiter25aef069a683
diff --git a/htroot/Bookmarks.java b/htroot/Bookmarks.java
index de4509c6d..6216f5afa 100644
--- a/htroot/Bookmarks.java
+++ b/htroot/Bookmarks.java
@@ -185,7 +185,7 @@ public class Bookmarks {
final bookmarksDB.Bookmark bookmark = sb.bookmarksDB.getBookmark(urlHash);
if (bookmark == null) {
// try to get the bookmark from the LURL database
- final URIMetadataRow urlentry = sb.indexSegments.urlMetadata(Segments.Process.PUBLIC).load(urlHash, null, 0);
+ final URIMetadataRow urlentry = sb.indexSegments.urlMetadata(Segments.Process.PUBLIC).load(urlHash.getBytes(), null, 0);
Document document = null;
if (urlentry != null) {
final URIMetadataRow.Components metadata = urlentry.metadata();
diff --git a/htroot/CrawlProfileEditor_p.java b/htroot/CrawlProfileEditor_p.java
index feb676da4..893cf0a7c 100644
--- a/htroot/CrawlProfileEditor_p.java
+++ b/htroot/CrawlProfileEditor_p.java
@@ -28,6 +28,7 @@ import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Iterator;
+import net.yacy.kelondro.index.RowSpaceExceededException;
import net.yacy.kelondro.logging.Log;
import de.anomic.crawler.CrawlProfile;
@@ -91,13 +92,17 @@ public class CrawlProfileEditor_p {
// termination of a crawl: shift the crawl from active to passive
final CrawlProfile.entry entry = sb.crawler.profilesActiveCrawls.getEntry(handle);
if (entry != null) sb.crawler.profilesPassiveCrawls.newEntry(entry.map());
- sb.crawler.profilesActiveCrawls.removeEntry(handle);
+ sb.crawler.profilesActiveCrawls.removeEntry(handle.getBytes());
// delete all entries from the crawl queue that are deleted here
- sb.crawlQueues.noticeURL.removeByProfileHandle(handle, 10000);
+ try {
+ sb.crawlQueues.noticeURL.removeByProfileHandle(handle, 10000);
+ } catch (RowSpaceExceededException e) {
+ Log.logException(e);
+ }
}
if (post.containsKey("delete")) {
// deletion of a terminated crawl profile
- sb.crawler.profilesPassiveCrawls.removeEntry(handle);
+ sb.crawler.profilesPassiveCrawls.removeEntry(handle.getBytes());
}
if (post.containsKey("deleteTerminatedProfiles")) {
Iterator<CrawlProfile.entry> profiles = sb.crawler.profilesPassiveCrawls.profiles(false);
diff --git a/htroot/CrawlResults.java b/htroot/CrawlResults.java
index 41df95519..97b7477ce 100644
--- a/htroot/CrawlResults.java
+++ b/htroot/CrawlResults.java
@@ -186,7 +186,7 @@ public class CrawlResults {
while (i.hasNext()) {
entry = i.next();
try {
- urle = sb.indexSegments.urlMetadata(Segments.Process.LOCALCRAWLING).load(entry.getKey(), null, 0);
+ urle = sb.indexSegments.urlMetadata(Segments.Process.LOCALCRAWLING).load(entry.getKey().getBytes(), null, 0);
if(urle == null) {
Log.logWarning("PLASMA", "CrawlResults: URL not in index for crawl result "+ i +" with hash "+ entry.getKey());
urlstr = null;
@@ -197,8 +197,8 @@ public class CrawlResults {
urlstr = metadata.url().toNormalform(false, true);
urltxt = nxTools.shortenURLString(urlstr, 72); // shorten the string text like a URL
}
- initiatorSeed = sb.peers.getConnected(entry.getValue().initiatorHash);
- executorSeed = sb.peers.getConnected(entry.getValue().executorHash);
+ initiatorSeed = sb.peers.getConnected(new String(entry.getValue().initiatorHashb));
+ executorSeed = sb.peers.getConnected(new String(entry.getValue().executorHashb));
prop.put("table_indexed_" + cnt + "_dark", (dark) ? "1" : "0");
prop.put("table_indexed_" + cnt + "_feedbackpage", "CrawlResults.html");
diff --git a/htroot/Crawler_p.java b/htroot/Crawler_p.java
index e95865164..1cf184b87 100644
--- a/htroot/Crawler_p.java
+++ b/htroot/Crawler_p.java
@@ -228,7 +228,7 @@ public class Crawler_p {
// stack request
// first delete old entry, if exists
final DigestURI url = new DigestURI(crawlingStart, null);
- final byte[] urlhash = url.hash().getBytes();
+ final byte[] urlhash = url.hash();
indexSegment.urlMetadata().remove(urlhash);
sb.crawlQueues.noticeURL.removeByURLHash(urlhash);
sb.crawlQueues.errorURL.remove(urlhash);
@@ -246,7 +246,7 @@ public class Crawler_p {
indexText, indexMedia,
storeHTCache, true, crawlOrder, xsstopw, xdstopw, xpstopw, cachePolicy);
final String reasonString = sb.crawlStacker.stackCrawl(new Request(
- sb.peers.mySeed().hash,
+ sb.peers.mySeed().hash.getBytes(),
url,
null,
"CRAWLING-ROOT",
@@ -300,9 +300,9 @@ public class Crawler_p {
sb.crawlQueues.errorURL.push(
new Request(
- sb.peers.mySeed().hash,
+ sb.peers.mySeed().hash.getBytes(),
crawlingStartURL,
- "",
+ null,
"",
new Date(),
null,
@@ -310,7 +310,7 @@ public class Crawler_p {
0,
0,
0),
- sb.peers.mySeed().hash,
+ sb.peers.mySeed().hash.getBytes(),
new Date(),
1,
reasonString);
@@ -383,9 +383,9 @@ public class Crawler_p {
// enqueuing the url for crawling
sb.crawlStacker.enqueueEntry(new Request(
- sb.peers.mySeed().hash,
+ sb.peers.mySeed().hash.getBytes(),
nexturl,
- "",
+ null,
e.getValue(),
new Date(),
null,
diff --git a/htroot/IndexControlRWIs_p.java b/htroot/IndexControlRWIs_p.java
index dcd1c4df3..e1d1c00ae 100644
--- a/htroot/IndexControlRWIs_p.java
+++ b/htroot/IndexControlRWIs_p.java
@@ -163,7 +163,7 @@ public class IndexControlRWIs_p {
index = null;
}
if (delurlref) {
- for (i = 0; i < urlx.length; i++) segment.removeAllUrlReferences(urlx[i], sb.loader, true);
+ for (i = 0; i < urlx.length; i++) segment.removeAllUrlReferences(urlx[i].getBytes(), sb.loader, true);
}
// delete the word first because that is much faster than the deletion of the urls from the url database
segment.termIndex().delete(keyhash);
@@ -182,7 +182,7 @@ public class IndexControlRWIs_p {
// delete selected URLs
if (post.containsKey("keyhashdelete")) try {
if (delurlref) {
- for (i = 0; i < urlx.length; i++) segment.removeAllUrlReferences(urlx[i], sb.loader, true);
+ for (i = 0; i < urlx.length; i++) segment.removeAllUrlReferences(urlx[i].getBytes(), sb.loader, true);
}
if (delurl || delurlref) {
for (i = 0; i < urlx.length; i++) {
@@ -244,7 +244,7 @@ public class IndexControlRWIs_p {
URIMetadataRow lurl;
while (urlIter.hasNext()) {
iEntry = urlIter.next();
- lurl = segment.urlMetadata().load(iEntry.metadataHash(), null, 0);
+ lurl = segment.urlMetadata().load(iEntry.metadataHash().getBytes(), null, 0);
if (lurl == null) {
unknownURLEntries.add(iEntry.metadataHash());
urlIter.remove();
@@ -312,7 +312,7 @@ public class IndexControlRWIs_p {
DigestURI url;
for (i = 0; i < urlx.length; i++) {
urlHashes.add(urlx[i]);
- final URIMetadataRow e = segment.urlMetadata().load(urlx[i], null, 0);
+ final URIMetadataRow e = segment.urlMetadata().load(urlx[i].getBytes(), null, 0);
segment.urlMetadata().remove(urlx[i].getBytes());
if (e != null) {
url = e.metadata().url();
@@ -341,7 +341,7 @@ public class IndexControlRWIs_p {
DigestURI url;
for (i = 0; i<urlx.length; i++) {
urlHashes.add(urlx[i]);
- final URIMetadataRow e = segment.urlMetadata().load(urlx[i], null, 0);
+ final URIMetadataRow e = segment.urlMetadata().load(urlx[i].getBytes(), null, 0);
segment.urlMetadata().remove(urlx[i].getBytes());
if (e != null) {
url = e.metadata().url();
@@ -437,7 +437,7 @@ public class IndexControlRWIs_p {
((entry.word().flags().get(WordReferenceRow.flag_app_dc_subject)) ? "appears in subject, " : "") +
((entry.word().flags().get(WordReferenceRow.flag_app_dc_description)) ? "appears in description, " : "") +
((entry.word().flags().get(WordReferenceRow.flag_app_emphasized)) ? "appears emphasized, " : "") +
- ((DigestURI.probablyRootURL(entry.word().metadataHash())) ? "probably root url" : "")
+ ((DigestURI.probablyRootURL(entry.word().metadataHash().getBytes())) ? "probably root url" : "")
);
if (Switchboard.urlBlacklist.isListed(Blacklist.BLACKLIST_DHT, url)) {
prop.put("genUrlList_urlList_"+i+"_urlExists_urlhxChecked", "1");
diff --git a/htroot/IndexControlURLs_p.java b/htroot/IndexControlURLs_p.java
index a12c86262..f8d8f3a89 100644
--- a/htroot/IndexControlURLs_p.java
+++ b/htroot/IndexControlURLs_p.java
@@ -140,14 +140,14 @@ public class IndexControlURLs_p {
prop.put("result", " ");
if (post.containsKey("urlhashdeleteall")) {
- i = segment.removeAllUrlReferences(urlhash, sb.loader, true);
+ i = segment.removeAllUrlReferences(urlhash.getBytes(), sb.loader, true);
prop.put("result", "Deleted URL and " + i + " references from " + i + " word indexes.");
prop.put("lurlexport", 0);
prop.put("reload", 0);
}
if (post.containsKey("urlhashdelete")) {
- final URIMetadataRow entry = segment.urlMetadata().load(urlhash, null, 0);
+ final URIMetadataRow entry = segment.urlMetadata().load(urlhash.getBytes(), null, 0);
if (entry == null) {
prop.putHTML("result", "No Entry for URL hash " + urlhash + "; nothing deleted.");
} else {
@@ -162,7 +162,7 @@ public class IndexControlURLs_p {
if (post.containsKey("urldelete")) {
try {
- urlhash = (new DigestURI(urlstring, null)).hash();
+ urlhash = new String((new DigestURI(urlstring, null)).hash());
} catch (final MalformedURLException e) {
urlhash = null;
}
@@ -179,9 +179,9 @@ public class IndexControlURLs_p {
if (post.containsKey("urlstringsearch")) {
try {
final DigestURI url = new DigestURI(urlstring, null);
- urlhash = url.hash();
+ urlhash = new String(url.hash());
prop.put("urlhash", urlhash);
- final URIMetadataRow entry = segment.urlMetadata().load(urlhash, null, 0);
+ final URIMetadataRow entry = segment.urlMetadata().load(urlhash.getBytes(), null, 0);
if (entry == null) {
prop.putHTML("result", "No Entry for URL " + url.toNormalform(true, true));
prop.putHTML("urlstring", urlstring);
@@ -199,7 +199,7 @@ public class IndexControlURLs_p {
}
if (post.containsKey("urlhashsearch")) {
- final URIMetadataRow entry = segment.urlMetadata().load(urlhash, null, 0);
+ final URIMetadataRow entry = segment.urlMetadata().load(urlhash.getBytes(), null, 0);
if (entry == null) {
prop.putHTML("result", "No Entry for URL hash " + urlhash);
} else {
@@ -326,7 +326,7 @@ public class IndexControlURLs_p {
return prop;
}
final URIMetadataRow.Components metadata = entry.metadata();
- final URIMetadataRow le = ((entry.referrerHash() == null) || (entry.referrerHash().length() != Word.commonHashLength)) ? null : segment.urlMetadata().load(entry.referrerHash(), null, 0);
+ final URIMetadataRow le = (entry.referrerHash() == null || entry.referrerHash().length != Word.commonHashLength) ? null : segment.urlMetadata().load(entry.referrerHash(), null, 0);
if (metadata == null || metadata.url() == null) {
prop.put("genUrlProfile", "1");
prop.put("genUrlProfile_urlhash", urlhash);
diff --git a/htroot/IndexCreateLoaderQueue_p.java b/htroot/IndexCreateLoaderQueue_p.java
index 9acee7df4..3a19c37fb 100644
--- a/htroot/IndexCreateLoaderQueue_p.java
+++ b/htroot/IndexCreateLoaderQueue_p.java
@@ -53,7 +53,7 @@ public class IndexCreateLoaderQueue_p {
for (int i = 0; i < w.length; i++) {
if (w[i] == null) continue;
- initiator = sb.peers.getConnected(w[i].initiator());
+ initiator = sb.peers.getConnected(new String(w[i].initiator()));
prop.put("loader-set_list_"+count+"_dark", dark ? "1" : "0");
prop.putHTML("loader-set_list_"+count+"_initiator", ((initiator == null) ? "proxy" : initiator.getName()));
prop.put("loader-set_list_"+count+"_depth", w[i].depth());
diff --git a/htroot/IndexCreateParserErrors_p.java b/htroot/IndexCreateParserErrors_p.java
index dc60c2d9d..f535710fd 100644
--- a/htroot/IndexCreateParserErrors_p.java
+++ b/htroot/IndexCreateParserErrors_p.java
@@ -70,7 +70,7 @@ public class IndexCreateParserErrors_p {
}
dark = true;
DigestURI url;
- String initiatorHash, executorHash;
+ byte[] initiatorHash, executorHash;
yacySeed initiatorSeed, executorSeed;
int j=0;
ArrayList<ZURL.Entry> l = sb.crawlQueues.errorURL.list(showRejectedCount);
@@ -83,8 +83,8 @@ public class IndexCreateParserErrors_p {
initiatorHash = entry.initiator();
executorHash = entry.executor();
- initiatorSeed = sb.peers.getConnected(initiatorHash);
- executorSeed = sb.peers.getConnected(executorHash);
+ initiatorSeed = sb.peers.getConnected(new String(initiatorHash));
+ executorSeed = sb.peers.getConnected(new String(executorHash));
prop.putHTML("rejected_list_"+j+"_initiator", ((initiatorSeed == null) ? "proxy" : initiatorSeed.getName()));
prop.putHTML("rejected_list_"+j+"_executor", ((executorSeed == null) ? "proxy" : executorSeed.getName()));
prop.putHTML("rejected_list_"+j+"_url", url.toNormalform(false, true));
diff --git a/htroot/IndexCreateWWWGlobalQueue_p.java b/htroot/IndexCreateWWWGlobalQueue_p.java
index 7677d2c89..4b6ea43b4 100644
--- a/htroot/IndexCreateWWWGlobalQueue_p.java
+++ b/htroot/IndexCreateWWWGlobalQueue_p.java
@@ -98,8 +98,8 @@ public class IndexCreateWWWGlobalQueue_p {
int i, showNum = 0;
for (i = 0; (i < crawlerList.size()) && (showNum < showLimit); i++) {
urle = crawlerList.get(i);
- if ((urle != null)&&(urle.url()!=null)) {
- initiator = sb.peers.getConnected(urle.initiator());
+ if (urle != null && urle.url() != null) {
+ initiator = sb.peers.getConnected(urle.initiator() == null ? "" : new String(urle.initiator()));
profileHandle = urle.profileHandle();
profileEntry = (profileHandle == null) ? null : sb.crawler.profilesActiveCrawls.getEntry(profileHandle);
prop.put("crawler-queue_list_"+showNum+"_dark", dark ? "1" : "0");
diff --git a/htroot/IndexCreateWWWLocalQueue_p.java b/htroot/IndexCreateWWWLocalQueue_p.java
index 4f24013a8..097ec71b2 100644
--- a/htroot/IndexCreateWWWLocalQueue_p.java
+++ b/htroot/IndexCreateWWWLocalQueue_p.java
@@ -109,7 +109,7 @@ public class IndexCreateWWWLocalQueue_p {
name.equals(CrawlSwitchboard.CRAWL_PROFILE_SURROGATE))
continue;
if (compiledPattern.matcher(name).find()) {
- sb.crawler.profilesActiveCrawls.removeEntry(entry.handle());
+ sb.crawler.profilesActiveCrawls.removeEntry(entry.handle().getBytes());
}
}
} else {
@@ -125,7 +125,7 @@ public class IndexCreateWWWLocalQueue_p {
case ANCHOR: value = entry.name(); break;
case DEPTH: value = Integer.toString(entry.depth()); break;
case INITIATOR:
- value = (entry.initiator() == null || entry.initiator().length() == 0) ? "proxy" : entry.initiator();
+ value = (entry.initiator() == null || entry.initiator().length == 0) ? "proxy" : new String(entry.initiator());
break;
case MODIFIED: value = daydate(entry.loaddate()); break;
default: value = null;
@@ -134,7 +134,7 @@ public class IndexCreateWWWLocalQueue_p {
if (value != null) {
final Matcher matcher = compiledPattern.matcher(value);
if (matcher.find()) {
- sb.crawlQueues.noticeURL.removeByURLHash(entry.url().hash().getBytes());
+ sb.crawlQueues.noticeURL.removeByURLHash(entry.url().hash());
}
}
}
@@ -170,7 +170,7 @@ public class IndexCreateWWWLocalQueue_p {
for (i = 0; (i < crawlerList.size()) && (showNum < showLimit); i++) {
urle = crawlerList.get(i);
if ((urle != null)&&(urle.url()!=null)) {
- initiator = sb.peers.getConnected(urle.initiator());
+ initiator = sb.peers.getConnected(urle.initiator() == null ? "" : new String(urle.initiator()));
profileHandle = urle.profileHandle();
profileEntry = (profileHandle == null) ? null : sb.crawler.profilesActiveCrawls.getEntry(profileHandle);
prop.put("crawler-queue_list_"+showNum+"_dark", dark ? "1" : "0");
diff --git a/htroot/IndexCreateWWWRemoteQueue_p.java b/htroot/IndexCreateWWWRemoteQueue_p.java
index 6edc377c6..821add7ae 100644
--- a/htroot/IndexCreateWWWRemoteQueue_p.java
+++ b/htroot/IndexCreateWWWRemoteQueue_p.java
@@ -96,7 +96,7 @@ public class IndexCreateWWWRemoteQueue_p {
for (i = 0; (i < crawlerList.size()) && (showNum < showLimit); i++) {
urle = crawlerList.get(i);
if (urle != null && urle.url() != null) {
- initiator = sb.peers.getConnected(urle.initiator());
+ initiator = sb.peers.getConnected(urle.initiator() == null ? "" : new String(urle.initiator()));
profileHandle = urle.profileHandle();
profileEntry = (profileHandle == null) ? null : sb.crawler.profilesActiveCrawls.getEntry(profileHandle);
prop.put("crawler-queue_list_" + showNum + "_dark", dark ? "1" : "0");
diff --git a/htroot/QuickCrawlLink_p.java b/htroot/QuickCrawlLink_p.java
index 8f0d94466..134d40712 100644
--- a/htroot/QuickCrawlLink_p.java
+++ b/htroot/QuickCrawlLink_p.java
@@ -137,7 +137,7 @@ public class QuickCrawlLink_p {
return prop;
}
- final byte[] urlhash = crawlingStartURL.hash().getBytes();
+ final byte[] urlhash = crawlingStartURL.hash();
indexSegment.urlMetadata().remove(urlhash);
sb.crawlQueues.noticeURL.removeByURLHash(urlhash);
sb.crawlQueues.errorURL.remove(urlhash);
@@ -176,7 +176,7 @@ public class QuickCrawlLink_p {
// stack URL
String reasonString = null;
reasonString = sb.crawlStacker.stackCrawl(new Request(
- sb.peers.mySeed().hash,
+ sb.peers.mySeed().hash.getBytes(),
crawlingStartURL,
null,
(title==null)?"CRAWLING-ROOT":title,
diff --git a/htroot/RSSLoader_p.java b/htroot/RSSLoader_p.java
new file mode 100644
index 000000000..0b673500f
--- /dev/null
+++ b/htroot/RSSLoader_p.java
@@ -0,0 +1,120 @@
+//ViewFile.java
+//-----------------------
+//part of YaCy
+//(C) by Michael Peter Christen; [email protected]
+//first published on http://www.anomic.de
+//Frankfurt, Germany, 2004
+
+//last major change: 12.07.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
+
+//you must compile this file with
+//javac -classpath .:../Classes Status.java
+//if the shell's current path is HTROOT
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.util.Map;
+
+import net.yacy.document.Document;
+import net.yacy.document.ParserException;
+import net.yacy.document.parser.rssParser;
+import net.yacy.kelondro.data.meta.DigestURI;
+import net.yacy.kelondro.logging.Log;
+
+import de.anomic.crawler.retrieval.Response;
+import de.anomic.http.client.Cache;
+import de.anomic.http.server.RequestHeader;
+import de.anomic.http.server.ResponseHeader;
+import de.anomic.search.Segment;
+import de.anomic.search.Segments;
+import de.anomic.search.Switchboard;
+import de.anomic.server.serverObjects;
+import de.anomic.server.serverSwitch;
+
+public class RSSLoader_p {
+
+ public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
+
+ final serverObjects prop = new serverObjects();
+ final Switchboard sb = (Switchboard)env;
+
+ if (post == null) {
+ return prop;
+ }
+
+ // get segment
+ Segment indexSegment = null;
+ if (post.containsKey("segment")) {
+ String segmentName = post.get("segment");
+ if (sb.indexSegments.segmentExist(segmentName)) {
+ indexSegment = sb.indexSegments.segment(segmentName);
+ }
+ } else {
+ // take default segment
+ indexSegment = sb.indexSegments.segment(Segments.Process.PUBLIC);
+ }
+
+ DigestURI url = null;
+
+ final String urlString = post.get("url", "");
+ if (urlString.length() > 0) try {
+ url = new DigestURI(urlString, null);
+ } catch (final MalformedURLException e) {
+ return prop;
+ }
+
+
+ // if the resource body was not cached we try to load it from web
+ Response entry = null;
+ try {
+ entry = sb.loader.load(url, true, false);
+ } catch (final Exception e) {
+ return prop;
+ }
+ if (entry == null) return prop;
+
+ byte[] resource = entry.getContent();
+
+ if (resource == null) {
+ return prop;
+ }
+
+ // now parse the content as rss
+ ByteArrayInputStream bais = new ByteArrayInputStream(resource);
+ rssParser parser = new rssParser();
+ Document doc;
+ try {
+ doc = parser.parse(url, "text/rss", "UTF-8", bais);
+ } catch (ParserException e) {
+ return prop;
+ } catch (InterruptedException e) {
+ return prop;
+ }
+
+ // get the links out of the rss
+ Map<DigestURI, String> map = doc.getAnchors();
+
+ // put the urls into crawler using the proxy profile
+
+
+
+ return prop;
+ }
+
+}
diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.java
index dbd390221..1ec681c4e 100644
--- a/htroot/SettingsAck_p.java
+++ b/htroot/SettingsAck_p.java
@@ -35,6 +35,7 @@ import java.util.StringTokenizer;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
+import net.yacy.kelondro.data.meta.DigestURI;
import net.yacy.kelondro.order.Base64Order;
import net.yacy.kelondro.order.Digest;
import net.yacy.kelondro.util.DateFormatter;
@@ -62,8 +63,8 @@ public class SettingsAck_p {
final Switchboard sb = (Switchboard) env;
// get referer for backlink
- final String referer = header.referer();
- prop.put("referer", (referer == null) ? "Settings_p.html" : referer);
+ final DigestURI referer = header.referer();
+ prop.put("referer", (referer == null) ? "Settings_p.html" : referer.toNormalform(true, true));
//if (post == null) System.out.println("POST: NULL"); else System.out.println("POST: " + post.toString());
if (post == null) {
diff --git a/htroot/Supporter.java b/htroot/Supporter.java
index d116e9bee..1d8f07dc0 100644
--- a/htroot/Supporter.java
+++ b/htroot/Supporter.java
@@ -126,7 +126,7 @@ public class Supporter {
url = row.getColString(0, null);
try {
- if (Switchboard.urlBlacklist.isListed(Blacklist.BLACKLIST_SURFTIPS ,new DigestURI(url, urlhash))) continue;
+ if (Switchboard.urlBlacklist.isListed(Blacklist.BLACKLIST_SURFTIPS, new DigestURI(url, urlhash.getBytes()))) continue;
} catch(final MalformedURLException e) {continue;}
title = row.getColString(1,"UTF-8");
description = row.getColString(2,"UTF-8");
@@ -242,13 +242,13 @@ public class Supporter {
// add/subtract votes and write record
if (entry != null) {
try {
- urlhash = (new DigestURI(url, null)).hash();
+ urlhash = new String((new DigestURI(url, null)).hash());
} catch (final MalformedURLException e) {
urlhash = null;
}
if (urlhash == null)
try {
- urlhash = (new DigestURI("http://" + url, null)).hash();
+ urlhash = new String((new DigestURI("http://" + url, null)).hash());
} catch (final MalformedURLException e) {
urlhash = null;
}
diff --git a/htroot/Surftips.java b/htroot/Surftips.java
index 5c7f791bf..28acccb64 100644
--- a/htroot/Surftips.java
+++ b/htroot/Surftips.java
@@ -304,13 +304,13 @@ public class Surftips {
// add/subtract votes and write record
if (entry != null) {
try {
- urlhash = (new DigestURI(url, null)).hash();
+ urlhash = new String((new DigestURI(url, null)).hash());
} catch (final MalformedURLException e) {
urlhash = null;
}
if (urlhash == null)
try {
- urlhash = (new DigestURI("http://"+url, null)).hash();
+ urlhash = new String((new DigestURI("http://"+url, null)).hash());
} catch (final MalformedURLException e) {
urlhash = null;
}
diff --git a/htroot/ViewFile.java b/htroot/ViewFile.java
index 7941032e2..8327cb98f 100644
--- a/htroot/ViewFile.java
+++ b/htroot/ViewFile.java
@@ -120,10 +120,10 @@ public class ViewFile {
boolean pre = false;
// get the url hash from which the content should be loaded
- String urlHash = post.get("urlHash","");
+ String urlHash = post.get("urlHash", "");
URIMetadataRow urlEntry = null;
// get the urlEntry that belongs to the url hash
- if (urlHash.length() > 0 && (urlEntry = indexSegment.urlMetadata().load(urlHash, null, 0)) != null) {
+ if (urlHash.length() > 0 && (urlEntry = indexSegment.urlMetadata().load(urlHash.getBytes(), null, 0)) != null) {
// get the url that belongs to the entry
final URIMetadataRow.Components metadata = urlEntry.metadata();
if ((metadata == null) || (metadata.url() == null)) {
@@ -154,7 +154,7 @@ public class ViewFile {
// define an url by post parameter
url = new DigestURI(urlString, null);
- urlHash = url.hash();
+ urlHash = new String(url.hash());
pre = post.get("pre", "false").equals("true");
} catch (final MalformedURLException e) {}
diff --git a/htroot/WebStructurePicture_p.java b/htroot/WebStructurePicture_p.java
index 2a3bad89a..c052e958d 100644
--- a/htroot/WebStructurePicture_p.java
+++ b/htroot/WebStructurePicture_p.java
@@ -93,7 +93,7 @@ public class WebStructurePicture_p {
// find start hash
String hash = null;
try {
- hash = (new DigestURI("http://" + host, null)).hash().substring(6);
+ hash = new String((new DigestURI("http://" + host, null)).hash()).substring(6);
} catch (final MalformedURLException e) {Log.logException(e);}
//assert (sb.webStructure.outgoingReferences(hash) != null);
diff --git a/htroot/api/bookmarks/posts/delete_p.java b/htroot/api/bookmarks/posts/delete_p.java
index a77945241..5fa1c4440 100755
--- a/htroot/api/bookmarks/posts/delete_p.java
+++ b/htroot/api/bookmarks/posts/delete_p.java
@@ -23,11 +23,11 @@ public class delete_p {
return prop;
}
try {
- if( post.containsKey("url") && switchboard.bookmarksDB.removeBookmark((new DigestURI(post.get("url", "nourl"), null)).hash())) {
+ if (post.containsKey("url") && switchboard.bookmarksDB.removeBookmark(new String((new DigestURI(post.get("url", "nourl"), null)).hash()))) {
prop.put("result", "1");
- }else if(post.containsKey("urlhash") && switchboard.bookmarksDB.removeBookmark(post.get("urlhash", "nohash"))){
+ } else if (post.containsKey("urlhash") && switchboard.bookmarksDB.removeBookmark(post.get("urlhash", "nohash"))) {
prop.put("result", "1");
- }else{
+ } else {
prop.put("result", "0");
}
} catch (final MalformedURLException e) {
diff --git a/htroot/api/queues_p.java b/htroot/api/queues_p.java
index decbcdcbb..e7f749027 100755
--- a/htroot/api/queues_p.java
+++ b/htroot/api/queues_p.java
@@ -58,7 +58,7 @@ public class queues_p {
for (int i = 0; i < w.length; i++) {
if (w[i] == null) continue;
prop.put("list-loader_"+count+"_profile", w[i].profileHandle());
- initiator = sb.peers.getConnected(w[i].initiator());
+ initiator = sb.peers.getConnected(new String(w[i].initiator()));
prop.putHTML("list-loader_"+count+"_initiator", ((initiator == null) ? "proxy" : initiator.getName()));
prop.put("list-loader_"+count+"_depth", w[i].depth());
prop.putXML("list-loader_"+count+"_url", w[i].url().toString());
@@ -102,7 +102,7 @@ public class queues_p {
for (int i = 0; i < crawlerList.size(); i++) {
urle = crawlerList.get(i);
if ((urle != null) && (urle.url() != null)) {
- initiator = sb.peers.getConnected(urle.initiator());
+ initiator = sb.peers.getConnected(urle.initiator() == null ? "" : new String(urle.initiator()));
prop.put(tableName + "_" + showNum + "_profile", urle.profileHandle());
prop.put(tableName + "_" + showNum + "_initiator", ((initiator == null) ? "proxy" : initiator.getName()));
prop.put(tableName + "_" + showNum + "_depth", urle.depth());
diff --git a/htroot/api/webstructure.java b/htroot/api/webstructure.java
index 9b005c47b..078d1cfab 100644
--- a/htroot/api/webstructure.java
+++ b/htroot/api/webstructure.java
@@ -48,7 +48,7 @@ public class webstructure {
if (about.length() > 6) {
try {
url = new DigestURI(about, null);
- about = url.hash().substring(6);
+ about = new String(url.hash()).substring(6);
} catch (MalformedURLException e) {
about = null;
}
diff --git a/htroot/api/yacydoc.java b/htroot/api/yacydoc.java
index 24b42da8a..9efeaeda8 100644
--- a/htroot/api/yacydoc.java
+++ b/htroot/api/yacydoc.java
@@ -74,21 +74,21 @@ public class yacydoc {
if (urlstring.length() > 0 && urlhash.length() == 0) {
try {
- urlhash = (new DigestURI(urlstring, null)).hash();
+ urlhash = new String((new DigestURI(urlstring, null)).hash());
} catch (MalformedURLException e) {
Log.logException(e);
}
}
if (urlhash == null || urlhash.length() == 0) return prop;
- final URIMetadataRow entry = segment.urlMetadata().load(urlhash, null, 0);
+ final URIMetadataRow entry = segment.urlMetadata().load(urlhash.getBytes(), null, 0);
if (entry == null) return prop;
final URIMetadataRow.Components metadata = entry.metadata();
if (metadata.url() == null) {
return prop;
}
- final URIMetadataRow le = ((entry.referrerHash() == null) || (entry.referrerHash().length() != Word.commonHashLength)) ? null : segment.urlMetadata().load(entry.referrerHash(), null, 0);
+ final URIMetadataRow le = (entry.referrerHash() == null || entry.referrerHash().length != Word.commonHashLength) ? null : segment.urlMetadata().load(entry.referrerHash(), null, 0);
prop.putXML("dc_title", metadata.dc_title());
prop.putXML("dc_creator", metadata.dc_creator());
diff --git a/htroot/cytag.java b/htroot/cytag.java
index 7b73a291c..98a28c5ab 100644
--- a/htroot/cytag.java
+++ b/htroot/cytag.java
@@ -51,7 +51,7 @@ public class cytag {
StringBuilder connect = new StringBuilder();
connect.append('{');
addJSON(connect, "time", DateFormatter.formatShortMilliSecond(new Date()));
- addJSON(connect, "trail", header.referer());
+ addJSON(connect, "trail", header.referer().toNormalform(false, false));
addJSON(connect, "nick", (post == null) ? "" : post.get("nick", ""));
addJSON(connect, "tag", (post == null) ? "" : post.get("tag", ""));
addJSON(connect, "icon", (post == null) ? "" : post.get("icon", ""));
diff --git a/htroot/rct_p.java b/htroot/rct_p.java
index 7701bd63d..4e6c47398 100644
--- a/htroot/rct_p.java
+++ b/htroot/rct_p.java
@@ -79,7 +79,7 @@ public class rct_p {
// stack url
if (sb.getLog().isFinest()) sb.getLog().logFinest("crawlOrder: stack: url='" + url + "'");
sb.crawlStacker.enqueueEntry(new Request(
- peerhash,
+ peerhash.getBytes(),
url,
(referrer == null) ? null : referrer.hash(),
"REMOTE-CRAWLING",
diff --git a/htroot/yacy/crawlReceipt.java b/htroot/yacy/crawlReceipt.java
index 00c08c274..a0875f4da 100644
--- a/htroot/yacy/crawlReceipt.java
+++ b/htroot/yacy/crawlReceipt.java
@@ -140,7 +140,7 @@ public final class crawlReceipt {
if (result.equals("fill")) try {
// put new entry into database
sb.indexSegments.urlMetadata(Segments.Process.RECEIPTS).store(entry);
- sb.crawlResults.stack(entry, youare, iam, EventOrigin.REMOTE_RECEIPTS);
+ sb.crawlResults.stack(entry, youare.getBytes(), iam.getBytes(), EventOrigin.REMOTE_RECEIPTS);
sb.crawlQueues.delegatedURL.remove(entry.hash()); // the delegated work has been done
if (log.isInfo()) log.logInfo("crawlReceipt: RECEIVED RECEIPT from " + otherPeerName + " for URL " + new String(entry.hash()) + ":" + metadata.url().toNormalform(false, true));
@@ -156,7 +156,7 @@ public final class crawlReceipt {
sb.crawlQueues.delegatedURL.remove(entry.hash()); // the delegated work is transformed into an error case
sb.crawlQueues.errorURL.push(
entry.toBalancerEntry(iam),
- youare,
+ youare.getBytes(),
null,
0,
result + ":" + reason);
diff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.java
index a697de7af..d2927ecc0 100644
--- a/htroot/yacy/transferRWI.java
+++ b/htroot/yacy/transferRWI.java
@@ -189,7 +189,7 @@ public final class transferRWI {
// check if we need to ask for the corresponding URL
if (!(knownURL.contains(urlHash)||unknownURL.contains(urlHash))) try {
- if (sb.indexSegments.urlMetadata(Segments.Process.DHTIN).exists(urlHash)) {
+ if (sb.indexSegments.urlMetadata(Segments.Process.DHTIN).exists(urlHash.getBytes())) {
knownURL.add(urlHash);
} else {
unknownURL.add(urlHash);
diff --git a/htroot/yacy/transferURL.java b/htroot/yacy/transferURL.java
index dbf78897d..fd5748975 100644
--- a/htroot/yacy/transferURL.java
+++ b/htroot/yacy/transferURL.java
@@ -143,7 +143,7 @@ public final class transferURL {
if (yacyCore.log.isFine()) yacyCore.log.logFine("Accepting URL " + i + "/" + urlc + " from peer " + otherPeerName + ": " + lEntry.metadata().url().toNormalform(true, false));
try {
sb.indexSegments.urlMetadata(Segments.Process.DHTIN).store(lEntry);
- sb.crawlResults.stack(lEntry, iam, iam, EventOrigin.DHT_TRANSFER);
+ sb.crawlResults.stack(lEntry, iam.getBytes(), iam.getBytes(), EventOrigin.DHT_TRANSFER);
if (yacyCore.log.isFine()) yacyCore.log.logFine("transferURL: received URL '" + metadata.url().toNormalform(false, true) + "' from peer " + otherPeerName);
received++;
} catch (final IOException e) {
diff --git a/htroot/yacy/urls.java b/htroot/yacy/urls.java
index 540016f29..802c693e5 100644
--- a/htroot/yacy/urls.java
+++ b/htroot/yacy/urls.java
@@ -82,7 +82,7 @@ public class urls {
// place url to notice-url db
sb.crawlQueues.delegatedURL.push(
entry,
- sb.peers.mySeed().hash,
+ sb.peers.mySeed().hash.getBytes(),
new Date(),
0,
"client=____________");
@@ -112,7 +112,7 @@ public class urls {
URIMetadataRow.Components metadata;
DigestURI referrer;
for (int i = 0; i < count; i++) {
- entry = sb.indexSegments.urlMetadata(Segments.Process.PUBLIC).load(urlhashes.substring(12 * i, 12 * (i + 1)), null, 0);
+ entry = sb.indexSegments.urlMetadata(Segments.Process.PUBLIC).load(urlhashes.substring(12 * i, 12 * (i + 1)).getBytes(), null, 0);
if (entry == null) continue;
// find referrer, if there is one
referrer = sb.getURL(Segments.Process.PUBLIC, entry.referrerHash());
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java
index 5c11bb8d0..9c84fbb41 100644
--- a/htroot/yacysearch.java
+++ b/htroot/yacysearch.java
@@ -425,7 +425,7 @@ public class yacysearch {
return prop;
}
final String recommendHash = post.get("recommendref", ""); // urlhash
- final URIMetadataRow urlentry = indexSegment.urlMetadata().load(recommendHash, null, 0);
+ final URIMetadataRow urlentry = indexSegment.urlMetadata().load(recommendHash.getBytes(), null, 0);
if (urlentry != null) {
final URIMetadataRow.Components metadata = urlentry.metadata();
Document document;
diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.java
index 899369955..68f8a868f 100644
--- a/htroot/yacysearchitem.java
+++ b/htroot/yacysearchitem.java
@@ -146,8 +146,8 @@ public class yacysearchitem {
} catch (final UnsupportedEncodingException e) {}
prop.putHTML("content_former", theQuery.queryString);
prop.put("content_rankingprops", result.word().toPropertyForm() + ", domLengthEstimated=" + DigestURI.domLengthEstimation(result.hash()) +
- ((DigestURI.probablyRootURL(new String(result.hash()))) ? ", probablyRootURL" : "") +
- (((wordURL = DigestURI.probablyWordURL(new String(result.hash()), query[0])) != null) ? ", probablyWordURL=" + wordURL.toNormalform(false, true) : ""));
+ ((DigestURI.probablyRootURL(result.hash())) ? ", probablyRootURL" : "") +
+ (((wordURL = DigestURI.probablyWordURL(result.hash(), query[0])) != null) ? ", probablyWordURL=" + wordURL.toNormalform(false, true) : ""));
final TextSnippet snippet = result.textSnippet();
final String desc = (snippet == null) ? "" : snippet.getLineMarked(theQuery.fullqueryHashes);
prop.put("content_description", desc);
@@ -175,7 +175,7 @@ public class yacysearchitem {
prop.put("content_item_width", ms.width);
prop.put("content_item_height", ms.height);
prop.put("content_item_attr", (ms.attr.equals("-1 x -1")) ? "" : "(" + ms.attr + ")"); // attributes, here: original size of image
- prop.put("content_item_urlhash", ms.source.hash());
+ prop.put("content_item_urlhash", new String(ms.source.hash()));
prop.put("content_item_source", ms.source.toNormalform(true, false));
prop.putXML("content_item_source-xml", ms.source.toNormalform(true, false));
prop.put("content_item_sourcedom", ms.source.getHost());
diff --git a/source/de/anomic/crawler/Balancer.java b/source/de/anomic/crawler/Balancer.java
index 7419e5e8a..9d524f7bd 100644
--- a/source/de/anomic/crawler/Balancer.java
+++ b/source/de/anomic/crawler/Balancer.java
@@ -25,7 +25,6 @@ package de.anomic.crawler;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
@@ -33,12 +32,15 @@ import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
+import net.yacy.kelondro.index.HandleSet;
import net.yacy.kelondro.index.ObjectIndex;
import net.yacy.kelondro.index.Row;
import net.yacy.kelondro.index.RowSpaceExceededException;
import net.yacy.kelondro.logging.Log;
+import net.yacy.kelondro.order.Base64Order;
import net.yacy.kelondro.order.CloneableIterator;
import net.yacy.kelondro.table.Table;
+import net.yacy.kelondro.util.ByteBuffer;
import de.anomic.crawler.retrieval.Request;
import de.anomic.http.client.Cache;
@@ -49,9 +51,9 @@ public class Balancer {
private static final int EcoFSBufferSize = 1000;
// class variables
- private final ConcurrentHashMap<String, LinkedList<String>> domainStacks; // a map from domain name part to Lists with url hashs
- private final ConcurrentLinkedQueue<String> top;
- private final TreeMap<Long, String> delayed;
+ private final ConcurrentHashMap<String, LinkedList<byte[]>> domainStacks; // a map from domain name part to Lists with url hashs
+ private final ConcurrentLinkedQueue<byte[]> top;
+ private final TreeMap<Long, byte[]> delayed;
protected ObjectIndex urlFileIndex;
private final File cacheStacksPath;
private long minimumLocalDelta;
@@ -67,9 +69,9 @@ public class Balancer {
final boolean useTailCache,
final boolean exceed134217727) {
this.cacheStacksPath = cachePath;
- this.domainStacks = new ConcurrentHashMap<String, LinkedList<String>>();
- this.top = new ConcurrentLinkedQueue<String>();
- this.delayed = new TreeMap<Long, String>();
+ this.domainStacks = new ConcurrentHashMap<String, LinkedList<byte[]>>();
+ this.top = new ConcurrentLinkedQueue<byte[]>();
+ this.delayed = new TreeMap<Long, byte[]>();
this.minimumLocalDelta = minimumLocalDelta;
this.minimumGlobalDelta = minimumGlobalDelta;
this.domStackInitSize = Integer.MAX_VALUE;
@@ -125,21 +127,21 @@ public class Balancer {
}
}
- public Request get(final String urlhash) throws IOException {
+ public Request get(final byte[] urlhash) throws IOException {
assert urlhash != null;
if (urlFileIndex == null) return null; // case occurs during shutdown
- final Row.Entry entry = urlFileIndex.get(urlhash.getBytes());
+ final Row.Entry entry = urlFileIndex.get(urlhash);
if (entry == null) return null;
return new Request(entry);
}
- public int removeAllByProfileHandle(final String profileHandle, final long timeout) throws IOException {
+ public int removeAllByProfileHandle(final String profileHandle, final long timeout) throws IOException, RowSpaceExceededException {
// removes all entries with a specific profile hash.
// this may last some time
// returns number of deletions
// first find a list of url hashes that shall be deleted
- final HashSet<String> urlHashes = new HashSet<String>();
+ final HandleSet urlHashes = Base64Order.enhancedCoder.getHandleSet(this.urlFileIndex.row().primaryKeyLength, 100);
final long terminate = (timeout > 0) ? System.currentTimeMillis() + timeout : Long.MAX_VALUE;
synchronized (this) {
final Iterator<Row.Entry> i = urlFileIndex.rows();
@@ -149,7 +151,7 @@ public class Balancer {
rowEntry = i.next();
crawlEntry = new Request(rowEntry);
if (crawlEntry.profileHandle().equals(profileHandle)) {
- urlHashes.add(crawlEntry.url().hash());
+ urlHashes.put(crawlEntry.url().hash());
}
}
}
@@ -166,42 +168,42 @@ public class Balancer {
* @return number of entries that had been removed
* @throws IOException
*/
- public synchronized int remove(final HashSet<String> urlHashes) throws IOException {
+ public synchronized int remove(final HandleSet urlHashes) throws IOException {
final int s = urlFileIndex.size();
int removedCounter = 0;
- for (final String urlhash: urlHashes) {
- final Row.Entry entry = urlFileIndex.remove(urlhash.getBytes());
+ for (final byte[] urlhash: urlHashes) {
+ final Row.Entry entry = urlFileIndex.remove(urlhash);
if (entry != null) removedCounter++;
}
if (removedCounter == 0) return 0;
assert urlFileIndex.size() + removedCounter == s : "urlFileIndex.size() = " + urlFileIndex.size() + ", s = " + s;
// iterate through the top list
- final Iterator<String> j = top.iterator();
- String urlhash;
+ final Iterator<byte[]> j = top.iterator();
+ byte[] urlhash;
while (j.hasNext()) {
urlhash = j.next();
- if (urlHashes.contains(urlhash)) j.remove();
+ if (urlHashes.has(urlhash)) j.remove();
}
// remove from delayed
synchronized (this.delayed) {
- final Iterator<Map.Entry<Long, String>> k = this.delayed.entrySet().iterator();
+ final Iterator<Map.Entry<Long, byte[]>> k = this.delayed.entrySet().iterator();
while (k.hasNext()) {
- if (urlHashes.contains(k.next().getValue())) k.remove();
+ if (urlHashes.has(k.next().getValue())) k.remove();
}
}
// iterate through the domain stacks
- final Iterator<Map.Entry<String, LinkedList<String>>> q = domainStacks.entrySet().iterator();
- Map.Entry<String, LinkedList<String>> se;
- LinkedList<String> stack;
+ final Iterator<Map.Entry<String, LinkedList<byte[]>>> q = domainStacks.entrySet().iterator();
+ Map.Entry<String, LinkedList<byte[]>> se;
+ LinkedList<byte[]> stack;
while (q.hasNext()) {
se = q.next();
stack = se.getValue();
- final Iterator<String> i = stack.iterator();
+ final Iterator<byte[]> i = stack.iterator();
while (i.hasNext()) {
- if (urlHashes.contains(i.next())) i.remove();
+ if (urlHashes.has(i.next())) i.remove();
}
if (stack.isEmpty()) q.remove();
}
@@ -230,7 +232,7 @@ public class Balancer {
private boolean domainStacksNotEmpty() {
if (domainStacks == null) return false;
synchronized (domainStacks) {
- final Iterator<LinkedList<String>> i = domainStacks.values().iterator();
+ final Iterator<LinkedList<byte[]>> i = domainStacks.values().iterator();
while (i.hasNext()) {
if (!i.next().isEmpty()) return true;
}
@@ -240,31 +242,30 @@ public class Balancer {
public void push(final Request entry) throws IOException, RowSpaceExceededException {
assert entry != null;
- final String hash = entry.url().hash();
+ final byte[] hash = entry.url().hash();
synchronized (this) {
- if (urlFileIndex.has(hash.getBytes())) {
- //Log.logWarning("BALANCER", "double-check has failed for urlhash " + entry.url().hash() + " in " + stackname + " - fixed");
+ if (urlFileIndex.has(hash)) {
return;
}
// add to index
final int s = urlFileIndex.size();
- urlFileIndex.put(entry.toRow());
- assert s < urlFileIndex.size() : "hash = " + hash + ", s = " + s + ", size = " + urlFileIndex.size();
- assert urlFileIndex.has(hash.getBytes()) : "hash = " + hash;
-
+ urlFileIndex.put(entry.toRow());
+ assert s < urlFileIndex.size() : "hash = " + new String(hash) + ", s = " + s + ", size = " + urlFileIndex.size();
+ assert urlFileIndex.has(hash) : "hash = " + new String(hash);
+
// add the hash to a queue
pushHashToDomainStacks(entry.url().hash(), 50);
}
}
- private void pushHashToDomainStacks(final String hash, final int maxstacksize) {
+ private void pushHashToDomainStacks(final byte[] hash, final int maxstacksize) {
// extend domain stack
- final String dom = hash.substring(6);
- LinkedList<String> domainList = domainStacks.get(dom);
+ final String dom = new String(hash).substring(6);
+ LinkedList<byte[]> domainList = domainStacks.get(dom);
if (domainList == null) {
// create new list
- domainList = new LinkedList<String>();
+ domainList = new LinkedList<byte[]>();
domainList.add(hash);
domainStacks.put(dom, domainList);
} else {
@@ -273,21 +274,21 @@ public class Balancer {
}
}
- private void removeHashFromDomainStacks(final String hash) {
+ private void removeHashFromDomainStacks(final byte[] hash) {
// extend domain stack
- final String dom = hash.substring(6);
- final LinkedList<String> domainList = domainStacks.get(dom);
+ final String dom = new String(hash).substring(6);
+ final LinkedList<byte[]> domainList = domainStacks.get(dom);
if (domainList == null) return;
- final Iterator<String> i = domainList.iterator();
+ final Iterator<byte[]> i = domainList.iterator();
while (i.hasNext()) {
- if (i.next().equals(hash)) {
+ if (Base64Order.enhancedCoder.equal(i.next(), hash)) {
i.remove();
return;
}
}
}
- private String nextFromDelayed() {
+ private byte[] nextFromDelayed() {
if (this.delayed.isEmpty()) return null;
final Long first = this.delayed.firstKey();
if (first.longValue() < System.currentTimeMillis()) {
@@ -296,7 +297,7 @@ public class Balancer {
return null;
}
- private String anyFromDelayed() {
+ private byte[] anyFromDelayed() {
if (this.delayed.isEmpty()) return null;
final Long first = this.delayed.firstKey();
return this.delayed.remove(first);
@@ -338,29 +339,29 @@ public class Balancer {
long sleeptime = 0;
Request crawlEntry = null;
synchronized (this) {
- String failhash = null;
+ byte[] failhashb = null;
while (!this.urlFileIndex.isEmpty()) {
// first simply take one of the entries in the top list, that should be one without any delay
- String nexthash = nextFromDelayed();
+ byte[] nexthashb = nextFromDelayed();
//System.out.println("*** nextFromDelayed=" + nexthash);
- if (nexthash == null && !this.top.isEmpty()) {
- nexthash = top.remove();
+ if (nexthashb == null && !this.top.isEmpty()) {
+ nexthashb = top.remove();
//System.out.println("*** top.remove()=" + nexthash);
}
- if (nexthash == null) {
- nexthash = anyFromDelayed();
+ if (nexthashb == null) {
+ nexthashb = anyFromDelayed();
}
// check minimumDelta and if necessary force a sleep
//final int s = urlFileIndex.size();
- Row.Entry rowEntry = (nexthash == null) ? null : urlFileIndex.remove(nexthash.getBytes());
+ Row.Entry rowEntry = (nexthashb == null) ? null : urlFileIndex.remove(nexthashb);
if (rowEntry == null) {
//System.out.println("*** rowEntry=null, nexthash=" + nexthash);
rowEntry = urlFileIndex.removeOne();
if (rowEntry == null) {
- nexthash = null;
+ nexthashb = null;
} else {
- nexthash = new String(rowEntry.getPrimaryKeyBytes());
+ nexthashb = rowEntry.getPrimaryKeyBytes();
//System.out.println("*** rowEntry.getPrimaryKeyBytes()=" + nexthash);
}
@@ -374,7 +375,7 @@ public class Balancer {
crawlEntry = new Request(rowEntry);
//Log.logInfo("Balancer", "fetched next url: " + crawlEntry.url().toNormalform(true, false));
- // at this point we must check if the crawlEntry has relevancy because the crawl profile still exists
+ // at this point we must check if the crawlEntry has relevance because the crawl profile still exists
// if not: return null. A calling method must handle the null value and try again
final CrawlProfile.entry profileEntry = (profile == null) ? null : profile.getEntry(crawlEntry.profileHandle());
if (profileEntry == null) {
@@ -387,22 +388,22 @@ public class Balancer {
(profileEntry.cacheStrategy() == CrawlProfile.CACHE_STRATEGY_IFEXIST && Cache.has(crawlEntry.url()))
) ? 0 : Latency.waitingRemaining(crawlEntry.url(), minimumLocalDelta, minimumGlobalDelta); // this uses the robots.txt database and may cause a loading of robots.txt from the server
- assert nexthash.equals(new String(rowEntry.getPrimaryKeyBytes())) : "result = " + nexthash + ", rowEntry.getPrimaryKeyBytes() = " + new String(rowEntry.getPrimaryKeyBytes());
- assert nexthash.equals(crawlEntry.url().hash()) : "result = " + nexthash + ", crawlEntry.url().hash() = " + crawlEntry.url().hash();
+ assert Base64Order.enhancedCoder.equal(nexthashb, rowEntry.getPrimaryKeyBytes()) : "result = " + new String(nexthashb) + ", rowEntry.getPrimaryKeyBytes() = " + new String(rowEntry.getPrimaryKeyBytes());
+ assert Base64Order.enhancedCoder.equal(nexthashb, crawlEntry.url().hash()) : "result = " + new String(nexthashb) + ", crawlEntry.url().hash() = " + new String(crawlEntry.url().hash());
- if (failhash != null && failhash.equals(nexthash)) break; // prevent endless loops
+ if (failhashb != null && Base64Order.enhancedCoder.equal(failhashb, nexthashb)) break; // prevent endless loops
if (delay && sleeptime > 0 && this.domStackInitSize > 1) {
//System.out.println("*** putback: nexthash=" + nexthash + ", failhash="+failhash);
// put that thing back to omit a delay here
- if (!delayed.values().contains(nexthash)) {
+ if (!ByteBuffer.contains(delayed.values(), nexthashb)) {
//System.out.println("*** delayed +=" + nexthash);
- this.delayed.put(Long.valueOf(System.currentTimeMillis() + sleeptime + 1), nexthash);
+ this.delayed.put(Long.valueOf(System.currentTimeMillis() + sleeptime + 1), nexthashb);
}
try {
this.urlFileIndex.put(rowEntry);
- this.domainStacks.remove(nexthash.substring(6));
- failhash = nexthash;
+ this.domainStacks.remove(new String(nexthashb).substring(6));
+ failhashb = nexthashb;
} catch (RowSpaceExceededException e) {
Log.logException(e);
}
@@ -431,7 +432,7 @@ public class Balancer {
try {synchronized(this) { this.wait(3000); }} catch (final InterruptedException e) {}
}
}
- Latency.update(crawlEntry.url().hash().substring(6), crawlEntry.url().getHost());
+ Latency.update(new String(crawlEntry.url().hash()).substring(6), crawlEntry.url().getHost());
return crawlEntry;
}
@@ -448,10 +449,10 @@ public class Balancer {
}
// iterate over the domain stacks
- final Iterator<Map.Entry<String, LinkedList<String>>> i = this.domainStacks.entrySet().iterator();
- Map.Entry<String, LinkedList<String>> entry;
+ final Iterator<Map.Entry<String, LinkedList<byte[]>>> i = this.domainStacks.entrySet().iterator();
+ Map.Entry<String, LinkedList<byte[]>> entry;
long smallestWaiting = Long.MAX_VALUE;
- String besthash = null;
+ byte[] besthashb = null;
while (i.hasNext()) {
entry = i.next();
@@ -461,13 +462,13 @@ public class Balancer {
continue;
}
- String n = entry.getValue().getFirst();
+ byte[] n = entry.getValue().getFirst();
if (delay) {
final long w = Latency.waitingRemainingGuessed(n, minimumLocalDelta, minimumGlobalDelta);
if (w > maximumwaiting) {
if (w < smallestWaiting) {
smallestWaiting = w;
- besthash = n;
+ besthashb = n;
}
continue;
}
@@ -479,9 +480,9 @@ public class Balancer {
}
// if we could not find any entry, then take the best we have seen so far
- if (acceptonebest && !this.top.isEmpty() && besthash != null) {
- removeHashFromDomainStacks(besthash);
- this.top.add(besthash);
+ if (acceptonebest && !this.top.isEmpty() && besthashb != null) {
+ removeHashFromDomainStacks(besthashb);
+ this.top.add(besthashb);
}
}
@@ -492,7 +493,7 @@ public class Balancer {
this.lastDomainStackFill = System.currentTimeMillis();
final CloneableIterator<byte[]> i = this.urlFileIndex.keys(true, null);
while (i.hasNext()) {
- pushHashToDomainStacks(new String(i.next()), 50);
+ pushHashToDomainStacks(i.next(), 50);
if (this.domainStacks.size() > maxdomstacksize) break;
}
Log.logInfo("BALANCER", "re-fill of domain stacks; fileIndex.size() = " + this.urlFileIndex.size() + ", domainStacks.size = " + domainStacks.size() + ", collection time = " + (System.currentTimeMillis() - this.lastDomainStackFill) + " ms");
@@ -504,9 +505,9 @@ public class Balancer {
final ArrayList<Request> cel = new ArrayList<Request>();
if (count == 0) return cel;
synchronized (this) {
- for (String n: top) {
+ for (byte[] n: top) {
try {
- final Row.Entry rowEntry = urlFileIndex.get(n.getBytes());
+ final Row.Entry rowEntry = urlFileIndex.get(n);
if (rowEntry == null) continue;
final Request crawlEntry = new Request(rowEntry);
cel.add(crawlEntry);
@@ -518,11 +519,11 @@ public class Balancer {
int depth = 0;
loop: while (count > 0) {
// iterate over the domain stacks
- for (LinkedList<String> list: this.domainStacks.values()) {
+ for (LinkedList<byte[]> list: this.domainStacks.values()) {
if (list.size() <= depth) continue loop;
- String n = list.get(depth);
+ byte[] n = list.get(depth);
try {
- Row.Entry rowEntry = urlFileIndex.get(n.getBytes());
+ Row.Entry rowEntry = urlFileIndex.get(n);
if (rowEntry == null) continue;
final Request crawlEntry = new Request(rowEntry);
cel.add(crawlEntry);
diff --git a/source/de/anomic/crawler/CrawlProfile.java b/source/de/anomic/crawler/CrawlProfile.java
index 7b7ce22dd..2727a2df0 100644
--- a/source/de/anomic/crawler/CrawlProfile.java
+++ b/source/de/anomic/crawler/CrawlProfile.java
@@ -133,7 +133,7 @@ public class CrawlProfile {
}
public void remove() {
if (lastkey != null) try {
- removeEntry(lastkey);
+ removeEntry(lastkey.getBytes());
} catch (final kelondroException e) {
Log.logException(e);
clear();
@@ -141,7 +141,7 @@ public class CrawlProfile {
}
}
- public void removeEntry(final String handle) {
+ public void removeEntry(final byte[] handle) {
try {
profileTable.remove(handle);
} catch (final IOException e) {
@@ -296,7 +296,7 @@ public class CrawlProfile {
final boolean xsstopw, final boolean xdstopw, final boolean xpstopw,
final int cacheStrategy) {
if (name == null || name.length() == 0) throw new NullPointerException("name must not be null");
- final String handle = (startURL == null) ? Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(Long.toString(System.currentTimeMillis()))).substring(0, Word.commonHashLength) : startURL.hash();
+ final String handle = (startURL == null) ? Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(Long.toString(System.currentTimeMillis()))).substring(0, Word.commonHashLength) : new String(startURL.hash());
mem = new HashMap<String, String>(40);
mem.put(HANDLE, handle);
mem.put(NAME, name);
diff --git a/source/de/anomic/crawler/CrawlQueues.java b/source/de/anomic/crawler/CrawlQueues.java
index 12ff5cf36..1a7c69bf7 100644
--- a/source/de/anomic/crawler/CrawlQueues.java
+++ b/source/de/anomic/crawler/CrawlQueues.java
@@ -40,6 +40,7 @@ import net.yacy.document.content.RSSMessage;
import net.yacy.document.parser.xml.RSSFeed;
import net.yacy.kelondro.data.meta.DigestURI;
import net.yacy.kelondro.logging.Log;
+import net.yacy.kelondro.order.Base64Order;
import net.yacy.kelondro.util.DateFormatter;
import net.yacy.kelondro.util.FileUtils;
import net.yacy.kelondro.workflow.WorkflowJob;
@@ -135,7 +136,7 @@ public class CrawlQueues {
* @param hash
* @return if the hash exists, the name of the database is returned, otherwise null is returned
*/
- public String urlExists(final String hash) {
+ public String urlExists(final byte[] hash) {
if (delegatedURL.exists(hash)) return "delegated";
if (errorURL.exists(hash)) return "errors";
/*
@@ -153,15 +154,15 @@ public class CrawlQueues {
errorURL.remove(hash);
}
- public DigestURI getURL(final String urlhash) {
+ public DigestURI getURL(final byte[] urlhash) {
assert urlhash != null;
- if (urlhash == null || urlhash.length() == 0) return null;
+ if (urlhash == null || urlhash.length == 0) return null;
ZURL.Entry ee = delegatedURL.get(urlhash);
if (ee != null) return ee.url();
ee = errorURL.get(urlhash);
if (ee != null) return ee.url();
for (final crawlWorker w: workers.values()) {
- if (w.request.url().hash().equals(urlhash)) return w.request.url();
+ if (Base64Order.enhancedCoder.equal(w.request.url().hash(), urlhash)) return w.request.url();
}
final Request ne = noticeURL.get(urlhash);
if (ne != null) return ne.url();
@@ -260,7 +261,7 @@ public class CrawlQueues {
if (this.log.isFine())
log.logFine(stats + ": URL=" + urlEntry.url()
- + ", initiator=" + urlEntry.initiator()
+ + ", initiator=" + new String(urlEntry.initiator())
+ ", crawlOrder=" + ((profile.remoteIndexing()) ? "true" : "false")
+ ", depth=" + urlEntry.depth()
+ ", crawlDepth=" + profile.depth()
@@ -440,7 +441,7 @@ public class CrawlQueues {
// stack url
if (sb.getLog().isFinest()) sb.getLog().logFinest("crawlOrder: stack: url='" + url + "'");
sb.crawlStacker.enqueueEntry(new Request(
- hash,
+ hash.getBytes(),
url,
(referrer == null) ? null : referrer.hash(),
item.getDescription(),
@@ -544,7 +545,7 @@ public class CrawlQueues {
if (log.isFine()) log.logFine("Crawling of URL '" + request.url().toString() + "' disallowed by robots.txt.");
errorURL.push(
this.request,
- sb.peers.mySeed().hash,
+ sb.peers.mySeed().hash.getBytes(),
new Date(),
1,
"denied by robots.txt");
@@ -578,7 +579,7 @@ public class CrawlQueues {
if (result != null) {
errorURL.push(
this.request,
- sb.peers.mySeed().hash,
+ sb.peers.mySeed().hash.getBytes(),
new Date(),
1,
"cannot load: " + result);
@@ -590,7 +591,7 @@ public class CrawlQueues {
} catch (final Exception e) {
errorURL.push(
this.request,
- sb.peers.mySeed().hash,
+ sb.peers.mySeed().hash.getBytes(),
new Date(),
1,
e.getMessage() + " - in worker");
diff --git a/source/de/anomic/crawler/CrawlStacker.java b/source/de/anomic/crawler/CrawlStacker.java
index 4c134e72f..06426ff12 100644
--- a/source/de/anomic/crawler/CrawlStacker.java
+++ b/source/de/anomic/crawler/CrawlStacker.java
@@ -34,6 +34,7 @@ import java.util.Date;
import net.yacy.kelondro.data.meta.DigestURI;
import net.yacy.kelondro.data.meta.URIMetadataRow;
import net.yacy.kelondro.logging.Log;
+import net.yacy.kelondro.order.Base64Order;
import net.yacy.kelondro.util.Domains;
import net.yacy.kelondro.workflow.WorkflowProcessor;
import net.yacy.repository.Blacklist;
@@ -142,7 +143,7 @@ public final class CrawlStacker {
// if the url was rejected we store it into the error URL db
if (rejectReason != null) {
- nextQueue.errorURL.push(entry, peers.mySeed().hash, new Date(), 1, rejectReason);
+ nextQueue.errorURL.push(entry, peers.mySeed().hash.getBytes(), new Date(), 1, rejectReason);
}
} catch (final Exception e) {
CrawlStacker.this.log.logWarning("Error while processing stackCrawl entry.\n" + "Entry: " + entry.toString() + "Error: " + e.toString(), e);
@@ -154,7 +155,7 @@ public final class CrawlStacker {
public void enqueueEntry(final Request entry) {
// DEBUG
- if (log.isFinest()) log.logFinest("ENQUEUE " + entry.url() + ", referer=" + entry.referrerhash() + ", initiator=" + entry.initiator() + ", name=" + entry.name() + ", load=" + entry.loaddate() + ", depth=" + entry.depth());
+ if (log.isFinest()) log.logFinest("ENQUEUE " + entry.url() + ", referer=" + entry.referrerhash() + ", initiator=" + new String(entry.initiator()) + ", name=" + entry.name() + ", load=" + entry.loaddate() + ", depth=" + entry.depth());
if (prefetchHost(entry.url().getHost())) {
try {
@@ -237,7 +238,7 @@ public final class CrawlStacker {
return "post url not allowed";
}
- final DigestURI referrerURL = (entry.referrerhash() == null || entry.referrerhash().length() == 0) ? null : nextQueue.getURL(entry.referrerhash());
+ final DigestURI referrerURL = (entry.referrerhash() == null || entry.referrerhash().length == 0) ? null : nextQueue.getURL(entry.referrerhash());
// add domain to profile domain list
if ((profile.domFilterDepth() != Integer.MAX_VALUE) || (profile.domMaxPages() != Integer.MAX_VALUE)) {
@@ -294,8 +295,8 @@ public final class CrawlStacker {
}
// store information
- final boolean local = entry.initiator().equals(peers.mySeed().hash);
- final boolean proxy = (entry.initiator() == null || entry.initiator().length() == 0 || entry.initiator().equals("------------")) && profile.handle().equals(crawler.defaultProxyProfile.handle());
+ final boolean local = Base64Order.enhancedCoder.equal(entry.initiator(), peers.mySeed().hash.getBytes());
+ final boolean proxy = (entry.initiator() == null || entry.initiator().length == 0 || new String(entry.initiator()).equals("------------")) && profile.handle().equals(crawler.defaultProxyProfile.handle());
final boolean remote = profile.handle().equals(crawler.defaultRemoteProfile.handle());
final boolean global =
(profile.remoteIndexing()) /* granted */ &&
@@ -307,28 +308,28 @@ public final class CrawlStacker {
) /* qualified */;
if (!local && !global && !remote && !proxy) {
- String error = "URL '" + entry.url().toString() + "' cannot be crawled. initiator = " + entry.initiator() + ", profile.handle = " + profile.handle();
+ String error = "URL '" + entry.url().toString() + "' cannot be crawled. initiator = " + new String(entry.initiator()) + ", profile.handle = " + profile.handle();
this.log.logSevere(error);
return error;
}
if (global) {
// it may be possible that global == true and local == true, so do not check an error case against it
- if (proxy) this.log.logWarning("URL '" + entry.url().toString() + "' has conflicting initiator properties: global = true, proxy = true, initiator = " + entry.initiator() + ", profile.handle = " + profile.handle());
- if (remote) this.log.logWarning("URL '" + entry.url().toString() + "' has conflicting initiator properties: global = true, remote = true, initiator = " + entry.initiator() + ", profile.handle = " + profile.handle());
+ if (proxy) this.log.logWarning("URL '" + entry.url().toString() + "' has conflicting initiator properties: global = true, proxy = true, initiator = " + new String(entry.initiator()) + ", profile.handle = " + profile.handle());
+ if (remote) this.log.logWarning("URL '" + entry.url().toString() + "' has conflicting initiator properties: global = true, remote = true, initiator = " + new String(entry.initiator()) + ", profile.handle = " + profile.handle());
//int b = nextQueue.noticeURL.stackSize(NoticedURL.STACK_TYPE_LIMIT);
nextQueue.noticeURL.push(NoticedURL.STACK_TYPE_LIMIT, entry);
//assert b < nextQueue.noticeURL.stackSize(NoticedURL.STACK_TYPE_LIMIT);
//this.log.logInfo("stacked/global: " + entry.url().toString() + ", stacksize = " + nextQueue.noticeURL.stackSize(NoticedURL.STACK_TYPE_LIMIT));
} else if (local) {
- if (proxy) this.log.logWarning("URL '" + entry.url().toString() + "' has conflicting initiator properties: local = true, proxy = true, initiator = " + entry.initiator() + ", profile.handle = " + profile.handle());
- if (remote) this.log.logWarning("URL '" + entry.url().toString() + "' has conflicting initiator properties: local = true, remote = true, initiator = " + entry.initiator() + ", profile.handle = " + profile.handle());
+ if (proxy) this.log.logWarning("URL '" + entry.url().toString() + "' has conflicting initiator properties: local = true, proxy = true, initiator = " + new String(entry.initiator()) + ", profile.handle = " + profile.handle());
+ if (remote) this.log.logWarning("URL '" + entry.url().toString() + "' has conflicting initiator properties: local = true, remote = true, initiator = " + new String(entry.initiator()) + ", profile.handle = " + profile.handle());
//int b = nextQueue.noticeURL.stackSize(NoticedURL.STACK_TYPE_CORE);
nextQueue.noticeURL.push(NoticedURL.STACK_TYPE_CORE, entry);
//assert b < nextQueue.noticeURL.stackSize(NoticedURL.STACK_TYPE_CORE);
//this.log.logInfo("stacked/local: " + entry.url().toString() + ", stacksize = " + nextQueue.noticeURL.stackSize(NoticedURL.STACK_TYPE_CORE));
} else if (proxy) {
- if (remote) this.log.logWarning("URL '" + entry.url().toString() + "' has conflicting initiator properties: proxy = true, remote = true, initiator = " + entry.initiator() + ", profile.handle = " + profile.handle());
+ if (remote) this.log.logWarning("URL '" + entry.url().toString() + "' has conflicting initiator properties: proxy = true, remote = true, initiator = " + new String(entry.initiator()) + ", profile.handle = " + profile.handle());
//int b = nextQueue.noticeURL.stackSize(NoticedURL.STACK_TYPE_CORE);
nextQueue.noticeURL.push(NoticedURL.STACK_TYPE_CORE, entry);
//assert b < nextQueue.noticeURL.stackSize(NoticedURL.STACK_TYPE_CORE);
@@ -371,7 +372,7 @@ public final class CrawlStacker {
if (this.acceptGlobalURLs && this.acceptLocalURLs) return null; // fast shortcut to avoid dnsResolve
// check if this is a local address and we are allowed to index local pages:
//boolean local = hostAddress.isSiteLocalAddress() || hostAddress.isLoopbackAddress();
- final boolean local = DigestURI.isLocal(urlhash);
+ final boolean local = DigestURI.isLocal(urlhash.getBytes());
//assert local == yacyURL.isLocalDomain(url.hash()); // TODO: remove the dnsResolve above!
if ((this.acceptGlobalURLs && !local) || (this.acceptLocalURLs && local)) return null;
return (local) ?
diff --git a/source/de/anomic/crawler/Latency.java b/source/de/anomic/crawler/Latency.java
index de4a6cf36..9af61d32b 100644
--- a/source/de/anomic/crawler/Latency.java
+++ b/source/de/anomic/crawler/Latency.java
@@ -109,9 +109,9 @@ public class Latency {
* @return the remaining waiting time in milliseconds. The return value may be negative
* which expresses how long the time is over the minimum waiting time.
*/
- public static long waitingRemainingGuessed(String hosthash, final long minimumLocalDelta, final long minimumGlobalDelta) {
- assert hosthash.length() == 12 || hosthash.length() == 6;
- Host host = Latency.host((hosthash.length() == 6) ? hosthash : hosthash.substring(6));
+ public static long waitingRemainingGuessed(byte[] hosthash, final long minimumLocalDelta, final long minimumGlobalDelta) {
+ assert hosthash.length == 12 || hosthash.length == 6;
+ Host host = Latency.host((hosthash.length == 6) ? new String(hosthash) : new String(hosthash).substring(6));
if (host == null) return Long.MIN_VALUE;
// the time since last access to the domain is the basis of the remaining calculation
@@ -152,7 +152,7 @@ public class Latency {
public static long waitingRemaining(DigestURI url, final long minimumLocalDelta, final long minimumGlobalDelta) {
// first check if the domain was _ever_ accessed before
- String hosthash = url.hash().substring(6);
+ String hosthash = new String(url.hash()).substring(6);
Host host = host(hosthash);
if (host == null) return Long.MIN_VALUE; // no delay if host is new
@@ -193,7 +193,7 @@ public class Latency {
public static String waitingRemainingExplain(DigestURI url, final long minimumLocalDelta, final long minimumGlobalDelta) {
// first check if the domain was _ever_ accessed before
- String hosthash = url.hash().substring(6);
+ String hosthash = new String(url.hash()).substring(6);
Host host = host(hosthash);
if (host == null) return "host " + hosthash + "/" + url.getHost() + " never accessed before -> 0"; // no delay if host is new
diff --git a/source/de/anomic/crawler/NoticedURL.java b/source/de/anomic/crawler/NoticedURL.java
index 576b19770..41a023348 100755
--- a/source/de/anomic/crawler/NoticedURL.java
+++ b/source/de/anomic/crawler/NoticedURL.java
@@ -30,7 +30,10 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
+import net.yacy.kelondro.index.HandleSet;
+import net.yacy.kelondro.index.RowSpaceExceededException;
import net.yacy.kelondro.logging.Log;
+import net.yacy.kelondro.order.Base64Order;
import de.anomic.crawler.retrieval.Request;
@@ -166,7 +169,7 @@ public class NoticedURL {
}
}
- public Request get(final String urlhash) {
+ public Request get(final byte[] urlhash) {
Request entry = null;
try {if ((entry = coreStack.get(urlhash)) != null) return entry;} catch (final IOException e) {}
try {if ((entry = limitStack.get(urlhash)) != null) return entry;} catch (final IOException e) {}
@@ -181,15 +184,21 @@ public class NoticedURL {
* @return true, if the entry was removed; false if not
*/
public boolean removeByURLHash(final byte[] urlhashBytes) {
- final HashSet<String> urlHashes = new HashSet<String>();
- urlHashes.add(new String(urlhashBytes));
- try {return coreStack.remove(urlHashes) > 0;} catch (final IOException e) {}
- try {return limitStack.remove(urlHashes) > 0;} catch (final IOException e) {}
- try {return remoteStack.remove(urlHashes) > 0;} catch (final IOException e) {}
- return false;
+ try {
+ HandleSet urlHashes = Base64Order.enhancedCoder.getHandleSet(12, 1);
+ urlHashes.put(urlhashBytes);
+ try {return coreStack.remove(urlHashes) > 0;} catch (final IOException e) {}
+ try {return limitStack.remove(urlHashes) > 0;} catch (final IOException e) {}
+ try {return remoteStack.remove(urlHashes) > 0;} catch (final IOException e) {}
+ return false;
+ } catch (RowSpaceExceededException e) {
+ return false;
+ } catch (IOException e) {
+ return false;
+ }
}
- public int removeByProfileHandle(final String handle, final long timeout) {
+ public int removeByProfileHandle(final String handle, final long timeout) throws RowSpaceExceededException {
int removed = 0;
try {removed += coreStack.removeAllByProfileHandle(handle, timeout);} catch (final IOException e) {}
try {removed += limitStack.removeAllByProfileHandle(handle, timeout);} catch (final IOException e) {}
diff --git a/source/de/anomic/crawler/ResultImages.java b/source/de/anomic/crawler/ResultImages.java
index d9ff48902..d60c7de46 100755
--- a/source/de/anomic/crawler/ResultImages.java
+++ b/source/de/anomic/crawler/ResultImages.java
@@ -57,8 +57,9 @@ public class ResultImages {
final HashMap<String, ImageEntry> images = document.getImages();
for (final ImageEntry image: images.values()) {
// do a double-check; attention: this can be time-consuming since this possibly needs a DNS-lookup
- if (doubleCheck.containsKey(image.url().hash())) continue;
- doubleCheck.put(image.url().hash(), System.currentTimeMillis());
+ String hashstring = new String(image.url().hash());
+ if (doubleCheck.containsKey(hashstring)) continue;
+ doubleCheck.put(hashstring, System.currentTimeMillis());
final String name = image.url().getFile();
boolean good = false;
diff --git a/source/de/anomic/crawler/ResultURLs.java b/source/de/anomic/crawler/ResultURLs.java
index b686603ad..dd7815d47 100644
--- a/source/de/anomic/crawler/ResultURLs.java
+++ b/source/de/anomic/crawler/ResultURLs.java
@@ -47,10 +47,10 @@ public final class ResultURLs {
private final Map<EventOrigin, ScoreCluster<String>> resultDomains;
public class InitExecEntry {
- public String initiatorHash, executorHash;
- public InitExecEntry(final String initiatorHash, final String executorHash) {
- this.initiatorHash = initiatorHash;
- this.executorHash = executorHash;
+ public byte[] initiatorHashb, executorHashb;
+ public InitExecEntry(final byte[] initiatorHash, final byte[] executorHash) {
+ this.initiatorHashb = initiatorHash;
+ this.executorHashb = executorHash;
}
}
@@ -64,7 +64,11 @@ public final class ResultURLs {
}
}
- public synchronized void stack(final URIMetadataRow e, final String initiatorHash, final String executorHash, final EventOrigin stackType) {
+ public synchronized void stack(
+ final URIMetadataRow e,
+ final byte[] initiatorHash,
+ final byte[] executorHash,
+ final EventOrigin stackType) {
assert initiatorHash != null;
assert executorHash != null;
if (e == null) { return; }
@@ -188,7 +192,7 @@ public final class ResultURLs {
EventOrigin stackNo = EventOrigin.LOCAL_CRAWLING;
System.out.println("valid test:\n=======");
// add
- results.stack(urlRef, new String(urlRef.hash()), url.hash(), stackNo);
+ results.stack(urlRef, urlRef.hash(), url.hash(), stackNo);
// size
System.out.println("size of stack:\t"+ results.getStackSize(stackNo));
} catch (final MalformedURLException e) {
diff --git a/source/de/anomic/crawler/ZURL.java b/source/de/anomic/crawler/ZURL.java
index 528138b2d..28237abc0 100755
--- a/source/de/anomic/crawler/ZURL.java
+++ b/source/de/anomic/crawler/ZURL.java
@@ -64,7 +64,7 @@ public class ZURL implements Iterable<ZURL.Entry> {
// the class object
protected ObjectIndex urlIndex;
- protected final ConcurrentLinkedQueue<String> stack;
+ protected final ConcurrentLinkedQueue<byte[]> stack;
public ZURL(
final File cachePath,
@@ -90,13 +90,13 @@ public class ZURL implements Iterable<ZURL.Entry> {
}
}
//urlIndex = new kelondroFlexTable(cachePath, tablename, -1, rowdef, 0, true);
- this.stack = new ConcurrentLinkedQueue<String>();
+ this.stack = new ConcurrentLinkedQueue<byte[]>();
}
public ZURL() {
// creates a new ZUR in RAM
this.urlIndex = new RowSet(rowdef);
- this.stack = new ConcurrentLinkedQueue<String>();
+ this.stack = new ConcurrentLinkedQueue<byte[]>();
}
public void clear() throws IOException {
@@ -122,7 +122,7 @@ public class ZURL implements Iterable<ZURL.Entry> {
public void push(
final Request bentry,
- final String executor,
+ final byte[] executor,
final Date workdate,
final int workcount,
String anycause) {
@@ -131,7 +131,7 @@ public class ZURL implements Iterable<ZURL.Entry> {
if (anycause == null) anycause = "unknown";
Entry entry = new Entry(bentry, executor, workdate, workcount, anycause);
put(entry);
- stack.add(entry.hash());
+ stack.add(entry.hashb());
while (stack.size() > maxStackSize) stack.poll();
}
@@ -149,7 +149,7 @@ public class ZURL implements Iterable<ZURL.Entry> {
}
private class EntryIterator implements Iterator<ZURL.Entry> {
- private final Iterator<String> hi;
+ private final Iterator<byte[]> hi;
public EntryIterator() {
this.hi = stack.iterator();
}
@@ -167,11 +167,11 @@ public class ZURL implements Iterable<ZURL.Entry> {
}
- public ZURL.Entry get(final String urlhash) {
+ public ZURL.Entry get(final byte[] urlhash) {
try {
if (urlIndex == null) return null;
//System.out.println("*** DEBUG ZURL " + this.urlIndex.filename() + " get " + urlhash);
- final Row.Entry entry = urlIndex.get(urlhash.getBytes());
+ final Row.Entry entry = urlIndex.get(urlhash);
if (entry == null) return null;
return new Entry(entry);
} catch (final IOException e) {
@@ -189,8 +189,8 @@ public class ZURL implements Iterable<ZURL.Entry> {
if (entry.stored) return;
if (entry.bentry == null) return;
final Row.Entry newrow = rowdef.newEntry();
- newrow.setCol(0, entry.bentry.url().hash().getBytes());
- newrow.setCol(1, entry.executor.getBytes());
+ newrow.setCol(0, entry.bentry.url().hash());
+ newrow.setCol(1, entry.executor);
newrow.setCol(2, entry.workdate.getTime());
newrow.setCol(3, entry.workcount);
newrow.setCol(4, entry.anycause.getBytes());
@@ -203,8 +203,8 @@ public class ZURL implements Iterable<ZURL.Entry> {
}
}
- public boolean exists(final String urlHash) {
- return urlIndex.has(urlHash.getBytes());
+ public boolean exists(final byte[] urlHash) {
+ return urlIndex.has(urlHash);
}
public void clearStack() {
@@ -218,7 +218,7 @@ public class ZURL implements Iterable<ZURL.Entry> {
public class Entry {
Request bentry; // the balancer entry
- private final String executor; // the crawling executor
+ private final byte[] executor; // the crawling executor
private final Date workdate; // the time when the url was last time tried to load
private final int workcount; // number of tryings
private final String anycause; // string describing reason for load fail
@@ -226,7 +226,7 @@ public class ZURL implements Iterable<ZURL.Entry> {
protected Entry(
final Request bentry,
- final String executor,
+ final byte[] executor,
final Date workdate,
final int workcount,
final String anycause) {
@@ -243,12 +243,12 @@ public class ZURL implements Iterable<ZURL.Entry> {
protected Entry(final Row.Entry entry) throws IOException {
assert (entry != null);
- this.executor = entry.getColString(1, "UTF-8");
+ this.executor = entry.getColBytes(1, true);
this.workdate = new Date(entry.getColLong(2));
this.workcount = (int) entry.getColLong(3);
this.anycause = entry.getColString(4, "UTF-8");
- this.bentry = new Request(Request.rowdef.newEntry(entry.getColBytes(5)));
- assert ((new String(entry.getColBytes(0))).equals(bentry.url().hash()));
+ this.bentry = new Request(Request.rowdef.newEntry(entry.getColBytes(5, false)));
+ assert (Base64Order.enhancedCoder.equal(entry.getColBytes(0, false), bentry.url().hash()));
this.stored = true;
return;
}
@@ -257,11 +257,11 @@ public class ZURL implements Iterable<ZURL.Entry> {
return this.bentry.url();
}
- public String initiator() {
+ public byte[] initiator() {
return this.bentry.initiator();
}
- public String hash() {
+ public byte[] hashb() {
// return a url-hash, based on the md5 algorithm
// the result is a String of 12 bytes within a 72-bit space
// (each byte has an 6-bit range)
@@ -273,7 +273,7 @@ public class ZURL implements Iterable<ZURL.Entry> {
return workdate;
}
- public String executor() {
+ public byte[] executor() {
// return the creator's hash
return executor;
}
diff --git a/source/de/anomic/crawler/retrieval/FTPLoader.java b/source/de/anomic/crawler/retrieval/FTPLoader.java
index ea570819c..94c18cd04 100644
--- a/source/de/anomic/crawler/retrieval/FTPLoader.java
+++ b/source/de/anomic/crawler/retrieval/FTPLoader.java
@@ -150,11 +150,11 @@ public class FTPLoader {
if (berr.size() > 0 || response == null) {
// some error logging
final String detail = (berr.size() > 0) ? "\n Errorlog: " + berr.toString() : "";
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash, new Date(), 1, "server download" + detail);
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, "server download" + detail);
throw new IOException("FTPLoader: Unable to download URL " + request.url().toString() + detail);
}
- Latency.update(request.url().hash().substring(6), request.url().getHost(), System.currentTimeMillis() - start);
+ Latency.update(new String(request.url().hash()).substring(6), request.url().getHost(), System.currentTimeMillis() - start);
return response;
}
diff --git a/source/de/anomic/crawler/retrieval/HTTPLoader.java b/source/de/anomic/crawler/retrieval/HTTPLoader.java
index 11825b59e..ac2685b31 100644
--- a/source/de/anomic/crawler/retrieval/HTTPLoader.java
+++ b/source/de/anomic/crawler/retrieval/HTTPLoader.java
@@ -77,14 +77,14 @@ public final class HTTPLoader {
public Response load(final Request entry, final boolean acceptOnlyParseable) throws IOException {
long start = System.currentTimeMillis();
Response doc = load(entry, acceptOnlyParseable, DEFAULT_CRAWLING_RETRY_COUNT);
- Latency.update(entry.url().hash().substring(6), entry.url().getHost(), System.currentTimeMillis() - start);
+ Latency.update(new String(entry.url().hash()).substring(6), entry.url().getHost(), System.currentTimeMillis() - start);
return doc;
}
private Response load(final Request request, boolean acceptOnlyParseable, final int retryCount) throws IOException {
if (retryCount < 0) {
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash, new Date(), 1, "redirection counter exceeded");
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, "redirection counter exceeded");
throw new IOException("Redirection counter exceeded for URL " + request.url().toString() + ". Processing aborted.");
}
@@ -99,7 +99,7 @@ public final class HTTPLoader {
if (acceptOnlyParseable) {
String supportError = TextParser.supportsExtension(request.url());
if (supportError != null) {
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash, new Date(), 1, supportError);
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, supportError);
throw new IOException("REJECTED WRONG EXTENSION TYPE: " + supportError);
}
}
@@ -107,7 +107,7 @@ public final class HTTPLoader {
// check if url is in blacklist
final String hostlow = host.toLowerCase();
if (Switchboard.urlBlacklist.isListed(Blacklist.BLACKLIST_CRAWLER, hostlow, path)) {
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash, new Date(), 1, "url in blacklist");
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, "url in blacklist");
throw new IOException("CRAWLER Rejecting URL '" + request.url().toString() + "'. URL is in blacklist.");
}
@@ -142,7 +142,7 @@ public final class HTTPLoader {
// if the response has not the right file type then reject file
String supportError = TextParser.supports(request.url(), res.getResponseHeader().mime());
if (supportError != null) {
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash, new Date(), 1, supportError);
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, supportError);
throw new IOException("REJECTED WRONG MIME TYPE, mime = " + res.getResponseHeader().mime() + ": " + supportError);
}
}
@@ -154,7 +154,7 @@ public final class HTTPLoader {
// check length again in case it was not possible to get the length before loading
if (maxFileSize > 0 && contentLength > maxFileSize) {
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash, new Date(), 1, "file size limit exceeded");
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, "file size limit exceeded");
throw new IOException("REJECTED URL " + request.url() + " because file size '" + contentLength + "' exceeds max filesize limit of " + maxFileSize + " bytes. (GET)");
}
@@ -176,7 +176,7 @@ public final class HTTPLoader {
redirectionUrlString = redirectionUrlString.trim();
if (redirectionUrlString.length() == 0) {
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash, new Date(), 1, "redirection header empy");
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, "redirection header empy");
throw new IOException("CRAWLER Redirection of URL=" + request.url().toString() + " aborted. Location header is empty.");
}
@@ -189,17 +189,14 @@ public final class HTTPLoader {
// if we are already doing a shutdown we don't need to retry crawling
if (Thread.currentThread().isInterrupted()) {
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash, new Date(), 1, "server shutdown");
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, "server shutdown");
throw new IOException("CRAWLER Retry of URL=" + request.url().toString() + " aborted because of server shutdown.");
}
-
- // generating url hash
- final String urlhash = redirectionUrl.hash();
// check if the url was already indexed
- final String dbname = sb.urlExists(Segments.Process.LOCALCRAWLING, urlhash);
+ final String dbname = sb.urlExists(Segments.Process.LOCALCRAWLING, redirectionUrl.hash());
if (dbname != null) {
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash, new Date(), 1, "redirection to double content");
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, "redirection to double content");
throw new IOException("CRAWLER Redirection of URL=" + request.url().toString() + " ignored. The url appears already in db " + dbname);
}
@@ -209,7 +206,7 @@ public final class HTTPLoader {
}
} else {
// if the response has not the right response type then reject file
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash, new Date(), 1, "wrong http status code " + res.getStatusCode() + ")");
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, "wrong http status code " + res.getStatusCode() + ")");
throw new IOException("REJECTED WRONG STATUS TYPE '" + res.getStatusLine() + "' for URL " + request.url().toString());
}
} finally {
diff --git a/source/de/anomic/crawler/retrieval/Request.java b/source/de/anomic/crawler/retrieval/Request.java
index 4609f1eeb..39ac3cd0a 100755
--- a/source/de/anomic/crawler/retrieval/Request.java
+++ b/source/de/anomic/crawler/retrieval/Request.java
@@ -60,10 +60,10 @@ public class Request extends WorkflowJob {
Base64Order.enhancedCoder
);
- private String initiator; // the initiator hash, is NULL or "" if it is the own proxy;
+ private byte[] initiator; // the initiator hash, is NULL or "" if it is the own proxy;
// if this is generated by a crawl, the own peer hash in entered
- private String refhash; // the url's referrer hash
- private DigestURI url; // the url as string
+ private byte[] refhash; // the url's referrer hash
+ private DigestURI url; // the url as string
private String name; // the name of the url, from anchor tag <a>name</a>
private long appdate; // the time when the url was first time appeared
private long loaddate; // the time when the url was loaded
@@ -83,7 +83,7 @@ public class Request extends WorkflowJob {
* @param url
* @param referrerhash
*/
- public Request(final DigestURI url, final String referrerhash) {
+ public Request(final DigestURI url, final byte[] referrerhash) {
this(null, url, referrerhash, null, null, null, null, 0, 0, 0);
}
@@ -102,9 +102,9 @@ public class Request extends WorkflowJob {
* @param forkfactor sum of anchors of all ancestors
*/
public Request(
- final String initiator,
+ final byte[] initiator,
final DigestURI url,
- final String referrerhash,
+ final byte[] referrerhash,
final String name,
final Date appdate,
final Date loaddate,
@@ -117,9 +117,9 @@ public class Request extends WorkflowJob {
assert url != null;
assert profileHandle == null || profileHandle.length() == Word.commonHashLength : profileHandle + " != " + Word.commonHashLength;
url.removeRef(); // remove anchor reference
- this.initiator = (initiator == null) ? null : ((initiator.length() == 0) ? null : initiator);
+ this.initiator = (initiator == null) ? null : ((initiator.length == 0) ? null : initiator);
this.url = url;
- this.refhash = (referrerhash == null) ? "" : referrerhash;
+ this.refhash = referrerhash;
this.name = (name == null) ? "" : name;
this.appdate = (appdate == null) ? 0 : appdate.getTime();
this.loaddate = (loaddate == null) ? 0 : loaddate.getTime();
@@ -144,17 +144,17 @@ public class Request extends WorkflowJob {
private void insertEntry(final Row.Entry entry) throws IOException {
final String urlstring = entry.getColString(2, null);
if (urlstring == null) throw new IOException ("url string is null");
- this.initiator = entry.getColString(1, null);
- this.initiator = (initiator == null) ? null : ((initiator.length() == 0) ? null : initiator);
- this.url = new DigestURI(urlstring, entry.getColString(0, null));
- this.refhash = (entry.empty(3)) ? "" : entry.getColString(3, null);
+ this.initiator = entry.getColBytes(1, true);
+ this.initiator = (initiator == null) ? null : ((initiator.length == 0) ? null : initiator);
+ this.url = new DigestURI(urlstring, entry.getColBytes(0, true));
+ this.refhash = (entry.empty(3)) ? null : entry.getColBytes(3, true);
this.name = (entry.empty(4)) ? "" : entry.getColString(4, "UTF-8").trim();
this.appdate = entry.getColLong(5);
this.profileHandle = (entry.empty(6)) ? null : entry.getColString(6, null).trim();
this.depth = (int) entry.getColLong(7);
this.anchors = (int) entry.getColLong(8);
this.forkfactor = (int) entry.getColLong(9);
- this.flags = new Bitfield(entry.getColBytes(10));
+ this.flags = new Bitfield(entry.getColBytes(10, true));
this.handle = Integer.parseInt(entry.getColString(11, null), 16);
this.loaddate = entry.getColLong(12);
this.serverdate = entry.getColLong(13);
@@ -198,10 +198,10 @@ public class Request extends WorkflowJob {
namebytes = this.name.getBytes();
}
final byte[][] entry = new byte[][] {
- this.url.hash().getBytes(),
- (initiator == null) ? "".getBytes() : this.initiator.getBytes(),
+ this.url.hash(),
+ initiator,
this.url.toString().getBytes(),
- this.refhash.getBytes(),
+ this.refhash,
namebytes,
appdatestr,
(this.profileHandle == null) ? null : this.profileHandle.getBytes(),
@@ -226,21 +226,19 @@ public class Request extends WorkflowJob {
this.url = redirectedURL;
}
- public String referrerhash() {
+ public byte[] referrerhash() {
// the urlhash of a referer url
return this.refhash;
}
- public String initiator() {
+ public byte[] initiator() {
// returns the hash of the initiating peer
- if (initiator == null) return "";
- if (initiator.length() == 0) return "";
return initiator;
}
public boolean proxy() {
// true when the url was retrieved using the proxy
- return (initiator() == null);
+ return (initiator() == null || initiator().length == 0);
}
public Date appdate() {
diff --git a/source/de/anomic/crawler/retrieval/Response.java b/source/de/anomic/crawler/retrieval/Response.java
index 21d53460e..174cc2968 100755
--- a/source/de/anomic/crawler/retrieval/Response.java
+++ b/source/de/anomic/crawler/retrieval/Response.java
@@ -216,7 +216,7 @@ public class Response {
return this.profile;
}
- public String initiator() {
+ public byte[] initiator() {
return this.request.initiator();
}
@@ -745,7 +745,7 @@ public class Response {
}
}
- public String referrerHash() {
+ public byte[] referrerHash() {
if (requestHeader == null) return null;
String u = requestHeader.get(RequestHeader.REFERER, "");
if (u == null || u.length() == 0) return null;
@@ -785,10 +785,10 @@ public class Response {
// 6) local fetching for global crawling (other known or unknwon initiator)
EventOrigin processCase = EventOrigin.UNKNOWN;
// FIXME the equals seems to be incorrect: String.equals(boolean)
- if ((initiator() == null) || initiator().length() == 0 || initiator().equals("------------")) {
+ if ((initiator() == null) || initiator().length == 0 || new String(initiator()).equals("------------")) {
// proxy-load
processCase = EventOrigin.PROXY_LOAD;
- } else if (initiator().equals(mySeedHash)) {
+ } else if (new String(initiator()).equals(mySeedHash)) {
// normal crawling
processCase = EventOrigin.LOCAL_CRAWLING;
} else {
diff --git a/source/de/anomic/crawler/retrieval/SMBLoader.java b/source/de/anomic/crawler/retrieval/SMBLoader.java
index c9321f3d1..d136461e6 100644
--- a/source/de/anomic/crawler/retrieval/SMBLoader.java
+++ b/source/de/anomic/crawler/retrieval/SMBLoader.java
@@ -78,7 +78,7 @@ public class SMBLoader {
if (l == null) {
// this can only happen if there is no connection or the directory does not exist
log.logInfo("directory listing not available. URL = " + request.url().toString());
- sb.crawlQueues.errorURL.push(request, this.sb.peers.mySeed().hash, new Date(), 1, "directory listing not available. URL = " + request.url().toString());
+ sb.crawlQueues.errorURL.push(request, this.sb.peers.mySeed().hash.getBytes(), new Date(), 1, "directory listing not available. URL = " + request.url().toString());
throw new IOException("directory listing not available. URL = " + request.url().toString());
}
for (String s: l) list.add(u + s);
diff --git a/source/de/anomic/data/SitemapParser.java b/source/de/anomic/data/SitemapParser.java
index 7d7347298..f594bdedb 100644
--- a/source/de/anomic/data/SitemapParser.java
+++ b/source/de/anomic/data/SitemapParser.java
@@ -250,7 +250,7 @@ public class SitemapParser extends DefaultHandler {
return;
// get the url hash
- String nexturlhash = null;
+ byte[] nexturlhash = null;
DigestURI url = null;
try {
url = new DigestURI(this.nextURL, null);
@@ -275,7 +275,7 @@ public class SitemapParser extends DefaultHandler {
// URL needs to crawled
this.sb.crawlStacker.enqueueEntry(new Request(
- this.sb.peers.mySeed().hash,
+ this.sb.peers.mySeed().hash.getBytes(),
url,
null, // this.siteMapURL.toString(),
this.nextURL,
diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.java
index b02f7bec5..67d96ff5f 100644
--- a/source/de/anomic/data/bookmarksDB.java
+++ b/source/de/anomic/data/bookmarksDB.java
@@ -245,7 +245,7 @@ public class bookmarksDB {
// check if the crawl filter works correctly
Pattern.compile(newcrawlingMustMatch);
- byte[] urlhash = crawlingStartURL.hash().getBytes();
+ byte[] urlhash = crawlingStartURL.hash();
sb.indexSegments.urlMetadata(Segments.Process.LOCALCRAWLING).remove(urlhash);
sb.crawlQueues.noticeURL.removeByURLHash(urlhash);
sb.crawlQueues.errorURL.remove(urlhash);
@@ -262,7 +262,7 @@ public class bookmarksDB {
indexText, indexMedia,
storeHTCache, true, crawlOrder, xsstopw, xdstopw, xpstopw, cacheStrategy);
sb.crawlStacker.enqueueEntry(new Request(
- sb.peers.mySeed().hash,
+ sb.peers.mySeed().hash.getBytes(),
crawlingStartURL,
null,
"CRAWLING-ROOT",
@@ -667,7 +667,7 @@ public class bookmarksDB {
url="http://"+url;
}
try {
- this.urlHash=(new DigestURI(url, null)).hash();
+ this.urlHash = new String((new DigestURI(url, null)).hash());
} catch (final MalformedURLException e) {
this.urlHash = null;
}
@@ -704,7 +704,7 @@ public class bookmarksDB {
}
public Bookmark(final Map<String, String> map) throws MalformedURLException {
- this((new DigestURI(map.get(BOOKMARK_URL), null)).hash(), map);
+ this(new String((new DigestURI(map.get(BOOKMARK_URL), null)).hash()), map);
}
Map<String, String> toMap() {
diff --git a/source/de/anomic/http/client/Cache.java b/source/de/anomic/http/client/Cache.java
index 687b86f4d..24019fbd3 100644
--- a/source/de/anomic/http/client/Cache.java
+++ b/source/de/anomic/http/client/Cache.java
@@ -117,14 +117,14 @@ public final class Cache {
hm.putAll(responseHeader);
hm.put("@@URL", url.toNormalform(true, false));
try {
- responseHeaderDB.put(url.hash(), hm);
+ responseHeaderDB.put(new String(url.hash()), hm);
} catch (Exception e) {
throw new IOException("Cache.store: cannot write to headerDB: " + e.getMessage());
}
// store the file
try {
- fileDB.put(url.hash().getBytes("UTF-8"), file);
+ fileDB.put(url.hash(), file);
} catch (UnsupportedEncodingException e) {
throw new IOException("Cache.store: cannot write to fileDB (1): " + e.getMessage());
} catch (IOException e) {
@@ -141,20 +141,20 @@ public final class Cache {
public static boolean has(final DigestURI url) {
boolean headerExists;
try {
- headerExists = responseHeaderDB.has(url.hash());
+ headerExists = responseHeaderDB.has(new String(url.hash()));
} catch (IOException e1) {
try {
- fileDB.remove(url.hash().getBytes());
+ fileDB.remove(url.hash());
} catch (IOException e) {}
return false;
}
- boolean fileExists = fileDB.has(url.hash().getBytes());
+ boolean fileExists = fileDB.has(url.hash());
if (headerExists && fileExists) return true;
if (headerExists) try {
- responseHeaderDB.remove(url.hash());
+ responseHeaderDB.remove(new String(url.hash()));
} catch (IOException e) {}
if (fileExists) try {
- fileDB.remove(url.hash().getBytes());
+ fileDB.remove(url.hash());
} catch (IOException e) {}
return false;
}
@@ -173,7 +173,7 @@ public final class Cache {
// loading data from database
Map<String, String> hdb;
try {
- hdb = responseHeaderDB.get(url.hash());
+ hdb = responseHeaderDB.get(new String(url.hash()));
} catch (final IOException e) {
return null;
}
@@ -194,7 +194,7 @@ public final class Cache {
public static byte[] getContent(final DigestURI url) throws IOException {
// load the url as resource from the cache
try {
- return fileDB.get(url.hash().getBytes("UTF-8"));
+ return fileDB.get(url.hash());
} catch (UnsupportedEncodingException e) {
Log.logException(e);
return null;
@@ -208,7 +208,7 @@ public final class Cache {
* @throws IOException
*/
public static void delete(final DigestURI url) throws IOException {
- responseHeaderDB.remove(url.hash());
- fileDB.remove(url.hash().getBytes("UTF-8"));
+ responseHeaderDB.remove(new String(url.hash()));
+ fileDB.remove(url.hash());
}
}
diff --git a/source/de/anomic/http/client/Client.java b/source/de/anomic/http/client/Client.java
index 2099c347f..25c3eb63e 100644
--- a/source/de/anomic/http/client/Client.java
+++ b/source/de/anomic/http/client/Client.java
@@ -472,19 +472,19 @@ public class Client {
} catch (final IllegalThreadStateException e) {
// cleanUp statistics
DigestURI url = new DigestURI(method.getURI().toString(), null);
- if (url.hash() != null) Latency.slowdown(url.hash().substring(6), url.getHost());
+ if (url.hash() != null) Latency.slowdown(new String(url.hash()).substring(6), url.getHost());
ConnectionInfo.removeConnection(generateConInfo(method));
throw e;
} catch (final IOException e) {
// cleanUp statistics
DigestURI url = new DigestURI(method.getURI().toString(), null);
- if (url.hash() != null) Latency.slowdown(url.hash().substring(6), url.getHost());
+ if (url.hash() != null) Latency.slowdown(new String(url.hash()).substring(6), url.getHost());
ConnectionInfo.removeConnection(generateConInfo(method));
throw e;
} catch (final IllegalStateException e) {
// cleanUp statistics
DigestURI url = new DigestURI(method.getURI().toString(), null);
- if (url.hash() != null) Latency.slowdown(url.hash().substring(6), url.getHost());
+ if (url.hash() != null) Latency.slowdown(new String(url.hash()).substring(6), url.getHost());
ConnectionInfo.removeConnection(generateConInfo(method));
throw new IOException(e.getMessage());
}
diff --git a/source/de/anomic/http/server/HTTPDFileHandler.java b/source/de/anomic/http/server/HTTPDFileHandler.java
index 41a604428..2d6ec199f 100644
--- a/source/de/anomic/http/server/HTTPDFileHandler.java
+++ b/source/de/anomic/http/server/HTTPDFileHandler.java
@@ -294,7 +294,7 @@ public final class HTTPDFileHandler {
final boolean adminAccountForLocalhost = sb.getConfigBool("adminAccountForLocalhost", false);
final String refererHost = requestHeader.refererHost();
- boolean accessFromLocalhost = Domains.isLocal(clientIP) && (refererHost.length() == 0 || Domains.isLocal(refererHost));
+ boolean accessFromLocalhost = Domains.isLocal(clientIP) && (refererHost == null || refererHost.length() == 0 || Domains.isLocal(refererHost));
final boolean grantedForLocalhost = adminAccountForLocalhost && accessFromLocalhost;
final boolean protectedPage = path.indexOf("_p.") > 0;
final boolean accountEmpty = adminAccountBase64MD5.length() == 0;
diff --git a/source/de/anomic/http/server/HTTPDProxyHandler.java b/source/de/anomic/http/server/HTTPDProxyHandler.java
index bcb254306..4c4589cd6 100644
--- a/source/de/anomic/http/server/HTTPDProxyHandler.java
+++ b/source/de/anomic/http/server/HTTPDProxyHandler.java
@@ -385,7 +385,7 @@ public final class HTTPDProxyHandler {
final Request request = new Request(
null,
url,
- requestHeader.referer(),
+ requestHeader.referer() == null ? null : requestHeader.referer().hash(),
"",
new Date(),
new Date(),
@@ -508,7 +508,7 @@ public final class HTTPDProxyHandler {
final Request request = new Request(
null,
url,
- requestHeader.referer(),
+ requestHeader.referer() == null ? null : requestHeader.referer().hash(),
"",
new Date(),
new Date(),
diff --git a/source/de/anomic/http/server/RequestHeader.java b/source/de/anomic/http/server/RequestHeader.java
index 5972b7490..06bf9c79f 100755
--- a/source/de/anomic/http/server/RequestHeader.java
+++ b/source/de/anomic/http/server/RequestHeader.java
@@ -85,20 +85,20 @@ public class RequestHeader extends HeaderFramework {
super(reverseMappingCache, othermap);
}
- public String referer() {
- return get(REFERER, "");
+ public DigestURI referer() {
+ String referer = get(REFERER, null);
+ if (referer == null) return null;
+ try {
+ return new DigestURI(referer, null);
+ } catch (MalformedURLException e) {
+ return null;
+ }
}
public String refererHost() {
- final String referer = referer();
- if (referer.length() == 0) return referer;
- DigestURI url;
- try {
- url = new DigestURI(referer, null);
- return url.getHost();
- } catch (MalformedURLException e1) {
- return referer;
- }
+ final DigestURI url = referer();
+ if (url == null) return null;
+ return url.getHost();
}
public Date ifModifiedSince() {
diff --git a/source/de/anomic/search/MediaSnippet.java b/source/de/anomic/search/MediaSnippet.java
index a10abbcd6..093b34662 100644
--- a/source/de/anomic/search/MediaSnippet.java
+++ b/source/de/anomic/search/MediaSnippet.java
@@ -85,11 +85,11 @@ public class MediaSnippet implements Comparable<MediaSnippet>, Comparator<MediaS
@Override
public int hashCode() {
- return href.hash().hashCode();
+ return new String(href.hash()).hashCode();
}
public String toString() {
- return href.hash();
+ return new String(href.hash());
}
public boolean equals(final Object obj) {
@@ -97,11 +97,11 @@ public class MediaSnippet implements Comparable<MediaSnippet>, Comparator<MediaS
if (obj == null) return false;
if (!(obj instanceof MediaSnippet)) return false;
MediaSnippet other = (MediaSnippet) obj;
- return this.href.hash().equals(other.href.hash());
+ return Base64Order.enhancedCoder.equal(this.href.hash(), other.href.hash());
}
public int compareTo(MediaSnippet o) {
- return Base64Order.enhancedCoder.compare(this.href.hash().getBytes(), o.href.hash().getBytes());
+ return Base64Order.enhancedCoder.compare(this.href.hash(), o.href.hash());
}
public int compare(MediaSnippet o1, MediaSnippet o2) {
diff --git a/source/de/anomic/search/MetadataRepository.java b/source/de/anomic/search/MetadataRepository.java
index c13bc723c..ed5b425a0 100644
--- a/source/de/anomic/search/MetadataRepository.java
+++ b/source/de/anomic/search/MetadataRepository.java
@@ -115,13 +115,13 @@ public final class MetadataRepository implements Iterable<byte[]> {
return 0;
}
- public synchronized URIMetadataRow load(final String urlHash, final WordReferenceVars searchedWord, final long ranking) {
+ public synchronized URIMetadataRow load(final byte[] urlHash, final WordReferenceVars searchedWord, final long ranking) {
// generates an plasmaLURLEntry using the url hash
// if the url cannot be found, this returns null
if (urlHash == null) return null;
- assert urlIndexFile != null : "urlHash = " + urlHash;
+ assert urlIndexFile != null : "urlHash = " + new String(urlHash);
try {
- final Row.Entry entry = urlIndexFile.get(urlHash.getBytes());
+ final Row.Entry entry = urlIndexFile.get(urlHash);
if (entry == null) return null;
return new URIMetadataRow(entry, searchedWord, ranking);
} catch (final IOException e) {
@@ -167,9 +167,9 @@ public final class MetadataRepository implements Iterable<byte[]> {
}
}
- public boolean exists(final String urlHash) {
+ public boolean exists(final byte[] urlHash) {
if (urlIndexFile == null) return false; // case may happen during shutdown
- return urlIndexFile.has(urlHash.getBytes());
+ return urlIndexFile.has(urlHash);
}
public CloneableIterator<byte[]> keys(boolean up, byte[] firstKey) {
@@ -589,7 +589,7 @@ public final class MetadataRepository implements Iterable<byte[]> {
TreeSet<String> set = new TreeSet<String>();
for (hashStat hs: map.values()) {
if (hs == null) continue;
- urlref = this.load(hs.urlhash, null, 0);
+ urlref = this.load(hs.urlhash.getBytes(), null, 0);
if (urlref == null || urlref.metadata() == null || urlref.metadata().url() == null || urlref.metadata().url().getHost() == null) continue;
set.add(urlref.metadata().url().getHost());
count--;
@@ -623,7 +623,7 @@ public final class MetadataRepository implements Iterable<byte[]> {
while (j.hasNext()) {
urlhash = j.next();
if (urlhash == null) continue;
- urlref = this.load(urlhash, null, 0);
+ urlref = this.load(urlhash.getBytes(), null, 0);
if (urlref == null || urlref.metadata() == null || urlref.metadata().url() == null || urlref.metadata().url().getHost() == null) continue;
if (statsDump == null) return new ArrayList<hostStat>().iterator(); // some other operation has destroyed the object
comps = urlref.metadata();
diff --git a/source/de/anomic/search/RankingProcess.java b/source/de/anomic/search/RankingProcess.java
index c502e8224..613c42852 100644
--- a/source/de/anomic/search/RankingProcess.java
+++ b/source/de/anomic/search/RankingProcess.java
@@ -205,7 +205,7 @@ public final class RankingProcess extends Thread {
}
// check tld domain
- if (!DigestURI.matchesAnyDomDomain(iEntry.metadataHash(), this.query.zonecode)) {
+ if (!DigestURI.matchesAnyDomDomain(iEntry.metadataHash().getBytes(), this.query.zonecode)) {
// filter out all tld that do not match with wanted tld domain
continue;
}
@@ -383,7 +383,7 @@ public final class RankingProcess extends Thread {
continue;
}
urlhash = obrwi.element.metadataHash();
- final URIMetadataRow page = this.query.getSegment().urlMetadata().load(urlhash, obrwi.element, obrwi.weight.longValue());
+ final URIMetadataRow page = this.query.getSegment().urlMetadata().load(urlhash.getBytes(), obrwi.element, obrwi.weight.longValue());
if (page == null) {
misses.add(obrwi.element.metadataHash());
continue;
@@ -561,7 +561,7 @@ public final class RankingProcess extends Thread {
String hostname;
Components metadata;
loop: for (Navigator.Item item: hsa) {
- mr = this.query.getSegment().urlMetadata().load(item.name, null, 0);
+ mr = this.query.getSegment().urlMetadata().load(item.name.getBytes(), null, 0);
if (mr == null) continue;
metadata = mr.metadata();
if (metadata == null) continue;
diff --git a/source/de/anomic/search/ReferenceOrder.java b/source/de/anomic/search/ReferenceOrder.java
index aee4910a3..731533f37 100644
--- a/source/de/anomic/search/ReferenceOrder.java
+++ b/source/de/anomic/search/ReferenceOrder.java
@@ -174,7 +174,7 @@ public class ReferenceOrder {
+ ((flags.get(Condenser.flag_cat_hasvideo)) ? 255 << ranking.coeff_cathasvideo : 0)
+ ((flags.get(Condenser.flag_cat_hasapp)) ? 255 << ranking.coeff_cathasapp : 0)
+ ((patchUK(t.language).equals(this.language)) ? 255 << ranking.coeff_language : 0)
- + ((DigestURI.probablyRootURL(t.metadataHash())) ? 15 << ranking.coeff_urllength : 0);
+ + ((DigestURI.probablyRootURL(t.metadataHash().getBytes())) ? 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
diff --git a/source/de/anomic/search/Segment.java b/source/de/anomic/search/Segment.java
index 585cc66ed..c21838b36 100644
--- a/source/de/anomic/search/Segment.java
+++ b/source/de/anomic/search/Segment.java
@@ -205,7 +205,7 @@ public class Segment {
Map.Entry<String, Word> wentry;
String word;
int len = (document == null) ? urlLength : document.dc_title().length();
- WordReferenceRow ientry = new WordReferenceRow(url.hash(),
+ WordReferenceRow ientry = new WordReferenceRow(new String(url.hash()),
urlLength, urlComps, len,
condenser.RESULT_NUMB_WORDS,
condenser.RESULT_NUMB_SENTENCES,
@@ -305,7 +305,7 @@ public class Segment {
docDate, // modification date
new Date(), // loaded date
new Date(ldate + Math.max(0, ldate - docDate.getTime()) / 2), // freshdate, computed with Proxy-TTL formula
- (referrerURL == null) ? null : referrerURL.hash(), // referer hash
+ (referrerURL == null) ? null : new String(referrerURL.hash()), // referer hash
new byte[0], // md5
(int) sourcesize, // size
condenser.RESULT_NUMB_WORDS, // word count
@@ -343,7 +343,7 @@ public class Segment {
// TODO: UTF-8 docDescription seems not to be displayed correctly because
// of string concatenation
log.logInfo("*Indexed " + words + " words in URL " + url +
- " [" + url.hash() + "]" +
+ " [" + new String(url.hash()) + "]" +
"\n\tDescription: " + dc_title +
"\n\tMimeType: " + document.dc_format() + " | Charset: " + document.getCharset() + " | " +
"Size: " + document.getTextLength() + " bytes | " +
@@ -362,7 +362,7 @@ public class Segment {
return removeAllUrlReferences(url.hash(), loader, fetchOnline);
}
- public int removeAllUrlReferences(final String urlhash, LoaderDispatcher loader, final boolean fetchOnline) {
+ public int removeAllUrlReferences(final byte[] urlhash, LoaderDispatcher loader, final boolean fetchOnline) {
// find all the words in a specific resource and remove the url reference from every word index
// finally, delete the url entry
@@ -384,7 +384,7 @@ public class Segment {
}
if (resourceb == null) {
// delete just the url entry
- urlMetadata().remove(urlhash.getBytes());
+ urlMetadata().remove(urlhash);
return 0;
} else {
resourceContent = new ByteArrayInputStream(resourceb);
@@ -403,10 +403,10 @@ public class Segment {
// delete all word references
int count = 0;
- if (words != null) count = termIndex().remove(Word.words2hashes(words), urlhash.getBytes());
+ if (words != null) count = termIndex().remove(Word.words2hashes(words), urlhash);
// finally delete the url entry itself
- urlMetadata().remove(urlhash.getBytes());
+ urlMetadata().remove(urlhash);
return count;
}
} catch (final ParserException e) {
@@ -458,7 +458,7 @@ public class Segment {
entry = new WordReferenceVars(containerIterator.next());
// System.out.println("Wordhash: "+wordHash+" UrlHash:
// "+entry.getUrlHash());
- final URIMetadataRow ue = urlMetadata.load(entry.metadataHash(), entry, 0);
+ final URIMetadataRow ue = urlMetadata.load(entry.metadataHash().getBytes(), entry, 0);
if (ue == null) {
urlHashs.add(entry.metadataHash());
} else {
diff --git a/source/de/anomic/search/Switchboard.java b/source/de/anomic/search/Switchboard.java
index 7ac009bd9..43a8205dc 100644
--- a/source/de/anomic/search/Switchboard.java
+++ b/source/de/anomic/search/Switchboard.java
@@ -1032,7 +1032,7 @@ public final class Switchboard extends serverSwitch {
}
}
- public String urlExists(final Segments.Process process, final String hash) {
+ public String urlExists(final Segments.Process process, final byte[] hash) {
// tests if hash occurrs in any database
// if it exists, the name of the database is returned,
// if it not exists, null is returned
@@ -1052,9 +1052,9 @@ public final class Switchboard extends serverSwitch {
crawlQueues.urlRemove(hash);
}
- public DigestURI getURL(final Segments.Process process, final String urlhash) {
+ public DigestURI getURL(final Segments.Process process, final byte[] urlhash) {
if (urlhash == null) return null;
- if (urlhash.length() == 0) return null;
+ if (urlhash.length == 0) return null;
final DigestURI ne = crawlQueues.getURL(urlhash);
if (ne != null) return ne;
final URIMetadataRow le = indexSegments.urlMetadata(process).load(urlhash, null, 0);
@@ -1224,7 +1224,7 @@ public final class Switchboard extends serverSwitch {
// log cause and close queue
final DigestURI referrerURL = response.referrerURL();
if (log.isFine()) log.logFine("deQueue: not indexed any word in URL " + response.url() + "; cause: " + noIndexReason);
- addURLtoErrorDB(response.url(), (referrerURL == null) ? "" : referrerURL.hash(), response.initiator(), response.name(), noIndexReason);
+ addURLtoErrorDB(response.url(), (referrerURL == null) ? null : referrerURL.hash(), response.initiator(), response.name(), noIndexReason);
// finish this entry
return "not allowed: " + noIndexReason;
}
@@ -1265,7 +1265,7 @@ public final class Switchboard extends serverSwitch {
// create a queue entry
Document document = surrogate.document();
Request request = new Request(
- peers.mySeed().hash,
+ peers.mySeed().hash.getBytes(),
surrogate.getIdentifier(),
null,
"",
@@ -1638,7 +1638,7 @@ public final class Switchboard extends serverSwitch {
", maxDepth=" + ((response.profile() == null) ? "null" : Integer.toString(response.profile().depth())) +
", must-match=" + ((response.profile() == null) ? "null" : response.profile().mustMatchPattern().toString()) +
", must-not-match=" + ((response.profile() == null) ? "null" : response.profile().mustNotMatchPattern().toString()) +
- ", initiatorHash=" + response.initiator() +
+ ", initiatorHash=" + new String(response.initiator()) +
//", responseHeader=" + ((entry.responseHeader() == null) ? "null" : entry.responseHeader().toString()) +
", url=" + response.url()); // DEBUG
@@ -1782,13 +1782,13 @@ public final class Switchboard extends serverSwitch {
if (condenser == null || document.indexingDenied()) {
if (this.log.isInfo()) log.logInfo("Not Indexed Resource '" + queueEntry.url().toNormalform(false, true) + "': denied by rule in document, process case=" + processCase);
- addURLtoErrorDB(queueEntry.url(), (referrerURL == null) ? "" : referrerURL.hash(), queueEntry.initiator(), dc_title, "unknown indexing process case" + processCase);
+ addURLtoErrorDB(queueEntry.url(), (referrerURL == null) ? null : referrerURL.hash(), queueEntry.initiator(), dc_title, "unknown indexing process case" + processCase);
return;
}
if (!queueEntry.profile().indexText() && !queueEntry.profile().indexMedia()) {
if (this.log.isInfo()) log.logInfo("Not Indexed Resource '" + queueEntry.url().toNormalform(false, true) + "': denied by profile rule, process case=" + processCase);
- addURLtoErrorDB(queueEntry.url(), (referrerURL == null) ? "" : referrerURL.hash(), queueEntry.initiator(), dc_title, "unknown indexing process case" + processCase);
+ addURLtoErrorDB(queueEntry.url(), (referrerURL == null) ? null : referrerURL.hash(), queueEntry.initiator(), dc_title, "unknown indexing process case" + processCase);
return;
}
@@ -1805,19 +1805,19 @@ public final class Switchboard extends serverSwitch {
queueEntry.size(),
document,
condenser);
- RSSFeed.channels((queueEntry.initiator().equals(peers.mySeed().hash)) ? RSSFeed.LOCALINDEXING : RSSFeed.REMOTEINDEXING).addMessage(new RSSMessage("Indexed web page", dc_title, queueEntry.url().toNormalform(true, false)));
+ RSSFeed.channels(Base64Order.enhancedCoder.equal(queueEntry.initiator(), peers.mySeed().hash.getBytes()) ? RSSFeed.LOCALINDEXING : RSSFeed.REMOTEINDEXING).addMessage(new RSSMessage("Indexed web page", dc_title, queueEntry.url().toNormalform(true, false)));
} catch (final IOException e) {
if (this.log.isFine()) log.logFine("Not Indexed Resource '" + queueEntry.url().toNormalform(false, true) + "': process case=" + processCase);
- addURLtoErrorDB(queueEntry.url(), (referrerURL == null) ? "" : referrerURL.hash(), queueEntry.initiator(), dc_title, "error storing url: " + e.getMessage());
+ addURLtoErrorDB(queueEntry.url(), (referrerURL == null) ? null : referrerURL.hash(), queueEntry.initiator(), dc_title, "error storing url: " + e.getMessage());
return;
}
// update url result list statistics
crawlResults.stack(
- newEntry, // loaded url db entry
- queueEntry.initiator(), // initiator peer hash
- this.peers.mySeed().hash, // executor peer hash
- processCase // process case
+ newEntry, // loaded url db entry
+ queueEntry.initiator(), // initiator peer hash
+ this.peers.mySeed().hash.getBytes(), // executor peer hash
+ processCase // process case
);
// increment number of indexed urls
@@ -1834,12 +1834,12 @@ public final class Switchboard extends serverSwitch {
// if this was performed for a remote crawl request, notify requester
if ((processCase == EventOrigin.GLOBAL_CRAWLING) && (queueEntry.initiator() != null)) {
- final yacySeed initiatorPeer = peers.get(queueEntry.initiator());
+ final yacySeed initiatorPeer = peers.get(new String(queueEntry.initiator()));
if (initiatorPeer != null) {
log.logInfo("Sending crawl receipt for '" + queueEntry.url().toNormalform(false, true) + "' to " + initiatorPeer.getName());
- if (clusterhashes != null) initiatorPeer.setAlternativeAddress(clusterhashes.get(queueEntry.initiator().getBytes()));
+ if (clusterhashes != null) initiatorPeer.setAlternativeAddress(clusterhashes.get(queueEntry.initiator()));
// start a thread for receipt sending to avoid a blocking here
- new Thread(new receiptSending(initiatorPeer, newEntry), "sending receipt to " + queueEntry.initiator()).start();
+ new Thread(new receiptSending(initiatorPeer, newEntry), "sending receipt to " + new String(queueEntry.initiator())).start();
}
}
}
@@ -1880,7 +1880,7 @@ public final class Switchboard extends serverSwitch {
// authorization for localhost, only if flag is set to grant localhost access as admin
final String clientIP = requestHeader.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "");
final String refererHost = requestHeader.refererHost();
- boolean accessFromLocalhost = Domains.isLocal(clientIP) && (refererHost.length() == 0 || Domains.isLocal(refererHost));
+ boolean accessFromLocalhost = Domains.isLocal(clientIP) && (refererHost == null || refererHost.length() == 0 || Domains.isLocal(refererHost));
if (getConfigBool("adminAccountForLocalhost", false) && accessFromLocalhost) return 3; // soft-authenticated for localhost
// get the authorization string from the header
@@ -2041,8 +2041,8 @@ public final class Switchboard extends serverSwitch {
private void addURLtoErrorDB(
final DigestURI url,
- final String referrerHash,
- final String initiator,
+ final byte[] referrerHash,
+ final byte[] initiator,
final String name,
final String failreason
) {
diff --git a/source/de/anomic/search/TextSnippet.java b/source/de/anomic/search/TextSnippet.java
index 7c6c0e70c..97369cbed 100644
--- a/source/de/anomic/search/TextSnippet.java
+++ b/source/de/anomic/search/TextSnippet.java
@@ -83,7 +83,7 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnip
public static boolean existsInCache(final DigestURI url, final TreeSet<byte[]> queryhashes) {
final String hashes = yacySearch.set2string(queryhashes);
- return retrieveFromCache(hashes, url.hash()) != null;
+ return retrieveFromCache(hashes, new String(url.hash())) != null;
}
public static void storeToCache(final String wordhashes, final String urlhash, final String snippet) {
@@ -170,13 +170,13 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnip
return line != null;
}
public int compareTo(TextSnippet o) {
- return Base64Order.enhancedCoder.compare(this.url.hash().getBytes(), o.url.hash().getBytes());
+ return Base64Order.enhancedCoder.compare(this.url.hash(), o.url.hash());
}
public int compare(TextSnippet o1, TextSnippet o2) {
return o1.compareTo(o2);
}
public int hashCode() {
- return this.url.hash().hashCode();
+ return new String(this.url.hash()).hashCode();
}
@Override
@@ -318,10 +318,10 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnip
// try to get snippet from snippetCache
int source = SOURCE_CACHE;
final String wordhashes = yacySearch.set2string(queryhashes);
- String line = retrieveFromCache(wordhashes, url.hash());
+ String line = retrieveFromCache(wordhashes, new String(url.hash()));
if (line != null) {
// found the snippet
- return new TextSnippet(url, line, source, null, null, faviconCache.get(url.hash()));
+ return new TextSnippet(url, line, source, null, null, faviconCache.get(new String(url.hash())));
}
@@ -336,16 +336,16 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnip
String loc;
if (containsAllHashes(loc = comp.dc_title(), queryhashes)) {
// try to create the snippet from information given in the url itself
- return new TextSnippet(url, loc, SOURCE_METADATA, null, null, faviconCache.get(url.hash()));
+ return new TextSnippet(url, loc, SOURCE_METADATA, null, null, faviconCache.get(new String(url.hash())));
} else if (containsAllHashes(loc = comp.dc_creator(), queryhashes)) {
// try to create the snippet from information given in the creator metadata
- return new TextSnippet(url, loc, SOURCE_METADATA, null, null, faviconCache.get(url.hash()));
+ return new TextSnippet(url, loc, SOURCE_METADATA, null, null, faviconCache.get(new String(url.hash())));
} else if (containsAllHashes(loc = comp.dc_subject(), queryhashes)) {
// try to create the snippet from information given in the subject metadata
- return new TextSnippet(url, loc, SOURCE_METADATA, null, null, faviconCache.get(url.hash()));
+ return new TextSnippet(url, loc, SOURCE_METADATA, null, null, faviconCache.get(new String(url.hash())));
} else if (containsAllHashes(loc = comp.url().toNormalform(true, true).replace('-', ' '), queryhashes)) {
// try to create the snippet from information given in the subject metadata
- return new TextSnippet(url, loc, SOURCE_METADATA, null, null, faviconCache.get(url.hash()));
+ return new TextSnippet(url, loc, SOURCE_METADATA, null, null, faviconCache.get(new String(url.hash())));
} else {
// trying to load the resource from the cache
@@ -405,7 +405,7 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnip
* COMPUTE SNIPPET
* =========================================================================== */
final DigestURI resFavicon = document.getFavicon();
- if (resFavicon != null) faviconCache.put(url.hash(), resFavicon);
+ if (resFavicon != null) faviconCache.put(new String(url.hash()), resFavicon);
// we have found a parseable non-empty file: use the lines
// compute snippet from text
@@ -433,7 +433,7 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnip
if (line.length() > snippetMaxLength) line = line.substring(0, snippetMaxLength);
// finally store this snippet in our own cache
- storeToCache(wordhashes, url.hash(), line);
+ storeToCache(wordhashes, new String(url.hash()), line);
document.close();
return new TextSnippet(url, line, source, null, null, resFavicon);
@@ -579,7 +579,7 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnip
public static String failConsequences(Segment indexSegment, final WordReferenceVars word, final TextSnippet snippet, final String eventID) throws IOException {
// problems with snippet fetch
- final byte[] urlHash = snippet.getUrl().hash().getBytes();
+ final byte[] urlHash = snippet.getUrl().hash();
final String querystring = SetTools.setToString(snippet.getRemainingHashes(), ' ');
if ((snippet.getErrorCode() == ERROR_SOURCE_LOADING) ||
(snippet.getErrorCode() == ERROR_RESOURCE_LOADING) ||
diff --git a/source/de/anomic/search/blockrank/CRProcess.java b/source/de/anomic/search/blockrank/CRProcess.java
index 1ebc28717..fe02dd917 100644
--- a/source/de/anomic/search/blockrank/CRProcess.java
+++ b/source/de/anomic/search/blockrank/CRProcess.java
@@ -60,6 +60,28 @@ public class CRProcess {
header.append("# ---"); header.append((char) 13); header.append((char) 10);
*/
+ /*
+ private static final int Col_Referee = 0;
+ private static final int Col_UDate = 1;
+ private static final int Col_VDate = 2;
+ private static final int Col_LCount = 3;
+ private static final int Col_GCount = 4;
+ private static final int Col_ICount = 5;
+ private static final int Col_DCount = 6;
+ private static final int Col_TLength = 7;
+ private static final int Col_WACount = 8;
+ private static final int Col_WUCount = 9;
+ */
+ private static final int Col_Flags = 10;
+ private static final int Col_FUDate = 11;
+ private static final int Col_FDDate = 12;
+ private static final int Col_LUDate = 13;
+ private static final int Col_UCount = 14;
+ private static final int Col_PCount = 15;
+ private static final int Col_ACount = 16;
+ private static final int Col_VCount = 17;
+ private static final int Col_Vita = 18;
+
public static final Row CRG_accrow = new Row(
"byte[] Referee-12," +
"Cardinal UDate-3 {b64e}, Cardinal VDate-3 {b64e}, " +
@@ -169,14 +191,14 @@ public class CRProcess {
new_flags = new Bitfield(Base64Order.enhancedCoder.encodeLong(new_entry.getAttr("Flags", 0), 1).getBytes());
// enrich information with additional values
if ((acc_entry = acc.get(key.getBytes())) != null) {
- FUDate = (int) acc_entry.getColLong("FUDate", 0);
- FDDate = (int) acc_entry.getColLong("FDDate", 0);
- LUDate = (int) acc_entry.getColLong("LUDate", 0);
- UCount = (int) acc_entry.getColLong("UCount", 0);
- PCount = (int) acc_entry.getColLong("PCount", 0);
- ACount = (int) acc_entry.getColLong("ACount", 0);
- VCount = (int) acc_entry.getColLong("VCount", 0);
- Vita = (int) acc_entry.getColLong("Vita", 0);
+ FUDate = (int) acc_entry.getColLong(Col_FUDate);
+ FDDate = (int) acc_entry.getColLong(Col_FDDate);
+ LUDate = (int) acc_entry.getColLong(Col_LUDate);
+ UCount = (int) acc_entry.getColLong(Col_UCount);
+ PCount = (int) acc_entry.getColLong(Col_PCount);
+ ACount = (int) acc_entry.getColLong(Col_ACount);
+ VCount = (int) acc_entry.getColLong(Col_VCount);
+ Vita = (int) acc_entry.getColLong(Col_Vita);
// update counters and dates
//seq.add(key.getBytes(), new_entry.getSeqCollection());
@@ -187,11 +209,11 @@ public class CRProcess {
VCount += (new_flags.get(3)) ? 1 : 0;
// 'OR' the flags
- acc_flags = new Bitfield(Base64Order.enhancedCoder.encodeLong(acc_entry.getColLong("Flags", 0), 1).getBytes());
+ acc_flags = new Bitfield(Base64Order.enhancedCoder.encodeLong(acc_entry.getColLong(Col_Flags), 1).getBytes());
for (int i = 0; i < 6; i++) {
if (new_flags.get(i)) acc_flags.set(i, true);
}
- acc_entry.setCol("Flags", (int) Base64Order.enhancedCoder.decodeLong(acc_flags.exportB64()));
+ acc_entry.setCol(Col_Flags, (int) Base64Order.enhancedCoder.decodeLong(acc_flags.exportB64()));
} else {
// initialize counters and dates
acc_entry = acc.row().newEntry();
@@ -212,14 +234,14 @@ public class CRProcess {
// make plausibility check?
// insert into accumulator
- acc_entry.setCol("FUDate", FUDate);
- acc_entry.setCol("FDDate", FDDate);
- acc_entry.setCol("LUDate", LUDate);
- acc_entry.setCol("UCount", UCount);
- acc_entry.setCol("PCount", PCount);
- acc_entry.setCol("ACount", ACount);
- acc_entry.setCol("VCount", VCount);
- acc_entry.setCol("Vita", Vita);
+ acc_entry.setCol(Col_FUDate, FUDate);
+ acc_entry.setCol(Col_FDDate, FDDate);
+ acc_entry.setCol(Col_LUDate, LUDate);
+ acc_entry.setCol(Col_UCount, UCount);
+ acc_entry.setCol(Col_PCount, PCount);
+ acc_entry.setCol(Col_ACount, ACount);
+ acc_entry.setCol(Col_VCount, VCount);
+ acc_entry.setCol(Col_Vita, Vita);
acc.put(acc_entry);
}
diff --git a/source/de/anomic/search/blockrank/RCIEvaluation.java b/source/de/anomic/search/blockrank/RCIEvaluation.java
index d5d787472..3b5cf9bcc 100644
--- a/source/de/anomic/search/blockrank/RCIEvaluation.java
+++ b/source/de/anomic/search/blockrank/RCIEvaluation.java
@@ -161,8 +161,8 @@ public class RCIEvaluation {
dom = i.next();
if (dom.startsWith("www.")) dom = dom.substring(4);
try {
- dommap.put((new DigestURI("http://" + dom, null)).hash().substring(6), dom);
- dommap.put((new DigestURI("http://www." + dom, null)).hash().substring(6), "www." + dom);
+ dommap.put(new String((new DigestURI("http://" + dom, null)).hash()).substring(6), dom);
+ dommap.put(new String((new DigestURI("http://www." + dom, null)).hash()).substring(6), "www." + dom);
} catch (final MalformedURLException e) {}
}
return dommap;
diff --git a/source/de/anomic/yacy/dht/Transmission.java b/source/de/anomic/yacy/dht/Transmission.java
index bc4c72a3d..5ba51d695 100644
--- a/source/de/anomic/yacy/dht/Transmission.java
+++ b/source/de/anomic/yacy/dht/Transmission.java
@@ -128,7 +128,7 @@ public class Transmission {
notFound.add(e.metadataHash());
continue;
}
- URIMetadataRow r = segment.urlMetadata().load(e.metadataHash(), null, 0);
+ URIMetadataRow r = segment.urlMetadata().load(e.metadataHash().getBytes(), null, 0);
if (r == null) {
notFound.add(e.metadataHash());
badReferences.add(e.metadataHash());
diff --git a/source/de/anomic/yacy/graphics/WebStructureGraph.java b/source/de/anomic/yacy/graphics/WebStructureGraph.java
index 0a8e08ef7..2a6b8208e 100644
--- a/source/de/anomic/yacy/graphics/WebStructureGraph.java
+++ b/source/de/anomic/yacy/graphics/WebStructureGraph.java
@@ -100,15 +100,19 @@ public class WebStructureGraph {
// generate citation reference
final Map<DigestURI, String> hl = document.getHyperlinks();
final Iterator<DigestURI> it = hl.keySet().iterator();
+ byte[] nexturlhashb;
String nexturlhash;
final StringBuilder cpg = new StringBuilder(12 * (hl.size() + 1) + 1);
+ assert cpg.length() % 12 == 0 : "cpg.length() = " + cpg.length() + ", cpg = " + cpg.toString();
final StringBuilder cpl = new StringBuilder(12 * (hl.size() + 1) + 1);
- final String lhp = url.hash().substring(6); // local hash part
+ final String lhp = new String(url.hash()).substring(6); // local hash part
int GCount = 0;
int LCount = 0;
while (it.hasNext()) {
- nexturlhash = it.next().hash();
- if (nexturlhash != null) {
+ nexturlhashb = it.next().hash();
+ if (nexturlhashb != null) {
+ nexturlhash = new String(nexturlhashb);
+ assert nexturlhash.length() == 12 : "nexturlhash.length() = " + nexturlhash.length() + ", nexturlhash = " + nexturlhash;
if (nexturlhash.substring(6).equals(lhp)) {
// this is a local link
cpl.append(nexturlhash.substring(0, 6)); // store only local part
@@ -116,6 +120,7 @@ public class WebStructureGraph {
} else {
// this is a global link
cpg.append(nexturlhash); // store complete hash
+ assert cpg.length() % 12 == 0 : "cpg.length() = " + cpg.length() + ", cpg = " + cpg.toString();
GCount++;
}
}
@@ -123,7 +128,7 @@ public class WebStructureGraph {
// append this reference to buffer
// generate header info
- final String head = url.hash() + "=" +
+ final String head = new String(url.hash()) + "=" +
MicroDate.microDateHoursStr(docDate.getTime()) + // latest update timestamp of the URL
MicroDate.microDateHoursStr(System.currentTimeMillis()) + // last visit timestamp of the URL
Base64Order.enhancedCoder.encodeLongSmart(LCount, 2) + // count of links to local resources
@@ -137,7 +142,8 @@ public class WebStructureGraph {
//crl.append(head); crl.append ('|'); crl.append(cpl); crl.append((char) 13); crl.append((char) 10);
crg.append(head); crg.append('|'); crg.append(cpg); crg.append((char) 13); crg.append((char) 10);
-
+
+ assert cpg.length() % 12 == 0 : "cpg.length() = " + cpg.length() + ", cpg = " + cpg.toString();
learn(url, cpg);
// if buffer is full, flush it.
@@ -355,12 +361,12 @@ public class WebStructureGraph {
}
private void learn(final DigestURI url, final StringBuilder reference /*string of b64(12digits)-hashes*/) {
- final String domhash = url.hash().substring(6);
+ final String domhash = new String(url.hash()).substring(6);
// parse the new reference string and join it with the stored references
structureEntry structure = outgoingReferences(domhash);
final Map<String, Integer> refs = (structure == null) ? new HashMap<String, Integer>() : structure.references;
- assert reference.length() % 12 == 0;
+ assert reference.length() % 12 == 0 : "reference.length() = " + reference.length() + ", reference = " + reference.toString();
String dom;
int c;
for (int i = 0; i < reference.length() / 12; i++) {
diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java
index 07062d2f1..b27fa369c 100644
--- a/source/de/anomic/yacy/yacyClient.java
+++ b/source/de/anomic/yacy/yacyClient.java
@@ -586,7 +586,7 @@ public final class yacyClient {
// passed all checks, store url
try {
indexSegment.urlMetadata().store(urlEntry);
- crawlResults.stack(urlEntry, mySeed.hash, target.hash, EventOrigin.QUERIES);
+ crawlResults.stack(urlEntry, mySeed.hash.getBytes(), target.hash.getBytes(), EventOrigin.QUERIES);
} catch (final IOException e) {
yacyCore.log.logSevere("could not store search result", e);
continue; // db-error
@@ -1036,12 +1036,13 @@ public final class yacyClient {
gzipBody = false;
}
- String resource = "";
+ String resource;
int urlc = 0;
int urlPayloadSize = 0;
for (int i = 0; i < urls.length; i++) {
if (urls[i] != null) {
- resource = urls[i].toString();
+ resource = urls[i].toString();
+ //System.out.println("*** DEBUG resource = " + resource);
if (resource != null) {
post.add(new DefaultCharsetStringPart("url" + urlc, resource));
urlPayloadSize += resource.length();
diff --git a/source/net/yacy/dbtest.java b/source/net/yacy/dbtest.java
index ba5e04b06..9c03c3293 100644
--- a/source/net/yacy/dbtest.java
+++ b/source/net/yacy/dbtest.java
@@ -170,7 +170,7 @@ public class dbtest {
try {
Row.Entry entryBytes = getTable_test().get(entry.getKey());
if (entryBytes != null) {
- final STEntry dbEntry = new STEntry(entryBytes.getColBytes(0), entryBytes.getColBytes(1));
+ final STEntry dbEntry = new STEntry(entryBytes.getColBytes(0, true), entryBytes.getColBytes(1, true));
if (!dbEntry.isValid()) {
System.out.println("INVALID table_test: " + dbEntry);
} /* else {
@@ -181,7 +181,7 @@ public class dbtest {
if (getTable_reference() != null) {
entryBytes = getTable_reference().get(entry.getKey());
if (entryBytes != null) {
- final STEntry dbEntry = new STEntry(entryBytes.getColBytes(0), entryBytes.getColBytes(1));
+ final STEntry dbEntry = new STEntry(entryBytes.getColBytes(0, true), entryBytes.getColBytes(1, true));
if (!dbEntry.isValid()) {
System.out.println("INVALID table_reference: " + dbEntry);
} /* else {
@@ -336,13 +336,13 @@ public class dbtest {
if (entry == null)
System.out.println("missing value for entry " + new String(key) + " in test table");
else
- if (!(new String(entry.getColBytes(1)).equals(new String(key)))) System.out.println("wrong value for entry " + new String(key) + ": " + new String(entry.getColBytes(1)) + " in test table");
+ if (!(new String(entry.getColBytes(1, false)).equals(new String(key)))) System.out.println("wrong value for entry " + new String(key) + ": " + new String(entry.getColBytes(1, false)) + " in test table");
if (table_reference != null) {
entry = table_reference.get(key);
if (entry == null)
System.out.println("missing value for entry " + new String(key) + " in reference table");
else
- if (!(new String(entry.getColBytes(1)).equals(new String(key)))) System.out.println("wrong value for entry " + new String(key) + ": " + new String(entry.getColBytes(1)) + " in reference table");
+ if (!(new String(entry.getColBytes(1, false)).equals(new String(key)))) System.out.println("wrong value for entry " + new String(key) + ": " + new String(entry.getColBytes(1, false)) + " in reference table");
}
if (i % 1000 == 0) {
diff --git a/source/net/yacy/document/parser/html/ContentScraper.java b/source/net/yacy/document/parser/html/ContentScraper.java
index 72724b95b..f8bf82112 100644
--- a/source/net/yacy/document/parser/html/ContentScraper.java
+++ b/source/net/yacy/document/parser/html/ContentScraper.java
@@ -193,7 +193,7 @@ public class ContentScraper extends AbstractScraper implements Scraper {
if (type.equalsIgnoreCase("shortcut icon")) {
final ImageEntry ie = new ImageEntry(newLink, linktitle, -1, -1, -1);
- images.put(ie.url().hash(), ie);
+ images.put(new String(ie.url().hash()), ie);
this.favicon = newLink;
} else if (!type.equalsIgnoreCase("stylesheet") && !type.equalsIgnoreCase("alternate stylesheet")) {
anchors.put(newLink, linktitle);
@@ -551,11 +551,11 @@ public class ContentScraper extends AbstractScraper implements Scraper {
}
public static void addImage(final HashMap<String, ImageEntry> a, final ImageEntry ie) {
- if (a.containsKey(ie.url().hash())) {
+ if (a.containsKey(new String(ie.url().hash()))) {
// in case of a collision, take that image that has the better image size tags
- if ((ie.height() > 0) && (ie.width() > 0)) a.put(ie.url().hash(), ie);
+ if ((ie.height() > 0) && (ie.width() > 0)) a.put(new String(ie.url().hash()), ie);
} else {
- a.put(ie.url().hash(), ie);
+ a.put(new String(ie.url().hash()), ie);
}
}
diff --git a/source/net/yacy/document/parser/rssParser.java b/source/net/yacy/document/parser/rssParser.java
index 8cbe84589..85ba34014 100644
--- a/source/net/yacy/document/parser/rssParser.java
+++ b/source/net/yacy/document/parser/rssParser.java
@@ -112,7 +112,7 @@ public class rssParser extends AbstractParser implements Idiom {
if (feed.getImage() != null) {
try {
DigestURI imgURL = new DigestURI(feed.getImage(), null);
- images.put(imgURL.hash(), new ImageEntry(imgURL, feedTitle, -1, -1, -1));
+ images.put(new String(imgURL.hash()), new ImageEntry(imgURL, feedTitle, -1, -1, -1));
} catch (MalformedURLException e) {}
}
diff --git a/source/net/yacy/kelondro/blob/MapHeap.java b/source/net/yacy/kelondro/blob/MapHeap.java
index 661ad4396..136ab3a57 100644
--- a/source/net/yacy/kelondro/blob/MapHeap.java
+++ b/source/net/yacy/kelondro/blob/MapHeap.java
@@ -168,6 +168,25 @@ public class MapHeap {
}
}
+ /**
+ * remove a Map
+ * @param key the primary key
+ * @throws IOException
+ */
+ public void remove(byte[] key) throws IOException {
+ // update elementCount
+ if (key == null) return;
+ key = normalizeKey(key);
+
+ synchronized (this) {
+ // remove from cache
+ cache.remove(new String(key, "UTF-8"));
+
+ // remove from file
+ blob.remove(key);
+ }
+ }
+
/**
* remove a Map
* @param key the primary key
@@ -219,11 +238,27 @@ public class MapHeap {
private String normalizeKey(String key) {
if (blob == null || key == null) return key;
- if (key.length() > blob.keylength()) key = key.substring(0, blob.keylength());
+ if (key.length() > blob.keylength()) key = key.substring(0, blob.keylength());
while (key.length() < blob.keylength()) key += fillchar;
return key;
}
+ private byte[] normalizeKey(byte[] key) {
+ if (blob == null || key == null) return key;
+ if (key.length > blob.keylength()) {
+ byte[] b = new byte[blob.keylength()];
+ System.arraycopy(key, 0, b, 0, blob.keylength());
+ key = b;
+ }
+ if (key.length < blob.keylength()) {
+ byte[] b = new byte[blob.keylength()];
+ System.arraycopy(key, 0, b, 0, key.length);
+ for (int i = key.length; i < blob.keylength(); i++) b[i] = (byte) fillchar;
+ key = b;
+ }
+ return key;
+ }
+
protected Map<String, String> get(String key, final boolean storeCache) throws IOException {
// load map from cache
assert key != null;
diff --git a/source/net/yacy/kelondro/data/image/ImageReferenceRow.java b/source/net/yacy/kelondro/data/image/ImageReferenceRow.java
index 5f8541eff..dda91c319 100644
--- a/source/net/yacy/kelondro/data/image/ImageReferenceRow.java
+++ b/source/net/yacy/kelondro/data/image/ImageReferenceRow.java
@@ -256,7 +256,7 @@ public final class ImageReferenceRow extends AbstractReference implements /*Imag
}
public Bitfield flags() {
- return new Bitfield(this.entry.getColBytes(col_flags));
+ return new Bitfield(this.entry.getColBytes(col_flags, true));
}
public String toString() {
diff --git a/source/net/yacy/kelondro/data/meta/DigestURI.java b/source/net/yacy/kelondro/data/meta/DigestURI.java
index 33ab275af..6c8c5fcbb 100644
--- a/source/net/yacy/kelondro/data/meta/DigestURI.java
+++ b/source/net/yacy/kelondro/data/meta/DigestURI.java
@@ -82,7 +82,8 @@ public class DigestURI implements Serializable {
}
// class variables
- private String protocol, host, userInfo, path, quest, ref, hash;
+ private String protocol, host, userInfo, path, quest, ref;
+ private byte[] hash;
private int port;
public static String domhash(final String host) {
@@ -95,7 +96,7 @@ public class DigestURI implements Serializable {
Log.logException(e);
return null;
}
- return (url == null) ? null : url.hash().substring(6);
+ return (url == null) ? null : new String(url.hash()).substring(6);
}
public DigestURI(final File file) throws MalformedURLException {
@@ -106,7 +107,7 @@ public class DigestURI implements Serializable {
this(url, null);
}
- public DigestURI(final String url, final String hash) throws MalformedURLException {
+ public DigestURI(final String url, final byte[] hash) throws MalformedURLException {
if (url == null) throw new MalformedURLException("url string is null");
parseURLString(url);
@@ -746,7 +747,7 @@ public class DigestURI implements Serializable {
*/
@Override
public int hashCode() {
- return this.hash().hashCode();
+ return new String(this.hash()).hashCode();
}
/* (non-Javadoc)
@@ -818,7 +819,7 @@ public class DigestURI implements Serializable {
return (Base64Order.enhancedCoder.decodeByte(hash.charAt(11)) & 3);
}
- public final String hash() {
+ public final byte[] hash() {
// in case that the object was initialized without a known url hash, compute it now
synchronized (this) {
if (this.hash == null) this.hash = urlHashComputation();
@@ -826,7 +827,7 @@ public class DigestURI implements Serializable {
return this.hash;
}
- private final String urlHashComputation() {
+ private final byte[] urlHashComputation() {
// the url hash computation needs a DNS lookup to check if the addresses domain is local
// that causes that this method may be very slow
@@ -863,19 +864,26 @@ public class DigestURI implements Serializable {
final byte flagbyte = (byte) (((isHTTP) ? 0 : 32) | (id << 2) | domlengthKey);
// combine the attributes
- final StringBuilder hash = new StringBuilder(12);
+ final StringBuilder hashs = new StringBuilder(12);
+ assert hashs.length() == 0;
// form the 'local' part of the hash
String normalform = toNormalform(true, true, true);
String b64l = Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(normalform));
if (b64l.length() < 5) return null;
- hash.append(b64l.substring(0, 5)); // 5 chars
- hash.append(subdomPortPath(subdom, port, rootpath)); // 1 char
+ hashs.append(b64l.substring(0, 5)); // 5 chars
+ assert hashs.length() == 5;
+ hashs.append(subdomPortPath(subdom, port, rootpath)); // 1 char
+ assert hashs.length() == 6;
// form the 'global' part of the hash
- hash.append(hosthash5(this.protocol, host, port)); // 5 chars
- hash.append(Base64Order.enhancedCoder.encodeByte(flagbyte)); // 1 char
+ hashs.append(hosthash5(this.protocol, host, port)); // 5 chars
+ assert hashs.length() == 11;
+ hashs.append(Base64Order.enhancedCoder.encodeByte(flagbyte)); // 1 char
+ assert hashs.length() == 12;
// return result hash
- return hash.toString();
+ byte[] b = hashs.toString().getBytes();
+ assert b.length == 12;
+ return b;
}
private static char subdomPortPath(final String subdom, final int port, final String rootpath) {
@@ -885,8 +893,8 @@ public class DigestURI implements Serializable {
private static final char rootURLFlag0 = subdomPortPath("", 80, "");
private static final char rootURLFlag1 = subdomPortPath("www", 80, "");
- public static final boolean probablyRootURL(final String urlHash) {
- return (urlHash.charAt(5) == rootURLFlag0) || (urlHash.charAt(5) == rootURLFlag1);
+ public static final boolean probablyRootURL(final byte[] urlHash) {
+ return (urlHash[5] == rootURLFlag0) || (urlHash[5] == rootURLFlag1);
}
private static final String hosthash5(final String protocol, final String host, final int port) {
@@ -923,13 +931,13 @@ public class DigestURI implements Serializable {
private static String[] testTLDs = new String[] { "com", "net", "org", "uk", "fr", "de", "es", "it" };
- public static final DigestURI probablyWordURL(final String urlHash, final TreeSet<String> words) {
+ public static final DigestURI probablyWordURL(final byte[] urlHash, final TreeSet<String> words) {
final Iterator<String> wi = words.iterator();
String word;
while (wi.hasNext()) {
word = wi.next();
if ((word == null) || (word.length() == 0)) continue;
- final String pattern = urlHash.substring(6, 11);
+ final String pattern = new String(urlHash).substring(6, 11);
for (int i = 0; i < testTLDs.length; i++) {
if (pattern.equals(hosthash5("http", "www." + word.toLowerCase() + "." + testTLDs[i], 80)))
try {
@@ -942,11 +950,11 @@ public class DigestURI implements Serializable {
return null;
}
- public static final boolean isWordRootURL(final String givenURLHash, final TreeSet<String> words) {
+ public static final boolean isWordRootURL(final byte[] givenURLHash, final TreeSet<String> words) {
if (!(probablyRootURL(givenURLHash))) return false;
final DigestURI wordURL = probablyWordURL(givenURLHash, words);
if (wordURL == null) return false;
- if (wordURL.hash().equals(givenURLHash)) return true;
+ if (Base64Order.enhancedCoder.equal(wordURL.hash(), givenURLHash)) return true;
return false;
}
@@ -973,19 +981,19 @@ public class DigestURI implements Serializable {
return domLengthEstimation(urlHashBytes) << 8 / 20;
}
- public static final int domDomain(final String urlHash) {
+ public static final int domDomain(final byte[] urlHash) {
// returns the ID of the domain of the domain
assert (urlHash != null);
- assert (urlHash.length() == 12 || urlHash.length() == 6) : "urlhash = " + urlHash;
- return (Base64Order.enhancedCoder.decodeByte(urlHash.charAt((urlHash.length() == 12) ? 11 : 5)) & 28) >> 2;
+ assert (urlHash.length == 12 || urlHash.length == 6) : "urlhash = " + new String(urlHash);
+ return (Base64Order.enhancedCoder.decodeByte(urlHash[(urlHash.length == 12) ? 11 : 5]) & 28) >> 2;
}
- public static boolean isDomDomain(final String urlHash, final int id) {
+ public static boolean isDomDomain(final byte[] urlHash, final int id) {
return domDomain(urlHash) == id;
}
- public static boolean matchesAnyDomDomain(final String urlHash, final int idset) {
+ public static boolean matchesAnyDomDomain(final byte[] urlHash, final int idset) {
// this is a boolean matching on a set of domDomains
return (domDomain(urlHash) | idset) != 0;
}
@@ -1002,7 +1010,7 @@ public class DigestURI implements Serializable {
return domDomain(this.hash) == 7;
}
- public static final boolean isLocal(final String urlhash) {
+ public static final boolean isLocal(final byte[] urlhash) {
return domDomain(urlhash) == 7;
}
@@ -1282,7 +1290,7 @@ public class DigestURI implements Serializable {
environment = test[i][0];
url = test[i][1];
try {aURL = DigestURI.newURL(environment, url);} catch (final MalformedURLException e) {Log.logException(e); aURL = null;}
- if (aURL != null) System.out.println("normalized: " + aURL.toNormalform(true, true, true) + " - hash=" + aURL.hash());
+ if (aURL != null) System.out.println("normalized: " + aURL.toNormalform(true, true, true) + " - hash=" + new String(aURL.hash()));
if (environment == null) {
try {jURL = new java.net.URL(url);} catch (final MalformedURLException e) {jURL = null;}
} else {
diff --git a/source/net/yacy/kelondro/data/meta/URIMetadata.java b/source/net/yacy/kelondro/data/meta/URIMetadata.java
index d1c7eb0b5..e96b84950 100644
--- a/source/net/yacy/kelondro/data/meta/URIMetadata.java
+++ b/source/net/yacy/kelondro/data/meta/URIMetadata.java
@@ -48,7 +48,7 @@ public interface URIMetadata {
public Date freshdate();
- public String referrerHash();
+ public byte[] referrerHash();
public String md5();
diff --git a/source/net/yacy/kelondro/data/meta/URIMetadataRow.java b/source/net/yacy/kelondro/data/meta/URIMetadataRow.java
index f431da77f..2e90fbc73 100644
--- a/source/net/yacy/kelondro/data/meta/URIMetadataRow.java
+++ b/source/net/yacy/kelondro/data/meta/URIMetadataRow.java
@@ -233,7 +233,7 @@ public class URIMetadataRow implements URIMetadata {
//System.out.println("DEBUG-ENTRY: prop=" + prop.toString());
DigestURI url;
try {
- url = new DigestURI(crypt.simpleDecode(prop.getProperty("url", ""), null), prop.getProperty("hash"));
+ url = new DigestURI(crypt.simpleDecode(prop.getProperty("url", ""), null), prop.getProperty("hash").getBytes());
} catch (final MalformedURLException e) {
url = null;
}
@@ -243,7 +243,7 @@ public class URIMetadataRow implements URIMetadata {
String ETag = crypt.simpleDecode(prop.getProperty("ETag", ""), null); if (ETag == null) ETag = "";
this.entry = rowdef.newEntry();
- this.entry.setCol(col_hash, url.hash(), null); // FIXME potential null pointer access
+ this.entry.setCol(col_hash, url.hash()); // FIXME potential null pointer access
this.entry.setCol(col_comp, encodeComp(url, descr, dc_creator, tags, ETag));
try {
encodeDate(col_mod, DateFormatter.parseShortDay(prop.getProperty("mod", "20000101")));
@@ -312,32 +312,55 @@ public class URIMetadataRow implements URIMetadata {
//System.out.println("author=" + comp.author());
try {
s.append("hash=").append(new String(hash()));
+ assert (s.toString().indexOf(0) < 0);
s.append(",url=").append(crypt.simpleEncode(metadata.url().toNormalform(false, true)));
+ assert (s.toString().indexOf(0) < 0);
s.append(",descr=").append(crypt.simpleEncode(metadata.dc_title()));
+ assert (s.toString().indexOf(0) < 0);
s.append(",author=").append(crypt.simpleEncode(metadata.dc_creator()));
+ assert (s.toString().indexOf(0) < 0);
s.append(",tags=").append(crypt.simpleEncode(metadata.dc_subject()));
+ assert (s.toString().indexOf(0) < 0);
s.append(",ETag=").append(crypt.simpleEncode(metadata.ETag()));
+ assert (s.toString().indexOf(0) < 0);
s.append(",mod=").append(DateFormatter.formatShortDay(moddate()));
+ assert (s.toString().indexOf(0) < 0);
s.append(",load=").append(DateFormatter.formatShortDay(loaddate()));
+ assert (s.toString().indexOf(0) < 0);
s.append(",fresh=").append(DateFormatter.formatShortDay(freshdate()));
- s.append(",referrer=").append(referrerHash());
+ assert (s.toString().indexOf(0) < 0);
+ s.append(",referrer=").append(referrerHash() == null ? "" : new String(referrerHash()));
+ assert (s.toString().indexOf(0) < 0);
s.append(",md5=").append(md5());
+ assert (s.toString().indexOf(0) < 0);
s.append(",size=").append(size());
+ assert (s.toString().indexOf(0) < 0);
s.append(",wc=").append(wordCount());
+ assert (s.toString().indexOf(0) < 0);
s.append(",dt=").append(doctype());
+ assert (s.toString().indexOf(0) < 0);
s.append(",flags=").append(flags().exportB64());
+ assert (s.toString().indexOf(0) < 0);
s.append(",lang=").append(language());
+ assert (s.toString().indexOf(0) < 0);
s.append(",llocal=").append(llocal());
+ assert (s.toString().indexOf(0) < 0);
s.append(",lother=").append(lother());
+ assert (s.toString().indexOf(0) < 0);
s.append(",limage=").append(limage());
+ assert (s.toString().indexOf(0) < 0);
s.append(",laudio=").append(laudio());
+ assert (s.toString().indexOf(0) < 0);
s.append(",lvideo=").append(lvideo());
+ assert (s.toString().indexOf(0) < 0);
s.append(",lapp=").append(lapp());
+ assert (s.toString().indexOf(0) < 0);
if (this.word != null) {
// append also word properties
s.append(",wi=").append(Base64Order.enhancedCoder.encodeString(word.toPropertyForm()));
}
+ assert (s.toString().indexOf(0) < 0);
return s;
} catch (final Exception e) {
@@ -372,7 +395,7 @@ public class URIMetadataRow implements URIMetadata {
final Iterator<String> cl = FileUtils.strings(this.entry.getCol("comp", null));
this.comp = new Components(
(cl.hasNext()) ? cl.next() : "",
- new String(hash()),
+ hash(),
(cl.hasNext()) ? cl.next() : "",
(cl.hasNext()) ? cl.next() : "",
(cl.hasNext()) ? cl.next() : "",
@@ -392,14 +415,14 @@ public class URIMetadataRow implements URIMetadata {
return decodeDate(col_fresh);
}
- public String referrerHash() {
+ public byte[] referrerHash() {
// return the creator's hash
- return entry.getColString(col_referrer, null);
+ return entry.getColBytes(col_referrer, true);
}
public String md5() {
// returns the md5 in hex representation
- return Digest.encodeHex(entry.getColBytes(col_md5));
+ return Digest.encodeHex(entry.getColBytes(col_md5, true));
}
public char doctype() {
@@ -415,7 +438,7 @@ public class URIMetadataRow implements URIMetadata {
}
public Bitfield flags() {
- return new Bitfield(this.entry.getColBytes(col_flags));
+ return new Bitfield(this.entry.getColBytes(col_flags, true));
}
public int wordCount() {
@@ -487,7 +510,7 @@ public class URIMetadataRow implements URIMetadata {
public Request toBalancerEntry(final String initiatorHash) {
return new Request(
- initiatorHash,
+ initiatorHash.getBytes(),
metadata().url(),
referrerHash(),
metadata().dc_title(),
@@ -512,16 +535,17 @@ public class URIMetadataRow implements URIMetadata {
core.insert(0, "{");
core.append("}");
- return new String(core);
+ return core.toString();
//return "{" + core + "}";
}
public class Components {
private DigestURI url;
- private String urlRaw, urlHash;
+ private String urlRaw;
+ private byte[] urlHash;
private final String dc_title, dc_creator, dc_subject, ETag;
- public Components(final String urlRaw, final String urlhash, final String title, final String author, final String tags, final String ETag) {
+ public Components(final String urlRaw, final byte[] urlhash, final String title, final String author, final String tags, final String ETag) {
this.url = null;
this.urlRaw = urlRaw;
this.urlHash = urlhash;
diff --git a/source/net/yacy/kelondro/data/word/WordReferenceRow.java b/source/net/yacy/kelondro/data/word/WordReferenceRow.java
index 7d3dfe115..bbbe48ad3 100644
--- a/source/net/yacy/kelondro/data/word/WordReferenceRow.java
+++ b/source/net/yacy/kelondro/data/word/WordReferenceRow.java
@@ -307,7 +307,7 @@ public final class WordReferenceRow extends AbstractReference implements WordRef
}
public Bitfield flags() {
- return new Bitfield(this.entry.getColBytes(col_flags));
+ return new Bitfield(this.entry.getColBytes(col_flags, false));
}
public double termFrequency() {
diff --git a/source/net/yacy/kelondro/index/HandleSet.java b/source/net/yacy/kelondro/index/HandleSet.java
index 321d37908..25e90aa75 100644
--- a/source/net/yacy/kelondro/index/HandleSet.java
+++ b/source/net/yacy/kelondro/index/HandleSet.java
@@ -163,4 +163,5 @@ public final class HandleSet implements Iterable<byte[]> {
index.close();
index = null;
}
+
}
diff --git a/source/net/yacy/kelondro/index/ObjectArrayCache.java b/source/net/yacy/kelondro/index/ObjectArrayCache.java
index 637e2f15f..b23775bdc 100644
--- a/source/net/yacy/kelondro/index/ObjectArrayCache.java
+++ b/source/net/yacy/kelondro/index/ObjectArrayCache.java
@@ -79,12 +79,12 @@ public final class ObjectArrayCache {
index1 = new RowSet(rowdef);
}
final Row.Entry indexentry = index0.get(key);
- if (indexentry != null) return indexentry.getColBytes(1);
+ if (indexentry != null) return indexentry.getColBytes(1, false);
}
assert (index1 != null);
final Row.Entry indexentry = index1.get(key);
if (indexentry == null) return null;
- return indexentry.getColBytes(1);
+ return indexentry.getColBytes(1, false);
}
public final byte[] putb(final int ii, final byte[] value) throws RowSpaceExceededException {
@@ -100,7 +100,7 @@ public final class ObjectArrayCache {
}
final Row.Entry indexentry = index0.get(key);
if (indexentry != null) {
- final byte[] oldv = indexentry.getColBytes(1);
+ final byte[] oldv = indexentry.getColBytes(1, false);
indexentry.setCol(0, key);
indexentry.setCol(1, value);
index0.put(indexentry);
@@ -116,7 +116,7 @@ public final class ObjectArrayCache {
newentry.setCol(1, value);
final Row.Entry oldentry = index1.replace(newentry);
if (oldentry == null) return null;
- return oldentry.getColBytes(1);
+ return oldentry.getColBytes(1, false);
}
public final void addb(final int ii, final byte[] value) throws RowSpaceExceededException {
@@ -142,7 +142,7 @@ public final class ObjectArrayCache {
}
final Row.Entry indexentry = index0.remove(key);
if (indexentry != null) {
- return indexentry.getColBytes(1);
+ return indexentry.getColBytes(1, false);
}
// else remove it from the index1
}
@@ -151,7 +151,7 @@ public final class ObjectArrayCache {
if (index1.isEmpty()) return null;
final Row.Entry indexentry = index1.remove(key);
if (indexentry == null) return null;
- return indexentry.getColBytes(1);
+ return indexentry.getColBytes(1, false);
}
public final byte[] removeoneb() {
@@ -160,14 +160,14 @@ public final class ObjectArrayCache {
assert (indexentry != null);
if (indexentry == null) return null;
//assert consistencyAnalysis0() : "consistency problem: " + consistencyAnalysis();
- return indexentry.getColBytes(1);
+ return indexentry.getColBytes(1, false);
}
if (index0 != null && !index0.isEmpty()) {
final Row.Entry indexentry = index0.removeOne();
assert (indexentry != null);
if (indexentry == null) return null;
//assert consistencyAnalysis0() : "consistency problem: " + consistencyAnalysis();
- return indexentry.getColBytes(1);
+ return indexentry.getColBytes(1, false);
}
return null;
}
diff --git a/source/net/yacy/kelondro/index/Row.java b/source/net/yacy/kelondro/index/Row.java
index b445b6082..a9d317686 100644
--- a/source/net/yacy/kelondro/index/Row.java
+++ b/source/net/yacy/kelondro/index/Row.java
@@ -159,8 +159,8 @@ public final class Row {
public final Entry newEntry(final Entry oldrow, final 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 (oldrow.getColBytes(0, false)[0] != 0);
+ assert (this.objectOrder.wellformed(oldrow.getColBytes(0, false), 0, row[0].cellwidth));
return new Entry(oldrow, fromColumn, false);
}
@@ -387,6 +387,7 @@ public final class Row {
return rowinstance[offset + colstart[column]] == 0;
}
+ @Deprecated
public final void setCol(final String nickname, final char c) {
if (nickref == null) genNickRef();
final Object[] ref = nickref.get(nickname);
@@ -394,6 +395,7 @@ public final class Row {
rowinstance[offset + ((Integer) ref[1]).intValue()] = (byte) c;
}
+ @Deprecated
public final void setCol(final String nickname, final byte[] cell) {
if (nickref == null) genNickRef();
final Object[] ref = nickref.get(nickname);
@@ -456,6 +458,7 @@ public final class Row {
}
}
+ @Deprecated
public final void setCol(final String nickname, final long cell) {
if (nickref == null) genNickRef();
final Object[] ref = nickref.get(nickname);
@@ -502,6 +505,7 @@ public final class Row {
throw new kelondroException("ROW", "addCol did not find appropriate encoding");
}
+ @Deprecated
public final byte[] getCol(final String nickname, final byte[] dflt) {
if (nickref == null) genNickRef();
final Object[] ref = nickref.get(nickname);
@@ -512,6 +516,7 @@ public final class Row {
return cell;
}
+ @Deprecated
public final String getColString(final String nickname, final String dflt, final String encoding) {
if (nickref == null) genNickRef();
final Object[] ref = nickref.get(nickname);
@@ -526,6 +531,7 @@ public final class Row {
private final String getColString(final int clstrt, int length, final String encoding) {
if (rowinstance[offset + clstrt] == 0) return null;
+ assert length <= rowinstance.length - offset - clstrt;
if (length > rowinstance.length - offset - clstrt) length = rowinstance.length - offset - clstrt;
while ((length > 0) && (rowinstance[offset + clstrt + length - 1] == 0)) length--;
if (length == 0) return null;
@@ -538,6 +544,7 @@ public final class Row {
}
}
+ @Deprecated
public final long getColLong(final String nickname, final long dflt) {
if (nickref == null) genNickRef();
final Object[] ref = nickref.get(nickname);
@@ -574,6 +581,7 @@ public final class Row {
throw new kelondroException("ROW", "getColLong did not find appropriate encoding");
}
+ @Deprecated
public final byte getColByte(final String nickname, final byte dflt) {
if (nickref == null) genNickRef();
final Object[] ref = nickref.get(nickname);
@@ -595,12 +603,18 @@ public final class Row {
return primaryKeyLength;
}
- public final byte[] getColBytes(final int column) {
+ public final byte[] getColBytes(final int column, boolean nullIfEmpty) {
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 clstrt = colstart[column];
final int w = row[column].cellwidth;
+ if (nullIfEmpty) {
+ int length = w;
+ while (length > 0 && rowinstance[offset + clstrt + length - 1] == 0) length--;
+ if (length == 0) return null;
+ }
final byte[] c = new byte[w];
- System.arraycopy(rowinstance, offset + colstart[column], c, 0, w);
+ System.arraycopy(rowinstance, offset + clstrt, c, 0, w);
return c;
}
@@ -618,7 +632,7 @@ public final class Row {
}
public final String toPropertyForm(final boolean includeBraces, final boolean decimalCardinal, final boolean longname) {
- final ByteBuffer bb = new ByteBuffer();
+ final ByteBuffer bb = new ByteBuffer(objectsize() * 2);
if (includeBraces) bb.append('{');
for (int i = 0; i < row.length; i++) {
bb.append((longname) ? row[i].description : row[i].nickname);
@@ -626,7 +640,7 @@ public final class Row {
if ((decimalCardinal) && (row[i].celltype == Column.celltype_cardinal)) {
bb.append(Long.toString(getColLong(i)));
} else if ((decimalCardinal) && (row[i].celltype == Column.celltype_bitfield)) {
- bb.append((new Bitfield(getColBytes(i))).exportB64());
+ bb.append((new Bitfield(getColBytes(i, true))).exportB64());
} else if ((decimalCardinal) && (row[i].celltype == Column.celltype_binary)) {
assert row[i].cellwidth == 1;
bb.append(Integer.toString((0xff & getColByte(i))));
diff --git a/source/net/yacy/kelondro/index/RowCollection.java b/source/net/yacy/kelondro/index/RowCollection.java
index b4ea8a26d..44fd1dbc2 100644
--- a/source/net/yacy/kelondro/index/RowCollection.java
+++ b/source/net/yacy/kelondro/index/RowCollection.java
@@ -126,7 +126,7 @@ public class RowCollection implements Iterable<Row.Entry> {
Log.logWarning("RowCollection", "corrected wrong sortBound; sortBound = " + sortBound + ", chunkcount = " + chunkcount);
this.sortBound = chunkcount;
}
- this.chunkcache = exportedCollection.getColBytes(exp_collection);
+ this.chunkcache = exportedCollection.getColBytes(exp_collection, false);
}
public void reset() {
@@ -1016,7 +1016,7 @@ public class RowCollection implements Iterable<Row.Entry> {
System.out.println("create c : " + (t1 - t0) + " nanoseconds, " + d(testsize, (t1 - t0)) + " entries/nanoseconds");
final RowCollection d = new RowCollection(r, testsize);
for (int i = 0; i < testsize; i++) {
- d.add(c.get(i, false).getColBytes(0));
+ d.add(c.get(i, false).getColBytes(0, false));
}
final long t2 = System.nanoTime();
System.out.println("copy c -> d: " + (t2 - t1) + " nanoseconds, " + d(testsize, (t2 - t1)) + " entries/nanoseconds");
diff --git a/source/net/yacy/kelondro/index/RowSet.java b/source/net/yacy/kelondro/index/RowSet.java
index f4958db14..dc0198db7 100644
--- a/source/net/yacy/kelondro/index/RowSet.java
+++ b/source/net/yacy/kelondro/index/RowSet.java
@@ -512,7 +512,7 @@ public class RowSet extends RowCollection implements ObjectIndex, Iterable<Row.E
Row.Entry entry;
while (ii.hasNext()) {
entry = ii.next();
- s = new String(entry.getColBytes(0)).trim();
+ s = new String(entry.getColBytes(0, true)).trim();
System.out.print(s + ", ");
if (s.equals("drei")) ii.remove();
}
diff --git a/source/net/yacy/kelondro/order/Base64Order.java b/source/net/yacy/kelondro/order/Base64Order.java
index 60b2323d7..aa2e160e4 100644
--- a/source/net/yacy/kelondro/order/Base64Order.java
+++ b/source/net/yacy/kelondro/order/Base64Order.java
@@ -30,6 +30,8 @@ package net.yacy.kelondro.order;
import java.io.UnsupportedEncodingException;
import java.util.Comparator;
+import net.yacy.kelondro.index.HandleSet;
+import net.yacy.kelondro.index.RowSpaceExceededException;
import net.yacy.kelondro.logging.Log;
@@ -81,10 +83,14 @@ public class Base64Order extends AbstractOrder<byte[]> implements ByteOrder, Com
if (acc < bcc) c = -1;
ab[(ac << 7) | bc] = c;
- }
+ }
}
this.log = new Log("BASE64");
}
+
+ public HandleSet getHandleSet(final int keylength, final int space) throws RowSpaceExceededException {
+ return new HandleSet(keylength, this, space, space);
+ }
public static byte[] zero(int length) {
final byte[] z = new byte[length];
diff --git a/source/net/yacy/kelondro/order/ByteOrder.java b/source/net/yacy/kelondro/order/ByteOrder.java
index 503846852..4500e7ee3 100644
--- a/source/net/yacy/kelondro/order/ByteOrder.java
+++ b/source/net/yacy/kelondro/order/ByteOrder.java
@@ -27,6 +27,9 @@
package net.yacy.kelondro.order;
+import net.yacy.kelondro.index.HandleSet;
+import net.yacy.kelondro.index.RowSpaceExceededException;
+
public interface ByteOrder extends Order<byte[]> {
@@ -41,5 +44,7 @@ public interface ByteOrder extends Order<byte[]> {
public boolean equal(final byte[] a, int astart, final byte[] b, int bstart, int length);
public long cardinal(final byte[] a, int off, int len);
+
+ public HandleSet getHandleSet(final int keylength, final int space) throws RowSpaceExceededException;
}
diff --git a/source/net/yacy/kelondro/order/NaturalOrder.java b/source/net/yacy/kelondro/order/NaturalOrder.java
index 118942863..c3915ccd0 100644
--- a/source/net/yacy/kelondro/order/NaturalOrder.java
+++ b/source/net/yacy/kelondro/order/NaturalOrder.java
@@ -29,6 +29,9 @@ package net.yacy.kelondro.order;
import java.util.Comparator;
import java.util.Iterator;
+import net.yacy.kelondro.index.HandleSet;
+import net.yacy.kelondro.index.RowSpaceExceededException;
+
public final class NaturalOrder extends AbstractOrder<byte[]> implements ByteOrder, Comparator<byte[]>, Cloneable {
public static final ByteOrder naturalOrder = new NaturalOrder(true);
@@ -38,6 +41,10 @@ public final class NaturalOrder extends AbstractOrder<byte[]> implements ByteOrd
this.zero = null;
}
+ public HandleSet getHandleSet(final int keylength, final int space) throws RowSpaceExceededException {
+ return new HandleSet(keylength, this, space, space);
+ }
+
public boolean wellformed(final byte[] a) {
return true;
}
diff --git a/source/net/yacy/kelondro/table/RecordStack.java b/source/net/yacy/kelondro/table/RecordStack.java
index 57806ceec..db8090f47 100644
--- a/source/net/yacy/kelondro/table/RecordStack.java
+++ b/source/net/yacy/kelondro/table/RecordStack.java
@@ -326,7 +326,7 @@ public final class RecordStack extends Records {
} else if (args[0].equals("-g")) {
fm = new RecordStack(new File(args[1]), lens);
final Row.Entry ret2 = fm.pop();
- ret = ((ret2 == null) ? null : ret2.getColBytes(1));
+ ret = ((ret2 == null) ? null : ret2.getColBytes(1, true));
fm.close();
}
fm.close();
@@ -358,7 +358,7 @@ public final class RecordStack extends Records {
} else if (args[0].equals("-g")) {
final RecordStack fm = new RecordStack(new File(args[2]), lens);
final Row.Entry ret2 = fm.pop();
- ret = ((ret2 == null) ? null : ret2.getColBytes(1));
+ ret = ((ret2 == null) ? null : ret2.getColBytes(1, true));
fm.close();
}
} else if (args.length == 4) {
diff --git a/source/net/yacy/kelondro/table/Records.java b/source/net/yacy/kelondro/table/Records.java
index f7b3fc53f..659401c3d 100644
--- a/source/net/yacy/kelondro/table/Records.java
+++ b/source/net/yacy/kelondro/table/Records.java
@@ -603,7 +603,7 @@ public class Records {
protected void printChunk(final Row.Entry chunk) {
for (int j = 0; j < chunk.columns(); j++)
- System.out.print(new String(chunk.getColBytes(j)) + ", ");
+ System.out.print(new String(chunk.getColBytes(j, false)) + ", ");
}
public final Row row() {
diff --git a/source/net/yacy/kelondro/table/Relations.java b/source/net/yacy/kelondro/table/Relations.java
index 50356ed38..7bf36fd38 100755
--- a/source/net/yacy/kelondro/table/Relations.java
+++ b/source/net/yacy/kelondro/table/Relations.java
@@ -151,7 +151,7 @@ public class Relations {
entry.setCol(3, value);
final Row.Entry oldentry = table.replace(entry);
if (oldentry == null) return null;
- return oldentry.getColBytes(3);
+ return oldentry.getColBytes(3, true);
}
public String getRelation(final String name, final String key) throws IOException, RowSpaceExceededException {
@@ -165,7 +165,7 @@ public class Relations {
if (table == null) return null;
final Row.Entry entry = table.get(key);
if (entry == null) return null;
- return entry.getColBytes(3);
+ return entry.getColBytes(3, true);
}
public boolean hasRelation(final String name, final byte[] key) throws RowSpaceExceededException {
@@ -179,7 +179,7 @@ public class Relations {
if (table == null) return null;
final Row.Entry entry = table.remove(key);
if (entry == null) return null;
- return entry.getColBytes(3);
+ return entry.getColBytes(3, true);
}
public static void main(final String args[]) {
diff --git a/source/net/yacy/kelondro/table/SQLTable.java b/source/net/yacy/kelondro/table/SQLTable.java
index e103bc303..6a335a182 100644
--- a/source/net/yacy/kelondro/table/SQLTable.java
+++ b/source/net/yacy/kelondro/table/SQLTable.java
@@ -184,7 +184,7 @@ public class SQLTable implements ObjectIndex, Iterable<Row.Entry> {
public Row.Entry replace(final Row.Entry row) throws IOException {
try {
- final Row.Entry oldEntry = remove(row.getColBytes(0));
+ final Row.Entry oldEntry = remove(row.getColBytes(0, false));
final String sqlQuery = "INSERT INTO test (" +
"hash, " +
"value) " +
diff --git a/source/net/yacy/kelondro/table/SplitTable.java b/source/net/yacy/kelondro/table/SplitTable.java
index 37258c930..f3c7206c5 100644
--- a/source/net/yacy/kelondro/table/SplitTable.java
+++ b/source/net/yacy/kelondro/table/SplitTable.java
@@ -333,7 +333,7 @@ public class SplitTable implements ObjectIndex, Iterable<Row.Entry> {
public synchronized Row.Entry replace(final Row.Entry row) throws IOException, RowSpaceExceededException {
assert row.objectsize() <= this.rowdef.objectsize;
- ObjectIndex keeper = keeperOf(row.getColBytes(0));
+ ObjectIndex keeper = keeperOf(row.getColBytes(0, true));
if (keeper != null) return keeper.replace(row);
keeper = (this.current == null) ? newTable() : checkTable(this.tables.get(this.current));
keeper.put(row);
@@ -342,7 +342,7 @@ public class SplitTable implements ObjectIndex, Iterable<Row.Entry> {
public synchronized void put(final Row.Entry row) throws IOException, RowSpaceExceededException {
assert row.objectsize() <= this.rowdef.objectsize;
- ObjectIndex keeper = keeperOf(row.getColBytes(0));
+ ObjectIndex keeper = keeperOf(row.getColBytes(0, true));
if (keeper != null) {keeper.put(row); return;}
assert this.current == null || this.tables.get(this.current) != null : "this.current = " + this.current;
keeper = (this.current == null) ? newTable() : checkTable(this.tables.get(this.current));
@@ -464,6 +464,7 @@ public class SplitTable implements ObjectIndex, Iterable<Row.Entry> {
private ObjectIndex keeperOf(final byte[] key) {
//if (!discoveriesAlive()) {
//synchronized (tables) {
+ if (key == null) return null;
for (ObjectIndex oi: tables.values()) {
if (oi.has(key)) return oi;
}
diff --git a/source/net/yacy/kelondro/util/ByteBuffer.java b/source/net/yacy/kelondro/util/ByteBuffer.java
index b535754d4..833f9a1a8 100644
--- a/source/net/yacy/kelondro/util/ByteBuffer.java
+++ b/source/net/yacy/kelondro/util/ByteBuffer.java
@@ -27,6 +27,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
+import java.util.Collection;
import java.util.Properties;
public final class ByteBuffer extends OutputStream {
@@ -503,5 +504,12 @@ public final class ByteBuffer extends OutputStream {
dest.write(this.buffer, this.offset, this.length);
dest.flush();
}
+
+ public static boolean contains(Collection<byte[]> collection, byte[] key) {
+ for (byte[] v: collection) {
+ if (equals(v, key)) return true;
+ }
+ return false;
+ }
}
\ No newline at end of file
diff --git a/source/net/yacy/kelondro/util/FileUtils.java b/source/net/yacy/kelondro/util/FileUtils.java
index 10dc65a00..9d4d03eb8 100644
--- a/source/net/yacy/kelondro/util/FileUtils.java
+++ b/source/net/yacy/kelondro/util/FileUtils.java
@@ -483,11 +483,11 @@ public final class FileUtils {
final Iterator<Row.Entry> i = set.iterator();
String key;
if (i.hasNext()) {
- key = new String(i.next().getColBytes(0));
+ key = new String(i.next().getColBytes(0, false));
os.write(key.getBytes("UTF-8"));
}
while (i.hasNext()) {
- key = new String((i.next()).getColBytes(0));
+ key = new String(i.next().getColBytes(0, false));
if (sep != null) os.write(sep.getBytes("UTF-8"));
os.write(key.getBytes("UTF-8"));
}
diff --git a/source/net/yacy/repository/Blacklist.java b/source/net/yacy/repository/Blacklist.java
index 59bf8f158..abaddc81b 100644
--- a/source/net/yacy/repository/Blacklist.java
+++ b/source/net/yacy/repository/Blacklist.java
@@ -283,10 +283,10 @@ public class Blacklist {
public boolean isListed(final String blacklistType, final DigestURI url) {
final Set<String> urlHashCache = getCacheUrlHashsSet(blacklistType);
- if (!urlHashCache.contains(url.hash())) {
+ if (!urlHashCache.contains(new String(url.hash()))) {
final boolean temp = isListed(blacklistType, url.getHost().toLowerCase(), url.getFile());
if (temp) {
- urlHashCache.add(url.hash());
+ urlHashCache.add(new String(url.hash()));
}
return temp;
}
diff --git a/source/net/yacy/repository/LoaderDispatcher.java b/source/net/yacy/repository/LoaderDispatcher.java
index a759a7c62..6679906ed 100644
--- a/source/net/yacy/repository/LoaderDispatcher.java
+++ b/source/net/yacy/repository/LoaderDispatcher.java
@@ -145,9 +145,9 @@ public final class LoaderDispatcher {
final boolean global
) {
return new Request(
- sb.peers.mySeed().hash,
+ sb.peers.mySeed().hash.getBytes(),
url,
- "",
+ null,
"",
new Date(),
new Date(),
diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.java
index b67c2dbcd..821d6ae13 100644
--- a/source/net/yacy/yacy.java
+++ b/source/net/yacy/yacy.java
@@ -678,8 +678,8 @@ public final class yacy {
while (wordIdxEntries.hasNext()) {
iEntry = wordIdxEntries.next();
final String urlHash = iEntry.metadataHash();
- if ((currentUrlDB.exists(urlHash)) && (!minimizedUrlDB.exists(urlHash))) try {
- final URIMetadataRow urlEntry = currentUrlDB.load(urlHash, null, 0);
+ if ((currentUrlDB.exists(urlHash.getBytes())) && (!minimizedUrlDB.exists(urlHash.getBytes()))) try {
+ final URIMetadataRow urlEntry = currentUrlDB.load(urlHash.getBytes(), null, 0);
urlCounter++;
minimizedUrlDB.store(urlEntry);
if (urlCounter % 500 == 0) {