• <tfoot id='6juLF'></tfoot>

  • <legend id='6juLF'><style id='6juLF'><dir id='6juLF'><q id='6juLF'></q></dir></style></legend>
      • <bdo id='6juLF'></bdo><ul id='6juLF'></ul>
    1. <i id='6juLF'><tr id='6juLF'><dt id='6juLF'><q id='6juLF'><span id='6juLF'><b id='6juLF'><form id='6juLF'><ins id='6juLF'></ins><ul id='6juLF'></ul><sub id='6juLF'></sub></form><legend id='6juLF'></legend><bdo id='6juLF'><pre id='6juLF'><center id='6juLF'></center></pre></bdo></b><th id='6juLF'></th></span></q></dt></tr></i><div id='6juLF'><tfoot id='6juLF'></tfoot><dl id='6juLF'><fieldset id='6juLF'></fieldset></dl></div>

      <small id='6juLF'></small><noframes id='6juLF'>

        MapReduce 结果似乎限制为 100?

        时间:2023-09-12
          <tbody id='sxjzG'></tbody>

        <i id='sxjzG'><tr id='sxjzG'><dt id='sxjzG'><q id='sxjzG'><span id='sxjzG'><b id='sxjzG'><form id='sxjzG'><ins id='sxjzG'></ins><ul id='sxjzG'></ul><sub id='sxjzG'></sub></form><legend id='sxjzG'></legend><bdo id='sxjzG'><pre id='sxjzG'><center id='sxjzG'></center></pre></bdo></b><th id='sxjzG'></th></span></q></dt></tr></i><div id='sxjzG'><tfoot id='sxjzG'></tfoot><dl id='sxjzG'><fieldset id='sxjzG'></fieldset></dl></div>
        • <bdo id='sxjzG'></bdo><ul id='sxjzG'></ul>
          <legend id='sxjzG'><style id='sxjzG'><dir id='sxjzG'><q id='sxjzG'></q></dir></style></legend>

            1. <small id='sxjzG'></small><noframes id='sxjzG'>

            2. <tfoot id='sxjzG'></tfoot>

                  本文介绍了MapReduce 结果似乎限制为 100?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我在 MongoDB 和 python 中使用 Map Reduce,但遇到了一个奇怪的限制.我只是想计算书"记录的数量.它在少于 100 条记录时有效,但当超过 100 条记录时,由于某种原因计数会重置.

                  I'm playing around with Map Reduce in MongoDB and python and I've run into a strange limitation. I'm just trying to count the number of "book" records. It works when there are less than 100 records but when it goes over 100 records the count resets for some reason.

                  这是我的 MR 代码和一些示例输出:

                  Here is my MR code and some sample outputs:

                  var M = function () {
                  book = this.book;
                  emit(book, {count : 1});
                  }
                  
                  var R = function (key, values) {
                  var sum = 0;
                  values.forEach(function(x) {
                  sum += 1;
                  });
                  var result = {
                  count : sum 
                  };
                  return result;
                  }
                  

                  记录数为99时的MR输出:

                  MR output when record count is 99:

                  {u'_id': u'superiors', u'value': {u'count': 99}}
                  

                  记录数为101时的MR输出:

                  MR output when record count is 101:

                  {u'_id': u'superiors', u'value': {u'count': 2.0}}
                  

                  有什么想法吗?

                  推荐答案

                  你的 reduce 函数应该是对 count 值求和,而不仅仅是添加 1 每个值.否则,一个 reduce 的输出不能被正确地用作另一个 reduce 的输入.试试这个:

                  Your reduce function should be summing up the count values, not just adding 1 for each value. Otherwise the output of a reduce can't properly be used as input back into another reduce. Try this instead:

                  var R = function (key, values) {
                    var sum = 0;
                    values.forEach(function(x) {
                      sum += x.count;
                    });
                    var result = {
                      count : sum 
                    };
                    return result;
                  }
                  

                  这篇关于MapReduce 结果似乎限制为 100?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Hadoop Streaming - 找不到文件错误 下一篇:将列表的字典(2 级深)展平

                  相关文章

                  最新文章

                  <i id='Us4Sy'><tr id='Us4Sy'><dt id='Us4Sy'><q id='Us4Sy'><span id='Us4Sy'><b id='Us4Sy'><form id='Us4Sy'><ins id='Us4Sy'></ins><ul id='Us4Sy'></ul><sub id='Us4Sy'></sub></form><legend id='Us4Sy'></legend><bdo id='Us4Sy'><pre id='Us4Sy'><center id='Us4Sy'></center></pre></bdo></b><th id='Us4Sy'></th></span></q></dt></tr></i><div id='Us4Sy'><tfoot id='Us4Sy'></tfoot><dl id='Us4Sy'><fieldset id='Us4Sy'></fieldset></dl></div>

                    <small id='Us4Sy'></small><noframes id='Us4Sy'>

                    • <bdo id='Us4Sy'></bdo><ul id='Us4Sy'></ul>
                    <tfoot id='Us4Sy'></tfoot>

                    1. <legend id='Us4Sy'><style id='Us4Sy'><dir id='Us4Sy'><q id='Us4Sy'></q></dir></style></legend>