public
Description: Support libraries for writing Hadoop Streaming-compatible map/reduce tasks.
Clone URL: git://github.com/codahale/hadoop-streaming.git
Add a full test suite (why isn't that auto-discovered?) and make the 
parsers default to parsing stdin.
codahale (author)
Sat Mar 22 21:38:41 -0700 2008
commit  f0815253fa53c5e531a4d3dab1170983e036ef9c
tree    792ae7e73d03142e804119d44fa573c17ccc8fac
parent  ab0eb14aa4e9f97cc0f8acfd8cb5f2b479a68ef8
...
1
2
3
 
4
5
6
...
12
13
14
15
 
16
17
18
...
1
2
3
4
5
6
7
...
13
14
15
 
16
17
18
19
0
@@ -1,6 +1,7 @@
0
 """
0
   Input parsers for Hadoop tasks.
0
 """
0
+from sys import stdin
0
 from itertools import imap
0
 
0
 class LineParser(object):
0
@@ -12,7 +13,7 @@ class LineParser(object):
0
     >>> lines = [line for line in p]
0
     ['blah', 'blee', 'blorg']
0
   """
0
- def __init__(self, iterable):
0
+ def __init__(self, iterable=stdin):
0
     """
0
       Creates a new LineParser instance which will iterate over the provided
0
       iterable.
...
14
15
16
17
 
18
19
20
...
22
23
24
25
 
26
27
28
29
30
31
 
 
 
32
33
34
...
14
15
16
 
17
18
19
20
...
22
23
24
 
25
26
27
28
29
30
31
32
33
34
35
36
37
0
@@ -14,7 +14,7 @@ class ParserTests(unittest.TestCase):
0
   
0
   @test
0
   def line_parser_should_parse_single_lines(self):
0
- p = LineParser(self.fixture)
0
+ p = LineParser(iterable=self.fixture)
0
     result = [l for l in p]
0
     self.assertEqual(2, len(result))
0
     self.assertEqual('one\ttwo\tthree', result[0])
0
@@ -22,12 +22,15 @@ class ParserTests(unittest.TestCase):
0
   
0
   @test
0
   def tsv_parser_should_parse_tuples(self):
0
- p = TSVParser(self.fixture)
0
+ p = TSVParser(iterable=self.fixture)
0
     result = [l for l in p]
0
     self.assertEqual(2, len(result))
0
     self.assertEqual(('one', ('two', 'three')), result[0])
0
     self.assertEqual(('four', ('five', 'six')), result[1])
0
   
0
 
0
+def suite():
0
+ return unittest.makeSuite(ParserTests)
0
+
0
 if __name__ == '__main__':
0
   unittest.main()
0
\ No newline at end of file

Comments

    No one has commented yet.