add compress
This commit is contained in:
parent
1d9b65226e
commit
0f629bebda
|
@ -1601,29 +1601,36 @@ int32_t valueDecode(void* value, int32_t vlen, int64_t* ttl, char** dest) {
|
||||||
}
|
}
|
||||||
p = taosDecodeFixedI64(p, &key.unixTimestamp);
|
p = taosDecodeFixedI64(p, &key.unixTimestamp);
|
||||||
p = taosDecodeFixedI32(p, &key.len);
|
p = taosDecodeFixedI32(p, &key.len);
|
||||||
p = taosDecodeFixedI32(p, &key.rawLen);
|
|
||||||
p = taosDecodeFixedI8(p, &key.compress);
|
|
||||||
|
|
||||||
if (vlen != (sizeof(key.unixTimestamp) + sizeof(key.len) + sizeof(key.rawLen) + sizeof(key.compress) + key.len)) {
|
if (vlen == (sizeof(key.unixTimestamp) + sizeof(key.len) + key.len)) {
|
||||||
stError("vlen: %d, read len: %d", vlen, key.len);
|
// compatiable with previous data
|
||||||
goto _EXCEPT;
|
if (key.len != 0 && dest != NULL) p = taosDecodeBinary(p, (void**)dest, key.len);
|
||||||
}
|
|
||||||
if (key.compress == 1) {
|
|
||||||
char* pCompressData = NULL;
|
|
||||||
if (key.len != 0) {
|
|
||||||
p = taosDecodeBinary(p, (void**)&pCompressData, key.len);
|
|
||||||
*dest = taosMemoryCalloc(1, key.rawLen);
|
|
||||||
int32_t decompressSize = LZ4_decompress_safe(pCompressData, *dest, key.len, key.rawLen);
|
|
||||||
ASSERT(decompressSize == key.rawLen);
|
|
||||||
key.len = decompressSize;
|
|
||||||
}
|
|
||||||
taosMemoryFree(pCompressData);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (key.len != 0 && dest != NULL) p = taosDecodeBinary(p, (void**)dest, key.len);
|
p = taosDecodeFixedI32(p, &key.rawLen);
|
||||||
|
p = taosDecodeFixedI8(p, &key.compress);
|
||||||
|
if (vlen != (sizeof(key.unixTimestamp) + sizeof(key.len) + sizeof(key.rawLen) + sizeof(key.compress) + key.len)) {
|
||||||
|
stError("vlen: %d, read len: %d", vlen, key.len);
|
||||||
|
goto _EXCEPT;
|
||||||
|
}
|
||||||
|
if (key.compress == 1) {
|
||||||
|
char* pCompressData = NULL;
|
||||||
|
if (key.len != 0) {
|
||||||
|
p = taosDecodeBinary(p, (void**)&pCompressData, key.len);
|
||||||
|
*dest = taosMemoryCalloc(1, key.rawLen);
|
||||||
|
int32_t decompressSize = LZ4_decompress_safe(pCompressData, *dest, key.len, key.rawLen);
|
||||||
|
ASSERT(decompressSize == key.rawLen);
|
||||||
|
key.len = decompressSize;
|
||||||
|
}
|
||||||
|
taosMemoryFree(pCompressData);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (key.len != 0 && dest != NULL) p = taosDecodeBinary(p, (void**)dest, key.len);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ttl != NULL) *ttl = key.unixTimestamp == 0 ? 0 : key.unixTimestamp - taosGetTimestampMs();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ttl != NULL) *ttl = key.unixTimestamp == 0 ? 0 : key.unixTimestamp - taosGetTimestampMs();
|
|
||||||
return key.len;
|
return key.len;
|
||||||
|
|
||||||
_EXCEPT:
|
_EXCEPT:
|
||||||
|
|
Loading…
Reference in New Issue