当前位置: 首页>>代码示例>>Python>>正文


Python index.create_index_expression函数代码示例

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


在下文中一共展示了create_index_expression函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例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


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