如何解决HBase 自定义地图减速器作业
我想使用 map reducer 作业将数据批量加载到 HBase (HDInsights) 集群中。
目标表结构比较简单:
RowKey = deviceId#datebucket#valuetype,{values:measured} = 31.2 (timestamp)
map reducer 作业是用 c# 编写的。
这是当前的基本实现:
using System;
using Microsoft.Hadoop.MapReduce;
namespace Solytic.Data.Hadoop.DeviceDataMapReducer
{
internal class Program
{
public class DeviveDataMapper : MapperBase
{
public override void Map(string inputLine,MapperContext context)
{
var csvColumns = inputLine.Split(';');
[... some CSV line magic ...]
context.EmitLine("???");
context.IncrementCounter("???",1);
}
}
public class DeviceDataJob : HadoopJob<DeviveDataMapper>
{
public override HadoopJobConfiguration Configure(ExecutorContext context)
{
var hadoopConfiguration = new HadoopJobConfiguration();
hadoopConfiguration.InputPath = "/input/device_data";
hadoopConfiguration.OutputFolder = "/output/device_data";
return hadoopConfiguration;
}
}
private static void Main(string[] args)
{
var myUri = new Uri("locahost");
var hadoop = Microsoft.Hadoop.MapReduce.Hadoop.Connect(myUri,"user_name","pwn");
var result = hadoop.MapReduceJob.ExecuteJob<DeviceDataJob>();
Console.Read();
}
}
}
在 Java 中,有一个名为 Put
的辅助类可以将一行写入上下文。
public void map(LongWritable key,Text value,Context context) throws IOException,InterruptedException {
[...]
Put HPut = new Put(l[0].getBytes());
HPut.add("backward".getBytes(),"first".getBytes(),l[i].getBytes());
context.write(new Text(l[0]),HPut);
我没有在网上找到任何示例信息,添加到上下文的行的输出是什么样的。由于在 c# 中缺少这些帮助程序类,PUT 行需要如何查找?
我需要设置 values:measured
以及单元版本(手动)。
还有一个奖励问题;) 计数器是干什么用的?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。