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

MCOL-641 Clean up primitives code

Add int128_t support into ByteStream

Fixed UTs broken after collation patch
This commit is contained in:
Roman Nozdrin
2020-07-17 14:56:59 +00:00
parent 638202417f
commit 1588ebe439
23 changed files with 225 additions and 197 deletions

View File

@ -235,18 +235,6 @@ ByteStream& ByteStream::operator<<(const uint64_t o)
return *this;
}
// WIP MCOL-641
ByteStream& ByteStream::operator<<(const int128_t& o)
{
if (fBuf == 0 || (fCurInPtr - fBuf + 16U > fMaxLen + ISSOverhead))
growBuf(fMaxLen + BlockSize);
*((int128_t*) fCurInPtr) = o;
fCurInPtr += 16;
return *this;
}
ByteStream& ByteStream::operator<<(const uint128_t& o)
{
if (fBuf == 0 || (fCurInPtr - fBuf + 16U > fMaxLen + ISSOverhead))
@ -258,6 +246,17 @@ ByteStream& ByteStream::operator<<(const uint128_t& o)
return *this;
}
ByteStream& ByteStream::operator<<(const int128_t& o)
{
if (fBuf == 0 || (fCurInPtr - fBuf + 16U > fMaxLen + ISSOverhead))
growBuf(fMaxLen + BlockSize);
*((int128_t*) fCurInPtr) = o;
fCurInPtr += 16;
return *this;
}
ByteStream& ByteStream::operator<<(const string& s)
{
int32_t len = s.size();
@ -342,15 +341,14 @@ ByteStream& ByteStream::operator>>(uint64_t& o)
return *this;
}
// WIP MCOL-641
ByteStream& ByteStream::operator>>(int128_t& o)
ByteStream& ByteStream::operator>>(uint128_t& o)
{
peek(o);
fCurOutPtr += 16;
return *this;
}
ByteStream& ByteStream::operator>>(uint128_t& o)
ByteStream& ByteStream::operator>>(int128_t& o)
{
peek(o);
fCurOutPtr += 16;
@ -437,16 +435,6 @@ void ByteStream::peek(uint64_t& o) const
o = *((uint64_t*) fCurOutPtr);
}
// WIP MCOL-641
void ByteStream::peek(int128_t& o) const
{
if (length() < 16)
throw underflow_error("ByteStream>int128_t: not enough data in stream to fill datatype");
o = *((int128_t*) fCurOutPtr);
}
void ByteStream::peek(uint128_t& o) const
{
@ -456,6 +444,15 @@ void ByteStream::peek(uint128_t& o) const
o = *((uint128_t*) fCurOutPtr);
}
void ByteStream::peek(int128_t& o) const
{
if (length() < 16)
throw underflow_error("ByteStream>int128_t: not enough data in stream to fill datatype");
o = *((int128_t*) fCurOutPtr);
}
void ByteStream::peek(string& s) const
{
int32_t len;

View File

@ -47,6 +47,7 @@ class ByteStreamTestSuite;
using int128_t = __int128;
using uint128_t = unsigned __int128;
using int128_t = __int128;
namespace messageqcpp
{
@ -77,7 +78,7 @@ public:
typedef uint16_t doublebyte;
typedef uint32_t quadbyte;
typedef uint64_t octbyte;
typedef uint128_t hexbyte;
typedef int128_t hexbyte;
typedef boost::uuids::uuid uuid;
/**
@ -147,7 +148,6 @@ public:
* push an uint64_t onto the end of the stream. The byte order is whatever the native byte order is.
*/
EXPORT ByteStream& operator<<(const uint64_t o);
// WIP MCOL-641
/**
* push an uint128_t onto the end of the stream. The byte order is whatever the native byte order is.
*/
@ -156,6 +156,10 @@ public:
* push an uint128_t onto the end of the stream. The byte order is whatever the native byte order is.
*/
EXPORT ByteStream& operator<<(const uint128_t& o);
/**
* push an int128_t onto the end of the stream. The byte order is whatever the native byte order is.
*/
EXPORT ByteStream& operator<<(const int128_t& o);
/**
* push a float onto the end of the stream. The byte order is
* whatever the native byte order is.
@ -220,7 +224,6 @@ public:
* extract an uint64_t from the front of the stream. The byte order is whatever the native byte order is.
*/
EXPORT ByteStream& operator>>(uint64_t& o);
// WIP MCOL-641
/**
* extract an uint128_t from the front of the stream. The byte order is whatever the native byte order is.
*/
@ -229,6 +232,10 @@ public:
* extract an uint128_t from the front of the stream. The byte order is whatever the native byte order is.
*/
EXPORT ByteStream& operator>>(uint128_t& o);
/**
* extract an int128_t from the front of the stream. The byte order is whatever the native byte order is.
*/
EXPORT ByteStream& operator>>(int128_t& o);
/**
* extract a float from the front of the stream. The byte
* order is whatever the native byte order is.
@ -299,7 +306,6 @@ public:
* Peek at an uint64_t from the front of the stream. The byte order is whatever the native byte order is.
*/
EXPORT void peek(uint64_t& o) const;
// WIP MCOL-641
/**
* Peek at an uint128_t from the front of the stream. The byte order is whatever the native byte order is.
*/
@ -308,6 +314,10 @@ public:
* Peek at an uint128_t from the front of the stream. The byte order is whatever the native byte order is.
*/
EXPORT void peek(uint128_t& o) const;
/**
* Peek at an int128_t from the front of the stream. The byte order is whatever the native byte order is.
*/
EXPORT void peek(int128_t& o) const;
/**
* Peek at a float from the front of the stream. The byte order
* is whatever the native byte order is.