Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c语言指针跟数组的区别——和mapreduce的思想 #10

Open
maiff opened this issue Feb 13, 2018 · 0 comments
Open

c语言指针跟数组的区别——和mapreduce的思想 #10

maiff opened this issue Feb 13, 2018 · 0 comments
Labels

Comments

@maiff
Copy link
Owner

maiff commented Feb 13, 2018

c语言指针跟数组的区别——和mapreduce的思想

c语言数组跟指针的区别

关键要知道每个符号的地址在编译时可知。所以如果编译器需要地址加上偏移量这种操作就可以直接进行操作,比如数组。相反,指针必须在运行的时取得它当前值,然后才能进行应用操作。

定义为指针但以数组方式引用

char *p = "abcdefgh";
c = p[i]

编译器具有一个p 地址为4624
运行时取4624的内容 5081
取得i的值与5081相加
取地址[5081+i]的内容

定义为数组但以指针的方式引用

声明extern char *p;却定义是char p[10],当用P[10]这种形式提取这个声明内容时,实际上得到是一个字符。但按照上面的方法,编译器却把它当做是一个指针把ascii字符解释为地址显然是牛头不对马嘴。

以上内容来自expert c programming

MapReduce

find friend example

function map(String name, String document):
  // name: document name
  // document: document contents
  for each word w in document:
    emit (w, 1)

function reduce(String word, Iterator partialCounts):
  // word: a word
  // partialCounts: a list of aggregated partial counts
  sum = 0
  for each pc in partialCounts:
    sum += pc
  emit (word, sum)
  //from wikipedia

按照我的理解,MapReduce有个map函数,和一个reduce函数,他们接受的参数也是一定的,跟状态没有关系,而且返回时key-value也跟状态没有关系,这样就可以在分布式里运用消息队列和键值数据库。

@maiff maiff added the blog label Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant