本文整理汇总了Python中pycassa.columnfamily.ColumnFamily.column_name_class方法的典型用法代码示例。如果您正苦于以下问题:Python ColumnFamily.column_name_class方法的具体用法?Python ColumnFamily.column_name_class怎么用?Python ColumnFamily.column_name_class使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycassa.columnfamily.ColumnFamily
的用法示例。
在下文中一共展示了ColumnFamily.column_name_class方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_retrieve_with_custom_composite
# 需要导入模块: from pycassa.columnfamily import ColumnFamily [as 别名]
# 或者: from pycassa.columnfamily.ColumnFamily import column_name_class [as 别名]
def test_retrieve_with_custom_composite(self):
cf_std = ColumnFamily(pool, "CustomComposite1")
cf_cust = ColumnFamily(pool, "CustomComposite1")
cf_cust.column_name_class = CompositeType(TestCustomComposite.IntDateType(), TestCustomComposite.IntString())
std_col = (20120312, "321")
cust_col = (date(2012, 3, 12), 321)
cf_std.insert("cust_insert_key_2", {std_col: "cust_insert_val_2"})
assert_equal(cf_cust.get("cust_insert_key_2"), {cust_col: "cust_insert_val_2"})
示例2: test_insert_with_custom_composite
# 需要导入模块: from pycassa.columnfamily import ColumnFamily [as 别名]
# 或者: from pycassa.columnfamily.ColumnFamily import column_name_class [as 别名]
def test_insert_with_custom_composite(self):
cf_std = ColumnFamily(pool, 'CustomComposite1')
cf_cust = ColumnFamily(pool, 'CustomComposite1')
cf_cust.column_name_class = CompositeType(
TestCustomComposite.IntDateType(),
TestCustomComposite.IntString())
std_col = (20120311, '321')
cust_col = (date(2012, 3, 11), 321)
cf_cust.insert('cust_insert_key_1', {cust_col: 'cust_insert_val_1'})
assert_equal(cf_std.get('cust_insert_key_1'),
{std_col: 'cust_insert_val_1'})
示例3: test_composite_slicing
# 需要导入模块: from pycassa.columnfamily import ColumnFamily [as 别名]
# 或者: from pycassa.columnfamily.ColumnFamily import column_name_class [as 别名]
def test_composite_slicing(self):
cf_std = ColumnFamily(pool, 'CustomComposite1')
cf_cust = ColumnFamily(pool, 'CustomComposite1')
cf_cust.column_name_class = CompositeType(
TestCustomComposite.IntDateType(),
TestCustomComposite.IntString2())
col0 = (20120101, '123')
col1 = (20120102, '123')
col2 = (20120102, '456')
col3 = (20120102, '789')
col4 = (20120103, '123')
dt0 = date(2012, 1, 1)
dt1 = date(2012, 1, 2)
dt2 = date(2012, 1, 3)
col0_cust = (dt0, 123)
col1_cust = (dt1, 123)
col2_cust = (dt1, 456)
col3_cust = (dt1, 789)
col4_cust = (dt2, 123)
cf_std.insert('key2', {col0: '', col1: '', col2: '', col3: '', col4: ''})
def check(column_start, column_finish, col_reversed=False):
result = cf_cust.get('key2', column_start=column_start,
column_finish=column_finish, column_reversed=col_reversed)
assert_equal(result, {col1_cust: '', col2_cust: '', col3_cust: ''})
# Defaults should be inclusive on both ends
check((dt1,), (dt1,))
check((dt1,), (dt1,), True)
check(((dt1, True),), ((dt1, True),))
check((dt1,), ((dt2, False),))
check(((dt1, True),), ((dt2, False),))
check(((dt0, False),), ((dt2, False),))
check((dt1, 123), (dt1, 789))
check((dt1, 123), (dt1, (789, True)))
check((dt1, (123, True)), ((dt2, False),))
# Test inclusive ends for reversed
check(((dt1, True),), ((dt1, True),), True)
check( (dt1,), ((dt1, True),), True)
check(((dt1, True),), (dt1,), True)
# Test exclusive ends for reversed
check(((dt2, False),), ((dt0, False),), True)
check(((dt2, False),), (dt1,), True)
check((dt1,), ((dt0, False),), True)
示例4: test_composite_slicing
# 需要导入模块: from pycassa.columnfamily import ColumnFamily [as 别名]
# 或者: from pycassa.columnfamily.ColumnFamily import column_name_class [as 别名]
def test_composite_slicing(self):
cf_std = ColumnFamily(pool, 'CustomComposite1')
cf_cust = ColumnFamily(pool, 'CustomComposite1')
cf_cust.column_name_class = CompositeType(
TestCustomComposite.IntDateType(),
TestCustomComposite.IntString2())
col0 = (20120101, '123')
col1 = (20120102, '123')
col2 = (20120102, '456')
col3 = (20120102, '789')
col4 = (20120103, '123')
dt0 = date(2012, 1, 1)
dt1 = date(2012, 1, 2)
dt2 = date(2012, 1, 3)
col0_cust = (dt0, 123)
col1_cust = (dt1, 123)
col2_cust = (dt1, 456)
col3_cust = (dt1, 789)
col4_cust = (dt2, 123)
cf_std.insert('key2', {col0: '', col1: '', col2: '', col3: '', col4: ''})
result = cf_cust.get('key2',
column_start=((dt1, True),),
column_finish=((dt1, True),))
assert_equal(result, {col1_cust: '', col2_cust: '', col3_cust: ''})
result = cf_cust.get('key2',
column_start=(dt1,),
column_finish=((dt2, False), ))
assert_equal(result, {col1_cust: '', col2_cust: '', col3_cust: ''})
result = cf_cust.get('key2',
column_start=((dt1, True),),
column_finish=((dt2, False), ))
assert_equal(result, {col1_cust: '', col2_cust: '', col3_cust: ''})
result = cf_cust.get('key2',
column_start=(dt1, ),
column_finish=((dt2, False), ))
assert_equal(result, {col1_cust: '', col2_cust: '', col3_cust: ''})
result = cf_cust.get('key2',
column_start=((dt0, False), ),
column_finish=((dt2, False), ))
assert_equal(result, {col1_cust: '', col2_cust: '', col3_cust: ''})
result = cf_cust.get('key2',
column_start=(dt1, 123),
column_finish=(dt1, 789))
assert_equal(result, {col1_cust: '', col2_cust: '', col3_cust: ''})
result = cf_cust.get('key2',
column_start=(dt1, 123),
column_finish=(dt1, (789, True)))
assert_equal(result, {col1_cust: '', col2_cust: '', col3_cust: ''})
result = cf_cust.get('key2',
column_start=(dt1, (123, True)),
column_finish=((dt2, False), ))
assert_equal(result, {col1_cust: '', col2_cust: '', col3_cust: ''})