• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python index.create_index_clause函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pycassa.index.create_index_clause函数的典型用法代码示例。如果您正苦于以下问题:Python create_index_clause函数的具体用法?Python create_index_clause怎么用?Python create_index_clause使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了create_index_clause函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:dln,项目名称:pycassa,代码行数:34,代码来源:test_columnfamily.py


示例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]
开发者ID:mozilla-services,项目名称:queuey,代码行数:15,代码来源:cassandra.py


示例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)
开发者ID:anisnasir,项目名称:pycassa,代码行数:25,代码来源:test_columnfamilymap.py


示例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))
开发者ID:derekchiang,项目名称:PyQuery,代码行数:30,代码来源:cassandra.py


示例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)
开发者ID:thaingo,项目名称:pycassa,代码行数:29,代码来源:test_columnfamilymap.py


示例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
开发者ID:AlfiyaZi,项目名称:pythonhackers,代码行数:8,代码来源:cassandra_old.py


示例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
开发者ID:noruni,项目名称:Open-BRAS,代码行数:10,代码来源:probe.py


示例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
开发者ID:noruni,项目名称:Open-BRAS,代码行数:11,代码来源:probe.py


示例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
开发者ID:noruni,项目名称:Open-BRAS,代码行数:11,代码来源:probe.py


示例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
开发者ID:noruni,项目名称:Open-BRAS,代码行数:11,代码来源:probe.py


示例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]
开发者ID:jbryan,项目名称:agamemnon,代码行数:13,代码来源:factory.py


示例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})
开发者ID:YinYanfei,项目名称:pycassa,代码行数:14,代码来源:test_autopacking.py


示例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)
开发者ID:trhowe,项目名称:pycassa,代码行数:15,代码来源:test_columnfamilymap.py


示例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)
开发者ID:dln,项目名称:pycassa,代码行数:19,代码来源:test_columnfamily.py


示例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)
开发者ID:anisnasir,项目名称:pycassa,代码行数:19,代码来源:test_columnfamily.py


示例16: insert_insert_get_indexed_slices

    def insert_insert_get_indexed_slices(self):
        columns = {'birthdate': 1L}

        keys = set()
        for i in range(1, 4):
            indexed_cf.insert('key%d' % i, columns)
            indexed_cf_stub.insert('key%d' % i, columns)
            keys.add('key%d' % i)

        expr = index.create_index_expression(column_name='birthdate', value=1L)
        clause = index.create_index_clause([expr])

        for test_indexed_cf in (indexed_cf, indexed_cf_stub):
            count = 0
            for key, cols in test_indexed_cf.get_indexed_slices(clause):
                assert_equal(cols, columns)
                assert key in keys
                count += 1
            assert_equal(count, 3)
开发者ID:a13x,项目名称:pycassa,代码行数:19,代码来源:stubs.py


示例17: get_by

    def get_by(cls, attribute, value):
        """Only works for columns indexed in Cassandra.
        This means that the property must be in the __indexes__ attribute.

        :param attribute: The attribute to lookup.
          This argument is always provided by the partial method.

        :param value: The value to match.

        Returns a list of matched objects.

        """
        col_fam = ColumnFamily(cls.pool, cls.__column_family__)
        clause = create_index_clause([create_index_expression(attribute, value)])
        idx_slices = col_fam.get_indexed_slices(clause)
        result = []
        for rowkey, columns in idx_slices:
            result.append(cls(rowkey, **columns))
        return result
开发者ID:zllak,项目名称:cassobjects,代码行数:19,代码来源:models.py


示例18: test_insert_get_indexed_slices

    def test_insert_get_indexed_slices(self):
        indexed_cf = ColumnFamily(self.client, 'Indexed1')

        columns = {'birthdate': 1L}

        key = 'key1'
        indexed_cf.insert(key, columns, write_consistency_level=ConsistencyLevel.ONE)

        key = 'key2'
        indexed_cf.insert(key, columns, write_consistency_level=ConsistencyLevel.ONE)

        key = 'key3'
        indexed_cf.insert(key, columns, write_consistency_level=ConsistencyLevel.ONE)

        expr = index.create_index_expression(column_name='birthdate', value=1L)
        clause = index.create_index_clause([expr])
        result = indexed_cf.get_indexed_slices(clause)
        assert len(result) == 3
        assert result.get('key1') == columns
        assert result.get('key2') == columns
        assert result.get('key3') == columns
开发者ID:eevans,项目名称:pycassa,代码行数:21,代码来源:test_columnfamily.py


示例19: 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)
        assert_equal(len(result), 1)
        assert_equal(result.get("key3"), instance3)
开发者ID:bwhite,项目名称:pycassa,代码行数:22,代码来源:test_columnfamilymap.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python index.create_index_expression函数代码示例发布时间:2022-05-25
下一篇:
Python columnfamily.ColumnFamily类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap