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-1786 Reduce the performance degradation caused by iequals.
This commit is contained in:
@ -31,8 +31,6 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
|
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
|
||||||
|
|
||||||
#include "we_bulkload.h"
|
#include "we_bulkload.h"
|
||||||
#include "we_bulkloadbuffer.h"
|
#include "we_bulkloadbuffer.h"
|
||||||
#include "we_brm.h"
|
#include "we_brm.h"
|
||||||
@ -370,18 +368,11 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
|
|||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
if (iequals(field, "true"))
|
|
||||||
{
|
|
||||||
fVal = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
fVal = (float)strtod( field, 0 );
|
fVal = (float)strtod( field, 0 );
|
||||||
#else
|
#else
|
||||||
fVal = strtof( field, 0 );
|
fVal = strtof( field, 0 );
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
if (errno == ERANGE)
|
if (errno == ERANGE)
|
||||||
{
|
{
|
||||||
@ -414,6 +405,11 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
|
|||||||
fVal = minFltSat;
|
fVal = minFltSat;
|
||||||
bufStats.satCount++;
|
bufStats.satCount++;
|
||||||
}
|
}
|
||||||
|
if ( fVal == 0
|
||||||
|
&& isTrueWord(const_cast<const char*>(field), fieldLength) )
|
||||||
|
{
|
||||||
|
fVal = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,14 +470,7 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
|
|||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
if (iequals(field, "true"))
|
dVal = strtod(field, 0);
|
||||||
{
|
|
||||||
dVal = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dVal = strtod(field, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errno == ERANGE)
|
if (errno == ERANGE)
|
||||||
{
|
{
|
||||||
@ -514,6 +503,11 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
|
|||||||
dVal = column.fMinDblSat;
|
dVal = column.fMinDblSat;
|
||||||
bufStats.satCount++;
|
bufStats.satCount++;
|
||||||
}
|
}
|
||||||
|
else if (dVal == 0
|
||||||
|
&& isTrueWord(const_cast<const char*>(field), fieldLength))
|
||||||
|
{
|
||||||
|
dVal = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -629,12 +623,6 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (iequals(field, "true"))
|
|
||||||
{
|
|
||||||
strcpy(field, "1");
|
|
||||||
fieldLength = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( (column.dataType == CalpontSystemCatalog::DECIMAL ) ||
|
if ( (column.dataType == CalpontSystemCatalog::DECIMAL ) ||
|
||||||
(column.dataType == CalpontSystemCatalog::UDECIMAL) )
|
(column.dataType == CalpontSystemCatalog::UDECIMAL) )
|
||||||
{
|
{
|
||||||
@ -664,6 +652,11 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
|
|||||||
origVal = static_cast<int64_t>(column.fMaxIntSat);
|
origVal = static_cast<int64_t>(column.fMaxIntSat);
|
||||||
bSatVal = true;
|
bSatVal = true;
|
||||||
}
|
}
|
||||||
|
else if ( origVal == 0
|
||||||
|
&& isTrueWord(const_cast<const char*>(field), fieldLength) )
|
||||||
|
{
|
||||||
|
origVal = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (bSatVal)
|
if (bSatVal)
|
||||||
bufStats.satCount++;
|
bufStats.satCount++;
|
||||||
@ -722,15 +715,8 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
|
|||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
if (iequals(field, "true"))
|
origVal = strtoll(field, 0, 10);
|
||||||
{
|
|
||||||
origVal = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
origVal = strtoll(field, 0, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errno == ERANGE)
|
if (errno == ERANGE)
|
||||||
bSatVal = true;
|
bSatVal = true;
|
||||||
}
|
}
|
||||||
@ -747,6 +733,11 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
|
|||||||
origVal = static_cast<int64_t>(column.fMaxIntSat);
|
origVal = static_cast<int64_t>(column.fMaxIntSat);
|
||||||
bSatVal = true;
|
bSatVal = true;
|
||||||
}
|
}
|
||||||
|
else if ( origVal == 0
|
||||||
|
&& isTrueWord(const_cast<const char*>(field), fieldLength) )
|
||||||
|
{
|
||||||
|
origVal = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (bSatVal)
|
if (bSatVal)
|
||||||
bufStats.satCount++;
|
bufStats.satCount++;
|
||||||
@ -805,12 +796,12 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (iequals(field, "true"))
|
if (isTrueWord(const_cast<const char*>(field), fieldLength))
|
||||||
{
|
{
|
||||||
strcpy(field, "1");
|
strcpy(field, "1");
|
||||||
fieldLength = 1;
|
fieldLength = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (column.dataType == CalpontSystemCatalog::DECIMAL ) ||
|
if ( (column.dataType == CalpontSystemCatalog::DECIMAL ) ||
|
||||||
(column.dataType == CalpontSystemCatalog::UDECIMAL))
|
(column.dataType == CalpontSystemCatalog::UDECIMAL))
|
||||||
{
|
{
|
||||||
@ -898,14 +889,7 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
|
|||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
if (iequals(field, "true"))
|
origVal = strtoll(field, 0, 10);
|
||||||
{
|
|
||||||
origVal = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
origVal = strtoll(field, 0, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errno == ERANGE)
|
if (errno == ERANGE)
|
||||||
bSatVal = true;
|
bSatVal = true;
|
||||||
@ -923,6 +907,11 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
|
|||||||
origVal = static_cast<int64_t>(column.fMaxIntSat);
|
origVal = static_cast<int64_t>(column.fMaxIntSat);
|
||||||
bSatVal = true;
|
bSatVal = true;
|
||||||
}
|
}
|
||||||
|
else if ( origVal == 0
|
||||||
|
&& isTrueWord(const_cast<const char*>(field), fieldLength) )
|
||||||
|
{
|
||||||
|
origVal = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (bSatVal)
|
if (bSatVal)
|
||||||
bufStats.satCount++;
|
bufStats.satCount++;
|
||||||
@ -981,12 +970,12 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (iequals(field, "true"))
|
if (isTrueWord(const_cast<const char*>(field), fieldLength))
|
||||||
{
|
{
|
||||||
strcpy(field, "1");
|
strcpy(field, "1");
|
||||||
fieldLength = 1;
|
fieldLength = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (column.dataType == CalpontSystemCatalog::DECIMAL) ||
|
if ( (column.dataType == CalpontSystemCatalog::DECIMAL) ||
|
||||||
(column.dataType == CalpontSystemCatalog::UDECIMAL))
|
(column.dataType == CalpontSystemCatalog::UDECIMAL))
|
||||||
{
|
{
|
||||||
@ -1018,6 +1007,7 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
|
|||||||
bSatVal = true;
|
bSatVal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (bSatVal)
|
if (bSatVal)
|
||||||
bufStats.satCount++;
|
bufStats.satCount++;
|
||||||
|
|
||||||
@ -1199,14 +1189,7 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
|
|||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
if (iequals(field, "true"))
|
ullVal = strtoull(field, 0, 10);
|
||||||
{
|
|
||||||
ullVal = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ullVal = strtoull(field, 0, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errno == ERANGE)
|
if (errno == ERANGE)
|
||||||
bSatVal = true;
|
bSatVal = true;
|
||||||
@ -1220,6 +1203,11 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
|
|||||||
ullVal = column.fMaxIntSat;
|
ullVal = column.fMaxIntSat;
|
||||||
bSatVal = true;
|
bSatVal = true;
|
||||||
}
|
}
|
||||||
|
else if ( ullVal == 0
|
||||||
|
&& isTrueWord(const_cast<const char*>(field), fieldLength) )
|
||||||
|
{
|
||||||
|
ullVal = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (bSatVal)
|
if (bSatVal)
|
||||||
bufStats.satCount++;
|
bufStats.satCount++;
|
||||||
@ -1276,14 +1264,7 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
|
|||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
if (iequals(field, "true"))
|
origVal = strtoll(field, 0, 10);
|
||||||
{
|
|
||||||
origVal = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
origVal = strtoll(field, 0, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errno == ERANGE)
|
if (errno == ERANGE)
|
||||||
bSatVal = true;
|
bSatVal = true;
|
||||||
@ -1301,6 +1282,11 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
|
|||||||
origVal = static_cast<int64_t>(column.fMaxIntSat);
|
origVal = static_cast<int64_t>(column.fMaxIntSat);
|
||||||
bSatVal = true;
|
bSatVal = true;
|
||||||
}
|
}
|
||||||
|
else if ( origVal == 0
|
||||||
|
&& isTrueWord(const_cast<const char*>(field), fieldLength) )
|
||||||
|
{
|
||||||
|
origVal = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (bSatVal)
|
if (bSatVal)
|
||||||
bufStats.satCount++;
|
bufStats.satCount++;
|
||||||
@ -1361,12 +1347,12 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (iequals(field, "true"))
|
if (isTrueWord(const_cast<const char*>(field), fieldLength))
|
||||||
{
|
{
|
||||||
strcpy(field, "1");
|
strcpy(field, "1");
|
||||||
fieldLength = 1;
|
fieldLength = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (column.dataType == CalpontSystemCatalog::DECIMAL) ||
|
if ( (column.dataType == CalpontSystemCatalog::DECIMAL) ||
|
||||||
(column.dataType == CalpontSystemCatalog::UDECIMAL))
|
(column.dataType == CalpontSystemCatalog::UDECIMAL))
|
||||||
{
|
{
|
||||||
|
@ -383,5 +383,14 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline bool isTrueWord(const char *field, int fieldLength)
|
||||||
|
{
|
||||||
|
//return false;
|
||||||
|
return fieldLength == 4 && ( field[0] == 'T' || field[0] == 't' )
|
||||||
|
&& ( field[1] == 'R' || field[1] == 'r' )
|
||||||
|
&& ( field[2] == 'U' || field[2] == 'u' )
|
||||||
|
&& ( field[3] == 'E' || field[3] == 'e' );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user