Merge pull request #21719 from taosdata/fix/td-24781
fix: calculate the rows that can be put in one page
This commit is contained in:
commit
a65b103b1d
|
@ -1590,18 +1590,35 @@ size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize, int
|
||||||
int32_t nRows = payloadSize / rowSize;
|
int32_t nRows = payloadSize / rowSize;
|
||||||
ASSERT(nRows >= 1);
|
ASSERT(nRows >= 1);
|
||||||
|
|
||||||
// the true value must be less than the value of nRows
|
int32_t numVarCols = 0;
|
||||||
int32_t additional = 0;
|
int32_t numFixCols = 0;
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, i);
|
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
if (IS_VAR_DATA_TYPE(pCol->info.type)) {
|
if (IS_VAR_DATA_TYPE(pCol->info.type)) {
|
||||||
additional += nRows * sizeof(int32_t);
|
++numVarCols;
|
||||||
} else {
|
} else {
|
||||||
additional += BitmapLen(nRows);
|
++numFixCols;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t newRows = (payloadSize - additional) / rowSize;
|
// find the data payload whose size is greater than payloadSize
|
||||||
|
int result = -1;
|
||||||
|
int start = 1;
|
||||||
|
int end = nRows;
|
||||||
|
while (start <= end) {
|
||||||
|
int mid = start + (end - start) / 2;
|
||||||
|
//data size + var data type columns offset + fixed data type columns bitmap len
|
||||||
|
int midSize = rowSize * mid + numVarCols * sizeof(int32_t) * mid + numFixCols * BitmapLen(mid);
|
||||||
|
if (midSize > payloadSize) {
|
||||||
|
result = mid;
|
||||||
|
end = mid - 1;
|
||||||
|
} else {
|
||||||
|
start = mid + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t newRows = (result != -1) ? result - 1 : nRows;
|
||||||
|
// the true value must be less than the value of nRows
|
||||||
ASSERT(newRows <= nRows && newRows >= 1);
|
ASSERT(newRows <= nRows && newRows >= 1);
|
||||||
|
|
||||||
return newRows;
|
return newRows;
|
||||||
|
|
|
@ -131,4 +131,8 @@ print $rows
|
||||||
if $rows != 9 then
|
if $rows != 9 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
print =========================== td-24781
|
||||||
|
sql select DISTINCT (`precision`) from `information_schema`.`ins_databases` PARTITION BY `precision`
|
||||||
|
|
||||||
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
|
|
Loading…
Reference in New Issue