Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into 0829-logical-partition
Browse files Browse the repository at this point in the history
Signed-off-by: HangyuanLiu <[email protected]>

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/statistic/StatisticUtils.java
  • Loading branch information
HangyuanLiu committed Sep 3, 2024
2 parents 1a5848e + a9652a2 commit 56d329f
Show file tree
Hide file tree
Showing 135 changed files with 4,126 additions and 844 deletions.
5 changes: 4 additions & 1 deletion be/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,8 @@ endif()

set(WL_START_GROUP "-Wl,--start-group")
set(WL_END_GROUP "-Wl,--end-group")
set(WL_LINK_STATIC "-Wl,-Bstatic")
set(WL_LINK_DYNAMIC "-Wl,-Bdynamic")

# Set starrocks libraries
set(STARROCKS_LINK_LIBS
Expand Down Expand Up @@ -963,7 +965,8 @@ if (NOT ("${MAKE_TEST}" STREQUAL "ON" AND "${BUILD_FOR_SANITIZE}" STREQUAL "ON")
endif()

set(STARROCKS_LINK_LIBS ${STARROCKS_LINK_LIBS}
-lresolv -lbfd -liberty -lc -lm -ldl -rdynamic -pthread -Wl,-wrap=__cxa_throw
${WL_LINK_STATIC} -lbfd
${WL_LINK_DYNAMIC} -lresolv -liberty -lc -lm -ldl -rdynamic -pthread -Wl,-wrap=__cxa_throw
)

# link gcov if WITH_GCOV is on
Expand Down
8 changes: 3 additions & 5 deletions be/src/column/adaptive_nullable_column.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,7 @@ class AdaptiveNullableColumn final : public ColumnFactory<NullableColumn, Adapti

StatusOr<ColumnPtr> upgrade_if_overflow() override {
materialized_nullable();
if (_null_column->capacity_limit_reached()) {
return Status::InternalError("Size of NullableColumn exceed the limit");
}
RETURN_IF_ERROR(_null_column->capacity_limit_reached());

return upgrade_helper_func(&_data_column);
}
Expand Down Expand Up @@ -556,9 +554,9 @@ class AdaptiveNullableColumn final : public ColumnFactory<NullableColumn, Adapti
return NullableColumn::debug_string();
}

bool capacity_limit_reached(std::string* msg = nullptr) const override {
Status capacity_limit_reached() const override {
materialized_nullable();
return NullableColumn::capacity_limit_reached(msg);
return NullableColumn::capacity_limit_reached();
}

void check_or_die() const override {
Expand Down
5 changes: 3 additions & 2 deletions be/src/column/array_column.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ class ArrayColumn final : public ColumnFactory<Column, ArrayColumn> {

std::string debug_string() const override;

bool capacity_limit_reached(std::string* msg = nullptr) const override {
return _elements->capacity_limit_reached(msg) || _offsets->capacity_limit_reached(msg);
Status capacity_limit_reached() const override {
RETURN_IF_ERROR(_elements->capacity_limit_reached());
return _offsets->capacity_limit_reached();
}

StatusOr<ColumnPtr> upgrade_if_overflow() override;
Expand Down
39 changes: 16 additions & 23 deletions be/src/column/binary_column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "gutil/bits.h"
#include "gutil/casts.h"
#include "gutil/strings/fastmem.h"
#include "gutil/strings/substitute.h"
#include "util/hash_util.hpp"
#include "util/mysql_row_buffer.h"
#include "util/raw_container.h"
Expand Down Expand Up @@ -738,45 +739,37 @@ bool BinaryColumnBase<T>::has_large_column() const {
}

template <typename T>
bool BinaryColumnBase<T>::capacity_limit_reached(std::string* msg) const {
Status BinaryColumnBase<T>::capacity_limit_reached() const {
static_assert(std::is_same_v<T, uint32_t> || std::is_same_v<T, uint64_t>);
if constexpr (std::is_same_v<T, uint32_t>) {
// The size limit of a single element is 2^32 - 1.
// The size limit of all elements is 2^32 - 1.
// The number limit of elements is 2^32 - 1.
if (_bytes.size() >= Column::MAX_CAPACITY_LIMIT) {
if (msg != nullptr) {
msg->append("Total byte size of binary column exceed the limit: " +
std::to_string(Column::MAX_CAPACITY_LIMIT));
}
return true;
return Status::CapacityLimitExceed(
strings::Substitute("Total byte size of binary column exceed the limit: $0",
std::to_string(Column::MAX_CAPACITY_LIMIT)));
} else if (_offsets.size() >= Column::MAX_CAPACITY_LIMIT) {
if (msg != nullptr) {
msg->append("Total row count of binary column exceed the limit: " +
std::to_string(Column::MAX_CAPACITY_LIMIT));
}
return true;
return Status::CapacityLimitExceed(
strings::Substitute("Total row count of binary column exceed the limit: $0",
std::to_string(Column::MAX_CAPACITY_LIMIT)));
} else {
return false;
return Status::OK();
}
} else {
// The size limit of a single element is 2^32 - 1.
// The size limit of all elements is 2^64 - 1.
// The number limit of elements is 2^32 - 1.
if (_bytes.size() >= Column::MAX_LARGE_CAPACITY_LIMIT) {
if (msg != nullptr) {
msg->append("Total byte size of large binary column exceed the limit: " +
std::to_string(Column::MAX_LARGE_CAPACITY_LIMIT));
}
return true;
return Status::CapacityLimitExceed(
strings::Substitute("Total byte size of large binary column exceed the limit: $0",
std::to_string(Column::MAX_LARGE_CAPACITY_LIMIT)));
} else if (_offsets.size() >= Column::MAX_CAPACITY_LIMIT) {
if (msg != nullptr) {
msg->append("Total row count of large binary column exceed the limit: " +
std::to_string(Column::MAX_CAPACITY_LIMIT));
}
return true;
return Status::CapacityLimitExceed(
strings::Substitute("Total row count of large binary column exceed the limit: $0",
std::to_string(Column::MAX_CAPACITY_LIMIT)));
} else {
return false;
return Status::OK();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion be/src/column/binary_column.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class BinaryColumnBase final : public ColumnFactory<Column, BinaryColumnBase<T>>
return ss.str();
}

bool capacity_limit_reached(std::string* msg = nullptr) const override;
Status capacity_limit_reached() const override;

private:
void _build_slices() const;
Expand Down
8 changes: 3 additions & 5 deletions be/src/column/chunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,11 @@ class Chunk {

std::string rebuild_csv_row(size_t index, const std::string& delimiter) const;

bool capacity_limit_reached(std::string* msg = nullptr) const {
Status capacity_limit_reached() const {
for (const auto& column : _columns) {
if (column->capacity_limit_reached(msg)) {
return true;
}
RETURN_IF_ERROR(column->capacity_limit_reached());
}
return false;
return Status::OK();
}

query_cache::owner_info& owner_info() { return _owner_info; }
Expand Down
2 changes: 1 addition & 1 deletion be/src/column/column.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ class Column {
// The interface will not free memory!!!
virtual void reset_column() { _delete_state = DEL_NOT_SATISFIED; }

virtual bool capacity_limit_reached(std::string* msg = nullptr) const = 0;
virtual Status capacity_limit_reached() const = 0;

virtual Status accept(ColumnVisitor* visitor) const = 0;

Expand Down
13 changes: 6 additions & 7 deletions be/src/column/const_column.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "column/datum.h"
#include "column/vectorized_fwd.h"
#include "common/logging.h"
#include "gutil/strings/substitute.h"

namespace starrocks {

Expand Down Expand Up @@ -251,15 +252,13 @@ class ConstColumn final : public ColumnFactory<Column, ConstColumn> {
return ss.str();
}

bool capacity_limit_reached(std::string* msg = nullptr) const override {
RETURN_IF_UNLIKELY(_data->capacity_limit_reached(msg), true);
Status capacity_limit_reached() const override {
RETURN_IF_ERROR(_data->capacity_limit_reached());
if (_size > Column::MAX_CAPACITY_LIMIT) {
if (msg != nullptr) {
msg->append("Row count of const column reach limit: " + std::to_string(Column::MAX_CAPACITY_LIMIT));
}
return true;
return Status::CapacityLimitExceed(strings::Substitute("Row count of const column reach limit: $0",
std::to_string(Column::MAX_CAPACITY_LIMIT)));
}
return false;
return Status::OK();
}

void check_or_die() const override;
Expand Down
7 changes: 2 additions & 5 deletions be/src/column/fixed_length_column_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ namespace starrocks {

template <typename T>
StatusOr<ColumnPtr> FixedLengthColumnBase<T>::upgrade_if_overflow() {
if (capacity_limit_reached()) {
return Status::InternalError("Size of FixedLengthColumn exceed the limit");
} else {
return nullptr;
}
RETURN_IF_ERROR(capacity_limit_reached());
return nullptr;
}

template <typename T>
Expand Down
13 changes: 6 additions & 7 deletions be/src/column/fixed_length_column_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "column/datum.h"
#include "column/vectorized_fwd.h"
#include "common/statusor.h"
#include "gutil/strings/substitute.h"
#include "runtime/decimalv2_value.h"
#include "types/date_value.hpp"
#include "types/timestamp_value.h"
Expand Down Expand Up @@ -236,15 +237,13 @@ class FixedLengthColumnBase : public ColumnFactory<Column, FixedLengthColumnBase

// The `_data` support one size(> 2^32), but some interface such as update_rows() will use index of uint32_t to
// access the item, so we should use 2^32 as the limit
bool capacity_limit_reached(std::string* msg = nullptr) const override {
Status capacity_limit_reached() const override {
if (_data.size() > Column::MAX_CAPACITY_LIMIT) {
if (msg != nullptr) {
msg->append("row count of fixed length column exceend the limit: " +
std::to_string(Column::MAX_CAPACITY_LIMIT));
}
return true;
return Status::CapacityLimitExceed(
strings::Substitute("row count of fixed length column exceend the limit: $0",
std::to_string(Column::MAX_CAPACITY_LIMIT)));
}
return false;
return Status::OK();
}

void check_or_die() const override {}
Expand Down
11 changes: 5 additions & 6 deletions be/src/column/json_column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "common/compiler_util.h"
#include "glog/logging.h"
#include "gutil/casts.h"
#include "gutil/strings/substitute.h"
#include "simd/simd.h"
#include "types/logical_type.h"
#include "util/hash_util.hpp"
Expand Down Expand Up @@ -430,14 +431,12 @@ void JsonColumn::reset_column() {
_path_to_index.clear();
}

bool JsonColumn::capacity_limit_reached(std::string* msg) const {
Status JsonColumn::capacity_limit_reached() const {
if (size() > Column::MAX_CAPACITY_LIMIT) {
if (msg != nullptr) {
msg->append("row count of object column exceed the limit: " + std::to_string(Column::MAX_CAPACITY_LIMIT));
}
return true;
return Status::CapacityLimitExceed(strings::Substitute("row count of object column exceed the limit: $0",
std::to_string(Column::MAX_CAPACITY_LIMIT)));
}
return false;
return Status::OK();
}

void JsonColumn::check_or_die() const {
Expand Down
2 changes: 1 addition & 1 deletion be/src/column/json_column.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class JsonColumn final : public ColumnFactory<ObjectColumn<JsonValue>, JsonColum
void swap_column(Column& rhs) override;
void reset_column() override;

bool capacity_limit_reached(std::string* msg = nullptr) const override;
Status capacity_limit_reached() const override;
void check_or_die() const override;

// support flat json on storage
Expand Down
7 changes: 4 additions & 3 deletions be/src/column/map_column.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ class MapColumn final : public ColumnFactory<Column, MapColumn> {

std::string debug_string() const override;

bool capacity_limit_reached(std::string* msg = nullptr) const override {
return _keys->capacity_limit_reached(msg) || _values->capacity_limit_reached(msg) ||
_offsets->capacity_limit_reached(msg);
Status capacity_limit_reached() const override {
RETURN_IF_ERROR(_keys->capacity_limit_reached());
RETURN_IF_ERROR(_values->capacity_limit_reached());
return _offsets->capacity_limit_reached();
}

StatusOr<ColumnPtr> upgrade_if_overflow() override;
Expand Down
4 changes: 1 addition & 3 deletions be/src/column/nullable_column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,7 @@ void NullableColumn::check_or_die() const {
}

StatusOr<ColumnPtr> NullableColumn::upgrade_if_overflow() {
if (_null_column->capacity_limit_reached()) {
return Status::InternalError("Size of NullableColumn exceed the limit");
}
RETURN_IF_ERROR(_null_column->capacity_limit_reached());

return upgrade_helper_func(&_data_column);
}
Expand Down
5 changes: 3 additions & 2 deletions be/src/column/nullable_column.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,9 @@ class NullableColumn : public ColumnFactory<Column, NullableColumn> {
return ss.str();
}

bool capacity_limit_reached(std::string* msg = nullptr) const override {
return _data_column->capacity_limit_reached(msg) || _null_column->capacity_limit_reached(msg);
Status capacity_limit_reached() const override {
RETURN_IF_ERROR(_data_column->capacity_limit_reached());
return _null_column->capacity_limit_reached();
}

void check_or_die() const override;
Expand Down
4 changes: 1 addition & 3 deletions be/src/column/object_column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,7 @@ std::string ObjectColumn<BitmapValue>::debug_item(size_t idx) const {

template <typename T>
StatusOr<ColumnPtr> ObjectColumn<T>::upgrade_if_overflow() {
if (capacity_limit_reached()) {
return Status::InternalError("Size of ObjectColumn exceed the limit");
}
RETURN_IF_ERROR(capacity_limit_reached());
return nullptr;
}

Expand Down
14 changes: 6 additions & 8 deletions be/src/column/object_column.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "column/datum.h"
#include "column/vectorized_fwd.h"
#include "common/object_pool.h"
#include "gutil/strings/substitute.h"
#include "types/bitmap_value.h"
#include "types/hll.h"
#include "util/json.h"
Expand Down Expand Up @@ -213,15 +214,12 @@ class ObjectColumn : public ColumnFactory<Column, ObjectColumn<T>> {
return ss.str();
}

bool capacity_limit_reached(std::string* msg = nullptr) const override {
Status capacity_limit_reached() const override {
if (_pool.size() > Column::MAX_CAPACITY_LIMIT) {
if (msg != nullptr) {
msg->append("row count of object column exceed the limit: " +
std::to_string(Column::MAX_CAPACITY_LIMIT));
}
return true;
return Status::CapacityLimitExceed(strings::Substitute("row count of object column exceed the limit: $0",
std::to_string(Column::MAX_CAPACITY_LIMIT)));
}
return false;
return Status::OK();
}

StatusOr<ColumnPtr> upgrade_if_overflow() override;
Expand All @@ -230,7 +228,7 @@ class ObjectColumn : public ColumnFactory<Column, ObjectColumn<T>> {

bool has_large_column() const override { return false; }

void check_or_die() const {}
void check_or_die() const override {}

private:
// add this to avoid warning clang-diagnostic-overloaded-virtual
Expand Down
7 changes: 3 additions & 4 deletions be/src/column/struct_column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,11 @@ void StructColumn::swap_column(Column& rhs) {
// _field_names dont need swap
}

bool StructColumn::capacity_limit_reached(std::string* msg) const {
bool res = false;
Status StructColumn::capacity_limit_reached() const {
for (const auto& column : _fields) {
res = res || column->capacity_limit_reached(msg);
RETURN_IF_ERROR(column->capacity_limit_reached());
}
return res;
return Status::OK();
}

void StructColumn::check_or_die() const {
Expand Down
2 changes: 1 addition & 1 deletion be/src/column/struct_column.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class StructColumn final : public ColumnFactory<Column, StructColumn> {

void reset_column() override;

bool capacity_limit_reached(std::string* msg = nullptr) const override;
Status capacity_limit_reached() const override;

void check_or_die() const override;

Expand Down
Loading

0 comments on commit 56d329f

Please sign in to comment.