How to use the lz4.loads function in lz4

To help you get started, we’ve selected a few lz4 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github summertriangle-dev / starlight_sync / View on Github external
def get_resource(url, asset_name, flags):
    resp = SESSION.get(url)

    buf = resp.content
    if flags & 1:
        bio = io.BytesIO()
        buf = lz4.loads(bio.getvalue())

    return buf
github summertriangle-dev / starlight_sync / View on Github external
for selector in mp:
        if selector.platform == platform and \
           selector.asset_qual == asset_qual and \
           selector.sound_qual == sound_qual:
            get_file = selector.filename

    abso = "/".join(( DBMANIFEST.format(version), get_file ))
    resp = SESSION.get(abso)

    buf = resp.content
    bio = io.BytesIO()
    data = lz4.loads(bio.getvalue())
    with open(dest_file, "wb") as write_db:

    return dest_file
github cctbx / cctbx_project / dxtbx / format / View on Github external
def readLZ4(self, data, shape, dtype, size):
    Unpack lz4 compressed frame and return np array image data

    import numpy as np
    import lz4, bitshuffle

    dtype = np.dtype(dtype)
    data = lz4.loads(data)

    return np.reshape(np.fromstring(data, dtype=dtype), shape[::-1])
github oleiade / py-elevator / pyelevator / View on Github external
def __init__(self, raw_message, *args, **kwargs):
        compression = kwargs.pop('compression', False)
        raw_message = lz4.loads(raw_message) if compression else raw_message
        message = msgpack.unpackb(raw_message)

            self.datas = message['datas']
        except KeyError:
            errors_logger.exception("Invalid response message : %s" %
            raise MessageFormatError("Invalid response message")
github keitaroyam / yamtbx / yamtbx / dataproc / View on Github external
for i in (1,3,4): header.update(json.loads(frames[i].bytes))

    if header.get("bss_job_mode", 4) != bss_job_mode:
        return None, None

    dtype = header["type"]
    shape = header["shape"][::-1]

    if dtype in ("int32","uint32"): byte = 4
    elif dtype in ("int16","uint16"): byte = 2
    else: raise RuntimeError("Unknown dtype (%s)"%dtype)

    size = byte*shape[0]*shape[1]

    if header["encoding"] == "lz4<":
        data = lz4.loads(struct.pack('u4", buffer=data[8:12])/4
        data = bitshuffle.decompress_lz4(blob, shape, numpy.dtype(dtype), blocksize)
        data = data.reshape(shape)
    elif header["encoding"] == "bs16-lz4<":
        data = frames[2].bytes
        blob = numpy.fromstring(data[12:],dtype=numpy.uint8)
        data = bitshuffle.decompress_lz4(blob, shape, numpy.dtype(dtype))
        data = data.reshape(shape)
        RuntimeError("Unknown encoding (%s)"%header["encoding"])