def test_record_reader_from_cpluplus(self): d = { 'input_key': 'inputkey', 'input_value': 'inputvalue', 'input_split': 'inputsplit', 'input_key_class': 'keyclass', 'input_value_class': 'valueclass', 'job_conf': {} } ctx = pp.get_MapContext_object(d) self.assertEqual(ctx.getInputKey(), d['input_key']) self.assertEqual(ctx.getInputValue(), d['input_value']) self.assertEqual(ctx.getInputSplit(), d['input_split']) self.assertEqual(ctx.getInputKeyClass(), d['input_key_class']) self.assertEqual(ctx.getInputValueClass(), d['input_value_class']) f = Factory(None, None, test_record_reader) rr = f.createRecordReader(ctx) for i in range(test_record_reader.NUMBER_RECORDS): (f, k, v) = pp.get_record_from_record_reader(rr) self.assertTrue(f) self.assertEqual(k, test_record_reader.KEY_FORMAT % (i + 1)) self.assertEqual(v, test_record_reader.DEFAULT_VALUE) self.assertAlmostEqual( pp.get_progress_from_record_reader(rr), float(i + 1) / test_record_reader.NUMBER_RECORDS) (f, k, v) = pp.get_record_from_record_reader(rr) self.assertFalse(f)
def test_factory_costructor(self): f = Factory(mapper, reducer) self.failUnless(isinstance(f.createMapper(self.m_ctx), mapper)) self.failUnless(isinstance(f.createReducer(self.r_ctx), reducer)) #-- f = Factory(mapper, reducer, record_reader) self.failUnless(isinstance(f.createMapper(self.m_ctx), mapper)) self.failUnless(isinstance(f.createReducer(self.r_ctx), reducer)) self.failUnless(isinstance(f.createRecordReader(self.m_ctx), record_reader))
def test_factory_costructor(self): f = Factory(mapper, reducer) self.failUnless(isinstance(f.createMapper(self.m_ctx), mapper)) self.failUnless(isinstance(f.createReducer(self.r_ctx), reducer)) #-- f = Factory(mapper, reducer, record_reader) self.failUnless(isinstance(f.createMapper(self.m_ctx), mapper)) self.failUnless(isinstance(f.createReducer(self.r_ctx), reducer)) self.failUnless( isinstance(f.createRecordReader(self.m_ctx), record_reader))
def test_record_reader_from_cpluplus(self): d = {'input_key' : 'inputkey', 'input_value' : 'inputvalue', 'input_split' : 'inputsplit', 'input_key_class' : 'keyclass', 'input_value_class' : 'valueclass', 'job_conf' : {}} ctx = pp.get_MapContext_object(d) self.assertEqual(ctx.getInputKey(), d['input_key']) self.assertEqual(ctx.getInputValue(), d['input_value']) self.assertEqual(ctx.getInputSplit(), d['input_split']) self.assertEqual(ctx.getInputKeyClass(), d['input_key_class']) self.assertEqual(ctx.getInputValueClass(), d['input_value_class']) f = Factory(None, None, test_record_reader) rr = f.createRecordReader(ctx) for i in range(test_record_reader.NUMBER_RECORDS): (f, k, v) = pp.get_record_from_record_reader(rr) self.assertTrue(f) self.assertEqual(k, test_record_reader.KEY_FORMAT % (i+1)) self.assertEqual(v, test_record_reader.DEFAULT_VALUE) self.assertAlmostEqual(pp.get_progress_from_record_reader(rr), float(i+1)/test_record_reader.NUMBER_RECORDS) (f, k, v) = pp.get_record_from_record_reader(rr) self.assertFalse(f)