java - 如何将数组中的字符串附加到 mapreduce 中的 Text()

标签 java hadoop mapreduce

我有一个数组中的字符串。我需要将基于索引的数组的所有元素附加到 mapreduce 中的 Text()。我需要将值作为字符串附加到 Text()

例如:

 String s = "12,23";
 String[] array = s.split(",");
 Text t1 = new Text();
 for(int i=0;i<array.length;i++) {
     t1.append(array[i]);
 }

最佳答案

您可以这样做而不需要拆分字符串数组:

String str = "12,23";
String newStr = str.replace("," , ""); // or replace with any character or string you want between those numbers
Text text = new Text(newStr);

关于java - 如何将数组中的字符串附加到 mapreduce 中的 Text(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39507607/

相关文章:

java - java中永远无法通过键盘输入的字符

java - 透明背景清屏java

hadoop - hive -e 带分隔符

bash - Hadoop-2.6 中 Map Reduce 作业的总时间计算

java - Spring data rest合并补丁

java - Java 中的日期时间选择器

hadoop - 与Hadoop中的MapReduce中的 'controller'等效

compression - Hadoop,如何压缩映射器输出而不是缩减器输出

java - Hadoop 设置最大并发 mapreduce 任务在伪模式下不起作用

database - 是否有任何 nosql 数据库可以在 map/reduce 上进行搜索(例如 lucene)