Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-2357 Index metadata throw Exception because writable object cannot be cast to Text - do not cast CrawlDatum metadata values from o.a.hadoop.io.Writable to o.a.hadoop.io.Text (contributed by Eyeris Rodriguez Rueda)

Sebastian Nagel439f1153991e
diff --git a/src/plugin/index-metadata/src/java/org/apache/nutch/indexer/metadata/MetadataIndexer.java b/src/plugin/index-metadata/src/java/org/apache/nutch/indexer/metadata/MetadataIndexer.java
index 78718aafd..3db3333db 100644
--- a/src/plugin/index-metadata/src/java/org/apache/nutch/indexer/metadata/MetadataIndexer.java
+++ b/src/plugin/index-metadata/src/java/org/apache/nutch/indexer/metadata/MetadataIndexer.java
@@ -23,6 +23,7 @@ import java.util.Map;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
+import org.apache.hadoop.io.Writable;
import org.apache.nutch.crawl.CrawlDatum;
import org.apache.nutch.crawl.Inlinks;
import org.apache.nutch.indexer.IndexingException;
@@ -55,7 +56,7 @@ public class MetadataIndexer implements IndexingFilter {
// add the fields from crawldb
if (dbFieldnames != null) {
for (String metatag : dbFieldnames) {
- Text metadata = (Text) datum.getMetaData().get(new Text(metatag));
+ Writable metadata = datum.getMetaData().get(new Text(metatag));
if (metadata != null)
doc.add(metatag, metadata.toString());
}