This commit is contained in:
parent
672c7d59d9
commit
821b3cbc12
|
@ -239,6 +239,7 @@ typedef struct STableDataBlocks {
|
||||||
|
|
||||||
int32_t rowSize; // row size for current table
|
int32_t rowSize; // row size for current table
|
||||||
uint32_t nAllocSize;
|
uint32_t nAllocSize;
|
||||||
|
uint32_t headerSize; // header for metadata (submit metadata)
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -579,6 +579,7 @@ int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int3
|
||||||
size_t remain = pDataBlock->nAllocSize - pDataBlock->size;
|
size_t remain = pDataBlock->nAllocSize - pDataBlock->size;
|
||||||
const int factor = 5;
|
const int factor = 5;
|
||||||
uint32_t nAllocSizeOld = pDataBlock->nAllocSize;
|
uint32_t nAllocSizeOld = pDataBlock->nAllocSize;
|
||||||
|
assert(pDataBlock->headerSize >= 0);
|
||||||
|
|
||||||
// expand the allocated size
|
// expand the allocated size
|
||||||
if (remain < rowSize * factor) {
|
if (remain < rowSize * factor) {
|
||||||
|
@ -595,12 +596,12 @@ int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int3
|
||||||
//assert(false);
|
//assert(false);
|
||||||
// do nothing
|
// do nothing
|
||||||
pDataBlock->nAllocSize = nAllocSizeOld;
|
pDataBlock->nAllocSize = nAllocSizeOld;
|
||||||
*numOfRows = (int32_t)(pDataBlock->nAllocSize) / rowSize;
|
*numOfRows = (int32_t)(pDataBlock->nAllocSize - pDataBlock->headerSize) / rowSize;
|
||||||
return TSDB_CODE_CLI_OUT_OF_MEMORY;
|
return TSDB_CODE_CLI_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*numOfRows = (int32_t)(pDataBlock->nAllocSize) / rowSize;
|
*numOfRows = (int32_t)(pDataBlock->nAllocSize - pDataBlock->headerSize) / rowSize;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -598,6 +598,7 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff
|
||||||
}
|
}
|
||||||
|
|
||||||
dataBuf->nAllocSize = (uint32_t)initialSize;
|
dataBuf->nAllocSize = (uint32_t)initialSize;
|
||||||
|
dataBuf->headerSize = startOffset; // the header size will always be the startOffset value, reserved for the subumit block header
|
||||||
dataBuf->pData = calloc(1, dataBuf->nAllocSize);
|
dataBuf->pData = calloc(1, dataBuf->nAllocSize);
|
||||||
dataBuf->ordered = true;
|
dataBuf->ordered = true;
|
||||||
dataBuf->prevTS = INT64_MIN;
|
dataBuf->prevTS = INT64_MIN;
|
||||||
|
|
Loading…
Reference in New Issue