1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-27 16:01:57 +03:00

MCOL-3536 use Locale for compare of strings in ORDER BY

This commit is contained in:
David Hall
2019-10-07 09:21:09 -05:00
parent 1f475340dc
commit b747e9ab92
4 changed files with 20 additions and 11 deletions

View File

@@ -54,11 +54,10 @@ public:
void finalize(); void finalize();
protected: protected:
uint64_t fStart; uint64_t fStart;
uint64_t fCount; uint64_t fCount;
}; };
} }
#endif // LIMITED_ORDER_BY_H #endif // LIMITED_ORDER_BY_H

View File

@@ -53,7 +53,7 @@ extern std::locale loc;
// Is there a way to construct a global reference to a facet? // Is there a way to construct a global reference to a facet?
// const std::collate<char>& coll = std::use_facet<std::collate<char> >(loc); // const std::collate<char>& coll = std::use_facet<std::collate<char> >(loc);
//Infinidb version of strlocale BUG 5362 //Columnstore version of strlocale BUG 5362
//set System Locale "C" by default //set System Locale "C" by default
//return the system Locale currently set in from Columnstore.xml //return the system Locale currently set in from Columnstore.xml
inline inline

View File

@@ -375,6 +375,7 @@ public:
inline std::string getStringField(uint32_t colIndex) const; inline std::string getStringField(uint32_t colIndex) const;
inline const uint8_t* getStringPointer(uint32_t colIndex) const; inline const uint8_t* getStringPointer(uint32_t colIndex) const;
inline uint32_t getStringLength(uint32_t colIndex) const; inline uint32_t getStringLength(uint32_t colIndex) const;
inline const char* getCharPtrField(uint32_t colIndex, int& len) const;
void setStringField(const std::string& val, uint32_t colIndex); void setStringField(const std::string& val, uint32_t colIndex);
inline void setStringField(const uint8_t*, uint32_t len, uint32_t colIndex); inline void setStringField(const uint8_t*, uint32_t len, uint32_t colIndex);
@@ -774,6 +775,17 @@ inline std::string Row::getStringField(uint32_t colIndex) const
strnlen((char*) &data[offsets[colIndex]], getColumnWidth(colIndex))); strnlen((char*) &data[offsets[colIndex]], getColumnWidth(colIndex)));
} }
// Return a char* to the string field with len
inline const char* Row::getCharPtrField(uint32_t colIndex, int& len) const
{
len = getStringLength(colIndex);
if (inStringTable(colIndex))
{
return (const char*)strings->getPointer(*((uint64_t*) &data[offsets[colIndex]]));
}
return (char*)&data[offsets[colIndex]];
}
inline std::string Row::getVarBinaryStringField(uint32_t colIndex) const inline std::string Row::getVarBinaryStringField(uint32_t colIndex) const
{ {
if (inStringTable(colIndex)) if (inStringTable(colIndex))

View File

@@ -130,13 +130,11 @@ int StringCompare::operator()(IdbCompare* l, Row::Pointer r1, Row::Pointer r2)
} }
else else
{ {
string v1 = l->row1().getStringField(fSpec.fIndex); int len1, len2;
string v2 = l->row2().getStringField(fSpec.fIndex); const char* s1 = l->row1().getCharPtrField(fSpec.fIndex, len1);
const char* s2 = l->row2().getCharPtrField(fSpec.fIndex, len2);
if (v1 > v2) const std::collate<char>& coll = std::use_facet<std::collate<char> >(loc);
ret = fSpec.fAsc; ret = fSpec.fAsc * coll.compare(s1, s1+len1, s2, s2+len2);
else if (v1 < v2)
ret = -fSpec.fAsc;
} }
return ret; return ret;