本文整理汇总了Python中pycassa.index.create_index_clause函数的典型用法代码示例。如果您正苦于以下问题:Python create_index_clause函数的具体用法?Python create_index_clause怎么用?Python create_index_clause使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_index_clause函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_indexed_slices_batching
def test_get_indexed_slices_batching(self):
indexed_cf = ColumnFamily(self.client, 'Indexed1')
columns = {'birthdate': 1L}
for i in range(200):
indexed_cf.insert('key%d' % i, columns)
expr = index.create_index_expression(column_name='birthdate', value=1L)
clause = index.create_index_clause([expr], count=10)
result = list(indexed_cf.get_indexed_slices(clause, buffer_size=2))
assert_equal(len(result), 10)
result = list(indexed_cf.get_indexed_slices(clause, buffer_size=10))
assert_equal(len(result), 10)
result = list(indexed_cf.get_indexed_slices(clause, buffer_size=77))
assert_equal(len(result), 10)
result = list(indexed_cf.get_indexed_slices(clause, buffer_size=200))
assert_equal(len(result), 10)
result = list(indexed_cf.get_indexed_slices(clause, buffer_size=1000))
assert_equal(len(result), 10)
clause = index.create_index_clause([expr], count=250)
result = list(indexed_cf.get_indexed_slices(clause, buffer_size=2))
assert_equal(len(result), 200)
result = list(indexed_cf.get_indexed_slices(clause, buffer_size=10))
assert_equal(len(result), 200)
result = list(indexed_cf.get_indexed_slices(clause, buffer_size=77))
assert_equal(len(result), 200)
result = list(indexed_cf.get_indexed_slices(clause, buffer_size=200))
assert_equal(len(result), 200)
result = list(indexed_cf.get_indexed_slices(clause, buffer_size=1000))
assert_equal(len(result), 200)
示例2: queue_list
def queue_list(self, application_name, limit=100, offset=None):
"""Return list of queues"""
cl = self.cl or LOCAL_QUORUM if self.multi_dc else QUORUM
app_expr = create_index_expression('application', application_name)
if offset:
offset = '%s:%s' % (application_name, offset)
clause = create_index_clause([app_expr], start_key=offset,
count=limit)
else:
clause = create_index_clause([app_expr], count=limit)
results = self.queue_fam.get_indexed_slices(
clause, columns=['application'], read_consistency_level=cl)
# Pull off the application name in front
app_len = len(application_name) + 1
return [key[app_len:] for key, _ in results]
示例3: test_insert_get_indexed_slices
def test_insert_get_indexed_slices(self):
instance1 = TestIndex()
instance1.key = 'key1'
instance1.birthdate = 1L
self.indexed_map.insert(instance1)
instance2 = TestIndex()
instance2.key = 'key2'
instance2.birthdate = 1L
self.indexed_map.insert(instance2)
instance3 = TestIndex()
instance3.key = 'key3'
instance3.birthdate = 2L
self.indexed_map.insert(instance3)
expr = index.create_index_expression(column_name='birthdate', value=2L)
clause = index.create_index_clause([expr])
result = self.indexed_map.get_indexed_slices(index_clause=clause)
count = 0
for instance in result:
assert_equal(instance, instance3)
count += 1
assert_equal(count, 1)
示例4: fetch
def fetch(self, model, specs, number):
expressions = []
for spec in specs:
if isinstance(spec.value_spec, EQ):
expressions.push(
create_index_expression(spec.attr, spec.value_spec.value))
elif isinstance(spec.value_spec, GT):
expressions.push(create_index_expression(
spec.attr, spec.value_spec.value, index.GT))
elif isinstance(spec.value_spec, LT):
expressions.push(create_index_expression(
spec.attr, spec.value_spec.value, index.LT))
elif isinstance(spec.value_spec, GTE):
expressions.push(create_index_expression(
spec.attr, spec.value_spec.value, index.GTE))
elif isinstance(spec.value_spec, LTE):
expressions.push(create_index_expression(
spec.attr, spec.value_spec.value, index.LTE))
cfm = ColumnFamilyMap(model, pool, model.cf_name)
clause = create_index_clause([state_expr, bday_expr], count=number)
def value_only(lst):
values = []
for key, value in lst:
values.push(value)
return values
return value_only(cfm.get_indexed_slices(clause))
示例5: test_insert_get_indexed_slices
def test_insert_get_indexed_slices(self):
instance1 = TestIndex()
instance1.key = 'key1'
instance1.birthdate = 1L
self.indexed_map.insert(instance1)
instance2 = TestIndex()
instance2.key = 'key2'
instance2.birthdate = 1L
self.indexed_map.insert(instance2)
instance3 = TestIndex()
instance3.key = 'key3'
instance3.birthdate = 2L
self.indexed_map.insert(instance3)
expr = index.create_index_expression(column_name='birthdate', value=2L)
clause = index.create_index_clause([expr])
# test with passing an instance
result = self.indexed_map.get_indexed_slices(instance1, index_clause=clause)
assert_equal(len(result), 2)
assert_equal(result.get('key1'), instance1)
assert_equal(result.get('key2'), instance2)
# test without passing an instance
result = self.indexed_map.get_indexed_slices(index_clause=clause)
assert_equal(len(result), 1)
assert_equal(result.get('key3'), instance3)
示例6: get_user_by_nick
def get_user_by_nick(self, user_nick):
nick_expression = create_index_expression('nick', user_nick)
clause = create_index_clause([nick_expression], count=1)
user_dict = None
for key, user in user_cf.get_indexed_slices(clause):
user_dict = msgpack.unpackb(zlib.decompress(user.get("data")))
return user_dict
示例7: authenticatorlist_get_id
def authenticatorlist_get_id(self,key):
global pool
ret = None
authenticatorlist = ColumnFamily(pool,'authenticators_info')
expr = create_index_expression('token_id',key)
clause = create_index_clause([expr])
result = authenticatorlist.get_indexed_slices(clause)
for keyx,columnx in result:
ret = keyx
return ret
示例8: authenticator_get_token_id
def authenticator_get_token_id(self,key):
# if provided a column value key, get this token id
global pool
ret = None
authenticator = ColumnFamily(pool,'authenticator')
expr = create_index_expression('atoken',key)
clause = create_index_clause([expr])
result = authenticator.get_indexed_slices(clause)
for keyx,columnx in result:
ret = keyx
return ret
示例9: network_get_id_viaSession
def network_get_id_viaSession(self,key):
# if provided a column value key, get this token id
global pool
ret = None
network = ColumnFamily(pool,'network_info')
expr = create_index_expression('session_id',key)
clause = create_index_clause([expr])
result = network.get_indexed_slices(clause)
for keyx,columnx in result:
ret = keyx
return ret
示例10: handle_get_id_viaNetwork
def handle_get_id_viaNetwork(self,key):
# if provided a column value key, get this token id
global pool
ret = None
token = ColumnFamily(pool,'handle')
expr = create_index_expression('network_item_id',key)
clause = create_index_clause([expr])
result = token.get_indexed_slices(clause)
for keyx,columnx in result:
ret = keyx
return ret
示例11: get_nodes_by_attr
def get_nodes_by_attr(self, type, attrs={}, expressions=None, start_key="", row_count=2147483647, **kwargs):
if expressions is None:
expressions = []
for attr, value in self.serialize_columns(attrs).items():
expressions.append(index.create_index_expression(attr, value))
clause = index.create_index_clause(expressions, start_key=start_key, count=row_count)
try:
column_family = self.delegate.get_cf(type)
rows = column_family.get_indexed_slices(clause, **kwargs)
except NotFoundException:
raise NodeNotFoundException()
return [prim.Node(self, type, key, self.deserialize_value(values)) for key, values in rows]
示例12: test_get_indexed_slices
def test_get_indexed_slices(self):
sys = SystemManager()
for cf, keys in self.type_groups:
sys.create_index(TEST_KS, cf.column_family, 'birthdate', LongType())
cf = ColumnFamily(pool, cf.column_family)
for key in keys:
cf.insert(key, {'birthdate': 1})
expr = create_index_expression('birthdate', 1)
clause = create_index_clause([expr])
rows = list(cf.get_indexed_slices(clause))
assert_equal(len(rows), len(keys))
for k, c in rows:
assert_true(k in keys)
assert_equal(c, {'birthdate': 1})
示例13: test_insert_get_indexed_slices
def test_insert_get_indexed_slices(self):
instance = TestIndex()
instance.key = 'key'
instance.birthdate = 1L
self.indexed_map.insert(instance)
instance.key = 'key2'
self.indexed_map.insert(instance)
instance.key = 'key3'
self.indexed_map.insert(instance)
expr = index.create_index_expression(column_name='birthdate', value=1L)
clause = index.create_index_clause([expr])
result = self.indexed_map.get_indexed_slices(instance, index_clause=clause)
assert_equal(len(result), 3)
assert_equal(result.get('key3'), instance)
示例14: insert_insert_get_indexed_slices
def insert_insert_get_indexed_slices(self):
indexed_cf = ColumnFamily(self.client, 'Indexed1')
columns = {'birthdate': 1L}
keys = []
for i in range(1,4):
indexed_cf.insert('key%d' % i, columns)
keys.append('key%d')
expr = index.create_index_expression(column_name='birthdate', value=1L)
clause = index.create_index_clause([expr])
count = 0
for key,cols in indexed_cf.get_indexed_slices(clause):
assert cols == columns
assert key in keys
count += 1
assert_equal(count, 3)
示例15: insert_insert_get_indexed_slices
def insert_insert_get_indexed_slices(self):
indexed_cf = ColumnFamily(pool, "Indexed1")
columns = {"birthdate": 1L}
keys = []
for i in range(1, 4):
indexed_cf.insert("key%d" % i, columns)
keys.append("key%d")
expr = index.create_index_expression(column_name="birthdate", value=1L)
clause = index.create_index_clause([expr])
count = 0
for key, cols in indexed_cf.get_indexed_slices(clause):
assert_equal(cols, columns)
assert key in keys
count += 1
assert_equal(count, 3)