本文整理汇总了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
示例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)
示例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)])
示例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)
示例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)