提交 215883ea 编写于 作者: H Hongze Cheng

refact code

上级 678f9da4
...@@ -333,10 +333,10 @@ typedef struct tDataTypeDescriptor { ...@@ -333,10 +333,10 @@ typedef struct tDataTypeDescriptor {
char *name; char *name;
int64_t minValue; int64_t minValue;
int64_t maxValue; int64_t maxValue;
int32_t (*compFunc)(const char *const input, int32_t inputSize, const int32_t nelements, char *const output, int32_t (*compFunc)(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize); int32_t nBuf);
int32_t (*decompFunc)(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output, int32_t (*decompFunc)(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize); int32_t nBuf);
void (*statisFunc)(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numofrow, int64_t *min, void (*statisFunc)(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numofrow, int64_t *min,
int64_t *max, int64_t *sum, int16_t *minindex, int16_t *maxindex, int16_t *numofnull); int64_t *max, int64_t *sum, int16_t *minindex, int16_t *maxindex, int16_t *numofnull);
} tDataTypeDescriptor; } tDataTypeDescriptor;
...@@ -356,7 +356,6 @@ void operateVal(void *dst, void *s1, void *s2, int32_t optr, int32_t type); ...@@ -356,7 +356,6 @@ void operateVal(void *dst, void *s1, void *s2, int32_t optr, int32_t type);
void *getDataMin(int32_t type); void *getDataMin(int32_t type);
void *getDataMax(int32_t type); void *getDataMax(int32_t type);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -83,46 +83,42 @@ static FORCE_INLINE int32_t tsDecompressDoubleLossy(const char *const input, int ...@@ -83,46 +83,42 @@ static FORCE_INLINE int32_t tsDecompressDoubleLossy(const char *const input, int
#endif #endif
int32_t tsCompressTimestamp(const char *const input, int32_t inputSize, const int32_t nelements, char *const output, int32_t tsCompressTimestamp(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize); int32_t nBuf);
int32_t tsDecompressTimestamp(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg,
int32_t tsDecompressTimestamp(const char *const input, int32_t compressedSize, const int32_t nelements, void *pBuf, int32_t nBuf);
char *const output, int32_t outputSize, char algorithm, char *const buffer, int32_t tsCompressFloat(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t bufferSize); int32_t nBuf);
int32_t tsCompressFloat(const char *const input, int32_t inputSize, const int32_t nelements, char *const output, int32_t tsDecompressFloat(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize); int32_t nBuf);
int32_t tsDecompressFloat(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output, int32_t tsCompressDouble(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize); int32_t nBuf);
int32_t tsCompressDouble(const char *const input, int32_t inputSize, const int32_t nelements, char *const output, int32_t tsDecompressDouble(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize); int32_t nBuf);
int32_t tsDecompressDouble(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output, int32_t tsCompressString(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize); int32_t nBuf);
int32_t tsCompressString(const char *const input, int32_t inputSize, const int32_t nelements, char *const output, int32_t tsDecompressString(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize); int32_t nBuf);
int32_t tsDecompressString(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output, int32_t tsCompressBool(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize); int32_t nBuf);
int32_t tsCompressBool(const char *const input, int32_t inputSize, const int32_t nelements, char *const output, int32_t tsDecompressBool(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize); int32_t nBuf);
int32_t tsDecompressBool(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output, int32_t tsCompressTinyint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize); int32_t nBuf);
int32_t tsCompressTinyint(const char *const input, int32_t inputSize, const int32_t nelements, char *const output, int32_t tsDecompressTinyint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize); int32_t nBuf);
int32_t tsDecompressTinyint(const char *const input, int32_t compressedSize, const int32_t nelements, int32_t tsCompressSmallint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
char *const output, int32_t outputSize, char algorithm, char *const buffer, int32_t nBuf);
int32_t bufferSize); int32_t tsDecompressSmallint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg,
int32_t tsCompressSmallint(const char *const input, int32_t inputSize, const int32_t nelements, char *const output, void *pBuf, int32_t nBuf);
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize); int32_t tsCompressInt(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t tsDecompressSmallint(const char *const input, int32_t compressedSize, const int32_t nelements, int32_t nBuf);
char *const output, int32_t outputSize, char algorithm, char *const buffer, int32_t tsDecompressInt(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t bufferSize); int32_t nBuf);
int32_t tsCompressInt(const char *const input, int32_t inputSize, const int32_t nelements, char *const output, int32_t tsCompressBigint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize); int32_t nBuf);
int32_t tsDecompressInt(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output, int32_t tsDecompressBigint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize); int32_t nBuf);
int32_t tsCompressBigint(const char *const input, int32_t inputSize, const int32_t nelements, char *const output,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize);
int32_t tsDecompressBigint(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -1618,27 +1618,26 @@ int32_t tCompress(SCompressor *pCmprsor, const void *pData, int64_t nData) { ...@@ -1618,27 +1618,26 @@ int32_t tCompress(SCompressor *pCmprsor, const void *pData, int64_t nData) {
* REGULAR COMPRESSION * REGULAR COMPRESSION
*************************************************************************/ *************************************************************************/
// Timestamp ===================================================== // Timestamp =====================================================
int32_t tsCompressTimestamp(const char *const input, int32_t inputSize, const int32_t nelements, char *const output, int32_t tsCompressTimestamp(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize) { int32_t nBuf) {
if (algorithm == ONE_STAGE_COMP) { if (cmprAlg == ONE_STAGE_COMP) {
return tsCompressTimestampImp(input, nelements, output); return tsCompressTimestampImp(pIn, nEle, pOut);
} else if (algorithm == TWO_STAGE_COMP) { } else if (cmprAlg == TWO_STAGE_COMP) {
int32_t len = tsCompressTimestampImp(input, nelements, buffer); int32_t len = tsCompressTimestampImp(pIn, nEle, pBuf);
return tsCompressStringImp(buffer, len, output, outputSize); return tsCompressStringImp(pBuf, len, pOut, nOut);
} else { } else {
assert(0); assert(0);
return -1; return -1;
} }
} }
int32_t tsDecompressTimestamp(const char *const input, int32_t compressedSize, const int32_t nelements, int32_t tsDecompressTimestamp(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg,
char *const output, int32_t outputSize, char algorithm, char *const buffer, void *pBuf, int32_t nBuf) {
int32_t bufferSize) { if (cmprAlg == ONE_STAGE_COMP) {
if (algorithm == ONE_STAGE_COMP) { return tsDecompressTimestampImp(pIn, nEle, pOut);
return tsDecompressTimestampImp(input, nelements, output); } else if (cmprAlg == TWO_STAGE_COMP) {
} else if (algorithm == TWO_STAGE_COMP) { if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1;
if (tsDecompressStringImp(input, compressedSize, buffer, bufferSize) < 0) return -1; return tsDecompressTimestampImp(pBuf, nEle, pOut);
return tsDecompressTimestampImp(buffer, nelements, output);
} else { } else {
assert(0); assert(0);
return -1; return -1;
...@@ -1646,20 +1645,20 @@ int32_t tsDecompressTimestamp(const char *const input, int32_t compressedSize, c ...@@ -1646,20 +1645,20 @@ int32_t tsDecompressTimestamp(const char *const input, int32_t compressedSize, c
} }
// Float ===================================================== // Float =====================================================
int32_t tsCompressFloat(const char *const input, int32_t inputSize, const int32_t nelements, char *const output, int32_t tsCompressFloat(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize) { int32_t nBuf) {
#ifdef TD_TSZ #ifdef TD_TSZ
// lossy mode // lossy mode
if (lossyFloat) { if (lossyFloat) {
return tsCompressFloatLossyImp(input, nelements, output); return tsCompressFloatLossyImp(pIn, nEle, pOut);
// lossless mode // lossless mode
} else { } else {
#endif #endif
if (algorithm == ONE_STAGE_COMP) { if (cmprAlg == ONE_STAGE_COMP) {
return tsCompressFloatImp(input, nelements, output); return tsCompressFloatImp(pIn, nEle, pOut);
} else if (algorithm == TWO_STAGE_COMP) { } else if (cmprAlg == TWO_STAGE_COMP) {
int32_t len = tsCompressFloatImp(input, nelements, buffer); int32_t len = tsCompressFloatImp(pIn, nEle, pBuf);
return tsCompressStringImp(buffer, len, output, outputSize); return tsCompressStringImp(pBuf, len, pOut, nOut);
} else { } else {
assert(0); assert(0);
return -1; return -1;
...@@ -1669,20 +1668,20 @@ int32_t tsCompressFloat(const char *const input, int32_t inputSize, const int32_ ...@@ -1669,20 +1668,20 @@ int32_t tsCompressFloat(const char *const input, int32_t inputSize, const int32_
#endif #endif
} }
int32_t tsDecompressFloat(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output, int32_t tsDecompressFloat(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize) { int32_t nBuf) {
#ifdef TD_TSZ #ifdef TD_TSZ
if (HEAD_ALGO(input[0]) == ALGO_SZ_LOSSY) { if (HEAD_ALGO(pIn[0]) == ALGO_SZ_LOSSY) {
// decompress lossy // decompress lossy
return tsDecompressFloatLossyImp(input, compressedSize, nelements, output); return tsDecompressFloatLossyImp(pIn, nIn, nEle, pOut);
} else { } else {
#endif #endif
// decompress lossless // decompress lossless
if (algorithm == ONE_STAGE_COMP) { if (cmprAlg == ONE_STAGE_COMP) {
return tsDecompressFloatImp(input, nelements, output); return tsDecompressFloatImp(pIn, nEle, pOut);
} else if (algorithm == TWO_STAGE_COMP) { } else if (cmprAlg == TWO_STAGE_COMP) {
if (tsDecompressStringImp(input, compressedSize, buffer, bufferSize) < 0) return -1; if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1;
return tsDecompressFloatImp(buffer, nelements, output); return tsDecompressFloatImp(pBuf, nEle, pOut);
} else { } else {
assert(0); assert(0);
return -1; return -1;
...@@ -1693,20 +1692,20 @@ int32_t tsDecompressFloat(const char *const input, int32_t compressedSize, const ...@@ -1693,20 +1692,20 @@ int32_t tsDecompressFloat(const char *const input, int32_t compressedSize, const
} }
// Double ===================================================== // Double =====================================================
int32_t tsCompressDouble(const char *const input, int32_t inputSize, const int32_t nelements, char *const output, int32_t tsCompressDouble(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize) { int32_t nBuf) {
#ifdef TD_TSZ #ifdef TD_TSZ
if (lossyDouble) { if (lossyDouble) {
// lossy mode // lossy mode
return tsCompressDoubleLossyImp(input, nelements, output); return tsCompressDoubleLossyImp(pIn, nEle, pOut);
} else { } else {
#endif #endif
// lossless mode // lossless mode
if (algorithm == ONE_STAGE_COMP) { if (cmprAlg == ONE_STAGE_COMP) {
return tsCompressDoubleImp(input, nelements, output); return tsCompressDoubleImp(pIn, nEle, pOut);
} else if (algorithm == TWO_STAGE_COMP) { } else if (cmprAlg == TWO_STAGE_COMP) {
int32_t len = tsCompressDoubleImp(input, nelements, buffer); int32_t len = tsCompressDoubleImp(pIn, nEle, pBuf);
return tsCompressStringImp(buffer, len, output, outputSize); return tsCompressStringImp(pBuf, len, pOut, nOut);
} else { } else {
assert(0); assert(0);
return -1; return -1;
...@@ -1716,20 +1715,20 @@ int32_t tsCompressDouble(const char *const input, int32_t inputSize, const int32 ...@@ -1716,20 +1715,20 @@ int32_t tsCompressDouble(const char *const input, int32_t inputSize, const int32
#endif #endif
} }
int32_t tsDecompressDouble(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output, int32_t tsDecompressDouble(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize) { int32_t nBuf) {
#ifdef TD_TSZ #ifdef TD_TSZ
if (HEAD_ALGO(input[0]) == ALGO_SZ_LOSSY) { if (HEAD_ALGO(input[0]) == ALGO_SZ_LOSSY) {
// decompress lossy // decompress lossy
return tsDecompressDoubleLossyImp(input, compressedSize, nelements, output); return tsDecompressDoubleLossyImp(pIn, nIn, nEle, pOut);
} else { } else {
#endif #endif
// decompress lossless // decompress lossless
if (algorithm == ONE_STAGE_COMP) { if (cmprAlg == ONE_STAGE_COMP) {
return tsDecompressDoubleImp(input, nelements, output); return tsDecompressDoubleImp(pIn, nEle, pOut);
} else if (algorithm == TWO_STAGE_COMP) { } else if (cmprAlg == TWO_STAGE_COMP) {
if (tsDecompressStringImp(input, compressedSize, buffer, bufferSize) < 0) return -1; if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1;
return tsDecompressDoubleImp(buffer, nelements, output); return tsDecompressDoubleImp(pBuf, nEle, pOut);
} else { } else {
assert(0); assert(0);
return -1; return -1;
...@@ -1740,37 +1739,37 @@ int32_t tsDecompressDouble(const char *const input, int32_t compressedSize, cons ...@@ -1740,37 +1739,37 @@ int32_t tsDecompressDouble(const char *const input, int32_t compressedSize, cons
} }
// Binary ===================================================== // Binary =====================================================
int32_t tsCompressString(const char *const input, int32_t inputSize, const int32_t nelements, char *const output, int32_t tsCompressString(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize) { int32_t nBuf) {
return tsCompressStringImp(input, inputSize, output, outputSize); return tsCompressStringImp(pIn, nIn, pOut, nOut);
} }
int32_t tsDecompressString(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output, int32_t tsDecompressString(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize) { int32_t nBuf) {
return tsDecompressStringImp(input, compressedSize, output, outputSize); return tsDecompressStringImp(pIn, nIn, pOut, nOut);
} }
// Bool ===================================================== // Bool =====================================================
int32_t tsCompressBool(const char *const input, int32_t inputSize, const int32_t nelements, char *const output, int32_t tsCompressBool(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize) { int32_t nBuf) {
if (algorithm == ONE_STAGE_COMP) { if (cmprAlg == ONE_STAGE_COMP) {
return tsCompressBoolImp(input, nelements, output); return tsCompressBoolImp(pIn, nEle, pOut);
} else if (algorithm == TWO_STAGE_COMP) { } else if (cmprAlg == TWO_STAGE_COMP) {
int32_t len = tsCompressBoolImp(input, nelements, buffer); int32_t len = tsCompressBoolImp(pIn, nEle, pBuf);
return tsCompressStringImp(buffer, len, output, outputSize); return tsCompressStringImp(pBuf, len, pOut, nOut);
} else { } else {
assert(0); assert(0);
return -1; return -1;
} }
} }
int32_t tsDecompressBool(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output, int32_t tsDecompressBool(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize) { int32_t nBuf) {
if (algorithm == ONE_STAGE_COMP) { if (cmprAlg == ONE_STAGE_COMP) {
return tsDecompressBoolImp(input, nelements, output); return tsDecompressBoolImp(pIn, nEle, pOut);
} else if (algorithm == TWO_STAGE_COMP) { } else if (cmprAlg == TWO_STAGE_COMP) {
if (tsDecompressStringImp(input, compressedSize, buffer, bufferSize) < 0) return -1; if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1;
return tsDecompressBoolImp(buffer, nelements, output); return tsDecompressBoolImp(pBuf, nEle, pOut);
} else { } else {
assert(0); assert(0);
return -1; return -1;
...@@ -1778,27 +1777,26 @@ int32_t tsDecompressBool(const char *const input, int32_t compressedSize, const ...@@ -1778,27 +1777,26 @@ int32_t tsDecompressBool(const char *const input, int32_t compressedSize, const
} }
// Tinyint ===================================================== // Tinyint =====================================================
int32_t tsCompressTinyint(const char *const input, int32_t inputSize, const int32_t nelements, char *const output, int32_t tsCompressTinyint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize) { int32_t nBuf) {
if (algorithm == ONE_STAGE_COMP) { if (cmprAlg == ONE_STAGE_COMP) {
return tsCompressINTImp(input, nelements, output, TSDB_DATA_TYPE_TINYINT); return tsCompressINTImp(pIn, nEle, pOut, TSDB_DATA_TYPE_TINYINT);
} else if (algorithm == TWO_STAGE_COMP) { } else if (cmprAlg == TWO_STAGE_COMP) {
int32_t len = tsCompressINTImp(input, nelements, buffer, TSDB_DATA_TYPE_TINYINT); int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_TINYINT);
return tsCompressStringImp(buffer, len, output, outputSize); return tsCompressStringImp(pBuf, len, pOut, nOut);
} else { } else {
assert(0); assert(0);
return -1; return -1;
} }
} }
int32_t tsDecompressTinyint(const char *const input, int32_t compressedSize, const int32_t nelements, int32_t tsDecompressTinyint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
char *const output, int32_t outputSize, char algorithm, char *const buffer, int32_t nBuf) {
int32_t bufferSize) { if (cmprAlg == ONE_STAGE_COMP) {
if (algorithm == ONE_STAGE_COMP) { return tsDecompressINTImp(pIn, nEle, pOut, TSDB_DATA_TYPE_TINYINT);
return tsDecompressINTImp(input, nelements, output, TSDB_DATA_TYPE_TINYINT); } else if (cmprAlg == TWO_STAGE_COMP) {
} else if (algorithm == TWO_STAGE_COMP) { if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1;
if (tsDecompressStringImp(input, compressedSize, buffer, bufferSize) < 0) return -1; return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_TINYINT);
return tsDecompressINTImp(buffer, nelements, output, TSDB_DATA_TYPE_TINYINT);
} else { } else {
assert(0); assert(0);
return -1; return -1;
...@@ -1806,27 +1804,26 @@ int32_t tsDecompressTinyint(const char *const input, int32_t compressedSize, con ...@@ -1806,27 +1804,26 @@ int32_t tsDecompressTinyint(const char *const input, int32_t compressedSize, con
} }
// Smallint ===================================================== // Smallint =====================================================
int32_t tsCompressSmallint(const char *const input, int32_t inputSize, const int32_t nelements, char *const output, int32_t tsCompressSmallint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize) { int32_t nBuf) {
if (algorithm == ONE_STAGE_COMP) { if (cmprAlg == ONE_STAGE_COMP) {
return tsCompressINTImp(input, nelements, output, TSDB_DATA_TYPE_SMALLINT); return tsCompressINTImp(pIn, nEle, pOut, TSDB_DATA_TYPE_SMALLINT);
} else if (algorithm == TWO_STAGE_COMP) { } else if (cmprAlg == TWO_STAGE_COMP) {
int32_t len = tsCompressINTImp(input, nelements, buffer, TSDB_DATA_TYPE_SMALLINT); int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_SMALLINT);
return tsCompressStringImp(buffer, len, output, outputSize); return tsCompressStringImp(pBuf, len, pOut, nOut);
} else { } else {
assert(0); assert(0);
return -1; return -1;
} }
} }
int32_t tsDecompressSmallint(const char *const input, int32_t compressedSize, const int32_t nelements, int32_t tsDecompressSmallint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg,
char *const output, int32_t outputSize, char algorithm, char *const buffer, void *pBuf, int32_t nBuf) {
int32_t bufferSize) { if (cmprAlg == ONE_STAGE_COMP) {
if (algorithm == ONE_STAGE_COMP) { return tsDecompressINTImp(pIn, nEle, pOut, TSDB_DATA_TYPE_SMALLINT);
return tsDecompressINTImp(input, nelements, output, TSDB_DATA_TYPE_SMALLINT); } else if (cmprAlg == TWO_STAGE_COMP) {
} else if (algorithm == TWO_STAGE_COMP) { if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1;
if (tsDecompressStringImp(input, compressedSize, buffer, bufferSize) < 0) return -1; return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_SMALLINT);
return tsDecompressINTImp(buffer, nelements, output, TSDB_DATA_TYPE_SMALLINT);
} else { } else {
assert(0); assert(0);
return -1; return -1;
...@@ -1834,26 +1831,26 @@ int32_t tsDecompressSmallint(const char *const input, int32_t compressedSize, co ...@@ -1834,26 +1831,26 @@ int32_t tsDecompressSmallint(const char *const input, int32_t compressedSize, co
} }
// Int ===================================================== // Int =====================================================
int32_t tsCompressInt(const char *const input, int32_t inputSize, const int32_t nelements, char *const output, int32_t tsCompressInt(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize) { int32_t nBuf) {
if (algorithm == ONE_STAGE_COMP) { if (cmprAlg == ONE_STAGE_COMP) {
return tsCompressINTImp(input, nelements, output, TSDB_DATA_TYPE_INT); return tsCompressINTImp(pIn, nEle, pOut, TSDB_DATA_TYPE_INT);
} else if (algorithm == TWO_STAGE_COMP) { } else if (cmprAlg == TWO_STAGE_COMP) {
int32_t len = tsCompressINTImp(input, nelements, buffer, TSDB_DATA_TYPE_INT); int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_INT);
return tsCompressStringImp(buffer, len, output, outputSize); return tsCompressStringImp(pBuf, len, pOut, nOut);
} else { } else {
assert(0); assert(0);
return -1; return -1;
} }
} }
int32_t tsDecompressInt(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output, int32_t tsDecompressInt(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize) { int32_t nBuf) {
if (algorithm == ONE_STAGE_COMP) { if (cmprAlg == ONE_STAGE_COMP) {
return tsDecompressINTImp(input, nelements, output, TSDB_DATA_TYPE_INT); return tsDecompressINTImp(pIn, nEle, pOut, TSDB_DATA_TYPE_INT);
} else if (algorithm == TWO_STAGE_COMP) { } else if (cmprAlg == TWO_STAGE_COMP) {
if (tsDecompressStringImp(input, compressedSize, buffer, bufferSize) < 0) return -1; if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1;
return tsDecompressINTImp(buffer, nelements, output, TSDB_DATA_TYPE_INT); return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_INT);
} else { } else {
assert(0); assert(0);
return -1; return -1;
...@@ -1861,26 +1858,26 @@ int32_t tsDecompressInt(const char *const input, int32_t compressedSize, const i ...@@ -1861,26 +1858,26 @@ int32_t tsDecompressInt(const char *const input, int32_t compressedSize, const i
} }
// Bigint ===================================================== // Bigint =====================================================
int32_t tsCompressBigint(const char *const input, int32_t inputSize, const int32_t nelements, char *const output, int32_t tsCompressBigint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize) { int32_t nBuf) {
if (algorithm == ONE_STAGE_COMP) { if (cmprAlg == ONE_STAGE_COMP) {
return tsCompressINTImp(input, nelements, output, TSDB_DATA_TYPE_BIGINT); return tsCompressINTImp(pIn, nEle, pOut, TSDB_DATA_TYPE_BIGINT);
} else if (algorithm == TWO_STAGE_COMP) { } else if (cmprAlg == TWO_STAGE_COMP) {
int32_t len = tsCompressINTImp(input, nelements, buffer, TSDB_DATA_TYPE_BIGINT); int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_BIGINT);
return tsCompressStringImp(buffer, len, output, outputSize); return tsCompressStringImp(pBuf, len, pOut, nOut);
} else { } else {
assert(0); assert(0);
return -1; return -1;
} }
} }
int32_t tsDecompressBigint(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output, int32_t tsDecompressBigint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize) { int32_t nBuf) {
if (algorithm == ONE_STAGE_COMP) { if (cmprAlg == ONE_STAGE_COMP) {
return tsDecompressINTImp(input, nelements, output, TSDB_DATA_TYPE_BIGINT); return tsDecompressINTImp(pIn, nEle, pOut, TSDB_DATA_TYPE_BIGINT);
} else if (algorithm == TWO_STAGE_COMP) { } else if (cmprAlg == TWO_STAGE_COMP) {
if (tsDecompressStringImp(input, compressedSize, buffer, bufferSize) < 0) return -1; if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1;
return tsDecompressINTImp(buffer, nelements, output, TSDB_DATA_TYPE_BIGINT); return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_BIGINT);
} else { } else {
assert(0); assert(0);
return -1; return -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册