提交 9493ecd1 编写于 作者: wmmhello's avatar wmmhello

Merge branch 'fix/TS-3081' of https://github.com/taosdata/TDengine into fix/TS-3081

......@@ -6,6 +6,14 @@ add_executable(tmq_taosx_ci tmq_taosx_ci.c)
add_executable(write_raw_block_test write_raw_block_test.c)
add_executable(sml_test sml_test.c)
add_executable(get_db_name_test get_db_name_test.c)
add_executable(tmq_offset tmqOffset.c)
target_link_libraries(
tmq_offset
PUBLIC taos_static
PUBLIC util
PUBLIC common
PUBLIC os
)
target_link_libraries(
create_table
PUBLIC taos_static
......
//
// Created by mingming wanng on 2023/4/7.
//
#include <stdio.h>
#include <stdlib.h>
#include "taoserror.h"
#include "tlog.h"
#include "tmsg.h"
typedef struct {
int32_t size;
} STqOffsetHead;
int32_t tqOffsetRestoreFromFile(const char* fname) {
TdFilePtr pFile = taosOpenFile(fname, TD_FILE_READ);
if (pFile != NULL) {
STqOffsetHead head = {0};
int32_t code;
while (1) {
if ((code = taosReadFile(pFile, &head, sizeof(STqOffsetHead))) != sizeof(STqOffsetHead)) {
if (code == 0) {
break;
} else {
printf("code:%d != 0\n", code);
return -1;
}
}
int32_t size = htonl(head.size);
void* memBuf = taosMemoryCalloc(1, size);
if (memBuf == NULL) {
printf("memBuf == NULL\n");
return -1;
}
if ((code = taosReadFile(pFile, memBuf, size)) != size) {
taosMemoryFree(memBuf);
printf("code:%d != size:%d\n", code, size);
return -1;
}
STqOffset offset;
SDecoder decoder;
tDecoderInit(&decoder, memBuf, size);
if (tDecodeSTqOffset(&decoder, &offset) < 0) {
taosMemoryFree(memBuf);
tDecoderClear(&decoder);
printf("tDecodeSTqOffset error\n");
return -1;
}
tDecoderClear(&decoder);
printf("subkey:%s, type:%d, uid/version:%"PRId64", ts:%"PRId64"\n",
offset.subKey, offset.val.type, offset.val.uid, offset.val.ts);
taosMemoryFree(memBuf);
}
taosCloseFile(&pFile);
}
return 0;
}
int main(int argc, char *argv[]) {
tqOffsetRestoreFromFile("offset-ver0");
return 0;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册