engine.py 文件源码

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

项目:cyphon 作者: dunbarcyber 项目源码 文件源码
def _create_unique_index(self):
        """Create an index based on raw data reference fields.

        Creates a compound index on the fields that contain the location
        of the raw data from which a document was derived. This prevents
        duplicate documents from being saved.
        """
        data_key = _DISTILLERY_SETTINGS['RAW_DATA_KEY']

        fields = [
            'BACKEND_KEY',
            'WAREHOUSE_KEY',
            'COLLECTION_KEY',
            'DOC_ID_KEY'
        ]
        keys = ['%s.%s' % (data_key, _DISTILLERY_SETTINGS[field])
                for field in fields]
        formatted_keys = [(key, pymongo.ASCENDING) for key in keys]
        return self._collection.create_index(formatted_keys, unique=True,
                                             sparse=True)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号