<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Why doesn't the reducer get all events from the mapper function in my custom reporting command? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-the-reducer-get-all-events-from-the-mapper-function/m-p/224548#M66160</link>
    <description>&lt;P&gt;I don't know if this is the issue but line 16:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE&gt;         word_cnt += count
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I think there are 2 different variables.  'cnt' and 'count'.   At line 16 'count' is not defined.&lt;/P&gt;</description>
    <pubDate>Wed, 11 Nov 2015 15:17:47 GMT</pubDate>
    <dc:creator>DeronJensen</dc:creator>
    <dc:date>2015-11-11T15:17:47Z</dc:date>
    <item>
      <title>Why doesn't the reducer get all events from the mapper function in my custom reporting command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-the-reducer-get-all-events-from-the-mapper-function/m-p/224547#M66159</link>
      <description>&lt;P&gt;I am trying to write a custom reporting command that finds the top words. It seems to work, but I see some data isn't transferred to reducer from mapper. For example, I process 10 events and produced 100 words on each mapper invocation, the reducer should get 100 x mapper times words to process, but it doesn't happen. Some of the words yielded by the mapper cannot be accessed by the reducer. &lt;/P&gt;

&lt;P&gt;My mapper and reducer implementation is below.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;@Configuration()
def map(self, records):
    self.logger.debug('TopWordsCommand.map')
    fieldname = self.field
    total = {}
    cnt = 0
    word_cnt = 0

    for record in records:
        text = record[fieldname]
        for word in text.split():
            if word in total:
                total[word] = int(total[word]) + 1
            else:
                total[word] = 1
            word_cnt += 1
        cnt += 1

    for word, count in total.iteritems():
        yield { 'word': word, 'count': count }

    self.logger.info('Finished map. Processed {} events and {} words.'.format(cnt, word_cnt))

def reduce(self, records):
    self.logger.debug('TopWordsCommand.reduce')
    total = {}
    word_cnt = 0
    uniq_word_cnt = 0

    for record in records:
        word = record['word']
        count = record['count']
        word_cnt += 1

        if word in total:
            total[word] += int(count)
        else:
            total[word] = int(count)
            uniq_word_cnt += 1

    for word, count in total.iteritems():
        yield { 'word': word, 'count': count }

    self.logger.info("Finished reduce. Total number of words {}, unique words {}".format(word_cnt, uniq_word_cnt))
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Nov 2015 11:53:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-the-reducer-get-all-events-from-the-mapper-function/m-p/224547#M66159</guid>
      <dc:creator>dcagatay</dc:creator>
      <dc:date>2015-11-11T11:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't the reducer get all events from the mapper function in my custom reporting command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-the-reducer-get-all-events-from-the-mapper-function/m-p/224548#M66160</link>
      <description>&lt;P&gt;I don't know if this is the issue but line 16:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE&gt;         word_cnt += count
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I think there are 2 different variables.  'cnt' and 'count'.   At line 16 'count' is not defined.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 15:17:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-the-reducer-get-all-events-from-the-mapper-function/m-p/224548#M66160</guid>
      <dc:creator>DeronJensen</dc:creator>
      <dc:date>2015-11-11T15:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't the reducer get all events from the mapper function in my custom reporting command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-the-reducer-get-all-events-from-the-mapper-function/m-p/224549#M66161</link>
      <description>&lt;P&gt;No that is not the issue. I didn't post the actual code, but it is very similar to the original to give the gist. The actual code doesn't give that kind of errors.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 15:29:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-the-reducer-get-all-events-from-the-mapper-function/m-p/224549#M66161</guid>
      <dc:creator>dcagatay</dc:creator>
      <dc:date>2015-11-11T15:29:39Z</dc:date>
    </item>
  </channel>
</rss>

