提交 59462d35 编写于 作者: A Alex Duan

new ASSERT add tdiest.c and tcompression.c

上级 232c4f4a
...@@ -470,7 +470,7 @@ int32_t tsDecompressStringImp(const char *const input, int32_t compressedSize, c ...@@ -470,7 +470,7 @@ int32_t tsDecompressStringImp(const char *const input, int32_t compressedSize, c
// TODO: Take care here, we assumes little endian encoding. // TODO: Take care here, we assumes little endian encoding.
int32_t tsCompressTimestampImp(const char *const input, const int32_t nelements, char *const output) { int32_t tsCompressTimestampImp(const char *const input, const int32_t nelements, char *const output) {
int32_t _pos = 1; int32_t _pos = 1;
assert(nelements >= 0); ASSERTS(nelements >= 0, "nelements is negative");
if (nelements == 0) return 0; if (nelements == 0) return 0;
...@@ -565,7 +565,7 @@ _exit_over: ...@@ -565,7 +565,7 @@ _exit_over:
} }
int32_t tsDecompressTimestampImp(const char *const input, const int32_t nelements, char *const output) { int32_t tsDecompressTimestampImp(const char *const input, const int32_t nelements, char *const output) {
assert(nelements >= 0); ASSERTS(nelements >= 0, "nelements is negative");
if (nelements == 0) return 0; if (nelements == 0) return 0;
if (input[0] == 0) { if (input[0] == 0) {
...@@ -629,7 +629,7 @@ int32_t tsDecompressTimestampImp(const char *const input, const int32_t nelement ...@@ -629,7 +629,7 @@ int32_t tsDecompressTimestampImp(const char *const input, const int32_t nelement
} }
} else { } else {
assert(0); ASSERT(0);
return -1; return -1;
} }
} }
...@@ -2146,7 +2146,7 @@ int32_t tsCompressTimestamp(void *pIn, int32_t nIn, int32_t nEle, void *pOut, in ...@@ -2146,7 +2146,7 @@ int32_t tsCompressTimestamp(void *pIn, int32_t nIn, int32_t nEle, void *pOut, in
int32_t len = tsCompressTimestampImp(pIn, nEle, pBuf); int32_t len = tsCompressTimestampImp(pIn, nEle, pBuf);
return tsCompressStringImp(pBuf, len, pOut, nOut); return tsCompressStringImp(pBuf, len, pOut, nOut);
} else { } else {
assert(0); ASSERTS(0, "compress algo not one or two stage");
return -1; return -1;
} }
} }
...@@ -2159,7 +2159,7 @@ int32_t tsDecompressTimestamp(void *pIn, int32_t nIn, int32_t nEle, void *pOut, ...@@ -2159,7 +2159,7 @@ int32_t tsDecompressTimestamp(void *pIn, int32_t nIn, int32_t nEle, void *pOut,
if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1;
return tsDecompressTimestampImp(pBuf, nEle, pOut); return tsDecompressTimestampImp(pBuf, nEle, pOut);
} else { } else {
assert(0); ASSERTS(0, "compress algo invalid");
return -1; return -1;
} }
} }
...@@ -2180,7 +2180,7 @@ int32_t tsCompressFloat(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_ ...@@ -2180,7 +2180,7 @@ int32_t tsCompressFloat(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_
int32_t len = tsCompressFloatImp(pIn, nEle, pBuf); int32_t len = tsCompressFloatImp(pIn, nEle, pBuf);
return tsCompressStringImp(pBuf, len, pOut, nOut); return tsCompressStringImp(pBuf, len, pOut, nOut);
} else { } else {
assert(0); ASSERTS(0, "compress algo invalid");
return -1; return -1;
} }
#ifdef TD_TSZ #ifdef TD_TSZ
...@@ -2203,7 +2203,7 @@ int32_t tsDecompressFloat(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int3 ...@@ -2203,7 +2203,7 @@ int32_t tsDecompressFloat(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int3
if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1;
return tsDecompressFloatImp(pBuf, nEle, pOut); return tsDecompressFloatImp(pBuf, nEle, pOut);
} else { } else {
assert(0); ASSERTS(0, "compress algo invalid");
return -1; return -1;
} }
#ifdef TD_TSZ #ifdef TD_TSZ
...@@ -2227,7 +2227,7 @@ int32_t tsCompressDouble(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32 ...@@ -2227,7 +2227,7 @@ int32_t tsCompressDouble(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32
int32_t len = tsCompressDoubleImp(pIn, nEle, pBuf); int32_t len = tsCompressDoubleImp(pIn, nEle, pBuf);
return tsCompressStringImp(pBuf, len, pOut, nOut); return tsCompressStringImp(pBuf, len, pOut, nOut);
} else { } else {
assert(0); ASSERTS(0, "compress algo invalid");
return -1; return -1;
} }
#ifdef TD_TSZ #ifdef TD_TSZ
...@@ -2250,7 +2250,7 @@ int32_t tsDecompressDouble(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int ...@@ -2250,7 +2250,7 @@ int32_t tsDecompressDouble(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int
if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1;
return tsDecompressDoubleImp(pBuf, nEle, pOut); return tsDecompressDoubleImp(pBuf, nEle, pOut);
} else { } else {
assert(0); ASSERTS(0, "compress algo invalid");
return -1; return -1;
} }
#ifdef TD_TSZ #ifdef TD_TSZ
...@@ -2281,7 +2281,7 @@ int32_t tsCompressBool(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t ...@@ -2281,7 +2281,7 @@ int32_t tsCompressBool(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t
} }
return tsCompressStringImp(pBuf, len, pOut, nOut); return tsCompressStringImp(pBuf, len, pOut, nOut);
} else { } else {
assert(0); ASSERTS(0, "compress algo invalid");
return -1; return -1;
} }
} }
...@@ -2294,7 +2294,7 @@ int32_t tsDecompressBool(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32 ...@@ -2294,7 +2294,7 @@ int32_t tsDecompressBool(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32
if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1;
return tsDecompressBoolImp(pBuf, nEle, pOut); return tsDecompressBoolImp(pBuf, nEle, pOut);
} else { } else {
assert(0); ASSERTS(0, "compress algo invalid");
return -1; return -1;
} }
} }
...@@ -2308,7 +2308,7 @@ int32_t tsCompressTinyint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int3 ...@@ -2308,7 +2308,7 @@ int32_t tsCompressTinyint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int3
int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_TINYINT); int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_TINYINT);
return tsCompressStringImp(pBuf, len, pOut, nOut); return tsCompressStringImp(pBuf, len, pOut, nOut);
} else { } else {
assert(0); ASSERTS(0, "compress algo invalid");
return -1; return -1;
} }
} }
...@@ -2321,7 +2321,7 @@ int32_t tsDecompressTinyint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, in ...@@ -2321,7 +2321,7 @@ int32_t tsDecompressTinyint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, in
if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1;
return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_TINYINT); return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_TINYINT);
} else { } else {
assert(0); ASSERTS(0, "compress algo invalid");
return -1; return -1;
} }
} }
...@@ -2335,7 +2335,7 @@ int32_t tsCompressSmallint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int ...@@ -2335,7 +2335,7 @@ int32_t tsCompressSmallint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int
int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_SMALLINT); int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_SMALLINT);
return tsCompressStringImp(pBuf, len, pOut, nOut); return tsCompressStringImp(pBuf, len, pOut, nOut);
} else { } else {
assert(0); ASSERTS(0, "compress algo invalid");
return -1; return -1;
} }
} }
...@@ -2348,7 +2348,7 @@ int32_t tsDecompressSmallint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, i ...@@ -2348,7 +2348,7 @@ int32_t tsDecompressSmallint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, i
if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1;
return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_SMALLINT); return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_SMALLINT);
} else { } else {
assert(0); ASSERTS(0, "compress algo invalid");
return -1; return -1;
} }
} }
...@@ -2362,7 +2362,7 @@ int32_t tsCompressInt(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t ...@@ -2362,7 +2362,7 @@ int32_t tsCompressInt(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t
int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_INT); int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_INT);
return tsCompressStringImp(pBuf, len, pOut, nOut); return tsCompressStringImp(pBuf, len, pOut, nOut);
} else { } else {
assert(0); ASSERTS(0, "compress algo invalid");
return -1; return -1;
} }
} }
...@@ -2375,7 +2375,7 @@ int32_t tsDecompressInt(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_ ...@@ -2375,7 +2375,7 @@ int32_t tsDecompressInt(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_
if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1;
return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_INT); return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_INT);
} else { } else {
assert(0); ASSERTS(0, "compress algo invalid");
return -1; return -1;
} }
} }
...@@ -2389,7 +2389,7 @@ int32_t tsCompressBigint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32 ...@@ -2389,7 +2389,7 @@ int32_t tsCompressBigint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32
int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_BIGINT); int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_BIGINT);
return tsCompressStringImp(pBuf, len, pOut, nOut); return tsCompressStringImp(pBuf, len, pOut, nOut);
} else { } else {
assert(0); ASSERTS(0, "compress algo invalid");
return -1; return -1;
} }
} }
...@@ -2402,7 +2402,7 @@ int32_t tsDecompressBigint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int ...@@ -2402,7 +2402,7 @@ int32_t tsDecompressBigint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int
if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1;
return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_BIGINT); return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_BIGINT);
} else { } else {
assert(0); ASSERTS(0, "compress algo invalid");
return -1; return -1;
} }
} }
...@@ -135,24 +135,24 @@ void tdigestCompress(TDigest *t) { ...@@ -135,24 +135,24 @@ void tdigestCompress(TDigest *t) {
if (a->mean <= b->mean) { if (a->mean <= b->mean) {
mergeCentroid(&args, a); mergeCentroid(&args, a);
assert(args.idx < t->size); ASSERTS(args.idx < t->size, "idx over size");
i++; i++;
} else { } else {
mergeCentroid(&args, b); mergeCentroid(&args, b);
assert(args.idx < t->size); ASSERTS(args.idx < t->size, "idx over size");
j++; j++;
} }
} }
while (i < num_unmerged) { while (i < num_unmerged) {
mergeCentroid(&args, &unmerged_centroids[i++]); mergeCentroid(&args, &unmerged_centroids[i++]);
assert(args.idx < t->size); ASSERTS(args.idx < t->size, "idx over size");
} }
taosMemoryFree((void *)unmerged_centroids); taosMemoryFree((void *)unmerged_centroids);
while (j < t->num_centroids) { while (j < t->num_centroids) {
mergeCentroid(&args, &t->centroids[j++]); mergeCentroid(&args, &t->centroids[j++]);
assert(args.idx < t->size); ASSERTS(args.idx < t->size, "idx over size");
} }
if (t->total_weight > 0) { if (t->total_weight > 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册