fix tsma test
This commit is contained in:
parent
b10beaa035
commit
844a01a751
|
@ -1977,7 +1977,7 @@ static int8_t UNIT_INDEX[26] = {/*a*/ 2, 0, -1, 6, -1, -1, -1,
|
|||
|
||||
#define GET_UNIT_INDEX(idx) UNIT_INDEX[(idx) - 97]
|
||||
|
||||
static int64_t MATRIX[10][11] = { /* ns, us, ms, s, min, h, d, w, month, y*/
|
||||
static int64_t UNIT_MATRIX[10][11] = { /* ns, us, ms, s, min, h, d, w, month, y*/
|
||||
/*ns*/ { 1, 1000, 0},
|
||||
/*us*/ {1000, 1, 1000, 0},
|
||||
/*ms*/ { 0, 1000, 1, 1000, 0},
|
||||
|
@ -1990,18 +1990,18 @@ static int64_t MATRIX[10][11] = { /* ns, us, ms, s, min, h, d,
|
|||
/*y*/ { 0, 0, 0, 0, 0, 0, 0, 0, 12, 1, 0}};
|
||||
|
||||
static bool recursiveTsmaCheckRecursive(int64_t baseInterval, int8_t baseIdx, int64_t interval, int8_t idx, bool checkEq) {
|
||||
if (MATRIX[baseIdx][idx] == -1) return false;
|
||||
if (UNIT_MATRIX[baseIdx][idx] == -1) return false;
|
||||
if (baseIdx == idx) {
|
||||
if (interval < baseInterval) return false;
|
||||
if (checkEq && interval == baseInterval) return false;
|
||||
return interval % baseInterval == 0;
|
||||
}
|
||||
int8_t next = baseIdx + 1;
|
||||
int64_t val = MATRIX[baseIdx][next];
|
||||
int64_t val = UNIT_MATRIX[baseIdx][next];
|
||||
while (val != 0 && next <= idx) {
|
||||
if (val == -1) {
|
||||
next++;
|
||||
val = MATRIX[baseIdx][next];
|
||||
val = UNIT_MATRIX[baseIdx][next];
|
||||
continue;
|
||||
}
|
||||
if (val % baseInterval == 0 || baseInterval % val == 0) {
|
||||
|
@ -2009,7 +2009,7 @@ static bool recursiveTsmaCheckRecursive(int64_t baseInterval, int8_t baseIdx, in
|
|||
bool needCheckEq = baseInterval >= val && !(baseIdx < next && val == 1);
|
||||
if (!recursiveTsmaCheckRecursive(baseInterval / val + extra, next, interval, idx, needCheckEq && checkEq)) {
|
||||
next++;
|
||||
val = MATRIX[baseIdx][next];
|
||||
val = UNIT_MATRIX[baseIdx][next];
|
||||
continue;
|
||||
} else {
|
||||
return true;
|
||||
|
@ -2022,7 +2022,7 @@ static bool recursiveTsmaCheckRecursive(int64_t baseInterval, int8_t baseIdx, in
|
|||
}
|
||||
|
||||
static bool recursiveTsmaCheckRecursiveReverse(int64_t baseInterval, int8_t baseIdx, int64_t interval, int8_t idx, bool checkEq) {
|
||||
if (MATRIX[baseIdx][idx] == -1) return false;
|
||||
if (UNIT_MATRIX[baseIdx][idx] == -1) return false;
|
||||
|
||||
if (baseIdx == idx) {
|
||||
if (interval < baseInterval) return false;
|
||||
|
@ -2031,7 +2031,7 @@ static bool recursiveTsmaCheckRecursiveReverse(int64_t baseInterval, int8_t base
|
|||
}
|
||||
|
||||
int8_t next = baseIdx - 1;
|
||||
int64_t val = MATRIX[baseIdx][next];
|
||||
int64_t val = UNIT_MATRIX[baseIdx][next];
|
||||
while (val != 0 && next >= 0) {
|
||||
return recursiveTsmaCheckRecursiveReverse(baseInterval * val, next, interval, idx, checkEq);
|
||||
}
|
||||
|
@ -2044,7 +2044,8 @@ static bool recursiveTsmaCheckRecursiveReverse(int64_t baseInterval, int8_t base
|
|||
* @param interval the tsma interval going to create. Not that if unit is not calander unit, then interval has already been
|
||||
* translated to TICKS of [precision]
|
||||
* @param unit the tsma unit going to create
|
||||
* @precision the precision of this db
|
||||
* @param precision the precision of this db
|
||||
* @param checkEq pass true if same interval is not acceptable, false if acceptable.
|
||||
* @ret true the tsma can be created, else cannot
|
||||
* */
|
||||
bool checkRecursiveTsmaInterval(int64_t baseInterval, int8_t baseUnit, int64_t interval, int8_t unit, int8_t precision, bool checkEq) {
|
||||
|
|
|
@ -1610,7 +1610,7 @@ class TDTestCase:
|
|||
|
||||
# def test_split_dnode(self):
|
||||
|
||||
def test_create_recursive_tsma_interval(self, db: str, tb: str, func: list[str], interval: str, recursive_interval: str, succ: bool, code: int):
|
||||
def test_create_recursive_tsma_interval(self, db: str, tb: str, func, interval: str, recursive_interval: str, succ: bool, code: int):
|
||||
self.create_tsma('tsma1', db, tb, func, interval)
|
||||
sql = f'CREATE RECURSIVE TSMA tsma2 ON tsma1 INTERVAL({recursive_interval})'
|
||||
if not succ:
|
||||
|
|
Loading…
Reference in New Issue