コード例 #1
0
    def test_stopiteration_is_raised(self):
        def stopit(*args, **kwargs):
            raise StopIteration()

        def legit_create_combiner(x):
            return [x]

        def legit_merge_value(x, y):
            return x.append(y) or x

        def legit_merge_combiners(x, y):
            return x.extend(y) or x

        data = [(x % 2, x) for x in range(100)]

        # wrong create combiner
        m = ExternalMerger(
            Aggregator(stopit, legit_merge_value, legit_merge_combiners), 20)
        with self.assertRaises((Py4JJavaError, RuntimeError)) as cm:
            m.mergeValues(data)

        # wrong merge value
        m = ExternalMerger(
            Aggregator(legit_create_combiner, stopit, legit_merge_combiners),
            20)
        with self.assertRaises((Py4JJavaError, RuntimeError)) as cm:
            m.mergeValues(data)

        # wrong merge combiners
        m = ExternalMerger(
            Aggregator(legit_create_combiner, legit_merge_value, stopit), 20)
        with self.assertRaises((Py4JJavaError, RuntimeError)) as cm:
            m.mergeCombiners(map(lambda x_y1: (x_y1[0], [x_y1[1]]), data))
コード例 #2
0
ファイル: tests.py プロジェクト: joyyoj/spark
 def setUp(self):
     self.N = 1 << 16
     self.l = [i for i in xrange(self.N)]
     self.data = zip(self.l, self.l)
     self.agg = Aggregator(lambda x: [x], 
             lambda x, y: x.append(y) or x,
             lambda x, y: x.extend(y) or x)
コード例 #3
0
    def setUp(self):
        self.N = 1 << 20
        values = [i for i in range(self.N)]
        keys = [i for i in range(2)]
        import itertools

        self.data = [value for value in itertools.product(keys, values)]
        self.agg = Aggregator(lambda x: [x], lambda x, y: x.append(y) or x,
                              lambda x, y: x.extend(y) or x)
コード例 #4
0
ファイル: test_shuffle.py プロジェクト: yliou/spark
 def setUp(self):
     self.N = 1 << 12
     self.lst = [i for i in range(self.N)]
     self.data = list(zip(self.lst, self.lst))
     self.agg = Aggregator(lambda x: [x], lambda x, y: x.append(y) or x,
                           lambda x, y: x.extend(y) or x)