Skip to content

Commit 39f8202

Browse files
committed
some docs improvement for 3.7.0
1 parent 4f6d88a commit 39f8202

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

cassandra/policies.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,9 @@ def new_plan(self, keyspace, statement):
939939

940940

941941
class ConstantSpeculativeExecutionPolicy(SpeculativeExecutionPolicy):
942+
"""
943+
A speculative execution policy that sends a new query every X seconds (**delay**) for a maximum of Y attempts (**max_attempts**).
944+
"""
942945

943946
def __init__(self, delay, max_attempts):
944947
self.delay = delay

docs/api/cassandra/policies.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,12 @@ Retrying Failed Operations
6868

6969
.. autoclass:: DowngradingConsistencyRetryPolicy
7070
:members:
71+
72+
Retrying Idempotent Operations
73+
------------------------------
74+
75+
.. autoclass:: SpeculativeExecutionPolicy
76+
:members:
77+
78+
.. autoclass:: ConstantSpeculativeExecutionPolicy
79+
:members:

docs/query_paging.rst

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Paging Large Queries
44
====================
55
Cassandra 2.0+ offers support for automatic query paging. Starting with
6-
version 2.0 of the driver, if :attr:`~.Cluster.protocol_version` is greater than
6+
version 2.0 of the driver, if :attr:`~.Cluster.protocol_version` is greater than
77
:const:`2` (it is by default), queries returning large result sets will be
88
automatically paged.
99

@@ -74,3 +74,22 @@ pages. For example::
7474
handler.finished_event.wait()
7575
if handler.error:
7676
raise handler.error
77+
78+
Resume Paged Results
79+
--------------------
80+
81+
You can resume the pagination when executing a new query by using the :attr:`.ResultSet.paging_state`. This can be useful if you want to provide some stateless pagination capabilities to your application (ie. via http). For example::
82+
83+
from cassandra.query import SimpleStatement
84+
query = "SELECT * FROM users"
85+
statement = SimpleStatement(query, fetch_size=10)
86+
results = session.execute(statement)
87+
88+
# save the paging_state somewhere and return current results
89+
session['paging_stage'] = results.paging_state
90+
91+
92+
# resume the pagination sometime later...
93+
statement = SimpleStatement(query, fetch_size=10)
94+
ps = session['paging_state']
95+
results = session.execute(statement, paging_state=ps)

0 commit comments

Comments
 (0)