You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-641 Work of Ivan Zuniga on basic read and write support for Binary16
This commit is contained in:
committed by
Roman Nozdrin
parent
d943beb445
commit
32f6167067
@ -123,7 +123,9 @@ int ColumnOp::allocRowId(const TxnID& txnid, bool useStartingExtent,
|
||||
newFile = false;
|
||||
Column newCol;
|
||||
unsigned char buf[BYTE_PER_BLOCK];
|
||||
|
||||
unsigned char* curVal;
|
||||
int64_t emptyVal = getEmptyRowValue(column.colDataType, column.colWidth); // Seems is ok have it here and just once
|
||||
|
||||
if (useStartingExtent)
|
||||
{
|
||||
// ZZ. For insert select, skip the hwm block and start inserting from the next block
|
||||
@ -137,10 +139,10 @@ int ColumnOp::allocRowId(const TxnID& txnid, bool useStartingExtent,
|
||||
|
||||
if ( rc != NO_ERROR)
|
||||
return rc;
|
||||
|
||||
for (j = 0; j < totalRowPerBlock; j++)
|
||||
|
||||
for (j = 0, curVal = buf; j < totalRowPerBlock; j++, curVal += column.colWidth)
|
||||
{
|
||||
if (isEmptyRow(buf, j, column))
|
||||
if (isEmptyRow((uint64_t*)curVal, emptyVal, column.colWidth))
|
||||
{
|
||||
rowIdArray[counter] = getRowId(hwm, column.colWidth, j);
|
||||
rowsallocated++;
|
||||
@ -192,9 +194,9 @@ int ColumnOp::allocRowId(const TxnID& txnid, bool useStartingExtent,
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < totalRowPerBlock; j++)
|
||||
for (j = 0, curVal = buf; j < totalRowPerBlock; j++, curVal += column.colWidth)
|
||||
{
|
||||
if (isEmptyRow(buf, j, column))
|
||||
if (isEmptyRow((uint64_t*)curVal, emptyVal, column.colWidth))
|
||||
{
|
||||
rowIdArray[counter] = getRowId(hwm, column.colWidth, j);
|
||||
rowsallocated++;
|
||||
@ -492,9 +494,9 @@ int ColumnOp::allocRowId(const TxnID& txnid, bool useStartingExtent,
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < totalRowPerBlock; j++)
|
||||
for (j = 0, curVal = buf; j < totalRowPerBlock; j++, curVal += column.colWidth)
|
||||
{
|
||||
if (isEmptyRow(buf, j, column))
|
||||
if (isEmptyRow((uint64_t*)curVal, emptyVal, column.colWidth)) // Why to check it if beacause line 483 is always true ?
|
||||
{
|
||||
rowIdArray[counter] = getRowId(newHwm, column.colWidth, j);
|
||||
rowsallocated++;
|
||||
@ -533,9 +535,9 @@ int ColumnOp::allocRowId(const TxnID& txnid, bool useStartingExtent,
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < totalRowPerBlock; j++)
|
||||
for (j = 0, curVal = buf; j < totalRowPerBlock; j++, curVal += column.colWidth)
|
||||
{
|
||||
if (isEmptyRow(buf, j, column))
|
||||
if (isEmptyRow((uint64_t*)curVal, emptyVal, column.colWidth))
|
||||
{
|
||||
rowIdArray[counter] = getRowId(newHwm, newCol.colWidth, j);
|
||||
rowsallocated++;
|
||||
@ -1064,7 +1066,7 @@ int ColumnOp::fillColumn(const TxnID& txnid, Column& column, Column& refCol, voi
|
||||
startColFbo++;
|
||||
colBufOffset = 0;
|
||||
}
|
||||
|
||||
|
||||
while (((refBufOffset + refCol.colWidth) <= BYTE_PER_BLOCK) &&
|
||||
((colBufOffset + column.colWidth) <= BYTE_PER_BLOCK))
|
||||
{
|
||||
@ -1080,7 +1082,8 @@ int ColumnOp::fillColumn(const TxnID& txnid, Column& column, Column& refCol, voi
|
||||
}
|
||||
else if (column.compressionType != 0) //@Bug 3866, fill the empty row value for compressed chunk
|
||||
{
|
||||
memcpy(colBuf + colBufOffset, &emptyVal, column.colWidth);
|
||||
for(int b = 0, w = column.colWidth; b < column.colWidth; b += 8, w = 8) //FIXME for no loop!
|
||||
memcpy(colBuf + colBufOffset + b, &emptyVal, w);
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
@ -1405,18 +1408,39 @@ void ColumnOp::initColumn(Column& column) const
|
||||
* RETURN:
|
||||
* true if success, false otherwise
|
||||
***********************************************************/
|
||||
bool ColumnOp::isEmptyRow(unsigned char* buf, int offset, const Column& column)
|
||||
|
||||
// It is called at just 4 places on allocRowId() but all the time inside extend scanning loops
|
||||
inline bool ColumnOp::isEmptyRow(uint64_t* curVal, uint64_t emptyVal, const int colWidth)
|
||||
{
|
||||
bool emptyFlag = true;
|
||||
uint64_t curVal, emptyVal;
|
||||
//Calling it here makes calling it "i" times from the calling loop at allocRowId()
|
||||
//uint64_t emptyVal = getEmptyRowValue(column.colDataType, column.colWidth);
|
||||
|
||||
// No need for it if change param type.. just been lazy to add extra castings
|
||||
//uint64_t &emptyVal = column.emptyVal;
|
||||
|
||||
//no need to multiply over and over if just increment the pointer on the caller
|
||||
//uint64_t *curVal = (uint64_t*)(buf + offset * column.colWidth);
|
||||
|
||||
memcpy(&curVal, buf + offset * column.colWidth, column.colWidth);
|
||||
emptyVal = getEmptyRowValue(column.colDataType, column.colWidth);
|
||||
switch(colWidth){
|
||||
case 1:
|
||||
return *(uint8_t*)curVal == emptyVal;
|
||||
|
||||
if (/*curVal != emptyVal*/memcmp(&curVal, &emptyVal, column.colWidth))
|
||||
emptyFlag = false;
|
||||
|
||||
return emptyFlag;
|
||||
case 2:
|
||||
return *(uint16_t*)curVal == emptyVal;
|
||||
|
||||
case 4:
|
||||
return *(uint32_t*)curVal == emptyVal;
|
||||
|
||||
case 8:
|
||||
return *curVal == emptyVal;
|
||||
|
||||
case 16:
|
||||
return ((curVal[0] == emptyVal) && (curVal[1] == emptyVal));
|
||||
|
||||
case 32:
|
||||
return ((curVal[0] == emptyVal) && (curVal[1] == emptyVal)
|
||||
&& (curVal[2] == emptyVal) && (curVal[3] == emptyVal));
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
@ -1534,7 +1558,7 @@ void ColumnOp::setColParam(Column& column,
|
||||
column.colWidth = colWidth;
|
||||
column.colType = colType;
|
||||
column.colDataType = colDataType;
|
||||
|
||||
|
||||
column.dataFile.fid = dataFid;
|
||||
column.dataFile.fDbRoot = dbRoot;
|
||||
column.dataFile.fPartition = partition;
|
||||
@ -1662,6 +1686,12 @@ int ColumnOp::writeRow(Column& curCol, uint64_t totalRow, const RID* rowIdArray,
|
||||
if (!bDelete) pVal = &((uint64_t*) valArray)[i];
|
||||
break;
|
||||
|
||||
case WriteEngine::WR_BINARY:
|
||||
if (!bDelete) pVal = (uint8_t*) valArray + i * curCol.colWidth;
|
||||
|
||||
//pOldVal = (uint8_t*) oldValArray + i * curCol.colWidth;
|
||||
break;
|
||||
|
||||
default :
|
||||
if (!bDelete) pVal = &((int*) valArray)[i];
|
||||
break;
|
||||
@ -1669,7 +1699,7 @@ int ColumnOp::writeRow(Column& curCol, uint64_t totalRow, const RID* rowIdArray,
|
||||
|
||||
if (bDelete)
|
||||
{
|
||||
emptyVal = getEmptyRowValue(curCol.colDataType, curCol.colWidth);
|
||||
emptyVal = getEmptyRowValue(curCol.colDataType, curCol.colWidth);
|
||||
pVal = &emptyVal;
|
||||
}
|
||||
|
||||
@ -1852,7 +1882,8 @@ int ColumnOp::writeRows(Column& curCol, uint64_t totalRow, const RIDList& ridLis
|
||||
}
|
||||
|
||||
// This is the write stuff
|
||||
writeBufValue(dataBuf + dataBio, pVal, curCol.colWidth);
|
||||
for(int b = 0, w = curCol.colWidth > 8 ? 8 : curCol.colWidth; b < curCol.colWidth; b += 8) //FIXME for no loop
|
||||
writeBufValue(dataBuf + dataBio + b, pVal, w);
|
||||
|
||||
i++;
|
||||
|
||||
|
Reference in New Issue
Block a user