@@ -66,54 +66,62 @@ The extras for a continue range scan encodes:
6666## Response format
6767
6868A successful continue will trigger the server to iterate forwards through the
69- range of keys, return keys/documents using a bulk framing.
69+ range of keys and return keys/documents using a bulk framing.
7070
71- The many keys/documents of a single continue maybe sent (framed) in multiple
72- responses, where a final response (with bespoke status) indicates the end of the
73- individual continue or the end of the scan itself. Each response of the continue
74- may encode multiple keys or documents, the formatting of which is described
75- in the following sections.
71+ The many keys/documents of a single continue maybe sent using multiple responses.
72+ A final response uses a bespoke range-scan status code to indicate the end of the
73+ individual range-scan-continue or that the scan has completed.
7674
75+ Each response generated by the range-scan-continue may contain a value which
76+ encodes multiple keys or documents, the formatting of which is described
77+ in the following sections. Note that each response will also be given an extras
78+ section, which is defined in a following section.
7779
78- A successful continue will return key/documents using the following framing. A
79- series of key/documents always begins with the standard mcbp 24-byte response
80- header which will include a success status and a value, the value encodes many
81- keys/documents.
80+ A batch of keys or documents always begins with the standard mcbp 24-byte response
81+ header which will include a "success" status, extras and a value. It is the value
82+ that contains the keys or documents.
8283
83- The following examples highlight how the responses to range-scan-continue works .
84+ The following examples intend to highlight how the responses from a range-scan-continue work .
8485
85- For example a range may cover an unknown number of keys and the client only
86+ For example a range covers an unknown number of keys and the client only
8687wants to handle up to 500 keys per range-scan-continue. Thus the client would
87- first issue a range-scan-continue (0xDB) with the uuid from range-scan-create
88- (0xDA), item limit set to 500 and the time limit set to 0.
88+ first issue a range-scan-continue (0xDB) with:
8989
90- The server will respond with a series of responses, there is no definition of
91- how many keys each response may encode.
90+ * the uuid from range-scan-create (0xDA)
91+ * item limit set to 500
92+ * time limit set to 0
93+ * byte limit set to 0
9294
93- Example 1, range scan progresses, yet more continues will be required.
95+ The server will respond with a series of responses. Clients must note that there
96+ is no definition of how many keys or documents each response may include.
97+
98+ Example 1: A continue hits a limit and indicates that another continue is
99+ required because more keys or documents maybe available.
94100
95101* response status=success, bodylen=261
96102* response status=success, bodylen=259
97103* response status=success, bodylen=260
98104* response status=range-scan-more (0xA6), bodylen=241
99105
100- In this sequence 500 keys are returned ( distributed over 4 different responses).
101- The final response has the status of range-scan-more informing the client that
102- the scan has more data.
106+ In this sequence 500 keys are distributed over 4 different responses. The final
107+ response has the status of range-scan-more informing the client that the scan
108+ could have more data.
103109
104- Example 2, range scan progress to the end
110+ Example 2: A continue now reaches the end of the requested range.
105111
106112* response status=success, bodylen=262
107113* response status=range-scan-complete (0xA7), bodylen=120
108114
109- In this sequence <= 500 keys have been returned (distributed over 2 different
110- responses). The final response as the status of range-scan-complete, informing
111- the client that the scan has now completed (server has closed the scan).
115+ In this sequence <= 500 keys have been distributed over 2 different responses.
116+ The status of range-scan-complete informs the client that the scan has now
117+ completed. The server has closed the scan and any further continue will be
118+ rejected.
112119
113- Example 3, range scan progresses, but vbucket state change interrupts. This
114- example demonstrates that the client must be aware that the sequence of continue
115- responses could be bookmarked with a status indicating some other issue. In this
116- case the range-scan has also been cancelled due to the issue.
120+ Example 3: range scan progresses, but is stopped due to a system state change,
121+ in this case the vbucket is no longer active. This example demonstrates that the
122+ client must be aware that the sequence of continue responses could end with a
123+ status indicating a terminal issue. For these situations the range-scan is
124+ cancelled by the server.
117125
118126* response status=success, bodylen=261
119127* response status=success, bodylen=259
@@ -122,6 +130,15 @@ case the range-scan has also been cancelled due to the issue.
122130In this example < 500 keys have been spread over three responses, the final
123131response indicates that the target vbucket has changed state.
124132
133+ ### Extras Definition
134+
135+ Each response packet includes an extras structure which contains a single 4-byte
136+ "flags" field. This field currently describes the content of the value (keys or
137+ key/meta/value). The field uses network byte order.
138+
139+ * 0 response has keys only (i.e. a ` key_only:true ` scan)
140+ * 1 response has keys + meta + documents (i.e. a ` key_only:false ` scan)
141+
125142### Response Value Encoding ` "key_only":true `
126143
127144The mcbp header defines how much data follows, in this command only a value is
@@ -221,14 +238,25 @@ E.g. a document with key="key0" and value="value0"
221238In the above layout, a second document would begin at offset 37, no padding or
222239alignment.
223240
224- ### Success
241+ ### Success status codes
242+
243+ A range-scan-continue response sequence indicates success using the following
244+ status codes.
245+
246+ ** Status::Success 0x00**
247+
248+ Used for intermediate responses making up a larger response.
249+
250+ ** Status::RangeScanMore 0xA6**
251+
252+ Scan has reached a limit and more data maybe available, the client must issue
253+ another continue.
254+
255+ ** Status::RangeScanComplete 0xA7**
225256
226- A range-scan-continue response sequence indicates success using status codes
257+ Scan has reached the end of the range, the scan itself will be removed from the
258+ server and any subsequent range-scan continue or cancel will be rejected.
227259
228- * Status::Success 0x00: Used for intermediate responses making up a larger response.
229- * Status::RangeScanMore 0xA6: Scan has reached a limit and has not reached the end
230- key, more data maybe available and the client must issue another continue.
231- * Status::RangeScanComplete 0xA7: Scan has reached the end of the range.
232260
233261### Errors
234262
@@ -259,5 +287,4 @@ The collection was dropped.
259287
260288** Status::RangeScanCancelled (0xA5)**
261289
262- The scan was cancelled whilst returning data. This could be the only status if
263- the cancel was noticed before a key/value was loaded.
290+ The scan was cancelled whilst returning data.
0 commit comments