csun5285 commented on code in PR #67949:
URL: https://github.com/apache/doris/pull/67949#discussion_r4004657778
##########
be/src/core/data_type_serde/data_type_string_serde.cpp:
##########
@@ -847,12 +847,15 @@ Status
DataTypeStringSerDeBase<ColumnType>::from_string(StringRef& str, IColumn&
template <typename ColumnType>
Status DataTypeStringSerDeBase<ColumnType>::from_olap_string(const
std::string& str, Field& field,
const
FormatOptions& options) const {
- // CHAR(N) writes through OlapColumnDataConvertorChar are zero-padded to
- // the declared schema length, so the serialized OLAP string carries
- // trailing '\0' bytes. strnlen() drops that padding to surface the
- // logical character content in the Field. VARCHAR / STRING never write
- // trailing '\0' through this path, so strnlen is a no-op for them.
- size_t len = strnlen(str.data(), str.size());
+ // CHAR(N) is zero-padded to the declared schema length before it is
written, so its
+ // stored bytes carry trailing '\0' and stop at the first one. The page
read path cuts
+ // CHAR values the same way (see BinaryPlainPageCharStripPreDecoder), so a
bound built
+ // like this stays comparable with the rows it describes.
+ //
+ // VARCHAR and STRING keep every byte they were given, '\0' included.
Cutting such a
+ // value at an embedded '\0' would give a bound the data never held, and a
zone map
+ // built from it prunes rows that match.
+ size_t len = _type == TYPE_CHAR ? strnlen(str.data(), str.size()) :
str.size();
Review Comment:
https://github.com/apache/doris/pull/67642
##########
be/src/core/data_type_serde/data_type_string_serde.cpp:
##########
@@ -847,12 +847,15 @@ Status
DataTypeStringSerDeBase<ColumnType>::from_string(StringRef& str, IColumn&
template <typename ColumnType>
Status DataTypeStringSerDeBase<ColumnType>::from_olap_string(const
std::string& str, Field& field,
const
FormatOptions& options) const {
- // CHAR(N) writes through OlapColumnDataConvertorChar are zero-padded to
- // the declared schema length, so the serialized OLAP string carries
- // trailing '\0' bytes. strnlen() drops that padding to surface the
- // logical character content in the Field. VARCHAR / STRING never write
- // trailing '\0' through this path, so strnlen is a no-op for them.
- size_t len = strnlen(str.data(), str.size());
+ // CHAR(N) is zero-padded to the declared schema length before it is
written, so its
+ // stored bytes carry trailing '\0' and stop at the first one. The page
read path cuts
+ // CHAR values the same way (see BinaryPlainPageCharStripPreDecoder), so a
bound built
+ // like this stays comparable with the rows it describes.
+ //
+ // VARCHAR and STRING keep every byte they were given, '\0' included.
Cutting such a
+ // value at an embedded '\0' would give a bound the data never held, and a
zone map
+ // built from it prunes rows that match.
+ size_t len = _type == TYPE_CHAR ? strnlen(str.data(), str.size()) :
str.size();
Review Comment:
https://github.com/apache/doris/pull/67642 已经修复
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]