def _read_page(file_obj, page_header, column_metadata):
 bytes_from_file = file_obj.read(page_header.compressed_page_size)
 codec = column_metadata.codec
 if ((codec is not None) and (codec != parquet_thrift.CompressionCodec.UNCOMPRESSED)):
  if (column_metadata.codec == parquet_thrift.CompressionCodec.SNAPPY):
   raw_bytes = snappy.decompress(bytes_from_file)
  elif (column_metadata.codec == parquet_thrift.CompressionCodec.GZIP):
   io_obj = io.BytesIO(bytes_from_file)
   with gzip.GzipFile(fileobj=io_obj, mode=u'rb') as file_data:
    raw_bytes = file_data.read()
  else:
   raise ParquetFormatException(u'Unsupported Codec: {0}'.format(codec))
 else:
  raw_bytes = bytes_from_file
 if logger.isEnabledFor(logging.DEBUG):
  logger.debug(u'Read page with compression type %s. Bytes %d -> %d', _get_name(parquet_thrift.CompressionCodec, codec), page_header.compressed_page_size, page_header.uncompressed_page_size)
 assert (len(raw_bytes) == page_header.uncompressed_page_size), u'found {0} raw bytes (expected {1})'.format(len(raw_bytes), page_header.uncompressed_page_size)
 return raw_bytes

def _read_page ( file_obj , page_header , column_metadata ) : bytes_from_file = file_obj . read ( page_header . compressed_page_size ) codec = column_metadata . codec if ( ( codec is not None ) and ( codec != parquet_thrift . CompressionCodec . UNCOMPRESSED ) ) : if ( column_metadata . codec == parquet_thrift . CompressionCodec . SNAPPY ) : raw_bytes = snappy . decompress ( bytes_from_file ) elif ( column_metadata . codec == parquet_thrift . CompressionCodec . GZIP ) : io_obj = io . BytesIO ( bytes_from_file ) with gzip . GzipFile ( fileobj = io_obj , mode = u'rb' ) as file_data : raw_bytes = file_data . read ( ) else : raise ParquetFormatException ( u'Unsupported Codec: {0}' . format ( codec ) ) else : raw_bytes = bytes_from_file if logger . isEnabledFor ( logging . DEBUG ) : logger . debug ( u'Read page with compression type %s. Bytes %d -> %d' , _get_name ( parquet_thrift . CompressionCodec , codec ) , page_header . compressed_page_size , page_header . uncompressed_page_size ) assert ( len ( raw_bytes ) == page_header . uncompressed_page_size ) , u'found {0} raw bytes (expected {1})' . format ( len ( raw_bytes ) , page_header . uncompressed_page_size ) return raw_bytes
read the data page from the given file-object and convert it to raw .