mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-16 11:22:12 +00:00
Added some comments and fixed some format
This commit is contained in:
parent
bb8a96b6d9
commit
b4f481e724
@ -824,8 +824,7 @@ struct JSONExtractTree
|
|||||||
class LowCardinalityFixedStringNode : public Node
|
class LowCardinalityFixedStringNode : public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LowCardinalityFixedStringNode(const size_t fixed_length_)
|
LowCardinalityFixedStringNode(const size_t fixed_length_) : fixed_length(fixed_length_) {}
|
||||||
: fixed_length(fixed_length_) {}
|
|
||||||
bool insertResultToColumn(IColumn & dest, const Element & element) override
|
bool insertResultToColumn(IColumn & dest, const Element & element) override
|
||||||
{
|
{
|
||||||
auto str = element.getString();
|
auto str = element.getString();
|
||||||
@ -833,12 +832,15 @@ struct JSONExtractTree
|
|||||||
if (str.size() > fixed_length)
|
if (str.size() > fixed_length)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// For the non low cardinality case of FixedString, the padding is done in the FixedString Column implementation.
|
||||||
|
// In order to avoid having to pass the data to a FixedString Column and read it back (which would slow down the execution)
|
||||||
|
// the data is padded here and writen directly to the Low Cardinality Column
|
||||||
auto padded_str = str.data() + std::string(fixed_length - std::min(fixed_length, str.length()), '\0');
|
auto padded_str = str.data() + std::string(fixed_length - std::min(fixed_length, str.length()), '\0');
|
||||||
|
|
||||||
assert_cast<ColumnLowCardinality &>(dest).insertData(padded_str.data(), padded_str.size());
|
assert_cast<ColumnLowCardinality &>(dest).insertData(padded_str.data(), padded_str.size());
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const size_t fixed_length;
|
const size_t fixed_length;
|
||||||
};
|
};
|
||||||
@ -880,6 +882,7 @@ struct JSONExtractTree
|
|||||||
assert_cast<ColumnDecimal<DecimalType> &>(dest).insert(result);
|
assert_cast<ColumnDecimal<DecimalType> &>(dest).insert(result);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DataTypePtr data_type;
|
DataTypePtr data_type;
|
||||||
};
|
};
|
||||||
@ -1128,6 +1131,11 @@ struct JSONExtractTree
|
|||||||
case TypeIndex::UUID: return std::make_unique<UUIDNode>();
|
case TypeIndex::UUID: return std::make_unique<UUIDNode>();
|
||||||
case TypeIndex::LowCardinality:
|
case TypeIndex::LowCardinality:
|
||||||
{
|
{
|
||||||
|
// The low cardinality case is treated in two different ways:
|
||||||
|
// For FixedString type, an especial class is implemented for inserting the data in the destination column,
|
||||||
|
// as the string length must be passed in order to check and pad the incoming data.
|
||||||
|
// For the rest of low cardinality types, the insertion is done in their corresponding class, adapting the data
|
||||||
|
// as needed for the insertData function of the ColumnLowCardinality.
|
||||||
auto dictionary_type = typeid_cast<const DataTypeLowCardinality *>(type.get())->getDictionaryType();
|
auto dictionary_type = typeid_cast<const DataTypeLowCardinality *>(type.get())->getDictionaryType();
|
||||||
if ((*dictionary_type).getTypeId() == TypeIndex::FixedString)
|
if ((*dictionary_type).getTypeId() == TypeIndex::FixedString)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user