tfill.h 3.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*
 * 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_TFILL_H
#define TDENGINE_TFILL_H

#ifdef __cplusplus
extern "C" {
#endif

#include "os.h"
#include "taosdef.h"
25
#include "tcommon.h"
26 27 28

struct SSDataBlock;

29
typedef struct SFillColInfo {
30 31 32 33
  SExprInfo *pExpr;
  int16_t    flag;            // column flag: TAG COLUMN|NORMAL COLUMN
  int16_t    tagIndex;        // index of current tag in SFillTagColInfo array list
  SVariant   fillVal;
34 35 36 37 38 39 40 41 42 43 44
} SFillColInfo;

typedef struct {
  SSchema col;
  char*   tagVal;
} SFillTagColInfo;
  
typedef struct SFillInfo {
  TSKEY     start;                // start timestamp
  TSKEY     end;                  // endKey for fill
  TSKEY     currentKey;           // current active timestamp, the value may be changed during the fill procedure.
45
  int32_t   tsSlotId;             // primary time stamp slot id
46 47 48 49 50 51 52 53 54 55 56
  int32_t   order;                // order [TSDB_ORDER_ASC|TSDB_ORDER_DESC]
  int32_t   type;                 // fill type
  int32_t   numOfRows;            // number of rows in the input data block
  int32_t   index;                // active row index
  int32_t   numOfTotal;           // number of filled rows in one round
  int32_t   numOfCurrent;         // number of filled rows in current results

  int32_t   numOfTags;            // number of tags
  int32_t   numOfCols;            // number of columns, including the tags columns
  int32_t   rowSize;              // size of each row
  SInterval interval;
57 58 59 60

  SArray   *prev;
  SArray   *next;
  SSDataBlock *pSrcBlock;
61 62 63 64
  int32_t   alloc;                // data buffer size in rows

  SFillColInfo* pFillCol;         // column info for fill operations
  SFillTagColInfo* pTags;         // tags value for filling gap
H
Haojun Liao 已提交
65
  const char* id;
66 67
} SFillInfo;

68
int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, int64_t ekey, int32_t maxNumOfRows);
69 70


71 72 73
void taosFillSetStartInfo(struct SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey);
void taosResetFillInfo(struct SFillInfo* pFillInfo, TSKEY startTimestamp);
void taosFillSetInputDataBlock(struct SFillInfo* pFillInfo, const struct SSDataBlock* pInput);
74
struct SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, const struct SNodeListNode* val);
75
bool taosFillHasMoreResults(struct SFillInfo* pFillInfo);
76

77
SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols,
78 79
                              SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol, int32_t slotId,
                              const char* id);
80 81

void* taosDestroyFillInfo(struct SFillInfo *pFillInfo);
82
int64_t taosFillResultDataBlock(struct SFillInfo* pFillInfo, SSDataBlock* p, int32_t capacity);
83
int64_t getFillInfoStart(struct SFillInfo *pFillInfo);
84 85 86 87 88 89 90


#ifdef __cplusplus
}
#endif

#endif  // TDENGINE_TFILL_H