Ejemplo n.º 1
0
 def close(self):
     if not self.__bClose:
         lz4f.freeDecompContext(self.__ctx)
         self.file.close()
         self.__ctx = None
         self.__file = None
         self.__bClose = True
         self.__frames = None
Ejemplo n.º 2
0
 def close(self):
     if not self.__bClose:
         lz4f.freeDecompContext(self.__ctx)
         self.file.close()
         self.__ctx = None
         self.__file = None
         self.__bClose = True
         self.__frames = None
Ejemplo n.º 3
0
def lz4f_decode(payload):
    """Decode payload using interoperable LZ4 framing. Requires Kafka >= 0.10"""
    # pylint: disable-msg=no-member
    ctx = lz4f.createDecompContext()
    data = lz4f.decompressFrame(payload, ctx)
    lz4f.freeDecompContext(ctx)

    # lz4f python module does not expose how much of the payload was
    # actually read if the decompression was only partial.
    if data['next'] != 0:
        raise RuntimeError('lz4f unable to decompress full payload')
    return data['decomp']
Ejemplo n.º 4
0
def lz4f_decode(payload):
    """Decode payload using interoperable LZ4 framing. Requires Kafka >= 0.10"""
    # pylint: disable-msg=no-member
    ctx = lz4f.createDecompContext()
    data = lz4f.decompressFrame(payload, ctx)
    lz4f.freeDecompContext(ctx)

    # lz4f python module does not expose how much of the payload was
    # actually read if the decompression was only partial.
    if data['next'] != 0:
        raise RuntimeError('lz4f unable to decompress full payload')
    return data['decomp']
Ejemplo n.º 5
0
 def _regenDCTX(self):
     """
     Regenerate the decompression context.
     """
     try:
         lz4f.freeDecompContext(self.dCtx)
         del self.dCtx
         self.dCtx = lz4f.createDecompContext()
         frameInfo = lz4f.getFrameInfo(self.header, self.dCtx)
         lz4f.disableChecksum(self.dCtx)
     except AttributeError:
         self.dCtx = lz4f.createDecompContext()
         frameInfo = lz4f.getFrameInfo(self.header, self.dCtx)
         pass
     del frameInfo
Ejemplo n.º 6
0
 def _regenDCTX(self):
     """
     Regenerate the decompression context.
     """
     try:
         lz4f.freeDecompContext(self.dCtx)
         del self.dCtx
         self.dCtx = lz4f.createDecompContext()
         frameInfo = lz4f.getFrameInfo(self.header, self.dCtx)
         lz4f.disableChecksum(self.dCtx)
     except AttributeError:
         self.dCtx = lz4f.createDecompContext()
         frameInfo = lz4f.getFrameInfo(self.header, self.dCtx)
         pass
     del frameInfo