MCPcopy Create free account
hub / github.com/apache/nutch / map

Method map

src/java/org/apache/nutch/crawl/GeneratorMapper.java:49–108  ·  view source on GitHub ↗
(String reversedUrl, WebPage page, Context context)

Source from the content-addressed store, hash-verified

47 private float scoreThreshold;
48
49 @Override
50 public void map(String reversedUrl, WebPage page, Context context)
51 throws IOException, InterruptedException {
52 String url = TableUtil.unreverseUrl(reversedUrl);
53
54 if (Mark.GENERATE_MARK.checkMark(page) != null) {
55 GeneratorJob.LOG.debug("Skipping {}; already generated", url);
56 return;
57 }
58
59 // filter on distance
60 if (maxDistance > -1) {
61 CharSequence distanceUtf8 = page.getMarkers().get(DbUpdaterJob.DISTANCE);
62 if (distanceUtf8 != null) {
63 int distance = Integer.parseInt(distanceUtf8.toString());
64 if (distance > maxDistance) {
65 return;
66 }
67 }
68 }
69
70 // If filtering is on don't generate URLs that don't pass URLFilters
71 try {
72 if (normalise) {
73 url = normalizers.normalize(url,
74 URLNormalizers.SCOPE_GENERATE_HOST_COUNT);
75 }
76 if (filter && filters.filter(url) == null)
77 return;
78 if ((sitemap && !URLFilters.isSitemap(page)) || !sitemap && URLFilters
79 .isSitemap(page))
80 return;
81 } catch (URLFilterException | MalformedURLException e) {
82 GeneratorJob.LOG
83 .warn("Couldn't filter url: {} ({})", url, e);
84 return;
85 }
86
87 // check fetch schedule
88 if (!schedule.shouldFetch(url, page, curTime)) {
89 if (GeneratorJob.LOG.isDebugEnabled()) {
90 GeneratorJob.LOG.debug("-shouldFetch rejected '" + url
91 + "', fetchTime=" + page.getFetchTime() + ", curTime=" + curTime);
92 }
93 return;
94 }
95 float score = page.getScore();
96 try {
97 score = scoringFilters.generatorSortValue(url, page, score);
98 } catch (ScoringFilterException e) {
99 // ignore
100 }
101
102 // consider only entries with a score superior to the threshold
103 if (scoreThreshold != Float.NaN && score < scoreThreshold)
104 return;
105
106 entry.set(url, score);

Callers

nothing calls this directly

Calls 14

unreverseUrlMethod · 0.95
isSitemapMethod · 0.95
checkMarkMethod · 0.80
getMethod · 0.65
normalizeMethod · 0.65
filterMethod · 0.65
shouldFetchMethod · 0.65
generatorSortValueMethod · 0.65
writeMethod · 0.65
getMarkersMethod · 0.45
toStringMethod · 0.45
getFetchTimeMethod · 0.45

Tested by

no test coverage detected