很简单,就是把sql数据库导入hdfs中
经常用的方法是如下方法
setInput
public static void setInput(JobConf job, Class<? extends DBWritable> inputClass, String inputQuery, String inputCountQuery)
- Initializes the map-part of the job with the appropriate input settings.
-
-
-
Parameters:
-
job
- The job -
inputClass
- the class object implementing DBWritable, which is the Java object holding tuple fields. -
inputQuery
- the input query to select fields. Example : "SELECT f1, f2, f3 FROM Mytable ORDER BY f1" -
inputCountQuery
- the input query that returns the number of records in the table. Example : "SELECT COUNT(f1) FROM Mytable" -
- 例如
- String queryStr="select distinct bookid, bookname from booktable";
-
- String countStr="select count (*) from booktable";
-
- DBinputformat.setInput(jobname,Book.class,queryStr,countStr);
-
- 这样的话,就好将booktable这个表中的书籍数据取出来放到了Book.class 中。
-