You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-08 14:22:09 +03:00
feat(TNS): distribute SortingPQ that supports CountingAllocator
This commit is contained in:
@@ -768,6 +768,7 @@ void GroupConcatOrderBy::processRow(const rowgroup::Row& row)
|
||||
if (concatColIsNull(row))
|
||||
return;
|
||||
|
||||
auto& orderByQueue = getQueue();
|
||||
// if the row count is less than the limit
|
||||
if (fCurrentLength < fGroupConcatLen)
|
||||
{
|
||||
@@ -776,7 +777,7 @@ void GroupConcatOrderBy::processRow(const rowgroup::Row& row)
|
||||
int16_t estLen = lengthEstimate(fRow0);
|
||||
fRow0.setRid(estLen);
|
||||
OrderByRow newRow(fRow0, fRule);
|
||||
fOrderByQueue.push(newRow);
|
||||
orderByQueue.push(newRow);
|
||||
fCurrentLength += estLen;
|
||||
|
||||
// add to the distinct map
|
||||
@@ -806,11 +807,11 @@ void GroupConcatOrderBy::processRow(const rowgroup::Row& row)
|
||||
}
|
||||
}
|
||||
|
||||
else if (fOrderByCond.size() > 0 && fRule.less(row.getPointer(), fOrderByQueue.top().fData))
|
||||
else if (fOrderByCond.size() > 0 && fRule.less(row.getPointer(), orderByQueue.top().fData))
|
||||
{
|
||||
OrderByRow swapRow = fOrderByQueue.top();
|
||||
OrderByRow swapRow = orderByQueue.top();
|
||||
fRow1.setData(swapRow.fData);
|
||||
fOrderByQueue.pop();
|
||||
orderByQueue.pop();
|
||||
fCurrentLength -= fRow1.getRelRid();
|
||||
fRow2.setData(swapRow.fData);
|
||||
|
||||
@@ -830,7 +831,7 @@ void GroupConcatOrderBy::processRow(const rowgroup::Row& row)
|
||||
fRow2.setRid(estLen);
|
||||
fCurrentLength += estLen;
|
||||
|
||||
fOrderByQueue.push(swapRow);
|
||||
orderByQueue.push(swapRow);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -838,9 +839,12 @@ void GroupConcatOrderBy::merge(GroupConcator* gc)
|
||||
{
|
||||
GroupConcatOrderBy* go = dynamic_cast<GroupConcatOrderBy*>(gc);
|
||||
|
||||
while (go->fOrderByQueue.empty() == false)
|
||||
auto& orderByQueue = getQueue();
|
||||
auto mergeQueue = go->getQueue();
|
||||
|
||||
while (mergeQueue.empty() == false)
|
||||
{
|
||||
const OrderByRow& row = go->fOrderByQueue.top();
|
||||
const OrderByRow& row = mergeQueue.top();
|
||||
|
||||
// check if the distinct row already exists
|
||||
if (fDistinct && fDistinctMap->find(row.fData) != fDistinctMap->end())
|
||||
@@ -851,7 +855,7 @@ void GroupConcatOrderBy::merge(GroupConcator* gc)
|
||||
// if the row count is less than the limit
|
||||
else if (fCurrentLength < fGroupConcatLen)
|
||||
{
|
||||
fOrderByQueue.push(row);
|
||||
orderByQueue.push(row);
|
||||
row1.setData(row.fData);
|
||||
fCurrentLength += row1.getRelRid();
|
||||
|
||||
@@ -860,11 +864,11 @@ void GroupConcatOrderBy::merge(GroupConcator* gc)
|
||||
fDistinctMap->insert(row.fData);
|
||||
}
|
||||
|
||||
else if (fOrderByCond.size() > 0 && fRule.less(row.fData, fOrderByQueue.top().fData))
|
||||
else if (fOrderByCond.size() > 0 && fRule.less(row.fData, orderByQueue.top().fData))
|
||||
{
|
||||
OrderByRow swapRow = fOrderByQueue.top();
|
||||
OrderByRow swapRow = orderByQueue.top();
|
||||
row1.setData(swapRow.fData);
|
||||
fOrderByQueue.pop();
|
||||
orderByQueue.pop();
|
||||
fCurrentLength -= row1.getRelRid();
|
||||
|
||||
if (fDistinct)
|
||||
@@ -876,10 +880,10 @@ void GroupConcatOrderBy::merge(GroupConcator* gc)
|
||||
row1.setData(row.fData);
|
||||
fCurrentLength += row1.getRelRid();
|
||||
|
||||
fOrderByQueue.push(row);
|
||||
orderByQueue.push(row);
|
||||
}
|
||||
|
||||
go->fOrderByQueue.pop();
|
||||
mergeQueue.pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -890,10 +894,12 @@ uint8_t* GroupConcatOrderBy::getResultImpl(const string& sep)
|
||||
|
||||
// need to reverse the order
|
||||
stack<OrderByRow> rowStack;
|
||||
while (fOrderByQueue.size() > 0)
|
||||
auto& orderByQueue = getQueue();
|
||||
|
||||
while (orderByQueue.size() > 0)
|
||||
{
|
||||
rowStack.push(fOrderByQueue.top());
|
||||
fOrderByQueue.pop();
|
||||
rowStack.push(orderByQueue.top());
|
||||
orderByQueue.pop();
|
||||
}
|
||||
|
||||
size_t prevResultSize = 0;
|
||||
|
Reference in New Issue
Block a user