You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2022/08/05 03:04:44 UTC
[doris] branch master updated: [refactor](schema change) Using tablet schema shared ptr instead of raw ptr (#11475)
This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 321107cb40 [refactor](schema change) Using tablet schema shared ptr instead of raw ptr (#11475)
321107cb40 is described below
commit 321107cb40ff7855a6a4f6a2ea51f99e3aa1873e
Author: yiguolei <67...@qq.com>
AuthorDate: Fri Aug 5 11:04:38 2022 +0800
[refactor](schema change) Using tablet schema shared ptr instead of raw ptr (#11475)
* Using tabletschema shared ptr instead of raw ptrs
Co-authored-by: yiguolei <yi...@gmail.com>
---
be/src/exec/olap_scanner.cpp | 23 ++--
be/src/exec/olap_scanner.h | 2 +-
be/src/olap/collect_iterator.cpp | 2 +-
be/src/olap/compaction.cpp | 4 +-
be/src/olap/delete_handler.cpp | 4 +-
be/src/olap/delete_handler.h | 3 +-
be/src/olap/delta_writer.cpp | 2 +-
be/src/olap/iterators.h | 2 +-
be/src/olap/merger.cpp | 13 +-
be/src/olap/merger.h | 4 +-
be/src/olap/olap_cond.h | 4 +-
be/src/olap/push_handler.cpp | 4 +-
be/src/olap/reader.cpp | 6 +-
be/src/olap/reader.h | 4 +-
be/src/olap/row_block.cpp | 2 +-
be/src/olap/row_block.h | 6 +-
be/src/olap/row_cursor.cpp | 37 +++--
be/src/olap/row_cursor.h | 14 +-
be/src/olap/rowset/beta_rowset_reader.cpp | 2 +-
be/src/olap/rowset/rowset_reader_context.h | 2 +-
be/src/olap/rowset/segment_v2/segment_writer.cpp | 5 +-
be/src/olap/rowset/segment_v2/segment_writer.h | 2 +-
be/src/olap/schema.h | 10 +-
be/src/olap/schema_change.cpp | 149 ++++++++++-----------
be/src/olap/schema_change.h | 12 +-
be/src/olap/tablet.cpp | 12 +-
be/src/olap/task/engine_checksum_task.cpp | 4 +-
be/src/vec/exec/volap_scanner.cpp | 28 ++--
be/src/vec/exec/volap_scanner.h | 2 +-
be/test/olap/block_column_predicate_test.cpp | 46 +++----
.../olap/bloom_filter_column_predicate_test.cpp | 14 +-
be/test/olap/comparison_predicate_test.cpp | 108 +++++++--------
be/test/olap/delete_handler_test.cpp | 12 +-
be/test/olap/in_list_predicate_test.cpp | 78 +++++------
be/test/olap/null_predicate_test.cpp | 102 +++++++-------
be/test/olap/row_block_test.cpp | 48 +++----
be/test/olap/row_block_v2_test.cpp | 8 +-
be/test/olap/row_cursor_test.cpp | 46 +++----
be/test/olap/rowset/beta_rowset_test.cpp | 6 +-
be/test/olap/rowset/segment_v2/segment_test.cpp | 110 +++++++--------
be/test/util/key_util_test.cpp | 16 +--
41 files changed, 478 insertions(+), 480 deletions(-)
diff --git a/be/src/exec/olap_scanner.cpp b/be/src/exec/olap_scanner.cpp
index 4fe1bff489..161b1e0d3b 100644
--- a/be/src/exec/olap_scanner.cpp
+++ b/be/src/exec/olap_scanner.cpp
@@ -53,6 +53,7 @@ OlapScanner::OlapScanner(RuntimeState* runtime_state, OlapScanNode* parent, bool
_need_agg_finalize(need_agg_finalize),
_version(-1) {
_mem_tracker = tracker;
+ _tablet_schema = std::make_shared<TabletSchema>();
}
Status OlapScanner::prepare(
@@ -79,12 +80,12 @@ Status OlapScanner::prepare(
LOG(WARNING) << ss.str();
return Status::InternalError(ss.str());
}
- _tablet_schema.copy_from(*_tablet->tablet_schema());
+ _tablet_schema->copy_from(*_tablet->tablet_schema());
if (!_parent->_olap_scan_node.columns_desc.empty() &&
_parent->_olap_scan_node.columns_desc[0].col_unique_id >= 0) {
- _tablet_schema.clear_columns();
+ _tablet_schema->clear_columns();
for (const auto& column_desc : _parent->_olap_scan_node.columns_desc) {
- _tablet_schema.append_column(TabletColumn(column_desc));
+ _tablet_schema->append_column(TabletColumn(column_desc));
}
}
{
@@ -189,7 +190,7 @@ Status OlapScanner::_init_tablet_reader_params(
RETURN_IF_ERROR(_init_return_columns(!_tablet_reader_params.direct_mode));
_tablet_reader_params.tablet = _tablet;
- _tablet_reader_params.tablet_schema = &_tablet_schema;
+ _tablet_reader_params.tablet_schema = _tablet_schema;
_tablet_reader_params.reader_type = READER_QUERY;
_tablet_reader_params.aggregation = _aggregation;
_tablet_reader_params.version = Version(0, _version);
@@ -234,7 +235,7 @@ Status OlapScanner::_init_tablet_reader_params(
_tablet_reader_params.return_columns.push_back(i);
}
for (auto index : _return_columns) {
- if (_tablet_schema.column(index).is_key()) {
+ if (_tablet_schema->column(index).is_key()) {
continue;
} else {
_tablet_reader_params.return_columns.push_back(index);
@@ -270,8 +271,8 @@ Status OlapScanner::_init_return_columns(bool need_seq_col) {
continue;
}
int32_t index = slot->col_unique_id() >= 0
- ? _tablet_schema.field_index(slot->col_unique_id())
- : _tablet_schema.field_index(slot->col_name());
+ ? _tablet_schema->field_index(slot->col_unique_id())
+ : _tablet_schema->field_index(slot->col_name());
if (index < 0) {
std::stringstream ss;
ss << "field name is invalid. field=" << slot->col_name();
@@ -279,22 +280,22 @@ Status OlapScanner::_init_return_columns(bool need_seq_col) {
return Status::InternalError(ss.str());
}
_return_columns.push_back(index);
- if (slot->is_nullable() && !_tablet_schema.column(index).is_nullable())
+ if (slot->is_nullable() && !_tablet_schema->column(index).is_nullable())
_tablet_columns_convert_to_null_set.emplace(index);
_query_slots.push_back(slot);
}
// expand the sequence column
- if (_tablet_schema.has_sequence_col() && need_seq_col) {
+ if (_tablet_schema->has_sequence_col() && need_seq_col) {
bool has_replace_col = false;
for (auto col : _return_columns) {
- if (_tablet_schema.column(col).aggregation() ==
+ if (_tablet_schema->column(col).aggregation() ==
FieldAggregationMethod::OLAP_FIELD_AGGREGATION_REPLACE) {
has_replace_col = true;
break;
}
}
- if (auto sequence_col_idx = _tablet_schema.sequence_col_idx();
+ if (auto sequence_col_idx = _tablet_schema->sequence_col_idx();
has_replace_col && std::find(_return_columns.begin(), _return_columns.end(),
sequence_col_idx) == _return_columns.end()) {
_return_columns.push_back(sequence_col_idx);
diff --git a/be/src/exec/olap_scanner.h b/be/src/exec/olap_scanner.h
index ea128dc9dd..1bb890dfd3 100644
--- a/be/src/exec/olap_scanner.h
+++ b/be/src/exec/olap_scanner.h
@@ -153,7 +153,7 @@ protected:
MemTracker* _mem_tracker;
- TabletSchema _tablet_schema;
+ TabletSchemaSPtr _tablet_schema;
};
} // namespace doris
diff --git a/be/src/olap/collect_iterator.cpp b/be/src/olap/collect_iterator.cpp
index dd98303108..138110ba06 100644
--- a/be/src/olap/collect_iterator.cpp
+++ b/be/src/olap/collect_iterator.cpp
@@ -202,7 +202,7 @@ CollectIterator::Level0Iterator::Level0Iterator(RowsetReaderSharedPtr rs_reader,
CollectIterator::Level0Iterator::~Level0Iterator() = default;
Status CollectIterator::Level0Iterator::init() {
- RETURN_NOT_OK_LOG(_row_cursor.init(*_reader->_tablet_schema, _reader->_seek_columns),
+ RETURN_NOT_OK_LOG(_row_cursor.init(_reader->_tablet_schema, _reader->_seek_columns),
"failed to init row cursor");
return (this->*_refresh_current_row)();
}
diff --git a/be/src/olap/compaction.cpp b/be/src/olap/compaction.cpp
index 163b7c8faf..5b1620d884 100644
--- a/be/src/olap/compaction.cpp
+++ b/be/src/olap/compaction.cpp
@@ -171,10 +171,10 @@ Status Compaction::do_compaction_impl(int64_t permits) {
}
if (use_vectorized_compaction) {
- res = Merger::vmerge_rowsets(_tablet, compaction_type(), cur_tablet_schema.get(),
+ res = Merger::vmerge_rowsets(_tablet, compaction_type(), cur_tablet_schema,
_input_rs_readers, _output_rs_writer.get(), &stats);
} else {
- res = Merger::merge_rowsets(_tablet, compaction_type(), cur_tablet_schema.get(),
+ res = Merger::merge_rowsets(_tablet, compaction_type(), cur_tablet_schema,
_input_rs_readers, _output_rs_writer.get(), &stats);
}
diff --git a/be/src/olap/delete_handler.cpp b/be/src/olap/delete_handler.cpp
index f3a24731ab..3c529df9cf 100644
--- a/be/src/olap/delete_handler.cpp
+++ b/be/src/olap/delete_handler.cpp
@@ -237,7 +237,7 @@ bool DeleteHandler::_parse_condition(const std::string& condition_str, TConditio
return true;
}
-Status DeleteHandler::init(const TabletSchema& schema,
+Status DeleteHandler::init(TabletSchemaSPtr schema,
const std::vector<DeletePredicatePB>& delete_conditions, int64_t version,
const TabletReader* reader) {
DCHECK(!_is_inited) << "reinitialize delete handler.";
@@ -258,7 +258,7 @@ Status DeleteHandler::init(const TabletSchema& schema,
return Status::OLAPInternalError(OLAP_ERR_MALLOC_ERROR);
}
- temp.del_cond->set_tablet_schema(&schema);
+ temp.del_cond->set_tablet_schema(schema);
for (const auto& sub_predicate : delete_condition.sub_predicates()) {
TCondition condition;
if (!_parse_condition(sub_predicate, &condition)) {
diff --git a/be/src/olap/delete_handler.h b/be/src/olap/delete_handler.h
index f3f68eff5d..02e015a0e0 100644
--- a/be/src/olap/delete_handler.h
+++ b/be/src/olap/delete_handler.h
@@ -25,6 +25,7 @@
#include "olap/block_column_predicate.h"
#include "olap/column_predicate.h"
#include "olap/olap_define.h"
+#include "olap/tablet_schema.h"
namespace doris {
@@ -89,7 +90,7 @@ public:
// return:
// * Status::OLAPInternalError(OLAP_ERR_DELETE_INVALID_PARAMETERS): input parameters are not valid
// * Status::OLAPInternalError(OLAP_ERR_MALLOC_ERROR): alloc memory failed
- Status init(const TabletSchema& schema, const std::vector<DeletePredicatePB>& delete_conditions,
+ Status init(TabletSchemaSPtr schema, const std::vector<DeletePredicatePB>& delete_conditions,
int64_t version, const doris::TabletReader* = nullptr);
// Return the delete conditions' size.
diff --git a/be/src/olap/delta_writer.cpp b/be/src/olap/delta_writer.cpp
index 1d28e56dd5..58c914e6d4 100644
--- a/be/src/olap/delta_writer.cpp
+++ b/be/src/olap/delta_writer.cpp
@@ -131,7 +131,7 @@ Status DeltaWriter::init() {
RETURN_NOT_OK(_tablet->create_rowset_writer(_req.txn_id, _req.load_id, PREPARED, OVERLAPPING,
_tablet_schema, &_rowset_writer));
- _schema.reset(new Schema(*_tablet_schema));
+ _schema.reset(new Schema(_tablet_schema));
_reset_mem_table();
// create flush handler
diff --git a/be/src/olap/iterators.h b/be/src/olap/iterators.h
index d18f74b094..ffbb80329f 100644
--- a/be/src/olap/iterators.h
+++ b/be/src/olap/iterators.h
@@ -93,7 +93,7 @@ public:
bool use_page_cache = false;
int block_row_max = 4096;
- const TabletSchema* tablet_schema = nullptr;
+ TabletSchemaSPtr tablet_schema = nullptr;
bool record_rowids = false;
};
diff --git a/be/src/olap/merger.cpp b/be/src/olap/merger.cpp
index e6f769c6c5..efdaadef76 100644
--- a/be/src/olap/merger.cpp
+++ b/be/src/olap/merger.cpp
@@ -30,7 +30,7 @@
namespace doris {
Status Merger::merge_rowsets(TabletSharedPtr tablet, ReaderType reader_type,
- const TabletSchema* cur_tablet_schema,
+ TabletSchemaSPtr cur_tablet_schema,
const std::vector<RowsetReaderSharedPtr>& src_rowset_readers,
RowsetWriter* dst_rowset_writer, Merger::Statistics* stats_output) {
TRACE_COUNTER_SCOPE_LATENCY_US("merge_rowsets_latency_us");
@@ -47,9 +47,9 @@ Status Merger::merge_rowsets(TabletSharedPtr tablet, ReaderType reader_type,
RowCursor row_cursor;
RETURN_NOT_OK_LOG(
- row_cursor.init(*cur_tablet_schema),
+ row_cursor.init(cur_tablet_schema),
"failed to init row cursor when merging rowsets of tablet " + tablet->full_name());
- row_cursor.allocate_memory_for_string_type(*cur_tablet_schema);
+ row_cursor.allocate_memory_for_string_type(cur_tablet_schema);
std::unique_ptr<MemPool> mem_pool(new MemPool());
@@ -91,7 +91,7 @@ Status Merger::merge_rowsets(TabletSharedPtr tablet, ReaderType reader_type,
}
Status Merger::vmerge_rowsets(TabletSharedPtr tablet, ReaderType reader_type,
- const TabletSchema* cur_tablet_schema,
+ TabletSchemaSPtr cur_tablet_schema,
const std::vector<RowsetReaderSharedPtr>& src_rowset_readers,
RowsetWriter* dst_rowset_writer, Statistics* stats_output) {
TRACE_COUNTER_SCOPE_LATENCY_US("merge_rowsets_latency_us");
@@ -108,8 +108,7 @@ Status Merger::vmerge_rowsets(TabletSharedPtr tablet, ReaderType reader_type,
reader_params.record_rowids = true;
}
- const auto& schema = *cur_tablet_schema;
- reader_params.return_columns.resize(schema.num_columns());
+ reader_params.return_columns.resize(cur_tablet_schema->num_columns());
std::iota(reader_params.return_columns.begin(), reader_params.return_columns.end(), 0);
reader_params.origin_return_columns = &reader_params.return_columns;
RETURN_NOT_OK(reader.init(reader_params));
@@ -124,7 +123,7 @@ Status Merger::vmerge_rowsets(TabletSharedPtr tablet, ReaderType reader_type,
}
}
- vectorized::Block block = schema.create_block(reader_params.return_columns);
+ vectorized::Block block = cur_tablet_schema->create_block(reader_params.return_columns);
size_t output_rows = 0;
bool eof = false;
while (!eof) {
diff --git a/be/src/olap/merger.h b/be/src/olap/merger.h
index 0059202c05..e0286e158d 100644
--- a/be/src/olap/merger.h
+++ b/be/src/olap/merger.h
@@ -38,12 +38,12 @@ public:
// return OLAP_SUCCESS and set statistics into `*stats_output`.
// return others on error
static Status merge_rowsets(TabletSharedPtr tablet, ReaderType reader_type,
- const TabletSchema* cur_tablet_schema,
+ TabletSchemaSPtr cur_tablet_schema,
const std::vector<RowsetReaderSharedPtr>& src_rowset_readers,
RowsetWriter* dst_rowset_writer, Statistics* stats_output);
static Status vmerge_rowsets(TabletSharedPtr tablet, ReaderType reader_type,
- const TabletSchema* cur_tablet_schema,
+ TabletSchemaSPtr cur_tablet_schema,
const std::vector<RowsetReaderSharedPtr>& src_rowset_readers,
RowsetWriter* dst_rowset_writer, Statistics* stats_output);
};
diff --git a/be/src/olap/olap_cond.h b/be/src/olap/olap_cond.h
index cdf10cbbc4..4c6afe1c9d 100644
--- a/be/src/olap/olap_cond.h
+++ b/be/src/olap/olap_cond.h
@@ -158,7 +158,7 @@ public:
bool empty() const { return _columns.empty(); }
// TODO(yingchun): should do it in constructor
- void set_tablet_schema(const TabletSchema* schema) { _schema = schema; }
+ void set_tablet_schema(TabletSchemaSPtr schema) { _schema = schema; }
// 如果成功,则_columns中增加一项,如果失败则无视此condition,同时输出日志
// 对于下列情况,将不会被处理
@@ -176,7 +176,7 @@ private:
}
private:
- const TabletSchema* _schema = nullptr;
+ TabletSchemaSPtr _schema = nullptr;
// CondColumns in _index_conds are in 'AND' relationship
CondColumns _columns; // list of condition column
diff --git a/be/src/olap/push_handler.cpp b/be/src/olap/push_handler.cpp
index 8c5637abb9..7cae605904 100644
--- a/be/src/olap/push_handler.cpp
+++ b/be/src/olap/push_handler.cpp
@@ -220,7 +220,7 @@ Status PushHandler::_convert_v2(TabletSharedPtr cur_tablet, RowsetSharedPtr* cur
}
// init schema
- std::unique_ptr<Schema> schema(new (std::nothrow) Schema(*tablet_schema));
+ std::unique_ptr<Schema> schema(new (std::nothrow) Schema(tablet_schema));
if (schema == nullptr) {
LOG(WARNING) << "fail to create schema. tablet=" << cur_tablet->full_name();
res = Status::OLAPInternalError(OLAP_ERR_MALLOC_ERROR);
@@ -363,7 +363,7 @@ Status PushHandler::_convert(TabletSharedPtr cur_tablet, RowsetSharedPtr* cur_ro
<< ", block_row_size=" << cur_tablet->num_rows_per_row_block();
// 4. Init RowCursor
- if (!(res = row.init(*tablet_schema))) {
+ if (!(res = row.init(tablet_schema))) {
LOG(WARNING) << "fail to init rowcursor. res=" << res;
break;
}
diff --git a/be/src/olap/reader.cpp b/be/src/olap/reader.cpp
index 50f4e7178a..35b07cacc8 100644
--- a/be/src/olap/reader.cpp
+++ b/be/src/olap/reader.cpp
@@ -402,7 +402,7 @@ Status TabletReader::_init_keys_param(const ReaderParams& read_params) {
}
Status res = _keys_param.start_keys[i].init_scan_key(
- *_tablet_schema, read_params.start_key[i].values(), schema);
+ _tablet_schema, read_params.start_key[i].values(), schema);
if (!res.ok()) {
LOG(WARNING) << "fail to init row cursor. res = " << res;
return res;
@@ -424,7 +424,7 @@ Status TabletReader::_init_keys_param(const ReaderParams& read_params) {
return Status::OLAPInternalError(OLAP_ERR_INPUT_PARAMETER_ERROR);
}
- Status res = _keys_param.end_keys[i].init_scan_key(*_tablet_schema,
+ Status res = _keys_param.end_keys[i].init_scan_key(_tablet_schema,
read_params.end_key[i].values(), schema);
if (!res.ok()) {
LOG(WARNING) << "fail to init row cursor. res = " << res;
@@ -613,7 +613,7 @@ Status TabletReader::_init_delete_condition(const ReaderParams& read_params) {
}
auto delete_init = [&]() -> Status {
- return _delete_handler.init(*_tablet_schema, _tablet->delete_predicates(),
+ return _delete_handler.init(_tablet_schema, _tablet->delete_predicates(),
read_params.version.second, this);
};
diff --git a/be/src/olap/reader.h b/be/src/olap/reader.h
index 8f999267be..f5d2817ead 100644
--- a/be/src/olap/reader.h
+++ b/be/src/olap/reader.h
@@ -58,7 +58,7 @@ public:
// mainly include tablet, data version and fetch range.
struct ReaderParams {
TabletSharedPtr tablet;
- const TabletSchema* tablet_schema;
+ TabletSchemaSPtr tablet_schema;
ReaderType reader_type = READER_QUERY;
bool direct_mode = false;
bool aggregation = false;
@@ -186,7 +186,7 @@ protected:
TabletSharedPtr _tablet;
RowsetReaderContext _reader_context;
- const TabletSchema* _tablet_schema;
+ TabletSchemaSPtr _tablet_schema;
KeysParam _keys_param;
std::vector<bool> _is_lower_keys_included;
std::vector<bool> _is_upper_keys_included;
diff --git a/be/src/olap/row_block.cpp b/be/src/olap/row_block.cpp
index 6a04119f24..8d5e7677a2 100644
--- a/be/src/olap/row_block.cpp
+++ b/be/src/olap/row_block.cpp
@@ -37,7 +37,7 @@ using std::vector;
namespace doris {
-RowBlock::RowBlock(const TabletSchema* schema) : _capacity(0), _schema(schema) {
+RowBlock::RowBlock(TabletSchemaSPtr schema) : _capacity(0), _schema(schema) {
_mem_pool.reset(new MemPool());
}
diff --git a/be/src/olap/row_block.h b/be/src/olap/row_block.h
index ac157991eb..0d9ed4c24a 100644
--- a/be/src/olap/row_block.h
+++ b/be/src/olap/row_block.h
@@ -54,7 +54,7 @@ class RowBlock {
friend class RowBlockChanger;
public:
- RowBlock(const TabletSchema* schema);
+ RowBlock(TabletSchemaSPtr schema);
// 注意回收内部buffer
~RowBlock();
@@ -80,7 +80,7 @@ public:
const uint32_t row_num() const { return _info.row_num; }
const RowBlockInfo& row_block_info() const { return _info; }
- const TabletSchema& tablet_schema() const { return *_schema; }
+ const TabletSchemaSPtr tablet_schema() const { return _schema; }
size_t capacity() const { return _capacity; }
// Return field pointer, this pointer point to the nullbyte before the field
@@ -112,7 +112,7 @@ private:
uint32_t _capacity;
RowBlockInfo _info;
- const TabletSchema* _schema; // 内部保存的schema句柄
+ TabletSchemaSPtr _schema; // 内部保存的schema句柄
bool _null_supported;
diff --git a/be/src/olap/row_cursor.cpp b/be/src/olap/row_cursor.cpp
index bb91469177..48233830c6 100644
--- a/be/src/olap/row_cursor.cpp
+++ b/be/src/olap/row_cursor.cpp
@@ -78,13 +78,13 @@ Status RowCursor::_init(const std::vector<TabletColumn>& schema,
return _init(columns);
}
-Status RowCursor::_init_scan_key(const TabletSchema& schema,
+Status RowCursor::_init_scan_key(TabletSchemaSPtr schema,
const std::vector<std::string>& scan_keys) {
// NOTE: cid equal with column index
// Hyperloglog cannot be key, no need to handle it
_variable_len = 0;
for (auto cid : _schema->column_ids()) {
- const TabletColumn& column = schema.column(cid);
+ const TabletColumn& column = schema->column(cid);
FieldType type = column.type();
if (type == OLAP_FIELD_TYPE_VARCHAR) {
_variable_len += scan_keys[cid].length();
@@ -101,7 +101,7 @@ Status RowCursor::_init_scan_key(const TabletSchema& schema,
char* variable_ptr = _variable_buf;
char** long_text_ptr = _long_text_buf;
for (auto cid : _schema->column_ids()) {
- const TabletColumn& column = schema.column(cid);
+ const TabletColumn& column = schema->column(cid);
fixed_ptr = _fixed_buf + _schema->column_offset(cid);
FieldType type = column.type();
if (type == OLAP_FIELD_TYPE_VARCHAR) {
@@ -126,20 +126,20 @@ Status RowCursor::_init_scan_key(const TabletSchema& schema,
return Status::OK();
}
-Status RowCursor::init(const TabletSchema& schema) {
- return init(schema.columns(), schema.num_columns());
+Status RowCursor::init(TabletSchemaSPtr schema) {
+ return init(schema->columns(), schema->num_columns());
}
Status RowCursor::init(const std::vector<TabletColumn>& schema) {
return init(schema, schema.size());
}
-Status RowCursor::init(const TabletSchema& schema, size_t column_count) {
- if (column_count > schema.num_columns()) {
+Status RowCursor::init(TabletSchemaSPtr schema, size_t column_count) {
+ if (column_count > schema->num_columns()) {
LOG(WARNING)
<< "Input param are invalid. Column count is bigger than num_columns of schema. "
<< "column_count=" << column_count
- << ", schema.num_columns=" << schema.num_columns();
+ << ", schema.num_columns=" << schema->num_columns();
return Status::OLAPInternalError(OLAP_ERR_INPUT_PARAMETER_ERROR);
}
@@ -147,7 +147,7 @@ Status RowCursor::init(const TabletSchema& schema, size_t column_count) {
for (size_t i = 0; i < column_count; ++i) {
columns.push_back(i);
}
- RETURN_NOT_OK(_init(schema.columns(), columns));
+ RETURN_NOT_OK(_init(schema->columns(), columns));
return Status::OK();
}
@@ -167,32 +167,31 @@ Status RowCursor::init(const std::vector<TabletColumn>& schema, size_t column_co
return Status::OK();
}
-Status RowCursor::init(const TabletSchema& schema, const std::vector<uint32_t>& columns) {
- RETURN_NOT_OK(_init(schema.columns(), columns));
+Status RowCursor::init(TabletSchemaSPtr schema, const std::vector<uint32_t>& columns) {
+ RETURN_NOT_OK(_init(schema->columns(), columns));
return Status::OK();
}
-Status RowCursor::init_scan_key(const TabletSchema& schema,
+Status RowCursor::init_scan_key(TabletSchemaSPtr schema,
const std::vector<std::string>& scan_keys) {
size_t scan_key_size = scan_keys.size();
- if (scan_key_size > schema.num_columns()) {
+ if (scan_key_size > schema->num_columns()) {
LOG(WARNING)
<< "Input param are invalid. Column count is bigger than num_columns of schema. "
<< "column_count=" << scan_key_size
- << ", schema.num_columns=" << schema.num_columns();
+ << ", schema.num_columns=" << schema->num_columns();
return Status::OLAPInternalError(OLAP_ERR_INPUT_PARAMETER_ERROR);
}
std::vector<uint32_t> columns(scan_key_size);
std::iota(columns.begin(), columns.end(), 0);
- RETURN_NOT_OK(_init(schema.columns(), columns));
+ RETURN_NOT_OK(_init(schema->columns(), columns));
return _init_scan_key(schema, scan_keys);
}
-Status RowCursor::init_scan_key(const TabletSchema& schema,
- const std::vector<std::string>& scan_keys,
+Status RowCursor::init_scan_key(TabletSchemaSPtr schema, const std::vector<std::string>& scan_keys,
const std::shared_ptr<Schema>& shared_schema) {
size_t scan_key_size = scan_keys.size();
@@ -206,8 +205,8 @@ Status RowCursor::init_scan_key(const TabletSchema& schema,
return _init_scan_key(schema, scan_keys);
}
-// TODO(yingchun): parameter 'const TabletSchema& schema' is not used
-Status RowCursor::allocate_memory_for_string_type(const TabletSchema& schema) {
+// TODO(yingchun): parameter 'TabletSchemaSPtr schema' is not used
+Status RowCursor::allocate_memory_for_string_type(TabletSchemaSPtr schema) {
// allocate memory for string type(char, varchar, hll, array)
// The memory allocated in this function is used in aggregate and copy function
if (_variable_len == 0 && _string_field_count == 0) {
diff --git a/be/src/olap/row_cursor.h b/be/src/olap/row_cursor.h
index b60a11ddce..7d3eb5ed28 100644
--- a/be/src/olap/row_cursor.h
+++ b/be/src/olap/row_cursor.h
@@ -41,25 +41,25 @@ public:
~RowCursor();
// Create a RowCursor based on the schema
- Status init(const TabletSchema& schema);
+ Status init(TabletSchemaSPtr schema);
Status init(const std::vector<TabletColumn>& schema);
// Create a RowCursor based on the first n columns of the schema
Status init(const std::vector<TabletColumn>& schema, size_t column_count);
- Status init(const TabletSchema& schema, size_t column_count);
+ Status init(TabletSchemaSPtr schema, size_t column_count);
// Create a RowCursor based on the schema and column id list
// which is used for the calculation process only uses some discontinuous prefix columns
- Status init(const TabletSchema& schema, const std::vector<uint32_t>& columns);
+ Status init(TabletSchemaSPtr schema, const std::vector<uint32_t>& columns);
// Initialize with the size of the key, currently only used when splitting the range of key
- Status init_scan_key(const TabletSchema& schema, const std::vector<std::string>& keys);
+ Status init_scan_key(TabletSchemaSPtr schema, const std::vector<std::string>& keys);
- Status init_scan_key(const TabletSchema& schema, const std::vector<std::string>& keys,
+ Status init_scan_key(TabletSchemaSPtr schema, const std::vector<std::string>& keys,
const std::shared_ptr<Schema>& shared_schema);
//allocate memory for string type, which include char, varchar, hyperloglog
- Status allocate_memory_for_string_type(const TabletSchema& schema);
+ Status allocate_memory_for_string_type(TabletSchemaSPtr schema);
RowCursorCell cell(uint32_t cid) const { return RowCursorCell(nullable_cell_ptr(cid)); }
@@ -151,7 +151,7 @@ private:
Status _init(const std::vector<TabletColumn>& schema, const std::vector<uint32_t>& columns);
Status _alloc_buf();
- Status _init_scan_key(const TabletSchema& schema, const std::vector<std::string>& scan_keys);
+ Status _init_scan_key(TabletSchemaSPtr schema, const std::vector<std::string>& scan_keys);
std::unique_ptr<Schema> _schema;
diff --git a/be/src/olap/rowset/beta_rowset_reader.cpp b/be/src/olap/rowset/beta_rowset_reader.cpp
index b96255d16f..d699b3ed0d 100644
--- a/be/src/olap/rowset/beta_rowset_reader.cpp
+++ b/be/src/olap/rowset/beta_rowset_reader.cpp
@@ -164,7 +164,7 @@ Status BetaRowsetReader::init(RowsetReaderContext* read_context) {
output_block_info.column_ids = *(_context->seek_columns);
_output_block->init(output_block_info);
_row.reset(new RowCursor());
- RETURN_NOT_OK(_row->init(*(read_context->tablet_schema), *(_context->seek_columns)));
+ RETURN_NOT_OK(_row->init(read_context->tablet_schema, *(_context->seek_columns)));
}
return Status::OK();
diff --git a/be/src/olap/rowset/rowset_reader_context.h b/be/src/olap/rowset/rowset_reader_context.h
index e62c1ed9b9..5e96774c15 100644
--- a/be/src/olap/rowset/rowset_reader_context.h
+++ b/be/src/olap/rowset/rowset_reader_context.h
@@ -33,7 +33,7 @@ class TabletSchema;
struct RowsetReaderContext {
ReaderType reader_type = READER_QUERY;
Version version {-1, -1};
- const TabletSchema* tablet_schema = nullptr;
+ TabletSchemaSPtr tablet_schema = nullptr;
// whether rowset should return ordered rows.
bool need_ordered_result = true;
// projection columns: the set of columns rowset reader should return
diff --git a/be/src/olap/rowset/segment_v2/segment_writer.cpp b/be/src/olap/rowset/segment_v2/segment_writer.cpp
index 2b74828707..d041a7a1a0 100644
--- a/be/src/olap/rowset/segment_v2/segment_writer.cpp
+++ b/be/src/olap/rowset/segment_v2/segment_writer.cpp
@@ -69,8 +69,7 @@ SegmentWriter::~SegmentWriter() {
}
void SegmentWriter::init_column_meta(ColumnMetaPB* meta, uint32_t* column_id,
- const TabletColumn& column,
- const TabletSchema* tablet_schema) {
+ const TabletColumn& column, TabletSchemaSPtr tablet_schema) {
// TODO(zc): Do we need this column_id??
meta->set_column_id((*column_id)++);
meta->set_unique_id(column.unique_id());
@@ -92,7 +91,7 @@ Status SegmentWriter::init(uint32_t write_mbytes_per_sec __attribute__((unused))
ColumnWriterOptions opts;
opts.meta = _footer.add_columns();
- init_column_meta(opts.meta, &column_id, column, _tablet_schema.get());
+ init_column_meta(opts.meta, &column_id, column, _tablet_schema);
// now we create zone map for key columns in AGG_KEYS or all column in UNIQUE_KEYS or DUP_KEYS
// and not support zone map for array type.
diff --git a/be/src/olap/rowset/segment_v2/segment_writer.h b/be/src/olap/rowset/segment_v2/segment_writer.h
index 7d0bc4cf0b..636adb05bf 100644
--- a/be/src/olap/rowset/segment_v2/segment_writer.h
+++ b/be/src/olap/rowset/segment_v2/segment_writer.h
@@ -83,7 +83,7 @@ public:
Status finalize(uint64_t* segment_file_size, uint64_t* index_size);
static void init_column_meta(ColumnMetaPB* meta, uint32_t* column_id,
- const TabletColumn& column, const TabletSchema* tablet_schema);
+ const TabletColumn& column, TabletSchemaSPtr tablet_schema);
Slice min_encoded_key();
Slice max_encoded_key();
diff --git a/be/src/olap/schema.h b/be/src/olap/schema.h
index a93a12432f..f3f09ffe3c 100644
--- a/be/src/olap/schema.h
+++ b/be/src/olap/schema.h
@@ -37,8 +37,8 @@ namespace doris {
// we store all column schema maybe accessed here. And default access through column id
class Schema {
public:
- Schema(const TabletSchema& tablet_schema) {
- size_t num_columns = tablet_schema.num_columns();
+ Schema(TabletSchemaSPtr tablet_schema) {
+ size_t num_columns = tablet_schema->num_columns();
std::vector<ColumnId> col_ids(num_columns);
_unique_ids.resize(num_columns);
std::vector<TabletColumn> columns;
@@ -47,15 +47,15 @@ public:
size_t num_key_columns = 0;
for (uint32_t cid = 0; cid < num_columns; ++cid) {
col_ids[cid] = cid;
- const TabletColumn& column = tablet_schema.column(cid);
+ const TabletColumn& column = tablet_schema->column(cid);
_unique_ids[cid] = column.unique_id();
if (column.is_key()) {
++num_key_columns;
}
columns.push_back(column);
}
- _delete_sign_idx = tablet_schema.delete_sign_idx();
- if (tablet_schema.has_sequence_col()) {
+ _delete_sign_idx = tablet_schema->delete_sign_idx();
+ if (tablet_schema->has_sequence_col()) {
_has_sequence_col = true;
}
_init(columns, col_ids, num_key_columns);
diff --git a/be/src/olap/schema_change.cpp b/be/src/olap/schema_change.cpp
index 783ec85272..6dc20fc6c5 100644
--- a/be/src/olap/schema_change.cpp
+++ b/be/src/olap/schema_change.cpp
@@ -241,15 +241,15 @@ private:
RowRefComparator _cmp;
};
-RowBlockChanger::RowBlockChanger(const TabletSchema& tablet_schema, DescriptorTbl desc_tbl)
+RowBlockChanger::RowBlockChanger(TabletSchemaSPtr tablet_schema, DescriptorTbl desc_tbl)
: _desc_tbl(desc_tbl) {
- _schema_mapping.resize(tablet_schema.num_columns());
+ _schema_mapping.resize(tablet_schema->num_columns());
}
-RowBlockChanger::RowBlockChanger(const TabletSchema& tablet_schema,
+RowBlockChanger::RowBlockChanger(TabletSchemaSPtr tablet_schema,
const DeleteHandler* delete_handler, DescriptorTbl desc_tbl)
: _desc_tbl(desc_tbl) {
- _schema_mapping.resize(tablet_schema.num_columns());
+ _schema_mapping.resize(tablet_schema->num_columns());
_delete_handler = delete_handler;
}
@@ -293,39 +293,39 @@ ColumnMapping* RowBlockChanger::get_mutable_column_mapping(size_t column_index)
break; \
}
-#define CONVERT_FROM_TYPE(from_type) \
- { \
- switch (newtype) { \
- case OLAP_FIELD_TYPE_TINYINT: \
- TYPE_REINTERPRET_CAST(from_type, int8_t); \
- case OLAP_FIELD_TYPE_UNSIGNED_TINYINT: \
- TYPE_REINTERPRET_CAST(from_type, uint8_t); \
- case OLAP_FIELD_TYPE_SMALLINT: \
- TYPE_REINTERPRET_CAST(from_type, int16_t); \
- case OLAP_FIELD_TYPE_UNSIGNED_SMALLINT: \
- TYPE_REINTERPRET_CAST(from_type, uint16_t); \
- case OLAP_FIELD_TYPE_INT: \
- TYPE_REINTERPRET_CAST(from_type, int32_t); \
- case OLAP_FIELD_TYPE_UNSIGNED_INT: \
- TYPE_REINTERPRET_CAST(from_type, uint32_t); \
- case OLAP_FIELD_TYPE_BIGINT: \
- TYPE_REINTERPRET_CAST(from_type, int64_t); \
- case OLAP_FIELD_TYPE_UNSIGNED_BIGINT: \
- TYPE_REINTERPRET_CAST(from_type, uint64_t); \
- case OLAP_FIELD_TYPE_LARGEINT: \
- LARGEINT_REINTERPRET_CAST(from_type, int128_t); \
- case OLAP_FIELD_TYPE_FLOAT: \
- TYPE_REINTERPRET_CAST(from_type, float); \
- case OLAP_FIELD_TYPE_DOUBLE: \
- TYPE_REINTERPRET_CAST(from_type, double); \
- default: \
- LOG(WARNING) << "the column type which was altered to was unsupported." \
- << " origin_type=" \
- << ref_block->tablet_schema().column(ref_column).type() \
- << ", alter_type=" << mutable_block->tablet_schema().column(i).type(); \
- return Status::OLAPInternalError(OLAP_ERR_SCHEMA_CHANGE_INFO_INVALID); \
- } \
- break; \
+#define CONVERT_FROM_TYPE(from_type) \
+ { \
+ switch (newtype) { \
+ case OLAP_FIELD_TYPE_TINYINT: \
+ TYPE_REINTERPRET_CAST(from_type, int8_t); \
+ case OLAP_FIELD_TYPE_UNSIGNED_TINYINT: \
+ TYPE_REINTERPRET_CAST(from_type, uint8_t); \
+ case OLAP_FIELD_TYPE_SMALLINT: \
+ TYPE_REINTERPRET_CAST(from_type, int16_t); \
+ case OLAP_FIELD_TYPE_UNSIGNED_SMALLINT: \
+ TYPE_REINTERPRET_CAST(from_type, uint16_t); \
+ case OLAP_FIELD_TYPE_INT: \
+ TYPE_REINTERPRET_CAST(from_type, int32_t); \
+ case OLAP_FIELD_TYPE_UNSIGNED_INT: \
+ TYPE_REINTERPRET_CAST(from_type, uint32_t); \
+ case OLAP_FIELD_TYPE_BIGINT: \
+ TYPE_REINTERPRET_CAST(from_type, int64_t); \
+ case OLAP_FIELD_TYPE_UNSIGNED_BIGINT: \
+ TYPE_REINTERPRET_CAST(from_type, uint64_t); \
+ case OLAP_FIELD_TYPE_LARGEINT: \
+ LARGEINT_REINTERPRET_CAST(from_type, int128_t); \
+ case OLAP_FIELD_TYPE_FLOAT: \
+ TYPE_REINTERPRET_CAST(from_type, float); \
+ case OLAP_FIELD_TYPE_DOUBLE: \
+ TYPE_REINTERPRET_CAST(from_type, double); \
+ default: \
+ LOG(WARNING) << "the column type which was altered to was unsupported." \
+ << " origin_type=" \
+ << ref_block->tablet_schema()->column(ref_column).type() \
+ << ", alter_type=" << mutable_block->tablet_schema()->column(i).type(); \
+ return Status::OLAPInternalError(OLAP_ERR_SCHEMA_CHANGE_INFO_INVALID); \
+ } \
+ break; \
}
#define ASSIGN_DEFAULT_VALUE(length) \
@@ -580,9 +580,9 @@ Status RowBlockChanger::change_row_block(const RowBlock* ref_block, int32_t data
if (mutable_block == nullptr) {
LOG(FATAL) << "mutable block is uninitialized.";
return Status::OLAPInternalError(OLAP_ERR_NOT_INITED);
- } else if (mutable_block->tablet_schema().num_columns() != _schema_mapping.size()) {
+ } else if (mutable_block->tablet_schema()->num_columns() != _schema_mapping.size()) {
LOG(WARNING) << "mutable block does not match with schema mapping rules. "
- << "block_schema_size=" << mutable_block->tablet_schema().num_columns()
+ << "block_schema_size=" << mutable_block->tablet_schema()->num_columns()
<< ", mapping_schema_size=" << _schema_mapping.size();
return Status::OLAPInternalError(OLAP_ERR_NOT_INITED);
}
@@ -619,7 +619,7 @@ Status RowBlockChanger::change_row_block(const RowBlock* ref_block, int32_t data
MemPool* mem_pool = mutable_block->mem_pool();
// b. According to the previous filtering information, only processes that are also marked as 1
- for (size_t i = 0, len = mutable_block->tablet_schema().num_columns(); !filter_all && i < len;
+ for (size_t i = 0, len = mutable_block->tablet_schema()->num_columns(); !filter_all && i < len;
++i) {
int32_t ref_column = _schema_mapping[i].ref_column;
if (_schema_mapping[i].ref_column >= 0) {
@@ -645,7 +645,7 @@ Status RowBlockChanger::change_row_block(const RowBlock* ref_block, int32_t data
ref_block->get_row(row_index, &read_helper);
if (!_do_materialized_transform(&read_helper, &write_helper,
- ref_block->tablet_schema().column(ref_column),
+ ref_block->tablet_schema()->column(ref_column),
i, _schema_mapping[i].ref_column, mem_pool)) {
return Status::OLAPInternalError(OLAP_ERR_DATA_QUALITY_ERR);
}
@@ -655,8 +655,8 @@ Status RowBlockChanger::change_row_block(const RowBlock* ref_block, int32_t data
// new column will be assigned as referenced column
// check if the type of new column is equal to the older's.
- FieldType reftype = ref_block->tablet_schema().column(ref_column).type();
- FieldType newtype = mutable_block->tablet_schema().column(i).type();
+ FieldType reftype = ref_block->tablet_schema()->column(ref_column).type();
+ FieldType newtype = mutable_block->tablet_schema()->column(i).type();
if (newtype == reftype) {
// Low efficiency, you can also directly calculate the variable length domain copy, but it will still destroy the package
for (size_t row_index = 0, new_row_index = 0;
@@ -673,7 +673,7 @@ Status RowBlockChanger::change_row_block(const RowBlock* ref_block, int32_t data
// if modify length of CHAR type, the size of slice should be equal
// to new length.
Slice* src = (Slice*)(read_helper.cell_ptr(ref_column));
- size_t size = mutable_block->tablet_schema().column(i).length();
+ size_t size = mutable_block->tablet_schema()->column(i).length();
char* buf = reinterpret_cast<char*>(mem_pool->allocate(size));
memset(buf, 0, size);
size_t copy_size = (size < src->size) ? size : src->size;
@@ -735,17 +735,17 @@ Status RowBlockChanger::change_row_block(const RowBlock* ref_block, int32_t data
default:
LOG(WARNING) << "the column type which was altered from was unsupported."
<< " from_type="
- << ref_block->tablet_schema().column(ref_column).type();
+ << ref_block->tablet_schema()->column(ref_column).type();
return Status::OLAPInternalError(OLAP_ERR_SCHEMA_CHANGE_INFO_INVALID);
}
if (newtype < reftype) {
VLOG_NOTICE << "type degraded while altering column. "
- << "column=" << mutable_block->tablet_schema().column(i).name()
+ << "column=" << mutable_block->tablet_schema()->column(i).name()
<< ", origin_type="
- << ref_block->tablet_schema().column(ref_column).type()
+ << ref_block->tablet_schema()->column(ref_column).type()
<< ", alter_type="
- << mutable_block->tablet_schema().column(i).type();
+ << mutable_block->tablet_schema()->column(i).type();
}
}
} else {
@@ -951,10 +951,10 @@ bool RowBlockSorter::sort(RowBlock** row_block) {
return true;
}
-RowBlockAllocator::RowBlockAllocator(const TabletSchema& tablet_schema, size_t memory_limitation)
+RowBlockAllocator::RowBlockAllocator(TabletSchemaSPtr tablet_schema, size_t memory_limitation)
: _tablet_schema(tablet_schema),
_tracker(std::make_unique<MemTracker>("RowBlockAllocator")),
- _row_len(tablet_schema.row_size()),
+ _row_len(tablet_schema->row_size()),
_memory_limitation(memory_limitation) {
VLOG_NOTICE << "RowBlockAllocator(). row_len=" << _row_len;
}
@@ -980,7 +980,7 @@ Status RowBlockAllocator::allocate(RowBlock** row_block, size_t num_rows, bool n
}
// TODO(lijiao) : Why abandon the original m_row_block_buffer
- *row_block = new (nothrow) RowBlock(&_tablet_schema);
+ *row_block = new (nothrow) RowBlock(_tablet_schema);
if (*row_block == nullptr) {
LOG(WARNING) << "failed to malloc RowBlock. size=" << sizeof(RowBlock);
@@ -1041,7 +1041,7 @@ bool RowBlockMerger::merge(const std::vector<RowBlock*>& row_block_arr, RowsetWr
return false;
};
- if (row_cursor.init(*_tablet->tablet_schema()) != Status::OK()) {
+ if (row_cursor.init(_tablet->tablet_schema()) != Status::OK()) {
LOG(WARNING) << "fail to init row cursor.";
return merge_error();
}
@@ -1051,7 +1051,7 @@ bool RowBlockMerger::merge(const std::vector<RowBlock*>& row_block_arr, RowsetWr
return merge_error();
}
- row_cursor.allocate_memory_for_string_type(*_tablet->tablet_schema());
+ row_cursor.allocate_memory_for_string_type(_tablet->tablet_schema());
while (_heap.size() > 0) {
init_row_with_others(&row_cursor, *(_heap.top().row_cursor), mem_pool.get(),
agg_object_pool.get());
@@ -1201,7 +1201,7 @@ Status SchemaChangeDirectly::_inner_process(RowsetReaderSharedPtr rowset_reader,
RowsetWriter* rowset_writer, TabletSharedPtr new_tablet,
TabletSharedPtr base_tablet) {
if (_row_block_allocator == nullptr) {
- _row_block_allocator = new RowBlockAllocator(*new_tablet->tablet_schema(), 0);
+ _row_block_allocator = new RowBlockAllocator(new_tablet->tablet_schema(), 0);
if (_row_block_allocator == nullptr) {
LOG(FATAL) << "failed to malloc RowBlockAllocator. size=" << sizeof(RowBlockAllocator);
return Status::OLAPInternalError(OLAP_ERR_INPUT_PARAMETER_ERROR);
@@ -1215,7 +1215,7 @@ Status SchemaChangeDirectly::_inner_process(RowsetReaderSharedPtr rowset_reader,
return Status::OLAPInternalError(OLAP_ERR_INPUT_PARAMETER_ERROR);
}
- if (!_cursor->init(*new_tablet->tablet_schema())) {
+ if (!_cursor->init(new_tablet->tablet_schema())) {
LOG(WARNING) << "fail to init row cursor.";
return Status::OLAPInternalError(OLAP_ERR_INPUT_PARAMETER_ERROR);
}
@@ -1321,7 +1321,7 @@ Status SchemaChangeWithSorting::_inner_process(RowsetReaderSharedPtr rowset_read
TabletSharedPtr base_tablet) {
if (_row_block_allocator == nullptr) {
_row_block_allocator =
- new (nothrow) RowBlockAllocator(*new_tablet->tablet_schema(), _memory_limitation);
+ new (nothrow) RowBlockAllocator(new_tablet->tablet_schema(), _memory_limitation);
if (_row_block_allocator == nullptr) {
LOG(FATAL) << "failed to malloc RowBlockAllocator. size=" << sizeof(RowBlockAllocator);
return Status::OLAPInternalError(OLAP_ERR_INPUT_PARAMETER_ERROR);
@@ -1633,10 +1633,9 @@ bool SchemaChangeWithSorting::_external_sorting(vector<RowsetSharedPtr>& src_row
rs_readers.push_back(rs_reader);
}
// get cur schema if rowset schema exist, rowset schema must be newer than tablet schema
- const TabletSchema* cur_tablet_schema =
- src_rowsets.back()->rowset_meta()->tablet_schema().get();
+ TabletSchemaSPtr cur_tablet_schema = src_rowsets.back()->rowset_meta()->tablet_schema();
if (cur_tablet_schema == nullptr) {
- cur_tablet_schema = new_tablet->tablet_schema().get();
+ cur_tablet_schema = new_tablet->tablet_schema();
}
Merger::Statistics stats;
@@ -1671,8 +1670,8 @@ Status VSchemaChangeWithSorting::_external_sorting(vector<RowsetSharedPtr>& src_
Merger::Statistics stats;
RETURN_IF_ERROR(Merger::vmerge_rowsets(new_tablet, READER_ALTER_TABLE,
- new_tablet->tablet_schema().get(), rs_readers,
- rowset_writer, &stats));
+ new_tablet->tablet_schema(), rs_readers, rowset_writer,
+ &stats));
_add_merged_rows(stats.merged_rows);
_add_filtered_rows(stats.filtered_rows);
@@ -1760,12 +1759,12 @@ Status SchemaChangeHandler::_do_process_alter_tablet_v2(const TAlterTabletReqV2&
// delete handlers for new tablet
DeleteHandler delete_handler;
std::vector<ColumnId> return_columns;
- TabletSchema base_tablet_schema;
- base_tablet_schema.copy_from(*base_tablet->tablet_schema());
+ TabletSchemaSPtr base_tablet_schema = std::make_shared<TabletSchema>();
+ base_tablet_schema->copy_from(*base_tablet->tablet_schema());
if (!request.columns.empty() && request.columns[0].col_unique_id >= 0) {
- base_tablet_schema.clear_columns();
+ base_tablet_schema->clear_columns();
for (const auto& column : request.columns) {
- base_tablet_schema.append_column(TabletColumn(column));
+ base_tablet_schema->append_column(TabletColumn(column));
}
}
@@ -1778,7 +1777,7 @@ Status SchemaChangeHandler::_do_process_alter_tablet_v2(const TAlterTabletReqV2&
std::lock_guard<std::shared_mutex> new_tablet_wlock(new_tablet->get_header_lock());
// check if the tablet has alter task
// if it has alter task, it means it is under old alter process
- size_t num_cols = base_tablet_schema.num_columns();
+ size_t num_cols = base_tablet_schema->num_columns();
return_columns.resize(num_cols);
for (int i = 0; i < num_cols; ++i) {
return_columns[i] = i;
@@ -1788,7 +1787,7 @@ Status SchemaChangeHandler::_do_process_alter_tablet_v2(const TAlterTabletReqV2&
// with rs_readers
RowsetReaderContext reader_context;
reader_context.reader_type = READER_ALTER_TABLE;
- reader_context.tablet_schema = &base_tablet_schema;
+ reader_context.tablet_schema = base_tablet_schema;
reader_context.need_ordered_result = true;
reader_context.delete_handler = &delete_handler;
reader_context.return_columns = &return_columns;
@@ -1874,9 +1873,8 @@ Status SchemaChangeHandler::_do_process_alter_tablet_v2(const TAlterTabletReqV2&
reader_params.tablet = base_tablet;
reader_params.reader_type = READER_ALTER_TABLE;
reader_params.rs_readers = rs_readers;
- reader_params.tablet_schema = &base_tablet_schema;
- const auto& schema = base_tablet_schema;
- reader_params.return_columns.resize(schema.num_columns());
+ reader_params.tablet_schema = base_tablet_schema;
+ reader_params.return_columns.resize(base_tablet_schema->num_columns());
std::iota(reader_params.return_columns.begin(), reader_params.return_columns.end(), 0);
reader_params.origin_return_columns = &reader_params.return_columns;
reader_params.version = {0, end_version};
@@ -1915,7 +1913,7 @@ Status SchemaChangeHandler::_do_process_alter_tablet_v2(const TAlterTabletReqV2&
sc_params.new_tablet = new_tablet;
sc_params.ref_rowset_readers = rs_readers;
sc_params.delete_handler = &delete_handler;
- sc_params.base_tablet_schema = &base_tablet_schema;
+ sc_params.base_tablet_schema = base_tablet_schema;
if (request.__isset.materialized_view_params) {
for (auto item : request.materialized_view_params) {
AlterMaterializedViewParam mv_param;
@@ -2026,7 +2024,7 @@ Status SchemaChangeHandler::_convert_historical_rowsets(const SchemaChangeParams
// Add filter information in change, and filter column information will be set in _parse_request
// And filter some data every time the row block changes
- RowBlockChanger rb_changer(*sc_params.new_tablet->tablet_schema(), sc_params.delete_handler,
+ RowBlockChanger rb_changer(sc_params.new_tablet->tablet_schema(), sc_params.delete_handler,
*sc_params.desc_tbl);
bool sc_sorting = false;
@@ -2140,7 +2138,7 @@ Status SchemaChangeHandler::_parse_request(
bool* sc_sorting, bool* sc_directly,
const std::unordered_map<std::string, AlterMaterializedViewParam>&
materialized_function_map,
- DescriptorTbl desc_tbl, const TabletSchema* base_tablet_schema) {
+ DescriptorTbl desc_tbl, TabletSchemaSPtr base_tablet_schema) {
// set column mapping
for (int i = 0, new_schema_size = new_tablet->tablet_schema()->num_columns();
i < new_schema_size; ++i) {
@@ -2219,9 +2217,8 @@ Status SchemaChangeHandler::_parse_request(
}
}
- const TabletSchema& ref_tablet_schema = *base_tablet_schema;
TabletSchemaSPtr new_tablet_schema = new_tablet->tablet_schema();
- if (ref_tablet_schema.keys_type() != new_tablet_schema->keys_type()) {
+ if (base_tablet_schema->keys_type() != new_tablet_schema->keys_type()) {
// only when base table is dup and mv is agg
// the rollup job must be reagg.
*sc_sorting = true;
@@ -2256,7 +2253,7 @@ Status SchemaChangeHandler::_parse_request(
continue;
} else {
auto column_new = new_tablet_schema->column(i);
- auto column_old = ref_tablet_schema.column(column_mapping->ref_column);
+ auto column_old = base_tablet_schema->column(column_mapping->ref_column);
if (column_new.type() != column_old.type() ||
column_new.precision() != column_old.precision() ||
column_new.frac() != column_old.frac() ||
diff --git a/be/src/olap/schema_change.h b/be/src/olap/schema_change.h
index 79b5da2852..d3623216fe 100644
--- a/be/src/olap/schema_change.h
+++ b/be/src/olap/schema_change.h
@@ -38,10 +38,10 @@ bool count_field(RowCursor* read_helper, RowCursor* write_helper, const TabletCo
class RowBlockChanger {
public:
- RowBlockChanger(const TabletSchema& tablet_schema, const DeleteHandler* delete_handler,
+ RowBlockChanger(TabletSchemaSPtr tablet_schema, const DeleteHandler* delete_handler,
DescriptorTbl desc_tbl);
- RowBlockChanger(const TabletSchema& tablet_schema, DescriptorTbl desc_tbl);
+ RowBlockChanger(TabletSchemaSPtr tablet_schema, DescriptorTbl desc_tbl);
~RowBlockChanger();
@@ -71,7 +71,7 @@ private:
class RowBlockAllocator {
public:
- RowBlockAllocator(const TabletSchema& tablet_schema, size_t memory_limitation);
+ RowBlockAllocator(TabletSchemaSPtr tablet_schema, size_t memory_limitation);
virtual ~RowBlockAllocator();
Status allocate(RowBlock** row_block, size_t num_rows, bool null_supported);
@@ -79,7 +79,7 @@ public:
bool is_memory_enough_for_sorting(size_t num_rows, size_t allocated_rows);
private:
- const TabletSchema& _tablet_schema;
+ TabletSchemaSPtr _tablet_schema;
std::unique_ptr<MemTracker> _tracker;
size_t _row_len;
size_t _memory_limitation;
@@ -301,7 +301,7 @@ private:
AlterTabletType alter_tablet_type;
TabletSharedPtr base_tablet;
TabletSharedPtr new_tablet;
- TabletSchema* base_tablet_schema = nullptr;
+ TabletSchemaSPtr base_tablet_schema = nullptr;
std::vector<RowsetReaderSharedPtr> ref_rowset_readers;
DeleteHandler* delete_handler = nullptr;
std::unordered_map<std::string, AlterMaterializedViewParam> materialized_params_map;
@@ -320,7 +320,7 @@ private:
RowBlockChanger* rb_changer, bool* sc_sorting, bool* sc_directly,
const std::unordered_map<std::string, AlterMaterializedViewParam>&
materialized_function_map,
- DescriptorTbl desc_tbl, const TabletSchema* base_tablet_schema);
+ DescriptorTbl desc_tbl, TabletSchemaSPtr base_tablet_schema);
// Initialization Settings for creating a default value
static Status _init_column_mapping(ColumnMapping* column_mapping,
diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp
index 6553a3fc6d..811998ea3f 100644
--- a/be/src/olap/tablet.cpp
+++ b/be/src/olap/tablet.cpp
@@ -973,7 +973,7 @@ Status Tablet::split_range(const OlapTuple& start_key_strings, const OlapTuple&
RowCursor start_key;
// 如果有startkey,用startkey初始化;反之则用minkey初始化
if (start_key_strings.size() > 0) {
- if (start_key.init_scan_key(*_schema, start_key_strings.values()) != Status::OK()) {
+ if (start_key.init_scan_key(_schema, start_key_strings.values()) != Status::OK()) {
LOG(WARNING) << "fail to initial key strings with RowCursor type.";
return Status::OLAPInternalError(OLAP_ERR_INIT_FAILED);
}
@@ -984,12 +984,12 @@ Status Tablet::split_range(const OlapTuple& start_key_strings, const OlapTuple&
}
key_num = start_key_strings.size();
} else {
- if (start_key.init(*_schema, num_short_key_columns()) != Status::OK()) {
+ if (start_key.init(_schema, num_short_key_columns()) != Status::OK()) {
LOG(WARNING) << "fail to initial key strings with RowCursor type.";
return Status::OLAPInternalError(OLAP_ERR_INIT_FAILED);
}
- start_key.allocate_memory_for_string_type(*_schema);
+ start_key.allocate_memory_for_string_type(_schema);
start_key.build_min_key();
key_num = num_short_key_columns();
}
@@ -997,7 +997,7 @@ Status Tablet::split_range(const OlapTuple& start_key_strings, const OlapTuple&
RowCursor end_key;
// 和startkey一样处理,没有则用maxkey初始化
if (end_key_strings.size() > 0) {
- if (!end_key.init_scan_key(*_schema, end_key_strings.values())) {
+ if (!end_key.init_scan_key(_schema, end_key_strings.values())) {
LOG(WARNING) << "fail to parse strings to key with RowCursor type.";
return Status::OLAPInternalError(OLAP_ERR_INVALID_SCHEMA);
}
@@ -1007,12 +1007,12 @@ Status Tablet::split_range(const OlapTuple& start_key_strings, const OlapTuple&
return Status::OLAPInternalError(OLAP_ERR_INVALID_SCHEMA);
}
} else {
- if (end_key.init(*_schema, num_short_key_columns()) != Status::OK()) {
+ if (end_key.init(_schema, num_short_key_columns()) != Status::OK()) {
LOG(WARNING) << "fail to initial key strings with RowCursor type.";
return Status::OLAPInternalError(OLAP_ERR_INIT_FAILED);
}
- end_key.allocate_memory_for_string_type(*_schema);
+ end_key.allocate_memory_for_string_type(_schema);
end_key.build_max_key();
}
diff --git a/be/src/olap/task/engine_checksum_task.cpp b/be/src/olap/task/engine_checksum_task.cpp
index 3b3e5fde1f..3add201854 100644
--- a/be/src/olap/task/engine_checksum_task.cpp
+++ b/be/src/olap/task/engine_checksum_task.cpp
@@ -90,12 +90,12 @@ Status EngineChecksumTask::_compute_checksum() {
RowCursor row;
std::unique_ptr<MemPool> mem_pool(new MemPool());
std::unique_ptr<ObjectPool> agg_object_pool(new ObjectPool());
- res = row.init(*tablet->tablet_schema(), reader_params.return_columns);
+ res = row.init(tablet->tablet_schema(), reader_params.return_columns);
if (!res.ok()) {
LOG(WARNING) << "failed to init row cursor. res = " << res;
return res;
}
- row.allocate_memory_for_string_type(*tablet->tablet_schema());
+ row.allocate_memory_for_string_type(tablet->tablet_schema());
bool eof = false;
uint32_t row_checksum = 0;
diff --git a/be/src/vec/exec/volap_scanner.cpp b/be/src/vec/exec/volap_scanner.cpp
index 194da3ca7d..f7ca037e31 100644
--- a/be/src/vec/exec/volap_scanner.cpp
+++ b/be/src/vec/exec/volap_scanner.cpp
@@ -38,7 +38,9 @@ VOlapScanner::VOlapScanner(RuntimeState* runtime_state, VOlapScanNode* parent, b
_aggregation(aggregation),
_need_agg_finalize(need_agg_finalize),
_version(-1),
- _mem_tracker(tracker) {}
+ _mem_tracker(tracker) {
+ _tablet_schema = std::make_shared<TabletSchema>();
+}
Status VOlapScanner::prepare(
const TPaloScanRange& scan_range, const std::vector<OlapScanRange*>& key_ranges,
@@ -68,16 +70,16 @@ Status VOlapScanner::prepare(
LOG(WARNING) << ss.str();
return Status::InternalError(ss.str());
}
- _tablet_schema.copy_from(*_tablet->tablet_schema());
+ _tablet_schema->copy_from(*_tablet->tablet_schema());
if (!_parent->_olap_scan_node.columns_desc.empty() &&
_parent->_olap_scan_node.columns_desc[0].col_unique_id >= 0) {
// Originally scanner get TabletSchema from tablet object in BE.
// To support lightweight schema change for adding / dropping columns,
// tabletschema is bounded to rowset and tablet's schema maybe outdated,
// so we have to use schema from a query plan witch FE puts it in query plans.
- _tablet_schema.clear_columns();
+ _tablet_schema->clear_columns();
for (const auto& column_desc : _parent->_olap_scan_node.columns_desc) {
- _tablet_schema.append_column(TabletColumn(column_desc));
+ _tablet_schema->append_column(TabletColumn(column_desc));
}
}
{
@@ -180,7 +182,7 @@ Status VOlapScanner::_init_tablet_reader_params(
RETURN_IF_ERROR(_init_return_columns(!_tablet_reader_params.direct_mode));
_tablet_reader_params.tablet = _tablet;
- _tablet_reader_params.tablet_schema = &_tablet_schema;
+ _tablet_reader_params.tablet_schema = _tablet_schema;
_tablet_reader_params.reader_type = READER_QUERY;
_tablet_reader_params.aggregation = _aggregation;
_tablet_reader_params.version = Version(0, _version);
@@ -221,11 +223,11 @@ Status VOlapScanner::_init_tablet_reader_params(
_tablet_reader_params.return_columns = _return_columns;
} else {
// we need to fetch all key columns to do the right aggregation on storage engine side.
- for (size_t i = 0; i < _tablet_schema.num_key_columns(); ++i) {
+ for (size_t i = 0; i < _tablet_schema->num_key_columns(); ++i) {
_tablet_reader_params.return_columns.push_back(i);
}
for (auto index : _return_columns) {
- if (_tablet_schema.column(index).is_key()) {
+ if (_tablet_schema->column(index).is_key()) {
continue;
} else {
_tablet_reader_params.return_columns.push_back(index);
@@ -253,10 +255,10 @@ Status VOlapScanner::_init_return_columns(bool need_seq_col) {
continue;
}
- int32_t index = _tablet_schema.field_index(slot->col_unique_id());
+ int32_t index = _tablet_schema->field_index(slot->col_unique_id());
if (index < 0) {
// rollup/materialized view should use col_name to find index
- index = _tablet_schema.field_index(slot->col_name());
+ index = _tablet_schema->field_index(slot->col_name());
}
if (index < 0) {
@@ -266,22 +268,22 @@ Status VOlapScanner::_init_return_columns(bool need_seq_col) {
return Status::InternalError(ss.str());
}
_return_columns.push_back(index);
- if (slot->is_nullable() && !_tablet_schema.column(index).is_nullable()) {
+ if (slot->is_nullable() && !_tablet_schema->column(index).is_nullable()) {
_tablet_columns_convert_to_null_set.emplace(index);
}
}
// expand the sequence column
- if (_tablet_schema.has_sequence_col() && need_seq_col) {
+ if (_tablet_schema->has_sequence_col() && need_seq_col) {
bool has_replace_col = false;
for (auto col : _return_columns) {
- if (_tablet_schema.column(col).aggregation() ==
+ if (_tablet_schema->column(col).aggregation() ==
FieldAggregationMethod::OLAP_FIELD_AGGREGATION_REPLACE) {
has_replace_col = true;
break;
}
}
- if (auto sequence_col_idx = _tablet_schema.sequence_col_idx();
+ if (auto sequence_col_idx = _tablet_schema->sequence_col_idx();
has_replace_col && std::find(_return_columns.begin(), _return_columns.end(),
sequence_col_idx) == _return_columns.end()) {
_return_columns.push_back(sequence_col_idx);
diff --git a/be/src/vec/exec/volap_scanner.h b/be/src/vec/exec/volap_scanner.h
index dbede5c4e7..1ea8639c6c 100644
--- a/be/src/vec/exec/volap_scanner.h
+++ b/be/src/vec/exec/volap_scanner.h
@@ -145,7 +145,7 @@ private:
VExprContext* _vconjunct_ctx = nullptr;
bool _need_to_close = false;
- TabletSchema _tablet_schema;
+ TabletSchemaSPtr _tablet_schema;
};
} // namespace vectorized
diff --git a/be/test/olap/block_column_predicate_test.cpp b/be/test/olap/block_column_predicate_test.cpp
index 2d488e0791..876ec189e5 100644
--- a/be/test/olap/block_column_predicate_test.cpp
+++ b/be/test/olap/block_column_predicate_test.cpp
@@ -40,7 +40,7 @@ public:
void SetTabletSchema(std::string name, const std::string& type, const std::string& aggregation,
uint32_t length, bool is_allow_null, bool is_key,
- TabletSchema* tablet_schema) {
+ TabletSchemaSPtr tablet_schema) {
TabletSchemaPB tablet_schema_pb;
static int id = 0;
ColumnPB* column = tablet_schema_pb.add_column();
@@ -57,8 +57,8 @@ public:
tablet_schema->init_from_pb(tablet_schema_pb);
}
- void init_row_block(const TabletSchema* tablet_schema, int size) {
- Schema schema(*tablet_schema);
+ void init_row_block(TabletSchemaSPtr tablet_schema, int size) {
+ Schema schema(tablet_schema);
_row_block.reset(new RowBlockV2(schema, size));
}
@@ -67,11 +67,11 @@ public:
};
TEST_F(BlockColumnPredicateTest, SINGLE_COLUMN) {
- TabletSchema tablet_schema;
- SetTabletSchema(std::string("FLOAT_COLUMN"), "FLOAT", "REPLACE", 1, true, true, &tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ SetTabletSchema(std::string("FLOAT_COLUMN"), "FLOAT", "REPLACE", 1, true, true, tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
float value = 5.0;
@@ -79,7 +79,7 @@ TEST_F(BlockColumnPredicateTest, SINGLE_COLUMN) {
std::unique_ptr<ColumnPredicate> pred(new EqualPredicate<float>(0, value));
SingleColumnBlockPredicate single_column_block_pred(pred.get());
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -118,12 +118,12 @@ TEST_F(BlockColumnPredicateTest, SINGLE_COLUMN_VEC) {
}
TEST_F(BlockColumnPredicateTest, AND_MUTI_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("DOUBLE_COLUMN"), "DOUBLE", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
double less_value = 5.0;
@@ -137,7 +137,7 @@ TEST_F(BlockColumnPredicateTest, AND_MUTI_COLUMN) {
and_block_column_pred.add_column_predicate(single_less_pred);
and_block_column_pred.add_column_predicate(single_great_pred);
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -183,12 +183,12 @@ TEST_F(BlockColumnPredicateTest, AND_MUTI_COLUMN_VEC) {
}
TEST_F(BlockColumnPredicateTest, OR_MUTI_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("DOUBLE_COLUMN"), "DOUBLE", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
double less_value = 5.0;
@@ -202,7 +202,7 @@ TEST_F(BlockColumnPredicateTest, OR_MUTI_COLUMN) {
or_block_column_pred.add_column_predicate(single_less_pred);
or_block_column_pred.add_column_predicate(single_great_pred);
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -248,12 +248,12 @@ TEST_F(BlockColumnPredicateTest, OR_MUTI_COLUMN_VEC) {
}
TEST_F(BlockColumnPredicateTest, OR_AND_MUTI_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("DOUBLE_COLUMN"), "DOUBLE", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
double less_value = 5.0;
@@ -262,7 +262,7 @@ TEST_F(BlockColumnPredicateTest, OR_AND_MUTI_COLUMN) {
std::unique_ptr<ColumnPredicate> great_pred(new GreaterPredicate<double>(0, great_value));
std::unique_ptr<ColumnPredicate> less_pred1(new LessPredicate<double>(0, great_value));
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -366,12 +366,12 @@ TEST_F(BlockColumnPredicateTest, OR_AND_MUTI_COLUMN_VEC) {
}
TEST_F(BlockColumnPredicateTest, AND_OR_MUTI_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("DOUBLE_COLUMN"), "DOUBLE", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
double less_value = 5.0;
@@ -380,7 +380,7 @@ TEST_F(BlockColumnPredicateTest, AND_OR_MUTI_COLUMN) {
std::unique_ptr<ColumnPredicate> great_pred(new GreaterPredicate<double>(0, great_value));
std::unique_ptr<ColumnPredicate> less_pred1(new LessPredicate<double>(0, great_value));
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
diff --git a/be/test/olap/bloom_filter_column_predicate_test.cpp b/be/test/olap/bloom_filter_column_predicate_test.cpp
index 3d697ecfe3..e597d50172 100644
--- a/be/test/olap/bloom_filter_column_predicate_test.cpp
+++ b/be/test/olap/bloom_filter_column_predicate_test.cpp
@@ -43,7 +43,7 @@ public:
void SetTabletSchema(std::string name, const std::string& type, const std::string& aggregation,
uint32_t length, bool is_allow_null, bool is_key,
- TabletSchema* tablet_schema) {
+ TabletSchemaSPtr tablet_schema) {
TabletSchemaPB tablet_schema_pb;
static int id = 0;
ColumnPB* column = tablet_schema_pb.add_column();
@@ -61,8 +61,8 @@ public:
tablet_schema->init_from_pb(tablet_schema_pb);
}
- void init_row_block(const TabletSchema* tablet_schema, int size) {
- Schema schema(*tablet_schema);
+ void init_row_block(TabletSchemaSPtr tablet_schema, int size) {
+ Schema schema(tablet_schema);
_row_block.reset(new RowBlockV2(schema, size));
}
@@ -71,11 +71,11 @@ public:
};
TEST_F(TestBloomFilterColumnPredicate, FLOAT_COLUMN) {
- TabletSchema tablet_schema;
- SetTabletSchema(std::string("FLOAT_COLUMN"), "FLOAT", "REPLACE", 1, true, true, &tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ SetTabletSchema(std::string("FLOAT_COLUMN"), "FLOAT", "REPLACE", 1, true, true, tablet_schema);
const int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
@@ -94,7 +94,7 @@ TEST_F(TestBloomFilterColumnPredicate, FLOAT_COLUMN) {
auto* col_data = reinterpret_cast<float*>(_mem_pool->allocate(size * sizeof(float)));
// for ColumnBlock no null
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
diff --git a/be/test/olap/comparison_predicate_test.cpp b/be/test/olap/comparison_predicate_test.cpp
index 6a59c4abb3..b29ea20582 100644
--- a/be/test/olap/comparison_predicate_test.cpp
+++ b/be/test/olap/comparison_predicate_test.cpp
@@ -92,7 +92,7 @@ static std::string to_datetime_string(uint64_t& datetime_value) {
~CLASS_NAME() {} \
void SetTabletSchema(std::string name, const std::string& type, \
const std::string& aggregation, uint32_t length, bool is_allow_null, \
- bool is_key, TabletSchema* tablet_schema) { \
+ bool is_key, TabletSchemaSPtr tablet_schema) { \
TabletSchemaPB tablet_schema_pb; \
static int id = 0; \
ColumnPB* column = tablet_schema_pb.add_column(); \
@@ -109,8 +109,8 @@ static std::string to_datetime_string(uint64_t& datetime_value) {
tablet_schema->init_from_pb(tablet_schema_pb); \
} \
\
- void init_row_block(const TabletSchema* tablet_schema, int size) { \
- Schema schema(*tablet_schema); \
+ void init_row_block(TabletSchemaSPtr tablet_schema, int size) { \
+ Schema schema(tablet_schema); \
_row_block.reset(new RowBlockV2(schema, size)); \
} \
std::unique_ptr<MemPool> _mem_pool; \
@@ -121,18 +121,18 @@ TEST_PREDICATE_DEFINITION(TestEqualPredicate)
TEST_PREDICATE_DEFINITION(TestLessPredicate)
TEST_F(TestEqualPredicate, FLOAT_COLUMN) {
- TabletSchema tablet_schema;
- SetTabletSchema(std::string("FLOAT_COLUMN"), "FLOAT", "REPLACE", 1, true, true, &tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ SetTabletSchema(std::string("FLOAT_COLUMN"), "FLOAT", "REPLACE", 1, true, true, tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
float value = 5.0;
ColumnPredicate* pred = new EqualPredicate<float>(0, value);
// for ColumnBlock no null
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -164,19 +164,19 @@ TEST_F(TestEqualPredicate, FLOAT_COLUMN) {
}
TEST_F(TestEqualPredicate, DOUBLE_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("DOUBLE_COLUMN"), "DOUBLE", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
double value = 5.0;
ColumnPredicate* pred = new EqualPredicate<double>(0, value);
// for ColumnBlock no null
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -208,19 +208,19 @@ TEST_F(TestEqualPredicate, DOUBLE_COLUMN) {
}
TEST_F(TestEqualPredicate, DECIMAL_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("DECIMAL_COLUMN"), "DECIMAL", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
decimal12_t value = {5, 5};
ColumnPredicate* pred = new EqualPredicate<decimal12_t>(0, value);
// for ColumnBlock no null
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -254,11 +254,11 @@ TEST_F(TestEqualPredicate, DECIMAL_COLUMN) {
}
TEST_F(TestEqualPredicate, STRING_COLUMN) {
- TabletSchema char_tablet_schema;
+ TabletSchemaSPtr char_tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("STRING_COLUMN"), "CHAR", "REPLACE", 5, true, true,
- &char_tablet_schema);
+ char_tablet_schema);
// test WrapperField.from_string() for char type
- WrapperField* field = WrapperField::create(char_tablet_schema.column(0));
+ WrapperField* field = WrapperField::create(char_tablet_schema->column(0));
EXPECT_EQ(Status::OK(), field->from_string("true"));
const std::string tmp = field->to_string();
EXPECT_EQ(5, tmp.size());
@@ -268,12 +268,12 @@ TEST_F(TestEqualPredicate, STRING_COLUMN) {
EXPECT_EQ('e', tmp[3]);
EXPECT_EQ(0, tmp[4]);
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("STRING_COLUMN"), "VARCHAR", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
@@ -285,7 +285,7 @@ TEST_F(TestEqualPredicate, STRING_COLUMN) {
ColumnPredicate* pred = new EqualPredicate<StringValue>(0, value);
// for ColumnBlock no null
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -331,11 +331,11 @@ TEST_F(TestEqualPredicate, STRING_COLUMN) {
}
TEST_F(TestEqualPredicate, DATE_COLUMN) {
- TabletSchema tablet_schema;
- SetTabletSchema(std::string("DATE_COLUMN"), "DATE", "REPLACE", 1, true, true, &tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ SetTabletSchema(std::string("DATE_COLUMN"), "DATE", "REPLACE", 1, true, true, tablet_schema);
int size = 6;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
uint24_t value = datetime::to_date_timestamp("2017-09-10");
@@ -350,7 +350,7 @@ TEST_F(TestEqualPredicate, DATE_COLUMN) {
date_array.push_back("2017-09-12");
// for ColumnBlock no nulls
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -388,12 +388,12 @@ TEST_F(TestEqualPredicate, DATE_COLUMN) {
}
TEST_F(TestEqualPredicate, DATETIME_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("DATETIME_COLUMN"), "DATETIME", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 6;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
uint64_t value = datetime::to_datetime_timestamp("2017-09-10 01:00:00");
@@ -408,7 +408,7 @@ TEST_F(TestEqualPredicate, DATETIME_COLUMN) {
date_array.push_back("2017-09-12 01:01:01");
// for ColumnBlock no nulls
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -446,18 +446,18 @@ TEST_F(TestEqualPredicate, DATETIME_COLUMN) {
}
TEST_F(TestLessPredicate, FLOAT_COLUMN) {
- TabletSchema tablet_schema;
- SetTabletSchema(std::string("FLOAT_COLUMN"), "FLOAT", "REPLACE", 1, true, true, &tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ SetTabletSchema(std::string("FLOAT_COLUMN"), "FLOAT", "REPLACE", 1, true, true, tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
float value = 5.0;
ColumnPredicate* pred = new LessPredicate<float>(0, value);
// for ColumnBlock no null
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -497,19 +497,19 @@ TEST_F(TestLessPredicate, FLOAT_COLUMN) {
}
TEST_F(TestLessPredicate, DOUBLE_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("DOUBLE_COLUMN"), "DOUBLE", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
double value = 5.0;
ColumnPredicate* pred = new LessPredicate<double>(0, value);
// for ColumnBlock no null
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -549,19 +549,19 @@ TEST_F(TestLessPredicate, DOUBLE_COLUMN) {
}
TEST_F(TestLessPredicate, DECIMAL_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("DECIMAL_COLUMN"), "DECIMAL", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
decimal12_t value = {5, 5};
ColumnPredicate* pred = new LessPredicate<decimal12_t>(0, value);
// for ColumnBlock no null
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -593,12 +593,12 @@ TEST_F(TestLessPredicate, DECIMAL_COLUMN) {
}
TEST_F(TestLessPredicate, STRING_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("STRING_COLUMN"), "VARCHAR", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
@@ -609,7 +609,7 @@ TEST_F(TestLessPredicate, STRING_COLUMN) {
ColumnPredicate* pred = new LessPredicate<StringValue>(0, value);
// for ColumnBlock no null
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -660,11 +660,11 @@ TEST_F(TestLessPredicate, STRING_COLUMN) {
}
TEST_F(TestLessPredicate, DATE_COLUMN) {
- TabletSchema tablet_schema;
- SetTabletSchema(std::string("DATE_COLUMN"), "DATE", "REPLACE", 1, true, true, &tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ SetTabletSchema(std::string("DATE_COLUMN"), "DATE", "REPLACE", 1, true, true, tablet_schema);
int size = 6;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
uint24_t value = datetime::to_date_timestamp("2017-09-10");
@@ -679,7 +679,7 @@ TEST_F(TestLessPredicate, DATE_COLUMN) {
date_array.push_back("2017-09-12");
// for ColumnBlock no nulls
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -717,13 +717,13 @@ TEST_F(TestLessPredicate, DATE_COLUMN) {
}
TEST_F(TestLessPredicate, DATETIME_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
TabletColumn tablet_column;
SetTabletSchema(std::string("DATETIME_COLUMN"), "DATETIME", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 6;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
@@ -739,7 +739,7 @@ TEST_F(TestLessPredicate, DATETIME_COLUMN) {
date_array.push_back("2017-09-12 01:01:01");
// for ColumnBlock no nulls
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
diff --git a/be/test/olap/delete_handler_test.cpp b/be/test/olap/delete_handler_test.cpp
index bc0ca3bce5..db90b68d3f 100644
--- a/be/test/olap/delete_handler_test.cpp
+++ b/be/test/olap/delete_handler_test.cpp
@@ -811,8 +811,8 @@ protected:
EXPECT_TRUE(tablet != nullptr);
_tablet_path = tablet->tablet_path();
- _data_row_cursor.init(*tablet->tablet_schema());
- _data_row_cursor.allocate_memory_for_string_type(*tablet->tablet_schema());
+ _data_row_cursor.init(tablet->tablet_schema());
+ _data_row_cursor.allocate_memory_for_string_type(tablet->tablet_schema());
}
void TearDown() {
@@ -900,7 +900,7 @@ TEST_F(TestDeleteHandler, InitSuccess) {
tablet->add_delete_predicate(del_pred_4, 4);
// 从header文件中取出版本号小于等于7的过滤条件
- res = _delete_handler.init(*tablet->tablet_schema(), tablet->delete_predicates(), 4);
+ res = _delete_handler.init(tablet->tablet_schema(), tablet->delete_predicates(), 4);
EXPECT_EQ(Status::OK(), res);
EXPECT_EQ(4, _delete_handler.conditions_num());
std::vector<int64_t> conds_version = _delete_handler.get_conds_version();
@@ -941,7 +941,7 @@ TEST_F(TestDeleteHandler, FilterDataSubconditions) {
tablet->add_delete_predicate(del_pred, 1);
// 指定版本号为10以载入Header中的所有过滤条件(在这个case中,只有过滤条件1)
- res = _delete_handler.init(*tablet->tablet_schema(), tablet->delete_predicates(), 4);
+ res = _delete_handler.init(tablet->tablet_schema(), tablet->delete_predicates(), 4);
EXPECT_EQ(Status::OK(), res);
EXPECT_EQ(1, _delete_handler.conditions_num());
@@ -1026,7 +1026,7 @@ TEST_F(TestDeleteHandler, FilterDataConditions) {
tablet->add_delete_predicate(del_pred_3, 3);
// 指定版本号为4以载入meta中的所有过滤条件(在这个case中,只有过滤条件1)
- res = _delete_handler.init(*tablet->tablet_schema(), tablet->delete_predicates(), 4);
+ res = _delete_handler.init(tablet->tablet_schema(), tablet->delete_predicates(), 4);
EXPECT_EQ(Status::OK(), res);
EXPECT_EQ(3, _delete_handler.conditions_num());
@@ -1089,7 +1089,7 @@ TEST_F(TestDeleteHandler, FilterDataVersion) {
tablet->add_delete_predicate(del_pred_2, 4);
// 指定版本号为4以载入meta中的所有过滤条件(过滤条件1,过滤条件2)
- res = _delete_handler.init(*tablet->tablet_schema(), tablet->delete_predicates(), 4);
+ res = _delete_handler.init(tablet->tablet_schema(), tablet->delete_predicates(), 4);
EXPECT_EQ(Status::OK(), res);
EXPECT_EQ(2, _delete_handler.conditions_num());
diff --git a/be/test/olap/in_list_predicate_test.cpp b/be/test/olap/in_list_predicate_test.cpp
index 311c2b8fb2..418f806b0e 100644
--- a/be/test/olap/in_list_predicate_test.cpp
+++ b/be/test/olap/in_list_predicate_test.cpp
@@ -110,7 +110,7 @@ public:
void SetTabletSchema(std::string name, const std::string& type, const std::string& aggregation,
uint32_t length, bool is_allow_null, bool is_key,
- TabletSchema* tablet_schema) {
+ TabletSchemaSPtr tablet_schema) {
TabletSchemaPB tablet_schema_pb;
static int id = 0;
ColumnPB* column = tablet_schema_pb.add_column();
@@ -128,8 +128,8 @@ public:
tablet_schema->init_from_pb(tablet_schema_pb);
}
- void init_row_block(const TabletSchema* tablet_schema, int size) {
- _schema = std::make_unique<Schema>(*tablet_schema);
+ void init_row_block(TabletSchemaSPtr tablet_schema, int size) {
+ _schema = std::make_unique<Schema>(tablet_schema);
_row_block.reset(new RowBlockV2(*_schema, size));
}
@@ -140,9 +140,9 @@ public:
#define TEST_IN_LIST_PREDICATE_V2(TYPE, TYPE_NAME, FIELD_TYPE) \
TEST_F(TestInListPredicate, TYPE_NAME##_COLUMN_V2) { \
- TabletSchema tablet_schema; \
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>(); \
SetTabletSchema(std::string("TYPE_NAME##_COLUMN"), FIELD_TYPE, "REPLACE", 1, false, true, \
- &tablet_schema); \
+ tablet_schema); \
int size = 10; \
Schema schema(tablet_schema); \
RowBlockV2 block(schema, size); \
@@ -171,9 +171,9 @@ public:
EXPECT_EQ(*((TYPE*)column.cell_ptr(sel[2])), 6); \
\
/* for has nulls */ \
- TabletSchema tablet_schema2; \
+ TabletSchemaSPtr tablet_schema2 = std::make_shared<TabletSchema>(); \
SetTabletSchema(std::string("TYPE_NAME##_COLUMN"), FIELD_TYPE, "REPLACE", 1, true, true, \
- &tablet_schema2); \
+ tablet_schema2); \
Schema schema2(tablet_schema2); \
RowBlockV2 block2(schema2, size); \
ColumnBlock column2 = block2.column_block(0); \
@@ -204,11 +204,11 @@ TEST_IN_LIST_PREDICATE_V2(int64_t, BIGINT, "BIGINT")
TEST_IN_LIST_PREDICATE_V2(int128_t, LARGEINT, "LARGEINT")
TEST_F(TestInListPredicate, FLOAT_COLUMN) {
- TabletSchema tablet_schema;
- SetTabletSchema(std::string("FLOAT_COLUMN"), "FLOAT", "REPLACE", 1, true, true, &tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ SetTabletSchema(std::string("FLOAT_COLUMN"), "FLOAT", "REPLACE", 1, true, true, tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
phmap::flat_hash_set<float> values;
@@ -218,7 +218,7 @@ TEST_F(TestInListPredicate, FLOAT_COLUMN) {
ColumnPredicate* pred = new InListPredicate<float>(0, std::move(values));
// for ColumnBlock no null
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -252,12 +252,12 @@ TEST_F(TestInListPredicate, FLOAT_COLUMN) {
}
TEST_F(TestInListPredicate, DOUBLE_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("DOUBLE_COLUMN"), "DOUBLE", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
phmap::flat_hash_set<double> values;
@@ -268,7 +268,7 @@ TEST_F(TestInListPredicate, DOUBLE_COLUMN) {
ColumnPredicate* pred = new InListPredicate<double>(0, std::move(values));
// for ColumnBlock no null
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -302,12 +302,12 @@ TEST_F(TestInListPredicate, DOUBLE_COLUMN) {
}
TEST_F(TestInListPredicate, DECIMAL_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("DECIMAL_COLUMN"), "DECIMAL", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
phmap::flat_hash_set<decimal12_t> values;
@@ -322,7 +322,7 @@ TEST_F(TestInListPredicate, DECIMAL_COLUMN) {
ColumnPredicate* pred = new InListPredicate<decimal12_t>(0, std::move(values));
// for ColumnBlock no null
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -358,11 +358,11 @@ TEST_F(TestInListPredicate, DECIMAL_COLUMN) {
}
TEST_F(TestInListPredicate, CHAR_COLUMN) {
- TabletSchema tablet_schema;
- SetTabletSchema(std::string("STRING_COLUMN"), "CHAR", "REPLACE", 1, true, true, &tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ SetTabletSchema(std::string("STRING_COLUMN"), "CHAR", "REPLACE", 1, true, true, tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
phmap::flat_hash_set<StringValue> values;
@@ -387,7 +387,7 @@ TEST_F(TestInListPredicate, CHAR_COLUMN) {
ColumnPredicate* pred = new InListPredicate<StringValue>(0, std::move(values));
// for ColumnBlock no null
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -434,12 +434,12 @@ TEST_F(TestInListPredicate, CHAR_COLUMN) {
}
TEST_F(TestInListPredicate, VARCHAR_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("STRING_COLUMN"), "VARCHAR", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
phmap::flat_hash_set<StringValue> values;
@@ -464,7 +464,7 @@ TEST_F(TestInListPredicate, VARCHAR_COLUMN) {
ColumnPredicate* pred = new InListPredicate<StringValue>(0, std::move(values));
// for ColumnBlock no null
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -511,11 +511,11 @@ TEST_F(TestInListPredicate, VARCHAR_COLUMN) {
}
TEST_F(TestInListPredicate, DATE_COLUMN) {
- TabletSchema tablet_schema;
- SetTabletSchema(std::string("DATE_COLUMN"), "DATE", "REPLACE", 1, true, true, &tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ SetTabletSchema(std::string("DATE_COLUMN"), "DATE", "REPLACE", 1, true, true, tablet_schema);
int size = 6;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
phmap::flat_hash_set<uint24_t> values;
@@ -538,7 +538,7 @@ TEST_F(TestInListPredicate, DATE_COLUMN) {
date_array.push_back("2017-09-12");
// for ColumnBlock no nulls
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -582,12 +582,12 @@ TEST_F(TestInListPredicate, DATE_COLUMN) {
}
TEST_F(TestInListPredicate, DATE_V2_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("DATE_V2_COLUMN"), "DATEV2", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 6;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
phmap::flat_hash_set<uint32_t> values;
@@ -610,7 +610,7 @@ TEST_F(TestInListPredicate, DATE_V2_COLUMN) {
date_array.push_back("2017-09-12");
// for ColumnBlock no nulls
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -654,12 +654,12 @@ TEST_F(TestInListPredicate, DATE_V2_COLUMN) {
}
TEST_F(TestInListPredicate, DATETIME_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("DATETIME_COLUMN"), "DATETIME", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 6;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
phmap::flat_hash_set<uint64_t> values;
@@ -683,7 +683,7 @@ TEST_F(TestInListPredicate, DATETIME_COLUMN) {
date_array.push_back("2017-09-12 01:01:01");
// for ColumnBlock no nulls
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
diff --git a/be/test/olap/null_predicate_test.cpp b/be/test/olap/null_predicate_test.cpp
index 978b5a6dbe..0b51598617 100644
--- a/be/test/olap/null_predicate_test.cpp
+++ b/be/test/olap/null_predicate_test.cpp
@@ -61,7 +61,7 @@ public:
void SetTabletSchema(std::string name, std::string type, std::string aggregation,
uint32_t length, bool is_allow_null, bool is_key,
- TabletSchema* tablet_schema) {
+ TabletSchemaSPtr tablet_schema) {
TabletSchemaPB tablet_schema_pb;
static int id = 0;
ColumnPB* column = tablet_schema_pb.add_column();
@@ -79,8 +79,8 @@ public:
tablet_schema->init_from_pb(tablet_schema_pb);
}
- void init_row_block(const TabletSchema* tablet_schema, int size) {
- _schema = std::make_unique<Schema>(*tablet_schema);
+ void init_row_block(TabletSchemaSPtr tablet_schema, int size) {
+ _schema = std::make_unique<Schema>(tablet_schema);
_row_block.reset(new RowBlockV2(*_schema, size));
}
@@ -91,18 +91,18 @@ public:
#define TEST_IN_LIST_PREDICATE(TYPE, TYPE_NAME, FIELD_TYPE) \
TEST_F(TestNullPredicate, TYPE_NAME##_COLUMN) { \
- TabletSchema tablet_schema; \
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>(); \
SetTabletSchema(std::string("TYPE_NAME##_COLUMN"), FIELD_TYPE, "REPLACE", 1, true, true, \
- &tablet_schema); \
+ tablet_schema); \
int size = 10; \
std::vector<uint32_t> return_columns; \
- for (int i = 0; i < tablet_schema.num_columns(); ++i) { \
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) { \
return_columns.push_back(i); \
} \
std::unique_ptr<ColumnPredicate> pred(new NullPredicate(0, true)); \
\
/* for ColumnBlock nulls */ \
- init_row_block(&tablet_schema, size); \
+ init_row_block(tablet_schema, size); \
ColumnBlock col_block = _row_block->column_block(0); \
auto select_size = _row_block->selected_size(); \
ColumnBlockView col_block_view(&col_block); \
@@ -116,7 +116,7 @@ public:
/* for vectorized::Block no null */ \
_row_block->clear(); \
select_size = _row_block->selected_size(); \
- vectorized::Block vec_block = tablet_schema.create_block(return_columns); \
+ vectorized::Block vec_block = tablet_schema->create_block(return_columns); \
_row_block->convert_to_vec_block(&vec_block); \
ColumnPtr vec_col = vec_block.get_columns()[0]; \
select_size = pred->evaluate(const_cast<doris::vectorized::IColumn&>(*vec_col), \
@@ -141,7 +141,7 @@ public:
/* for vectorized::Block has nulls */ \
_row_block->clear(); \
select_size = _row_block->selected_size(); \
- vec_block = tablet_schema.create_block(return_columns); \
+ vec_block = tablet_schema->create_block(return_columns); \
_row_block->convert_to_vec_block(&vec_block); \
vec_col = vec_block.get_columns()[0]; \
select_size = pred->evaluate(const_cast<doris::vectorized::IColumn&>(*vec_col), \
@@ -157,17 +157,17 @@ TEST_IN_LIST_PREDICATE(int64_t, BIGINT, "BIGINT")
TEST_IN_LIST_PREDICATE(int128_t, LARGEINT, "LARGEINT")
TEST_F(TestNullPredicate, FLOAT_COLUMN) {
- TabletSchema tablet_schema;
- SetTabletSchema(std::string("FLOAT_COLUMN"), "FLOAT", "REPLACE", 1, true, true, &tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ SetTabletSchema(std::string("FLOAT_COLUMN"), "FLOAT", "REPLACE", 1, true, true, tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
std::unique_ptr<ColumnPredicate> pred(new NullPredicate(0, true));
// for ColumnBlock no nulls
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -181,7 +181,7 @@ TEST_F(TestNullPredicate, FLOAT_COLUMN) {
// for vectorized::Block no null
_row_block->clear();
select_size = _row_block->selected_size();
- vectorized::Block vec_block = tablet_schema.create_block(return_columns);
+ vectorized::Block vec_block = tablet_schema->create_block(return_columns);
_row_block->convert_to_vec_block(&vec_block);
ColumnPtr vec_col = vec_block.get_columns()[0];
select_size = pred->evaluate(const_cast<doris::vectorized::IColumn&>(*vec_col),
@@ -206,7 +206,7 @@ TEST_F(TestNullPredicate, FLOAT_COLUMN) {
// for vectorized::Block has nulls
_row_block->clear();
select_size = _row_block->selected_size();
- vec_block = tablet_schema.create_block(return_columns);
+ vec_block = tablet_schema->create_block(return_columns);
_row_block->convert_to_vec_block(&vec_block);
vec_col = vec_block.get_columns()[0];
select_size = pred->evaluate(const_cast<doris::vectorized::IColumn&>(*vec_col),
@@ -215,18 +215,18 @@ TEST_F(TestNullPredicate, FLOAT_COLUMN) {
}
TEST_F(TestNullPredicate, DOUBLE_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("DOUBLE_COLUMN"), "DOUBLE", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
std::unique_ptr<ColumnPredicate> pred(new NullPredicate(0, true));
// for ColumnBlock no nulls
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -240,7 +240,7 @@ TEST_F(TestNullPredicate, DOUBLE_COLUMN) {
// for vectorized::Block no null
_row_block->clear();
select_size = _row_block->selected_size();
- vectorized::Block vec_block = tablet_schema.create_block(return_columns);
+ vectorized::Block vec_block = tablet_schema->create_block(return_columns);
_row_block->convert_to_vec_block(&vec_block);
ColumnPtr vec_col = vec_block.get_columns()[0];
select_size = pred->evaluate(const_cast<doris::vectorized::IColumn&>(*vec_col),
@@ -265,7 +265,7 @@ TEST_F(TestNullPredicate, DOUBLE_COLUMN) {
// for vectorized::Block has nulls
_row_block->clear();
select_size = _row_block->selected_size();
- vec_block = tablet_schema.create_block(return_columns);
+ vec_block = tablet_schema->create_block(return_columns);
_row_block->convert_to_vec_block(&vec_block);
vec_col = vec_block.get_columns()[0];
select_size = pred->evaluate(const_cast<doris::vectorized::IColumn&>(*vec_col),
@@ -274,18 +274,18 @@ TEST_F(TestNullPredicate, DOUBLE_COLUMN) {
}
TEST_F(TestNullPredicate, DECIMAL_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("DECIMAL_COLUMN"), "DECIMAL", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
std::unique_ptr<ColumnPredicate> pred(new NullPredicate(0, true));
// for ColumnBlock no nulls
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -300,7 +300,7 @@ TEST_F(TestNullPredicate, DECIMAL_COLUMN) {
// for vectorized::Block no null
_row_block->clear();
select_size = _row_block->selected_size();
- vectorized::Block vec_block = tablet_schema.create_block(return_columns);
+ vectorized::Block vec_block = tablet_schema->create_block(return_columns);
_row_block->convert_to_vec_block(&vec_block);
ColumnPtr vec_col = vec_block.get_columns()[0];
select_size = pred->evaluate(const_cast<doris::vectorized::IColumn&>(*vec_col),
@@ -326,7 +326,7 @@ TEST_F(TestNullPredicate, DECIMAL_COLUMN) {
// for vectorized::Block has nulls
_row_block->clear();
select_size = _row_block->selected_size();
- vec_block = tablet_schema.create_block(return_columns);
+ vec_block = tablet_schema->create_block(return_columns);
_row_block->convert_to_vec_block(&vec_block);
vec_col = vec_block.get_columns()[0];
select_size = pred->evaluate(const_cast<doris::vectorized::IColumn&>(*vec_col),
@@ -335,18 +335,18 @@ TEST_F(TestNullPredicate, DECIMAL_COLUMN) {
}
TEST_F(TestNullPredicate, STRING_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("STRING_COLUMN"), "VARCHAR", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 10;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
std::unique_ptr<ColumnPredicate> pred(new NullPredicate(0, true));
// for ColumnBlock no nulls
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -367,7 +367,7 @@ TEST_F(TestNullPredicate, STRING_COLUMN) {
// for vectorized::Block no null
_row_block->clear();
select_size = _row_block->selected_size();
- vectorized::Block vec_block = tablet_schema.create_block(return_columns);
+ vectorized::Block vec_block = tablet_schema->create_block(return_columns);
_row_block->convert_to_vec_block(&vec_block);
ColumnPtr vec_col = vec_block.get_columns()[0];
select_size = pred->evaluate(const_cast<doris::vectorized::IColumn&>(*vec_col),
@@ -398,7 +398,7 @@ TEST_F(TestNullPredicate, STRING_COLUMN) {
// for vectorized::Block has nulls
_row_block->clear();
select_size = _row_block->selected_size();
- vec_block = tablet_schema.create_block(return_columns);
+ vec_block = tablet_schema->create_block(return_columns);
_row_block->convert_to_vec_block(&vec_block);
vec_col = vec_block.get_columns()[0];
select_size = pred->evaluate(const_cast<doris::vectorized::IColumn&>(*vec_col),
@@ -407,11 +407,11 @@ TEST_F(TestNullPredicate, STRING_COLUMN) {
}
TEST_F(TestNullPredicate, DATE_COLUMN) {
- TabletSchema tablet_schema;
- SetTabletSchema(std::string("DATE_COLUMN"), "DATE", "REPLACE", 1, true, true, &tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ SetTabletSchema(std::string("DATE_COLUMN"), "DATE", "REPLACE", 1, true, true, tablet_schema);
int size = 6;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
std::unique_ptr<ColumnPredicate> pred(new NullPredicate(0, true));
@@ -425,7 +425,7 @@ TEST_F(TestNullPredicate, DATE_COLUMN) {
date_array.push_back("2017-09-12");
// for ColumnBlock no nulls
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -440,7 +440,7 @@ TEST_F(TestNullPredicate, DATE_COLUMN) {
// for vectorized::Block no null
_row_block->clear();
select_size = _row_block->selected_size();
- vectorized::Block vec_block = tablet_schema.create_block(return_columns);
+ vectorized::Block vec_block = tablet_schema->create_block(return_columns);
_row_block->convert_to_vec_block(&vec_block);
ColumnPtr vec_col = vec_block.get_columns()[0];
select_size = pred->evaluate(const_cast<doris::vectorized::IColumn&>(*vec_col),
@@ -466,7 +466,7 @@ TEST_F(TestNullPredicate, DATE_COLUMN) {
// for vectorized::Block has nulls
_row_block->clear();
select_size = _row_block->selected_size();
- vec_block = tablet_schema.create_block(return_columns);
+ vec_block = tablet_schema->create_block(return_columns);
_row_block->convert_to_vec_block(&vec_block);
vec_col = vec_block.get_columns()[0];
select_size = pred->evaluate(const_cast<doris::vectorized::IColumn&>(*vec_col),
@@ -475,12 +475,12 @@ TEST_F(TestNullPredicate, DATE_COLUMN) {
}
TEST_F(TestNullPredicate, DATETIME_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("DATETIME_COLUMN"), "DATETIME", "REPLACE", 1, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 6;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
std::unique_ptr<ColumnPredicate> pred(new NullPredicate(0, true));
@@ -494,7 +494,7 @@ TEST_F(TestNullPredicate, DATETIME_COLUMN) {
date_array.push_back("2017-09-12");
// for ColumnBlock no nulls
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -509,7 +509,7 @@ TEST_F(TestNullPredicate, DATETIME_COLUMN) {
// for vectorized::Block no null
_row_block->clear();
select_size = _row_block->selected_size();
- vectorized::Block vec_block = tablet_schema.create_block(return_columns);
+ vectorized::Block vec_block = tablet_schema->create_block(return_columns);
_row_block->convert_to_vec_block(&vec_block);
ColumnPtr vec_col = vec_block.get_columns()[0];
select_size = pred->evaluate(const_cast<doris::vectorized::IColumn&>(*vec_col),
@@ -535,7 +535,7 @@ TEST_F(TestNullPredicate, DATETIME_COLUMN) {
// for vectorized::Block has nulls
_row_block->clear();
select_size = _row_block->selected_size();
- vec_block = tablet_schema.create_block(return_columns);
+ vec_block = tablet_schema->create_block(return_columns);
_row_block->convert_to_vec_block(&vec_block);
vec_col = vec_block.get_columns()[0];
select_size = pred->evaluate(const_cast<doris::vectorized::IColumn&>(*vec_col),
@@ -544,12 +544,12 @@ TEST_F(TestNullPredicate, DATETIME_COLUMN) {
}
TEST_F(TestNullPredicate, DATEV2_COLUMN) {
- TabletSchema tablet_schema;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
SetTabletSchema(std::string("DATEV2_COLUMN"), "DATEV2", "REPLACE", 4, true, true,
- &tablet_schema);
+ tablet_schema);
int size = 6;
std::vector<uint32_t> return_columns;
- for (int i = 0; i < tablet_schema.num_columns(); ++i) {
+ for (int i = 0; i < tablet_schema->num_columns(); ++i) {
return_columns.push_back(i);
}
std::unique_ptr<ColumnPredicate> pred(new NullPredicate(0, true));
@@ -563,7 +563,7 @@ TEST_F(TestNullPredicate, DATEV2_COLUMN) {
date_array.push_back("2017-09-12");
// for ColumnBlock no nulls
- init_row_block(&tablet_schema, size);
+ init_row_block(tablet_schema, size);
ColumnBlock col_block = _row_block->column_block(0);
auto select_size = _row_block->selected_size();
ColumnBlockView col_block_view(&col_block);
@@ -578,7 +578,7 @@ TEST_F(TestNullPredicate, DATEV2_COLUMN) {
// for vectorized::Block no null
_row_block->clear();
select_size = _row_block->selected_size();
- vectorized::Block vec_block = tablet_schema.create_block(return_columns);
+ vectorized::Block vec_block = tablet_schema->create_block(return_columns);
_row_block->convert_to_vec_block(&vec_block);
ColumnPtr vec_col = vec_block.get_columns()[0];
select_size = pred->evaluate(const_cast<doris::vectorized::IColumn&>(*vec_col),
@@ -604,7 +604,7 @@ TEST_F(TestNullPredicate, DATEV2_COLUMN) {
// for vectorized::Block has nulls
_row_block->clear();
select_size = _row_block->selected_size();
- vec_block = tablet_schema.create_block(return_columns);
+ vec_block = tablet_schema->create_block(return_columns);
_row_block->convert_to_vec_block(&vec_block);
vec_col = vec_block.get_columns()[0];
select_size = pred->evaluate(const_cast<doris::vectorized::IColumn&>(*vec_col),
diff --git a/be/test/olap/row_block_test.cpp b/be/test/olap/row_block_test.cpp
index fffa470d70..0c0b146c11 100644
--- a/be/test/olap/row_block_test.cpp
+++ b/be/test/olap/row_block_test.cpp
@@ -43,7 +43,7 @@ public:
void TearDown() {}
};
-void init_tablet_schema(TabletSchema* tablet_schema) {
+void init_tablet_schema(TabletSchemaSPtr tablet_schema) {
TabletSchemaPB tablet_schema_pb;
{
// k1: bigint
@@ -81,11 +81,11 @@ void init_tablet_schema(TabletSchema* tablet_schema) {
}
TEST_F(TestRowBlock, init) {
- TabletSchema tablet_schema;
- init_tablet_schema(&tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ init_tablet_schema(tablet_schema);
{
// has nullbyte
- RowBlock block(&tablet_schema);
+ RowBlock block(tablet_schema);
RowBlockInfo block_info;
block_info.row_num = 1024;
block_info.null_supported = true;
@@ -94,7 +94,7 @@ TEST_F(TestRowBlock, init) {
}
{
// has nullbyte
- RowBlock block(&tablet_schema);
+ RowBlock block(tablet_schema);
RowBlockInfo block_info;
block_info.row_num = 1024;
block_info.null_supported = false;
@@ -102,7 +102,7 @@ TEST_F(TestRowBlock, init) {
EXPECT_EQ(9 + 17 + 17, block._mem_row_bytes);
}
{
- RowBlock block(&tablet_schema);
+ RowBlock block(tablet_schema);
RowBlockInfo block_info;
block_info.row_num = 1024;
block_info.null_supported = true;
@@ -117,9 +117,9 @@ TEST_F(TestRowBlock, init) {
}
TEST_F(TestRowBlock, write_and_read) {
- TabletSchema tablet_schema;
- init_tablet_schema(&tablet_schema);
- RowBlock block(&tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ init_tablet_schema(tablet_schema);
+ RowBlock block(tablet_schema);
RowBlockInfo block_info;
block_info.row_num = 1024;
block_info.null_supported = true;
@@ -158,9 +158,9 @@ TEST_F(TestRowBlock, write_and_read) {
}
TEST_F(TestRowBlock, write_and_read_without_nullbyte) {
- TabletSchema tablet_schema;
- init_tablet_schema(&tablet_schema);
- RowBlock block(&tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ init_tablet_schema(tablet_schema);
+ RowBlock block(tablet_schema);
RowBlockInfo block_info;
block_info.row_num = 1024;
block_info.null_supported = false;
@@ -199,9 +199,9 @@ TEST_F(TestRowBlock, write_and_read_without_nullbyte) {
}
TEST_F(TestRowBlock, compress_failed) {
- TabletSchema tablet_schema;
- init_tablet_schema(&tablet_schema);
- RowBlock block(&tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ init_tablet_schema(tablet_schema);
+ RowBlock block(tablet_schema);
RowBlockInfo block_info;
block_info.row_num = 1024;
block_info.null_supported = true;
@@ -237,9 +237,9 @@ TEST_F(TestRowBlock, compress_failed) {
}
TEST_F(TestRowBlock, decompress_failed) {
- TabletSchema tablet_schema;
- init_tablet_schema(&tablet_schema);
- RowBlock block(&tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ init_tablet_schema(tablet_schema);
+ RowBlock block(tablet_schema);
RowBlockInfo block_info;
block_info.row_num = 1024;
block_info.null_supported = true;
@@ -275,9 +275,9 @@ TEST_F(TestRowBlock, decompress_failed) {
}
TEST_F(TestRowBlock, clear) {
- TabletSchema tablet_schema;
- init_tablet_schema(&tablet_schema);
- RowBlock block(&tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ init_tablet_schema(tablet_schema);
+ RowBlock block(tablet_schema);
RowBlockInfo block_info;
block_info.row_num = 1024;
block_info.null_supported = true;
@@ -291,9 +291,9 @@ TEST_F(TestRowBlock, clear) {
}
TEST_F(TestRowBlock, pos_limit) {
- TabletSchema tablet_schema;
- init_tablet_schema(&tablet_schema);
- RowBlock block(&tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ init_tablet_schema(tablet_schema);
+ RowBlock block(tablet_schema);
RowBlockInfo block_info;
block_info.row_num = 1024;
block_info.null_supported = true;
diff --git a/be/test/olap/row_block_v2_test.cpp b/be/test/olap/row_block_v2_test.cpp
index 0283026959..217a3871fb 100644
--- a/be/test/olap/row_block_v2_test.cpp
+++ b/be/test/olap/row_block_v2_test.cpp
@@ -28,7 +28,7 @@ public:
void TearDown() {}
};
-void init_tablet_schema(TabletSchema* tablet_schema, bool is_nullable) {
+void init_tablet_schema(TabletSchemaSPtr tablet_schema, bool is_nullable) {
TabletSchemaPB tablet_schema_pb;
{
// k1: bigint
@@ -80,11 +80,11 @@ void init_tablet_schema(TabletSchema* tablet_schema, bool is_nullable) {
}
TEST_F(TestRowBlockV2, test_convert) {
- TabletSchema tablet_schema;
- init_tablet_schema(&tablet_schema, true);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ init_tablet_schema(tablet_schema, true);
Schema schema(tablet_schema);
RowBlockV2 input_block(schema, 1024);
- RowBlock output_block(&tablet_schema);
+ RowBlock output_block(tablet_schema);
RowBlockInfo block_info;
block_info.row_num = 1024;
block_info.null_supported = true;
diff --git a/be/test/olap/row_cursor_test.cpp b/be/test/olap/row_cursor_test.cpp
index fe30e0544d..9412dfbea7 100644
--- a/be/test/olap/row_cursor_test.cpp
+++ b/be/test/olap/row_cursor_test.cpp
@@ -29,7 +29,7 @@
namespace doris {
-void set_tablet_schema_for_init(TabletSchema* tablet_schema) {
+void set_tablet_schema_for_init(TabletSchemaSPtr tablet_schema) {
TabletSchemaPB tablet_schema_pb;
ColumnPB* column_1 = tablet_schema_pb.add_column();
column_1->set_unique_id(1);
@@ -155,7 +155,7 @@ void set_tablet_schema_for_init(TabletSchema* tablet_schema) {
tablet_schema->init_from_pb(tablet_schema_pb);
}
-void set_tablet_schema_for_scan_key(TabletSchema* tablet_schema) {
+void set_tablet_schema_for_scan_key(TabletSchemaSPtr tablet_schema) {
TabletSchemaPB tablet_schema_pb;
ColumnPB* column_1 = tablet_schema_pb.add_column();
@@ -198,7 +198,7 @@ void set_tablet_schema_for_scan_key(TabletSchema* tablet_schema) {
tablet_schema->init_from_pb(tablet_schema_pb);
}
-void set_tablet_schema_for_cmp_and_aggregate(TabletSchema* tablet_schema) {
+void set_tablet_schema_for_cmp_and_aggregate(TabletSchemaSPtr tablet_schema) {
TabletSchemaPB tablet_schema_pb;
ColumnPB* column_1 = tablet_schema_pb.add_column();
@@ -271,8 +271,8 @@ public:
};
TEST_F(TestRowCursor, InitRowCursor) {
- TabletSchema tablet_schema;
- set_tablet_schema_for_init(&tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ set_tablet_schema_for_init(tablet_schema);
RowCursor row;
Status res = row.init(tablet_schema);
EXPECT_EQ(res, Status::OK());
@@ -281,8 +281,8 @@ TEST_F(TestRowCursor, InitRowCursor) {
}
TEST_F(TestRowCursor, InitRowCursorWithColumnCount) {
- TabletSchema tablet_schema;
- set_tablet_schema_for_init(&tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ set_tablet_schema_for_init(tablet_schema);
RowCursor row;
Status res = row.init(tablet_schema, 5);
EXPECT_EQ(res, Status::OK());
@@ -293,11 +293,11 @@ TEST_F(TestRowCursor, InitRowCursorWithColumnCount) {
}
TEST_F(TestRowCursor, InitRowCursorWithColIds) {
- TabletSchema tablet_schema;
- set_tablet_schema_for_init(&tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ set_tablet_schema_for_init(tablet_schema);
std::vector<uint32_t> col_ids;
- for (size_t i = 0; i < tablet_schema.num_columns() / 2; ++i) {
+ for (size_t i = 0; i < tablet_schema->num_columns() / 2; ++i) {
col_ids.push_back(i * 2);
}
@@ -309,15 +309,15 @@ TEST_F(TestRowCursor, InitRowCursorWithColIds) {
}
TEST_F(TestRowCursor, InitRowCursorWithScanKey) {
- TabletSchema tablet_schema;
- set_tablet_schema_for_scan_key(&tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ set_tablet_schema_for_scan_key(tablet_schema);
std::vector<std::string> scan_keys;
scan_keys.push_back("char_exceed_length");
scan_keys.push_back("varchar_exceed_length");
std::vector<uint32_t> columns {0, 1};
- std::shared_ptr<Schema> schema = std::make_shared<Schema>(tablet_schema.columns(), columns);
+ std::shared_ptr<Schema> schema = std::make_shared<Schema>(tablet_schema->columns(), columns);
RowCursor row;
Status res = row.init_scan_key(tablet_schema, scan_keys, schema);
@@ -335,8 +335,8 @@ TEST_F(TestRowCursor, InitRowCursorWithScanKey) {
}
TEST_F(TestRowCursor, EqualAndCompare) {
- TabletSchema tablet_schema;
- set_tablet_schema_for_cmp_and_aggregate(&tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ set_tablet_schema_for_cmp_and_aggregate(tablet_schema);
RowCursor left;
Status res = left.init(tablet_schema);
@@ -373,8 +373,8 @@ TEST_F(TestRowCursor, EqualAndCompare) {
}
TEST_F(TestRowCursor, IndexCmp) {
- TabletSchema tablet_schema;
- set_tablet_schema_for_cmp_and_aggregate(&tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ set_tablet_schema_for_cmp_and_aggregate(tablet_schema);
RowCursor left;
Status res = left.init(tablet_schema, 2);
@@ -414,8 +414,8 @@ TEST_F(TestRowCursor, IndexCmp) {
}
TEST_F(TestRowCursor, FullKeyCmp) {
- TabletSchema tablet_schema;
- set_tablet_schema_for_cmp_and_aggregate(&tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ set_tablet_schema_for_cmp_and_aggregate(tablet_schema);
RowCursor left;
Status res = left.init(tablet_schema);
@@ -454,8 +454,8 @@ TEST_F(TestRowCursor, FullKeyCmp) {
}
TEST_F(TestRowCursor, AggregateWithoutNull) {
- TabletSchema tablet_schema;
- set_tablet_schema_for_cmp_and_aggregate(&tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ set_tablet_schema_for_cmp_and_aggregate(tablet_schema);
RowCursor row;
@@ -516,8 +516,8 @@ TEST_F(TestRowCursor, AggregateWithoutNull) {
}
TEST_F(TestRowCursor, AggregateWithNull) {
- TabletSchema tablet_schema;
- set_tablet_schema_for_cmp_and_aggregate(&tablet_schema);
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ set_tablet_schema_for_cmp_and_aggregate(tablet_schema);
RowCursor row;
diff --git a/be/test/olap/rowset/beta_rowset_test.cpp b/be/test/olap/rowset/beta_rowset_test.cpp
index 4d849b4ac2..5c60fd0313 100644
--- a/be/test/olap/rowset/beta_rowset_test.cpp
+++ b/be/test/olap/rowset/beta_rowset_test.cpp
@@ -186,7 +186,7 @@ TEST_F(BetaRowsetTest, BasicFunctionTest) {
EXPECT_EQ(Status::OK(), s);
RowCursor input_row;
- input_row.init(*tablet_schema);
+ input_row.init(tablet_schema);
// for segment "i", row "rid"
// k1 := rid*10 + i
@@ -216,7 +216,7 @@ TEST_F(BetaRowsetTest, BasicFunctionTest) {
{ // test return ordered results and return k1 and k2
RowsetReaderContext reader_context;
- reader_context.tablet_schema = tablet_schema.get();
+ reader_context.tablet_schema = tablet_schema;
reader_context.need_ordered_result = true;
std::vector<uint32_t> return_columns = {0, 1};
reader_context.return_columns = &return_columns;
@@ -306,7 +306,7 @@ TEST_F(BetaRowsetTest, BasicFunctionTest) {
{ // test return unordered data and only k3
RowsetReaderContext reader_context;
- reader_context.tablet_schema = tablet_schema.get();
+ reader_context.tablet_schema = tablet_schema;
reader_context.need_ordered_result = false;
std::vector<uint32_t> return_columns = {2};
reader_context.return_columns = &return_columns;
diff --git a/be/test/olap/rowset/segment_v2/segment_test.cpp b/be/test/olap/rowset/segment_v2/segment_test.cpp
index a3767a18e2..82bb77d773 100644
--- a/be/test/olap/rowset/segment_v2/segment_test.cpp
+++ b/be/test/olap/rowset/segment_v2/segment_test.cpp
@@ -140,7 +140,7 @@ protected:
EXPECT_TRUE(st.ok());
RowCursor row;
- auto olap_st = row.init(*build_schema);
+ auto olap_st = row.init(build_schema);
EXPECT_EQ(Status::OK(), olap_st);
for (size_t rid = 0; rid < nrows; ++rid) {
@@ -208,13 +208,13 @@ TEST_F(SegmentReaderWriterTest, normal) {
// reader
{
- Schema schema(*tablet_schema);
+ Schema schema(tablet_schema);
OlapReaderStatistics stats;
// scan all rows
{
StorageReadOptions read_opts;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
std::unique_ptr<RowwiseIterator> iter;
ASSERT_TRUE(segment->new_iterator(schema, read_opts, &iter).ok());
@@ -247,7 +247,7 @@ TEST_F(SegmentReaderWriterTest, normal) {
{
// lower bound
std::unique_ptr<RowCursor> lower_bound(new RowCursor());
- lower_bound->init(*tablet_schema, 2);
+ lower_bound->init(tablet_schema, 2);
{
auto cell = lower_bound->cell(0);
cell.set_not_null();
@@ -261,7 +261,7 @@ TEST_F(SegmentReaderWriterTest, normal) {
// upper bound
std::unique_ptr<RowCursor> upper_bound(new RowCursor());
- upper_bound->init(*tablet_schema, 1);
+ upper_bound->init(tablet_schema, 1);
{
auto cell = upper_bound->cell(0);
cell.set_not_null();
@@ -270,7 +270,7 @@ TEST_F(SegmentReaderWriterTest, normal) {
StorageReadOptions read_opts;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
read_opts.key_ranges.emplace_back(lower_bound.get(), false, upper_bound.get(),
true);
std::unique_ptr<RowwiseIterator> iter;
@@ -289,7 +289,7 @@ TEST_F(SegmentReaderWriterTest, normal) {
{
// lower bound
std::unique_ptr<RowCursor> lower_bound(new RowCursor());
- lower_bound->init(*tablet_schema, 2);
+ lower_bound->init(tablet_schema, 2);
{
auto cell = lower_bound->cell(0);
cell.set_not_null();
@@ -303,7 +303,7 @@ TEST_F(SegmentReaderWriterTest, normal) {
// upper bound
std::unique_ptr<RowCursor> upper_bound(new RowCursor());
- upper_bound->init(*tablet_schema, 2);
+ upper_bound->init(tablet_schema, 2);
{
auto cell = upper_bound->cell(0);
cell.set_not_null();
@@ -318,7 +318,7 @@ TEST_F(SegmentReaderWriterTest, normal) {
// include upper key
StorageReadOptions read_opts;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
read_opts.key_ranges.emplace_back(lower_bound.get(), true, upper_bound.get(),
true);
std::unique_ptr<RowwiseIterator> iter;
@@ -336,7 +336,7 @@ TEST_F(SegmentReaderWriterTest, normal) {
// not include upper key
StorageReadOptions read_opts1;
read_opts1.stats = &stats;
- read_opts1.tablet_schema = tablet_schema.get();
+ read_opts1.tablet_schema = tablet_schema;
read_opts1.key_ranges.emplace_back(lower_bound.get(), true, upper_bound.get(),
false);
std::unique_ptr<RowwiseIterator> iter1;
@@ -351,7 +351,7 @@ TEST_F(SegmentReaderWriterTest, normal) {
{
// lower bound
std::unique_ptr<RowCursor> lower_bound(new RowCursor());
- lower_bound->init(*tablet_schema, 1);
+ lower_bound->init(tablet_schema, 1);
{
auto cell = lower_bound->cell(0);
cell.set_not_null();
@@ -360,7 +360,7 @@ TEST_F(SegmentReaderWriterTest, normal) {
StorageReadOptions read_opts;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
read_opts.key_ranges.emplace_back(lower_bound.get(), false, nullptr, false);
std::unique_ptr<RowwiseIterator> iter;
ASSERT_TRUE(segment->new_iterator(schema, read_opts, &iter).ok());
@@ -373,7 +373,7 @@ TEST_F(SegmentReaderWriterTest, normal) {
{
// lower bound
std::unique_ptr<RowCursor> lower_bound(new RowCursor());
- lower_bound->init(*tablet_schema, 1);
+ lower_bound->init(tablet_schema, 1);
{
auto cell = lower_bound->cell(0);
cell.set_not_null();
@@ -381,7 +381,7 @@ TEST_F(SegmentReaderWriterTest, normal) {
}
std::unique_ptr<RowCursor> upper_bound(new RowCursor());
- upper_bound->init(*tablet_schema, 1);
+ upper_bound->init(tablet_schema, 1);
{
auto cell = upper_bound->cell(0);
cell.set_not_null();
@@ -390,7 +390,7 @@ TEST_F(SegmentReaderWriterTest, normal) {
StorageReadOptions read_opts;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
read_opts.key_ranges.emplace_back(lower_bound.get(), false, upper_bound.get(),
false);
std::unique_ptr<RowwiseIterator> iter;
@@ -423,7 +423,7 @@ TEST_F(SegmentReaderWriterTest, LazyMaterialization) {
{
// lazy enabled when predicate is subset of returned columns:
// select c1, c2 where c2 = 30;
- Schema read_schema(*tablet_schema);
+ Schema read_schema(tablet_schema);
std::unique_ptr<ColumnPredicate> predicate(new EqualPredicate<int32_t>(1, 30));
const std::vector<ColumnPredicate*> predicates = {predicate.get()};
@@ -431,7 +431,7 @@ TEST_F(SegmentReaderWriterTest, LazyMaterialization) {
StorageReadOptions read_opts;
read_opts.column_predicates = predicates;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
std::unique_ptr<RowwiseIterator> iter;
ASSERT_TRUE(segment->new_iterator(read_schema, read_opts, &iter).ok());
@@ -447,7 +447,7 @@ TEST_F(SegmentReaderWriterTest, LazyMaterialization) {
{
// lazy disabled when all return columns have predicates:
// select c1, c2 where c1 = 10 and c2 = 100;
- Schema read_schema(*tablet_schema);
+ Schema read_schema(tablet_schema);
std::unique_ptr<ColumnPredicate> p0(new EqualPredicate<int32_t>(0, 10));
std::unique_ptr<ColumnPredicate> p1(new EqualPredicate<int32_t>(1, 100));
const std::vector<ColumnPredicate*> predicates = {p0.get(), p1.get()};
@@ -456,7 +456,7 @@ TEST_F(SegmentReaderWriterTest, LazyMaterialization) {
StorageReadOptions read_opts;
read_opts.column_predicates = predicates;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
std::unique_ptr<RowwiseIterator> iter;
ASSERT_TRUE(segment->new_iterator(read_schema, read_opts, &iter).ok());
@@ -477,7 +477,7 @@ TEST_F(SegmentReaderWriterTest, LazyMaterialization) {
OlapReaderStatistics stats;
StorageReadOptions read_opts;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
std::unique_ptr<RowwiseIterator> iter;
ASSERT_TRUE(segment->new_iterator(read_schema, read_opts, &iter).ok());
@@ -502,7 +502,7 @@ TEST_F(SegmentReaderWriterTest, LazyMaterialization) {
{
// lazy disabled when all predicates are removed by bitmap index:
// select c1, c2 where c2 = 30;
- Schema read_schema(*tablet_schema);
+ Schema read_schema(tablet_schema);
std::unique_ptr<ColumnPredicate> predicate(new EqualPredicate<int32_t>(0, 20));
const std::vector<ColumnPredicate*> predicates = {predicate.get()};
@@ -510,7 +510,7 @@ TEST_F(SegmentReaderWriterTest, LazyMaterialization) {
StorageReadOptions read_opts;
read_opts.column_predicates = predicates;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
std::unique_ptr<RowwiseIterator> iter;
ASSERT_TRUE(segment->new_iterator(read_schema, read_opts, &iter).ok());
@@ -557,7 +557,7 @@ TEST_F(SegmentReaderWriterTest, TestIndex) {
// reader with condition
{
- Schema schema(*tablet_schema);
+ Schema schema(tablet_schema);
OlapReaderStatistics stats;
// test empty segment iterator
{
@@ -568,12 +568,12 @@ TEST_F(SegmentReaderWriterTest, TestIndex) {
std::vector<std::string> vals = {"2"};
condition.__set_condition_values(vals);
std::shared_ptr<Conditions> conditions(new Conditions());
- conditions->set_tablet_schema(tablet_schema.get());
+ conditions->set_tablet_schema(tablet_schema);
EXPECT_EQ(Status::OK(), conditions->append_condition(condition));
StorageReadOptions read_opts;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
read_opts.conditions = conditions.get();
std::unique_ptr<RowwiseIterator> iter;
@@ -592,12 +592,12 @@ TEST_F(SegmentReaderWriterTest, TestIndex) {
std::vector<std::string> vals = {"100"};
condition.__set_condition_values(vals);
std::shared_ptr<Conditions> conditions(new Conditions());
- conditions->set_tablet_schema(tablet_schema.get());
+ conditions->set_tablet_schema(tablet_schema);
EXPECT_EQ(Status::OK(), conditions->append_condition(condition));
StorageReadOptions read_opts;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
read_opts.conditions = conditions.get();
std::unique_ptr<RowwiseIterator> iter;
@@ -642,7 +642,7 @@ TEST_F(SegmentReaderWriterTest, TestIndex) {
std::vector<std::string> vals = {"165000"};
condition.__set_condition_values(vals);
std::shared_ptr<Conditions> conditions(new Conditions());
- conditions->set_tablet_schema(tablet_schema.get());
+ conditions->set_tablet_schema(tablet_schema);
EXPECT_EQ(Status::OK(), conditions->append_condition(condition));
// the second page read will be pruned by the following delete predicate
@@ -652,12 +652,12 @@ TEST_F(SegmentReaderWriterTest, TestIndex) {
std::vector<std::string> vals2 = {"164001"};
delete_condition.__set_condition_values(vals2);
std::shared_ptr<Conditions> delete_conditions(new Conditions());
- delete_conditions->set_tablet_schema(tablet_schema.get());
+ delete_conditions->set_tablet_schema(tablet_schema);
EXPECT_EQ(Status::OK(), delete_conditions->append_condition(delete_condition));
StorageReadOptions read_opts;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
read_opts.conditions = conditions.get();
read_opts.delete_conditions.push_back(delete_conditions.get());
@@ -699,7 +699,7 @@ TEST_F(SegmentReaderWriterTest, TestIndex) {
{
StorageReadOptions read_opts;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
TCondition condition;
condition.__set_column_name("2");
condition.__set_condition_op("=");
@@ -707,7 +707,7 @@ TEST_F(SegmentReaderWriterTest, TestIndex) {
std::vector<std::string> vals = {"102"};
condition.__set_condition_values(vals);
std::shared_ptr<Conditions> conditions(new Conditions());
- conditions->set_tablet_schema(tablet_schema.get());
+ conditions->set_tablet_schema(tablet_schema);
EXPECT_EQ(Status::OK(), conditions->append_condition(condition));
read_opts.conditions = conditions.get();
std::unique_ptr<RowwiseIterator> iter;
@@ -749,7 +749,7 @@ TEST_F(SegmentReaderWriterTest, estimate_segment_size) {
EXPECT_TRUE(st.ok()) << st.to_string();
RowCursor row;
- auto olap_st = row.init(*tablet_schema);
+ auto olap_st = row.init(tablet_schema);
EXPECT_EQ(Status::OK(), olap_st);
// 0, 1, 2, 3
@@ -793,13 +793,13 @@ TEST_F(SegmentReaderWriterTest, TestDefaultValueColumn) {
build_segment(SegmentWriterOptions(), build_schema, query_schema, 4096, DefaultIntGenerator,
&segment);
- Schema schema(*query_schema);
+ Schema schema(query_schema);
OlapReaderStatistics stats;
// scan all rows
{
StorageReadOptions read_opts;
read_opts.stats = &stats;
- read_opts.tablet_schema = query_schema.get();
+ read_opts.tablet_schema = query_schema;
std::unique_ptr<RowwiseIterator> iter;
ASSERT_TRUE(segment->new_iterator(schema, read_opts, &iter).ok());
@@ -844,13 +844,13 @@ TEST_F(SegmentReaderWriterTest, TestDefaultValueColumn) {
build_segment(SegmentWriterOptions(), build_schema, query_schema, 4096, DefaultIntGenerator,
&segment);
- Schema schema(*query_schema);
+ Schema schema(query_schema);
OlapReaderStatistics stats;
// scan all rows
{
StorageReadOptions read_opts;
read_opts.stats = &stats;
- read_opts.tablet_schema = query_schema.get();
+ read_opts.tablet_schema = query_schema;
std::unique_ptr<RowwiseIterator> iter;
ASSERT_TRUE(segment->new_iterator(schema, read_opts, &iter).ok());
@@ -917,7 +917,7 @@ TEST_F(SegmentReaderWriterTest, TestStringDict) {
EXPECT_TRUE(st.ok());
RowCursor row;
- auto olap_st = row.init(*tablet_schema);
+ auto olap_st = row.init(tablet_schema);
EXPECT_EQ(Status::OK(), olap_st);
// 0, 1, 2, 3
@@ -946,13 +946,13 @@ TEST_F(SegmentReaderWriterTest, TestStringDict) {
st = Segment::open(fs, fname, 0, tablet_schema, &segment);
EXPECT_TRUE(st.ok());
EXPECT_EQ(4096, segment->num_rows());
- Schema schema(*tablet_schema);
+ Schema schema(tablet_schema);
OlapReaderStatistics stats;
// scan all rows
{
StorageReadOptions read_opts;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
std::unique_ptr<RowwiseIterator> iter;
ASSERT_TRUE(segment->new_iterator(schema, read_opts, &iter).ok());
@@ -994,7 +994,7 @@ TEST_F(SegmentReaderWriterTest, TestStringDict) {
{
// lower bound
std::unique_ptr<RowCursor> lower_bound(new RowCursor());
- lower_bound->init(*tablet_schema, 1);
+ lower_bound->init(tablet_schema, 1);
{
auto cell = lower_bound->cell(0);
cell.set_not_null();
@@ -1005,7 +1005,7 @@ TEST_F(SegmentReaderWriterTest, TestStringDict) {
StorageReadOptions read_opts;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
read_opts.key_ranges.emplace_back(lower_bound.get(), false, nullptr, false);
std::unique_ptr<RowwiseIterator> iter;
ASSERT_TRUE(segment->new_iterator(schema, read_opts, &iter).ok());
@@ -1020,7 +1020,7 @@ TEST_F(SegmentReaderWriterTest, TestStringDict) {
{
// lower bound
std::unique_ptr<RowCursor> lower_bound(new RowCursor());
- lower_bound->init(*tablet_schema, 1);
+ lower_bound->init(tablet_schema, 1);
{
auto cell = lower_bound->cell(0);
cell.set_not_null();
@@ -1029,7 +1029,7 @@ TEST_F(SegmentReaderWriterTest, TestStringDict) {
}
std::unique_ptr<RowCursor> upper_bound(new RowCursor());
- upper_bound->init(*tablet_schema, 1);
+ upper_bound->init(tablet_schema, 1);
{
auto cell = upper_bound->cell(0);
cell.set_not_null();
@@ -1039,7 +1039,7 @@ TEST_F(SegmentReaderWriterTest, TestStringDict) {
StorageReadOptions read_opts;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
read_opts.key_ranges.emplace_back(lower_bound.get(), false, upper_bound.get(), false);
std::unique_ptr<RowwiseIterator> iter;
ASSERT_TRUE(segment->new_iterator(schema, read_opts, &iter).ok());
@@ -1058,12 +1058,12 @@ TEST_F(SegmentReaderWriterTest, TestStringDict) {
std::vector<std::string> vals = {"100"};
condition.__set_condition_values(vals);
std::shared_ptr<Conditions> conditions(new Conditions());
- conditions->set_tablet_schema(tablet_schema.get());
+ conditions->set_tablet_schema(tablet_schema);
EXPECT_EQ(Status::OK(), conditions->append_condition(condition));
StorageReadOptions read_opts;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
read_opts.conditions = conditions.get();
std::unique_ptr<RowwiseIterator> iter;
@@ -1116,12 +1116,12 @@ TEST_F(SegmentReaderWriterTest, TestStringDict) {
std::vector<std::string> vals = {"-2"};
condition.__set_condition_values(vals);
std::shared_ptr<Conditions> conditions(new Conditions());
- conditions->set_tablet_schema(tablet_schema.get());
+ conditions->set_tablet_schema(tablet_schema);
EXPECT_EQ(Status::OK(), conditions->append_condition(condition));
StorageReadOptions read_opts;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
read_opts.conditions = conditions.get();
std::unique_ptr<RowwiseIterator> iter;
@@ -1148,7 +1148,7 @@ TEST_F(SegmentReaderWriterTest, TestBitmapPredicate) {
EXPECT_TRUE(column_contains_index(segment->footer().columns(1), BITMAP_INDEX));
{
- Schema schema(*tablet_schema);
+ Schema schema(tablet_schema);
// test where v1=10
{
@@ -1160,7 +1160,7 @@ TEST_F(SegmentReaderWriterTest, TestBitmapPredicate) {
OlapReaderStatistics stats;
read_opts.column_predicates = column_predicates;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
std::unique_ptr<RowwiseIterator> iter;
ASSERT_TRUE(segment->new_iterator(schema, read_opts, &iter).ok());
@@ -1183,7 +1183,7 @@ TEST_F(SegmentReaderWriterTest, TestBitmapPredicate) {
OlapReaderStatistics stats;
read_opts.column_predicates = column_predicates;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
std::unique_ptr<RowwiseIterator> iter;
ASSERT_TRUE(segment->new_iterator(schema, read_opts, &iter).ok());
@@ -1206,7 +1206,7 @@ TEST_F(SegmentReaderWriterTest, TestBitmapPredicate) {
OlapReaderStatistics stats;
read_opts.column_predicates = column_predicates;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
std::unique_ptr<RowwiseIterator> iter;
ASSERT_TRUE(segment->new_iterator(schema, read_opts, &iter).ok());
@@ -1231,7 +1231,7 @@ TEST_F(SegmentReaderWriterTest, TestBitmapPredicate) {
OlapReaderStatistics stats;
read_opts.column_predicates = column_predicates;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
std::unique_ptr<RowwiseIterator> iter;
ASSERT_TRUE(segment->new_iterator(schema, read_opts, &iter).ok());
@@ -1255,7 +1255,7 @@ TEST_F(SegmentReaderWriterTest, TestBitmapPredicate) {
OlapReaderStatistics stats;
read_opts.column_predicates = column_predicates;
read_opts.stats = &stats;
- read_opts.tablet_schema = tablet_schema.get();
+ read_opts.tablet_schema = tablet_schema;
std::unique_ptr<RowwiseIterator> iter;
ASSERT_TRUE(segment->new_iterator(schema, read_opts, &iter).ok());
diff --git a/be/test/util/key_util_test.cpp b/be/test/util/key_util_test.cpp
index cb5af67e2b..f7395a8959 100644
--- a/be/test/util/key_util_test.cpp
+++ b/be/test/util/key_util_test.cpp
@@ -32,14 +32,14 @@ public:
};
TEST_F(KeyUtilTest, encode) {
- TabletSchema tablet_schema;
- tablet_schema._cols.push_back(create_int_key(0));
- tablet_schema._cols.push_back(create_int_key(1));
- tablet_schema._cols.push_back(create_int_key(2));
- tablet_schema._cols.push_back(create_int_value(3));
- tablet_schema._num_columns = 4;
- tablet_schema._num_key_columns = 3;
- tablet_schema._num_short_key_columns = 3;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ tablet_schema->_cols.push_back(create_int_key(0));
+ tablet_schema->_cols.push_back(create_int_key(1));
+ tablet_schema->_cols.push_back(create_int_key(2));
+ tablet_schema->_cols.push_back(create_int_value(3));
+ tablet_schema->_num_columns = 4;
+ tablet_schema->_num_key_columns = 3;
+ tablet_schema->_num_short_key_columns = 3;
// test encoding with padding
{
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org