1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

fix(build): replace std::ranges usage for gcc9 and std::span with boost::span

This commit is contained in:
Leonid Fedorov
2025-04-15 12:10:18 +00:00
committed by Leonid Fedorov
parent 6a712dc0ad
commit 432d0cf7f8
3 changed files with 25 additions and 18 deletions

View File

@ -22,7 +22,7 @@
#include <iostream> #include <iostream>
// #define NDEBUG // #define NDEBUG
#include <cassert> #include <cassert>
#include <ranges>
#include <string> #include <string>
#include "windowfunction/idborderby.h" #include "windowfunction/idborderby.h"
using namespace std; using namespace std;
@ -467,9 +467,9 @@ void GroupConcator::initialize(const rowgroup::SP_GroupConcat& gcc)
fRm = gcc->fRm; fRm = gcc->fRm;
fSessionMemLimit = gcc->fSessionMemLimit; fSessionMemLimit = gcc->fSessionMemLimit;
for (const auto& str : views::keys(gcc->fConstCols)) for (const auto& str : gcc->fConstCols)
{ {
fConstantLen += str.length(); fConstantLen += str.first.length();
} }
} }
@ -714,7 +714,8 @@ void GroupConcator::outputRow(std::ostringstream& oss, const rowgroup::Row& row)
bool GroupConcator::concatColIsNull(const rowgroup::Row& row) bool GroupConcator::concatColIsNull(const rowgroup::Row& row)
{ {
return ranges::any_of(fConcatColumns, [&](uint32_t idx) { return row.isNullValue(idx); }); return std::any_of(fConcatColumns.cbegin(), fConcatColumns.cend(),
[&row](uint32_t idx) { return row.isNullValue(idx); });
} }
int64_t GroupConcator::lengthEstimate(const rowgroup::Row& row) int64_t GroupConcator::lengthEstimate(const rowgroup::Row& row)
@ -987,6 +988,7 @@ void GroupConcatOrderBy::initialize(const rowgroup::SP_GroupConcat& gcc)
fOrderByCond.resize(0); fOrderByCond.resize(0);
fOrderByCond.reserve(gcc->fOrderCond.size());
for (const auto& [idx, asc] : gcc->fOrderCond) for (const auto& [idx, asc] : gcc->fOrderCond)
{ {
fOrderByCond.emplace_back(idx, asc); fOrderByCond.emplace_back(idx, asc);
@ -994,9 +996,10 @@ void GroupConcatOrderBy::initialize(const rowgroup::SP_GroupConcat& gcc)
fDistinct = gcc->fDistinct; fDistinct = gcc->fDistinct;
for (uint32_t x : views::values(gcc->fGroupCols)) fConcatColumns.reserve(fConcatColumns.size() + gcc->fGroupCols.size());
for (auto& x : gcc->fGroupCols)
{ {
fConcatColumns.emplace_back(x); fConcatColumns.emplace_back(x.second);
} }
auto size = fRowGroup.getSizeWithStrings(fRowsPerRG); auto size = fRowGroup.getSizeWithStrings(fRowsPerRG);
@ -1048,9 +1051,10 @@ void GroupConcatOrderBy::serialize(messageqcpp::ByteStream& bs) const
{ {
sz = fDistinctMap->size(); sz = fDistinctMap->size();
bs << sz; bs << sz;
for (const auto& idx : views::values(*fDistinctMap))
for (const auto& idx : *fDistinctMap)
{ {
bs << idx; bs << idx.second;
} }
} }
sz = fOrderByQueue->size(); sz = fOrderByQueue->size();
@ -1435,9 +1439,11 @@ void GroupConcatNoOrder::initialize(const rowgroup::SP_GroupConcat& gcc)
fRowGroup.setUseOnlyLongString(true); fRowGroup.setUseOnlyLongString(true);
fRowsPerRG = 128; fRowsPerRG = 128;
for (uint32_t colIdx : views::values(gcc->fGroupCols)) fConcatColumns.reserve(fConcatColumns.size() + gcc->fGroupCols.size());
for (auto& colIdx : gcc->fGroupCols)
{ {
fConcatColumns.push_back(colIdx); fConcatColumns.push_back(colIdx.second);
} }
createNewRGData(); createNewRGData();

View File

@ -428,7 +428,7 @@ RGData::RGData(const RowGroup& rg, allocators::CountingAllocator<RGDataBufType>&
if (rg.usesStringTable()) if (rg.usesStringTable())
{ {
allocators::CountingAllocator<StringStoreBufType> ssAlloc = _alloc; allocators::CountingAllocator<StringStoreBufType> ssAlloc = _alloc;
strings.reset(new StringStore(ssAlloc)); strings.reset(new StringStore(ssAlloc));
strings->useOnlyLongStrings(rg.usesOnlyLongString()); strings->useOnlyLongStrings(rg.usesOnlyLongString());
} }
@ -455,12 +455,12 @@ void RGData::reinit(const RowGroup& rg, uint32_t rowCount)
if (alloc) if (alloc)
{ {
allocators::CountingAllocator<StringStoreBufType> ssAlloc = alloc.value(); allocators::CountingAllocator<StringStoreBufType> ssAlloc = alloc.value();
strings.reset(new StringStore(ssAlloc)); strings.reset(new StringStore(ssAlloc));
strings->useOnlyLongStrings(rg.usesOnlyLongString()); strings->useOnlyLongStrings(rg.usesOnlyLongString());
} }
else else
{ {
strings.reset(new StringStore()); strings.reset(new StringStore());
} }
} }
else else
@ -1368,7 +1368,7 @@ void RowGroup::deserialize(ByteStream& bs)
charsets.insert(charsets.begin(), charsetNumbers.size(), nullptr); charsets.insert(charsets.begin(), charsetNumbers.size(), nullptr);
} }
void RowGroup::setUseAggregateDataStore(bool b, std::span<boost::shared_ptr<GroupConcat>> group_concats) void RowGroup::setUseAggregateDataStore(bool b, boost::span<boost::shared_ptr<GroupConcat>> group_concats)
{ {
idbassert(!b || !group_concats.empty()); idbassert(!b || !group_concats.empty());
if (useAggregateDataStore && !b) if (useAggregateDataStore && !b)

View File

@ -27,12 +27,13 @@
#pragma once #pragma once
#include <span>
#include <vector> #include <vector>
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
// #define NDEBUG // #define NDEBUG
#include <cassert> #include <cassert>
#include <boost/core/span.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/thread/mutex.hpp> #include <boost/thread/mutex.hpp>
@ -1103,7 +1104,7 @@ inline void Row::setStringField(const utils::ConstString& str, uint32_t colIndex
} }
else else
{ {
// std::cout << "setStringField memcpy " << std::endl; // std::cout << "setStringField memcpy " << std::endl;
uint8_t* buf = &data[offsets[colIndex]]; uint8_t* buf = &data[offsets[colIndex]];
memset(buf + length, 0, memset(buf + length, 0,
offsets[colIndex + 1] - (offsets[colIndex] + length)); // needed for memcmp in equals(). offsets[colIndex + 1] - (offsets[colIndex] + length)); // needed for memcmp in equals().
@ -1640,7 +1641,7 @@ class RowGroup : public messageqcpp::Serializeable
{ {
return useOnlyLongStrings; return useOnlyLongStrings;
} }
void setUseAggregateDataStore(bool b, std::span<boost::shared_ptr<GroupConcat>> group_concats = {}); void setUseAggregateDataStore(bool b, boost::span<boost::shared_ptr<GroupConcat>> group_concats = {});
bool usesAggregateDataStore() const bool usesAggregateDataStore() const
{ {
return useAggregateDataStore; return useAggregateDataStore;
@ -2314,7 +2315,7 @@ inline void RGData::getRow(uint32_t num, Row* row)
{ {
uint32_t incomingRowSize = row->getSize(); uint32_t incomingRowSize = row->getSize();
idbassert(columnCount == row->getColumnCount() && rowSize == incomingRowSize); idbassert(columnCount == row->getColumnCount() && rowSize == incomingRowSize);
row->setData( row->setData(
Row::Pointer(&rowData[RowGroup::getHeaderSize() + (num * incomingRowSize)], strings.get(), Row::Pointer(&rowData[RowGroup::getHeaderSize() + (num * incomingRowSize)], strings.get(),
userDataStore.get(), aggregateDataStore.get())); userDataStore.get(), aggregateDataStore.get()));