在mapreduce中难以理解 [英] Having difficulty in mapreduce to understand

查看:141
本文介绍了在mapreduce中难以理解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到下面的链接,它是python入门mapreduce的开始!



http://code.google.com/p/appengine-mapreduce/wiki/GettingStartedInPython



但我仍然无法理解它的工作方式。



mapreduce.yaml


$ b我正在执行下面的代码,但无法理解究竟发生了什么? $ b

  mapreduce:
- 名称:Testmapper
映射器:
input_reader:mapreduce.input_readers.DatastoreInputReader
处理器:main.process
params:
- name:entity_kind
default:main.userDetail

mapreduce / main.py

 一些代码

class userDetail (db.Model):
name = db.StringProperty()

某些代码

def process(u):
u.name = mahesh
yield op.db.Put(u)

我正在执行此操作



但是无法理解发生了什么

主要的是我想用mapreduce做就是从实体搜索或计数记录

所以任何人都可以请帮助我??



提前致谢 您正在设置所有 userDetail mahesh值添加到 StringProperty名称

如果你想计算你的实体使用:

 从mapreduce导入操作作为op 
def process(实体):
yield op.counters.Increment(counter1)


I have seen the below link which is of getting started mapreduce with python

http://code.google.com/p/appengine-mapreduce/wiki/GettingStartedInPython

But still I am not able to understand how its working. I am executing below code but not able to understand what exactly is happening?

mapreduce.yaml

mapreduce: 
- name: Testmapper 
   mapper: 
       input_reader: mapreduce.input_readers.DatastoreInputReader 
       handler: main.process 
   params: 
       - name: entity_kind 
         default: main.userDetail

mapreduce/main.py

some code

class userDetail(db.Model): 
name = db.StringProperty()

some code

def process(u): 
          u.name="mahesh" 
          yield op.db.Put(u)

I am executing this and it gives me status = success in status page.

But not able to understand what happend

The main thing I want do with mapreduce is to search or count records from entity

So anyone can please help me??

Thanks in advance

解决方案

You are setting the "mahesh" value to the StringProperty name of all your userDetail entities.

If you want to count your entities use :

from mapreduce import operation as op
 def process(entity):
    yield op.counters.Increment("counter1")

这篇关于在mapreduce中难以理解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆