linkage_entity.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:onefl-deduper 作者: ufbmi 项目源码 文件源码
def init_hash_uuid_lut(session, hashes):
        """
        From the list [x, y, z] of hashes return
        a dictionary which tells if a chunk was `linked` or not:
            {x: LinkageEntity, y: LinkageEntity, z: None}
        """
        # Note: unhexlify is necessary since the database stores
        # binary representations of the hashes
        bin_hashes = [binascii.unhexlify(ahash.encode('utf-8'))
                      for ahash in hashes]
        links = session.query(LinkageEntity).filter(
            LinkageEntity.linkage_hash.in_(bin_hashes)).all()
        links_cache = {link.friendly_hash(): link for link in links}

        lut = {}

        # Extra loop so we can provide an entry for hashes not found in the db
        for ahash in hashes:
            lut[ahash] = links_cache.get(ahash, None)

        return lut
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号