From a3e12271a6b700d44309a54300f5fda9fec5f5a0 Mon Sep 17 00:00:00 2001 From: hzcheng Date: Fri, 13 Mar 2020 17:29:24 +0800 Subject: [PATCH] more --- src/vnode/tsdb/tests/tsdbTests.cpp | 51 ++++++++++++++++-------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/src/vnode/tsdb/tests/tsdbTests.cpp b/src/vnode/tsdb/tests/tsdbTests.cpp index eba7df3adb..91b6d417a4 100644 --- a/src/vnode/tsdb/tests/tsdbTests.cpp +++ b/src/vnode/tsdb/tests/tsdbTests.cpp @@ -33,28 +33,33 @@ TEST(TsdbTest, createRepo) { tsdbCreateTable(pRepo, &tCfg); // // 3. Loop to write some simple data - // int nRows = 10; - // SSubmitMsg *pMsg = (SSubmitMsg *)malloc(sizeof(SSubmitMsg) + sizeof(SSubmitBlk) + tdMaxRowBytesFromSchema(schema) * nRows); - - // SSubmitBlk *pBlock = pMsg->blocks; - // pBlock->tableId = {.uid = 987607499877672L, .tid = 0}; - // pBlock->sversion = 0; - // pBlock->len = 0; - // int64_t start_time = 1584081000000; - // for (int i = 0; i < nRows; i++) { - // int64_t ttime = start_time + 1000 * i; - // SDataRow row = (SDataRow)(pBlock->data + pBlock->len); - // dataRowInit(row); - - // for (int j; j < schemaNCols(schema); j++) { - // if (j == 0) { // Just for timestamp - // tdAppendColVal(row, (void *)(&time), schemaColAt(schema, i), ); - // } else { // For int - - // } - // } - - // pBlock->len += dataRowLen(row); - // } + int nRows = 10; + SSubmitMsg *pMsg = (SSubmitMsg *)malloc(sizeof(SSubmitMsg) + sizeof(SSubmitBlk) + tdMaxRowBytesFromSchema(schema) * nRows); + + SSubmitBlk *pBlock = pMsg->blocks; + pBlock->tableId = {.uid = 987607499877672L, .tid = 0}; + pBlock->sversion = 0; + pBlock->len = 0; + int64_t start_time = 1584081000000; + for (int i = 0; i < nRows; i++) { + int64_t ttime = start_time + 1000 * i; + SDataRow row = (SDataRow)(pBlock->data + pBlock->len); + tdInitDataRow(row, schema); + + for (int j; j < schemaNCols(schema); j++) { + if (j == 0) { // Just for timestamp + tdAppendColVal(row, (void *)(&time), schemaColAt(schema, i)); + } else { // For int + int val = 10; + tdAppendColVal(row, (void *)(&val), schemaColAt(schema, i)); + } + + pBlock->len += dataRowLen(row); + } + + pMsg->length = pMsg->length + sizeof(SSubmitBlk) + pBlock->len; + } + + tsdbInsertData(pRepo, pMsg); } -- GitLab