当前位置: 首页>>代码示例>>Python>>正文


Python pymongo.HASHED属性代码示例

本文整理汇总了Python中pymongo.HASHED属性的典型用法代码示例。如果您正苦于以下问题:Python pymongo.HASHED属性的具体用法?Python pymongo.HASHED怎么用?Python pymongo.HASHED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在pymongo的用法示例。


在下文中一共展示了pymongo.HASHED属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _ensure_index

# 需要导入模块: import pymongo [as 别名]
# 或者: from pymongo import HASHED [as 别名]
def _ensure_index(collection):
        try:
            collection.create_index([('symbol', pymongo.HASHED)], background=True)
            # We keep it only for its uniqueness
            collection.create_index([('symbol', pymongo.ASCENDING),
                                     ('sha', pymongo.ASCENDING)], unique=True, background=True)
            # TODO: When/if we remove the segments->versions pointers implementation and keep only the forward pointers,
            #       we can remove the 'parent' from the index.
            collection.create_index([('symbol', pymongo.ASCENDING),
                                     ('parent', pymongo.ASCENDING),
                                     ('segment', pymongo.ASCENDING)], unique=True, background=True)
            # Used for efficient SHA-based read queries that have index ranges
            collection.create_index([('symbol', pymongo.ASCENDING),
                                     ('sha', pymongo.ASCENDING),
                                     ('segment', pymongo.ASCENDING)], unique=True, background=True)
        except OperationFailure as e:
            if "can't use unique indexes" in str(e):
                return
            raise 
开发者ID:man-group,项目名称:arctic,代码行数:21,代码来源:_ndarray_store.py

示例2: _ensure_index

# 需要导入模块: import pymongo [as 别名]
# 或者: from pymongo import HASHED [as 别名]
def _ensure_index(self):
        self._symbols.create_index([(SYMBOL, pymongo.ASCENDING)],
                                   unique=True,
                                   background=True)

        self._collection.create_index([(SYMBOL, pymongo.HASHED)],
                                      background=True)
        self._collection.create_index([(SYMBOL, pymongo.ASCENDING),
                                       (SHA, pymongo.ASCENDING)],
                                      unique=True,
                                      background=True)
        self._collection.create_index([(SYMBOL, pymongo.ASCENDING),
                                       (START, pymongo.ASCENDING),
                                       (END, pymongo.ASCENDING),
                                       (SEGMENT, pymongo.ASCENDING)],
                                      unique=True, background=True)
        self._collection.create_index([(SYMBOL, pymongo.ASCENDING),
                                       (START, pymongo.ASCENDING),
                                       (SEGMENT, pymongo.ASCENDING)],
                                      unique=True, background=True)
        self._collection.create_index([(SEGMENT, pymongo.ASCENDING)],
                                      unique=False, background=True)
        self._mdata.create_index([(SYMBOL, pymongo.ASCENDING),
                                  (START, pymongo.ASCENDING),
                                  (END, pymongo.ASCENDING)],
                                 unique=True, background=True) 
开发者ID:man-group,项目名称:arctic,代码行数:28,代码来源:chunkstore.py

示例3: init

# 需要导入模块: import pymongo [as 别名]
# 或者: from pymongo import HASHED [as 别名]
def init(dataset_name, create_index=True):
    # Connection to DB system
    global dbc
    dbc = MongoClient(C.db_location)
    # Configure right DB
    global database
    database = dbc[dataset_name]
    global modeldb
    modeldb = database.columns
    # Create full text search index
    if create_index:
        print("Creating full-text search index")
        modeldb.create_index([('t_data', TEXT)])
        modeldb.create_index([("key", HASHED)]) 
开发者ID:mitdbg,项目名称:aurum-datadiscovery,代码行数:16,代码来源:mongomodelstore.py

示例4: explicit_key

# 需要导入模块: import pymongo [as 别名]
# 或者: from pymongo import HASHED [as 别名]
def explicit_key(index):
    if isinstance(index, (list, tuple)):
        assert len(index) == 2, 'Must be a (`key`, `direction`) tuple'
        return index
    if index.startswith('+'):
        return (index[1:], ASCENDING)
    if index.startswith('-'):
        return (index[1:], DESCENDING)
    if index.startswith('$'):
        return (index[1:], TEXT)
    if index.startswith('#'):
        return (index[1:], HASHED)
    return (index, ASCENDING) 
开发者ID:Scille,项目名称:umongo,代码行数:15,代码来源:indexes.py

示例5: ensure_indexes

# 需要导入模块: import pymongo [as 别名]
# 或者: from pymongo import HASHED [as 别名]
def ensure_indexes(self):
        self.Blockchain.create_index('previous', unique=True)
        self.Blockchain.create_index('block_id', unique=True)
        self.Blockchain.create_index([('block_num', -1)])

        self.Accounts.create_index('name', unique=True)

        # Operations are using _id as unique index
        self.Operations.create_index([('type', 1), ('timestamp', -1)])
        self.Operations.create_index([('block_id', 1)])
        self.Operations.create_index([('type', 1)])
        self.Operations.create_index([('block_num', -1)])
        self.Operations.create_index([('timestamp', -1)])
        # partial indexes
        self.Operations.create_index([('author', 1), ('permlink', 1)], sparse=True, background=True)
        self.Operations.create_index([('to', 1)], sparse=True, background=True)
        self.Operations.create_index([('from', 1)], sparse=True, background=True)
        self.Operations.create_index([('memo', pymongo.HASHED)], sparse=True, background=True)

        # AccountOperations are using _id as unique index
        self.AccountOperations.create_index([('account', 1), ('type', 1), ('timestamp', -1)])
        self.AccountOperations.create_index([('account', 1), ('type', 1)])
        self.AccountOperations.create_index([('account', 1)])
        self.AccountOperations.create_index([('type', 1)])
        self.AccountOperations.create_index([('timestamp', -1)])
        self.AccountOperations.create_index([('index', -1)])

        self.Posts.create_index([('author', 1), ('permlink', 1)], unique=True)
        self.Posts.create_index([('identifier', 1)], unique=True)
        self.Posts.create_index([('author', 1)])
        self.Posts.create_index([('created', -1)])
        self.Posts.create_index([('json_metadata.app', 1)], background=True, sparse=True)
        self.Posts.create_index([('json_metadata.users', 1)], background=True, sparse=True)
        self.Posts.create_index([('json_metadata.tags', 1)], background=True, sparse=True)
        self.Posts.create_index([('json_metadata.community', 1)], background=True, sparse=True)
        self.Posts.create_index([('body', 'text'), ('title', 'text')], background=True)

        self.Comments.create_index([('identifier', 1)], unique=True)
        self.Comments.create_index([('parent_author', 1)])
        self.Comments.create_index([('parent_permlink', 1)])
        self.Comments.create_index([('author', 1)])
        self.Comments.create_index([('permlink', 1)])
        self.Comments.create_index([('created', -1)])
        self.Comments.create_index([('body', 'text'), ('title', 'text')], background=True)

        self.PriceHistory.create_index([('timestamp', -1)])

        # 4 jesta's tools
        self.Operations.create_index(
            [('producer', 1), ('type', 1), ('timestamp', 1)],
            sparse=True, background=True)
        self.Operations.create_index(
            [('curator', 1), ('type', 1), ('timestamp', 1)],
            sparse=True, background=True)
        self.Operations.create_index(
            [('benefactor', 1), ('type', 1), ('timestamp', 1)],
            sparse=True, background=True)
        self.Operations.create_index(
            [('author', 1), ('type', 1), ('timestamp', 1)],
            sparse=True, background=True) 
开发者ID:SteemData,项目名称:steemdata-mongo,代码行数:62,代码来源:mongostorage.py


注:本文中的pymongo.HASHED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。