chaoyli closed pull request #474: add rowset cmake file
URL: https://github.com/apache/incubator-doris/pull/474
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt
index 3db6acaf..825aaf80 100644
--- a/be/CMakeLists.txt
+++ b/be/CMakeLists.txt
@@ -453,6 +453,7 @@ set(DORIS_LINK_LIBS
Exprs
Gutil
Olap
+ Rowset
Runtime
Service
Udf
@@ -550,6 +551,7 @@ add_subdirectory(${SRC_DIR}/util)
add_subdirectory(${SRC_DIR}/gen_cpp)
add_subdirectory(${SRC_DIR}/gutil)
add_subdirectory(${SRC_DIR}/olap)
+add_subdirectory(${SRC_DIR}/olap/rowset)
add_subdirectory(${SRC_DIR}/agent)
add_subdirectory(${SRC_DIR}/http)
add_subdirectory(${SRC_DIR}/service)
diff --git a/be/src/olap/CMakeLists.txt b/be/src/olap/CMakeLists.txt
index 071b649f..c6314f8c 100644
--- a/be/src/olap/CMakeLists.txt
+++ b/be/src/olap/CMakeLists.txt
@@ -24,19 +24,13 @@ set(EXECUTABLE_OUTPUT_PATH "${BUILD_DIR}/src/olap")
add_library(Olap STATIC
aggregate_func.cpp
base_compaction.cpp
- rowset/bit_field_reader.cpp
- rowset/bit_field_writer.cpp
bloom_filter.hpp
bloom_filter_reader.cpp
bloom_filter_writer.cpp
byte_buffer.cpp
- rowset/column_data.cpp
- rowset/column_reader.cpp
- rowset/column_writer.cpp
comparison_predicate.cpp
compress.cpp
cumulative_compaction.cpp
- rowset/data_writer.cpp
delete_handler.cpp
delta_writer.cpp
field.cpp
@@ -62,14 +56,7 @@ add_library(Olap STATIC
reader.cpp
row_block.cpp
row_cursor.cpp
- rowset/segment_group.cpp
- rowset/run_length_byte_reader.cpp
- rowset/run_length_byte_writer.cpp
- rowset/run_length_integer_reader.cpp
- rowset/run_length_integer_writer.cpp
schema_change.cpp
- rowset/segment_reader.cpp
- rowset/segment_writer.cpp
serialize.cpp
storage_engine.cpp
data_dir.cpp
@@ -85,9 +72,4 @@ add_library(Olap STATIC
types.cpp
utils.cpp
wrapper_field.cpp
- rowset/rowset_meta_manager.cpp
- rowset/alpha_rowset.cpp
- rowset/alpha_rowset_reader.cpp
- rowset/alpha_rowset_builder.cpp
- rowset/alpha_rowset_meta.cpp
)
diff --git a/be/src/olap/delete_handler.cpp b/be/src/olap/delete_handler.cpp
index 8ba3de79..390b24ab 100644
--- a/be/src/olap/delete_handler.cpp
+++ b/be/src/olap/delete_handler.cpp
@@ -45,52 +45,6 @@ using google::protobuf::RepeatedPtrField;
namespace doris {
-// 将删除条件存储到table的Header文件中,
-// 在存储之前会判断删除条件是否符合要求。主要判断以下2个方面:
-// 1. 删除条件的版本要不是当前最大的delta版本号,要不是最大的delta版本号加1
-// 2. 删除条件中指定的列在table中存在,必须是key列,且不能是double,float类型
-OLAPStatus DeleteConditionHandler::store_cond(
- TabletSharedPtr tablet,
- const int32_t version,
- const vector<TCondition>& conditions) {
- if (conditions.size() == 0 || _check_version_valid(tablet, version) !=
OLAP_SUCCESS) {
- OLAP_LOG_WARNING("invalid parameters for store_cond. "
- "[version=%d condition_size=%u]",
- version, conditions.size());
- return OLAP_ERR_DELETE_INVALID_PARAMETERS;
- }
-
- // 检查删除条件是否符合要求
- for (const TCondition& condition : conditions) {
- if (check_condition_valid(tablet, condition) != OLAP_SUCCESS) {
- OLAP_LOG_WARNING("invalid condition. [%s]",
- ThriftDebugString(condition).c_str());
- return OLAP_ERR_DELETE_INVALID_CONDITION;
- }
- }
-
- int cond_index = _check_whether_condition_exist(tablet, version);
- DeleteConditionMessage* del_cond = NULL;
-
- if (cond_index == -1) { // 删除条件不存在
- del_cond = tablet->add_delete_data_conditions();
- del_cond->set_version(version);
- } else { // 删除条件已经存在
- del_cond = tablet->mutable_delete_data_conditions(cond_index);
- del_cond->clear_sub_conditions();
- }
-
- // 存储删除条件
- for (const TCondition& condition : conditions) {
- string condition_str = construct_sub_conditions(condition);
- del_cond->add_sub_conditions(condition_str);
- LOG(INFO) << "store one sub-delete condition."
- << "condition=" << condition_str;
- }
-
- return OLAP_SUCCESS;
-}
-
string DeleteConditionHandler::construct_sub_conditions(const TCondition&
condition) {
string op = condition.condition_op;
if (op == "<") {
@@ -109,7 +63,7 @@ string
DeleteConditionHandler::construct_sub_conditions(const TCondition& condit
// 删除指定版本号的删除条件;需要注意的是,如果table上没有任何删除条件,或者
// 指定版本号的删除条件不存在,也会返回OLAP_SUCCESS。
-OLAPStatus DeleteConditionHandler::delete_cond(TabletSharedPtr tablet,
+OLAPStatus DeleteConditionHandler::delete_cond(del_cond_array*
delete_condition,
const int32_t version,
bool delete_smaller_version_conditions) {
if (version < 0) {
@@ -117,8 +71,6 @@ OLAPStatus
DeleteConditionHandler::delete_cond(TabletSharedPtr tablet,
return OLAP_ERR_DELETE_INVALID_PARAMETERS;
}
- del_cond_array* delete_conditions =
tablet->mutable_delete_data_conditions();
-
if (delete_conditions->size() == 0) {
return OLAP_SUCCESS;
}
@@ -157,10 +109,9 @@ OLAPStatus
DeleteConditionHandler::delete_cond(TabletSharedPtr tablet,
return OLAP_SUCCESS;
}
-OLAPStatus DeleteConditionHandler::log_conds(TabletSharedPtr tablet) {
- LOG(INFO) << "display all delete condition. tablet=" <<
tablet->full_name();
- tablet->obtain_header_rdlock();
- const del_cond_array& delete_conditions = tablet->delete_data_conditions();
+OLAPStatus DeleteConditionHandler::log_conds(std::string tablet_full_name,
+ const del_cond_array& delete_conditions) {
+ LOG(INFO) << "display all delete condition. tablet=" << tablet_full_name;
for (int index = 0; index != delete_conditions.size(); ++index) {
DeleteConditionMessage temp = delete_conditions.Get(index);
@@ -175,16 +126,14 @@ OLAPStatus
DeleteConditionHandler::log_conds(TabletSharedPtr tablet) {
LOG(INFO) << "condition item: version=" << temp.version()
<< ", condition=" << del_cond_str;
}
-
- tablet->release_header_lock();
return OLAP_SUCCESS;
}
OLAPStatus DeleteConditionHandler::check_condition_valid(
- TabletSharedPtr tablet,
+ const RowFields& tablet_schema,
const TCondition& cond) {
// 检查指定列名的列是否存在
- int field_index = tablet->get_field_index(cond.column_name);
+ int field_index = _get_field_index(tablet_schema, cond.column_name);
if (field_index < 0) {
OLAP_LOG_WARNING("field is not existent. [field_index=%d]",
field_index);
@@ -192,7 +141,7 @@ OLAPStatus DeleteConditionHandler::check_condition_valid(
}
// 检查指定的列是不是key,是不是float或doulbe类型
- FieldInfo field_info = tablet->tablet_schema()[field_index];
+ FieldInfo field_info = tablet_schema[field_index];
if (!field_info.is_key
|| field_info.type == OLAP_FIELD_TYPE_DOUBLE
@@ -257,11 +206,9 @@ OLAPStatus DeleteConditionHandler::check_condition_valid(
}
}
-OLAPStatus DeleteConditionHandler::_check_version_valid(TabletSharedPtr tablet,
+OLAPStatus DeleteConditionHandler::_check_version_valid(std::vector<Version>*
all_file_versions,
const int32_t filter_version) {
// 找到当前最大的delta文件版本号
- vector<Version> all_file_versions;
- tablet->list_versions(&all_file_versions);
int max_delta_version = -1;
vector<Version>::const_iterator version_iter = all_file_versions.begin();
@@ -280,9 +227,7 @@ OLAPStatus
DeleteConditionHandler::_check_version_valid(TabletSharedPtr tablet,
}
}
-int DeleteConditionHandler::_check_whether_condition_exist(TabletSharedPtr
tablet, int cond_version) {
- const del_cond_array& delete_conditions = tablet->delete_data_conditions();
-
+int DeleteConditionHandler::_check_whether_condition_exist(const
del_cond_array& delete_conditions, int cond_version) {
if (delete_conditions.size() == 0) {
return -1;
}
@@ -334,24 +279,19 @@ bool DeleteHandler::_parse_condition(const std::string&
condition_str, TConditio
return true;
}
-OLAPStatus DeleteHandler::init(TabletSharedPtr tablet, int32_t version) {
+OLAPStatus DeleteHandler::init(const RowFields& tablet_schema,
+ const del_cond_array& delete_conditions, int32_t version) {
if (_is_inited) {
OLAP_LOG_WARNING("reintialize delete handler.");
return OLAP_ERR_INIT_FAILED;
}
- if (!tablet) {
- OLAP_LOG_WARNING("invalid parameters: invalid tablet.");
- return OLAP_ERR_DELETE_INVALID_PARAMETERS;
- }
-
if (version < 0) {
OLAP_LOG_WARNING("invalid parameters. [version=%d]", version);
return OLAP_ERR_DELETE_INVALID_PARAMETERS;
}
- const del_cond_array& delete_conditions = tablet->delete_data_conditions();
del_cond_array::const_iterator it = delete_conditions.begin();
for (; it != delete_conditions.end(); ++it) {
@@ -370,7 +310,7 @@ OLAPStatus DeleteHandler::init(TabletSharedPtr tablet,
int32_t version) {
return OLAP_ERR_MALLOC_ERROR;
}
- temp.del_cond->set_tablet(tablet);
+ temp.del_cond->set_tablet_schema(tablet_schema);
for (int i = 0; i != it->sub_conditions_size(); ++i) {
TCondition condition;
diff --git a/be/src/olap/delete_handler.h b/be/src/olap/delete_handler.h
index 65dbfd0e..b7d83dc9 100644
--- a/be/src/olap/delete_handler.h
+++ b/be/src/olap/delete_handler.h
@@ -26,7 +26,6 @@
#include "olap/field.h"
#include "olap/olap_cond.h"
#include "olap/olap_define.h"
-#include "olap/tablet.h"
#include "olap/row_cursor.h"
namespace doris {
@@ -55,22 +54,7 @@ class DeleteConditionHandler {
// 检查cond表示的删除条件是否符合要求;
// 如果不符合要求,返回OLAP_ERR_DELETE_INVALID_CONDITION;符合要求返回OLAP_SUCCESS
- OLAPStatus check_condition_valid(TabletSharedPtr tablet, const TCondition&
cond);
-
- // 存储指定版本号的删除条件到Header文件中。因此,调用之前需要对Header文件加写锁
- //
- // 输入参数:
- // * table:指定删除条件要作用的olap engine表;删除条件就存储在这个表的Header文件中
- // * version: 删除条件的版本
- // * del_condition: 用字符串形式表示的删除条件
- // 返回值:
- // * OLAP_SUCCESS:调用成功
- // * OLAP_ERR_DELETE_INVALID_PARAMETERS:函数参数不符合要求
- // * OLAP_ERR_DELETE_INVALID_CONDITION:del_condition不符合要求
- OLAPStatus store_cond(
- TabletSharedPtr tablet,
- const int32_t version,
- const std::vector<TCondition>& conditions);
+ OLAPStatus check_condition_valid(const RowFields& tablet_schema, const
TCondition& cond);
// construct sub condition from TCondition
std::string construct_sub_conditions(const TCondition& condition);
@@ -90,7 +74,7 @@ class DeleteConditionHandler {
// * 这个表没有指定版本号的删除条件
// * OLAP_ERR_DELETE_INVALID_PARAMETERS:函数参数不符合要求
OLAPStatus delete_cond(
- TabletSharedPtr tablet, const int32_t version, bool
delete_smaller_version_conditions);
+ del_cond_array* delete_condition, const int32_t version, bool
delete_smaller_version_conditions);
// 将一个olap engine的表上存有的所有删除条件打印到log中。调用前只需要给Header文件加读锁
//
@@ -98,15 +82,26 @@ class DeleteConditionHandler {
// tablet: 要打印删除条件的olap engine表
// 返回值:
// OLAP_SUCCESS:调用成功
- OLAPStatus log_conds(TabletSharedPtr tablet);
+ OLAPStatus log_conds(std::string tablet_full_name,
+ const del_cond_array& delete_conditions);
private:
// 检查指定的删除条件版本是否符合要求;
// 如果不符合要求,返回OLAP_ERR_DELETE_INVALID_VERSION;符合要求返回OLAP_SUCCESS
- OLAPStatus _check_version_valid(TabletSharedPtr tablet, const int32_t
filter_version);
+ OLAPStatus _check_version_valid(std::vector<Version>* all_file_versions,
const int32_t filter_version);
// 检查指定版本的删除条件是否已经存在。如果存在,返回指定版本删除条件的数组下标;不存在返回-1
- int _check_whether_condition_exist(TabletSharedPtr, int cond_version);
+ int _check_whether_condition_exist(const del_cond_array&
delete_conditions, int cond_version);
+
+ int32_t _get_field_index(const RowFields& tablet_schema, const
std::string& field_name) const {
+ for (int i = 0; i < tablet_schema.size(); i++) {
+ if (tablet_schema[i].name == field_name) {
+ return i;
+ }
+ }
+ LOG(WARNING) << "invalid field name. [name='" << field_name << "']";
+ return -1;
+ }
};
// 表示一个删除条件
@@ -154,7 +149,8 @@ class DeleteHandler {
// * OLAP_SUCCESS: 调用成功
// * OLAP_ERR_DELETE_INVALID_PARAMETERS: 参数不符合要求
// * OLAP_ERR_MALLOC_ERROR: 在填充_del_conds时,分配内存失败
- OLAPStatus init(TabletSharedPtr tablet, int32_t version);
+ OLAPStatus init(const RowFields& tablet_schema,
+ const del_cond_array& delete_conditions, int32_t version);
// 判定一条数据是否符合删除条件
//
diff --git a/be/src/olap/olap_common.h b/be/src/olap/olap_common.h
index 5d45adcd..123eb632 100644
--- a/be/src/olap/olap_common.h
+++ b/be/src/olap/olap_common.h
@@ -28,6 +28,7 @@
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
+#include <functional>
#include "gen_cpp/Types_types.h"
#include "olap/olap_define.h"
@@ -263,4 +264,4 @@ typedef std::map<ColumnId, ColumnId> UniqueIdToColumnIdMap;
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_OLAP_COMMON_H
+#endif // DORIS_BE_SRC_OLAP_OLAP_COMMON_H
\ No newline at end of file
diff --git a/be/src/olap/olap_cond.cpp b/be/src/olap/olap_cond.cpp
index f3f1fc76..f7708fb6 100644
--- a/be/src/olap/olap_cond.cpp
+++ b/be/src/olap/olap_cond.cpp
@@ -555,7 +555,7 @@ bool CondColumn::eval(const BloomFilter& bf) const {
}
OLAPStatus Conditions::append_condition(const TCondition& tcond) {
- int32_t index = _tablet->get_field_index(tcond.column_name);
+ int32_t index = _get_field_index(tcond.column_name);
if (index < 0) {
OLAP_LOG_WARNING("fail to get field index, name is invalid. [index=%d;
field_name=%s]",
index,
@@ -564,7 +564,7 @@ OLAPStatus Conditions::append_condition(const TCondition&
tcond) {
}
// Skip column which is non-key, or whose type is string or float
- const FieldInfo& fi = _tablet->tablet_schema()[index];
+ const FieldInfo& fi = _tablet_schema[index];
if (fi.type == OLAP_FIELD_TYPE_DOUBLE || fi.type == OLAP_FIELD_TYPE_FLOAT)
{
return OLAP_SUCCESS;
}
@@ -572,7 +572,7 @@ OLAPStatus Conditions::append_condition(const TCondition&
tcond) {
CondColumn* cond_col = nullptr;
auto it = _columns.find(index);
if (it == _columns.end()) {
- cond_col = new CondColumn(_tablet, index);
+ cond_col = new CondColumn(_tablet_schema, index);
_columns[index] = cond_col;
} else {
cond_col = it->second;
diff --git a/be/src/olap/olap_cond.h b/be/src/olap/olap_cond.h
index 4ef14150..e8f48613 100644
--- a/be/src/olap/olap_cond.h
+++ b/be/src/olap/olap_cond.h
@@ -28,7 +28,7 @@
#include "olap/bloom_filter.hpp"
#include "olap/stream_index_common.h"
#include "olap/field.h"
-#include "olap/tablet.h"
+#include "olap/field_info.h"
#include "olap/row_cursor.h"
namespace doris {
@@ -89,9 +89,9 @@ struct Cond {
// 所有归属于同一列上的条件二元组,聚合在一个CondColumn上
class CondColumn {
public:
- CondColumn(TabletSharedPtr tablet, int32_t index) : _col_index(index),
_tablet(tablet) {
+ CondColumn(const RowFields& tablet_schema, int32_t index) :
_col_index(index) {
_conds.clear();
- _is_key = _tablet->tablet_schema()[_col_index].is_key;
+ _is_key = tablet_schema[_col_index].is_key;
}
~CondColumn();
@@ -120,7 +120,6 @@ class CondColumn {
bool _is_key;
int32_t _col_index;
std::vector<Cond*> _conds;
- TabletSharedPtr _tablet;
};
// 一次请求所关联的条件
@@ -139,11 +138,8 @@ class Conditions {
_columns.clear();
}
- void set_tablet(TabletSharedPtr tablet) {
- long do_not_remove_me_until_you_want_a_heart_attacking =
tablet.use_count();
- OLAP_UNUSED_ARG(do_not_remove_me_until_you_want_a_heart_attacking);
-
- _tablet = tablet;
+ void set_tablet_schema(const RowFields& tablet_schema) {
+ _tablet_schema = tablet_schema;
}
// 如果成功,则_columns中增加一项,如果失败则无视此condition,同时输出日志
@@ -164,7 +160,18 @@ class Conditions {
}
private:
- TabletSharedPtr _tablet; // ref to Tablet to access schema
+ int32_t _get_field_index(const std::string& field_name) const {
+ for (int i = 0; i < _tablet_schema.size(); i++) {
+ if (_tablet_schema[i].name == field_name) {
+ return i;
+ }
+ }
+ LOG(WARNING) << "invalid field name. [name='" << field_name << "']";
+ return -1;
+ }
+
+private:
+ RowFields _tablet_schema;
CondColumns _columns; // list of condition column
};
diff --git a/be/src/olap/olap_index.cpp b/be/src/olap/olap_index.cpp
index 8e4ee191..5a093a3f 100644
--- a/be/src/olap/olap_index.cpp
+++ b/be/src/olap/olap_index.cpp
@@ -23,7 +23,6 @@
#include <fstream>
#include "olap/rowset/column_data.h"
-#include "olap/tablet.h"
#include "olap/row_block.h"
#include "olap/row_cursor.h"
#include "olap/utils.h"
diff --git a/be/src/olap/olap_index.h b/be/src/olap/olap_index.h
index 87f98f23..94b4660c 100644
--- a/be/src/olap/olap_index.h
+++ b/be/src/olap/olap_index.h
@@ -33,14 +33,12 @@
#include "olap/file_helper.h"
#include "olap/olap_common.h"
#include "olap/olap_define.h"
-#include "olap/tablet.h"
#include "olap/row_cursor.h"
#include "olap/utils.h"
namespace doris {
class IndexComparator;
class SegmentGroup;
-class Tablet;
class RowBlock;
class RowCursor;
class SegmentComparator;
diff --git a/be/src/olap/olap_meta.h b/be/src/olap/olap_meta.h
index fcd58def..c40a7bc9 100755
--- a/be/src/olap/olap_meta.h
+++ b/be/src/olap/olap_meta.h
@@ -22,7 +22,6 @@
#include <map>
#include <functional>
-#include "olap/tablet_meta.h"
#include "olap/olap_define.h"
#include "rocksdb/db.h"
diff --git a/be/src/olap/rowset/CMakeLists.txt
b/be/src/olap/rowset/CMakeLists.txt
new file mode 100644
index 00000000..fecf11dc
--- /dev/null
+++ b/be/src/olap/rowset/CMakeLists.txt
@@ -0,0 +1,43 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# where to put generated libraries
+set(LIBRARY_OUTPUT_PATH "${BUILD_DIR}/src/olap/rowset")
+
+# where to put generated binaries
+set(EXECUTABLE_OUTPUT_PATH "${BUILD_DIR}/src/olap/rowset")
+
+add_library(Rowset STATIC
+ bit_field_reader.cpp
+ bit_field_writer.cpp
+ column_data.cpp
+ column_reader.cpp
+ column_writer.cpp
+ column_data_writer.cpp
+ segment_group.cpp
+ run_length_byte_reader.cpp
+ run_length_byte_writer.cpp
+ run_length_integer_reader.cpp
+ run_length_integer_writer.cpp
+ segment_reader.cpp
+ segment_writer.cpp
+ rowset_meta_manager.cpp
+ alpha_rowset.cpp
+ alpha_rowset_reader.cpp
+ alpha_rowset_builder.cpp
+ alpha_rowset_meta.cpp
+)
\ No newline at end of file
diff --git a/be/src/olap/rowset/alpha_rowset.cpp
b/be/src/olap/rowset/alpha_rowset.cpp
index 84214455..6c692852 100644
--- a/be/src/olap/rowset/alpha_rowset.cpp
+++ b/be/src/olap/rowset/alpha_rowset.cpp
@@ -1,147 +1,149 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include "olap/rowset/alpha_rowset.h"
-
-namespace doris {
-
-AlphaRowset::AlphaRowset(const RowFields& tablet_schema,
- int num_key_fields, int num_short_key_fields,
- int num_rows_per_row_block, const std::string rowset_path,
- RowsetMetaSharedPtr rowset_meta) : _tablet_schema(tablet_schema),
- _num_key_fields(num_key_fields),
- _num_short_key_fields(num_short_key_fields),
- _num_rows_per_row_block(num_rows_per_row_block),
- _rowset_path(rowset_path),
- _rowset_meta(rowset_meta),
- _segment_group_size(0),
- _is_cumulative_rowset(false) {
- Version version = _rowset_meta->get_version();
- if (veresion.first == version.second) {
- _is_cumulative_rowset = false;
- } else {
- _is_cumulative_rowset = true;
- }
-}
-
-NewStatus AlphaRowset::init() {
- _init_segment_groups();
- return NewStatus.OK();
-}
-
-std::unique_ptr<RowsetReader> AlphaRowset::create_reader() {
- std::vector<SegmentGroup*> segment_groups;
- for (auto& segment_group : _segment_groups) {
- segment_groups.push_back(segment_group.get());
- }
- AlphaRowsetReader* rowset_reader = new AlphaRowsetReader(_tablet_schema,
- _num_key_fields, _num_short_key_fields, _num_rows_per_row_block,
- _rowset_path, _rowset_meta.get(), _segment_groups);
- return std::unique_ptr<RowsetReader>(rowset_reader);
-}
-
-NewStatus AlphaRowset::copy(RowsetBuilder* dest_rowset_builder) {
- return NewStatus.OK();
-}
-
-NewStatus AlphaRowset::delete() {
- // TODO(hkp) : add delete code
- // delete rowset from meta
- // delete segment groups
- return NewStatus.OK();
-}
-
-void get_meta(RowsetMetaSharedPtr rowset_meta) {
- rowset_meta = _rowset_meta;
-}
-
-void set_version(Version version) {
- _rowset_meta.set_version(version);
-}
-
-NewStatus AlphaRowset::_init_segment_groups() {
- std::vector<SegmentGroupPB> segment_group_metas;
- _rowset_meta.get_segment_groups(&segment_group_metas);
- for (auot& segment_group_meta : segment_group_metas) {
- Version version = _rowset_meta.get_version();
- int64_t version_hash = _rowset_meta.get_version_hash();
- std::shared_ptr<SegmentGroup> segment_group(new
SegmentGroup(tablet_schema, num_key_fields, num_short_key_fields,
- num_rows_per_row_block, rowset_path, version, version_hash,
- false, segment_group_meta.segment_group_id(),
segment_group_meta.num_segments()));
- if (segment_group.get() == nullptr) {
- LOG(WARNING) << "fail to create olap segment_group. [version='" <<
version.first
- << "-" << version.second << "' rowset_id='" <<
_rowset_meta.get_rowset_id() << "']";
- return NewStatus::NoSpace("new segment group failed");
- }
- _segment_groups.push_back(segment_group);
- if (segment_group_meta.has_empty()) {
- segment_group->set_empty(segment_group_meta.empty());
- }
-
- // validate segment group
- if (segment_group->validate() != OLAP_SUCCESS) {
- LOG(WARNING) << "fail to validate segment_group. [version="<<
version.first
- << "-" << version.second << " version_hash=" <<
version_hash;
- // if load segment group failed, rowset init failed
- return NewStatus::Corruption("segment group invalidate failed");
- }
-
- if (segment_group_meta.column_pruning_size() != 0) {
- size_t column_pruning_size =
segment_group_meta.column_pruning_size();
- if (_num_key_fields != column_pruning_size) {
- LOG(ERROR) << "column pruning size is error."
- << "column_pruning_size=" << column_pruning_size << ",
"
- << "num_key_fields=" << _num_key_fields;
- return NewStatus::InvalidArgument("invalid segment group
column prunning size");
- }
- std::vector<std::pair<std::string, std::string>>
column_statistic_strings(_num_key_fields);
- std::vector<bool> null_vec(_num_key_fields);
- for (size_t j = 0; j < _num_key_fields; ++j) {
- ColumnPruning column_pruning =
segment_group_meta.column_pruning(j);
- column_statistic_strings[j].first = column_pruning.min();
- column_statistic_strings[j].second = column_pruning.max();
- if (column_pruning.has_null_flag()) {
- null_vec[j] = column_pruning.null_flag();
- } else {
- null_vec[j] = false;
- }
- }
- OLAPStatus status =
segment_group->add_column_statistics(column_statistic_strings, null_vec);
- if (status != OLAP_SUCCESS) {
- return NewStatus::NotSupported("add column statistics failed");
- }
-
- res = segment_group->load();
- if (res != OLAP_SUCCESS) {
- LOG(WARNING) << "fail to load segment_group. res=" << res <<
", "
- << "version=" << version.first << "-"
- << version.second << ", "
- << "version_hash=" << version_hash;
- return NewStatus::Corruption("segment group load failed");
- }
- }
- }
- _segment_group_size = _segment_groups.size();
- if (_is_cumulative_rowset && _segment_group_size > 1) {
- LOG(WARNING) << "invalid segment group meta for cumulative rowset.
segment group size:"
- << _segment_group_size;
- return NewStatus::InvalidArgument("invalid segment group size:" +
std::to_string(_segment_group_size);
- }
- return NewStatus::OK();
-}
-
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "olap/rowset/alpha_rowset.h"
+#include "olap/rowset/alpha_rowset_meta.h"
+
+namespace doris {
+
+AlphaRowset::AlphaRowset(const RowFields& tablet_schema,
+ int num_key_fields, int num_short_key_fields,
+ int num_rows_per_row_block, const std::string rowset_path,
+ RowsetMetaSharedPtr rowset_meta) : _tablet_schema(tablet_schema),
+ _num_key_fields(num_key_fields),
+ _num_short_key_fields(num_short_key_fields),
+ _num_rows_per_row_block(num_rows_per_row_block),
+ _rowset_path(rowset_path),
+ _rowset_meta(rowset_meta),
+ _segment_group_size(0),
+ _is_cumulative_rowset(false) {
+ Version version = _rowset_meta->get_version();
+ if (version.first == version.second) {
+ _is_cumulative_rowset = false;
+ } else {
+ _is_cumulative_rowset = true;
+ }
+}
+
+NewStatus AlphaRowset::init() {
+ _init_segment_groups();
+ return NewStatus::OK();
+}
+
+std::unique_ptr<RowsetReader> AlphaRowset::create_reader() {
+ std::vector<SegmentGroup*> segment_groups;
+ for (auto& segment_group : _segment_groups) {
+ segment_groups.push_back(segment_group.get());
+ }
+ return std::unique_ptr<RowsetReader>(new AlphaRowsetReader(_tablet_schema,
+ _num_key_fields, _num_short_key_fields, _num_rows_per_row_block,
+ _rowset_path, _rowset_meta.get(), _segment_groups));
+}
+
+NewStatus AlphaRowset::copy(RowsetBuilder* dest_rowset_builder) {
+ return NewStatus::OK();
+}
+
+NewStatus AlphaRowset::remove() {
+ // TODO(hkp) : add delete code
+ // delete rowset from meta
+ // delete segment groups
+ return NewStatus::OK();
+}
+
+RowsetMetaSharedPtr AlphaRowset::get_meta() {
+ return _rowset_meta;
+}
+
+void AlphaRowset::set_version(Version version) {
+ _rowset_meta->set_version(version);
+}
+
+NewStatus AlphaRowset::_init_segment_groups() {
+ std::vector<SegmentGroupPB> segment_group_metas;
+ AlphaRowsetMeta* _alpha_rowset_meta = (AlphaRowsetMeta*)_rowset_meta.get();
+ _alpha_rowset_meta->get_segment_groups(&segment_group_metas);
+ for (auto& segment_group_meta : segment_group_metas) {
+ Version version = _rowset_meta->get_version();
+ int64_t version_hash = _rowset_meta->get_version_hash();
+ std::shared_ptr<SegmentGroup> segment_group(new
SegmentGroup(_rowset_meta->get_tablet_id(),
+ _tablet_schema, _num_key_fields, _num_short_key_fields,
+ _num_rows_per_row_block, _rowset_path, version, version_hash,
+ false, segment_group_meta.segment_group_id(),
segment_group_meta.num_segments()));
+ if (segment_group.get() == nullptr) {
+ LOG(WARNING) << "fail to create olap segment_group. [version='" <<
version.first
+ << "-" << version.second << "' rowset_id='" <<
_rowset_meta->get_rowset_id() << "']";
+ return NewStatus::NoSpace("new segment group failed");
+ }
+ _segment_groups.push_back(segment_group);
+ if (segment_group_meta.has_empty()) {
+ segment_group->set_empty(segment_group_meta.empty());
+ }
+
+ // validate segment group
+ if (segment_group->validate() != OLAP_SUCCESS) {
+ LOG(WARNING) << "fail to validate segment_group. [version="<<
version.first
+ << "-" << version.second << " version_hash=" <<
version_hash;
+ // if load segment group failed, rowset init failed
+ return NewStatus::Corruption("segment group invalidate failed");
+ }
+
+ if (segment_group_meta.column_pruning_size() != 0) {
+ size_t column_pruning_size =
segment_group_meta.column_pruning_size();
+ if (_num_key_fields != column_pruning_size) {
+ LOG(ERROR) << "column pruning size is error."
+ << "column_pruning_size=" << column_pruning_size << ",
"
+ << "num_key_fields=" << _num_key_fields;
+ return NewStatus::InvalidArgument("invalid segment group
column prunning size");
+ }
+ std::vector<std::pair<std::string, std::string>>
column_statistic_strings(_num_key_fields);
+ std::vector<bool> null_vec(_num_key_fields);
+ for (size_t j = 0; j < _num_key_fields; ++j) {
+ ColumnPruning column_pruning =
segment_group_meta.column_pruning(j);
+ column_statistic_strings[j].first = column_pruning.min();
+ column_statistic_strings[j].second = column_pruning.max();
+ if (column_pruning.has_null_flag()) {
+ null_vec[j] = column_pruning.null_flag();
+ } else {
+ null_vec[j] = false;
+ }
+ }
+ OLAPStatus status =
segment_group->add_column_statistics(column_statistic_strings, null_vec);
+ if (status != OLAP_SUCCESS) {
+ return NewStatus::NotSupported("add column statistics failed");
+ }
+
+ OLAPStatus res = segment_group->load();
+ if (res != OLAP_SUCCESS) {
+ LOG(WARNING) << "fail to load segment_group. res=" << res <<
", "
+ << "version=" << version.first << "-"
+ << version.second << ", "
+ << "version_hash=" << version_hash;
+ return NewStatus::Corruption("segment group load failed");
+ }
+ }
+ }
+ _segment_group_size = _segment_groups.size();
+ if (_is_cumulative_rowset && _segment_group_size > 1) {
+ LOG(WARNING) << "invalid segment group meta for cumulative rowset.
segment group size:"
+ << _segment_group_size;
+ return NewStatus::InvalidArgument("invalid segment group size:" +
std::to_string(_segment_group_size));
+ }
+ return NewStatus::OK();
+}
+
} // namespace doris
\ No newline at end of file
diff --git a/be/src/olap/rowset/alpha_rowset.h
b/be/src/olap/rowset/alpha_rowset.h
index afe6dcab..3486d158 100644
--- a/be/src/olap/rowset/alpha_rowset.h
+++ b/be/src/olap/rowset/alpha_rowset.h
@@ -1,62 +1,68 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#ifndef DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_H
-#define DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_H
-
-#include "olap/rowset/rowset.h"
-#include "olap/rowset/segment_group.h"
-#include "olap/alpha_rowset_reader.h"
-#include "olap/alpha_rowset_builder.h"
-
-#include <vector>
-#include <memory>
-
-namespace doris {
-
-class AlphaRowset {
-public:
- AlphaRowset(const RowFields& tablet_schema,
- int num_key_fields, int num_short_key_fields,
- int num_rows_per_row_block, const std::string rowset_path,
- RowsetMetaSharedPtr rowset_meta);
-
- virtual NewStatus init();
-
- virtual std::unique_ptr<RowsetReader> create_reader();
-
- virtual NewStatus copy(RowsetBuilder* dest_rowset_builder);
-
- virtual NewStatus delete();
-
- virtual void get_meta(RowsetMetaSharedPtr rowset_meta);
-
- virtual void set_version(Version version);
-
-private:
- NewStatus _init_segment_groups();
-
-private:
- RowsetMetaSharedPtr _rowset_meta;
- std::vector<std::shared_ptr<SegmentGroup>> _segment_groups;
- int _segment_group_size;
- bool _is_cumulative_rowset;
-};
-
-}
-
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#ifndef DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_H
+#define DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_H
+
+#include "olap/rowset/rowset.h"
+#include "olap/rowset/segment_group.h"
+#include "olap/rowset/alpha_rowset_reader.h"
+#include "olap/rowset/alpha_rowset_builder.h"
+#include "olap/rowset/rowset_meta.h"
+
+#include <vector>
+#include <memory>
+
+namespace doris {
+
+class AlphaRowset : public Rowset {
+public:
+ AlphaRowset(const RowFields& tablet_schema,
+ int num_key_fields, int num_short_key_fields,
+ int num_rows_per_row_block, const std::string rowset_path,
+ RowsetMetaSharedPtr rowset_meta);
+
+ virtual NewStatus init();
+
+ virtual std::unique_ptr<RowsetReader> create_reader();
+
+ virtual NewStatus copy(RowsetBuilder* dest_rowset_builder);
+
+ virtual NewStatus remove();
+
+ virtual RowsetMetaSharedPtr get_meta();
+
+ virtual void set_version(Version version);
+
+private:
+ NewStatus _init_segment_groups();
+
+private:
+ RowFields _tablet_schema;
+ int _num_key_fields;
+ int _num_short_key_fields;
+ int _num_rows_per_row_block;
+ std::string _rowset_path;
+ RowsetMetaSharedPtr _rowset_meta;
+ std::vector<std::shared_ptr<SegmentGroup>> _segment_groups;
+ int _segment_group_size;
+ bool _is_cumulative_rowset;
+};
+
+} // namespace doris
+
#endif // DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/alpha_rowset_builder.cpp
b/be/src/olap/rowset/alpha_rowset_builder.cpp
index 383ff6e4..147799af 100644
--- a/be/src/olap/rowset/alpha_rowset_builder.cpp
+++ b/be/src/olap/rowset/alpha_rowset_builder.cpp
@@ -1,38 +1,38 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include "olap/rowset/alpha_rowset_builder.h"
-
-namespace doris {
-
-NewStatus AlphaRowsetBuilder::init(int64_t rowset_id, const std::string&
rowset_path_prefix, Schema* schema) {
- return NewStatus.OK();
-}
-
-NewStatus AlphaRowsetBuilder::add_row_block(const RowBlock& row_block) {
- return NewStatus.OK();
-}
-
-NewStatus AlphaRowsetBuilder::generate_written_path(const std::string&
src_path, std::string* dest_path) {
- return NewStatus.OK();
-}
-
-NewStatus AlphaRowsetBuilder::build(Rowset* rowset) {
- return NewStatus.OK();
-}
-
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "olap/rowset/alpha_rowset_builder.h"
+
+namespace doris {
+
+NewStatus AlphaRowsetBuilder::init(int64_t rowset_id, const std::string&
rowset_path_prefix, Schema* schema) {
+ return NewStatus::OK();
+}
+
+NewStatus AlphaRowsetBuilder::add_row_block(const RowBlock& row_block) {
+ return NewStatus::OK();
+}
+
+NewStatus AlphaRowsetBuilder::generate_written_path(const std::string&
src_path, std::string* dest_path) {
+ return NewStatus::OK();
+}
+
+NewStatus AlphaRowsetBuilder::build(Rowset* rowset) {
+ return NewStatus::OK();
+}
+
} // namespace doris
\ No newline at end of file
diff --git a/be/src/olap/rowset/alpha_rowset_builder.h
b/be/src/olap/rowset/alpha_rowset_builder.h
index 97fbe9cc..a89a3556 100644
--- a/be/src/olap/rowset/alpha_rowset_builder.h
+++ b/be/src/olap/rowset/alpha_rowset_builder.h
@@ -1,43 +1,42 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#ifndef DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_BUILDER_H
-#define DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_BUILDER_H
-
-#include "olap/rowset/rowset_builder.h"
-
-namespace doris {
-
-class AlphaRowsetBuilder {
-public:
- virtual NewStatus init(int64_t rowset_id, const std::string&
rowset_path_prefix, Schema* schema);
-
- // add a row block to rowset
- virtual NewStatus add_row_block(const RowBlock& row_block);
-
- // this is a temp api
- // it is used to get rewritten path for writing rowset data
- virtual NewStatus generate_written_path(const std::string& src_path,
std::string* dest_path);
-
- // get a rowset
- virtual NewStatus build(Rowset* rowset);
-};
-
-}
-
-#endif // DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_BUILDER_H
-
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#ifndef DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_BUILDER_H
+#define DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_BUILDER_H
+
+#include "olap/rowset/rowset_builder.h"
+
+namespace doris {
+
+class AlphaRowsetBuilder : public RowsetBuilder {
+public:
+ virtual NewStatus init(int64_t rowset_id, const std::string&
rowset_path_prefix, Schema* schema);
+
+ // add a row block to rowset
+ virtual NewStatus add_row_block(const RowBlock& row_block);
+
+ // this is a temp api
+ // it is used to get rewritten path for writing rowset data
+ virtual NewStatus generate_written_path(const std::string& src_path,
std::string* dest_path);
+
+ // get a rowset
+ virtual NewStatus build(Rowset* rowset);
+};
+
+}
+
+#endif // DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_BUILDER_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/alpha_rowset_meta.cpp
b/be/src/olap/rowset/alpha_rowset_meta.cpp
index db4daf33..dd266319 100644
--- a/be/src/olap/rowset/alpha_rowset_meta.cpp
+++ b/be/src/olap/rowset/alpha_rowset_meta.cpp
@@ -1,48 +1,45 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include "olap/rowset/alpha_rowset_meta.h"
-
-namespace doris {
-
-bool AlphaRowsetMeta::deserialize_extra_properties() {
- std::string extra_properties = _rowset_meta->extra_properties();
- bool parsed = _extra_meta_pb->ParseFromString(extra_properties);
- if (!parsed) {
- LOG(WARNING) << "alpha rowset parse extra propertis failed.";
- }
- return parsed;
-}
-
-void AlphaRowsetMeta::get_segment_groups(std::vector<SegmentGroupPB>*
segment_groups) {
- for (auto& segment_group : _extra_meta_pb.segment_groups()) {
- segment_groups->push_back(segment_group);
- }
-}
-
-void AlphaRowsetMeta::add_segment_group(SegmentGroupPB& segment_group) {
- SegmentGroupPB* new_segment_group =
_extra_meta_pb.mutable_segment_groups();
- *new_segment_group = segment_group;
-}
-
-void AlphaRowsetMeta::_serialize_extra_meta_pb() {
- std::string extra_properties;
- _extra_meta_pb->SerializeToString(&extra_properties);
- _rowset_meta->set_extra_properties(extra_properties);
-}
-
-} // namespace doris
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "olap/rowset/alpha_rowset_meta.h"
+
+namespace doris {
+
+bool AlphaRowsetMeta::deserialize_extra_properties() {
+ std::string extra_properties = get_extra_properties();
+ bool parsed = _extra_meta_pb.ParseFromString(extra_properties);
+ return parsed;
+}
+
+void AlphaRowsetMeta::get_segment_groups(std::vector<SegmentGroupPB>*
segment_groups) {
+ for (auto& segment_group : _extra_meta_pb.segment_groups()) {
+ segment_groups->push_back(segment_group);
+ }
+}
+
+void AlphaRowsetMeta::add_segment_group(const SegmentGroupPB& segment_group) {
+ SegmentGroupPB* new_segment_group = _extra_meta_pb.add_segment_groups();
+ *new_segment_group = segment_group;
+}
+
+void AlphaRowsetMeta::_serialize_extra_meta_pb() {
+ std::string extra_properties;
+ _extra_meta_pb.SerializeToString(&extra_properties);
+ set_extra_properties(extra_properties);
+}
+
+} // namespace doris
\ No newline at end of file
diff --git a/be/src/olap/rowset/alpha_rowset_meta.h
b/be/src/olap/rowset/alpha_rowset_meta.h
index 663b79ac..f69fb993 100644
--- a/be/src/olap/rowset/alpha_rowset_meta.h
+++ b/be/src/olap/rowset/alpha_rowset_meta.h
@@ -1,46 +1,48 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#ifndef DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_META_H
-#define DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_META_H
-
-#include "olap/rowset/rowset_meta.h"
-
-#include <memory>
-#include <vector>
-#include <string>
-
-namespace doris {
-
-class AlphaRowsetMeta : public RowsetMeta {
-public:
- virtual bool deserialize_extra_properties();
-
- void get_segment_groups(std::vector<SegmentGroupPB>* segment_groups)
-
- void add_segment_group(const SegmentGroupPB& segment_group);
-
-private:
- void _serialize_extra_meta_pb();
-
-private:
- AlphaRowsetExtraMetaPB _extra_meta_pb;
-};
-
-}
-
-#endif // DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_META_H
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#ifndef DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_META_H
+#define DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_META_H
+
+#include "olap/rowset/rowset_meta.h"
+
+#include <memory>
+#include <vector>
+#include <string>
+
+namespace doris {
+
+class AlphaRowsetMeta : public RowsetMeta {
+public:
+ virtual bool deserialize_extra_properties();
+
+ void get_segment_groups(std::vector<SegmentGroupPB>* segment_groups);
+
+ void add_segment_group(const SegmentGroupPB& segment_group);
+
+private:
+ void _serialize_extra_meta_pb();
+
+private:
+ AlphaRowsetExtraMetaPB _extra_meta_pb;
+};
+
+typedef std::shared_ptr<AlphaRowsetMeta> AlphaRowsetMetaSharedPtr;
+
+}
+
+#endif // DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_META_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/alpha_rowset_reader.cpp
b/be/src/olap/rowset/alpha_rowset_reader.cpp
index f6ceb93f..0b9d2ad0 100644
--- a/be/src/olap/rowset/alpha_rowset_reader.cpp
+++ b/be/src/olap/rowset/alpha_rowset_reader.cpp
@@ -1,246 +1,247 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include "olap/rowset/alpha_rowset_reader.h"
-
-namespace doris {
-
-AlphaRowsetReader::AlphaRowsetReader(const RowFields& tablet_schema,
- int num_key_fields, int num_short_key_fields,
- int num_rows_per_row_block, const std::string rowset_path,
- RowsetMeta* rowset_meta,
- std::vector<std::shared_ptr<SegmentGroup>> segment_groups) :
_tablet_schema(tablet_schema),
- _num_key_fields(num_key_fields),
- _num_short_key_fields(num_short_key_fields),
- _num_rows_per_row_block(num_rows_per_row_block),
- _rowset_path(rowset_path),
- _alpha_rowset_meta(nullptr),
- _segment_groups(segment_groups),
- _key_range_size(0),
- _key_range_index(0) {
- _alpha_rowset_meta = (AlphaRowsetMeta*)rowset_meta;
- Version version = _alpha_rowset_meta->get_version();
- if (veresion.first == version.second) {
- _is_cumulative_rowset = false;
- } else {
- _is_cumulative_rowset = true;
- }
-}
-
-NewStatus AlphaRowsetReader::init(ReaderContext* read_context) {
- NewStatus status = _init_segment_group();
- if (!status.ok()) {
- return status;
- }
- status = _init_column_data();
- return status;
-}
-
-bool AlphaRowsetReader::has_next() {
- for (auto& row_block : _row_blocks) {
- if (row_block != nullptr) {
- if (row_block.has_remaining()) {
- return true;
- }
- }
- }
- return false;
-}
-
-NewStatus AlphaRowsetReader::_get_next_block(ColumnData* column_data,
RowBlock* row_block) {
- // get next block
- OLAPStatus status = column_data->get_next_block(&row_block);
- if (status != OLAP_SUCCESS) {
- if (status == OLAP_ERR_DATA_EOF) {
- // reach the end of one predicate
- // refresh the predicate and continue read
- NewStatus status = _refresh_next_block(column_data, row_block);
- if (!status.ok()) {
- LOG(WARNING) << "refresh next block failed";
- return status;
- }
- return NewStatus::OK();
- }
- return NewStatus::Corruption("get next block failed");
- }
-}
-
-NewStatus AlphaRowsetReader::_get_next_row_for_singleton_rowset(RowCursor*
row) {
- RowCursor* min_row = nullptr;
- int min_index = -1;
- for (int i = 0; i < _row_blocks.size(); i++) {
- RowCursor* current_row = nullptr;
- RowBlock* current_row_block = _row_blocks[i];
- size_t pos = current_row_block->pos();
- current_row_block->get_row(pos, &row);
- if (min_row == nullptr || min_row->cmp(*current_row) < 0) {
- min_row = current_row;
- min_index = i;
- }
- }
- if (min_row == nullptr || min_index == -1) {
- return NewStatus::Corruption("get next row failed");
- }
- row = min_row;
- RowBlock* row_block = _row_blocks[min_index];
- ColumnData* column_data = _column_datas[min_index];
- row_block->pos_inc();
- if (!row_block->has_remaining()) {
- NewStatus status = _get_next_block(column_data, row_block);
- if (!status.ok()) {
- return status;
- }
- }
- return NewStatus::OK();
-}
-
-NewStatus AlphaRowsetReader::_get_next_row_for_cumulative_rowset(RowCursor*
row) {
- RowBlock* current_row_block = _row_blocks[0];
- size_t pos = current_row_block->pos();
- current_row_block->get_row(pos, &row);
- current_row_block->pos_inc();
- if (!current_row_block.has_remaining()) {
- NewStatus status = _get_next_block(_column_datas[0],
current_row_block);
- if (!status.ok()) {
- return status;
- }
- }
- return NewStatus::OK();
-}
-
-NewStatus AlphaRowsetReader::next(RowCursor* row) {
- if (_is_cumulative_rowset) {
- return _get_next_row_for_cumulative_rowset(row);
- } else {
- return _get_next_row_for_singleton_rowset(row);
- }
-}
-
-void AlphaRowsetReader::close() {
- _column_datas.clear();
-}
-
-NewStatus AlphaRowsetReader::_init_column_datas(ReaderContext* read_context) {
- for (auto& segment_group : _segment_groups) {
- std::unique_ptr<ColumnData> new_column_data(new
std::unique_ptr<ColumnData>(
- ColumnData::create(segment_group.get())));
- OLAPStatus status = new_column_data->init();
- if (status != OLAP_SUCCESS) {
- return NewStatus::Corruption("init column data failed");
- }
- new_column_data->set_delete_handler(read_context->delete_handler);
- std::vector<ColumnPredicate*> col_predicates;
- for (auto& column_predicate : predicates) {
- col_predicates.push_back(&column_predicate.second);
- }
- if (read_context->lower_bound_keys.size() !=
read_context->is_lower_keys_included.size()
- || read_context->lower_bound_keys.size() !=
read_context->upper_bound_keys.size()
- || read_context->upper_bound_keys.size() !=
read_context->is_upper_keys_included.size()) {
- std::string error_msg = "invalid key range arguments";
- LOG(WARNING) << error_msg;
- retun NewStatus.InvalidArgument(error_msg);
- }
- new_column_data->set_read_params(read_context->return_columns,
- read_context->load_bf_columns,
- read_context->conditions,
- col_predicates,
- read_context->lower_bound_keys,
- read_context->upper_bound_keys,
- read_context->is_using_cache,
- read_params->runtime_state);
- // filter column data
- if (i_data->delta_pruning_filter()) {
- VLOG(3) << "filter delta in query in condition:"
- << i_data->version().first << ", " <<
i_data->version().second;
- //_stats.rows_stats_filtered += i_data->num_rows();
- continue;
- }
- int ret = i_data->delete_pruning_filter();
- if (ret == DEL_SATISFIED) {
- VLOG(3) << "filter delta in delete predicate:"
- << i_data->version().first << ", " <<
i_data->version().second;
- //_stats.rows_del_filtered += i_data->num_rows();
- continue;
- } else if (ret == DEL_PARTIAL_SATISFIED) {
- VLOG(3) << "filter delta partially in delete predicate:"
- << i_data->version().first << ", " <<
i_data->version().second;
- i_data->set_delete_status(DEL_PARTIAL_SATISFIED);
- } else {
- VLOG(3) << "not filter delta in delete predicate:"
- << i_data->version().first << ", " <<
i_data->version().second;
- i_data->set_delete_status(DEL_NOT_SATISFIED);
- }
- _column_datas.emplace_back(std::move(new_column_data));
- _key_range_size = read_context->lower_bound_keys.size();
- RowBlock* row_block = nullptr;
- if (_key_range_size > 0) {
- status =
new_column_data->prepare_block_read(read_context->lower_bound_keys[_key_range_index],
- read_context->is_lower_keys_included[_key_range_index],
- read_context->upper_bound_keys[_key_range_index],
- read_context->is_upper_keys_included[_key_range_index],
- &row_block);
- if (status != OLAP_SUCCESS) {
- LOG(WARNING) << "prepare block read failed";
- return NewStatus::Corruption("prepare block read failed");
- }
- _key_range_index++;
- } else {
- status = new_column_data->get_first_row_block(&row_block);
- if (status != OLAP_SUCCESS) {
- LOG(WARNING) << "get first row block failed";
- return NewStatus::Corruption("get first row block failed");
- }
- }
- _row_blocks.push_back(row_block);
- }
- if (_is_cumulative_rowset && _column_datas.size() > 1) {
- LOG(WARNING) << "invalid column_datas for cumulative rowset.
column_datas size:"
- << _column_datas.size();
- return NewStatus::InvalidArgument("invalid _column_datas size:" +
std::to_string(_column_datas.size());
- }
- return NewStatus::OK();
-}
-
-NewStatus AlphaRowsetReader::_refresh_next_block(ColumnData* column_data,
RowBlock* next_block) {
- OLAPStatus status = column_data->get_next_block(&next_block);
- if (status == OLAP_ERR_DATA_EOF) {
- // currently, SegmentReader can only support filter one key range a
time
- // use the next predicate range to get data from segment here
- if (_key_range_size > 0 && _key_range_index < _key_range_size) {
- status =
column_data->prepare_block_read(read_context->lower_bound_keys[_key_range_index],
- read_context->is_lower_keys_included[_key_range_index],
- read_context->upper_bound_keys[_key_range_index],
- read_context->is_upper_keys_included[_key_range_index],
- &next_block);
- if (status != OLAP_SUCCESS) {
- LOG(WARNING) << "prepare block read failed";
- return NewStatus::Corruption("prepare block read failed");
- }
- _key_range_index++;
- } else {
- // read finished
- next_block = nullptr;
- }
- return NewStatus::OK();
- } else if (status != OLAP_SUCCESS) {
- return NewStatus::Corruption("get next block failed");
- } else {
- return NewStatus::OK();
- }
-}
-
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "olap/rowset/alpha_rowset_reader.h"
+
+namespace doris {
+
+AlphaRowsetReader::AlphaRowsetReader(const RowFields& tablet_schema,
+ int num_key_fields, int num_short_key_fields,
+ int num_rows_per_row_block, const std::string rowset_path,
+ RowsetMeta* rowset_meta,
+ std::vector<std::shared_ptr<SegmentGroup>> segment_groups) :
_tablet_schema(tablet_schema),
+ _num_key_fields(num_key_fields),
+ _num_short_key_fields(num_short_key_fields),
+ _num_rows_per_row_block(num_rows_per_row_block),
+ _rowset_path(rowset_path),
+ _alpha_rowset_meta(nullptr),
+ _segment_groups(segment_groups),
+ _key_range_size(0),
+ _key_range_index(0) {
+ _alpha_rowset_meta = (AlphaRowsetMeta*)rowset_meta;
+ Version version = _alpha_rowset_meta->get_version();
+ if (version.first == version.second) {
+ _is_cumulative_rowset = false;
+ } else {
+ _is_cumulative_rowset = true;
+ }
+}
+
+NewStatus AlphaRowsetReader::init(ReaderContext* read_context) {
+ _current_read_context = read_context;
+ NewStatus status = _init_segment_groups(read_context);
+ if (!status.ok()) {
+ return status;
+ }
+ status = _init_column_datas(read_context);
+ return status;
+}
+
+bool AlphaRowsetReader::has_next() {
+ for (auto& row_block : _row_blocks) {
+ if (row_block != nullptr) {
+ if (row_block->has_remaining()) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+NewStatus AlphaRowsetReader::_get_next_block(ColumnData* column_data,
RowBlock* row_block) {
+ // get next block
+ OLAPStatus status = column_data->get_next_block(&row_block);
+ if (status != OLAP_SUCCESS) {
+ if (status == OLAP_ERR_DATA_EOF) {
+ // reach the end of one predicate
+ // refresh the predicate and continue read
+ NewStatus status = _refresh_next_block(column_data, row_block);
+ if (!status.ok()) {
+ LOG(WARNING) << "refresh next block failed";
+ return status;
+ }
+ return NewStatus::OK();
+ }
+ return NewStatus::Corruption("get next block failed");
+ }
+ return NewStatus::OK();
+}
+
+NewStatus AlphaRowsetReader::_get_next_row_for_singleton_rowset(RowCursor*
row) {
+ RowCursor* min_row = nullptr;
+ int min_index = -1;
+ for (int i = 0; i < _row_blocks.size(); i++) {
+ RowCursor* current_row = nullptr;
+ RowBlock* current_row_block = _row_blocks[i];
+ size_t pos = current_row_block->pos();
+ current_row_block->get_row(pos, row);
+ if (min_row == nullptr || min_row->cmp(*current_row) < 0) {
+ min_row = current_row;
+ min_index = i;
+ }
+ }
+ if (min_row == nullptr || min_index == -1) {
+ return NewStatus::Corruption("get next row failed");
+ }
+ row = min_row;
+ RowBlock* row_block = _row_blocks[min_index];
+ ColumnData* column_data = _column_datas[min_index].get();
+ row_block->pos_inc();
+ if (!row_block->has_remaining()) {
+ NewStatus status = _get_next_block(column_data, row_block);
+ if (!status.ok()) {
+ return status;
+ }
+ }
+ return NewStatus::OK();
+}
+
+NewStatus AlphaRowsetReader::_get_next_row_for_cumulative_rowset(RowCursor*
row) {
+ RowBlock* current_row_block = _row_blocks[0];
+ size_t pos = current_row_block->pos();
+ current_row_block->get_row(pos, row);
+ current_row_block->pos_inc();
+ if (!current_row_block->has_remaining()) {
+ NewStatus status = _get_next_block(_column_datas[0].get(),
current_row_block);
+ if (!status.ok()) {
+ return status;
+ }
+ }
+ return NewStatus::OK();
+}
+
+NewStatus AlphaRowsetReader::next(RowCursor* row) {
+ if (_is_cumulative_rowset) {
+ return _get_next_row_for_cumulative_rowset(row);
+ } else {
+ return _get_next_row_for_singleton_rowset(row);
+ }
+}
+
+void AlphaRowsetReader::close() {
+ _column_datas.clear();
+}
+
+NewStatus AlphaRowsetReader::_init_column_datas(ReaderContext* read_context) {
+ for (auto& segment_group : _segment_groups) {
+ std::unique_ptr<ColumnData>
new_column_data(ColumnData::create(segment_group.get()));
+ OLAPStatus status = new_column_data->init();
+ if (status != OLAP_SUCCESS) {
+ return NewStatus::Corruption("init column data failed");
+ }
+ new_column_data->set_delete_handler(read_context->delete_handler);
+ new_column_data->set_stats(read_context->stats);
+ new_column_data->set_lru_cache(read_context->lru_cache);
+ std::vector<ColumnPredicate*> col_predicates;
+ for (auto& column_predicate : read_context->predicates) {
+ col_predicates.push_back(&column_predicate.second);
+ }
+ if (read_context->lower_bound_keys.size() !=
read_context->is_lower_keys_included.size()
+ || read_context->lower_bound_keys.size() !=
read_context->upper_bound_keys.size()
+ || read_context->upper_bound_keys.size() !=
read_context->is_upper_keys_included.size()) {
+ std::string error_msg = "invalid key range arguments";
+ LOG(WARNING) << error_msg;
+ return NewStatus::InvalidArgument(error_msg);
+ }
+ new_column_data->set_read_params(read_context->return_columns,
+ read_context->load_bf_columns,
+ read_context->conditions,
+ col_predicates,
+ read_context->lower_bound_keys,
+ read_context->upper_bound_keys,
+ read_context->is_using_cache,
+ read_context->runtime_state);
+ // filter column data
+ if (new_column_data->delta_pruning_filter()) {
+ VLOG(3) << "filter delta in query in condition:"
+ << new_column_data->version().first << ", " <<
new_column_data->version().second;
+ continue;
+ }
+ int ret = new_column_data->delete_pruning_filter();
+ if (ret == DEL_SATISFIED) {
+ VLOG(3) << "filter delta in delete predicate:"
+ << new_column_data->version().first << ", " <<
new_column_data->version().second;
+ continue;
+ } else if (ret == DEL_PARTIAL_SATISFIED) {
+ VLOG(3) << "filter delta partially in delete predicate:"
+ << new_column_data->version().first << ", " <<
new_column_data->version().second;
+ new_column_data->set_delete_status(DEL_PARTIAL_SATISFIED);
+ } else {
+ VLOG(3) << "not filter delta in delete predicate:"
+ << new_column_data->version().first << ", " <<
new_column_data->version().second;
+ new_column_data->set_delete_status(DEL_NOT_SATISFIED);
+ }
+ _column_datas.emplace_back(std::move(new_column_data));
+ _key_range_size = read_context->lower_bound_keys.size();
+ RowBlock* row_block = nullptr;
+ if (_key_range_size > 0) {
+ status =
new_column_data->prepare_block_read(read_context->lower_bound_keys[_key_range_index],
+ read_context->is_lower_keys_included[_key_range_index],
+ read_context->upper_bound_keys[_key_range_index],
+ read_context->is_upper_keys_included[_key_range_index],
+ &row_block);
+ if (status != OLAP_SUCCESS) {
+ LOG(WARNING) << "prepare block read failed";
+ return NewStatus::Corruption("prepare block read failed");
+ }
+ _key_range_index++;
+ } else {
+ status = new_column_data->get_first_row_block(&row_block);
+ if (status != OLAP_SUCCESS) {
+ LOG(WARNING) << "get first row block failed";
+ return NewStatus::Corruption("get first row block failed");
+ }
+ }
+ _row_blocks.push_back(row_block);
+ }
+ if (_is_cumulative_rowset && _column_datas.size() > 1) {
+ LOG(WARNING) << "invalid column_datas for cumulative rowset.
column_datas size:"
+ << _column_datas.size();
+ return NewStatus::InvalidArgument("invalid _column_datas size:" +
std::to_string(_column_datas.size()));
+ }
+ return NewStatus::OK();
+}
+
+NewStatus AlphaRowsetReader::_refresh_next_block(ColumnData* column_data,
RowBlock* next_block) {
+ OLAPStatus status = column_data->get_next_block(&next_block);
+ if (status == OLAP_ERR_DATA_EOF) {
+ // currently, SegmentReader can only support filter one key range a
time
+ // use the next predicate range to get data from segment here
+ if (_key_range_size > 0 && _key_range_index < _key_range_size) {
+ status =
column_data->prepare_block_read(_current_read_context->lower_bound_keys[_key_range_index],
+
_current_read_context->is_lower_keys_included[_key_range_index],
+ _current_read_context->upper_bound_keys[_key_range_index],
+
_current_read_context->is_upper_keys_included[_key_range_index],
+ &next_block);
+ if (status != OLAP_SUCCESS) {
+ LOG(WARNING) << "prepare block read failed";
+ return NewStatus::Corruption("prepare block read failed");
+ }
+ _key_range_index++;
+ } else {
+ // read finished
+ next_block = nullptr;
+ }
+ return NewStatus::OK();
+ } else if (status != OLAP_SUCCESS) {
+ return NewStatus::Corruption("get next block failed");
+ } else {
+ return NewStatus::OK();
+ }
+}
+
} // namespace doris
\ No newline at end of file
diff --git a/be/src/olap/rowset/alpha_rowset_reader.h
b/be/src/olap/rowset/alpha_rowset_reader.h
index 73dc75c0..fc1ec556 100644
--- a/be/src/olap/rowset/alpha_rowset_reader.h
+++ b/be/src/olap/rowset/alpha_rowset_reader.h
@@ -17,16 +17,17 @@
#ifndef DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_READER_H
#define DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_READER_H
-P
+
#include "olap/rowset/rowset_reader.h"
#include "olap/rowset/segment_group.h"
#include "olap/rowset/column_data.h"
+#include "olap/rowset/alpha_rowset_meta.h"
#include <vector>
namespace doris {
-class AlphaRowsetReader {
+class AlphaRowsetReader : public RowsetReader {
public:
AlphaRowsetReader(const RowFields& tablet_schema,
int num_key_fields, int num_short_key_fields,
@@ -50,9 +51,9 @@ class AlphaRowsetReader {
NewStatus _init_column_datas(ReaderContext* read_context);
- NewStatus _get_next_row_for_singleton_rowset(RowCursor row);
+ NewStatus _get_next_row_for_singleton_rowset(RowCursor* row);
- NewStatus _get_next_row_for_cumulative_rowset(RowCursor row);
+ NewStatus _get_next_row_for_cumulative_rowset(RowCursor* row);
NewStatus _get_next_block(ColumnData* column_data, RowBlock* row_block);
@@ -60,19 +61,20 @@ class AlphaRowsetReader {
private:
RowFields _tablet_schema;
- int num_key_fields;
- int num_short_key_fields;
- int num_rows_per_row_block;
+ int _num_key_fields;
+ int _num_short_key_fields;
+ int _num_rows_per_row_block;
std::string _rowset_path;
AlphaRowsetMeta* _alpha_rowset_meta;
- std::vector<std::shared_ptr<SegmentGroup>> _segment_groups
+ std::vector<std::shared_ptr<SegmentGroup>> _segment_groups;
std::vector<std::unique_ptr<ColumnData>> _column_datas;
std::vector<RowBlock*> _row_blocks;
int _key_range_size;
int _key_range_index;
bool _is_cumulative_rowset;
+ ReaderContext* _current_read_context;
};
}
-#endif // DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_READER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_READER_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/bit_field_reader.cpp
b/be/src/olap/rowset/bit_field_reader.cpp
index ca3ffcff..2042d37b 100644
--- a/be/src/olap/rowset/bit_field_reader.cpp
+++ b/be/src/olap/rowset/bit_field_reader.cpp
@@ -127,5 +127,4 @@ OLAPStatus BitFieldReader::skip(uint64_t num_values) {
return OLAP_SUCCESS;
}
-} // namespace doris
-
+} // namespace doris
\ No newline at end of file
diff --git a/be/src/olap/rowset/bit_field_reader.h
b/be/src/olap/rowset/bit_field_reader.h
index 349fdc47..e1fd5a4f 100644
--- a/be/src/olap/rowset/bit_field_reader.h
+++ b/be/src/olap/rowset/bit_field_reader.h
@@ -50,4 +50,4 @@ class BitFieldReader {
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_ROWSET_BIT_FIELD_READER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_BIT_FIELD_READER_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/bit_field_writer.cpp
b/be/src/olap/rowset/bit_field_writer.cpp
index 54111438..424c560d 100644
--- a/be/src/olap/rowset/bit_field_writer.cpp
+++ b/be/src/olap/rowset/bit_field_writer.cpp
@@ -99,4 +99,4 @@ void BitFieldWriter::get_position(PositionEntryWriter*
index_entry) const {
index_entry->add_position(8 - _bits_left);
}
-} // namespace doris
+} // namespace doris
\ No newline at end of file
diff --git a/be/src/olap/rowset/bit_field_writer.h
b/be/src/olap/rowset/bit_field_writer.h
index 7348072f..4c8dacbd 100644
--- a/be/src/olap/rowset/bit_field_writer.h
+++ b/be/src/olap/rowset/bit_field_writer.h
@@ -48,4 +48,4 @@ class BitFieldWriter {
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_ROWSET_BIT_FIELD_WRITER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_BIT_FIELD_WRITER_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/column_data.cpp
b/be/src/olap/rowset/column_data.cpp
index 95a853bc..e27707a3 100644
--- a/be/src/olap/rowset/column_data.cpp
+++ b/be/src/olap/rowset/column_data.cpp
@@ -19,24 +19,12 @@
#include "olap/rowset/segment_reader.h"
#include "olap/olap_cond.h"
-#include "olap/tablet.h"
#include "olap/row_block.h"
namespace doris {
ColumnData* ColumnData::create(SegmentGroup* segment_group) {
- ColumnData* data = NULL;
- DataFileType file_type = segment_group->tablet()->data_file_type();
-
- switch (file_type) {
- case COLUMN_ORIENTED_FILE:
- data = new(std::nothrow) ColumnData(segment_group);
- break;
-
- default:
- LOG(WARNING) << "unknown data file type. type=" <<
DataFileType_Name(file_type).c_str();
- }
-
+ ColumnData* data = new(std::nothrow) ColumnData(segment_group);
return data;
}
@@ -50,8 +38,7 @@ ColumnData::ColumnData(SegmentGroup* segment_group)
_runtime_state(NULL),
_is_using_cache(false),
_segment_reader(NULL) {
- _tablet = segment_group->tablet();
- _num_rows_per_block = _tablet->num_rows_per_row_block();
+ _num_rows_per_block = _segment_group->get_num_rows_per_row_block();
}
ColumnData::~ColumnData() {
@@ -64,8 +51,7 @@ OLAPStatus ColumnData::init() {
auto res = _short_key_cursor.init(_segment_group->short_key_fields());
if (res != OLAP_SUCCESS) {
- LOG(WARNING) << "key cursor init failed, tablet:" <<
_tablet->tablet_id()
- << ", res:" << res;
+ LOG(WARNING) << "key cursor init failed, res:" << res;
return res;
}
return res;
@@ -137,11 +123,11 @@ OLAPStatus ColumnData::_seek_to_block(const
RowBlockPosition& block_pos, bool wi
}
SAFE_DELETE(_segment_reader);
std::string file_name;
- file_name =
segment_group()->construct_data_file_path(segment_group()->segment_group_id(),
block_pos.segment);
+ file_name =
segment_group()->construct_data_file_path(block_pos.segment);
_segment_reader = new(std::nothrow) SegmentReader(
- file_name, _tablet, segment_group(), block_pos.segment,
+ file_name, segment_group(), block_pos.segment,
_seek_columns, _load_bf_columns, _conditions,
- _col_predicates, _delete_handler, _delete_status,
_runtime_state, _stats);
+ _col_predicates, _delete_handler, _delete_status,
_runtime_state, _stats, _lru_cache);
if (_segment_reader == nullptr) {
OLAP_LOG_WARNING("fail to malloc segment reader.");
return OLAP_ERR_MALLOC_ERROR;
@@ -285,8 +271,9 @@ OLAPStatus ColumnData::_find_position_by_full_key(
OLAPStatus ColumnData::_seek_to_row(const RowCursor& key, bool find_last_key,
bool is_end_key) {
RowBlockPosition position;
OLAPStatus res = OLAP_SUCCESS;
- FieldType type = _tablet->get_field_type_by_index(key.field_count() - 1);
- if (key.field_count() > _tablet->num_short_key_fields() ||
OLAP_FIELD_TYPE_VARCHAR == type) {
+ const RowFields& tablet_schema = _segment_group->get_tablet_schema();
+ FieldType type = tablet_schema[key.field_count() - 1].type;
+ if (key.field_count() > _segment_group->get_num_short_key_fields() ||
OLAP_FIELD_TYPE_VARCHAR == type) {
res = _find_position_by_full_key(key, find_last_key, &position);
} else {
res = _find_position_by_short_key(key, find_last_key, &position);
@@ -455,24 +442,24 @@ void ColumnData::set_read_params(
}
}
- for (uint32_t i = 0; i < _tablet->tablet_schema().size(); i++) {
+ for (uint32_t i = 0; i < _segment_group->get_tablet_schema().size(); i++) {
if (i < max_key_column_count || column_set.find(i) !=
column_set.end()) {
_seek_columns.push_back(i);
}
}
- auto res = _cursor.init(_tablet->tablet_schema());
+ auto res = _cursor.init(_segment_group->get_tablet_schema());
if (res != OLAP_SUCCESS) {
OLAP_LOG_WARNING("fail to init row_cursor");
}
_read_vector_batch.reset(new VectorizedRowBatch(
- _tablet->tablet_schema(), _return_columns, _num_rows_per_block));
+ _segment_group->get_tablet_schema(), _return_columns,
_num_rows_per_block));
_seek_vector_batch.reset(new VectorizedRowBatch(
- _tablet->tablet_schema(), _seek_columns, _num_rows_per_block));
+ _segment_group->get_tablet_schema(), _seek_columns,
_num_rows_per_block));
- _read_block.reset(new RowBlock(_tablet->tablet_schema()));
+ _read_block.reset(new RowBlock(_segment_group->get_tablet_schema()));
RowBlockInfo block_info;
block_info.row_num = _num_rows_per_block;
block_info.null_supported = true;
@@ -610,21 +597,21 @@ uint64_t ColumnData::get_filted_rows() {
OLAPStatus ColumnData::_schema_change_init() {
_is_using_cache = false;
- for (int i = 0; i < _tablet->tablet_schema().size(); ++i) {
+ for (int i = 0; i < _segment_group->get_tablet_schema().size(); ++i) {
_return_columns.push_back(i);
_seek_columns.push_back(i);
}
- auto res = _cursor.init(_tablet->tablet_schema());
+ auto res = _cursor.init(_segment_group->get_tablet_schema());
if (res != OLAP_SUCCESS) {
OLAP_LOG_WARNING("fail to init row_cursor");
return res;
}
_read_vector_batch.reset(new VectorizedRowBatch(
- _tablet->tablet_schema(), _return_columns, _num_rows_per_block));
+ _segment_group->get_tablet_schema(), _return_columns,
_num_rows_per_block));
- _read_block.reset(new RowBlock(_tablet->tablet_schema()));
+ _read_block.reset(new RowBlock(_segment_group->get_tablet_schema()));
RowBlockInfo block_info;
block_info.row_num = _num_rows_per_block;
@@ -717,4 +704,4 @@ OLAPStatus ColumnData::_get_block(bool without_filter) {
return OLAP_SUCCESS;
}
-} // namespace doris
+} // namespace doris
\ No newline at end of file
diff --git a/be/src/olap/rowset/column_data.h b/be/src/olap/rowset/column_data.h
index 7ebe6dab..453d7a10 100644
--- a/be/src/olap/rowset/column_data.h
+++ b/be/src/olap/rowset/column_data.h
@@ -89,6 +89,9 @@ class ColumnData {
// Only used to binary search in full-key find row
const RowCursor* seek_and_get_current_row(const RowBlockPosition&
position);
+ void set_lru_cache(Cache* lru_cache) {
+ _lru_cache = lru_cache;
+ }
void set_stats(OlapReaderStatistics* stats) {
_stats = stats;
@@ -202,6 +205,7 @@ class ColumnData {
int64_t _end_row_index = 0;
size_t _num_rows_per_block;
+ Cache* _lru_cache;
};
class ColumnDataComparator {
@@ -256,4 +260,4 @@ class ColumnDataComparator {
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_ROWSET_COLUMN_DATA_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_COLUMN_DATA_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/data_writer.cpp
b/be/src/olap/rowset/column_data_writer.cpp
similarity index 82%
rename from be/src/olap/rowset/data_writer.cpp
rename to be/src/olap/rowset/column_data_writer.cpp
index 04232ebc..9a09e154 100644
--- a/be/src/olap/rowset/data_writer.cpp
+++ b/be/src/olap/rowset/column_data_writer.cpp
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-#include "olap/rowset/data_writer.h"
+#include "olap/rowset/column_data_writer.h"
#include <math.h>
@@ -26,27 +26,23 @@
namespace doris {
-ColumnDataWriter* ColumnDataWriter::create(TabletSharedPtr tablet,
SegmentGroup* segment_group, bool is_push_write) {
- ColumnDataWriter* writer = NULL;
- switch (tablet->data_file_type()) {
- case COLUMN_ORIENTED_FILE:
- writer = new (std::nothrow) ColumnDataWriter(tablet, segment_group,
is_push_write);
- break;
- default:
- LOG(WARNING) << "unknown data file type. type=" <<
DataFileType_Name(tablet->data_file_type());
- break;
- }
-
+ColumnDataWriter* ColumnDataWriter::create(SegmentGroup* segment_group, bool
is_push_write,
+ CompressKind compress_kind, double bloom_filter_fpp) {
+ ColumnDataWriter* writer = new (std::nothrow)
ColumnDataWriter(segment_group, is_push_write,
+ compress_kind, bloom_filter_fpp);
return writer;
}
-ColumnDataWriter::ColumnDataWriter(TabletSharedPtr tablet, SegmentGroup*
segment_group, bool is_push_write)
- : _is_push_write(is_push_write),
- _tablet(tablet),
- _column_statistics(_tablet->num_key_fields(),
+ColumnDataWriter::ColumnDataWriter(SegmentGroup* segment_group,
+ bool is_push_write, CompressKind compress_kind,
+ double bloom_filter_fpp)
+ : _segment_group(segment_group),
+ _is_push_write(is_push_write),
+ _compress_kind(compress_kind),
+ _bloom_filter_fpp(bloom_filter_fpp),
+ _column_statistics(segment_group->get_num_key_fields(),
std::pair<WrapperField*, WrapperField*>(NULL, NULL)),
_row_index(0),
- _segment_group(segment_group),
_row_block(NULL),
_segment_writer(NULL),
_num_rows(0),
@@ -72,36 +68,36 @@ OLAPStatus ColumnDataWriter::init() {
OLAPStatus res = OLAP_SUCCESS;
for (size_t i = 0; i < _column_statistics.size(); ++i) {
- _column_statistics[i].first =
WrapperField::create(_tablet->tablet_schema()[i]);
+ _column_statistics[i].first =
WrapperField::create(_segment_group->get_tablet_schema()[i]);
DCHECK(_column_statistics[i].first != nullptr) << "fail to create
column statistics field.";
_column_statistics[i].first->set_to_max();
- _column_statistics[i].second =
WrapperField::create(_tablet->tablet_schema()[i]);
+ _column_statistics[i].second =
WrapperField::create(_segment_group->get_tablet_schema()[i]);
DCHECK(_column_statistics[i].second != nullptr) << "fail to create
column statistics field.";
_column_statistics[i].second->set_null();
_column_statistics[i].second->set_to_min();
}
- double size = static_cast<double>(_tablet->segment_size());
+ double size = static_cast<double>(_segment_group->num_segments());
size *= OLAP_COLUMN_FILE_SEGMENT_SIZE_SCALE;
_max_segment_size = static_cast<uint32_t>(lround(size));
- _row_block = new(std::nothrow) RowBlock(_tablet->tablet_schema());
+ _row_block = new(std::nothrow)
RowBlock(_segment_group->get_tablet_schema());
if (NULL == _row_block) {
- LOG(WARNING) << "fail to new RowBlock. [tablet='" <<
_tablet->full_name() << "']";
+ LOG(WARNING) << "fail to new RowBlock.";
return OLAP_ERR_MALLOC_ERROR;
}
- res = _cursor.init(_tablet->tablet_schema());
+ res = _cursor.init(_segment_group->get_tablet_schema());
if (OLAP_SUCCESS != res) {
OLAP_LOG_WARNING("fail to initiate row cursor. [res=%d]", res);
return res;
}
- VLOG(3) << "init ColumnData writer. [tablet='" << _tablet->full_name()
- << "' block_row_size=" << _tablet->num_rows_per_row_block() << "]";
- RowBlockInfo block_info(0U, _tablet->num_rows_per_row_block(), 0);
+ VLOG(3) << "init ColumnData writer. [segment group id='" <<
_segment_group->segment_group_id()
+ << "' block_row_size=" <<
_segment_group->get_num_rows_per_row_block() << "]";
+ RowBlockInfo block_info(0U, _segment_group->get_num_rows_per_row_block(),
0);
block_info.data_file_type = DataFileType::COLUMN_ORIENTED_FILE;
block_info.null_supported = true;
@@ -131,7 +127,7 @@ OLAPStatus ColumnDataWriter::_init_segment() {
}
OLAPStatus ColumnDataWriter::attached_by(RowCursor* row_cursor) {
- if (_row_index >= _tablet->num_rows_per_row_block()) {
+ if (_row_index >= _segment_group->get_num_rows_per_row_block()) {
if (OLAP_SUCCESS != _flush_row_block(false)) {
OLAP_LOG_WARNING("failed to flush data while attaching row
cursor.");
return OLAP_ERR_OTHER_ERROR;
@@ -143,7 +139,7 @@ OLAPStatus ColumnDataWriter::attached_by(RowCursor*
row_cursor) {
}
OLAPStatus ColumnDataWriter::write(const char* row) {
- if (_row_index >= _tablet->num_rows_per_row_block()) {
+ if (_row_index >= _segment_group->get_num_rows_per_row_block()) {
if (OLAP_SUCCESS != _flush_row_block(false)) {
OLAP_LOG_WARNING("failed to flush data while attaching row
cursor.");
return OLAP_ERR_OTHER_ERROR;
@@ -156,7 +152,7 @@ OLAPStatus ColumnDataWriter::write(const char* row) {
void ColumnDataWriter::next(const RowCursor& row_cursor) {
- for (size_t i = 0; i < _tablet->num_key_fields(); ++i) {
+ for (size_t i = 0; i < _segment_group->get_num_key_fields(); ++i) {
char* right =
row_cursor.get_field_by_index(i)->get_field_ptr(row_cursor.get_buf());
if (_column_statistics[i].first->cmp(right) > 0) {
_column_statistics[i].first->copy(right);
@@ -171,7 +167,7 @@ void ColumnDataWriter::next(const RowCursor& row_cursor) {
}
void ColumnDataWriter::next(const char* row, const Schema* schema) {
- for (size_t i = 0; i < _tablet->num_key_fields(); ++i) {
+ for (size_t i = 0; i < _segment_group->get_num_key_fields(); ++i) {
char* right = const_cast<char*>(row + schema->get_col_offset(i));
if (_column_statistics[i].first->cmp(right) > 0) {
_column_statistics[i].first->copy(right);
@@ -256,9 +252,9 @@ OLAPStatus ColumnDataWriter::_add_segment() {
return OLAP_ERR_WRITER_SEGMENT_NOT_FINALIZED;
}
- file_name =
_segment_group->construct_data_file_path(_segment_group->segment_group_id(),
_segment);
- _segment_writer = new(std::nothrow) SegmentWriter(file_name, _tablet,
- OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE);
+ file_name = _segment_group->construct_data_file_path(_segment);
+ _segment_writer = new(std::nothrow) SegmentWriter(file_name,
_segment_group,
+ OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, _compress_kind,
_bloom_filter_fpp);
if (NULL == _segment_writer) {
OLAP_LOG_WARNING("fail to allocate SegmentWriter");
@@ -327,5 +323,8 @@ MemPool* ColumnDataWriter::mem_pool() {
return _row_block->mem_pool();
}
-} // namespace doris
+CompressKind ColumnDataWriter::compress_kind() {
+ return _compress_kind;
+}
+} // namespace doris
\ No newline at end of file
diff --git a/be/src/olap/rowset/data_writer.h
b/be/src/olap/rowset/column_data_writer.h
similarity index 77%
rename from be/src/olap/rowset/data_writer.h
rename to be/src/olap/rowset/column_data_writer.h
index afe0178e..ca8e5cca 100644
--- a/be/src/olap/rowset/data_writer.h
+++ b/be/src/olap/rowset/column_data_writer.h
@@ -15,13 +15,14 @@
// specific language governing permissions and limitations
// under the License.
-#ifndef DORIS_BE_SRC_OLAP_ROWSET_DATA_WRITER_H
-#define DORIS_BE_SRC_OLAP_ROWSET_DATA_WRITER_H
+#ifndef DORIS_BE_SRC_OLAP_ROWSET_COLUMN_DATA_WRITER_H
+#define DORIS_BE_SRC_OLAP_ROWSET_COLUMN_DATA_WRITER_H
-#include "olap/tablet.h"
+#include "olap/rowset/segment_group.h"
#include "olap/row_block.h"
#include "olap/schema.h"
#include "olap/wrapper_field.h"
+#include "gen_cpp/olap_common.pb.h"
namespace doris {
class RowBlock;
@@ -31,8 +32,10 @@ class ColumnDataWriter {
public:
// Factory function
// 调用者获得新建的对象, 并负责delete释放
- static ColumnDataWriter* create(TabletSharedPtr tablet, SegmentGroup*
segment_group, bool is_push_write);
- ColumnDataWriter(TabletSharedPtr tablet, SegmentGroup* segment_group, bool
is_push_write);
+ static ColumnDataWriter* create(SegmentGroup* segment_group, bool
is_push_write,
+ CompressKind compress_kind, double bloom_filter_fpp);
+ ColumnDataWriter(SegmentGroup* segment_group, bool is_push_write,
+ CompressKind compress_kind, double bloom_filter_fpp);
~ColumnDataWriter();
OLAPStatus init();
OLAPStatus attached_by(RowCursor* row_cursor);
@@ -42,6 +45,8 @@ class ColumnDataWriter {
OLAPStatus finalize();
uint64_t written_bytes();
MemPool* mem_pool();
+ CompressKind compress_kind();
+
private:
OLAPStatus _add_segment();
OLAPStatus _flush_segment_with_verfication();
@@ -49,13 +54,15 @@ class ColumnDataWriter {
OLAPStatus _flush_row_block(bool finalize);
OLAPStatus _init_segment();
+private:
+ SegmentGroup* _segment_group;
bool _is_push_write;
- TabletSharedPtr _tablet;
+ CompressKind _compress_kind;
+ double _bloom_filter_fpp;
// first is min, second is max
std::vector<std::pair<WrapperField*, WrapperField*>> _column_statistics;
uint32_t _row_index;
- SegmentGroup* _segment_group;
RowBlock* _row_block; // 使用RowBlcok缓存要写入的数据
RowCursor _cursor;
SegmentWriter* _segment_writer;
@@ -69,4 +76,4 @@ class ColumnDataWriter {
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_ROWSET_DATA_WRITER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_COLUMN_DATA_WRITER_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/column_reader.cpp
b/be/src/olap/rowset/column_reader.cpp
index 5b00e395..24aaf893 100644
--- a/be/src/olap/rowset/column_reader.cpp
+++ b/be/src/olap/rowset/column_reader.cpp
@@ -1355,4 +1355,4 @@ OLAPStatus LargeIntColumnReader::next_vector(
return res;
}
-} // namespace doris
+} // namespace doris
\ No newline at end of file
diff --git a/be/src/olap/rowset/column_reader.h
b/be/src/olap/rowset/column_reader.h
index c0b2b840..26a0bcd6 100644
--- a/be/src/olap/rowset/column_reader.h
+++ b/be/src/olap/rowset/column_reader.h
@@ -920,4 +920,4 @@ typedef IntegerColumnReaderWrapper<uint64_t, false>
DateTimeColumnReader;
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_ROWSET_COLUMN_READER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_COLUMN_READER_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/column_writer.cpp
b/be/src/olap/rowset/column_writer.cpp
index 652fb03c..9eaaef84 100755
--- a/be/src/olap/rowset/column_writer.cpp
+++ b/be/src/olap/rowset/column_writer.cpp
@@ -17,7 +17,7 @@
#include "olap/rowset/column_writer.h"
-#include "olap/bit_field_writer.h"
+#include "olap/rowset/bit_field_writer.h"
#include "olap/file_helper.h"
namespace doris {
@@ -962,4 +962,4 @@ void LargeIntColumnWriter::record_position() {
_low_writer->get_position(index_entry(), false);
}
-} // namespace doris
+} // namespace doris
\ No newline at end of file
diff --git a/be/src/olap/rowset/column_writer.h
b/be/src/olap/rowset/column_writer.h
index acba5f6f..ed3f4312 100644
--- a/be/src/olap/rowset/column_writer.h
+++ b/be/src/olap/rowset/column_writer.h
@@ -648,4 +648,4 @@ class LargeIntColumnWriter : public ColumnWriter {
};
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_ROWSET_COLUMN_WRITER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_COLUMN_WRITER_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/rowset.h b/be/src/olap/rowset/rowset.h
index ca6a0a17..a53368d4 100644
--- a/be/src/olap/rowset/rowset.h
+++ b/be/src/olap/rowset/rowset.h
@@ -21,11 +21,13 @@
#include "olap/new_status.h"
#include "olap/rowset/rowset_reader.h"
#include "olap/rowset/rowset_builder.h"
+#include "olap/rowset/rowset_meta.h"
#include <memory>
namespace doris {
+class RowsetBuilder;
class Rowset;
using RowsetSharedPtr = std::shared_ptr<Rowset>;
@@ -39,12 +41,9 @@ class Rowset {
virtual NewStatus copy(RowsetBuilder* dest_rowset_builder) = 0;
- virtual NewStatus delete() = 0;
-
-private:
- RowsetMeta _rowset_meta;
+ virtual NewStatus remove() = 0;
};
-}
+} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_ROWSET_ROWSET_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_ROWSET_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/rowset_builder.h
b/be/src/olap/rowset/rowset_builder.h
index 3e0005aa..19db9fba 100644
--- a/be/src/olap/rowset/rowset_builder.h
+++ b/be/src/olap/rowset/rowset_builder.h
@@ -25,6 +25,8 @@
namespace doris {
+class Rowset;
+
class RowsetBuilder {
public:
virtual ~RowsetBuilder() { }
@@ -44,4 +46,4 @@ class RowsetBuilder {
}
-#endif // DORIS_BE_SRC_OLAP_ROWSET_ROWSET_BUILDER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_ROWSET_BUILDER_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/rowset_meta.h b/be/src/olap/rowset/rowset_meta.h
index 21e28f2e..2685915b 100644
--- a/be/src/olap/rowset/rowset_meta.h
+++ b/be/src/olap/rowset/rowset_meta.h
@@ -85,19 +85,19 @@ class RowsetMeta {
_rowset_meta_pb.set_tablet_schema_hash(tablet_schema_hash);
}
- virtual RowsetType get_rowset_type() {
+ virtual RowsetTypePB get_rowset_type() {
return _rowset_meta_pb.rowset_type();
}
- virtual void set_rowset_type(RowsetType rowset_type) {
+ virtual void set_rowset_type(RowsetTypePB rowset_type) {
_rowset_meta_pb.set_rowset_type(rowset_type);
}
- virtual RowsetState get_rowset_state() {
+ virtual RowsetStatePB get_rowset_state() {
return _rowset_meta_pb.rowset_state();
}
- virtual void set_rowset_state(RowsetState rowset_state) {
+ virtual void set_rowset_state(RowsetStatePB rowset_state) {
_rowset_meta_pb.set_rowset_state(rowset_state);
}
@@ -129,6 +129,14 @@ class RowsetMeta {
_rowset_meta_pb.set_end_version(end_version);
}
+ virtual int64_t get_version_hash() {
+ return _rowset_meta_pb.version_hash();
+ }
+
+ virtual void set_version_hash(int64_t version_hash) {
+ _rowset_meta_pb.set_version_hash(version_hash);
+ }
+
virtual int get_row_number() {
return _rowset_meta_pb.row_number();
}
@@ -196,6 +204,14 @@ class RowsetMeta {
_rowset_meta_pb.set_txn_id(txn_id);
}
+ std::string get_extra_properties() {
+ return _rowset_meta_pb.extra_properties();
+ }
+
+ void set_extra_properties(std::string extra_properties) {
+ _rowset_meta_pb.set_extra_properties(extra_properties);
+ }
+
private:
bool _deserialize_from_pb(const std::string& value) {
return _rowset_meta_pb.ParseFromString(value);
@@ -212,6 +228,6 @@ class RowsetMeta {
RowsetMetaPB _rowset_meta_pb;
};
-}
+} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_ROWSET_ROWSET_META_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_ROWSET_META_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/rowset_meta_manager.cpp
b/be/src/olap/rowset/rowset_meta_manager.cpp
index 15e0542c..e0a9a36a 100644
--- a/be/src/olap/rowset/rowset_meta_manager.cpp
+++ b/be/src/olap/rowset/rowset_meta_manager.cpp
@@ -24,7 +24,7 @@
#include <boost/algorithm/string/trim.hpp>
#include "olap/olap_define.h"
-#include "olap/storage_engine.h"
+#include "olap/utils.h"
#include "common/logging.h"
#include "json2pb/json_to_pb.h"
#include "json2pb/pb_to_json.h"
diff --git a/be/src/olap/rowset/rowset_meta_manager.h
b/be/src/olap/rowset/rowset_meta_manager.h
index d5f161b9..40b9fc6c 100644
--- a/be/src/olap/rowset/rowset_meta_manager.h
+++ b/be/src/olap/rowset/rowset_meta_manager.h
@@ -45,4 +45,4 @@ class RowsetMetaManager {
}
-#endif // DORIS_BE_SRC_OLAP_ROWSET_ROWSET_META_MANAGER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_ROWSET_META_MANAGER_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/rowset_reader.h
b/be/src/olap/rowset/rowset_reader.h
index 1586f3dd..bab4c73b 100644
--- a/be/src/olap/rowset/rowset_reader.h
+++ b/be/src/olap/rowset/rowset_reader.h
@@ -23,6 +23,9 @@
#include "olap/column_predicate.h"
#include "olap/row_cursor.h"
#include "olap/row_block.h"
+#include "olap/lru_cache.h"
+#include "olap/olap_cond.h"
+#include "olap/delete_handler.h"
#include "runtime/runtime_state.h"
#include <memory>
@@ -49,6 +52,7 @@ struct ReaderContext {
const DeleteHandler& delete_handler;
OlapReaderStatistics* stats;
bool is_using_cache;
+ Cache* lru_cache;
RuntimeState* runtime_state;
};
@@ -71,4 +75,4 @@ class RowsetReader {
}
-#endif // DORIS_BE_SRC_OLAP_ROWSET_ROWSET_READER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_ROWSET_READER_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/run_length_byte_reader.cpp
b/be/src/olap/rowset/run_length_byte_reader.cpp
index 26a5725f..cc01009c 100644
--- a/be/src/olap/rowset/run_length_byte_reader.cpp
+++ b/be/src/olap/rowset/run_length_byte_reader.cpp
@@ -145,4 +145,4 @@ OLAPStatus RunLengthByteReader::skip(uint64_t num_values) {
return res;
}
-} // namespace doris
+} // namespace doris
\ No newline at end of file
diff --git a/be/src/olap/rowset/run_length_byte_reader.h
b/be/src/olap/rowset/run_length_byte_reader.h
index 3e8eae42..c3e45d1a 100644
--- a/be/src/olap/rowset/run_length_byte_reader.h
+++ b/be/src/olap/rowset/run_length_byte_reader.h
@@ -54,4 +54,4 @@ class RunLengthByteReader {
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_BYTE_READER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_BYTE_READER_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/run_length_byte_writer.cpp
b/be/src/olap/rowset/run_length_byte_writer.cpp
index e8efc79e..330259d2 100644
--- a/be/src/olap/rowset/run_length_byte_writer.cpp
+++ b/be/src/olap/rowset/run_length_byte_writer.cpp
@@ -142,5 +142,4 @@ void RunLengthByteWriter::get_position(PositionEntryWriter*
index_entry) const {
index_entry->add_position(_num_literals);
}
-} // namespace doris
-
+} // namespace doris
\ No newline at end of file
diff --git a/be/src/olap/rowset/run_length_byte_writer.h
b/be/src/olap/rowset/run_length_byte_writer.h
index b0875f8c..ac083357 100644
--- a/be/src/olap/rowset/run_length_byte_writer.h
+++ b/be/src/olap/rowset/run_length_byte_writer.h
@@ -53,4 +53,4 @@ class RunLengthByteWriter {
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_BYTE_WRITER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_BYTE_WRITER_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/run_length_integer_reader.cpp
b/be/src/olap/rowset/run_length_integer_reader.cpp
index 06d66e9e..2afa5362 100644
--- a/be/src/olap/rowset/run_length_integer_reader.cpp
+++ b/be/src/olap/rowset/run_length_integer_reader.cpp
@@ -432,5 +432,4 @@ OLAPStatus RunLengthIntegerReader::skip(uint64_t
num_values) {
return res;
}
-} // namespace doris
-
+} // namespace doris
\ No newline at end of file
diff --git a/be/src/olap/rowset/run_length_integer_reader.h
b/be/src/olap/rowset/run_length_integer_reader.h
index 4a557bdb..41581b71 100644
--- a/be/src/olap/rowset/run_length_integer_reader.h
+++ b/be/src/olap/rowset/run_length_integer_reader.h
@@ -74,4 +74,4 @@ class RunLengthIntegerReader {
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_INTEGER_READER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_INTEGER_READER_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/run_length_integer_writer.cpp
b/be/src/olap/rowset/run_length_integer_writer.cpp
index d1901786..44cb6fea 100644
--- a/be/src/olap/rowset/run_length_integer_writer.cpp
+++ b/be/src/olap/rowset/run_length_integer_writer.cpp
@@ -730,5 +730,4 @@ void
RunLengthIntegerWriter::get_position(PositionEntryWriter* index_entry, bool
}
}
-} // namespace doris
-
+} // namespace doris
\ No newline at end of file
diff --git a/be/src/olap/rowset/run_length_integer_writer.h
b/be/src/olap/rowset/run_length_integer_writer.h
index 4e484e5e..df846256 100644
--- a/be/src/olap/rowset/run_length_integer_writer.h
+++ b/be/src/olap/rowset/run_length_integer_writer.h
@@ -296,4 +296,4 @@ class RunLengthIntegerWriter {
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_INTEGER_WRITER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_INTEGER_WRITER_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/segment_group.cpp
b/be/src/olap/rowset/segment_group.cpp
index 5fb3db1a..b880aec6 100644
--- a/be/src/olap/rowset/segment_group.cpp
+++ b/be/src/olap/rowset/segment_group.cpp
@@ -15,15 +15,15 @@
// specific language governing permissions and limitations
// under the License.
-#include "olap/segment_group.h"
+#include "olap/rowset/segment_group.h"
#include <algorithm>
#include <cassert>
#include <cmath>
#include <fstream>
+#include <sstream>
#include "olap/rowset/column_data.h"
-#include "olap/tablet.h"
#include "olap/row_block.h"
#include "olap/row_cursor.h"
#include "olap/utils.h"
@@ -61,7 +61,7 @@ namespace doris {
} while (0);
SegmentGroup::SegmentGroup(int64_t tablet_id, const RowFields& tablet_schema,
int num_key_fields, int num_short_key_fields,
- int num_rows_per_row_block, std::string rowset_path_prefix,
Version version, VersionHash version_hash,
+ size_t num_rows_per_row_block, std::string rowset_path_prefix,
Version version, VersionHash version_hash,
bool delete_flag, int32_t segment_group_id, int32_t num_segments)
: _tablet_id(tablet_id),
_tablet_schema(tablet_schema),
@@ -99,7 +99,7 @@ SegmentGroup::SegmentGroup(int64_t tablet_id, const
RowFields& tablet_schema, in
}
SegmentGroup::SegmentGroup(int64_t tablet_id, const RowFields& tablet_schema,
int num_key_fields, int num_short_key_fields,
- int num_rows_per_row_block, std::string rowset_path_prefix, bool
delete_flag,
+ size_t num_rows_per_row_block, std::string rowset_path_prefix, bool
delete_flag,
int32_t segment_group_id, int32_t num_segments, bool is_pending,
TPartitionId partition_id, TTransactionId transaction_id) :
_tablet_id(tablet_id),
_tablet_schema(tablet_schema),
@@ -147,17 +147,17 @@ SegmentGroup::~SegmentGroup() {
_seg_pb_map.clear();
}
-std::string SegmentGroup::_construct_pending_file_path(int32_t segment_id,
const std::string& suffix) {
+std::string SegmentGroup::_construct_pending_file_path(int32_t segment_id,
const std::string& suffix) const {
std::string pending_dir_path = _rowset_path_prefix + PENDING_DELTA_PREFIX;
- stringstream file_path;
+ std::stringstream file_path;
file_path << pending_dir_path << "/"
<< _transaction_id << "_"
<< _segment_group_id << "_" << segment_id << suffix;
return file_path.str();
}
-std::string SegmentGroup::_construct_file_path(int32_t segment_id, const
string& suffix) {
- stringstream prefix_stream;
+std::string SegmentGroup::_construct_file_path(int32_t segment_id, const
string& suffix) const {
+ std::stringstream prefix_stream;
prefix_stream << _rowset_path_prefix << "/" << _tablet_id;
string path_prefix = prefix_stream.str();
char file_path[OLAP_MAX_PATH_LEN];
@@ -186,7 +186,7 @@ std::string SegmentGroup::_construct_file_path(int32_t
segment_id, const string&
return file_path;
}
-string SegmentGroup::construct_index_file_path(int32_t segment_group_id,
int32_t segment_id) const {
+std::string SegmentGroup::construct_index_file_path(int32_t segment_id) const {
if (_is_pending) {
return _construct_pending_file_path(segment_id, ".idx");
} else {
@@ -194,7 +194,7 @@ string SegmentGroup::construct_index_file_path(int32_t
segment_group_id, int32_t
}
}
-string SegmentGroup::construct_data_file_path(int32_t segment_group_id,
int32_t segment_id) const {
+std::string SegmentGroup::construct_data_file_path(int32_t segment_id) const {
if (_is_pending) {
return _construct_pending_file_path(segment_id, ".dat");
} else {
@@ -228,8 +228,8 @@ void SegmentGroup::delete_all_files() {
if (!_file_created) { return; }
for (uint32_t seg_id = 0; seg_id < _num_segments; ++seg_id) {
// get full path for one segment
- string index_path = construct_index_file_path(_segment_group_id,
seg_id);
- string data_path = construct_data_file_path(_segment_group_id, seg_id);
+ string index_path = construct_index_file_path(seg_id);
+ string data_path = construct_data_file_path(seg_id);
if (remove(index_path.c_str()) != 0) {
char errmsg[64];
@@ -256,11 +256,11 @@ OLAPStatus
SegmentGroup::add_column_statistics_for_linked_schema_change(
//as rollup tablet num_key_fields will less than base tablet
column_statistic_fields.size().
//For LinkedSchemaChange, the rollup tablet keys order is the same as base
tablet
for (size_t i = 0; i < _num_key_fields; ++i) {
- WrapperField* first = WrapperField::create(_tablet_schema()[i]);
+ WrapperField* first = WrapperField::create(_tablet_schema[i]);
DCHECK(first != NULL) << "failed to allocate memory for field: " << i;
first->copy(column_statistic_fields[i].first);
- WrapperField* second = WrapperField::create(_tablet_schema()[i]);
+ WrapperField* second = WrapperField::create(_tablet_schema[i]);
DCHECK(second != NULL) << "failed to allocate memory for field: " << i;
second->copy(column_statistic_fields[i].second);
@@ -273,11 +273,11 @@ OLAPStatus SegmentGroup::add_column_statistics(
const std::vector<std::pair<WrapperField*, WrapperField*>>&
column_statistic_fields) {
DCHECK(column_statistic_fields.size() == _num_key_fields);
for (size_t i = 0; i < column_statistic_fields.size(); ++i) {
- WrapperField* first = WrapperField::create(_tablet_schema()[i]);
+ WrapperField* first = WrapperField::create(_tablet_schema[i]);
DCHECK(first != NULL) << "failed to allocate memory for field: " << i;
first->copy(column_statistic_fields[i].first);
- WrapperField* second = WrapperField::create(_tablet_schema()[i]);
+ WrapperField* second = WrapperField::create(_tablet_schema[i]);
DCHECK(second != NULL) << "failed to allocate memory for field: " << i;
second->copy(column_statistic_fields[i].second);
@@ -289,16 +289,16 @@ OLAPStatus SegmentGroup::add_column_statistics(
OLAPStatus SegmentGroup::add_column_statistics(
std::vector<std::pair<std::string, std::string> >
&column_statistic_strings,
std::vector<bool> &null_vec) {
- DCHECK(column_statistic_strings.size() == _num_key_fields;
+ DCHECK(column_statistic_strings.size() == _num_key_fields);
for (size_t i = 0; i < column_statistic_strings.size(); ++i) {
- WrapperField* first = WrapperField::create(_tablet_schema()[i]);
+ WrapperField* first = WrapperField::create(_tablet_schema[i]);
DCHECK(first != NULL) << "failed to allocate memory for field: " << i ;
RETURN_NOT_OK(first->from_string(column_statistic_strings[i].first));
if (null_vec[i]) {
//[min, max] -> [NULL, max]
first->set_null();
}
- WrapperField* second = WrapperField::create(_tablet_schema()[i]);
+ WrapperField* second = WrapperField::create(_tablet_schema[i]);
DCHECK(first != NULL) << "failed to allocate memory for field: " << i ;
RETURN_NOT_OK(second->from_string(column_statistic_strings[i].second));
_column_statistics.push_back(std::make_pair(first, second));
@@ -330,7 +330,7 @@ OLAPStatus SegmentGroup::load() {
// for each segment
for (uint32_t seg_id = 0; seg_id < _num_segments; ++seg_id) {
- string seg_path = construct_data_file_path(_segment_group_id, seg_id);
+ string seg_path = construct_data_file_path(seg_id);
if (OLAP_SUCCESS != (res = load_pb(seg_path.c_str(), seg_id))) {
LOG(WARNING) << "failed to load pb structures. [seg_path='" <<
seg_path << "']";
@@ -338,8 +338,8 @@ OLAPStatus SegmentGroup::load() {
}
// get full path for one segment
- string path = construct_index_file_path(_segment_group_id, seg_id);
- if ((res = _index.load_segment(path.c_str(),
&_current_num_rows_per_row_block))
+ std::string path = construct_index_file_path(seg_id);
+ if ((res = _index.load_segment(path.c_str(), &_num_rows_per_row_block))
!= OLAP_SUCCESS) {
LOG(WARNING) << "fail to load segment. [path='" << path << "']";
@@ -392,8 +392,8 @@ OLAPStatus SegmentGroup::validate() {
FileHeader<OLAPDataHeaderMessage> data_file_header;
// get full path for one segment
- string index_path = construct_index_file_path(_segment_group_id,
seg_id);
- string data_path = construct_data_file_path(_segment_group_id, seg_id);
+ string index_path = construct_index_file_path(seg_id);
+ string data_path = construct_data_file_path(seg_id);
// 检查index文件头
if ((res = index_file_header.validate(index_path)) != OLAP_SUCCESS) {
@@ -567,7 +567,7 @@ OLAPStatus SegmentGroup::add_segment() {
return OLAP_ERR_MALLOC_ERROR;
}
- if (_current_index_row.init(_tablet_schema()) != OLAP_SUCCESS) {
+ if (_current_index_row.init(_tablet_schema) != OLAP_SUCCESS) {
OLAP_LOG_WARNING("init _current_index_row fail.");
return OLAP_ERR_INIT_FAILED;
}
@@ -587,7 +587,7 @@ OLAPStatus SegmentGroup::add_row_block(const RowBlock&
row_block, const uint32_t
OLAPStatus SegmentGroup::add_short_key(const RowCursor& short_key, const
uint32_t data_offset) {
OLAPStatus res = OLAP_SUCCESS;
if (!_new_segment_created) {
- string file_path = construct_index_file_path(_segment_group_id,
_num_segments - 1);
+ string file_path = construct_index_file_path(_num_segments - 1);
res = _current_file_handler.open_with_mode(
file_path.c_str(), O_CREAT | O_EXCL | O_WRONLY,
S_IRUSR | S_IWUSR);
if (res != OLAP_SUCCESS) {
@@ -686,7 +686,7 @@ const RowFields& SegmentGroup::get_tablet_schema() {
return _tablet_schema;
}
-int SegmentGroup::get_num_key_fields)() {
+int SegmentGroup::get_num_key_fields() {
return _num_key_fields;
}
@@ -694,7 +694,7 @@ int SegmentGroup::get_num_short_key_fields() {
return _num_short_key_fields;
}
-int SegmentGroup::get_num_rows_per_row_block() {
+size_t SegmentGroup::get_num_rows_per_row_block() {
return _num_rows_per_row_block;
}
@@ -706,4 +706,4 @@ int64_t SegmentGroup::get_tablet_id() {
return _tablet_id;
}
-}
+} // namespace doris
\ No newline at end of file
diff --git a/be/src/olap/rowset/segment_group.h
b/be/src/olap/rowset/segment_group.h
index 59a16a6d..eb31a46a 100644
--- a/be/src/olap/rowset/segment_group.h
+++ b/be/src/olap/rowset/segment_group.h
@@ -48,11 +48,11 @@ class SegmentGroup {
friend class MemIndex;
public:
SegmentGroup(int64_t tablet_id, const RowFields& tablet_schema, int
num_key_fields, int num_short_key_fields,
- int num_rows_per_row_block, std::string tablet_path_prefix,
Version version,
+ size_t num_rows_per_row_block, std::string tablet_path_prefix,
Version version,
VersionHash version_hash, bool delete_flag, int segment_group_id,
int32_t num_segments);
SegmentGroup(int64_t tablet_id, const RowFields& tablet_schema, int
num_key_fields, int num_short_key_fields,
- int num_rows_per_row_block, std::string tablet_path_prefix, bool
delete_flag,
+ size_t num_rows_per_row_block, std::string tablet_path_prefix,
bool delete_flag,
int32_t segment_group_id, int32_t num_segments, bool is_pending,
TPartitionId partition_id, TTransactionId transaction_id);
@@ -213,10 +213,6 @@ class SegmentGroup {
// return count of entries in MemIndex
uint64_t num_index_entries() const;
- size_t current_num_rows_per_row_block() const {
- return _current_num_rows_per_row_block;
- }
-
OLAPStatus get_row_block_position(const OLAPIndexOffset& pos,
RowBlockPosition* rbp) const {
return _index.get_row_block_position(pos, rbp);
}
@@ -239,23 +235,23 @@ class SegmentGroup {
int get_num_short_key_fields();
- int get_num_rows_per_row_block();
+ size_t get_num_rows_per_row_block();
std::string get_rowset_path_prefix();
int64_t get_tablet_id();
private:
- std::string _construct_pending_file_path(int32_t segment, const
std::string& suffix);
+ std::string _construct_pending_file_path(int32_t segment, const
std::string& suffix) const;
- std::string _construct_file_path(int32_t segment, const std::string&
suffix);
+ std::string _construct_file_path(int32_t segment, const std::string&
suffix) const;
private:
int64_t _tablet_id;
const RowFields& _tablet_schema; // tablet schema
int _num_key_fields; // number of tablet keys
int _num_short_key_fields; // number of tablet short keys
- int _num_rows_per_row_block; // row number of a row block
+ size_t _num_rows_per_row_block; // row number of a row block
std::string _rowset_path_prefix; // path of rowset
Version _version; // version of associated data file
VersionHash _version_hash; // version hash for this segmentgroup
@@ -295,14 +291,12 @@ class SegmentGroup {
// Lock held while loading the index.
mutable boost::mutex _index_load_lock;
- size_t _current_num_rows_per_row_block;
-
std::vector<std::pair<WrapperField*, WrapperField*>> _column_statistics;
std::unordered_map<uint32_t, FileHeader<ColumnDataHeaderMessage> >
_seg_pb_map;
DISALLOW_COPY_AND_ASSIGN(SegmentGroup);
};
-}
+} // namespace doris
#endif // DORIS_BE_SRC_OLAP_ROWSET_SEGMENT_GROUP_H
\ No newline at end of file
diff --git a/be/src/olap/rowset/segment_reader.cpp
b/be/src/olap/rowset/segment_reader.cpp
index 430d8f2e..51051b31 100644
--- a/be/src/olap/rowset/segment_reader.cpp
+++ b/be/src/olap/rowset/segment_reader.cpp
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-#include "olap/segment_reader.h"
+#include "olap/rowset/segment_reader.h"
#include <sys/mman.h>
@@ -43,31 +43,31 @@ SegmentReader::SegmentReader(
const DeleteHandler& delete_handler,
const DelCondSatisfied delete_status,
RuntimeState* runtime_state,
- OlapReaderStatistics* stats) :
+ OlapReaderStatistics* stats,
+ Cache* lru_cache) :
_file_name(file),
_segment_group(segment_group),
_segment_id(segment_id),
+ _used_columns(used_columns),
+ _load_bf_columns(load_bf_columns),
_conditions(conditions),
_delete_handler(delete_handler),
_delete_status(delete_status),
+ _runtime_state(runtime_state),
+ _stats(stats),
+ _lru_cache(lru_cache),
_eof(false),
_end_block(-1),
// 确保第一次调用_move_to_next_row,会执行seek_to_block
_block_count(0),
_num_rows_in_block(0),
_null_supported(false),
- _used_columns(used_columns),
- _load_bf_columns(load_bf_columns),
_mmap_buffer(NULL),
_include_blocks(NULL),
_is_using_mmap(false),
_is_data_loaded(false),
_buffer_size(0),
- _lru_cache(NULL),
- _runtime_state(runtime_state),
- _shared_buffer(NULL),
- _stats(stats) {
- _lru_cache = StorageEngine::get_instance()->index_stream_lru_cache();
+ _shared_buffer(NULL) {
_tracker.reset(new MemTracker(-1));
_mem_pool.reset(new MemPool(_tracker.get()));
}
@@ -185,7 +185,7 @@ OLAPStatus SegmentReader::_set_decompressor() {
OLAPStatus SegmentReader::_set_segment_info() {
_num_rows_in_block = _header_message().num_rows_per_block();
if (_num_rows_in_block == 0) {
- _num_rows_in_block = _segment_group->num_rows_per_row_block();
+ _num_rows_in_block = _segment_group->get_num_rows_per_row_block();
}
_set_column_map();
@@ -947,4 +947,4 @@ OLAPStatus SegmentReader::_load_to_vectorized_row_batch(
return OLAP_SUCCESS;
}
-} //unamespace doris
+} //unamespace doris
\ No newline at end of file
diff --git a/be/src/olap/rowset/segment_reader.h
b/be/src/olap/rowset/segment_reader.h
index 5a610b9e..2ce33c6c 100644
--- a/be/src/olap/rowset/segment_reader.h
+++ b/be/src/olap/rowset/segment_reader.h
@@ -26,7 +26,8 @@
#include <string>
#include "olap/bloom_filter_reader.h"
-#include "olap/column_reader.h"
+#include "olap/rowset/column_reader.h"
+#include "olap/rowset/segment_group.h"
#include "olap/compress.h"
#include "olap/file_stream.h"
#include "olap/in_stream.h"
@@ -36,7 +37,6 @@
#include "olap/lru_cache.h"
#include "olap/olap_cond.h"
#include "olap/olap_define.h"
-#include "olap/storage_engine.h"
#include "olap/row_cursor.h"
#include "runtime/runtime_state.h"
#include "runtime/mem_pool.h"
@@ -45,25 +45,21 @@
namespace doris {
-class SegmentGroup;
-
-
-class ColumnReader;
-
// SegmentReader 用于读取一个Segment文件
class SegmentReader {
public:
explicit SegmentReader(const std::string file,
SegmentGroup* segment_group,
uint32_t segment_id,
- const std::vector<uint32_t>& return_columns,
+ const std::vector<uint32_t>& used_columns,
const std::set<uint32_t>& load_bf_columns,
const Conditions* conditions,
const std::vector<ColumnPredicate*>* col_predicates,
const DeleteHandler& delete_handler,
const DelCondSatisfied delete_status,
RuntimeState* runtime_state,
- OlapReaderStatistics* stats);
+ OlapReaderStatistics* stats,
+ Cache* lru_cache);
~SegmentReader();
@@ -230,7 +226,7 @@ class SegmentReader {
// 获取当前的table级schema。
inline const std::vector<FieldInfo>& tablet_schema() {
- return _segment_group->tablet_schema();
+ return _segment_group->get_tablet_schema();
}
inline const ColumnDataHeaderMessage& _header_message() {
@@ -291,10 +287,9 @@ class SegmentReader {
static const uint32_t CURRENT_COLUMN_DATA_VERSION = 1;
std::string _file_name; // 文件名
- doris::FileHandler _file_handler; // 文件handler
-
SegmentGroup* _segment_group;
uint32_t _segment_id;
+ doris::FileHandler _file_handler; // 文件handler
const Conditions* _conditions; // 列过滤条件
DeleteHandler _delete_handler;
diff --git a/be/src/olap/rowset/segment_writer.cpp
b/be/src/olap/rowset/segment_writer.cpp
index 5d536de0..caf11c58 100644
--- a/be/src/olap/rowset/segment_writer.cpp
+++ b/be/src/olap/rowset/segment_writer.cpp
@@ -15,23 +15,26 @@
// specific language governing permissions and limitations
// under the License.
-#include "olap/segment_writer.h"
+#include "olap/rowset/segment_writer.h"
-#include "olap/column_writer.h"
+#include "olap/rowset/column_writer.h"
#include "olap/out_stream.h"
#include "olap/file_helper.h"
#include "olap/utils.h"
-
namespace doris {
SegmentWriter::SegmentWriter(
const std::string& file_name,
- TabletSharedPtr tablet,
- uint32_t stream_buffer_size) :
+ SegmentGroup* segment_group,
+ uint32_t stream_buffer_size,
+ CompressKind compress_kind,
+ double bloom_filter_fpp) :
_file_name(file_name),
- _tablet(tablet),
+ _segment_group(segment_group),
_stream_buffer_size(stream_buffer_size),
+ _compress_kind(compress_kind),
+ _bloom_filter_fpp(bloom_filter_fpp),
_stream_factory(NULL),
_row_count(0),
_block_count(0) {}
@@ -49,7 +52,7 @@ OLAPStatus SegmentWriter::init(uint32_t write_mbytes_per_sec)
{
OLAPStatus res = OLAP_SUCCESS;
// 创建factory
_stream_factory =
- new(std::nothrow) OutStreamFactory(_tablet->compress_kind(),
_stream_buffer_size);
+ new(std::nothrow) OutStreamFactory(_compress_kind,
_stream_buffer_size);
if (NULL == _stream_factory) {
OLAP_LOG_WARNING("fail to allocate out stream factory");
@@ -57,12 +60,12 @@ OLAPStatus SegmentWriter::init(uint32_t
write_mbytes_per_sec) {
}
// 创建writer
- for (uint32_t i = 0; i < _tablet->tablet_schema().size(); i++) {
- if (_tablet->tablet_schema()[i].is_root_column) {
- ColumnWriter* writer = ColumnWriter::create(i,
_tablet->tablet_schema(),
+ for (uint32_t i = 0; i < _segment_group->get_tablet_schema().size(); i++) {
+ if (_segment_group->get_tablet_schema()[i].is_root_column) {
+ ColumnWriter* writer = ColumnWriter::create(i,
_segment_group->get_tablet_schema(),
_stream_factory,
-
_tablet->num_rows_per_row_block(),
-
_tablet->bloom_filter_fpp());
+
_segment_group->get_num_rows_per_row_block(),
+ _bloom_filter_fpp);
if (NULL == writer) {
OLAP_LOG_WARNING("fail to create writer");
@@ -85,9 +88,9 @@ OLAPStatus SegmentWriter::init(uint32_t write_mbytes_per_sec)
{
}
OLAPStatus SegmentWriter::write_batch(RowBlock* block, RowCursor* cursor, bool
is_finalize) {
- DCHECK(block->row_block_info().row_num ==
_tablet->num_rows_per_row_block() || is_finalize)
+ DCHECK(block->row_block_info().row_num ==
_segment_group->get_num_rows_per_row_block() || is_finalize)
<< "write block not empty, num_rows=" <<
block->row_block_info().row_num
- << ", table_num_rows=" << _tablet->num_rows_per_row_block();
+ << ", table_num_rows=" << _segment_group->get_num_rows_per_row_block();
OLAPStatus res = OLAP_SUCCESS;
for (auto col_writer : _root_writers) {
res = col_writer->write_batch(block, cursor);
@@ -125,12 +128,12 @@ uint64_t SegmentWriter::estimate_segment_size() {
OLAPStatus SegmentWriter::_make_file_header(ColumnDataHeaderMessage*
file_header) {
OLAPStatus res = OLAP_SUCCESS;
file_header->set_number_of_rows(_row_count);
- file_header->set_compress_kind(_tablet->compress_kind());
+ file_header->set_compress_kind(_compress_kind);
file_header->set_stream_buffer_size(_stream_buffer_size);
// TODO. 之前没设置
file_header->set_magic_string("COLUMN DATA");
file_header->set_version(1);
- file_header->set_num_rows_per_block(_tablet->num_rows_per_row_block());
+
file_header->set_num_rows_per_block(_segment_group->get_num_rows_per_row_block());
// check if has bloom filter columns
bool has_bf_column = false;
@@ -273,4 +276,4 @@ OLAPStatus SegmentWriter::finalize(uint32_t*
segment_file_size) {
return res;
}
-} // namespace doris
+} // namespace doris
\ No newline at end of file
diff --git a/be/src/olap/rowset/segment_writer.h
b/be/src/olap/rowset/segment_writer.h
index 9b653e6a..7dca0010 100644
--- a/be/src/olap/rowset/segment_writer.h
+++ b/be/src/olap/rowset/segment_writer.h
@@ -19,7 +19,7 @@
#define DORIS_BE_SRC_OLAP_ROWSET_SEGMENT_WRITER_H
#include "olap/olap_define.h"
-#include "olap/rowset/data_writer.h"
+#include "olap/rowset/column_data_writer.h"
namespace doris {
@@ -30,8 +30,10 @@ class ColumnDataHeaderMessage;
class SegmentWriter {
public:
explicit SegmentWriter(const std::string& file_name,
- TabletSharedPtr tablet,
- uint32_t stream_buffer_size);
+ SegmentGroup* segment_group,
+ uint32_t stream_buffer_size,
+ CompressKind compress_kind,
+ double bloom_filter_fpp);
~SegmentWriter();
OLAPStatus init(uint32_t write_mbytes_per_sec);
OLAPStatus write_batch(RowBlock* block, RowCursor* cursor, bool
is_finalize);
@@ -44,9 +46,12 @@ class SegmentWriter {
// Helper: 生成最终的PB文件头
OLAPStatus _make_file_header(ColumnDataHeaderMessage* file_header);
+private:
std::string _file_name;
- TabletSharedPtr _tablet;
+ SegmentGroup* _segment_group;
uint32_t _stream_buffer_size; // 输出缓冲区大小
+ CompressKind _compress_kind;
+ double _bloom_filter_fpp;
std::vector<ColumnWriter*> _root_writers;
OutStreamFactory* _stream_factory;
uint64_t _row_count; // 已经写入的行总数
diff --git a/gensrc/proto/olap_file.proto b/gensrc/proto/olap_file.proto
index 360cc26a..853af2be 100644
--- a/gensrc/proto/olap_file.proto
+++ b/gensrc/proto/olap_file.proto
@@ -276,5 +276,4 @@ message OLAPDataHeaderMessage {
message OLAPRawDeltaHeaderMessage {
required int32 schema_hash = 2;
-}
-
+}
\ No newline at end of file
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]