和rhadoop有问题吗?

jyztefdp  于 2021-06-02  发布在  Hadoop
关注(0)|答案(0)|浏览(272)

我已经用rmr检查了这个问题:rhadoop-wordcount,并尝试了我这边的答案。但它给了很多问题。
代码如下:

Sys.setenv("HADOOP_CMD"="/usr/local/hadoop/bin/hadoop")
Sys.setenv("HADOOP_STREAMING"="/usr/local/hadoop/share/hadoop/tools/lib/hadoop-streaming-2.4.0.jar")

# load librarys

library(rmr2)
library(rhdfs)

# initiate rhdfs package

hdfs.init()

map <- function(k,lines) {
  words.list <- strsplit(lines, '\\s')
  words <- unlist(words.list)
  return( keyval(words, 1) )
}

reduce <- function(word, counts) {
  keyval(word, sum(counts))
}

wordcount <- function (input, output=NULL) {
  mapreduce(input=input, output=output, input.format="text", map=map, reduce=reduce)
}

## read text files from folder example/wordcount/data

hdfs.root <- 'example/wordcount'
hdfs.data <- file.path(hdfs.root, 'data')

## save result in folder example/wordcount/out

hdfs.out <- file.path(hdfs.root, 'out')

## Submit job

out <- wordcount(hdfs.data, hdfs.out) 

## Fetch results from HDFS

results <- from.dfs(out)
results.df <- as.data.frame(results, stringsAsFactors=F)
colnames(results.df) <- c('word', 'count')

head(results.df)

以下是问题:
https://justpaste.it/143a0
我不明白这个问题以及这个问题的解决方法。请帮助我,让我知道什么是这个特殊问题的解决办法。
我使用的是rstudio服务器和r的最新版本。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题