tep.h 3.8 KB
Newer Older
1 2 3
#ifndef TDENGINE_TEP_H
#define TDENGINE_TEP_H

H
Haojun Liao 已提交
4 5 6 7
#ifdef __cplusplus
extern "C" {
#endif

8
#include "os.h"
H
Hongze Cheng 已提交
9
#include "tmsg.h"
H
Haojun Liao 已提交
10
#include "common.h"
11 12 13 14 15 16

typedef struct SCorEpSet {
  int32_t version;
  SEpSet  epSet;
} SCorEpSet;

H
Haojun Liao 已提交
17
typedef struct SBlockOrderInfo {
H
Haojun Liao 已提交
18 19 20
  int32_t          order;
  int32_t          colIndex;
  SColumnInfoData *pColData;
H
Haojun Liao 已提交
21 22
} SBlockOrderInfo;

S
Shengliang Guan 已提交
23
int  taosGetFqdnPortFromEp(const char *ep, SEp *pEp);
H
Haojun Liao 已提交
24 25
void addEpIntoEpSet(SEpSet *pEpSet, const char *fqdn, uint16_t port);

26 27
bool isEpsetEqual(const SEpSet *s1, const SEpSet *s2);

H
Haojun Liao 已提交
28
void   updateEpSet_s(SCorEpSet *pEpSet, SEpSet *pNewEpSet);
29
SEpSet getEpSet_s(SCorEpSet *pEpSet);
30

H
Haojun Liao 已提交
31
#define NBIT                     (3u)
H
Haojun Liao 已提交
32
#define BitPos(_n)               ((_n) & ((1 << NBIT) - 1))
H
Haojun Liao 已提交
33 34
#define BMCharPos(bm_, r_)       ((bm_)[(r_) >> NBIT])
#define colDataIsNull_f(bm_, r_) ((BMCharPos(bm_, r_) & (1u << (7u - BitPos(r_)))) == (1u << (7u - BitPos(r_))))
35

H
Haojun Liao 已提交
36 37 38 39
#define colDataSetNull_f(bm_, r_)                    \
  do {                                               \
    BMCharPos(bm_, r_) |= (1u << (7u - BitPos(r_))); \
  } while (0)
H
Haojun Liao 已提交
40

41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
static FORCE_INLINE bool colDataIsNull(const SColumnInfoData* pColumnInfoData, uint32_t totalRows, uint32_t row, SColumnDataAgg* pColAgg) {
  if (!pColumnInfoData->hasNull) {
    return false;
  }

  if (pColAgg != NULL) {
    if (pColAgg->numOfNull == totalRows) {
      ASSERT(pColumnInfoData->nullbitmap == NULL);
      return true;
    } else if (pColAgg->numOfNull == 0) {
      ASSERT(pColumnInfoData->nullbitmap == NULL);
      return false;
    }
  }

  if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
    return pColumnInfoData->varmeta.offset[row] == -1;
  } else {
    if (pColumnInfoData->nullbitmap == NULL) {
      return false;
    }

    return colDataIsNull_f(pColumnInfoData->nullbitmap, row);
  }
}

67
#define colDataGetData(p1_, r_)                                                          \
H
Haojun Liao 已提交
68
  ((IS_VAR_DATA_TYPE((p1_)->info.type)) ? (p1_)->pData + (p1_)->varmeta.offset[(r_)] \
69
                                        : (p1_)->pData + ((r_) * (p1_)->info.bytes))
H
Haojun Liao 已提交
70 71 72

int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull);
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, const SColumnInfoData* pSource, uint32_t numOfRow2);
H
Haojun Liao 已提交
73
int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock);
H
Haojun Liao 已提交
74

75 76
int32_t colDataGetLength(const SColumnInfoData* pColumnInfoData, int32_t numOfRows);
void    colDataTrim(SColumnInfoData* pColumnInfoData);
H
Haojun Liao 已提交
77 78 79 80 81 82

size_t colDataGetNumOfCols(const SSDataBlock* pBlock);
size_t colDataGetNumOfRows(const SSDataBlock* pBlock);

int32_t blockDataMerge(SSDataBlock* pDest, const SSDataBlock* pSrc);
int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startIndex, int32_t* stopIndex, int32_t pageSize);
83 84
SSDataBlock* blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int32_t rowCount);

H
Haojun Liao 已提交
85
int32_t blockDataToBuf(char* buf, const SSDataBlock* pBlock);
86
int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf);
H
Haojun Liao 已提交
87 88 89

size_t blockDataGetSize(const SSDataBlock* pBlock);
size_t blockDataGetRowSize(const SSDataBlock* pBlock);
H
Haojun Liao 已提交
90 91 92
double blockDataGetSerialRowSize(const SSDataBlock* pBlock);
size_t blockDataGetSerialMetaSize(const SSDataBlock* pBlock);

93 94
SSchema* blockDataExtractSchema(const SSDataBlock* pBlock, int32_t* numOfCols);

H
Haojun Liao 已提交
95
int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirst);
H
Haojun Liao 已提交
96
int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirst);
H
Haojun Liao 已提交
97

98 99
int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows);
void    blockDataClearup(SSDataBlock* pDataBlock, bool hasVarCol);
100 101
SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock);
size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize);
H
Haojun Liao 已提交
102
void   *blockDataDestroy(SSDataBlock *pBlock);
103

H
Haojun Liao 已提交
104 105 106 107
#ifdef __cplusplus
}
#endif

108
#endif  // TDENGINE_TEP_H