Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-533 - LinkDbMerger: url normalized is not updated in the key and inlinks list. Contributed by Emmanuel Joke.

Tacettin Guneyc548f361d510
diff --git a/CHANGES.txt b/CHANGES.txt
index 094ffabbf..6094045d8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -107,6 +107,9 @@ Unreleased changes (1.0-dev)
with redirected pages, and this issue can be considered as a band-aid
for the time being. See NUTCH-273 and NUTCH-353 for more details.
+36. NUTCH-533 - LinkDbMerger: url normalized is not updated in the key and
+ inlinks list. (Emmanuel Joke via dogacan)
+
Release 0.9 - 2007-04-02
1. Changed log4j confiquration to log to stdout on commandline
diff --git a/src/java/org/apache/nutch/crawl/LinkDbFilter.java b/src/java/org/apache/nutch/crawl/LinkDbFilter.java
index bca34ed6c..8c6c40450 100644
--- a/src/java/org/apache/nutch/crawl/LinkDbFilter.java
+++ b/src/java/org/apache/nutch/crawl/LinkDbFilter.java
@@ -22,6 +22,7 @@ import java.util.Iterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.mapred.JobConf;
@@ -57,6 +58,8 @@ public class LinkDbFilter implements Mapper {
private String scope;
public static final Log LOG = LogFactory.getLog(LinkDbFilter.class);
+
+ private Text newKey = new Text();
public void configure(JobConf job) {
this.jobConf = job;
@@ -75,6 +78,7 @@ public class LinkDbFilter implements Mapper {
public void map(WritableComparable key, Writable value, OutputCollector output, Reporter reporter) throws IOException {
String url = key.toString();
+ Inlinks result = new Inlinks();
if (normalize) {
try {
url = normalizers.normalize(url, scope); // normalize the url
@@ -114,11 +118,13 @@ public class LinkDbFilter implements Mapper {
fromUrl = null;
}
}
- if (fromUrl == null) { // should be discarded
- it.remove();
+ if (fromUrl != null) {
+ result.add(new Inlink(fromUrl, inlink.getAnchor()));
}
}
- if (inlinks.size() == 0) return; // don't collect empy inlinks
- output.collect(key, inlinks);
+ if (result.size() > 0) { // don't collect empty inlinks
+ newKey.set(url);
+ output.collect(newKey, result);
+ }
}
}