Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-1706 IndexerMapReduce does not remove db_redir_temp

Sebastian Nageld04f2c7116ea
diff --git a/CHANGES.txt b/CHANGES.txt
index 1ce3bd798..a9c1f4892 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,8 @@ Nutch Change Log
Nutch Development Trunk
+* NUTCH-1706 IndexerMapReduce does not remove db_redir_temp (markus, snagel)
+
* NUTCH-1113 SegmentMerger can now be safely used to merge segments (Edward Drapkin, markus, snagel)
* NUTCH-1729 Upgrade to Tika 1.5 (jnioche)
diff --git a/src/java/org/apache/nutch/indexer/IndexerMapReduce.java b/src/java/org/apache/nutch/indexer/IndexerMapReduce.java
index c446d4b91..bdd0581c9 100644
--- a/src/java/org/apache/nutch/indexer/IndexerMapReduce.java
+++ b/src/java/org/apache/nutch/indexer/IndexerMapReduce.java
@@ -180,36 +180,10 @@ implements Mapper<Text, Writable, Text, NutchWritable>,
dbDatum = datum;
}
else if (CrawlDatum.hasFetchStatus(datum)) {
-
// don't index unmodified (empty) pages
if (datum.getStatus() != CrawlDatum.STATUS_FETCH_NOTMODIFIED) {
fetchDatum = datum;
-
- /**
- * Check if we need to delete 404 NOT FOUND and 301 PERMANENT REDIRECT.
- */
- if (delete) {
- if (fetchDatum.getStatus() == CrawlDatum.STATUS_FETCH_GONE || dbDatum.getStatus() == CrawlDatum.STATUS_DB_GONE) {
- reporter.incrCounter("IndexerStatus", "Documents deleted", 1);
-
- NutchIndexAction action = new NutchIndexAction(null, NutchIndexAction.DELETE);
- output.collect(key, action);
- return;
- }
- if (fetchDatum.getStatus() == CrawlDatum.STATUS_FETCH_REDIR_PERM ||
- fetchDatum.getStatus() == CrawlDatum.STATUS_FETCH_REDIR_TEMP ||
- dbDatum.getStatus() == CrawlDatum.STATUS_DB_REDIR_PERM ||
- dbDatum.getStatus() == CrawlDatum.STATUS_DB_REDIR_TEMP) {
- reporter.incrCounter("IndexerStatus", "Deleted redirects", 1);
- reporter.incrCounter("IndexerStatus", "Perm redirects deleted", 1);
-
- NutchIndexAction action = new NutchIndexAction(null, NutchIndexAction.DELETE);
- output.collect(key, action);
- return;
- }
- }
}
-
} else if (CrawlDatum.STATUS_LINKED == datum.getStatus() ||
CrawlDatum.STATUS_SIGNATURE == datum.getStatus() ||
CrawlDatum.STATUS_PARSE_META == datum.getStatus()) {
@@ -239,6 +213,29 @@ implements Mapper<Text, Writable, Text, NutchWritable>,
LOG.warn("Unrecognized type: "+value.getClass());
}
}
+
+ // Whether to delete GONE or REDIRECTS
+ if (delete && fetchDatum != null && dbDatum != null) {
+ if (fetchDatum.getStatus() == CrawlDatum.STATUS_FETCH_GONE || dbDatum.getStatus() == CrawlDatum.STATUS_DB_GONE) {
+ reporter.incrCounter("IndexerStatus", "Documents deleted", 1);
+
+ NutchIndexAction action = new NutchIndexAction(null, NutchIndexAction.DELETE);
+ output.collect(key, action);
+ return;
+ }
+
+ if (fetchDatum.getStatus() == CrawlDatum.STATUS_FETCH_REDIR_PERM ||
+ fetchDatum.getStatus() == CrawlDatum.STATUS_FETCH_REDIR_TEMP ||
+ dbDatum.getStatus() == CrawlDatum.STATUS_DB_REDIR_PERM ||
+ dbDatum.getStatus() == CrawlDatum.STATUS_DB_REDIR_TEMP) {
+ reporter.incrCounter("IndexerStatus", "Deleted redirects", 1);
+ reporter.incrCounter("IndexerStatus", "Perm redirects deleted", 1);
+
+ NutchIndexAction action = new NutchIndexAction(null, NutchIndexAction.DELETE);
+ output.collect(key, action);
+ return;
+ }
+ }
if (fetchDatum == null || dbDatum == null
|| parseText == null || parseData == null) {