[ 
https://issues.apache.org/jira/browse/NUTCH-2644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16641177#comment-16641177
 ] 

ASF GitHub Bot commented on NUTCH-2644:
---------------------------------------

sebastian-nagel closed pull request #383: NUTCH-2644 CrawlDbReader -dump 
ignores filter options
URL: https://github.com/apache/nutch/pull/383
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/conf/log4j.properties b/conf/log4j.properties
index 211dad5c6..e133301ea 100644
--- a/conf/log4j.properties
+++ b/conf/log4j.properties
@@ -56,6 +56,7 @@ 
log4j.logger.org.apache.nutch.scoring.webgraph.LinkRank=INFO,cmdstdout
 log4j.logger.org.apache.nutch.scoring.webgraph.Loops=INFO,cmdstdout
 log4j.logger.org.apache.nutch.scoring.webgraph.ScoreUpdater=INFO,cmdstdout
 log4j.logger.org.apache.nutch.scoring.webgraph.WebGraph=INFO,cmdstdout
+log4j.logger.org.apache.nutch.scoring.webgraph.NodeDumper=INFO,cmdstdout
 log4j.logger.org.apache.nutch.segment.SegmentChecker=INFO,cmdstdout
 log4j.logger.org.apache.nutch.segment.SegmentMerger=INFO,cmdstdout
 log4j.logger.org.apache.nutch.segment.SegmentReader=INFO,cmdstdout
diff --git a/src/java/org/apache/nutch/crawl/CrawlDbReader.java 
b/src/java/org/apache/nutch/crawl/CrawlDbReader.java
index 7c4eb1c5e..f31b186c7 100644
--- a/src/java/org/apache/nutch/crawl/CrawlDbReader.java
+++ b/src/java/org/apache/nutch/crawl/CrawlDbReader.java
@@ -373,7 +373,7 @@ public void close() {
          Path tmpFolder = new Path(crawlDb, "stat_tmp" + 
System.currentTimeMillis());
 
          Job job = NutchJob.getInstance(config);
-          config = job.getConfiguration();
+         config = job.getConfiguration();
          job.setJobName("stats " + crawlDb);
          config.setBoolean("db.reader.stats.sort", sort);
 
@@ -658,6 +658,7 @@ public void processDumpJob(String crawlDb, String output,
 
     Job job = NutchJob.getInstance(config);
     job.setJobName("dump " + crawlDb);
+    Configuration jobConf = job.getConfiguration();
 
     FileInputFormat.addInputPath(job, new Path(crawlDb, CrawlDb.CURRENT_NAME));
     job.setInputFormatClass(SequenceFileInputFormat.class);
@@ -672,17 +673,18 @@ public void processDumpJob(String crawlDb, String output,
     }
 
     if (status != null)
-      config.set("status", status);
+      jobConf.set("status", status);
     if (regex != null)
-      config.set("regex", regex);
+      jobConf.set("regex", regex);
     if (retry != null)
-      config.setInt("retry", retry);
+      jobConf.setInt("retry", retry);
     if (expr != null) {
-      config.set("expr", expr);
+      jobConf.set("expr", expr);
       LOG.info("CrawlDb db: expr: " + expr);
     }
-    if (sample != null)
-      config.setFloat("sample", sample);
+    if (sample != null) {
+      jobConf.setFloat("sample", sample);
+    }
     job.setMapperClass(CrawlDbDumpMapper.class);
     job.setOutputKeyClass(Text.class);
     job.setOutputValueClass(CrawlDatum.class);
@@ -900,8 +902,7 @@ public int run(String[] args) throws IOException, 
InterruptedException, ClassNot
     String crawlDb = args[0];
     this.crawlDb = crawlDb;
     int numConsumed = 0;
-    Job job = NutchJob.getInstance(getConf());
-    Configuration config = job.getConfiguration();
+    Configuration config = getConf();
 
     for (int i = 1; i < args.length; i++) {
       if (args[i].equals("-stats")) {
diff --git a/src/java/org/apache/nutch/scoring/webgraph/NodeDumper.java 
b/src/java/org/apache/nutch/scoring/webgraph/NodeDumper.java
index 61b2061d4..cc93eb88a 100644
--- a/src/java/org/apache/nutch/scoring/webgraph/NodeDumper.java
+++ b/src/java/org/apache/nutch/scoring/webgraph/NodeDumper.java
@@ -285,9 +285,9 @@ public void dumpNodes(Path webGraphDb, DumpType type, long 
topN, Path output,
     long start = System.currentTimeMillis();
     LOG.info("NodeDumper: starting at " + sdf.format(start));
     Path nodeDb = new Path(webGraphDb, WebGraph.NODE_DIR);
-    Configuration conf = getConf();
 
-    Job dumper = NutchJob.getInstance(conf);
+    Job dumper = NutchJob.getInstance(getConf());
+    Configuration conf = dumper.getConfiguration();
     dumper.setJobName("NodeDumper: " + webGraphDb);
     FileInputFormat.addInputPath(dumper, nodeDb);
     dumper.setInputFormatClass(SequenceFileInputFormat.class);
diff --git a/src/java/org/apache/nutch/scoring/webgraph/WebGraph.java 
b/src/java/org/apache/nutch/scoring/webgraph/WebGraph.java
index 06728d1be..72a617337 100644
--- a/src/java/org/apache/nutch/scoring/webgraph/WebGraph.java
+++ b/src/java/org/apache/nutch/scoring/webgraph/WebGraph.java
@@ -527,8 +527,7 @@ public void createWebGraph(Path webGraphDb, Path[] segments,
       LOG.info("WebGraphDb: URL filter: " + filter);
     }
 
-    Configuration conf = getConf();
-    FileSystem fs = webGraphDb.getFileSystem(conf);
+    FileSystem fs = webGraphDb.getFileSystem(getConf());
 
     // lock an existing webgraphdb to prevent multiple simultaneous updates
     Path lock = new Path(webGraphDb, LOCK_NAME);
@@ -548,11 +547,12 @@ public void createWebGraph(Path webGraphDb, Path[] 
segments,
 
     Path tempOutlinkDb = new Path(outlinkDb + "-"
         + Integer.toString(new Random().nextInt(Integer.MAX_VALUE)));
-    Job outlinkJob = NutchJob.getInstance(conf);
+    Job outlinkJob = NutchJob.getInstance(getConf());
+    Configuration outlinkJobConf = outlinkJob.getConfiguration();
     outlinkJob.setJobName("Outlinkdb: " + outlinkDb);
 
-    boolean deleteGone = conf.getBoolean("link.delete.gone", false);
-    boolean preserveBackup = conf.getBoolean("db.preserve.backup", true);
+    boolean deleteGone = outlinkJobConf.getBoolean("link.delete.gone", false);
+    boolean preserveBackup = outlinkJobConf.getBoolean("db.preserve.backup", 
true);
 
     if (deleteGone) {
       LOG.info("OutlinkDb: deleting gone links");
@@ -561,7 +561,7 @@ public void createWebGraph(Path webGraphDb, Path[] segments,
     // get the parse data and crawl fetch data for all segments
     if (segments != null) {
       for (int i = 0; i < segments.length; i++) {
-        FileSystem sfs = segments[i].getFileSystem(conf);
+        FileSystem sfs = segments[i].getFileSystem(outlinkJobConf);
         Path parseData = new Path(segments[i], ParseData.DIR_NAME);
         if (sfs.exists(parseData)) {
           LOG.info("OutlinkDb: adding input: " + parseData);
@@ -582,8 +582,8 @@ public void createWebGraph(Path webGraphDb, Path[] segments,
     LOG.info("OutlinkDb: adding input: " + outlinkDb);
     FileInputFormat.addInputPath(outlinkJob, outlinkDb);
 
-    conf.setBoolean(OutlinkDb.URL_NORMALIZING, normalize);
-    conf.setBoolean(OutlinkDb.URL_FILTERING, filter);
+    outlinkJobConf.setBoolean(OutlinkDb.URL_NORMALIZING, normalize);
+    outlinkJobConf.setBoolean(OutlinkDb.URL_FILTERING, filter);
 
     outlinkJob.setInputFormatClass(SequenceFileInputFormat.class);
     outlinkJob.setJarByClass(OutlinkDb.class);
@@ -595,7 +595,7 @@ public void createWebGraph(Path webGraphDb, Path[] segments,
     outlinkJob.setOutputValueClass(LinkDatum.class);
     FileOutputFormat.setOutputPath(outlinkJob, tempOutlinkDb);
     outlinkJob.setOutputFormatClass(MapFileOutputFormat.class);
-    conf.setBoolean("mapreduce.fileoutputcommitter.marksuccessfuljobs",
+    
outlinkJobConf.setBoolean("mapreduce.fileoutputcommitter.marksuccessfuljobs",
         false);
 
     // run the outlinkdb job and replace any old outlinkdb with the new one
@@ -628,7 +628,8 @@ public void createWebGraph(Path webGraphDb, Path[] segments,
     Path tempInlinkDb = new Path(inlinkDb + "-"
         + Integer.toString(new Random().nextInt(Integer.MAX_VALUE)));
 
-    Job inlinkJob = NutchJob.getInstance(conf);
+    Job inlinkJob = NutchJob.getInstance(getConf());
+    Configuration inlinkJobConf = inlinkJob.getConfiguration();
     inlinkJob.setJobName("Inlinkdb " + inlinkDb);
     LOG.info("InlinkDb: adding input: " + outlinkDb);
     FileInputFormat.addInputPath(inlinkJob, outlinkDb);
@@ -641,7 +642,7 @@ public void createWebGraph(Path webGraphDb, Path[] segments,
     inlinkJob.setOutputValueClass(LinkDatum.class);
     FileOutputFormat.setOutputPath(inlinkJob, tempInlinkDb);
     inlinkJob.setOutputFormatClass(MapFileOutputFormat.class);
-    conf.setBoolean("mapreduce.fileoutputcommitter.marksuccessfuljobs",
+    
inlinkJobConf.setBoolean("mapreduce.fileoutputcommitter.marksuccessfuljobs",
         false);
 
     try {
@@ -672,7 +673,8 @@ public void createWebGraph(Path webGraphDb, Path[] segments,
     Path tempNodeDb = new Path(nodeDb + "-"
         + Integer.toString(new Random().nextInt(Integer.MAX_VALUE)));
 
-    Job nodeJob = NutchJob.getInstance(conf);
+    Job nodeJob = NutchJob.getInstance(getConf());
+    Configuration nodeJobConf = nodeJob.getConfiguration();
     nodeJob.setJobName("NodeDb " + nodeDb);
     LOG.info("NodeDb: adding input: " + outlinkDb);
     LOG.info("NodeDb: adding input: " + inlinkDb);
@@ -687,7 +689,7 @@ public void createWebGraph(Path webGraphDb, Path[] segments,
     nodeJob.setOutputValueClass(Node.class);
     FileOutputFormat.setOutputPath(nodeJob, tempNodeDb);
     nodeJob.setOutputFormatClass(MapFileOutputFormat.class);
-    conf.setBoolean("mapreduce.fileoutputcommitter.marksuccessfuljobs",
+    nodeJobConf.setBoolean("mapreduce.fileoutputcommitter.marksuccessfuljobs",
         false);
 
     try {
diff --git a/src/java/org/apache/nutch/util/ProtocolStatusStatistics.java 
b/src/java/org/apache/nutch/util/ProtocolStatusStatistics.java
index c7a852df3..2082fe518 100644
--- a/src/java/org/apache/nutch/util/ProtocolStatusStatistics.java
+++ b/src/java/org/apache/nutch/util/ProtocolStatusStatistics.java
@@ -65,8 +65,6 @@
 
   private static final Text UNFETCHED_TEXT = new Text("UNFETCHED");
 
-  public static Configuration conf;
-
   public int run(String[] args) throws Exception {
     if (args.length < 2) {
       System.err.println("Usage: ProtocolStatistics inputDirs outDir 
[numOfReducer]");
@@ -94,7 +92,7 @@ public int run(String[] args) throws Exception {
 
     String jobName = "ProtocolStatistics";
 
-    conf = getConf();
+    Configuration conf = getConf();
     conf.setBoolean("mapreduce.fileoutputcommitter.marksuccessfuljobs", false);
 
     Job job = Job.getInstance(conf, jobName);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> CrawlDbReader -dump ignores filter options
> ------------------------------------------
>
>                 Key: NUTCH-2644
>                 URL: https://issues.apache.org/jira/browse/NUTCH-2644
>             Project: Nutch
>          Issue Type: Bug
>          Components: crawldb
>    Affects Versions: 1.15
>            Reporter: Sebastian Nagel
>            Priority: Major
>             Fix For: 1.16
>
>
> The CrawlDbReader ignores the filter options -status and -expr when dumping a 
> crawldb:
> {noformat}
> % bin/nutch readdb crawldb/ -dump cdb.dump -status 'db_fetched' -expr 'status 
> == "db_fetched"'
> ...
> % grep '^Status:' cdb.dump/part-r-00000 | sort | uniq -c
>      10 Status: 1 (db_unfetched)
>      28 Status: 2 (db_fetched)
>       1 Status: 3 (db_gone)
>       1 Status: 4 (db_redir_temp)
>       3 Status: 7 (db_duplicate)
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to