我想知道将2013年10月26日的日期转换为41573的公式,如excel中所做的那样.就像10/26/2013如何转换为41573.
我有一个简单的mapreduce代码,包括mapper,reducer和combiner.mapper的输出传递给组合器.但是对于reducer而言,不是来自组合器的输出,而是传递mapper的输出.
请帮助
码:
package Combiner;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.Mapper.Context;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.GenericOptionsParser;
public class AverageSalary
{
public static class Map extends Mapper<LongWritable, Text, Text, DoubleWritable>
{
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException
{
String[] empDetails= value.toString().split(",");
Text unit_key = new Text(empDetails[1]);
DoubleWritable salary_value = new DoubleWritable(Double.parseDouble(empDetails[2]));
context.write(unit_key,salary_value);
}
}
public static class Combiner extends Reducer<Text,DoubleWritable, Text,Text> …
Run Code Online (Sandbox Code Playgroud) 我想将tsv格式的文件转换为xls/xlsx ..
我试过用
os.rename("sample.tsv","sample.xlsx")
Run Code Online (Sandbox Code Playgroud)
但是转换的文件已损坏.有没有其他方法呢?
我正在使用MRUnit测试我的映射器。我正在传递键和值列表作为测试类向映射器的输入。问题是 :
String key=1234_abc;
ArrayList<KeyValue> list = new ArrayList<KeyValue>();
KeyValue k1 = new KeyValue(Bytes.toBytes(key),"cf".getBytes(), "Val1".getBytes(),Bytes.toBytes("abc.com"));
KeyValue k2 = new KeyValue(Bytes.toBytes(key), "cf".getBytes(), "Val2".getBytes(),Bytes.toBytes("165"));
Result result = new Result(list);
mapDriver.withInput(key, result);
Run Code Online (Sandbox Code Playgroud)
问题在于,在结果对象中仅保留了第一个键值。其他被存储为空。