MCPcopy Index your code
hub / github.com/apache/cassandra-python-driver / ResultSet

Class ResultSet

cassandra/cluster.py:5176–5382  ·  view source on GitHub ↗

An iterator over the rows from a query result. Also supplies basic equality and indexing methods for backward-compatability. These methods materialize the entire result set (loading all pages), and should only be used if the total result size is understood. Warnings are emitted when

Source from the content-addressed store, hash-verified

5174
5175
5176class ResultSet(object):
5177 """
5178 An iterator over the rows from a query result. Also supplies basic equality
5179 and indexing methods for backward-compatability. These methods materialize
5180 the entire result set (loading all pages), and should only be used if the
5181 total result size is understood. Warnings are emitted when paged results
5182 are materialized in this fashion.
5183
5184 You can treat this as a normal iterator over rows::
5185
5186 >>> from cassandra.query import SimpleStatement
5187 >>> statement = SimpleStatement("SELECT * FROM users", fetch_size=10)
5188 >>> for user_row in session.execute(statement):
5189 ... process_user(user_row)
5190
5191 Whenever there are no more rows in the current page, the next page will
5192 be fetched transparently. However, note that it *is* possible for
5193 an :class:`Exception` to be raised while fetching the next page, just
5194 like you might see on a normal call to ``session.execute()``.
5195 """
5196
5197 def __init__(self, response_future, initial_response):
5198 self.response_future = response_future
5199 self.column_names = response_future._col_names
5200 self.column_types = response_future._col_types
5201 self._set_current_rows(initial_response)
5202 self._page_iter = None
5203 self._list_mode = False
5204
5205 @property
5206 def has_more_pages(self):
5207 """
5208 True if the last response indicated more pages; False otherwise
5209 """
5210 return self.response_future.has_more_pages
5211
5212 @property
5213 def current_rows(self):
5214 """
5215 The list of current page rows. May be empty if the result was empty,
5216 or this is the last page.
5217 """
5218 return self._current_rows or []
5219
5220 def all(self):
5221 """
5222 Returns all the remaining rows as a list. This is basically
5223 a convenient shortcut to `list(result_set)`.
5224
5225 This function is not recommended for queries that return a large number of elements.
5226 """
5227 return list(self)
5228
5229 def one(self):
5230 """
5231 Return a single row of the results or None if empty. This is basically
5232 a shortcut to `result_set.current_rows[0]` and should only be used when
5233 you know a query returns a single row. Consider using an iterator if the

Callers 15

test_iter_non_pagedMethod · 0.90
test_iter_pagedMethod · 0.90
test_list_non_pagedMethod · 0.90
test_list_pagedMethod · 0.90
test_has_more_pagesMethod · 0.90
test_index_list_modeMethod · 0.90
test_eqMethod · 0.90
test_boolMethod · 0.90
test_was_appliedMethod · 0.90
test_oneMethod · 0.90

Calls

no outgoing calls

Tested by 14

test_iter_non_pagedMethod · 0.72
test_iter_pagedMethod · 0.72
test_list_non_pagedMethod · 0.72
test_list_pagedMethod · 0.72
test_has_more_pagesMethod · 0.72
test_index_list_modeMethod · 0.72
test_eqMethod · 0.72
test_boolMethod · 0.72
test_was_appliedMethod · 0.72
test_oneMethod · 0.72