qinterpolation.h 3.3 KB
Newer Older
H
hzcheng 已提交
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_TINTERPOLATION_H
#define TDENGINE_TINTERPOLATION_H

#ifdef __cplusplus
extern "C" {
#endif

23 24 25 26
#include "os.h"
#include "taosdef.h"
#include "qextbuffer.h"

H
hzcheng 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
typedef struct SInterpolationInfo {
  int64_t startTimestamp;
  int32_t order;                // order [asc/desc]
  int32_t numOfRawDataInRows;   // number of points in pQuery->sdata
  int32_t rowIdx;               // rowIdx in pQuery->sdata
  int32_t numOfTotalInterpo;    // number of interpolated rows in one round
  int32_t numOfCurrentInterpo;  // number of interpolated rows in current results
  char *  prevValues;           // previous row of data
  char *  nextValues;           // next row of data
  int32_t numOfTags;
  char ** pTags;  // tags value for current interoplation
} SInterpolationInfo;

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

H
hjxilinx 已提交
45
int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t timeRange, char intervalTimeUnit, int16_t precision);
H
hzcheng 已提交
46 47 48 49

void taosInitInterpoInfo(SInterpolationInfo *pInterpoInfo, int32_t order, int64_t startTimeStamp, int32_t numOfTags,
                         int32_t rowSize);

H
hjxilinx 已提交
50 51
void taosDestoryInterpoInfo(SInterpolationInfo *pInterpoInfo);

H
hzcheng 已提交
52 53
void taosInterpoSetStartInfo(SInterpolationInfo *pInterpoInfo, int32_t numOfRawDataInRows, int32_t type);

H
hjxilinx 已提交
54
TSKEY taosGetRevisedEndKey(TSKEY ekey, int32_t order, int32_t timeInterval, int8_t intervalTimeUnit, int8_t precision);
H
hzcheng 已提交
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75

/**
 *
 * @param pInterpoInfo
 * @param pPrimaryKeyArray
 * @param numOfRows
 * @param nInterval
 * @param ekey
 * @param maxNumOfRows
 * @return
 */
int32_t taosGetNumOfResultWithInterpo(SInterpolationInfo *pInterpoInfo, int64_t *pPrimaryKeyArray, int32_t numOfRows,
                                      int64_t nInterval, int64_t ekey, int32_t maxNumOfRows);

int32_t taosGetNumOfResWithoutLimit(SInterpolationInfo *pInterpoInfo, int64_t *pPrimaryKeyArray,
                                    int32_t numOfRawDataInRows, int64_t nInterval, int64_t ekey);
/**
 *
 * @param pInterpoInfo
 * @return
 */
S
slguan 已提交
76
bool taosHasRemainsDataForInterpolation(SInterpolationInfo *pInterpoInfo);
H
hzcheng 已提交
77 78 79 80 81 82 83 84

int32_t taosNumOfRemainPoints(SInterpolationInfo *pInterpoInfo);

/**
 *
 */
int32_t taosDoInterpoResult(SInterpolationInfo *pInterpoInfo, int16_t interpoType, tFilePage **data,
                            int32_t numOfRawDataInRows, int32_t outputRows, int64_t nInterval,
H
hjxilinx 已提交
85
                            const int64_t *pPrimaryKeyArray, SColumnModel *pModel, char **srcData, int64_t *defaultVal,
H
hjxilinx 已提交
86
                            const int32_t *functionIDs, int32_t bufSize);
H
hzcheng 已提交
87 88 89 90 91 92 93 94

int taosDoLinearInterpolation(int32_t type, SPoint *point1, SPoint *point2, SPoint *point);

#ifdef __cplusplus
}
#endif

#endif  // TDENGINE_TINTERPOLATION_H