hadoop jar hadoopdb.jar edu.yale.cs.hadoopdb.dataloader.GlobalHasher input_path output_path 10 \| 0
上面的命令是將數據切分到10個分區內,即集羣中的10個結點,最後的參數 0是指對每行記錄的第一個字段進行hash,可將其視作鍵值。下面是edu.yale.cs.hadoopdb.dataloader.GlobalHasher類中的一段代碼,可以看到
該全局hasher要求輸入四個參數
//輸入 目錄
FileInputFormat.setInputPaths(conf, new Path(args[0]));
// OUTPUT properties
Path outputPath = new Path(args[1]);
HDFSUtil.deletePath(outputPath);
FileOutputFormat.setOutputPath(conf, outputPath);
//分區數量
int partNo = Integer.parseInt(args[2]);
conf.setNumReduceTasks(partNo);
//分界符
conf.set(DELIMITER_PARAM, args[3]);
//要hash的字段位置
int hashFieldPos = Integer.parseInt(args[4]);
conf.setInt(HASH_FIELD_POS_PARAM, hashFieldPos);