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


Python ColumnFamily.get_indexed_slices方法代码示例

本文整理汇总了Python中pycassa.columnfamily.ColumnFamily.get_indexed_slices方法的典型用法代码示例。如果您正苦于以下问题:Python ColumnFamily.get_indexed_slices方法的具体用法?Python ColumnFamily.get_indexed_slices怎么用?Python ColumnFamily.get_indexed_slices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pycassa.columnfamily.ColumnFamily的用法示例。


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

示例1: datatable

# 需要导入模块: from pycassa.columnfamily import ColumnFamily [as 别名]
# 或者: from pycassa.columnfamily.ColumnFamily import get_indexed_slices [as 别名]
def datatable():

    session = cassandra.connect()
    session.set_keyspace(settings['cluster_name'])
    cass_client = ConnectionPool(settings['cluster_name'],[settings['cass_cluster']+':'+settings['thrift_port']], timeout=60)
    col_fam = ColumnFamily(cass_client,'parsed_data')
    session.default_timeout = 100
    key1 = request.args.get('key')
    if key1 == None:
        key1=100
    key1= int(key1)
    query = "SELECT last_timeid FROM main_count"  # users contains 100 rows
    statement = session.execute(query)
    for x in statement:
        end_key = x[0]
    log_data = [[]for i in range(0,key1)]
    log_data_header,k = [], 0
    temp = end_key-key1
    for i in range(temp,end_key):
        expr2 = create_index_expression('logid',i)
        lause = create_index_clause([ expr2], count=1)
        test = list(col_fam.get_indexed_slices(lause, columns= ["timestamp", "host", "byte_transfer", "request_link", "request_details", "device_type", "operating_system", "request_type", "response_code", "response_time"]))[0][1]
        for m in test.values():
            log_data[k].append(m)
        k += 1
        if k == 1:
            for n in test.keys():
                log_data_header.append(n)
    return render_template('datatable.html', data= log_data, data_header = log_data_header,index = key1)
开发者ID:asinha093,项目名称:LogAnalysis,代码行数:31,代码来源:dashboard.py

示例2: authenticatorlist_get_id

# 需要导入模块: from pycassa.columnfamily import ColumnFamily [as 别名]
# 或者: from pycassa.columnfamily.ColumnFamily import get_indexed_slices [as 别名]
 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,代码行数:12,代码来源:probe.py

示例3: handle_get_id_viaNetwork

# 需要导入模块: from pycassa.columnfamily import ColumnFamily [as 别名]
# 或者: from pycassa.columnfamily.ColumnFamily import get_indexed_slices [as 别名]
 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,代码行数:13,代码来源:probe.py

示例4: authenticator_get_token_id

# 需要导入模块: from pycassa.columnfamily import ColumnFamily [as 别名]
# 或者: from pycassa.columnfamily.ColumnFamily import get_indexed_slices [as 别名]
 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,代码行数:13,代码来源:probe.py

示例5: network_get_id_viaSession

# 需要导入模块: from pycassa.columnfamily import ColumnFamily [as 别名]
# 或者: from pycassa.columnfamily.ColumnFamily import get_indexed_slices [as 别名]
 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,代码行数:13,代码来源:probe.py

示例6: test_get_indexed_slices

# 需要导入模块: from pycassa.columnfamily import ColumnFamily [as 别名]
# 或者: from pycassa.columnfamily.ColumnFamily import get_indexed_slices [as 别名]
 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:caruccio,项目名称:pycassa,代码行数:16,代码来源:test_autopacking.py

示例7: getVids

# 需要导入模块: from pycassa.columnfamily import ColumnFamily [as 别名]
# 或者: from pycassa.columnfamily.ColumnFamily import get_indexed_slices [as 别名]
def getVids(username, max_length=0):
  con = util.getConnection()
  videoCF = ColumnFamily(con, 'videos')
  username_criteria = create_index_expression('user_name', username)
  length_criteria = create_index_expression('runtime_in_sec', max_length, LTE) #LTE? Less than or equals
 
  user_only_clause = create_index_clause([username_criteria], count=3) #just pull 3
  movies_by_user = videoCF.get_indexed_slices(user_only_clause)
  print '''-- movies for username: {}  --'''.format(username)
  print_movie(movies_by_user)

  user_runtime_clause = create_index_clause([username_criteria, length_criteria]) #pull all
  movies_by_user_runtime = videoCF.get_indexed_slices(user_runtime_clause)
  print '''-- movies for username: {} and length <= {} --'''.format(username, max_length)
  print_movie(movies_by_user_runtime)
  
  """
  # Intended to fail
  runtime_clause = create_index_clause([length_criteria]) # At least on equality neccessary!
  movies_by_runtime = videoCF.get_indexed_slices(runtime_clause)
  print '''-- movies for length <= {} --'''.format(max_length)
  print_movie(movies_by_runtime)
  """
  con.dispose()
开发者ID:djnesmith,项目名称:mastering_cassandra,代码行数:26,代码来源:ch3_1.4.3_secondary_index.py

示例8: get_indexed_slices

# 需要导入模块: from pycassa.columnfamily import ColumnFamily [as 别名]
# 或者: from pycassa.columnfamily.ColumnFamily import get_indexed_slices [as 别名]
    def get_indexed_slices(self, *args, **kwargs):
        """
        Fetches a list of instances that satisfy an index clause. Similar
        to :meth:`get_range()`, but uses an index clause instead of a key range.

        See :meth:`.ColumnFamily.get_indexed_slices()` for
        an explanation of the parameters.

        """

        assert not self.super, "get_indexed_slices() is not " \
                "supported by super column families"

        if 'columns' not in kwargs and not self.raw_columns:
            kwargs['columns'] = self.fields

        for key, columns in ColumnFamily.get_indexed_slices(self, *args, **kwargs):
            combined = self.combine_columns(columns)
            yield create_instance(self.cls, key=key, **combined)
开发者ID:gustavopinto,项目名称:pycassa,代码行数:21,代码来源:columnfamilymap.py

示例9: get_by

# 需要导入模块: from pycassa.columnfamily import ColumnFamily [as 别名]
# 或者: from pycassa.columnfamily.ColumnFamily import get_indexed_slices [as 别名]
    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,代码行数:21,代码来源:models.py

示例10: datale

# 需要导入模块: from pycassa.columnfamily import ColumnFamily [as 别名]
# 或者: from pycassa.columnfamily.ColumnFamily import get_indexed_slices [as 别名]
def datale():

    session = cassandra.connect()
    session.set_keyspace(settings['cluster_name'])
    cass_client = ConnectionPool(settings['cluster_name'],[settings['cass_cluster']+':'+settings['thrift_port']], timeout=60)
    col_fam = ColumnFamily(cass_client,'parsed_data')
    session.default_timeout = 100
    key1 = request.args.get('key')
    expr2 = create_index_expression('timestamp',key1)
    lause = create_index_clause([ expr2], count=99999)

    test = list(col_fam.get_indexed_slices(lause, columns= ["timestamp", "host", "byte_transfer", "request_link", "request_details", "device_type", "operating_system", "request_type", "response_code", "response_time"]))
    data, data_header = [[]for i in range(0,len(test))], []
    k = 0
    for k in range(0,len(test)):
        for m in test[k][1].values():
            data[k].append(m)
            if k == 1:
                for n in test[k][1].keys():
                    data_header.append(n)

    #return json.dumps(test)
    return render_template('datatable.html', data= data, data_header = data_header,index = len(test))
开发者ID:asinha093,项目名称:LogAnalysis,代码行数:25,代码来源:dashboard.py


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