commit
5a068d8ebd
|
@ -443,6 +443,11 @@ int tsdbWriteCompIdx(SRWHelper *pHelper) {
|
||||||
for (uint32_t i = 0; i < pHelper->config.maxTables; i++) {
|
for (uint32_t i = 0; i < pHelper->config.maxTables; i++) {
|
||||||
SCompIdx *pCompIdx = pHelper->pCompIdx + i;
|
SCompIdx *pCompIdx = pHelper->pCompIdx + i;
|
||||||
if (pCompIdx->offset > 0) {
|
if (pCompIdx->offset > 0) {
|
||||||
|
int drift = POINTER_DISTANCE(buf, pHelper->pBuffer);
|
||||||
|
if (tsizeof(pHelper->pBuffer) - drift < 128) {
|
||||||
|
pHelper->pBuffer = trealloc(pHelper->pBuffer, tsizeof(pHelper->pBuffer)*2);
|
||||||
|
}
|
||||||
|
buf = POINTER_SHIFT(pHelper->pBuffer, drift);
|
||||||
buf = taosEncodeVariant32(buf, i);
|
buf = taosEncodeVariant32(buf, i);
|
||||||
buf = tsdbEncodeSCompIdx(buf, pCompIdx);
|
buf = tsdbEncodeSCompIdx(buf, pCompIdx);
|
||||||
}
|
}
|
||||||
|
@ -469,6 +474,7 @@ int tsdbLoadCompIdx(SRWHelper *pHelper, void *target) {
|
||||||
ASSERT(pFile->info.offset > TSDB_FILE_HEAD_SIZE);
|
ASSERT(pFile->info.offset > TSDB_FILE_HEAD_SIZE);
|
||||||
|
|
||||||
if (lseek(fd, pFile->info.offset, SEEK_SET) < 0) return -1;
|
if (lseek(fd, pFile->info.offset, SEEK_SET) < 0) return -1;
|
||||||
|
if ((pHelper->pBuffer = trealloc(pHelper->pBuffer, pFile->info.len)) == NULL) return -1;
|
||||||
if (tread(fd, (void *)(pHelper->pBuffer), pFile->info.len) < pFile->info.len)
|
if (tread(fd, (void *)(pHelper->pBuffer), pFile->info.len) < pFile->info.len)
|
||||||
return -1;
|
return -1;
|
||||||
if (!taosCheckChecksumWhole((uint8_t *)(pHelper->pBuffer), pFile->info.len)) {
|
if (!taosCheckChecksumWhole((uint8_t *)(pHelper->pBuffer), pFile->info.len)) {
|
||||||
|
|
|
@ -46,6 +46,7 @@ extern "C" {
|
||||||
|
|
||||||
// Pointer p drift right by b bytes
|
// Pointer p drift right by b bytes
|
||||||
#define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b)))
|
#define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b)))
|
||||||
|
#define POINTER_DISTANCE(p1, p2) ((char *)(p1) - (char *)(p2))
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#define ASSERT(x) assert(x)
|
#define ASSERT(x) assert(x)
|
||||||
|
|
Loading…
Reference in New Issue