sma.c 2.3 KB
Newer Older
C
Cary Xu 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * 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/>.
 */

16
#include "sma.h"
C
Cary Xu 已提交
17

18 19 20
// TODO: Who is responsible for resource allocate and release?
int32_t tdProcessTSmaInsert(SSma* pSma, int64_t indexUid, const char* msg) {
  int32_t code = TSDB_CODE_SUCCESS;
C
Cary Xu 已提交
21

22
  if ((code = tdProcessTSmaInsertImpl(pSma, indexUid, msg)) < 0) {
S
Shengliang Guan 已提交
23
    smaWarn("vgId:%d, insert tsma data failed since %s", SMA_VID(pSma), tstrerror(terrno));
C
Cary Xu 已提交
24
  }
25 26
  // TODO: destroy SSDataBlocks(msg)
  return code;
C
Cary Xu 已提交
27 28
}

C
Cary Xu 已提交
29 30 31 32
int32_t tdProcessTSmaCreate(SSma* pSma, int64_t version, const char* msg) {
  int32_t code = TSDB_CODE_SUCCESS;

  if ((code = tdProcessTSmaCreateImpl(pSma, version, msg)) < 0) {
S
Shengliang Guan 已提交
33
    smaWarn("vgId:%d, create tsma failed since %s", SMA_VID(pSma), tstrerror(terrno));
C
Cary Xu 已提交
34 35 36 37
  }
  // TODO: destroy SSDataBlocks(msg)
  return code;
}
C
Cary Xu 已提交
38

L
Liu Jicong 已提交
39
int32_t tdUpdateExpireWindow(SSma* pSma, const SSubmitReq* pMsg, int64_t version) {
C
Cary Xu 已提交
40 41
  int32_t code = TSDB_CODE_SUCCESS;
  if ((code = tdUpdateExpiredWindowImpl(pSma, pMsg, version)) < 0) {
S
Shengliang Guan 已提交
42
    smaWarn("vgId:%d, update expired sma window failed since %s", SMA_VID(pSma), tstrerror(terrno));
C
Cary Xu 已提交
43 44 45 46 47 48 49
  }
  return code;
}

int32_t tdGetTSmaData(SSma* pSma, char* pData, int64_t indexUid, TSKEY querySKey, int32_t nMaxResult) {
  int32_t code = TSDB_CODE_SUCCESS;
  if ((code = tdGetTSmaDataImpl(pSma, pData, indexUid, querySKey, nMaxResult)) < 0) {
S
Shengliang Guan 已提交
50
    smaWarn("vgId:%d, get tSma data failed since %s", SMA_VID(pSma), tstrerror(terrno));
C
Cary Xu 已提交
51 52 53
  }
  return code;
}
C
Cary Xu 已提交
54 55 56 57 58 59 60 61

int32_t smaGetTSmaDays(SVnodeCfg* pCfg, void* pCont, uint32_t contLen, int32_t *days) {
  int32_t code = TSDB_CODE_SUCCESS;
  if ((code = tdGetTSmaDaysImpl(pCfg, pCont, contLen, days)) < 0) {
    smaWarn("vgId:%d get tSma days failed since %s", pCfg->vgId, tstrerror(terrno));
  }
  return code;
}