标签: mapreduce

为Hadoop MR创建序列文件格式

我正在和我一起工作Hadoop MapRedue,并有一个问题.目前,我的映射的input KV typeLongWritable, LongWritable typeoutput KV typeLongWritable, LongWritable type.InputFileFormat是SequenceFileInputFormat.基本上我想要做的是将一个txt文件更改为SequenceFileFormat,以便我可以将它用于我的mapper.

我想做的是

输入文件是这样的

1\t2 (key = 1, value = 2)

2\t3 (key = 2, value = 3)

等等...

我查看了这个线程如何将.txt文件转换为Hadoop的序列文件格式,TextInputFormat只重新支持Key = LongWritable and Value = Text

有没有办法获得txt并生成一个序列文件KV = LongWritable, LongWritable

hadoop mapreduce

0
推荐指数
1
解决办法
8710
查看次数

MongoDB/Mongoose:无法使用最简单的MapReduce

大家好我想做的就是获取每个不同departmentType的计数:

fnMap = function() { 
  emit(this.departments.departmentType, {typeCount:1} ); 
} 

fnReduce = function(key, values) { 
  var result = {typeCount: 0}; 
  values.forEach(function(value) {
    result.typeCount += value.brandCount;
  });

  return result;             
};


var command = {
mapreduce : "clients", 
query     : {"departments.departmentType": {$exists: true}},
map       : fnMap.toString(), 
reduce    : fnReduce.toString(),    
    //sort: {"departments.departmentType":1}, 
    out: {inline: 1}   
};

mongoose.connection.db.executeDbCommand(command, function(err, dbres) {

    }); 
Run Code Online (Sandbox Code Playgroud)

执行命令时,dbres.documents [0] .results只包含1个具有departmentTypes总数的项目,而不是包含每个departmentType及其计数的几个项目.

有什么想法我做错了什么?

此外,当我取消注释SORT行时,我收到错误"db assertion failure:无法创建游标...",我相信字段名称是正确写入的.

grouping mapreduce mongoose mongodb

0
推荐指数
1
解决办法
4198
查看次数

使用mongoDB和Morphia映射Reduce

我用morphia在mongoDB中运行map reduce,这是我的java代码

String map = "function() { emit(this.id,this.cal.charge)}";
String reduce = "function(k, v) {var i, sum = 0;for (i in v) {sum += v[i];}return sum;}";

MapreduceResults<Results> mrRes = ds.mapReduce(MapreduceType.MERGE,ds.createQuery(MyTable.class).field("id").equal(5),map,reduce,null,null,Re.class);   
Run Code Online (Sandbox Code Playgroud)

这工作正常并将结果放到'Re'集合中,但是如何在不插入新集合的情况下将结果作为对象或列表获取?

谢谢

java mapreduce mongodb morphia

0
推荐指数
1
解决办法
2240
查看次数

性能比较:Hive和MapReduce

Hive为java Map Reduce作业提供了一个抽象层,因此与Java Map Reduce作业相比,它应该具有性能问题.

Do we have any benchmark to compare the performance of Hive Query & Java Map Reduce Jobs ? 
Run Code Online (Sandbox Code Playgroud)

具有运行时数据的实际用例场景将是真正的帮助.

谢谢

hadoop hive mapreduce

0
推荐指数
1
解决办法
2203
查看次数

在MapReduce中,如何在处理X记录后停止减速器

我正在使用Mapper加载大量数据,这些数据具有执行时间和与之关联的大型查询.我只需要找到1000个最昂贵的查询,所以我将执行时间作为我输出的关键字输入映射器.我使用1个reducer,只想写1000条记录,减速机停止处理.

如果(count <1000){context.write(key,value)},我可以有一个全局计数器并执行此操作

但这仍将加载所有数十亿条记录,然后不再写入.

我希望在吐出1000条记录后停止减速机.通过避免下一组记录的搜索时间和读取时间.

这可能吗??

hadoop mapreduce reducers mapper

0
推荐指数
1
解决办法
1370
查看次数

MongoDb:从查询中的两个数组中查找公共元素

假设我们在数据库中有以下结构的记录。

{
  "_id": 1234,
  "tags" : [ "t1", "t2", "t3" ]
}
Run Code Online (Sandbox Code Playgroud)

现在,我想检查数据库是否包含带有数组中指定的任何标签的记录 tagsArray which is [ "t3", "t4", "t5" ]

我了解$in运算符,但我不仅想知道数据库中的任何记录是否具有tagsArray中指定的任何标记,还想知道数据库中记录的哪个标记与tagsArray中指定的任何标记相匹配。(即在上述记录中为t3)

也就是说,我想比较两个数组(一个记录,另一个由我给定),并找出公共元素。

我需要将此表达式与查询中的许多表达式一起使用,因此投影运算符(例如$,$ elematch等)不会有太大用处。(或者有没有一种方法可以使用它而不必遍历所有记录?)

我想我可以使用$where运算符,但我认为这不是最好的方法。如何解决这个问题?

mapreduce mongodb aggregation-framework

0
推荐指数
1
解决办法
2443
查看次数

从MapReduce写入Hive(初始化HCatOutputFormat)

我编写了MR脚本,它应该从HBase加载数据并将它们转储到Hive中.连接到HBase是可以的,但是当我尝试将数据保存到HIVE表时,我收到以下错误消息:

 Failing Oozie Launcher, Main class [org.apache.oozie.action.hadoop.JavaMain], main() threw exception, org.apache.hive.hcatalog.common.HCatException : 2004 : HCatOutputFormat not initialized, setOutput has to be called
  org.apache.oozie.action.hadoop.JavaMainException: org.apache.hive.hcatalog.common.HCatException : 2004 : HCatOutputFormat not initialized, setOutput has to be called
  at org.apache.oozie.action.hadoop.JavaMain.run(JavaMain.java:58)
  at org.apache.oozie.action.hadoop.LauncherMain.run(LauncherMain.java:38)
  at org.apache.oozie.action.hadoop.JavaMain.main(JavaMain.java:36)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at org.apache.oozie.action.hadoop.LauncherMapper.map(LauncherMapper.java:226)
  at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:54)
  at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:430)
  at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
  at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:168)
  at java.security.AccessController.doPrivileged(Native Method)
  at javax.security.auth.Subject.doAs(Subject.java:415)
  at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1548)
  at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:163)
  Caused by: org.apache.hive.hcatalog.common.HCatException : 2004 : HCatOutputFormat not initialized, setOutput has …
Run Code Online (Sandbox Code Playgroud)

hadoop hive mapreduce

0
推荐指数
1
解决办法
1488
查看次数

Map-reduce JobConf - 添加FileInputFormat时出错

我创建了一个Mapper使用语法:

public class xyz extends MapReduceBase implements Mapper<LongWritable, Text, Text, Text>{
    -----
    public void map(LongWritable key, Text value,
        OutputCollector<Text, Text> output, Reporter reporter)
    --
}
Run Code Online (Sandbox Code Playgroud)

在作业中,我创建了一个Job对象:

Job job = new Job(getConf());
Run Code Online (Sandbox Code Playgroud)

对于这项工作,我无法使用以下方法添加Mapper类:

job.setMapper(xyz);
Run Code Online (Sandbox Code Playgroud)

错误信息:

The method setMapperClass(Class<? extends Mapper>) in the type Job is not applicable for the arguments (Class<InvertedIndMap1>)
Run Code Online (Sandbox Code Playgroud)

我不能使用带有extend的地图,Mapper因为我正在使用outputCollectorReportermapper.

在工作中,如果我使用JobConf而不是像以下那样的工作:

JobConf conf = new JobConf(getConf());
Run Code Online (Sandbox Code Playgroud)

然后conf.setMapper(xyz)工作.

但是无法使用以下方法设置输入路径:

FileInputFormat.addInputPaths(conf,new Path(args[0]));
Run Code Online (Sandbox Code Playgroud)

错误信息:

The method addInputPaths(Job, String) …
Run Code Online (Sandbox Code Playgroud)

hadoop mapreduce

0
推荐指数
1
解决办法
2119
查看次数

递归拆分字符串

说我有这样的文字:

pattern = "This_is some word/expression I'd like to parse:intelligently(using special symbols-like '.')"
Run Code Online (Sandbox Code Playgroud)

挑战在于如何使用单词分隔符将其拆分为单词

c(" ","-","/","\\","_",":","(",")",".",",")
Run Code Online (Sandbox Code Playgroud)

家庭.

期望的结果:

"This" "is" "some" "word" "expression" "I'd" "like" "to" "parse" "intelligently" "using" "special" "symbols" "like"
Run Code Online (Sandbox Code Playgroud)

方法:

我可以做sapplyfor循环使用:

 keywords = unlist(strsplit(pattern," "))
 keywords = unlist(strsplit(keywords,"-"))
Run Code Online (Sandbox Code Playgroud)

#等

题:

但是使用什么解决方案Reduce(f, x, init, accummulate=TRUE)

regex string r mapreduce

0
推荐指数
1
解决办法
192
查看次数

有没有办法在Hive HQL中将两列相加到另一列?

我希望每天,每周和每月运行我发送的邮件数量.大约有500种不同的消息类型.

我有以下表格:

Table name: messages

int message_type
BIGINT num_sent
string date

Table name: stats

int message_type
BIGINT num_sent_today
BIGINT num_sent_week
BIGINT num_sent_month
Run Code Online (Sandbox Code Playgroud)

表消息每天更新,包含今天日期的新行.我可以每天运行一个单独的配置单元查询来更新stats表吗?注意我无法通过直接查询消息表来获取运行计数,WHERE date >= 30 days ago因为表太大了.我必须添加/减去表统计中的每日值.像这样的东西:

// pseudocode
// Get this table (call it table b) from table messages

   int message_type
   BIGINT num_sent_today
   BIGINT num_sent_seven_days_ago
   BIGINT num_sent_thirty_days_ago

// join b with table stats so that I can

// Set stats.num_sent_today = b.num_sent_today
// Set stats.num_sent_week = stats.num_sent_week + b.num_sent_today - b.num_sent_seven_days_ago
// Set stats.num_sent_month …
Run Code Online (Sandbox Code Playgroud)

hadoop hive mapreduce hiveql

0
推荐指数
1
解决办法
5797
查看次数