Apache Nutch is an extensible and scalable web crawler
NUTCH-698 - CrawlDb is corrupted after a few crawl cycles, contributed by dogacan
Sami Sirene7aee8b3123e
diff --git a/CHANGES.txt b/CHANGES.txtindex 45a13457c..9b2c31fe5 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -359,6 +359,9 @@ Unreleased changes (1.0-dev)134. NUTCH-247 - Robot parser to restrict (kubes, siren)+135. NUTCH-698 - CrawlDb is corrupted after a few crawl cycles (dogacan+ via siren)+Release 0.9 - 2007-04-021. Changed log4j confiquration to log to stdout on commandlinediff --git a/src/java/org/apache/nutch/crawl/CrawlDatum.java b/src/java/org/apache/nutch/crawl/CrawlDatum.javaindex 244f0b289..b3812736e 100644--- a/src/java/org/apache/nutch/crawl/CrawlDatum.java+++ b/src/java/org/apache/nutch/crawl/CrawlDatum.java@@ -204,7 +204,17 @@ public class CrawlDatum implements WritableComparable<CrawlDatum>, Cloneable {}public void setMetaData(org.apache.hadoop.io.MapWritable mapWritable) {- this.metaData = mapWritable;+ this.metaData = new org.apache.hadoop.io.MapWritable(mapWritable);+ }++ /** Add all metadata from other CrawlDatum to this CrawlDatum.+ *+ * @param other CrawlDatum+ */+ public void putAllMetaData(CrawlDatum other) {+ for (Entry<Writable, Writable> e : other.getMetaData().entrySet()) {+ metaData.put(e.getKey(), e.getValue());+ }}/**diff --git a/src/java/org/apache/nutch/crawl/CrawlDbReducer.java b/src/java/org/apache/nutch/crawl/CrawlDbReducer.javaindex 7ceed077e..dc2c0a692 100644--- a/src/java/org/apache/nutch/crawl/CrawlDbReducer.java+++ b/src/java/org/apache/nutch/crawl/CrawlDbReducer.java@@ -131,10 +131,10 @@ public class CrawlDbReducer implements Reducer<Text, CrawlDatum, Text, CrawlDatuif (oldSet) {// copy metadata from old, if existsif (old.getMetaData().size() > 0) {- result.getMetaData().putAll(old.getMetaData());+ result.putAllMetaData(old);// overlay with new, if anyif (fetch.getMetaData().size() > 0)- result.getMetaData().putAll(fetch.getMetaData());+ result.putAllMetaData(fetch);}// set the most recent valid value of modifiedTimeif (old.getModifiedTime() > 0 && fetch.getModifiedTime() == 0) {