tsdbSmaTest.cpp 13.0 KB
Newer Older
C
Cary Xu 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
 *
 * This program is free software: you can use, redistribute, and/or modify
 * it under the terms of the GNU Affero General Public License, version 3
 * or later ("AGPL"), as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#include <gtest/gtest.h>
#include <taoserror.h>
#include <tglobal.h>
#include <iostream>

C
Cary Xu 已提交
21
#include <metaDef.h>
C
Cary Xu 已提交
22
#include <tmsg.h>
C
Cary Xu 已提交
23
#include <tsdbDef.h>
C
Cary Xu 已提交
24

C
Cary Xu 已提交
25 26 27 28 29 30
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"

C
Cary Xu 已提交
31 32 33 34 35
int main(int argc, char **argv) {
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}

C
Cary Xu 已提交
36
TEST(testCase, tSma_Meta_Encode_Decode_Test) {
C
Cary Xu 已提交
37 38 39
  // encode
  STSma tSma = {0};
  tSma.version = 0;
C
Cary Xu 已提交
40
  tSma.intervalUnit = TIME_UNIT_DAY;
C
Cary Xu 已提交
41
  tSma.interval = 1;
C
Cary Xu 已提交
42
  tSma.slidingUnit = TIME_UNIT_HOUR;
C
Cary Xu 已提交
43 44
  tSma.sliding = 0;
  tstrncpy(tSma.indexName, "sma_index_test", TSDB_INDEX_NAME_LEN);
C
Cary Xu 已提交
45
  tstrncpy(tSma.timezone, "Asia/Shanghai", TD_TIMEZONE_LEN);
C
Cary Xu 已提交
46
  tSma.indexUid = 2345678910;
C
Cary Xu 已提交
47
  tSma.tableUid = 1234567890;
C
Cary Xu 已提交
48

C
Cary Xu 已提交
49 50
  STSmaWrapper tSmaWrapper = {.number = 1, .tSma = &tSma};
  uint32_t     bufLen = tEncodeTSmaWrapper(NULL, &tSmaWrapper);
C
Cary Xu 已提交
51

52
  void *buf = calloc(1, bufLen);
C
Cary Xu 已提交
53
  ASSERT_NE(buf, nullptr);
C
Cary Xu 已提交
54 55 56 57

  STSmaWrapper *pSW = (STSmaWrapper *)buf;
  uint32_t      len = tEncodeTSmaWrapper(&buf, &tSmaWrapper);

C
Cary Xu 已提交
58
  ASSERT_EQ(len, bufLen);
C
Cary Xu 已提交
59 60 61 62

  // decode
  STSmaWrapper dstTSmaWrapper = {0};
  void *       result = tDecodeTSmaWrapper(pSW, &dstTSmaWrapper);
C
Cary Xu 已提交
63
  ASSERT_NE(result, nullptr);
C
Cary Xu 已提交
64

C
Cary Xu 已提交
65
  ASSERT_EQ(tSmaWrapper.number, dstTSmaWrapper.number);
C
Cary Xu 已提交
66 67 68 69 70

  for (int i = 0; i < tSmaWrapper.number; ++i) {
    STSma *pSma = tSmaWrapper.tSma + i;
    STSma *qSma = dstTSmaWrapper.tSma + i;

C
Cary Xu 已提交
71 72 73 74 75 76 77 78 79 80 81 82 83
    ASSERT_EQ(pSma->version, qSma->version);
    ASSERT_EQ(pSma->intervalUnit, qSma->intervalUnit);
    ASSERT_EQ(pSma->slidingUnit, qSma->slidingUnit);
    ASSERT_STRCASEEQ(pSma->indexName, qSma->indexName);
    ASSERT_STRCASEEQ(pSma->timezone, qSma->timezone);
    ASSERT_EQ(pSma->indexUid, qSma->indexUid);
    ASSERT_EQ(pSma->tableUid, qSma->tableUid);
    ASSERT_EQ(pSma->interval, qSma->interval);
    ASSERT_EQ(pSma->sliding, qSma->sliding);
    ASSERT_EQ(pSma->exprLen, qSma->exprLen);
    ASSERT_STRCASEEQ(pSma->expr, qSma->expr);
    ASSERT_EQ(pSma->tagsFilterLen, qSma->tagsFilterLen);
    ASSERT_STRCASEEQ(pSma->tagsFilter, qSma->tagsFilter);
C
Cary Xu 已提交
84 85 86
  }

  // resource release
87
  tfree(pSW);
C
Cary Xu 已提交
88 89
  tdDestroyTSma(&tSma);
  tdDestroyTSmaWrapper(&dstTSmaWrapper);
C
Cary Xu 已提交
90
}
C
Cary Xu 已提交
91

C
Cary Xu 已提交
92
#if 1
C
Cary Xu 已提交
93
TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
C
Cary Xu 已提交
94 95
  const char *   smaIndexName1 = "sma_index_test_1";
  const char *   smaIndexName2 = "sma_index_test_2";
C
Cary Xu 已提交
96 97
  const char *   timezone = "Asia/Shanghai";
  const char *   expr = "select count(a,b, top 20), from table interval 1d, sliding 1h;";
C
Cary Xu 已提交
98 99
  const char *   tagsFilter = "I'm tags filter";
  const char *   smaTestDir = "./smaTest";
C
Cary Xu 已提交
100 101 102
  const tb_uid_t tbUid = 1234567890;
  const int64_t  indexUid1 = 2000000001;
  const int64_t  indexUid2 = 2000000002;
C
Cary Xu 已提交
103
  const uint32_t nCntTSma = 2;
C
Cary Xu 已提交
104 105 106
  // encode
  STSma tSma = {0};
  tSma.version = 0;
C
Cary Xu 已提交
107
  tSma.intervalUnit = TIME_UNIT_DAY;
C
Cary Xu 已提交
108
  tSma.interval = 1;
C
Cary Xu 已提交
109
  tSma.slidingUnit = TIME_UNIT_HOUR;
C
Cary Xu 已提交
110
  tSma.sliding = 0;
C
Cary Xu 已提交
111
  tSma.indexUid = indexUid1;
C
Cary Xu 已提交
112
  tstrncpy(tSma.indexName, smaIndexName1, TSDB_INDEX_NAME_LEN);
C
Cary Xu 已提交
113
  tstrncpy(tSma.timezone, timezone, TD_TIMEZONE_LEN);
C
Cary Xu 已提交
114
  tSma.tableUid = tbUid;
C
Cary Xu 已提交
115 116

  tSma.exprLen = strlen(expr);
117
  tSma.expr = (char *)calloc(1, tSma.exprLen + 1);
C
Cary Xu 已提交
118
  ASSERT_NE(tSma.expr, nullptr);
C
Cary Xu 已提交
119 120
  tstrncpy(tSma.expr, expr, tSma.exprLen + 1);

C
Cary Xu 已提交
121 122
  tSma.tagsFilterLen = strlen(tagsFilter);
  tSma.tagsFilter = (char *)calloc(tSma.tagsFilterLen + 1, 1);
C
Cary Xu 已提交
123
  ASSERT_NE(tSma.tagsFilter, nullptr);
C
Cary Xu 已提交
124
  tstrncpy(tSma.tagsFilter, tagsFilter, tSma.tagsFilterLen + 1);
C
Cary Xu 已提交
125 126

  SMeta *         pMeta = NULL;
C
Cary Xu 已提交
127
  STSma *         pSmaCfg = &tSma;
C
Cary Xu 已提交
128 129 130 131 132 133 134
  const SMetaCfg *pMetaCfg = &defaultMetaOptions;

  taosRemoveDir(smaTestDir);

  pMeta = metaOpen(smaTestDir, pMetaCfg, NULL);
  assert(pMeta != NULL);
  // save index 1
C
Cary Xu 已提交
135
  ASSERT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0);
C
Cary Xu 已提交
136

C
Cary Xu 已提交
137
  pSmaCfg->indexUid = indexUid2;
C
Cary Xu 已提交
138 139
  tstrncpy(pSmaCfg->indexName, smaIndexName2, TSDB_INDEX_NAME_LEN);
  pSmaCfg->version = 1;
C
Cary Xu 已提交
140
  pSmaCfg->intervalUnit = TIME_UNIT_HOUR;
C
Cary Xu 已提交
141
  pSmaCfg->interval = 1;
C
Cary Xu 已提交
142
  pSmaCfg->slidingUnit = TIME_UNIT_MINUTE;
C
Cary Xu 已提交
143 144 145
  pSmaCfg->sliding = 5;

  // save index 2
C
Cary Xu 已提交
146
  ASSERT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0);
C
Cary Xu 已提交
147 148

  // get value by indexName
C
Cary Xu 已提交
149
  STSma *qSmaCfg = NULL;
C
Cary Xu 已提交
150
  qSmaCfg = metaGetSmaInfoByIndex(pMeta, indexUid1);
C
Cary Xu 已提交
151 152
  assert(qSmaCfg != NULL);
  printf("name1 = %s\n", qSmaCfg->indexName);
C
Cary Xu 已提交
153
  printf("timezone1 = %s\n", qSmaCfg->timezone);
C
Cary Xu 已提交
154
  printf("expr1 = %s\n", qSmaCfg->expr != NULL ? qSmaCfg->expr : "");
C
Cary Xu 已提交
155
  printf("tagsFilter1 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : "");
C
Cary Xu 已提交
156 157
  ASSERT_STRCASEEQ(qSmaCfg->indexName, smaIndexName1);
  ASSERT_EQ(qSmaCfg->tableUid, tSma.tableUid);
C
Cary Xu 已提交
158
  tdDestroyTSma(qSmaCfg);
C
Cary Xu 已提交
159
  tfree(qSmaCfg);
C
Cary Xu 已提交
160

C
Cary Xu 已提交
161
  qSmaCfg = metaGetSmaInfoByIndex(pMeta, indexUid2);
C
Cary Xu 已提交
162 163
  assert(qSmaCfg != NULL);
  printf("name2 = %s\n", qSmaCfg->indexName);
C
Cary Xu 已提交
164
  printf("timezone2 = %s\n", qSmaCfg->timezone);
C
Cary Xu 已提交
165
  printf("expr2 = %s\n", qSmaCfg->expr != NULL ? qSmaCfg->expr : "");
C
Cary Xu 已提交
166
  printf("tagsFilter2 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : "");
C
Cary Xu 已提交
167 168
  ASSERT_STRCASEEQ(qSmaCfg->indexName, smaIndexName2);
  ASSERT_EQ(qSmaCfg->interval, tSma.interval);
C
Cary Xu 已提交
169
  tdDestroyTSma(qSmaCfg);
C
Cary Xu 已提交
170
  tfree(qSmaCfg);
C
Cary Xu 已提交
171

C
Cary Xu 已提交
172
  // get index name by table uid
C
Cary Xu 已提交
173 174 175 176
  SMSmaCursor *pSmaCur = metaOpenSmaCursor(pMeta, tbUid);
  assert(pSmaCur != NULL);
  uint32_t indexCnt = 0;
  while (1) {
C
Cary Xu 已提交
177
    const char *indexName = metaSmaCursorNext(pSmaCur);
C
Cary Xu 已提交
178 179 180 181 182 183
    if (indexName == NULL) {
      break;
    }
    printf("indexName = %s\n", indexName);
    ++indexCnt;
  }
C
Cary Xu 已提交
184
  ASSERT_EQ(indexCnt, nCntTSma);
C
Cary Xu 已提交
185 186
  metaCloseSmaCurosr(pSmaCur);

C
Cary Xu 已提交
187
  // get wrapper by table uid
C
Cary Xu 已提交
188
  STSmaWrapper *pSW = metaGetSmaInfoByTable(pMeta, tbUid);
C
Cary Xu 已提交
189
  assert(pSW != NULL);
C
Cary Xu 已提交
190 191 192 193 194 195 196 197 198 199 200 201 202
  ASSERT_EQ(pSW->number, nCntTSma);
  ASSERT_STRCASEEQ(pSW->tSma->indexName, smaIndexName1);
  ASSERT_STRCASEEQ(pSW->tSma->timezone, timezone);
  ASSERT_STRCASEEQ(pSW->tSma->expr, expr);
  ASSERT_STRCASEEQ(pSW->tSma->tagsFilter, tagsFilter);
  ASSERT_EQ(pSW->tSma->indexUid, indexUid1);
  ASSERT_EQ(pSW->tSma->tableUid, tbUid);
  ASSERT_STRCASEEQ((pSW->tSma + 1)->indexName, smaIndexName2);
  ASSERT_STRCASEEQ((pSW->tSma + 1)->timezone, timezone);
  ASSERT_STRCASEEQ((pSW->tSma + 1)->expr, expr);
  ASSERT_STRCASEEQ((pSW->tSma + 1)->tagsFilter, tagsFilter);
  ASSERT_EQ((pSW->tSma + 1)->indexUid, indexUid2);
  ASSERT_EQ((pSW->tSma + 1)->tableUid, tbUid);
C
Cary Xu 已提交
203

C
Cary Xu 已提交
204 205 206 207 208 209 210 211 212 213
  tdDestroyTSmaWrapper(pSW);
  tfree(pSW);

  // get all sma table uids
  SArray *pUids = metaGetSmaTbUids(pMeta, false);
  assert(pUids != NULL);
  for (uint32_t i = 0; i < taosArrayGetSize(pUids); ++i) {
    printf("metaGetSmaTbUids: uid[%" PRIu32 "] = %" PRIi64 "\n", i, *(tb_uid_t *)taosArrayGet(pUids, i));
    // printf("metaGetSmaTbUids: index[%" PRIu32 "] = %s", i, (char *)taosArrayGet(pUids, i));
  }
C
Cary Xu 已提交
214
  ASSERT_EQ(taosArrayGetSize(pUids), 1);
C
Cary Xu 已提交
215
  taosArrayDestroy(pUids);
C
Cary Xu 已提交
216

C
Cary Xu 已提交
217 218 219 220
  // resource release
  metaRemoveSmaFromDb(pMeta, smaIndexName1);
  metaRemoveSmaFromDb(pMeta, smaIndexName2);

C
Cary Xu 已提交
221
  tdDestroyTSma(&tSma);
C
Cary Xu 已提交
222
  metaClose(pMeta);
C
Cary Xu 已提交
223
}
C
Cary Xu 已提交
224
#endif
C
Cary Xu 已提交
225

C
Cary Xu 已提交
226
#if 1
C
Cary Xu 已提交
227 228
TEST(testCase, tSma_Data_Insert_Query_Test) {
  // step 1: prepare meta
C
Cary Xu 已提交
229 230 231
  const char *   smaIndexName1 = "sma_index_test_1";
  const char *   timezone = "Asia/Shanghai";
  const char *   expr = "select count(a,b, top 20), from table interval 1d, sliding 1h;";
C
Cary Xu 已提交
232
  const char *   tagsFilter = "where tags.location='Beijing' and tags.district='ChaoYang'";
C
Cary Xu 已提交
233 234 235
  const char *   smaTestDir = "./smaTest";
  const tb_uid_t tbUid = 1234567890;
  const int64_t  indexUid1 = 2000000001;
C
Cary Xu 已提交
236
  const int64_t  interval1 = 1;
C
Cary Xu 已提交
237
  const int8_t   intervalUnit1 = TIME_UNIT_DAY;
C
Cary Xu 已提交
238
  const uint32_t nCntTSma = 2;
C
Cary Xu 已提交
239 240 241
  TSKEY          skey1 = 1646987196;
  const int64_t  testSmaData1 = 100;
  const int64_t  testSmaData2 = 200;
C
Cary Xu 已提交
242 243 244
  // encode
  STSma tSma = {0};
  tSma.version = 0;
C
Cary Xu 已提交
245
  tSma.intervalUnit = TIME_UNIT_DAY;
C
Cary Xu 已提交
246
  tSma.interval = 1;
C
Cary Xu 已提交
247
  tSma.slidingUnit = TIME_UNIT_HOUR;
C
Cary Xu 已提交
248 249 250 251 252 253 254
  tSma.sliding = 0;
  tSma.indexUid = indexUid1;
  tstrncpy(tSma.indexName, smaIndexName1, TSDB_INDEX_NAME_LEN);
  tstrncpy(tSma.timezone, timezone, TD_TIMEZONE_LEN);
  tSma.tableUid = tbUid;

  tSma.exprLen = strlen(expr);
255
  tSma.expr = (char *)calloc(1, tSma.exprLen + 1);
C
Cary Xu 已提交
256
  ASSERT_NE(tSma.expr, nullptr);
C
Cary Xu 已提交
257 258 259
  tstrncpy(tSma.expr, expr, tSma.exprLen + 1);

  tSma.tagsFilterLen = strlen(tagsFilter);
260
  tSma.tagsFilter = (char *)calloc(1, tSma.tagsFilterLen + 1);
C
Cary Xu 已提交
261
  ASSERT_NE(tSma.tagsFilter, nullptr);
C
Cary Xu 已提交
262 263 264 265 266 267 268 269 270 271 272
  tstrncpy(tSma.tagsFilter, tagsFilter, tSma.tagsFilterLen + 1);

  SMeta *         pMeta = NULL;
  STSma *         pSmaCfg = &tSma;
  const SMetaCfg *pMetaCfg = &defaultMetaOptions;

  taosRemoveDir(smaTestDir);

  pMeta = metaOpen(smaTestDir, pMetaCfg, NULL);
  assert(pMeta != NULL);
  // save index 1
C
Cary Xu 已提交
273
  ASSERT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0);
C
Cary Xu 已提交
274

C
Cary Xu 已提交
275
  // step 2: insert data
C
Cary Xu 已提交
276
  STSmaDataWrapper *pSmaData = NULL;
277 278 279 280 281 282 283 284 285 286 287 288 289 290
  STsdb *           pTsdb = (STsdb *)calloc(1, sizeof(STsdb));
  STsdbCfg *        pCfg = &pTsdb->config;

  pTsdb->pMeta = pMeta;
  pTsdb->vgId = 2;
  pTsdb->config.daysPerFile = 10;  // default days is 10
  pTsdb->config.keep1 = 30;
  pTsdb->config.keep2 = 90;
  pTsdb->config.keep = 365;
  pTsdb->config.precision = TSDB_TIME_PRECISION_MILLI;
  pTsdb->config.update = TD_ROW_OVERWRITE_UPDATE;
  pTsdb->config.compression = TWO_STAGE_COMP;

  switch (pTsdb->config.precision) {
C
Cary Xu 已提交
291 292 293 294 295 296 297 298 299 300 301 302 303 304
    case TSDB_TIME_PRECISION_MILLI:
      skey1 *= 1e3;
      break;
    case TSDB_TIME_PRECISION_MICRO:
      skey1 *= 1e6;
      break;
    case TSDB_TIME_PRECISION_NANO:
      skey1 *= 1e9;
      break;
    default:  // ms
      skey1 *= 1e3;
      break;
  }

C
Cary Xu 已提交
305 306 307
  SDiskCfg pDisks = {.level = 0, .primary = 1};
  strncpy(pDisks.dir, "/var/lib/taos", TSDB_FILENAME_LEN);
  int32_t numOfDisks = 1;
308 309
  pTsdb->pTfs = tfsOpen(&pDisks, numOfDisks);
  ASSERT_NE(pTsdb->pTfs, nullptr);
C
Cary Xu 已提交
310

311
  char *msg = (char *)calloc(1, 100);
C
Cary Xu 已提交
312
  ASSERT_NE(msg, nullptr);
313
  ASSERT_EQ(tsdbUpdateSmaWindow(pTsdb, TSDB_SMA_TYPE_TIME_RANGE, msg), 0);
C
Cary Xu 已提交
314 315

  // init
C
Cary Xu 已提交
316
  int32_t allocCnt = 0;
C
Cary Xu 已提交
317 318
  int32_t allocStep = 16384;
  int32_t buffer = 1024;
C
Cary Xu 已提交
319
  void *  buf = NULL;
C
Cary Xu 已提交
320
  ASSERT_EQ(tsdbMakeRoom(&buf, allocStep), 0);
C
Cary Xu 已提交
321
  int32_t  bufSize = taosTSizeof(buf);
C
Cary Xu 已提交
322 323
  int32_t  numOfTables = 10;
  col_id_t numOfCols = 4096;
C
Cary Xu 已提交
324
  ASSERT_GT(numOfCols, 0);
C
Cary Xu 已提交
325 326 327

  pSmaData = (STSmaDataWrapper *)buf;
  printf(">> allocate [%d] time to %d and addr is %p\n", ++allocCnt, bufSize, pSmaData);
C
Cary Xu 已提交
328 329 330
  pSmaData->skey = skey1;
  pSmaData->interval = interval1;
  pSmaData->intervalUnit = intervalUnit1;
331
  pSmaData->indexUid = indexUid1;
C
Cary Xu 已提交
332 333 334 335

  int32_t len = sizeof(STSmaDataWrapper);
  for (int32_t t = 0; t < numOfTables; ++t) {
    STSmaTbData *pTbData = (STSmaTbData *)POINTER_SHIFT(pSmaData, len);
C
Cary Xu 已提交
336
    pTbData->tableUid = tbUid + t;
C
Cary Xu 已提交
337 338 339 340

    int32_t tableDataLen = sizeof(STSmaTbData);
    for (col_id_t c = 0; c < numOfCols; ++c) {
      if (bufSize - len - tableDataLen < buffer) {
C
Cary Xu 已提交
341
        ASSERT_EQ(tsdbMakeRoom(&buf, bufSize + allocStep), 0);
C
Cary Xu 已提交
342 343 344 345 346 347 348
        pSmaData = (STSmaDataWrapper *)buf;
        pTbData = (STSmaTbData *)POINTER_SHIFT(pSmaData, len);
        bufSize = taosTSizeof(buf);
        printf(">> allocate [%d] time to %d and addr is %p\n", ++allocCnt, bufSize, pSmaData);
      }
      STSmaColData *pColData = (STSmaColData *)POINTER_SHIFT(pSmaData, len + tableDataLen);
      pColData->colId = c + PRIMARYKEY_TIMESTAMP_COL_ID;
C
Cary Xu 已提交
349

C
Cary Xu 已提交
350
      // TODO: fill col data
C
Cary Xu 已提交
351 352 353 354 355 356 357 358 359
      if ((c & 1) == 0) {
        pColData->blockSize = 8;
        memcpy(pColData->data, &testSmaData1, 8);
      } else {
        pColData->blockSize = 16;
        memcpy(pColData->data, &testSmaData1, 8);
        memcpy(POINTER_SHIFT(pColData->data, 8), &testSmaData2, 8);
      }

C
Cary Xu 已提交
360 361 362 363 364
      tableDataLen += (sizeof(STSmaColData) + pColData->blockSize);
    }
    pTbData->dataLen = (tableDataLen - sizeof(STSmaTbData));
    len += tableDataLen;
    // printf("bufSize=%d, len=%d, len of table[%d]=%d\n", bufSize, len, t, tableDataLen);
C
Cary Xu 已提交
365
  }
C
Cary Xu 已提交
366 367
  pSmaData->dataLen = (len - sizeof(STSmaDataWrapper));

C
Cary Xu 已提交
368
  ASSERT_GE(bufSize, pSmaData->dataLen);
C
Cary Xu 已提交
369 370

  // execute
371
  ASSERT_EQ(tsdbInsertTSmaData(pTsdb, (char *)pSmaData), TSDB_CODE_SUCCESS);
C
Cary Xu 已提交
372

C
Cary Xu 已提交
373 374 375 376
  // step 3: query
  uint32_t checkDataCnt = 0;
  for (int32_t t = 0; t < numOfTables; ++t) {
    for (col_id_t c = 0; c < numOfCols; ++c) {
377
      ASSERT_EQ(tsdbGetTSmaData(pTsdb, NULL, indexUid1, interval1, intervalUnit1, tbUid + t,
C
Cary Xu 已提交
378 379 380 381 382
                                c + PRIMARYKEY_TIMESTAMP_COL_ID, skey1, 1),
                TSDB_CODE_SUCCESS);
      ++checkDataCnt;
    }
  }
C
Cary Xu 已提交
383

C
Cary Xu 已提交
384 385
  printf("%s:%d The sma data check count for insert and query is %" PRIu32 "\n", __FILE__, __LINE__, checkDataCnt);

C
Cary Xu 已提交
386
  // release data
387
  tfree(msg);
C
Cary Xu 已提交
388
  taosTZfree(buf);
C
Cary Xu 已提交
389 390
  // release meta
  tdDestroyTSma(&tSma);
391 392
  tfsClose(pTsdb->pTfs);
  tsdbClose(pTsdb);
C
Cary Xu 已提交
393
  metaClose(pMeta);
C
Cary Xu 已提交
394 395 396 397
}
#endif

#pragma GCC diagnostic pop