You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
MCOL-641 This commit cleans up Row methods and adds couple UT for Row.
This commit is contained in:
@ -716,7 +716,9 @@ void SimpleColumn::evaluate(Row& row, bool& isNull)
|
||||
case CalpontSystemCatalog::BINARY:
|
||||
|
||||
{
|
||||
fResult.strVal = row.getBinaryField(fInputIndex);
|
||||
// WIP MCOL-641 Binary representation could contain \0.
|
||||
std::string value(row.getBinaryField<char>(fInputIndex));
|
||||
fResult.strVal.swap(value);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -824,14 +824,14 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
|
||||
if (colType.colDataType == CalpontSystemCatalog::DECIMAL)
|
||||
{
|
||||
dec = row.getBinaryField<int128_t>(s);
|
||||
dataconvert::DataConvert::decimalToString<int128_t>(dec,
|
||||
dataconvert::DataConvert::decimalToString(dec,
|
||||
(unsigned)colType.scale, buf,
|
||||
sizeof(buf), colType.colDataType);
|
||||
}
|
||||
else
|
||||
{
|
||||
udec = row.getBinaryField<uint128_t>(s);
|
||||
dataconvert::DataConvert::decimalToString<uint128_t>(udec,
|
||||
dataconvert::DataConvert::decimalToString(udec,
|
||||
(unsigned)colType.scale, buf,
|
||||
sizeof(buf), colType.colDataType);
|
||||
}
|
||||
@ -861,7 +861,9 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
|
||||
case CalpontSystemCatalog::BINARY:
|
||||
{
|
||||
Field_varstring* f2 = (Field_varstring*)*f;
|
||||
f2->store(row.getBinaryField(s).c_str(), 16, f2->charset());
|
||||
// WIP MCOL-641 Binary representation could contain \0.
|
||||
char* binaryString = row.getBinaryField<char>(s);
|
||||
f2->store(binaryString, colType.colWidth, f2->charset());
|
||||
|
||||
if ((*f)->null_ptr)
|
||||
*(*f)->null_ptr &= ~(*f)->null_bit;
|
||||
|
@ -814,7 +814,7 @@ void ColumnCommand::projectResultRG(RowGroup& rg, uint32_t pos)
|
||||
cout << __FILE__<< ":" <<__LINE__ << " ColumnCommand::projectResultRG " << endl;
|
||||
for (i = 0; i < outMsg->NVALS; ++i, msg8 += gapSize)
|
||||
{
|
||||
r.setBinaryField(msg8, colType.colWidth, offset);
|
||||
r.setBinaryField_offset(msg8, colType.colWidth, offset);
|
||||
r.nextRow(rowSize);
|
||||
}
|
||||
break;
|
||||
|
@ -167,7 +167,7 @@ void PassThruCommand::projectIntoRowGroup(RowGroup& rg, uint32_t col)
|
||||
<< *(((int64_t*) bpp->values[i]) +1)
|
||||
<< endl;
|
||||
// values[i] is 8 bytes so it contains the pointer to bpp->outputMsg set by ColumnCommand::process_OT_BOTH()
|
||||
r.setBinaryField((uint8_t*)bpp->values[i], 16, offset);
|
||||
r.setBinaryField_offset((uint8_t*)bpp->values[i], 16, offset);
|
||||
|
||||
r.nextRow(rowSize);
|
||||
}
|
||||
|
@ -477,11 +477,11 @@ void FuncExp::evaluate(rowgroup::Row& row, std::vector<execplan::SRCP>& expressi
|
||||
{
|
||||
// WIP make this a separate function w and w/o overflow check
|
||||
if (expression[i]->resultType().colDataType == execplan::CalpontSystemCatalog::DECIMAL)
|
||||
row.setBinaryField(reinterpret_cast<uint8_t*>(&val.__v.__s128),
|
||||
row.setBinaryField_offset(reinterpret_cast<uint8_t*>(&val.__v.__s128),
|
||||
expression[i]->resultType().colWidth,
|
||||
row.getOffset(expression[i]->outputIndex()));
|
||||
else
|
||||
row.setBinaryField(reinterpret_cast<uint8_t*>(&val.__v.__u128),
|
||||
row.setBinaryField_offset(reinterpret_cast<uint8_t*>(&val.__v.__u128),
|
||||
expression[i]->resultType().colWidth,
|
||||
row.getOffset(expression[i]->outputIndex()));
|
||||
}
|
||||
|
@ -1483,19 +1483,19 @@ void RowAggregation::doSum(const Row& rowIn, int64_t colIn, int64_t colOut, int
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t offset = fRow.getOffset(colOut);
|
||||
if (colDataType == execplan::CalpontSystemCatalog::DECIMAL)
|
||||
{
|
||||
int128_t *dec = reinterpret_cast<int128_t*>(wideValInPtr);
|
||||
// WIP MCOL-641 Replace Row::setBinaryField1
|
||||
if (isNull(fRowGroupOut, fRow, colOut))
|
||||
{
|
||||
fRow.setBinaryField1<int128_t>(dec, width, colOut);
|
||||
fRow.setBinaryField_offset(dec, sizeof(*dec), offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
int128_t *valOutPtr = fRow.getBinaryField<int128_t>(colOut);
|
||||
int128_t *valOutPtr = fRow.getBinaryField(valOutPtr, colOut);
|
||||
int128_t sum = *valOutPtr + *dec;
|
||||
fRow.setBinaryField1<int128_t>(&sum, width, colOut);
|
||||
fRow.setBinaryField_offset(&sum, sizeof(sum), offset);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1503,13 +1503,13 @@ void RowAggregation::doSum(const Row& rowIn, int64_t colIn, int64_t colOut, int
|
||||
uint128_t *dec = reinterpret_cast<uint128_t*>(wideValInPtr);
|
||||
if (isNull(fRowGroupOut, fRow, colOut))
|
||||
{
|
||||
fRow.setBinaryField1<uint128_t>(dec, width, colOut);
|
||||
fRow.setBinaryField_offset(dec, sizeof(*dec), offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint128_t *valOutPtr = fRow.getBinaryField<uint128_t>(colOut);
|
||||
uint128_t *valOutPtr = fRow.getBinaryField(valOutPtr, colOut);
|
||||
uint128_t sum = *valOutPtr + *dec;
|
||||
fRow.setBinaryField1<uint128_t>(&sum, width, colOut);
|
||||
fRow.setBinaryField_offset(&sum, sizeof(sum), offset);
|
||||
}
|
||||
}
|
||||
} // end-of isWideDataType block
|
||||
|
@ -2,41 +2,65 @@
|
||||
#include "rowgroup.h"
|
||||
#include "columnwidth.h"
|
||||
#include "joblisttypes.h"
|
||||
#include "iostream"
|
||||
|
||||
#define WIDE_DEC_PRECISION 38
|
||||
#define WIDE_DEC_PRECISION 38U
|
||||
#define INITIAL_ROW_OFFSET 2
|
||||
|
||||
using int128_t = __int128;
|
||||
using uint128_t = unsigned __int128;
|
||||
using CSCDataType = execplan::CalpontSystemCatalog::ColDataType;
|
||||
|
||||
class RowTest : public ::testing::Test {
|
||||
class RowDecimalTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
uint8_t width = utils::widthByPrecision(WIDE_DEC_PRECISION);
|
||||
uint32_t precision = WIDE_DEC_PRECISION;
|
||||
uint32_t oid =3001;
|
||||
|
||||
std::vector<uint32_t> offsets, roids, tkeys, cscale, cprecision;
|
||||
std::vector<execplan::CalpontSystemCatalog::ColDataType> types;
|
||||
offsets.push_back(INITIAL_ROW_OFFSET);
|
||||
offsets.push_back(width+INITIAL_ROW_OFFSET);
|
||||
offsets.push_back(width*2+INITIAL_ROW_OFFSET);
|
||||
roids.push_back(oid); roids.push_back(oid+1);
|
||||
tkeys.push_back(1); tkeys.push_back(1);
|
||||
std::vector<CSCDataType>types;
|
||||
std::vector<decltype(precision)>precisionVec;
|
||||
std::vector<uint32_t> roids, tkeys, cscale;
|
||||
types.push_back(execplan::CalpontSystemCatalog::DECIMAL);
|
||||
types.push_back(execplan::CalpontSystemCatalog::UDECIMAL);
|
||||
cscale.push_back(0); cscale.push_back(0);
|
||||
cprecision.push_back(WIDE_DEC_PRECISION);
|
||||
cprecision.push_back(WIDE_DEC_PRECISION);
|
||||
for (size_t i=0; i <= 3; i++) {
|
||||
types.push_back(execplan::CalpontSystemCatalog::DECIMAL);
|
||||
}
|
||||
precisionVec.push_back(precision);
|
||||
precisionVec.push_back(precision);
|
||||
precisionVec.push_back(18);
|
||||
precisionVec.push_back(9);
|
||||
precisionVec.push_back(4);
|
||||
precisionVec.push_back(2);
|
||||
std::vector<uint32_t>widthVec;
|
||||
uint32_t offset = INITIAL_ROW_OFFSET;
|
||||
offsets.push_back(offset);
|
||||
for (size_t i=0; i < types.size(); i++) {
|
||||
uint8_t width = utils::widthByPrecision(precisionVec[i]);
|
||||
widthVec.push_back(width);
|
||||
offset += width;
|
||||
offsets.push_back(offset);
|
||||
roids.push_back(oid+i);
|
||||
tkeys.push_back(i+1); cscale.push_back(0);
|
||||
}
|
||||
/*offsets.push_back(INITIAL_ROW_OFFSET);
|
||||
offsets.push_back(16+INITIAL_ROW_OFFSET);
|
||||
offsets.push_back(16*2+INITIAL_ROW_OFFSET);
|
||||
roids.push_back(oid); roids.push_back(oid+1);
|
||||
tkeys.push_back(1); tkeys.push_back(1);
|
||||
cscale.push_back(0); cscale.push_back(0);*/
|
||||
|
||||
rowgroup::RowGroup inRG(roids.size(), //column count
|
||||
offsets, //oldOffset
|
||||
roids, // column oids
|
||||
tkeys, //keys
|
||||
types, // types
|
||||
cscale, //scale
|
||||
cprecision, // precision
|
||||
precisionVec, // precision
|
||||
20, // sTableThreshold
|
||||
false //useStringTable
|
||||
);
|
||||
|
||||
//std::cout << inRG.toString() << std::endl;
|
||||
rg = inRG;
|
||||
rgD.reinit(rg);
|
||||
rg.setData(&rgD);
|
||||
@ -45,32 +69,61 @@ class RowTest : public ::testing::Test {
|
||||
rowSize = r.getSize();
|
||||
rg.getRow(0, &r);
|
||||
|
||||
std::vector<int128_t> sValueVector;
|
||||
std::vector<uint128_t> uValueVector;
|
||||
int128_t nullValue = 0;
|
||||
int128_t bigValue = 0;
|
||||
uint64_t* uint128_pod = reinterpret_cast<uint64_t*>(&nullValue);
|
||||
uint128_pod[0] = joblist::BINARYEMPTYROW;
|
||||
uint128_pod[1] = joblist::BINARYNULL;
|
||||
bigValue = 42*0xFFFFFFFFFFFFFFFFLL;
|
||||
|
||||
sValueVector.push_back(nullValue);
|
||||
sValueVector.push_back(-42);
|
||||
sValueVector.push_back(-42*0xFFFFFFFFFFFFFFFFLL);
|
||||
sValueVector.push_back(bigValue);
|
||||
sValueVector.push_back(0);
|
||||
sValueVector.push_back(nullValue-1);
|
||||
|
||||
uValueVector.push_back(nullValue);
|
||||
uValueVector.push_back(42);
|
||||
uValueVector.push_back(42*0xFFFFFFFFFFFFFFFFLL);
|
||||
uValueVector.push_back(bigValue);
|
||||
uValueVector.push_back(0);
|
||||
uValueVector.push_back(nullValue);
|
||||
uValueVector.push_back(nullValue-1);
|
||||
|
||||
for(size_t i = 0; i < sValueVector.size(); i++)
|
||||
{
|
||||
s8ValueVector.push_back(joblist::TINYINTNULL);
|
||||
s8ValueVector.push_back(-0x79);
|
||||
s8ValueVector.push_back(0);
|
||||
s8ValueVector.push_back(0x81);
|
||||
s8ValueVector.push_back(joblist::TINYINTNULL-1);
|
||||
|
||||
s16ValueVector.push_back(joblist::SMALLINTNULL);
|
||||
s16ValueVector.push_back(-0x79);
|
||||
s16ValueVector.push_back(0);
|
||||
s16ValueVector.push_back(0x81);
|
||||
s16ValueVector.push_back(joblist::SMALLINTNULL-1);
|
||||
|
||||
s32ValueVector.push_back(joblist::INTNULL);
|
||||
s32ValueVector.push_back(-0x79);
|
||||
s32ValueVector.push_back(0);
|
||||
s32ValueVector.push_back(0x81);
|
||||
s32ValueVector.push_back(joblist::INTNULL-1);
|
||||
|
||||
s64ValueVector.push_back(joblist::INTNULL);
|
||||
s64ValueVector.push_back(-0x79);
|
||||
s64ValueVector.push_back(0);
|
||||
s64ValueVector.push_back(0x81);
|
||||
s64ValueVector.push_back(joblist::INTNULL-1);
|
||||
|
||||
r.initToNull();
|
||||
r.nextRow(rowSize);
|
||||
for(size_t i = 1; i < sValueVector.size(); i++) {
|
||||
r.setBinaryField_offset(&sValueVector[i],
|
||||
sizeof(sValueVector[0]), INITIAL_ROW_OFFSET);
|
||||
sizeof(sValueVector[0]), offsets[0]);
|
||||
r.setBinaryField_offset(&uValueVector[i],
|
||||
sizeof(uValueVector[0]), INITIAL_ROW_OFFSET+width);
|
||||
sizeof(uValueVector[0]), offsets[1]);
|
||||
r.setIntField(s64ValueVector[i], 2);
|
||||
r.setIntField(s32ValueVector[i], 3);
|
||||
r.setIntField(s16ValueVector[i], 4);
|
||||
r.setIntField(s8ValueVector[i], 5);
|
||||
//std::cout << r.toString() << std::endl;
|
||||
r.nextRow(rowSize);
|
||||
}
|
||||
rowCount = sValueVector.size();
|
||||
@ -82,29 +135,70 @@ class RowTest : public ::testing::Test {
|
||||
rowgroup::RGData rgD;
|
||||
uint32_t rowSize;
|
||||
size_t rowCount;
|
||||
std::vector<int128_t> sValueVector;
|
||||
std::vector<uint128_t> uValueVector;
|
||||
std::vector<int64_t> s8ValueVector;
|
||||
std::vector<int64_t> s16ValueVector;
|
||||
std::vector<int64_t> s32ValueVector;
|
||||
std::vector<int64_t> s64ValueVector;
|
||||
std::vector<uint32_t> offsets;
|
||||
};
|
||||
|
||||
TEST_F(RowTest, NonNULLValuesCheck) {
|
||||
TEST_F(RowDecimalTest, NonNULLValuesCheck) {
|
||||
rg.getRow(1, &r);
|
||||
for (size_t i = 0; i <= rg.getRowCount(); i++)
|
||||
{
|
||||
for (size_t i = 1; i <= sValueVector.size(); i++) {
|
||||
EXPECT_FALSE(r.isNullValue(0));
|
||||
EXPECT_FALSE(r.isNullValue(1));
|
||||
EXPECT_FALSE(r.isNullValue(2));
|
||||
EXPECT_FALSE(r.isNullValue(3));
|
||||
EXPECT_FALSE(r.isNullValue(4));
|
||||
EXPECT_FALSE(r.isNullValue(5));
|
||||
r.nextRow(rowSize);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(RowTest, NULLValuesCheck) {
|
||||
TEST_F(RowDecimalTest, initToNullANDisNullValueValueCheck) {
|
||||
rg.getRow(0, &r);
|
||||
EXPECT_TRUE(r.isNullValue(0));
|
||||
EXPECT_TRUE(r.isNullValue(1));
|
||||
EXPECT_TRUE(r.isNullValue(2));
|
||||
EXPECT_TRUE(r.isNullValue(3));
|
||||
EXPECT_TRUE(r.isNullValue(4));
|
||||
EXPECT_TRUE(r.isNullValue(5));
|
||||
}
|
||||
|
||||
TEST_F(RowDecimalTest, getBinaryFieldCheck) {
|
||||
rg.getRow(0, &r);
|
||||
uint128_t* u128Value;
|
||||
int128_t* s128Value;
|
||||
// std::remove_reference<decltype(*u128Value)>::type uType;
|
||||
// std::remove_reference<decltype(*s128Value)>::type sType;
|
||||
|
||||
for (size_t i = 0; i < sValueVector.size(); i++) {
|
||||
s128Value = r.getBinaryField<int128_t>(0);
|
||||
EXPECT_EQ(*s128Value, sValueVector[i]);
|
||||
u128Value = r.getBinaryField<uint128_t>(1);
|
||||
EXPECT_EQ(*u128Value, uValueVector[i]);
|
||||
//EXPECT_EQ(r.getIntField(2),s64ValueVector[i]);
|
||||
//EXPECT_EQ(r.getIntField(3),s32ValueVector[i]);
|
||||
//EXPECT_EQ(r.getIntField(4),s16ValueVector[i]);
|
||||
//EXPECT_EQ(r.getIntField(5),s8ValueVector[i]);
|
||||
r.nextRow(rowSize);
|
||||
}
|
||||
}
|
||||
TEST_F(RowDecimalTest, toStringCheck) {
|
||||
std::string exemplar1("0: NULL NULL NULL NULL NULL NULL ");
|
||||
rg.getRow(0, &r);
|
||||
EXPECT_EQ(r.toString(), exemplar1);
|
||||
r.nextRow(rowSize);
|
||||
std::cout << r.toString() << std::endl;
|
||||
r.nextRow(rowSize);
|
||||
std::cout << r.toString() << std::endl;
|
||||
r.nextRow(rowSize);
|
||||
std::cout << r.toString() << std::endl;
|
||||
}
|
||||
|
||||
//Row::isNullValue_offset
|
||||
//toString
|
||||
//initToNull
|
||||
//toCSV
|
||||
//applyMapping
|
||||
//setBinaryField remove Field1 and combine setBinaryField
|
||||
//getBinaryField
|
||||
//Remove from set/getIntFields Varbinary
|
||||
//equals
|
||||
|
@ -43,6 +43,7 @@ using namespace execplan;
|
||||
#include "nullvaluemanip.h"
|
||||
#include "rowgroup.h"
|
||||
#include "dataconvert.h"
|
||||
#include "columnwidth.h"
|
||||
|
||||
#include "collation.h"
|
||||
|
||||
@ -636,16 +637,17 @@ string Row::toString() const
|
||||
break;
|
||||
// WIP
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
if (precision[i] > 18)
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
if (colWidths[i] > MAXLEGACYWIDTH)
|
||||
{
|
||||
char *buf = (char*)alloca(precision[i] + 3);
|
||||
// empty the buffer
|
||||
dataconvert::DataConvert::toString<uint128_t>(getBinaryField<uint128_t>(i),
|
||||
dataconvert::DataConvert::toString<int128_t>(getBinaryField<int128_t>(i),
|
||||
buf, precision[i]+3);
|
||||
os << buf << " ";
|
||||
break;
|
||||
}
|
||||
// fallback if the precision < 18
|
||||
// fallback if the the legacy DECIMAL
|
||||
default:
|
||||
os << getIntField(i) << " ";
|
||||
break;
|
||||
@ -709,6 +711,7 @@ string Row::toCSV() const
|
||||
}
|
||||
case CalpontSystemCatalog::BINARY:
|
||||
std::cout << __FILE__<< __LINE__ << ":" << "toCSV"<< std::endl;
|
||||
|
||||
default:
|
||||
os << getIntField(i);
|
||||
break;
|
||||
@ -877,7 +880,13 @@ void Row::initToNull()
|
||||
*((uint64_t*) &data[offsets[i]]) = joblist::UBIGINTNULL;
|
||||
break;
|
||||
case CalpontSystemCatalog::BINARY:
|
||||
std::cout << __FILE__<< ":" <<__LINE__ << " Fix for 16 Bytes ?" << std::endl;
|
||||
{
|
||||
uint64_t *dec = reinterpret_cast<uint64_t*>(&data[offsets[i]]);
|
||||
dec[0] = joblist::BINARYEMPTYROW;
|
||||
dec[1] = joblist::BINARYNULL;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
ostringstream os;
|
||||
os << "Row::initToNull(): got bad column type (" << types[i] <<
|
||||
@ -888,7 +897,7 @@ void Row::initToNull()
|
||||
}
|
||||
}
|
||||
|
||||
template<cscDataType cscDT, uint32_t width>
|
||||
template<cscDataType cscDT, int width>
|
||||
inline bool Row::isNullValue_offset(uint32_t offset) const
|
||||
{
|
||||
ostringstream os;
|
||||
@ -1052,21 +1061,13 @@ bool Row::isNullValue(uint32_t colIndex) const
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
// WIP MCOL-641 Allmighty hack.
|
||||
const uint32_t len = 16;
|
||||
uint32_t* lenPtr = const_cast<uint32_t*>(&len);
|
||||
*lenPtr = getColumnWidth(colIndex);
|
||||
return isNullValue_offset
|
||||
<execplan::CalpontSystemCatalog::DECIMAL,len>(offsets[colIndex]);
|
||||
|
||||
// WIP
|
||||
/*
|
||||
const int64_t *dec;
|
||||
switch (len)
|
||||
int32_t width = getColumnWidth(colIndex);
|
||||
switch (width)
|
||||
{
|
||||
// MCOL-641
|
||||
case 16:
|
||||
return isNullValue_offset
|
||||
<execplan::CalpontSystemCatalog::DECIMAL,len>(offsets[colIndex]);
|
||||
<execplan::CalpontSystemCatalog::DECIMAL,16>(offsets[colIndex]);
|
||||
|
||||
case 1 :
|
||||
return (data[offsets[colIndex]] == joblist::TINYINTNULL);
|
||||
@ -1080,7 +1081,7 @@ bool Row::isNullValue(uint32_t colIndex) const
|
||||
default:
|
||||
return (*((int64_t*) &data[offsets[colIndex]]) == static_cast<int64_t>(joblist::BIGINTNULL));
|
||||
}
|
||||
*/
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1647,7 +1648,7 @@ void applyMapping(const int* mapping, const Row& in, Row* out)
|
||||
// code precision 2 width convertor
|
||||
else if (UNLIKELY(in.getColTypes()[i] == execplan::CalpontSystemCatalog::DECIMAL &&
|
||||
in.getColumnWidth(i) == 16))
|
||||
out->setBinaryField(in.getBinaryField<uint8_t>(i), 16,
|
||||
out->setBinaryField_offset(in.getBinaryField<uint8_t>(i), 16,
|
||||
out->getOffset(mapping[i]));
|
||||
else if (in.isUnsigned(i))
|
||||
out->setUintField(in.getUintField(i), mapping[i]);
|
||||
|
@ -424,9 +424,8 @@ public:
|
||||
inline uint32_t getStringLength(uint32_t colIndex) const;
|
||||
void setStringField(const std::string& val, uint32_t colIndex);
|
||||
inline void setStringField(const uint8_t*, uint32_t len, uint32_t colIndex);
|
||||
inline void setBinaryField(const uint8_t* strdata, uint32_t length, uint32_t offset);
|
||||
template<typename T>
|
||||
inline void setBinaryField1(T* strdata, uint32_t width, uint32_t colIndex);
|
||||
inline void setBinaryField(T* strdata, uint32_t width, uint32_t colIndex);
|
||||
template<typename T>
|
||||
inline void setBinaryField_offset(T* strdata, uint32_t width, uint32_t colIndex);
|
||||
// support VARBINARY
|
||||
@ -440,9 +439,12 @@ public:
|
||||
inline const uint8_t* getVarBinaryField(uint32_t& len, uint32_t colIndex) const;
|
||||
inline void setVarBinaryField(const uint8_t* val, uint32_t len, uint32_t colIndex);
|
||||
|
||||
inline std::string getBinaryField(uint32_t colIndex) const;
|
||||
//inline std::string getBinaryField(uint32_t colIndex) const;
|
||||
template <typename T>
|
||||
inline T* getBinaryField(uint32_t colIndex) const;
|
||||
// To simplify parameter type deduction.
|
||||
template <typename T>
|
||||
inline T* getBinaryField(T* argtype, uint32_t colIndex) const;
|
||||
template <typename T>
|
||||
inline T* getBinaryField_offset(uint32_t offset) const;
|
||||
|
||||
@ -453,7 +455,7 @@ public:
|
||||
|
||||
uint64_t getNullValue(uint32_t colIndex) const;
|
||||
bool isNullValue(uint32_t colIndex) const;
|
||||
template<cscDataType cscDT, uint32_t len>
|
||||
template<cscDataType cscDT, int width>
|
||||
inline bool isNullValue_offset(uint32_t offset) const;
|
||||
|
||||
// when NULLs are pulled out via getIntField(), they come out with these values.
|
||||
@ -803,18 +805,21 @@ inline uint32_t Row::getStringLength(uint32_t colIndex) const
|
||||
return strnlen((char*) &data[offsets[colIndex]], getColumnWidth(colIndex));
|
||||
}
|
||||
|
||||
// WIP Remove this
|
||||
// Check whether memcpy affects perf here
|
||||
inline void Row::setBinaryField(const uint8_t* strdata, uint32_t length, uint32_t offset)
|
||||
/*inline void Row::setBinaryField(const uint8_t* strdata, uint32_t length, uint32_t offset)
|
||||
{
|
||||
memcpy(&data[offset], strdata, length);
|
||||
}
|
||||
}*/
|
||||
|
||||
// WIP MCOL-641. This method can be applied to uint8_t* buffers.
|
||||
template<typename T>
|
||||
inline void Row::setBinaryField1(T* value, uint32_t width, uint32_t colIndex)
|
||||
inline void Row::setBinaryField(T* value, uint32_t width, uint32_t colIndex)
|
||||
{
|
||||
memcpy(&data[offsets[colIndex]], value, width);
|
||||
}
|
||||
|
||||
// WIP MCOL-641. This method !cannot! be applied to uint8_t* buffers.
|
||||
template<typename T>
|
||||
inline void Row::setBinaryField_offset(T* value, uint32_t width, uint32_t offset)
|
||||
{
|
||||
@ -856,16 +861,24 @@ inline std::string Row::getStringField(uint32_t colIndex) const
|
||||
strnlen((char*) &data[offsets[colIndex]], getColumnWidth(colIndex)));
|
||||
}
|
||||
|
||||
inline std::string Row::getBinaryField(uint32_t colIndex) const
|
||||
/*inline std::string Row::getBinaryField(uint32_t colIndex) const
|
||||
{
|
||||
return std::string((char*) &data[offsets[colIndex]], getColumnWidth(colIndex));
|
||||
}
|
||||
}*/
|
||||
|
||||
// WIP MCOL-641
|
||||
template <typename T>
|
||||
inline T* Row::getBinaryField(uint32_t colIndex) const
|
||||
{
|
||||
return reinterpret_cast<T*>(&data[offsets[colIndex]]);
|
||||
//return reinterpret_cast<T*>(&data[offsets[colIndex]]);
|
||||
return getBinaryField_offset<T>(offsets[colIndex]);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T* Row::getBinaryField(T* argtype, uint32_t colIndex) const
|
||||
{
|
||||
//return reinterpret_cast<T*>(&data[offsets[colIndex]]);
|
||||
return getBinaryField_offset<T>(offsets[colIndex]);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -874,7 +887,6 @@ inline T* Row::getBinaryField_offset(uint32_t offset) const
|
||||
return reinterpret_cast<T*>(&data[offset]);
|
||||
}
|
||||
|
||||
|
||||
inline std::string Row::getVarBinaryStringField(uint32_t colIndex) const
|
||||
{
|
||||
if (inStringTable(colIndex))
|
||||
@ -994,12 +1006,7 @@ inline void Row::setUintField_offset(uint64_t val, uint32_t offset)
|
||||
case 8:
|
||||
*((uint64_t*) &data[offset]) = val;
|
||||
break;
|
||||
/* This doesn't look like appropriate place
|
||||
case 16:
|
||||
std::cout << __FILE__<< ":" <<__LINE__ << " Fix for 16 Bytes ?" << std::endl;
|
||||
*((uint64_t*) &data[offset]) = val;
|
||||
break;
|
||||
*/
|
||||
|
||||
default:
|
||||
idbassert(0);
|
||||
throw std::logic_error("Row::setUintField called on a non-uint32_t field");
|
||||
@ -1037,10 +1044,7 @@ inline void Row::setUintField(uint64_t val, uint32_t colIndex)
|
||||
case 8:
|
||||
*((uint64_t*) &data[offsets[colIndex]]) = val;
|
||||
break;
|
||||
case 16:
|
||||
std::cout << __FILE__<< ":" <<__LINE__ << " Fix for 16 Bytes ?" << std::endl;
|
||||
*((uint64_t*) &data[offsets[colIndex]]) = val;
|
||||
break;
|
||||
|
||||
default:
|
||||
idbassert(0);
|
||||
throw std::logic_error("Row::setUintField called on a non-uint32_t field");
|
||||
@ -1066,9 +1070,7 @@ inline void Row::setUintField(uint64_t val, uint32_t colIndex)
|
||||
case 8:
|
||||
*((uint64_t*) &data[offsets[colIndex]]) = val;
|
||||
break;
|
||||
case 16:
|
||||
std::cout << __FILE__<< ":" <<__LINE__ << " Fix for 16 Bytes ?" << std::endl;
|
||||
*((uint64_t*) &data[offsets[colIndex]]) = val;
|
||||
|
||||
default:
|
||||
idbassert(0);
|
||||
throw std::logic_error("Row::setUintField: bad length");
|
||||
@ -1095,8 +1097,7 @@ inline void Row::setIntField(int64_t val, uint32_t colIndex)
|
||||
case 8:
|
||||
*((int64_t*) &data[offsets[colIndex]]) = val;
|
||||
break;
|
||||
case 16:
|
||||
std::cout << __FILE__<< ":" <<__LINE__ << " Fix for 16 Bytes ?" << std::endl;
|
||||
|
||||
default:
|
||||
idbassert(0);
|
||||
throw std::logic_error("Row::setIntField: bad length");
|
||||
@ -1122,8 +1123,7 @@ inline void Row::setIntField(int64_t val, uint32_t colIndex)
|
||||
case 8:
|
||||
*((int64_t*) &data[offsets[colIndex]]) = val;
|
||||
break;
|
||||
case 16:
|
||||
std::cout << __FILE__<< ":" <<__LINE__ << " Fix for 16 Bytes ?" << std::endl;
|
||||
|
||||
default:
|
||||
idbassert(0);
|
||||
throw std::logic_error("Row::setIntField: bad length");
|
||||
|
Reference in New Issue
Block a user