Seek
Description
Returns the requested location within the specified stream shard, for use
in a subsequent
Request
Request Header
POST /<container>/<resource> HTTP/1.1
Host: <web-APIs URL>
Content-Type: application/json
X-v3io-function: Seek
<Authorization OR X-v3io-session-key>: <value>
url = "http://<web-APIs URL>/<container>/<resource>"
headers = {
"Content-Type": "application/json",
"X-v3io-function": "Seek",
"<Authorization OR X-v3io-session-key>": "<value>"
}
The path to the target stream shard.
The path includes the stream path and the shard ID.
You can optionally set the stream name and shard ID, or only the shard ID, in the request's
Request Data
{
"StreamName": "string",
"ShardId": number,
"Type": "string",
"TimestampSec": number,
"TimestampNSec": number,
"StartingSequenceNumber": number
}
payload = {
"StreamName": "string",
"ShardId": number,
"Type": "string",
"TimestampSec": number,
"TimestampNSec": number,
"StartingSequenceNumber": number
}
- StreamName
The name of the stream that contains the shard resource.
- Type: String
- Requirement: Required if not set in the request URL
- ShardId
The ID of the shard for which to obtain the requested location.
The shard ID is an integer between 0 and one less than the stream's shard count.- Type: Number
- Requirement: Required if not set in the request URL
- Type
The seek type, which determines the location in the specified stream shard to retrieve.
- Type: String
- Requirement: Required
The following seek types are supported:
-
"EARLIEST" — the location of the earliest ingested record in the shard. -
"TIME" — the location of the earliest ingested record in the shard beginning at the base time set in theTimestampSec andTimestampNSec request parameters. If no matching record is found (i.e., if all records in the shard arrived before the specified base time) the operation returns the location of the end of the shard. -
"SEQUENCE" — the location of the record whose sequence number matches the sequence number specified in theStartingSequenceNumber request parameter. If no match is found, the operation fails.
- TimestampSec
The base time for a time-based seek operation (
Type =TIME ), as a Unix timestamp in seconds. For example,1511260205
sets the search base time to 21 Nov 2017 at 10:30:05 AM UTC. TheTimestampNSec request parameter sets the nanoseconds unit of the seek base time.
When theTimestampSec andTimestampNSec parameters are set, the operation searches for the location of the earliest ingested record in the shard (the earliest record that arrived at the platform) beginning at the specified base time. If no matching record is found (i.e., if all records in the shard arrived before the specified base time), return the last location in the shard.- Type: Number
- TimestampNSec
The nanoseconds unit of the
TimestampSec base-time timestamp for a time-based seek operation (Type =TIME ). For example, ifTimestampSec is1511260205
andTimestampNSec is500000000
, seek should search for the earliest ingested record since 21 Nov 2017 at 10:30 AM and 5.5 seconds.- Type: Number
- StartSequenceNumber
Record sequence number for a sequence-number based seek operation —
Type =SEQUENCE . When this parameter is set, the operation returns the location of the record whose sequence number matches the parameter.- Type: Number
Response
Response Data
{
"Location": "blob"
}
- Location
The requested location within the specified stream shard (see the
Type request parameter).- Type: Blob — a Base64 encoded string
Errors
In the event of an error, the response includes a JSON object with anError Message | Description |
---|---|
A provided request parameter is not valid for this request. | |
The sender of the request does not have the required permissions to perform the operation. | |
The specified resource does not exist. | |
The specified shard does not exist in this stream. |
Examples
Obtain the location of the earliest ingested record in shard 199 of a MyStream stream:
POST /mycontainer/MyDirectory/MyStream/199 HTTP/1.1
Host: https://default-tenant.app.mycluster.iguazio.com:8443
Content-Type: application/json
X-v3io-function: Seek
X-v3io-session-key: e8bd4ca2-537b-4175-bf01-8c74963e90bf
{
"Type": "EARLIEST"
}
import requests
url = "https://default-tenant.app.mycluster.iguazio.com:8443/mycontainer/MyDirectory/MyStream/199"
headers = {
"Content-Type": "application/json",
"X-v3io-function": "Seek",
"X-v3io-session-key": "e8bd4ca2-537b-4175-bf01-8c74963e90bf"
}
payload = {"Type": "EARLIEST"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
HTTP/1.1 200 OK
Content-Type: application/json
...
{"Location": "AQAAAAAAAAAAAAAAAAAAAA=="}