Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
对同时将两个不同的数据集读入Hadoop有什么建议吗?_Hadoop - Fatal编程技术网

对同时将两个不同的数据集读入Hadoop有什么建议吗?

对同时将两个不同的数据集读入Hadoop有什么建议吗?,hadoop,Hadoop,亲爱的hadooper: 我是hadoop新手,最近尝试实现一个算法 该算法需要计算一个矩阵,表示每两对歌曲的不同评级。我已经这样做了,输出是一个600000*600000稀疏矩阵,我存储在我的HDFS中。我们将此数据集称为A size=160G 现在,我需要阅读用户的个人资料来预测他们对特定歌曲的评分。因此,我需要首先读取用户的配置文件,即5G大小,调用此数据集B,然后使用数据集A进行计算 但是现在我不知道如何从一个hadoop程序中读取这两个数据集。或者我可以将数据集B读入RAM,然后进行计

亲爱的hadooper: 我是hadoop新手,最近尝试实现一个算法

该算法需要计算一个矩阵,表示每两对歌曲的不同评级。我已经这样做了,输出是一个600000*600000稀疏矩阵,我存储在我的HDFS中。我们将此数据集称为A size=160G

现在,我需要阅读用户的个人资料来预测他们对特定歌曲的评分。因此,我需要首先读取用户的配置文件,即5G大小,调用此数据集B,然后使用数据集A进行计算

但是现在我不知道如何从一个hadoop程序中读取这两个数据集。或者我可以将数据集B读入RAM,然后进行计算吗?我想我不能,因为HDFS是一个分布式系统,我不能将数据集B读入一台机器的内存


有什么建议吗?

Hadoop允许您为不同的文件夹使用不同的地图输入格式。因此,您可以从多个数据源读取数据,然后在映射函数中转换为特定类型,即,在一种情况下,您得到字符串,另一个字符串中的用户,SongSongRating,并且您的映射签名是字符串,Object。
第二步是选择推荐算法,以某种方式连接这些数据,这样聚合器将拥有足够的信息来计算推荐。

您可以使用两个映射函数,如果您想要实现不同的处理,每个映射函数可以处理一个数据集。您需要在工作配置中注册地图。例如:

           public static class FullOuterJoinStdDetMapper extends MapReduceBase implements Mapper <LongWritable ,Text ,Text, Text>
    {
            private String person_name, book_title,file_tag="person_book#";
            private String emit_value = new String();
            //emit_value = "";
            public void map(LongWritable key, Text values, OutputCollector<Text,Text>output, Reporter reporter)
                     throws IOException
            {
                    String line = values.toString();
                    try
                    {
                            String[] person_detail = line.split(",");
                            person_name = person_detail[0].trim();
                            book_title = person_detail[1].trim();
                    }
                    catch (ArrayIndexOutOfBoundsException e)
                    {
                            person_name = "student name missing";
                     }
                    emit_value = file_tag + person_name;
                    output.collect(new Text(book_title), new Text(emit_value));
            }

    }


       public static class FullOuterJoinResultDetMapper extends MapReduceBase implements  Mapper <LongWritable ,Text ,Text, Text>
     {
            private String author_name, book_title,file_tag="auth_book#";
            private String emit_value = new String();

这可能会有帮助,我建议你使用猪或蜂巢谷歌为他们。然后将其实现为从用户配置文件到歌曲数据的连接。我还将研究Mahout Hadoop机器学习系统。通过Hadoop的原生JavaAPI实现连接真的很烦人。。。Mahout确实为SlopeOne提供了一个预计算差异矩阵的实现,但它没有提供SlopeOne算法的完整hadoop版本。不管怎样,我还是要试试蜂箱。谢谢你的建议
                          emit_value = file_tag + author_name;                                     
                         output.collect(new Text(book_title), new Text(emit_value));
                 }

             }


       public static void main(String args[])
                    throws Exception
    {

           if(args.length !=3)
                    {
                            System.out.println("Input outpur file missing");
                            System.exit(-1);
                    }


            Configuration conf = new Configuration();
            String [] argum = new GenericOptionsParser(conf,args).getRemainingArgs();
            conf.set("mapred.textoutputformat.separator", ",");
            JobConf mrjob = new JobConf();
            mrjob.setJobName("Inner_Join");
            mrjob.setJarByClass(FullOuterJoin.class);

            MultipleInputs.addInputPath(mrjob,new Path(argum[0]),TextInputFormat.class,FullOuterJoinStdDetMapper.class);
            MultipleInputs.addInputPath(mrjob,new Path(argum[1]),TextInputFormat.class,FullOuterJoinResultDetMapper.class);

            FileOutputFormat.setOutputPath(mrjob,new Path(args[2]));
            mrjob.setReducerClass(FullOuterJoinReducer.class);

            mrjob.setOutputKeyClass(Text.class);
            mrjob.setOutputValueClass(Text.class);

            JobClient.runJob(mrjob);
    }