Obtaining a Data Cursor
Use the DIS SDK to obtain the information about the data cursor.
char *streamName = "myStream";
char *projectId = "c159a24641da49b2a729ea6f57647888";
char *region = "******";
char *host = "dis.cn-north-1.myhuaweicloud.com:20004";
int ret = 0;
DISResponseInfo RspInfo = { 0 };
DISGetCursor tempCursor = { 0 };
tempCursor.streamName = streamName;
tempCursor.partitionId = "0";
tempCursor.cursorType = DISCursorTypeAtSeqNumber;
tempCursor.startingSequenceNumber = "0";
//tempCursor.cursorType = DISCursorTypeAtSeqNumber;
//tempCursor.timestamp = "1536026725191";
printf("===================%s Begin=======================\n", __FUNCTION__);
ret = DisGetCursor(host, projectId, region, &tempCursor, &RspInfo);
if (ret != 0)
{
printf("GetCursor Error: %d\r\n", ret);
}
printf("the rsp code is %d\r\n", RspInfo.HttpResponseCode);
if (RspInfo.HttpResponseCode >= 300 || RspInfo.HttpResponseCode < 200)
{
printf("HttpResponseCode: %ld\r\n", RspInfo.HttpResponseCode);
printf("the errorCode is %s, message is %s\r\n", RspInfo.ErrorCode, RspInfo.ErrorDetail);
printf("===================%s End=======================\n", __FUNCTION__);
}
else
{
printf("HttpResponseCode: %ld\r\n", RspInfo.HttpResponseCode);
printf("the partition cursor is %s\r\n", tempCursor.cursorResult.partitionCursor);
printf("===================%s End=======================\n", __FUNCTION__);
}
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
streamName |
Yes |
char * |
Name of the stream created on the management console. The name can contain letters, digits, hyphens (-), and underscores (_). The value must be 1 to 64 characters long. |
|
partitionId |
Yes |
char * |
ID of the partition to get the cursor for. Value range: 0 to 2147483647 |
|
cursorType |
No |
DISCursorType |
Cursor type.
|
|
startingSequenceNumber |
No |
char * |
Sequence number. A sequence number is the unique identifier of each record. DIS automatically allocates a sequence number when the data producer calls the PutRecords operation to add data to the DIS stream. The sequence number of the same partition key usually changes with time. A longer interval between PutRecords requests results in a larger sequence number. The sequence number is closely related to cursor types AT_SEQUENCE_NUMBER and AFTER_SEQUENCE_NUMBER. The two parameters determine the location of the data to be accessed. Value range: 0 to 9223372036854775807 |
|
timestamp |
No |
char * |
Timestamp when the data record starts to be read, which is closely related to the DISCursorTypeAtTimestamp cursor type. The two parameters determine the position of the data to be read.
NOTE:
This timestamp is accurate to milliseconds. |
|
pucReserved |
No |
void * |
Empty pointer, used to extend the request body. |
Execution Result
Information similar to the following is displayed on the console:
the rsp code is 200 HttpResponseCode: 200 the partition cursor is eyJnZXRJdGVyYXRvclBhcmFtIjp7InN0cmVhbS1uYW1lIjoiZGlzLXNoYXduIiwicGFydGl0aW9uLWlkIjoiMCIsImN1cnNvci10eXBlIjoiQVRfU0VRVUVOQ0VfTlVNQkVSIiwic3RhcnRpbmctc2VxdWVuY2UtbnVtYmVyIjoiMCJ9LCJnZW5lcmF0ZVRpbWVzdGFtcCI6MTUzNTk3MjU4NzIxOX0
|
Parameter |
Type |
Description |
|---|---|---|
|
cursorResult |
DISCursor |
Cursor that is obtained in response. |
|
Parameter |
Type |
Description |
|---|---|---|
|
partitionCursor |
Char [520] |
Data cursor. Value: 1 to 512 characters.
NOTE:
The validity period of a cursor is 5 minutes. |
Last Article: Downloading Streaming Data
Next Article: Error Codes
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.