parInsertUtil.h 2.7 KB
Newer Older
X
Xiaoyu Wang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 * 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/>.
 */

#ifndef TDENGINE_PAR_INSERT_UTIL_H
#define TDENGINE_PAR_INSERT_UTIL_H

#include "parUtil.h"

struct SToken;

X
Xiaoyu Wang 已提交
23 24 25 26 27
#define NEXT_TOKEN(pSql, sToken)                      \
  do {                                                \
    int32_t index = 0;                                \
    sToken = tStrGetToken(pSql, &index, false, NULL); \
    pSql += index;                                    \
X
Xiaoyu Wang 已提交
28 29 30 31 32 33 34 35 36 37
  } while (0)

#define CHECK_CODE(expr)             \
  do {                               \
    int32_t code = expr;             \
    if (TSDB_CODE_SUCCESS != code) { \
      return code;                   \
    }                                \
  } while (0)

X
Xiaoyu Wang 已提交
38
typedef struct SVgroupDataCxt {
X
Xiaoyu Wang 已提交
39 40
  int32_t      vgId;
  SSubmitReq2 *pData;
X
Xiaoyu Wang 已提交
41 42
} SVgroupDataCxt;

X
Xiaoyu Wang 已提交
43 44 45 46
int32_t insCreateSName(SName *pName, struct SToken *pTableName, int32_t acctId, const char *dbName, SMsgBuf *pMsgBuf);
int16_t insFindCol(struct SToken *pColname, int16_t start, int16_t end, SSchema *pSchema);
void    insBuildCreateTbReq(SVCreateTbReq *pTbReq, const char *tname, STag *pTag, int64_t suid, const char *sname,
                            SArray *tagName, uint8_t tagNum, int32_t ttl);
X
Xiaoyu Wang 已提交
47
int32_t insInitBoundColsInfo(int32_t numOfBound, SBoundColInfo *pInfo);
X
Xiaoyu Wang 已提交
48
void    insCheckTableDataOrder(STableDataCxt *pTableCxt, TSKEY tsKey);
X
Xiaoyu Wang 已提交
49
int32_t insGetTableDataCxt(SHashObj *pHash, void *id, int32_t idLen, STableMeta *pTableMeta,
D
dapan1121 已提交
50
                           SVCreateTbReq **pCreateTbReq, STableDataCxt **pTableCxt, bool colMode);
X
Xiaoyu Wang 已提交
51
int32_t initTableColSubmitData(STableDataCxt *pTableCxt);
X
Xiaoyu Wang 已提交
52 53 54 55 56 57
int32_t insMergeTableDataCxt(SHashObj *pTableHash, SArray **pVgDataBlocks);
int32_t insBuildVgDataBlocks(SHashObj *pVgroupsHashObj, SArray *pVgDataBlocks, SArray **pDataBlocks);
void    insDestroyTableDataCxtHashMap(SHashObj *pTableCxtHash);
void    insDestroyVgroupDataCxt(SVgroupDataCxt *pVgCxt);
void    insDestroyVgroupDataCxtList(SArray *pVgCxtList);
void    insDestroyVgroupDataCxtHashMap(SHashObj *pVgCxtHash);
X
Xiaoyu Wang 已提交
58 59 60
void    insDestroyTableDataCxt(STableDataCxt *pTableCxt);
void    insDestroyBoundColInfo(SBoundColInfo *pInfo);

X
Xiaoyu Wang 已提交
61
#endif  // TDENGINE_PAR_INSERT_UTIL_H