MapReduce TotalOrderPartitioning只将输出写入一个文件?

时间:2016-10-17 23:27:51

标签: hadoop totalorderpartitioner

我正在运行一个mapreduce作业,它读取输入并使用多个reduce进行排序。 我能够将输出与reducers的数量排序为5.但是,输出只写入1个文件,并且有4个空文件。 我正在使用输入采样器和totalorderpartitioner进行全局排序。

我的驱动程序如下所示:

do{
        System.out.print("Enter a multiple of 3: ");
        //We use the variable n to hold the multiple of 3, like the heading says to do.

        n = input.nextInt();
        if (n % 3 !=0 || n >= 25) {
            System.out.println("Error: Enter a multiple of 3 between 3 and 24, inclusive.");
            n = input.nextInt();                
        }
        /**
         * X = n /3, this gives us the base number of the multiple of 3 to use and figure out the
         * values of n->0 by 3's.
         */
        for(x = n / 3; x <= 8 && x >=0; x--){
            int three = 3 * x;
            System.out.printf(three + "\t");

        }

    }while(x >= 0);

1 个答案:

答案 0 :(得分:0)

您的RandomSampler参数对我来说似乎很可疑:

  • 第一个参数freq是概率,而不是百分比。对于pcnt = 1,您正在对100%的记录进行抽样。
  • 第二个参数numSamples应该更大。它应足以表示整个数据集的分布。

想象一下,你有以下钥匙:4,7,8,9,4,1,2,5,6,3,2,4,7,4,8,1,7,1,8,9, 9,9,9

使用freq = 0.3numSamples = 10。为简单起见,我们假设0.3表示每3个键一个(如果采样)。这将收集以下样本:4,9,2,3,7,1,8,9。这将分为1,2,3,4,7,8,9,9。此样本有8个元素,因此所有元素都保留,因为它不超过最大样本数numSamples = 10。 在此示例中,缩减器的边界将类似于2,4,8,9。这意味着如果一对拥有密钥&#34; 1&#34;它将最终出现在Reducer#1中。一对钥匙&#34; 2&#34;将最终进入Reducer#2。一对钥匙&#34; 5&#34;将最终出现在Reducer#3等......这将是一个很好的发行。

现在,如果我们在相同的示例键上运行您的值。您的freq = 1所以您将每个密钥都放入样本中。因此,您的示例将与初始键集相同。除了您设置最大样本数numSamples = 4,这意味着您只在样本中保留4个元素。您的最终样本可能是9,9,9,9。在这种情况下,所有边界都是相同的,因此所有对总是转到Reducer#5。

在我的例子中,看起来我们非常不幸拥有相同的最后4个键。但是,如果您的原始数据集已经排序,如果您使用具有少量样本的高频率,则可能会发生这种情况(并且边界分布可能会很差)。

blog post有很多关于采样和TotalOrderPartitioning的详细信息。