Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- // if(videos.containsKey(key)){
- // List palavras = videos.get(key);
- // palavras.add(value);
- // }else{
- // List<Text> list = new ArrayList<>();
- // list.add(value);
- //
- // videos.put(key, list);
- //
- // }
- Configuration configuration = new Configuration();
- FileSystem hdfs = FileSystem.get(new URI("hdfs://hadoop-master:9000"), configuration);
- Path file = new Path("hdfs://hadoop-master:9000/Videos/Mining/" + key);
- Path fileTime = new Path("hdfs://hadoop-master:9000/Videos/Time/" + key);
- OutputStream os = null;
- if (hdfs.exists(file)) {
- hdfs.delete(file, true);
- // os = hdfs.create(file, true);
- }
- os = hdfs.create(file,
- new Progressable() {
- public void progress() {
- System.out.println("...bytes written:");
- }
- });
- OutputStream osT = null;
- if (hdfs.exists(fileTime)) {
- hdfs.delete(fileTime, true);
- // os = hdfs.create(file, true);
- }
- osT = hdfs.create(fileTime,
- new Progressable() {
- public void progress() {
- System.out.println("...bytes written:");
- }
- });
- BufferedWriter br = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
- BufferedWriter brT = new BufferedWriter(new OutputStreamWriter(osT, "UTF-8"));
- StringBuilder sb = new StringBuilder();
- StringBuilder sbT = new StringBuilder();
- for (Text val : value) {
- // System.out.println("Valores: " + val);
- String[] split = val.toString().split("_");
- sb.append(split[0]).append(" ");
- sbT.append(val.toString()).append(";");
- // System.exit(1);
- }
- br.write(sb.toString());
- brT.write(sbT.toString());
- this.result.set(value.toString());
- context.write(key, this.result);
- br.close();
- brT.close();
- } catch (URISyntaxException ex) {
- Logger.getLogger(ReducerLSA.class.getName()).log(Level.SEVERE, null, ex);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement