未验证 提交 a65b103b 编写于 作者: D dapan1121 提交者: GitHub

Merge pull request #21719 from taosdata/fix/td-24781

fix: calculate the rows that can be put in one page
...@@ -1590,18 +1590,35 @@ size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize, int ...@@ -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 {
++numFixCols;
}
}
// 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 { } else {
additional += BitmapLen(nRows); start = mid + 1;
} }
} }
int32_t newRows = (payloadSize - additional) / rowSize; 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 ...@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册