o
    <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   _/home/ubuntu/veenaModal/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 )Nr   )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   
