本文整理匯總了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)