Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-1671 indexchecker to add digest field

Sebastian Nagel3a4afbaf8f59
diff --git a/CHANGES.txt b/CHANGES.txt
index 1efaf3335..05ad48b97 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,7 +2,7 @@ Nutch Change Log
Nutch Current Development
-*
+* NUTCH-1671 indexchecker to add digest field (snagel, lufeng)
Nutch 1.8 - 11/03/2014 (dd/mm/yyyy)
Release Report - http://s.apache.org/oHY
diff --git a/src/java/org/apache/nutch/indexer/IndexingFiltersChecker.java b/src/java/org/apache/nutch/indexer/IndexingFiltersChecker.java
index 57d2886a9..9d3cfef3b 100644
--- a/src/java/org/apache/nutch/indexer/IndexingFiltersChecker.java
+++ b/src/java/org/apache/nutch/indexer/IndexingFiltersChecker.java
@@ -17,11 +17,8 @@
package org.apache.nutch.indexer;
-import java.util.Arrays;
import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.io.Text;
@@ -29,10 +26,9 @@ import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
import org.apache.nutch.crawl.CrawlDatum;
import org.apache.nutch.crawl.Inlinks;
-import org.apache.nutch.indexer.IndexingException;
-import org.apache.nutch.indexer.IndexingFilters;
-import org.apache.nutch.indexer.NutchDocument;
+import org.apache.nutch.crawl.SignatureFactory;
import org.apache.nutch.metadata.Metadata;
+import org.apache.nutch.metadata.Nutch;
import org.apache.nutch.parse.Parse;
import org.apache.nutch.parse.ParseResult;
import org.apache.nutch.parse.ParseSegment;
@@ -42,7 +38,10 @@ import org.apache.nutch.protocol.Protocol;
import org.apache.nutch.protocol.ProtocolFactory;
import org.apache.nutch.protocol.ProtocolOutput;
import org.apache.nutch.util.NutchConfiguration;
+import org.apache.nutch.util.StringUtil;
import org.apache.nutch.util.URLUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Reads and parses a URL and run the indexers on it. Displays the fields obtained and the first
@@ -122,6 +121,14 @@ public class IndexingFiltersChecker extends Configured implements Tool {
Inlinks inlinks = null;
Parse parse = parseResult.get(urlText);
+
+ byte[] signature = SignatureFactory.getSignature(conf).calculate(content,
+ parse);
+ parse.getData().getContentMeta()
+ .set(Nutch.SIGNATURE_KEY, StringUtil.toHexString(signature));
+ String digest = parse.getData().getContentMeta().get(Nutch.SIGNATURE_KEY);
+ doc.add("digest", digest);
+
try {
doc = indexers.filter(doc, parse, urlText, datum, inlinks);
} catch (IndexingException e) {