Reduce some usage of StringRef

See #39535 and #39300
This commit is contained in:
Robert Schulze 2022-08-21 18:10:32 +00:00
parent 3aa5acdb35
commit 4caf2c4c33
No known key found for this signature in database
GPG Key ID: 26703B55FB13728A
9 changed files with 16 additions and 16 deletions

View File

@ -269,7 +269,7 @@ public:
bool isFixedAndContiguous() const override { return data->isFixedAndContiguous(); } bool isFixedAndContiguous() const override { return data->isFixedAndContiguous(); }
bool valuesHaveFixedSize() const override { return data->valuesHaveFixedSize(); } bool valuesHaveFixedSize() const override { return data->valuesHaveFixedSize(); }
size_t sizeOfValueIfFixed() const override { return data->sizeOfValueIfFixed(); } size_t sizeOfValueIfFixed() const override { return data->sizeOfValueIfFixed(); }
StringRef getRawData() const override { return data->getRawData(); } std::string_ref getRawData() const override { return data->getRawData(); }
/// Not part of the common interface. /// Not part of the common interface.

View File

@ -71,9 +71,9 @@ public:
data.resize_assume_reserved(data.size() - n); data.resize_assume_reserved(data.size() - n);
} }
StringRef getRawData() const override std::string_view getRawData() const override
{ {
return StringRef(reinterpret_cast<const char*>(data.data()), byteSize()); return {reinterpret_cast<const char*>(data.data()), byteSize()};
} }
StringRef getDataAt(size_t n) const override StringRef getDataAt(size_t n) const override

View File

@ -209,7 +209,7 @@ public:
bool isFixedAndContiguous() const override { return true; } bool isFixedAndContiguous() const override { return true; }
size_t sizeOfValueIfFixed() const override { return n; } size_t sizeOfValueIfFixed() const override { return n; }
StringRef getRawData() const override { return StringRef(chars.data(), chars.size()); } std::string_view getRawData() const override { return {chars.data(), chars.size()}; }
/// Specialized part of interface, not from IColumn. /// Specialized part of interface, not from IColumn.
void insertString(const String & string) { insertData(string.c_str(), string.size()); } void insertString(const String & string) { insertData(string.c_str(), string.size()); }

View File

@ -332,9 +332,9 @@ public:
bool isFixedAndContiguous() const override { return true; } bool isFixedAndContiguous() const override { return true; }
size_t sizeOfValueIfFixed() const override { return sizeof(T); } size_t sizeOfValueIfFixed() const override { return sizeof(T); }
StringRef getRawData() const override std::string_view getRawData() const override
{ {
return StringRef(reinterpret_cast<const char*>(data.data()), byteSize()); return {reinterpret_cast<const char*>(data.data()), byteSize()};
} }
StringRef getDataAt(size_t n) const override StringRef getDataAt(size_t n) const override

View File

@ -507,7 +507,7 @@ public:
[[nodiscard]] virtual bool isFixedAndContiguous() const { return false; } [[nodiscard]] virtual bool isFixedAndContiguous() const { return false; }
/// If isFixedAndContiguous, returns the underlying data array, otherwise throws an exception. /// If isFixedAndContiguous, returns the underlying data array, otherwise throws an exception.
[[nodiscard]] virtual StringRef getRawData() const { throw Exception("Column " + getName() + " is not a contiguous block of memory", ErrorCodes::NOT_IMPLEMENTED); } [[nodiscard]] virtual std::string_view getRawData() const { throw Exception("Column " + getName() + " is not a contiguous block of memory", ErrorCodes::NOT_IMPLEMENTED); }
/// If valuesHaveFixedSize, returns size of value, otherwise throw an exception. /// If valuesHaveFixedSize, returns size of value, otherwise throw an exception.
[[nodiscard]] virtual size_t sizeOfValueIfFixed() const { throw Exception("Values of column " + getName() + " are not fixed size.", ErrorCodes::CANNOT_GET_SIZE_OF_FIELD); } [[nodiscard]] virtual size_t sizeOfValueIfFixed() const { throw Exception("Values of column " + getName() + " are not fixed size.", ErrorCodes::CANNOT_GET_SIZE_OF_FIELD); }

View File

@ -41,12 +41,12 @@ struct HashMethodOneNumber
/// If the keys of a fixed length then key_sizes contains their lengths, empty otherwise. /// If the keys of a fixed length then key_sizes contains their lengths, empty otherwise.
HashMethodOneNumber(const ColumnRawPtrs & key_columns, const Sizes & /*key_sizes*/, const HashMethodContextPtr &) HashMethodOneNumber(const ColumnRawPtrs & key_columns, const Sizes & /*key_sizes*/, const HashMethodContextPtr &)
{ {
vec = key_columns[0]->getRawData().data; vec = key_columns[0]->getRawData().data();
} }
explicit HashMethodOneNumber(const IColumn * column) explicit HashMethodOneNumber(const IColumn * column)
{ {
vec = column->getRawData().data; vec = column->getRawData().data();
} }
/// Creates context. Method is called once and result context is used in all threads. /// Creates context. Method is called once and result context is used in all threads.
@ -577,7 +577,7 @@ struct HashMethodKeysFixed
columns_data.reset(new const char*[keys_size]); columns_data.reset(new const char*[keys_size]);
for (size_t i = 0; i < keys_size; ++i) for (size_t i = 0; i < keys_size; ++i)
columns_data[i] = Base::getActualColumns()[i]->getRawData().data; columns_data[i] = Base::getActualColumns()[i]->getRawData().data();
} }
#endif #endif
} }

View File

@ -301,7 +301,7 @@ private:
ColumnFixedString::Chars & data_to = dst.getChars(); ColumnFixedString::Chars & data_to = dst.getChars();
data_to.resize(n * rows); data_to.resize(n * rows);
memcpy(data_to.data(), src.getRawData().data, data_to.size()); memcpy(data_to.data(), src.getRawData().data(), data_to.size());
} }
static void NO_INLINE executeToString(const IColumn & src, ColumnString & dst) static void NO_INLINE executeToString(const IColumn & src, ColumnString & dst)

View File

@ -113,14 +113,14 @@ public:
const auto & null_map_column = nullable_column->getNullMapColumn(); const auto & null_map_column = nullable_column->getNullMapColumn();
auto nested_column_raw_data = nested_column.getRawData(); auto nested_column_raw_data = nested_column.getRawData();
__msan_unpoison(nested_column_raw_data.data, nested_column_raw_data.size); __msan_unpoison(nested_column_raw_data.data(), nested_column_raw_data.size());
auto null_map_column_raw_data = null_map_column.getRawData(); auto null_map_column_raw_data = null_map_column.getRawData();
__msan_unpoison(null_map_column_raw_data.data, null_map_column_raw_data.size); __msan_unpoison(null_map_column_raw_data.data(), null_map_column_raw_data.size());
} }
else else
{ {
__msan_unpoison(result_column->getRawData().data, result_column->getRawData().size); __msan_unpoison(result_column->getRawData().data(), result_column->getRawData().size());
} }
#endif #endif

View File

@ -47,11 +47,11 @@ ColumnData getColumnData(const IColumn * column)
if (const auto * nullable = typeid_cast<const ColumnNullable *>(column)) if (const auto * nullable = typeid_cast<const ColumnNullable *>(column))
{ {
result.null_data = nullable->getNullMapColumn().getRawData().data; result.null_data = nullable->getNullMapColumn().getRawData().data();
column = & nullable->getNestedColumn(); column = & nullable->getNestedColumn();
} }
result.data = column->getRawData().data; result.data = column->getRawData().data();
return result; return result;
} }