1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

feat(bytestream): serialize long strings in the common way

This commit is contained in:
Aleksei Antipovskii
2025-03-05 13:56:37 +01:00
committed by Alexey Antipovsky
parent 4bea7e59a0
commit 21ebd1ac20
4 changed files with 22 additions and 117 deletions

View File

@ -58,8 +58,6 @@ void ByteStream::doCopy(const ByteStream& rhs)
memcpy(fBuf + ISSOverhead, rhs.fCurOutPtr, rlen);
fCurInPtr = fBuf + ISSOverhead + rlen;
fCurOutPtr = fBuf + ISSOverhead;
// Copy `longStrings` as well.
longStrings = rhs.longStrings;
}
ByteStream::ByteStream(const ByteStream& rhs) : fBuf(0), fCurInPtr(0), fCurOutPtr(0), fMaxLen(0)
@ -86,8 +84,6 @@ ByteStream& ByteStream::operator=(const ByteStream& rhs)
deallocate(fBuf);
fBuf = fCurInPtr = fCurOutPtr = 0;
fMaxLen = 0;
// Clear `longStrings`.
longStrings.clear();
}
}
@ -180,21 +176,6 @@ void ByteStream::growBuf(BSSizeType toSize)
}
}
std::vector<rowgroup::StringStoreBufSPType>& ByteStream::getLongStrings()
{
return longStrings;
}
const std::vector<rowgroup::StringStoreBufSPType>& ByteStream::getLongStrings() const
{
return longStrings;
}
void ByteStream::setLongStrings(const std::vector<rowgroup::StringStoreBufSPType>& other)
{
longStrings = other;
}
ByteStream& ByteStream::operator<<(const int8_t b)
{
if (fBuf == 0 || (fCurInPtr - fBuf + sizeof(b) > fMaxLen + ISSOverhead))
@ -601,7 +582,6 @@ void ByteStream::swap(ByteStream& rhs)
std::swap(fCurInPtr, rhs.fCurInPtr);
std::swap(fCurOutPtr, rhs.fCurOutPtr);
std::swap(fMaxLen, rhs.fMaxLen);
std::swap(longStrings, rhs.longStrings);
std::swap(allocator, rhs.allocator);
}
@ -625,27 +605,6 @@ bool ByteStream::operator==(const ByteStream& b) const
if (memcmp(fCurOutPtr, b.fCurOutPtr, length()) != 0)
return false;
// Check the `longString` sizes.
if (longStrings.size() != b.longStrings.size())
return false;
// For each `longString`.
for (uint32_t i = 0, e = b.longStrings.size(); i < e; ++i)
{
const auto* leftMemChunk = reinterpret_cast<MemChunk*>(longStrings[i].get());
const auto* rightMemChunk = reinterpret_cast<MemChunk*>(b.longStrings[i].get());
if (leftMemChunk == nullptr || rightMemChunk == nullptr)
return false;
const uint32_t leftSize = leftMemChunk->currentSize;
const uint32_t rightSize = rightMemChunk->currentSize;
if (leftSize != rightSize)
return false;
if (memcmp(leftMemChunk->data, rightMemChunk->data, leftSize) != 0)
return false;
}
return true;
}