File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -333,7 +333,7 @@ def hadoop_stream_decompress(
333333 break
334334 buf = c .decompress (data )
335335 if buf :
336- dst .write ()
336+ dst .write (buf )
337337 dst .flush ()
338338
339339
@@ -349,7 +349,7 @@ def hadoop_stream_compress(
349349 break
350350 buf = c .compress (data )
351351 if buf :
352- dst .write ()
352+ dst .write (buf )
353353 dst .flush ()
354354
355355
Original file line number Diff line number Diff line change @@ -53,8 +53,9 @@ def uvarint(fin):
5353 return result
5454
5555
56- def check_unframed_format (fin ):
57- fin .seek (0 )
56+ def check_unframed_format (fin , reset = False ):
57+ if reset :
58+ fin .seek (0 )
5859 try :
5960 size = uvarint (fin )
6061 assert size < 2 ** 32 - 1
@@ -87,7 +88,7 @@ def guess_format_by_header(fin):
8788 form = "framed"
8889 elif HadoopStreamDecompressor .check_format (fin ):
8990 form = "hadoop"
90- elif check_unframed_format (fin ):
91+ elif check_unframed_format (fin , reset = True ):
9192 form = "raw"
9293 else :
9394 raise UncompressError ("Can't detect format" )
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ def runTest(self):
2020 decompress_func = formats .get_decompress_function (
2121 self .decompress_format , compressed_stream
2222 )
23+ compressed_stream .seek (0 )
2324 decompressed_stream = io .BytesIO ()
2425 decompress_func (
2526 compressed_stream ,
@@ -47,6 +48,30 @@ class TestFormatAutoFraming(TestFormatBase):
4748 success = True
4849
4950
51+ class TestFormatHadoop (TestFormatBase ):
52+ compress_format = "hadoop"
53+ decompress_format = "hadoop"
54+ success = True
55+
56+
57+ class TestFormatRaw (TestFormatBase ):
58+ compress_format = "raw"
59+ decompress_format = "raw"
60+ success = True
61+
62+
63+ class TestFormatHadoopAuto (TestFormatBase ):
64+ compress_format = "hadoop"
65+ decompress_format = "auto"
66+ success = True
67+
68+
69+ class TestFormatRawAuto (TestFormatBase ):
70+ compress_format = "raw"
71+ decompress_format = "auto"
72+ success = True
73+
74+
5075if __name__ == "__main__" :
5176 import unittest
5277 unittest .main ()
You can’t perform that action at this time.
0 commit comments