o
    uy‚iØ
  ã                   @  sv   d dl mZ d dlZd dlZd dlmZ e d¡Zzd dlZG dd„ deƒZ	W dS  e
y:   G dd„ deƒZ	Y dS w )é    )ÚannotationsN)ÚCodecz>Ic                   @  s6   e Zd Zeddd„ƒZedd
d„ƒZeddd„ƒZdS )ÚSnappyCodecÚbytes_ÚbytesÚchecksumÚreturnÚNonec                 C  s(   t  | ¡d@ t |¡d krtdƒ‚dS )aJ  Incrementally compute CRC-32 from bytes and compare to a checksum.

            Args:
              bytes_ (bytes): The bytes to check against `checksum`
              checksum (bytes): Byte representation of a checksum

            Raises:
              ValueError: If the computed CRC-32 does not match the checksum
            ì   ÿÿ r   zChecksum failureN)ÚbinasciiÚcrc32ÚSTRUCT_CRC32ÚunpackÚ
ValueError)r   r   © r   úe/home/ubuntu/maya3_transcribe/venv/lib/python3.10/site-packages/pyiceberg/avro/codecs/snappy_codec.pyÚ_check_crc32   s   ÿzSnappyCodec._check_crc32Údataútuple[bytes, int]c                 C  s.   t  | ¡}|t t | ¡d@ ¡7 }|t|ƒfS )Nr
   )ÚsnappyÚcompressr   Úpackr   r   Úlen)r   Úcompressed_datar   r   r   r   ,   s   
úSnappyCodec.compressc                 C  s2   | dd … }| dd… } t  | ¡}t ||¡ |S )Néüÿÿÿr   )r   Ú
decompressr   r   )r   r   Úuncompressedr   r   r   r   3   s
   
úSnappyCodec.decompressN)r   r   r   r   r   r	   ©r   r   r   r   ©r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ústaticmethodr   r   r   r   r   r   r   r      s    r   c                   @  s(   e Zd Zed
dd„ƒZeddd„ƒZd	S )r   r   r   r   r   c                 C  ó   t dƒ‚©NzRSnappy support not installed, please install using `pip install pyiceberg[snappy]`©ÚImportError©r   r   r   r   r   ?   ó   r   c                 C  r%   r&   r'   r)   r   r   r   r   C   r*   r   Nr   r    )r!   r"   r#   r$   r   r   r   r   r   r   r   >   s
    )Ú
__future__r   r   ÚstructÚpyiceberg.avro.codecs.codecr   ÚStructr   r   r   r(   r   r   r   r   Ú<module>   s   
þ