Apache Nutch is an extensible and scalable web crawler
NUTCH-1441 AnchorIndexingFilter should use plain HashSet
Lewis John McGibbneya56783048cc0
diff --git a/CHANGES.txt b/CHANGES.txtindex b7153c93f..b484f910d 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -2,6 +2,8 @@ Nutch Change Log(trunk) Current Development:+* NUTCH-1441 AnchorIndexingFilter should use plain HashSet (ferdy via lewismc)+* NUTCH-1470 Ensure test files are included for runtime testing (lewismc)* NUTCH-1434 Indexer to delete robots noindex (markus)diff --git a/src/plugin/index-anchor/src/java/org/apache/nutch/indexer/anchor/AnchorIndexingFilter.java b/src/plugin/index-anchor/src/java/org/apache/nutch/indexer/anchor/AnchorIndexingFilter.javaindex 749c66bee..b29d3510e 100644--- a/src/plugin/index-anchor/src/java/org/apache/nutch/indexer/anchor/AnchorIndexingFilter.java+++ b/src/plugin/index-anchor/src/java/org/apache/nutch/indexer/anchor/AnchorIndexingFilter.java@@ -16,10 +16,8 @@*/package org.apache.nutch.indexer.anchor;-import java.util.WeakHashMap;+import java.util.HashSet;-import org.slf4j.Logger;-import org.slf4j.LoggerFactory;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.io.Text;import org.apache.nutch.crawl.CrawlDatum;@@ -28,6 +26,8 @@ import org.apache.nutch.indexer.IndexingException;import org.apache.nutch.indexer.IndexingFilter;import org.apache.nutch.indexer.NutchDocument;import org.apache.nutch.parse.Parse;+import org.slf4j.Logger;+import org.slf4j.LoggerFactory;/*** Indexing filter that indexes all inbound anchor text for a document.@@ -56,19 +56,19 @@ public class AnchorIndexingFilterString[] anchors = (inlinks != null ? inlinks.getAnchors(): new String[0]);- // https://issues.apache.org/jira/browse/NUTCH-1037- WeakHashMap<String,Integer> map = new WeakHashMap<String,Integer>();+ HashSet<String> set = null;for (int i = 0; i < anchors.length; i++) {if (deduplicate) {+ if (set == null) set = new HashSet<String>();String lcAnchor = anchors[i].toLowerCase();// Check if already processed the current anchor- if (!map.containsKey(lcAnchor)) {+ if (!set.contains(lcAnchor)) {doc.add("anchor", anchors[i]);// Add to map- map.put(lcAnchor, 1);+ set.add(lcAnchor);}} else {doc.add("anchor", anchors[i]);