qFill.h 3.4 KB
Newer Older
H
hzcheng 已提交
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/>.
 */

H
Haojun Liao 已提交
16 17
#ifndef TDENGINE_QFILL_H
#define TDENGINE_QFILL_H
H
hzcheng 已提交
18 19 20 21 22

#ifdef __cplusplus
extern "C" {
#endif

23
#include "os.h"
H
Haojun Liao 已提交
24
#include "qExtbuffer.h"
25 26
#include "taosdef.h"

27 28 29 30
typedef struct {
  STColumn col;             // column info
  int16_t  functionId;      // sql function id
  int16_t  flag;            // column flag: TAG COLUMN|NORMAL COLUMN
31
  union {int64_t i; double d;} fillVal;
32
} SFillColInfo;
33 34 35 36 37

typedef struct {
  SSchema col;
  char*   tagVal;
} SFillTagColInfo;
38 39 40 41 42 43 44 45 46 47 48 49 50 51
  
typedef struct SFillInfo {
  TSKEY   start;                // start timestamp
  TSKEY   endKey;               // endKey for fill
  int32_t order;                // order [TSDB_ORDER_ASC|TSDB_ORDER_DESC]
  int32_t fillType;             // fill type
  int32_t numOfRows;            // number of rows in the input data block
  int32_t rowIdx;               // rowIdx
  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
52 53
//  char ** pTags;                // tags value for current interpolation
  SFillTagColInfo* pTags;       // tags value for filling gap
54
  SInterval interval;
55
  char *  prevValues;           // previous row of data, to generate the interpolation results
H
hzcheng 已提交
56
  char *  nextValues;           // next row of data
H
Haojun Liao 已提交
57 58
  char**  pData;                // original result data block involved in filling data
  int32_t capacityInRows;       // data buffer size in rows
H
Haojun Liao 已提交
59
  int8_t  precision;            // time resoluation
60 61
  SFillColInfo* pFillCol;       // column info for fill operations
} SFillInfo;
H
hzcheng 已提交
62 63 64 65 66 67

typedef struct SPoint {
  int64_t key;
  void *  val;
} SPoint;

H
Haojun Liao 已提交
68 69 70
SFillInfo* taosInitFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols,
                            int64_t slidingTime, int8_t slidingUnit, int8_t precision, int32_t fillType,
                            SFillColInfo* pFillCol);
H
hzcheng 已提交
71

72
void taosResetFillInfo(SFillInfo* pFillInfo, TSKEY startTimestamp);
H
hjxilinx 已提交
73

H
Haojun Liao 已提交
74
void* taosDestoryFillInfo(SFillInfo *pFillInfo);
H
hzcheng 已提交
75

76
void taosFillSetStartInfo(SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey);
H
hzcheng 已提交
77

78
void taosFillCopyInputDataFromFilePage(SFillInfo* pFillInfo, tFilePage** pInput);
H
hzcheng 已提交
79

80
void taosFillCopyInputDataFromOneFilePage(SFillInfo* pFillInfo, tFilePage* pInput);
H
hzcheng 已提交
81

H
Haojun Liao 已提交
82
int64_t getFilledNumOfRes(SFillInfo* pFillInfo, int64_t ekey, int32_t maxNumOfRows);
H
hzcheng 已提交
83

84 85
int32_t taosNumOfRemainRows(SFillInfo *pFillInfo);

H
hzcheng 已提交
86 87
int taosDoLinearInterpolation(int32_t type, SPoint *point1, SPoint *point2, SPoint *point);

88
int64_t taosGenerateDataBlock(SFillInfo* pFillInfo, tFilePage** output, int32_t capacity);
89

H
hzcheng 已提交
90 91 92 93
#ifdef __cplusplus
}
#endif

H
Haojun Liao 已提交
94
#endif  // TDENGINE_QFILL_H