File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -150,10 +150,9 @@ def __init__(self):
150150
151151 @staticmethod
152152 def check_format (fin ):
153- """Checks that the given data starts with snappy framing format
154- stream identifier.
155- Raises UncompressError if it doesn't start with the identifier.
156- :return: None
153+ """Does this stream start with a stream header block?
154+
155+ True indicates that the stream can likely be decoded using this class.
157156 """
158157 try :
159158 return fin .read (len (_STREAM_HEADER_BLOCK )) == _STREAM_HEADER_BLOCK
@@ -227,9 +226,7 @@ def __init__(self):
227226
228227 @staticmethod
229228 def check_format (fin ):
230- """Checks that there are enough bytes for a hadoop header
231-
232- We cannot actually determine if the data is really hadoop-snappy
229+ """Does this look like a hadoop snappy stream?
233230 """
234231 try :
235232 from snappy .snappy_formats import check_unframed_format
Original file line number Diff line number Diff line change 4242
4343
4444def uvarint (fin ):
45+ """Read uint64 nbumber from varint encoding in a stream"""
4546 result = 0
4647 shift = 0
4748 while True :
@@ -54,6 +55,11 @@ def uvarint(fin):
5455
5556
5657def check_unframed_format (fin , reset = False ):
58+ """Can this be read using the raw codec
59+
60+ This function wil return True for all snappy raw streams, but
61+ True does not mean that we can necessarily decode the stream.
62+ """
5763 if reset :
5864 fin .seek (0 )
5965 try :
@@ -81,8 +87,8 @@ def check_unframed_format(fin, reset=False):
8187def guess_format_by_header (fin ):
8288 """Tries to guess a compression format for the given input file by it's
8389 header.
84- :return: tuple of decompression method and a chunk that was taken from the
85- input for format detection.
90+
91+ :return: format name (str), stream decompress function (callable)
8692 """
8793 if StreamDecompressor .check_format (fin ):
8894 form = "framed"
You can’t perform that action at this time.
0 commit comments