How to input HDFS file into R mapreduce for processing and get the result into HDFS file -


I have the same question as the link below in the stack overflow

I, the location "/somnath/logreg_data/ds1.10.csv" read one file from HDFS to reduce the number of columns from 10 to 5 and then another place "/ somnath / logreg_data / reduced / ds1. 10 am tring to write. At least CDSV is using the transfer.csvfile.hdfs.to.hdfs.reduced function below in HDFS.

  transfer.csvfile.hdfs.to.hdfs.reduced ("HDFS: //10.5.5.82: 8020 / Somnath / logreg_data / ds1.10.csv", "HDFS: //10.5 .5.82: 8020 / Somnath / Logreg_data / low / DS1.10.rated.csv ", 5)   

The function definition is

  transfer.csvfile.hdfs .to.hdfs.reduced = function (hdfsFilePath, hdfsWritePath, reducedCols = 1) {# local.df = data.frame () # hdfs.get (hdfsFilePath, local.df) # to.dfs (local.df) # R .file & lt; - hdfs.file (hdfsFilePath, "r") transfer.reduced.mapped = function (., M) {label & lt; - M [, dim (M) [2]] weak. Plotter & lt; - M [, 1: reduced calls] less. M & lt; - cbind (reduced predictors, labels) keyless (1, as.Numeric (reduced.M))} less. Value = value (from.dfs (mapreduce (input = From.dfs (hdfsFilePath), input.format = "native", map = function (., M) {label & lt; - m [, dim (m) [2] ]] Less printed (labeled) .lotter <> - M [, 1: reduced calls] Less. & Lt; - cbind (weak pictures, label) keval (1, as.numeric (reduced.M)) }))) Write writeable (lower value, file = "/ root / somnath / less D.values.csv") w file and lieutenant; - hdfs.file (hdfsWritePath, "w") hdfs.write (reduced.values, w.file) # to.dfs (reduced.values)}   paste (if (read.) " R "and" w ", if (format $ mode = =: can not open connection call: transfer.csvfile.hdfs.to.hdfs.reduced ... make.keyval.reader -> Do.call - & gt; ; & Lt; Anonymous & gt; - & gt; In addition to the file: Warning message: in the file (fname, paste (if (read.) "R" else "w", if (format $ mode ==: '  

OR

When I'm trying to load down A file from the HDFS using the commands I get, I get the following error:

  & gt; x & lt; - hdfs.file (path = "hdfs: //10.5.5.82 : 8020 / Somnath /logreg_data/ds1.10.csv",mode="r ") Error in hdfs.file (path =" HDFS: //10.5.5.82: 8020 / Somnath / logreg_data / ds1.10.csv " Any effort to apply will be highly appreciated  

thanks

< P> Actually I found the problem described above.
  r.file & lt; - hdfs.file (hdfsFilePath, "r") from.dfs (mappedead) (input = as.matrix (hdfs.read.text.file (r.file)), input.format = "csv", map = .. The complete revised function is below:  
  transfer.csvfile.hdfs.to.hdfs.reduced = function (hdfsFilePath, hdfsWritePath, reducedCols = 1) {hdfs.init () # local.df = data.frame () # hdfs.get (hdfsFilePath, local.df) # to.dfs (local.df) r.file & lt; - hdfs.file (hdfsFilePath, "r") transfer.reduced.map = function (., M) {numRows & lt; - Length (M) M.vec .elems & LT; -unlist (lapply (m, function); strsplit (x, "")) M.matrix & lt; - Matrix (M.vec.elems, Nrow = numrows, byrow = TRUE) Labels & LT; - M. Metrics [, dim (M. matrix) [2]] weak. And lie down - M. matrix [, 1: reduced calls] less. M & LT; - CBIID (weak pictures, label) as keyval (1, .numeric (reduced.M))} less. Value = value (from.dfs (mappedreadus (input = as.matrix (hdfs.read.text.file (r.file)), input.format = "csv", map = function (., M) {numRows & lt ; - Length (M) M.V.C.LX & lt; -list (lapply (m, function x) strsplit (x, ","))) M. matrix <- Matrix (M.vec.elems, Labels & lt; - M. matrix [, dim (M. matrix) [2]] Weak. Article. & Lt; - M. matrix [, 1: reduced call] Less. M & LT; - cbind (decrease D.predictors, label) keyval (1, as.numeric (reduced.M))}))) write.table (lower value, file = "/ root / somnath / short. Values.csv ") w.file & lt; - hdfs.file (hdfsWritePath, "w") hdfs.write (lower value, w.file) hdfs.close (r.file) hdfs.close (w.file) # to.dfs (reduced.values)} < / Code>  

Hope this helps and do not forget to give points if you find it useful. Go

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -