Tag: hadoop

PIG – 找到接口org.apache.hadoop.mapreduce.JobContext,但是类是预期的

我试图从蜂巢中加载一个表。 我正在使用Hcatalog。 我使用登录hive pig -useHCatalog 我从蜂巢和hadoop出口几乎所有的jar子 register ‘hdfs://localhost:8020/user/pig/jars/hive-jdbc-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-exec-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-common-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-metastore-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/mysql-connector-java-5.1.28-bin.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-beeline-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-builtins-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-cli-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-contrib-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-hbase-handler-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-hwi-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-metastore-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-pdk-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-serde-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-service-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-shims-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/antlr-2.7.7.jar’; register ‘hdfs://localhost:8020/user/pig/jars/antlr-runtime-3.4.jar’; register ‘hdfs://localhost:8020/user/pig/jars/avro-1.7.4.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hcatalog-core-0.5.0-incubating.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hcatalog-pig-adapter-0.5.0-incubating.jar’; register ‘hdfs://localhost:8020/user/pig/jars/avro-ipc-1.7.4-tests.jar’; register ‘hdfs://localhost:8020/user/pig/jars/avro-mapred-1.7.4-hadoop2.jar’; register ‘hdfs://localhost:8020/user/pig/jars/commons-cli-1.2.jar’; register […]

java中的java.sql.SQLException:org.apache.thrift.transport.TTransportException?

我正在尝试使用java在hive中创建表。 我发现 java.sql.SQLException: org.apache.thrift.transport.TTransportException 在执行我的代码时。 这是我的代码 public void createTable(String tableName) { try{ Statement stat = con.createStatement(); String QueryString = “CREATE TABLE ‘”+tableName+”‘(User_Id INTEGER NOT NULL AUTO_INCREMENT, ” + “User_Name VARCHAR(25), UserId VARCHAR(20), User_Pwd VARCHAR(15), primary key(User_Id))”; a = stat.executeUpdate(QueryString); if(a==1){ System.out.println(a); System.out.println(“Table has been created”); } }catch(Exception e){ System.out.println(e);} } 为什么抛出此exception以及如何解决它。

在Hadoop中更改文件分割大小

我在HDFS目录中有一堆小文件。 虽然文件量相对较小, 但每个文件的处理时间量很大 。 也就是说, 64mb文件是TextInputFormat的默认分割大小,甚至需要几个小时才能处理。 我需要做的是减少分割大小 ,这样我就可以利用更多的节点来完成工作。 所以问题是,怎么可以分开文件让我们说10kb ? 我需要为此实现自己的InputFormat和RecordReader ,还是要设置任何参数? 谢谢。

没有这样的方法exceptionHadoop

当我从命令提示符运行Hadoop .jar文件时,它会抛出一个exception,说没有这样的方法StockKey方法。 StockKey是我为自己的键类型定义的自定义类。 这是例外: 12/07/12 00:18:47 INFO mapred.JobClient: Task Id : attempt_201207082224_0007_m_000000_1, Status : FAILED java.lang.RuntimeException: java.lang.NoSuchMethodException: SecondarySort$StockKey. () at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:115) at org.apache.hadoop.io.WritableComparator.newKey(WritableComparator.java:109) at org.apache.hadoop.io.WritableComparator.(WritableComparator.java:95) at org.apache.hadoop.io.WritableComparator.get(WritableComparator.java:51) at org.apache.hadoop.mapred.JobConf.getOutputKeyComparator(JobConf.java:795) at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.(MapTask.java:817) at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:383) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:325) at org.apache.hadoop.mapred.Child$4.run(Child.java:270) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:396) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1127) at org.apache.hadoop.mapred.Child.main(Child.java:264)

如何构建/运行这个简单的Mahout程序而不会出现exception?

我想运行我在Mahout In Action中找到的代码: package org.help; import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.SequenceFile; import org.apache.hadoop.io.Text; import org.apache.mahout.math.DenseVector; import org.apache.mahout.math.NamedVector; import org.apache.mahout.math.VectorWritable; public class SeqPrep { public static void main(String args[]) throws IOException{ List apples = new ArrayList(); NamedVector apple; apple = new NamedVector(new DenseVector(new double[]{0.11, 510, 1}), “small round […]

从reducer访问映射器的计数器

我需要从我的reducer中的mapper访问计数器。 这可能吗? 如果是这样怎么办? 举个例子:我的映射器是: public class CounterMapper extends Mapper { static enum TestCounters { TEST } @Override protected void map(Text key, Text value, Context context) throws IOException, InterruptedException { context.getCounter(TestCounters.TEST).increment(1); context.write(key, value); } } 我的减速机是 public class CounterReducer extends Reducer { @Override protected void reduce(Text key, Iterable values, Context context) throws IOException, InterruptedException { Counter […]

hadoop中的MultipleOutputFormat

我是Hadoop的新手。 我正在尝试Wordcount程序。 现在尝试多个输出文件,我使用MultipleOutputFormat 。 这个链接帮助我做到了这一点。 http://hadoop.apache.org/common/docs/r0.19.0/api/org/apache/hadoop/mapred/lib/MultipleOutputs.html 在我的司机课上我有 MultipleOutputs.addNamedOutput(conf, “even”, org.apache.hadoop.mapred.TextOutputFormat.class, Text.class, IntWritable.class); MultipleOutputs.addNamedOutput(conf, “odd”, org.apache.hadoop.mapred.TextOutputFormat.class, Text.class, IntWritable.class);` 而我的减少课就变成了这个 public static class Reduce extends MapReduceBase implements Reducer { MultipleOutputs mos = null; public void configure(JobConf job) { mos = new MultipleOutputs(job); } public void reduce(Text key, Iterator values, OutputCollector output, Reporter reporter) throws IOException { int […]

在值上迭代两次(MapReduce)

我收到一个迭代器作为参数,我想迭代两次值。 public void reduce(Pair key, Iterator values, Context context) 可能吗 ? 怎么样 ? 签名是由我使用的框架(即Hadoop)强加的。 – 编辑 – 最后, reduce方法的真实签名是iterable 。 我被这个wiki页面误导了(这实际上是我发现的wordcount的唯一非弃用(但错误)示例)。

从Spark中的压缩中读取整个文本文件

我有以下问题:假设我有一个包含压缩目录的目录,其中包含存储在HDFS上的多个文件。 我想创建一个包含T类型对象的RDD,即: context = new JavaSparkContext(conf); JavaPairRDD filesRDD = context.wholeTextFiles(inputDataPath); JavaPairRDD filesRDD = context.wholeTextFiles(inputDataPath); JavaRDD processingFiles = filesRDD.map(fileNameContent -> { // The name of the file String fileName = fileNameContent._1(); // The content of the file String content = fileNameContent._2(); // Class T has a constructor of taking the filename and the content of each […]

如何在Java程序中使用Sqoop?

我知道如何通过命令行使用sqoop。 但是不知道如何使用java程序调用sqoop命令。 谁能给一些代码视图?