chaoyli closed pull request #452: Add AlphaRowsetMeta and AlphaRowsetReader
URL: https://github.com/apache/incubator-doris/pull/452
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/src/exec/olap_scanner.h b/be/src/exec/olap_scanner.h
index b235d02f..06eaaf51 100644
--- a/be/src/exec/olap_scanner.h
+++ b/be/src/exec/olap_scanner.h
@@ -35,7 +35,7 @@
#include "runtime/vectorized_row_batch.h"
#include "olap/delete_handler.h"
-#include "olap/column_data.h"
+#include "olap/rowset/column_data.h"
#include "olap/olap_cond.h"
#include "olap/storage_engine.h"
#include "olap/reader.h"
diff --git a/be/src/olap/CMakeLists.txt b/be/src/olap/CMakeLists.txt
index 5bc442f6..071b649f 100644
--- a/be/src/olap/CMakeLists.txt
+++ b/be/src/olap/CMakeLists.txt
@@ -24,19 +24,19 @@ set(EXECUTABLE_OUTPUT_PATH "${BUILD_DIR}/src/olap")
add_library(Olap STATIC
aggregate_func.cpp
base_compaction.cpp
- bit_field_reader.cpp
- bit_field_writer.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
- column_data.cpp
- column_reader.cpp
- column_writer.cpp
+ rowset/column_data.cpp
+ rowset/column_reader.cpp
+ rowset/column_writer.cpp
comparison_predicate.cpp
compress.cpp
cumulative_compaction.cpp
- data_writer.cpp
+ rowset/data_writer.cpp
delete_handler.cpp
delta_writer.cpp
field.cpp
@@ -62,14 +62,14 @@ add_library(Olap STATIC
reader.cpp
row_block.cpp
row_cursor.cpp
- segment_group.cpp
- run_length_byte_reader.cpp
- run_length_byte_writer.cpp
- run_length_integer_reader.cpp
- run_length_integer_writer.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
- segment_reader.cpp
- segment_writer.cpp
+ rowset/segment_reader.cpp
+ rowset/segment_writer.cpp
serialize.cpp
storage_engine.cpp
data_dir.cpp
@@ -86,4 +86,8 @@ add_library(Olap STATIC
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/base_compaction.cpp b/be/src/olap/base_compaction.cpp
index 3f05a645..4f4f774f 100644
--- a/be/src/olap/base_compaction.cpp
+++ b/be/src/olap/base_compaction.cpp
@@ -25,10 +25,10 @@
#include "olap/delete_handler.h"
#include "olap/merger.h"
-#include "olap/column_data.h"
+#include "olap/rowset/column_data.h"
#include "olap/storage_engine.h"
#include "olap/tablet_meta.h"
-#include "olap/segment_group.h"
+#include "olap/rowset/segment_group.h"
#include "olap/tablet.h"
#include "olap/utils.h"
#include "util/doris_metrics.h"
diff --git a/be/src/olap/cumulative_compaction.h
b/be/src/olap/cumulative_compaction.h
index 48dfc9d3..89c74e27 100755
--- a/be/src/olap/cumulative_compaction.h
+++ b/be/src/olap/cumulative_compaction.h
@@ -24,7 +24,7 @@
#include <vector>
#include "olap/merger.h"
-#include "olap/column_data.h"
+#include "olap/rowset/column_data.h"
#include "olap/olap_define.h"
#include "olap/tablet.h"
diff --git a/be/src/olap/delta_writer.cpp b/be/src/olap/delta_writer.cpp
index 68c86344..74c892e3 100644
--- a/be/src/olap/delta_writer.cpp
+++ b/be/src/olap/delta_writer.cpp
@@ -18,7 +18,7 @@
#include "olap/delta_writer.h"
#include "olap/schema.h"
-#include "olap/segment_group.h"
+#include "olap/rowset/segment_group.h"
namespace doris {
diff --git a/be/src/olap/delta_writer.h b/be/src/olap/delta_writer.h
index ee849f17..2afd25ce 100644
--- a/be/src/olap/delta_writer.h
+++ b/be/src/olap/delta_writer.h
@@ -22,7 +22,7 @@
#include "olap/storage_engine.h"
#include "olap/tablet.h"
#include "olap/schema_change.h"
-#include "olap/data_writer.h"
+#include "olap/rowset/data_writer.h"
#include "runtime/descriptors.h"
#include "runtime/tuple.h"
#include "gen_cpp/internal_service.pb.h"
diff --git a/be/src/olap/field_info.h b/be/src/olap/field_info.h
index 9bb8518e..10c8bf9e 100644
--- a/be/src/olap/field_info.h
+++ b/be/src/olap/field_info.h
@@ -348,6 +348,8 @@ struct FieldInfo {
}
};
+typedef std::vector<FieldInfo> RowFields;
+
} // namespace doris
#endif // DORIS_BE_SRC_OLAP_FIELD_INFO_H
diff --git a/be/src/olap/memtable.cpp b/be/src/olap/memtable.cpp
index f145ef02..787ce63a 100644
--- a/be/src/olap/memtable.cpp
+++ b/be/src/olap/memtable.cpp
@@ -18,7 +18,7 @@
#include "olap/memtable.h"
#include "olap/hll.h"
-#include "olap/data_writer.h"
+#include "olap/rowset/data_writer.h"
#include "olap/row_cursor.h"
#include "util/runtime_profile.h"
#include "util/debug_util.h"
diff --git a/be/src/olap/merger.cpp b/be/src/olap/merger.cpp
index 61e48bb1..d28e61ef 100644
--- a/be/src/olap/merger.cpp
+++ b/be/src/olap/merger.cpp
@@ -20,13 +20,13 @@
#include <memory>
#include <vector>
-#include "olap/column_data.h"
+#include "olap/rowset/column_data.h"
#include "olap/olap_define.h"
-#include "olap/segment_group.h"
+#include "olap/rowset/segment_group.h"
#include "olap/tablet.h"
#include "olap/reader.h"
#include "olap/row_cursor.h"
-#include "olap/data_writer.h"
+#include "olap/rowset/data_writer.h"
using std::list;
using std::string;
@@ -114,7 +114,7 @@ OLAPStatus Merger::merge(const vector<ColumnData*>&
olap_data_arr,
if (!has_error) {
*merged_rows = reader.merged_rows();
- *filted_rows = reader.filted_rows();
+ *filted_rows = reader.filtered_rows();
}
return has_error ? OLAP_ERR_OTHER_ERROR : OLAP_SUCCESS;
diff --git a/be/src/olap/olap_index.cpp b/be/src/olap/olap_index.cpp
index 26ddbec9..8e4ee191 100644
--- a/be/src/olap/olap_index.cpp
+++ b/be/src/olap/olap_index.cpp
@@ -22,7 +22,7 @@
#include <cmath>
#include <fstream>
-#include "olap/column_data.h"
+#include "olap/rowset/column_data.h"
#include "olap/tablet.h"
#include "olap/row_block.h"
#include "olap/row_cursor.h"
diff --git a/be/src/olap/olap_index.h b/be/src/olap/olap_index.h
index c74ceeb5..87f98f23 100644
--- a/be/src/olap/olap_index.h
+++ b/be/src/olap/olap_index.h
@@ -47,7 +47,6 @@ class SegmentComparator;
class WrapperField;
typedef uint32_t data_file_offset_t;
-typedef std::vector<FieldInfo> RowFields;
struct OLAPIndexFixedHeader {
OLAPIndexFixedHeader() : data_length(0), num_rows(0) {}
diff --git a/be/src/olap/olap_snapshot.cpp b/be/src/olap/olap_snapshot.cpp
index af752d56..f10c45c3 100644
--- a/be/src/olap/olap_snapshot.cpp
+++ b/be/src/olap/olap_snapshot.cpp
@@ -33,7 +33,7 @@
#include "common/status.h"
#include "olap/field.h"
#include "olap/olap_common.h"
-#include "olap/column_data.h"
+#include "olap/rowset/column_data.h"
#include "olap/olap_define.h"
#include "olap/tablet.h"
#include "olap/tablet_meta_manager.h"
diff --git a/be/src/olap/push_handler.h b/be/src/olap/push_handler.h
index 15998b4e..4f254302 100644
--- a/be/src/olap/push_handler.h
+++ b/be/src/olap/push_handler.h
@@ -27,9 +27,9 @@
#include "olap/file_helper.h"
#include "olap/merger.h"
#include "olap/olap_common.h"
-#include "olap/segment_group.h"
+#include "olap/rowset/segment_group.h"
#include "olap/row_cursor.h"
-#include "olap/data_writer.h"
+#include "olap/rowset/data_writer.h"
namespace doris {
diff --git a/be/src/olap/reader.cpp b/be/src/olap/reader.cpp
index dff2a7ca..49876830 100644
--- a/be/src/olap/reader.cpp
+++ b/be/src/olap/reader.cpp
@@ -17,7 +17,7 @@
#include "olap/reader.h"
-#include "olap/column_data.h"
+#include "olap/rowset/column_data.h"
#include "olap/tablet.h"
#include "olap/row_block.h"
#include "olap/row_cursor.h"
diff --git a/be/src/olap/reader.h b/be/src/olap/reader.h
index b9c5b69a..f1f205d6 100644
--- a/be/src/olap/reader.h
+++ b/be/src/olap/reader.h
@@ -119,7 +119,7 @@ class Reader {
return _merged_rows;
}
- uint64_t filted_rows() const {
+ uint64_t filtered_rows() const {
return _stats.rows_del_filtered;
}
diff --git a/be/src/olap/rowset/alpha_rowset.cpp
b/be/src/olap/rowset/alpha_rowset.cpp
new file mode 100644
index 00000000..e387c6ff
--- /dev/null
+++ b/be/src/olap/rowset/alpha_rowset.cpp
@@ -0,0 +1,147 @@
+// 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<PSegmentGroup> 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();
+}
+
+} // 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
new file mode 100644
index 00000000..afe6dcab
--- /dev/null
+++ b/be/src/olap/rowset/alpha_rowset.h
@@ -0,0 +1,62 @@
+// 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;
+};
+
+}
+
+#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
new file mode 100644
index 00000000..383ff6e4
--- /dev/null
+++ b/be/src/olap/rowset/alpha_rowset_builder.cpp
@@ -0,0 +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();
+}
+
+} // 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
new file mode 100644
index 00000000..97fbe9cc
--- /dev/null
+++ b/be/src/olap/rowset/alpha_rowset_builder.h
@@ -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.
+
+#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
+
diff --git a/be/src/olap/rowset/alpha_rowset_meta.cpp
b/be/src/olap/rowset/alpha_rowset_meta.cpp
new file mode 100644
index 00000000..95ca4e31
--- /dev/null
+++ b/be/src/olap/rowset/alpha_rowset_meta.cpp
@@ -0,0 +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.
+
+#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<PSegmentGroup>*
segment_groups) {
+ for (auto& segment_group : _extra_meta_pb.segment_groups()) {
+ segment_groups->push_back(segment_group);
+ }
+}
+
+void AlphaRowsetMeta::add_segment_group(PSegmentGroup& segment_group) {
+ PSegmentGroup* 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
diff --git a/be/src/olap/rowset/alpha_rowset_meta.h
b/be/src/olap/rowset/alpha_rowset_meta.h
new file mode 100644
index 00000000..3399b90b
--- /dev/null
+++ b/be/src/olap/rowset/alpha_rowset_meta.h
@@ -0,0 +1,46 @@
+// 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<PSegmentGroup>* segment_groups)
+
+ void add_segment_group(const PSegmentGroup& segment_group);
+
+private:
+ void _serialize_extra_meta_pb();
+
+private:
+ AlphaRowsetExtraMetaPb _extra_meta_pb;
+};
+
+}
+
+#endif // DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_META_H
diff --git a/be/src/olap/rowset/alpha_rowset_reader.cpp
b/be/src/olap/rowset/alpha_rowset_reader.cpp
new file mode 100644
index 00000000..f6ceb93f
--- /dev/null
+++ b/be/src/olap/rowset/alpha_rowset_reader.cpp
@@ -0,0 +1,246 @@
+// 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();
+ }
+}
+
+} // 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
new file mode 100644
index 00000000..73dc75c0
--- /dev/null
+++ b/be/src/olap/rowset/alpha_rowset_reader.h
@@ -0,0 +1,78 @@
+// 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_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 <vector>
+
+namespace doris {
+
+class AlphaRowsetReader {
+public:
+ 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);
+
+ // reader init
+ virtual NewStatus init(ReaderContext* read_context);
+
+ // check whether rowset has more data
+ virtual bool has_next();
+
+ // read next block data
+ virtual NewStatus next(RowCursor* row);
+
+ // close reader
+ virtual void close();
+
+private:
+ NewStatus _init_segment_groups(ReaderContext* read_context);
+
+ NewStatus _init_column_datas(ReaderContext* read_context);
+
+ NewStatus _get_next_row_for_singleton_rowset(RowCursor row);
+
+ NewStatus _get_next_row_for_cumulative_rowset(RowCursor row);
+
+ NewStatus _get_next_block(ColumnData* column_data, RowBlock* row_block);
+
+ NewStatus _refresh_next_block(ColumnData* column_datam, RowBlock*
row_block);
+
+private:
+ RowFields _tablet_schema;
+ 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::unique_ptr<ColumnData>> _column_datas;
+ std::vector<RowBlock*> _row_blocks;
+ int _key_range_size;
+ int _key_range_index;
+ bool _is_cumulative_rowset;
+};
+
+}
+
+#endif // DORIS_BE_SRC_OLAP_ROWSET_ALPHA_ROWSET_READER_H
diff --git a/be/src/olap/bit_field_reader.cpp
b/be/src/olap/rowset/bit_field_reader.cpp
similarity index 96%
rename from be/src/olap/bit_field_reader.cpp
rename to be/src/olap/rowset/bit_field_reader.cpp
index 0252ec70..ca3ffcff 100644
--- a/be/src/olap/bit_field_reader.cpp
+++ b/be/src/olap/rowset/bit_field_reader.cpp
@@ -15,11 +15,11 @@
// specific language governing permissions and limitations
// under the License.
-#include "olap/bit_field_reader.h"
+#include "olap/rowset/bit_field_reader.h"
-#include "olap/column_reader.h"
+#include "olap/rowset/column_reader.h"
#include "olap/in_stream.h"
-#include "olap/run_length_byte_reader.h"
+#include "olap/rowset/run_length_byte_reader.h"
namespace doris {
diff --git a/be/src/olap/bit_field_reader.h
b/be/src/olap/rowset/bit_field_reader.h
similarity index 89%
rename from be/src/olap/bit_field_reader.h
rename to be/src/olap/rowset/bit_field_reader.h
index abc8a47e..349fdc47 100644
--- a/be/src/olap/bit_field_reader.h
+++ b/be/src/olap/rowset/bit_field_reader.h
@@ -15,8 +15,8 @@
// specific language governing permissions and limitations
// under the License.
-#ifndef DORIS_BE_SRC_OLAP_COLUMN_FILE_BIT_FIELD_READER_H
-#define DORIS_BE_SRC_OLAP_COLUMN_FILE_BIT_FIELD_READER_H
+#ifndef DORIS_BE_SRC_OLAP_ROWSET_BIT_FIELD_READER_H
+#define DORIS_BE_SRC_OLAP_ROWSET_BIT_FIELD_READER_H
#include "olap/stream_index_reader.h"
#include "olap/olap_define.h"
@@ -50,4 +50,4 @@ class BitFieldReader {
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_COLUMN_FILE_BIT_FIELD_READER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_BIT_FIELD_READER_H
diff --git a/be/src/olap/bit_field_writer.cpp
b/be/src/olap/rowset/bit_field_writer.cpp
similarity index 96%
rename from be/src/olap/bit_field_writer.cpp
rename to be/src/olap/rowset/bit_field_writer.cpp
index 81c098eb..54111438 100644
--- a/be/src/olap/bit_field_writer.cpp
+++ b/be/src/olap/rowset/bit_field_writer.cpp
@@ -15,9 +15,9 @@
// specific language governing permissions and limitations
// under the License.
-#include "bit_field_writer.h"
+#include "olap/rowset/bit_field_writer.h"
#include <gen_cpp/column_data_file.pb.h>
-#include "olap/run_length_byte_writer.h"
+#include "olap/rowset/run_length_byte_writer.h"
namespace doris {
diff --git a/be/src/olap/bit_field_writer.h
b/be/src/olap/rowset/bit_field_writer.h
similarity index 89%
rename from be/src/olap/bit_field_writer.h
rename to be/src/olap/rowset/bit_field_writer.h
index 02a6e95a..7348072f 100644
--- a/be/src/olap/bit_field_writer.h
+++ b/be/src/olap/rowset/bit_field_writer.h
@@ -15,8 +15,8 @@
// specific language governing permissions and limitations
// under the License.
-#ifndef DORIS_BE_SRC_OLAP_COLUMN_FILE_BIT_FIELD_WRITER_H
-#define DORIS_BE_SRC_OLAP_COLUMN_FILE_BIT_FIELD_WRITER_H
+#ifndef DORIS_BE_SRC_OLAP_ROWSET_BIT_FIELD_WRITER_H
+#define DORIS_BE_SRC_OLAP_ROWSET_BIT_FIELD_WRITER_H
#include "olap/stream_index_writer.h"
#include "olap/olap_define.h"
@@ -48,4 +48,4 @@ class BitFieldWriter {
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_COLUMN_FILE_BIT_FIELD_WRITER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_BIT_FIELD_WRITER_H
diff --git a/be/src/olap/column_data.cpp b/be/src/olap/rowset/column_data.cpp
similarity index 99%
rename from be/src/olap/column_data.cpp
rename to be/src/olap/rowset/column_data.cpp
index ae23a33a..95a853bc 100644
--- a/be/src/olap/column_data.cpp
+++ b/be/src/olap/rowset/column_data.cpp
@@ -15,9 +15,9 @@
// specific language governing permissions and limitations
// under the License.
-#include "column_data.h"
+#include "olap/rowset/column_data.h"
-#include "olap/segment_reader.h"
+#include "olap/rowset/segment_reader.h"
#include "olap/olap_cond.h"
#include "olap/tablet.h"
#include "olap/row_block.h"
diff --git a/be/src/olap/column_data.h b/be/src/olap/rowset/column_data.h
similarity index 97%
rename from be/src/olap/column_data.h
rename to be/src/olap/rowset/column_data.h
index d792171f..7ebe6dab 100644
--- a/be/src/olap/column_data.h
+++ b/be/src/olap/rowset/column_data.h
@@ -15,8 +15,8 @@
// specific language governing permissions and limitations
// under the License.
-#ifndef DORIS_BE_SRC_OLAP_COLUMN_FILE_COLUMN_DATA_H
-#define DORIS_BE_SRC_OLAP_COLUMN_FILE_COLUMN_DATA_H
+#ifndef DORIS_BE_SRC_OLAP_ROWSET_COLUMN_DATA_H
+#define DORIS_BE_SRC_OLAP_ROWSET_COLUMN_DATA_H
#include <string>
#include <string>
@@ -26,7 +26,7 @@
#include "olap/delete_handler.h"
#include "olap/olap_common.h"
#include "olap/olap_cond.h"
-#include "olap/segment_group.h"
+#include "olap/rowset/segment_group.h"
#include "olap/row_block.h"
#include "olap/row_cursor.h"
#include "util/runtime_profile.h"
@@ -256,4 +256,4 @@ class ColumnDataComparator {
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_COLUMN_FILE_COLUMN_DATA_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_COLUMN_DATA_H
diff --git a/be/src/olap/column_reader.cpp
b/be/src/olap/rowset/column_reader.cpp
similarity index 99%
rename from be/src/olap/column_reader.cpp
rename to be/src/olap/rowset/column_reader.cpp
index 38e9cd35..5b00e395 100644
--- a/be/src/olap/column_reader.cpp
+++ b/be/src/olap/rowset/column_reader.cpp
@@ -15,10 +15,11 @@
// specific language governing permissions and limitations
// under the License.
+#include "olap/rowset/column_reader.h"
+
#include <cstring>
-#include "olap/bit_field_reader.h"
-#include "olap/column_reader.h"
+#include "olap/rowset/bit_field_reader.h"
#include "olap/file_stream.h"
#include "olap/olap_define.h"
diff --git a/be/src/olap/column_reader.h b/be/src/olap/rowset/column_reader.h
similarity index 99%
rename from be/src/olap/column_reader.h
rename to be/src/olap/rowset/column_reader.h
index 566dde1d..c0b2b840 100644
--- a/be/src/olap/column_reader.h
+++ b/be/src/olap/rowset/column_reader.h
@@ -15,13 +15,13 @@
// specific language governing permissions and limitations
// under the License.
-#ifndef DORIS_BE_SRC_OLAP_COLUMN_FILE_COLUMN_READER_H
-#define DORIS_BE_SRC_OLAP_COLUMN_FILE_COLUMN_READER_H
+#ifndef DORIS_BE_SRC_OLAP_ROWSET_COLUMN_READER_H
+#define DORIS_BE_SRC_OLAP_ROWSET_COLUMN_READER_H
#include "olap/byte_buffer.h"
#include "olap/file_stream.h"
-#include "olap/run_length_byte_reader.h"
-#include "olap/run_length_integer_reader.h"
+#include "olap/rowset/run_length_byte_reader.h"
+#include "olap/rowset/run_length_integer_reader.h"
#include "olap/stream_name.h"
#include "olap/field.h"
#include "olap/olap_common.h"
@@ -920,4 +920,4 @@ typedef IntegerColumnReaderWrapper<uint64_t, false>
DateTimeColumnReader;
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_COLUMN_FILE_COLUMN_READER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_COLUMN_READER_H
diff --git a/be/src/olap/column_writer.cpp
b/be/src/olap/rowset/column_writer.cpp
similarity index 99%
rename from be/src/olap/column_writer.cpp
rename to be/src/olap/rowset/column_writer.cpp
index 91ed9291..652fb03c 100755
--- a/be/src/olap/column_writer.cpp
+++ b/be/src/olap/rowset/column_writer.cpp
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-#include "olap/column_writer.h"
+#include "olap/rowset/column_writer.h"
#include "olap/bit_field_writer.h"
#include "olap/file_helper.h"
diff --git a/be/src/olap/column_writer.h b/be/src/olap/rowset/column_writer.h
similarity index 98%
rename from be/src/olap/column_writer.h
rename to be/src/olap/rowset/column_writer.h
index 4ec0e538..acba5f6f 100644
--- a/be/src/olap/column_writer.h
+++ b/be/src/olap/rowset/column_writer.h
@@ -15,8 +15,8 @@
// specific language governing permissions and limitations
// under the License.
-#ifndef DORIS_BE_SRC_OLAP_COLUMN_FILE_COLUMN_WRITER_H
-#define DORIS_BE_SRC_OLAP_COLUMN_FILE_COLUMN_WRITER_H
+#ifndef DORIS_BE_SRC_OLAP_ROWSET_COLUMN_WRITER_H
+#define DORIS_BE_SRC_OLAP_ROWSET_COLUMN_WRITER_H
#include <gen_cpp/column_data_file.pb.h>
@@ -26,8 +26,8 @@
#include "olap/bloom_filter_writer.h"
#include "olap/out_stream.h"
#include "olap/stream_index_writer.h"
-#include "olap/run_length_byte_writer.h"
-#include "olap/run_length_integer_writer.h"
+#include "olap/rowset/run_length_byte_writer.h"
+#include "olap/rowset/run_length_integer_writer.h"
#include "olap/field.h"
#include "olap/olap_common.h"
#include "olap/olap_define.h"
@@ -648,4 +648,4 @@ class LargeIntColumnWriter : public ColumnWriter {
};
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_COLUMN_FILE_COLUMN_WRITER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_COLUMN_WRITER_H
diff --git a/be/src/olap/data_writer.cpp b/be/src/olap/rowset/data_writer.cpp
similarity index 98%
rename from be/src/olap/data_writer.cpp
rename to be/src/olap/rowset/data_writer.cpp
index 53694f92..04232ebc 100644
--- a/be/src/olap/data_writer.cpp
+++ b/be/src/olap/rowset/data_writer.cpp
@@ -15,12 +15,12 @@
// specific language governing permissions and limitations
// under the License.
-#include "olap/data_writer.h"
+#include "olap/rowset/data_writer.h"
#include <math.h>
-#include "olap/segment_writer.h"
-#include "olap/segment_group.h"
+#include "olap/rowset/segment_writer.h"
+#include "olap/rowset/segment_group.h"
#include "olap/row_block.h"
diff --git a/be/src/olap/data_writer.h b/be/src/olap/rowset/data_writer.h
similarity index 93%
rename from be/src/olap/data_writer.h
rename to be/src/olap/rowset/data_writer.h
index bc5132cd..afe0178e 100644
--- a/be/src/olap/data_writer.h
+++ b/be/src/olap/rowset/data_writer.h
@@ -15,8 +15,8 @@
// specific language governing permissions and limitations
// under the License.
-#ifndef DORIS_BE_SRC_OLAP_COLUMN_FILE_DATA_WRITER_H
-#define DORIS_BE_SRC_OLAP_COLUMN_FILE_DATA_WRITER_H
+#ifndef DORIS_BE_SRC_OLAP_ROWSET_DATA_WRITER_H
+#define DORIS_BE_SRC_OLAP_ROWSET_DATA_WRITER_H
#include "olap/tablet.h"
#include "olap/row_block.h"
@@ -69,4 +69,4 @@ class ColumnDataWriter {
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_COLUMN_FILE_DATA_WRITER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_DATA_WRITER_H
diff --git a/be/src/olap/rowset/rowset_builder.h
b/be/src/olap/rowset/rowset_builder.h
index d8697f89..3e0005aa 100644
--- a/be/src/olap/rowset/rowset_builder.h
+++ b/be/src/olap/rowset/rowset_builder.h
@@ -18,7 +18,7 @@
#ifndef DORIS_BE_SRC_OLAP_ROWSET_ROWSET_BUILDER_H
#define DORIS_BE_SRC_OLAP_ROWSET_ROWSET_BUILDER_H
-#include "rowset/rowset.h"
+#include "olap/rowset/rowset.h"
#include "olap/new_status.h"
#include "olap/schema.h"
#include "olap/row_block.h"
@@ -29,7 +29,7 @@ class RowsetBuilder {
public:
virtual ~RowsetBuilder() { }
- virtual NewStatus init(std::string rowset_id, const std::string&
rowset_path_prefix, Schema* schema) = 0;
+ virtual NewStatus init(int64_t rowset_id, const std::string&
rowset_path_prefix, Schema* schema) = 0;
// add a row block to rowset
virtual NewStatus add_row_block(RowBlock* row_block) = 0;
diff --git a/be/src/olap/rowset/rowset_meta.h b/be/src/olap/rowset/rowset_meta.h
index abfc2030..81355be3 100644
--- a/be/src/olap/rowset/rowset_meta.h
+++ b/be/src/olap/rowset/rowset_meta.h
@@ -30,6 +30,8 @@
namespace doris {
+typedef std::shared_ptr<RowsetMeta> RowsetMetaSharedPtr;
+
class RowsetMeta {
public:
virtual ~RowsetMeta() { }
diff --git a/be/src/olap/rowset/rowset_reader.h
b/be/src/olap/rowset/rowset_reader.h
index b168cea3..1586f3dd 100644
--- a/be/src/olap/rowset/rowset_reader.h
+++ b/be/src/olap/rowset/rowset_reader.h
@@ -23,32 +23,47 @@
#include "olap/column_predicate.h"
#include "olap/row_cursor.h"
#include "olap/row_block.h"
+#include "runtime/runtime_state.h"
#include <memory>
#include <unordered_map>
namespace doris {
-struct ReadContext {
- const Schema* projection;
- std::unordered_map<std::string, ColumnPredicate> predicates; // column
name -> column predicate
- const RowCursor* lower_bound_key;
- const RowCursor* exclusive_upper_bound_key;
+struct ReaderContext {
+ const RowFields& tablet_schema;
+ // projection columns
+ const std::vector<uint32_t>& return_columns;
+ // columns to load bloom filter index
+ // including columns in "=" or "in" conditions
+ const std::set<uint32_t>& load_bf_columns;
+ // column filter conditions by delete sql
+ const Conditions& conditions;
+ // column name -> column predicate
+ // adding column_name for predicate to make use of column selectivity
+ std::unordered_map<std::string, ColumnPredicate&> predicates;
+ const std::vector<RowCursor*>& lower_bound_keys;
+ std::vector<bool> is_lower_keys_included;
+ const std::vector<RowCursor*>& upper_bound_keys;
+ std::vector<bool> is_upper_keys_included;
+ const DeleteHandler& delete_handler;
+ OlapReaderStatistics* stats;
+ bool is_using_cache;
+ RuntimeState* runtime_state;
};
class RowsetReader {
public:
virtual ~RowsetReader() { }
-
+
// reader init
- // check whether this rowset can be filtered
- virtual NewStatus init(ReadContext* read_context) = 0;
+ virtual NewStatus init(ReaderContext* read_context) = 0;
// check whether rowset has more data
virtual bool has_next() = 0;
// read next block data
- virtual NewStatus next_block(RowBlock* row_block) = 0;
+ virtual NewStatus next(RowCursor* row) = 0;
// close reader
virtual void close() = 0;
diff --git a/be/src/olap/run_length_byte_reader.cpp
b/be/src/olap/rowset/run_length_byte_reader.cpp
similarity index 97%
rename from be/src/olap/run_length_byte_reader.cpp
rename to be/src/olap/rowset/run_length_byte_reader.cpp
index bfd7e61c..26a5725f 100644
--- a/be/src/olap/run_length_byte_reader.cpp
+++ b/be/src/olap/rowset/run_length_byte_reader.cpp
@@ -15,9 +15,9 @@
// specific language governing permissions and limitations
// under the License.
-#include "olap/run_length_byte_reader.h"
+#include "olap/rowset/run_length_byte_reader.h"
-#include "olap/column_reader.h"
+#include "olap/rowset/column_reader.h"
#include "olap/in_stream.h"
namespace doris {
diff --git a/be/src/olap/run_length_byte_reader.h
b/be/src/olap/rowset/run_length_byte_reader.h
similarity index 88%
rename from be/src/olap/run_length_byte_reader.h
rename to be/src/olap/rowset/run_length_byte_reader.h
index f20e2a34..3e8eae42 100644
--- a/be/src/olap/run_length_byte_reader.h
+++ b/be/src/olap/rowset/run_length_byte_reader.h
@@ -15,11 +15,11 @@
// specific language governing permissions and limitations
// under the License.
-#ifndef DORIS_BE_SRC_OLAP_COLUMN_FILE_RUN_LENGTH_BYTE_READER_H
-#define DORIS_BE_SRC_OLAP_COLUMN_FILE_RUN_LENGTH_BYTE_READER_H
+#ifndef DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_BYTE_READER_H
+#define DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_BYTE_READER_H
#include "olap/file_stream.h"
-#include "olap/run_length_byte_writer.h"
+#include "olap/rowset/run_length_byte_writer.h"
#include "olap/olap_define.h"
namespace doris {
@@ -54,4 +54,4 @@ class RunLengthByteReader {
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_COLUMN_FILE_RUN_LENGTH_BYTE_READER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_BYTE_READER_H
diff --git a/be/src/olap/run_length_byte_writer.cpp
b/be/src/olap/rowset/run_length_byte_writer.cpp
similarity index 98%
rename from be/src/olap/run_length_byte_writer.cpp
rename to be/src/olap/rowset/run_length_byte_writer.cpp
index b9f9ef58..e8efc79e 100644
--- a/be/src/olap/run_length_byte_writer.cpp
+++ b/be/src/olap/rowset/run_length_byte_writer.cpp
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-#include "olap/run_length_byte_writer.h"
+#include "olap/rowset/run_length_byte_writer.h"
#include "olap/out_stream.h"
diff --git a/be/src/olap/run_length_byte_writer.h
b/be/src/olap/rowset/run_length_byte_writer.h
similarity index 90%
rename from be/src/olap/run_length_byte_writer.h
rename to be/src/olap/rowset/run_length_byte_writer.h
index 6002ed65..b0875f8c 100644
--- a/be/src/olap/run_length_byte_writer.h
+++ b/be/src/olap/rowset/run_length_byte_writer.h
@@ -15,8 +15,8 @@
// specific language governing permissions and limitations
// under the License.
-#ifndef DORIS_BE_SRC_OLAP_COLUMN_FILE_RUN_LENGTH_BYTE_WRITER_H
-#define DORIS_BE_SRC_OLAP_COLUMN_FILE_RUN_LENGTH_BYTE_WRITER_H
+#ifndef DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_BYTE_WRITER_H
+#define DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_BYTE_WRITER_H
#include "olap/stream_index_writer.h"
#include "olap/olap_define.h"
@@ -53,4 +53,4 @@ class RunLengthByteWriter {
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_COLUMN_FILE_RUN_LENGTH_BYTE_WRITER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_BYTE_WRITER_H
diff --git a/be/src/olap/run_length_integer_reader.cpp
b/be/src/olap/rowset/run_length_integer_reader.cpp
similarity index 99%
rename from be/src/olap/run_length_integer_reader.cpp
rename to be/src/olap/rowset/run_length_integer_reader.cpp
index e7e34f6b..06d66e9e 100644
--- a/be/src/olap/run_length_integer_reader.cpp
+++ b/be/src/olap/rowset/run_length_integer_reader.cpp
@@ -15,9 +15,9 @@
// specific language governing permissions and limitations
// under the License.
-#include "olap/run_length_integer_reader.h"
+#include "olap/rowset/run_length_integer_reader.h"
-#include "olap/column_reader.h"
+#include "olap/rowset/column_reader.h"
#include "olap/in_stream.h"
#include "olap/serialize.h"
diff --git a/be/src/olap/run_length_integer_reader.h
b/be/src/olap/rowset/run_length_integer_reader.h
similarity index 90%
rename from be/src/olap/run_length_integer_reader.h
rename to be/src/olap/rowset/run_length_integer_reader.h
index 1e16f8b9..4a557bdb 100644
--- a/be/src/olap/run_length_integer_reader.h
+++ b/be/src/olap/rowset/run_length_integer_reader.h
@@ -15,11 +15,11 @@
// specific language governing permissions and limitations
// under the License.
-#ifndef DORIS_BE_SRC_OLAP_COLUMN_FILE_RUN_LENGTH_INTEGER_READER_H
-#define DORIS_BE_SRC_OLAP_COLUMN_FILE_RUN_LENGTH_INTEGER_READER_H
+#ifndef DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_INTEGER_READER_H
+#define DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_INTEGER_READER_H
#include "olap/file_stream.h"
-#include "olap/run_length_integer_writer.h"
+#include "olap/rowset/run_length_integer_writer.h"
#include "olap/stream_index_reader.h"
#include "olap/olap_define.h"
#include "util/runtime_profile.h"
@@ -74,4 +74,4 @@ class RunLengthIntegerReader {
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_COLUMN_FILE_RUN_LENGTH_INTEGER_READER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_INTEGER_READER_H
diff --git a/be/src/olap/run_length_integer_writer.cpp
b/be/src/olap/rowset/run_length_integer_writer.cpp
similarity index 99%
rename from be/src/olap/run_length_integer_writer.cpp
rename to be/src/olap/rowset/run_length_integer_writer.cpp
index f58ece50..d1901786 100644
--- a/be/src/olap/run_length_integer_writer.cpp
+++ b/be/src/olap/rowset/run_length_integer_writer.cpp
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-#include "olap/run_length_integer_writer.h"
+#include "olap/rowset/run_length_integer_writer.h"
#include <cmath>
diff --git a/be/src/olap/run_length_integer_writer.h
b/be/src/olap/rowset/run_length_integer_writer.h
similarity index 98%
rename from be/src/olap/run_length_integer_writer.h
rename to be/src/olap/rowset/run_length_integer_writer.h
index 60d61ed0..4e484e5e 100644
--- a/be/src/olap/run_length_integer_writer.h
+++ b/be/src/olap/rowset/run_length_integer_writer.h
@@ -15,8 +15,8 @@
// specific language governing permissions and limitations
// under the License.
-#ifndef DORIS_BE_SRC_OLAP_COLUMN_FILE_RUN_LENGTH_INTEGER_WRITER_H
-#define DORIS_BE_SRC_OLAP_COLUMN_FILE_RUN_LENGTH_INTEGER_WRITER_H
+#ifndef DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_INTEGER_WRITER_H
+#define DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_INTEGER_WRITER_H
#include <endian.h>
@@ -296,4 +296,4 @@ class RunLengthIntegerWriter {
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_COLUMN_FILE_RUN_LENGTH_INTEGER_WRITER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_RUN_LENGTH_INTEGER_WRITER_H
diff --git a/be/src/olap/segment_group.cpp
b/be/src/olap/rowset/segment_group.cpp
similarity index 75%
rename from be/src/olap/segment_group.cpp
rename to be/src/olap/rowset/segment_group.cpp
index 6d7535e3..5fb3db1a 100644
--- a/be/src/olap/segment_group.cpp
+++ b/be/src/olap/rowset/segment_group.cpp
@@ -22,7 +22,7 @@
#include <cmath>
#include <fstream>
-#include "olap/column_data.h"
+#include "olap/rowset/column_data.h"
#include "olap/tablet.h"
#include "olap/row_block.h"
#include "olap/row_cursor.h"
@@ -35,12 +35,11 @@ using std::vector;
namespace doris {
-#define TABLE_PARAM_VALIDATE() \
+#define SEGMENT_GROUP_PARAM_VALIDATE() \
do { \
if (!_index_loaded) { \
- OLAP_LOG_WARNING("fail to find, index is not loaded. [tablet=%ld
schema_hash=%d]", \
- _tablet->tablet_id(), \
- _tablet->schema_hash()); \
+ OLAP_LOG_WARNING("fail to find, index is not loaded.
[segment_group_id=%d]", \
+ _segment_group_id); \
return OLAP_ERR_NOT_INITED; \
} \
} while (0);
@@ -61,9 +60,15 @@ namespace doris {
} \
} while (0);
-SegmentGroup::SegmentGroup(Tablet* tablet, Version version, VersionHash
version_hash,
- bool delete_flag, int32_t segment_group_id, int32_t
num_segments)
- : _tablet(tablet),
+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,
+ bool delete_flag, int32_t segment_group_id, int32_t num_segments)
+ : _tablet_id(tablet_id),
+ _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_prefix(rowset_path_prefix),
_version(version),
_version_hash(version_hash),
_delete_flag(delete_flag),
@@ -81,27 +86,31 @@ SegmentGroup::SegmentGroup(Tablet* tablet, Version version,
VersionHash version_
_new_segment_created = false;
_empty = false;
- const RowFields& tablet_schema = _tablet->tablet_schema();
- for (size_t i = 0; i < _tablet->num_short_key_fields(); ++i) {
- _short_key_info_list.push_back(tablet_schema[i]);
- _short_key_length += tablet_schema[i].index_length + 1;// 1 for null
byte
- if (tablet_schema[i].type == OLAP_FIELD_TYPE_CHAR ||
- tablet_schema[i].type == OLAP_FIELD_TYPE_VARCHAR) {
+ for (size_t i = 0; i < _num_short_key_fields; ++i) {
+ _short_key_info_list.push_back(_tablet_schema[i]);
+ _short_key_length += _tablet_schema[i].index_length + 1;// 1 for null
byte
+ if (_tablet_schema[i].type == OLAP_FIELD_TYPE_CHAR ||
+ _tablet_schema[i].type == OLAP_FIELD_TYPE_VARCHAR) {
_new_short_key_length += sizeof(Slice) + 1;
} else {
- _new_short_key_length += tablet_schema[i].index_length + 1;
+ _new_short_key_length += _tablet_schema[i].index_length + 1;
}
}
}
-SegmentGroup::SegmentGroup(Tablet* tablet, bool delete_flag,
- int32_t segment_group_id, int32_t num_segments, bool
is_pending,
- TPartitionId partition_id, TTransactionId transaction_id)
- : _tablet(tablet), _delete_flag(delete_flag),
- _segment_group_id(segment_group_id), _num_segments(num_segments),
- _is_pending(is_pending), _partition_id(partition_id),
- _transaction_id(transaction_id)
-{
+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,
+ 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),
+ _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_prefix(rowset_path_prefix),
+ _delete_flag(delete_flag),
+ _segment_group_id(segment_group_id), _num_segments(num_segments),
+ _is_pending(is_pending), _partition_id(partition_id),
+ _transaction_id(transaction_id) {
_version = {-1, -1};
_version_hash = 0;
_load_id.set_hi(0);
@@ -115,15 +124,14 @@ SegmentGroup::SegmentGroup(Tablet* tablet, bool
delete_flag,
_new_segment_created = false;
_empty = false;
- const RowFields& tablet_schema = _tablet->tablet_schema();
- for (size_t i = 0; i < _tablet->num_short_key_fields(); ++i) {
- _short_key_info_list.push_back(tablet_schema[i]);
- _short_key_length += tablet_schema[i].index_length + 1;// 1 for null
byte
- if (tablet_schema[i].type == OLAP_FIELD_TYPE_CHAR ||
- tablet_schema[i].type == OLAP_FIELD_TYPE_VARCHAR) {
+ for (size_t i = 0; i < _num_key_fields; ++i) {
+ _short_key_info_list.push_back(_tablet_schema[i]);
+ _short_key_length += _tablet_schema[i].index_length + 1;// 1 for null
byte
+ if (_tablet_schema[i].type == OLAP_FIELD_TYPE_CHAR ||
+ _tablet_schema[i].type == OLAP_FIELD_TYPE_VARCHAR) {
_new_short_key_length += sizeof(Slice) + 1;
} else {
- _new_short_key_length += tablet_schema[i].index_length + 1;
+ _new_short_key_length += _tablet_schema[i].index_length + 1;
}
}
}
@@ -139,19 +147,58 @@ SegmentGroup::~SegmentGroup() {
_seg_pb_map.clear();
}
-string SegmentGroup::construct_index_file_path(int32_t segment_group_id,
int32_t segment) const {
+std::string SegmentGroup::_construct_pending_file_path(int32_t segment_id,
const std::string& suffix) {
+ std::string pending_dir_path = _rowset_path_prefix + PENDING_DELTA_PREFIX;
+ 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;
+ prefix_stream << _rowset_path_prefix << "/" << _tablet_id;
+ string path_prefix = prefix_stream.str();
+ char file_path[OLAP_MAX_PATH_LEN];
+ if (_segment_group_id == -1) {
+ snprintf(file_path,
+ sizeof(file_path),
+ "%s_%ld_%ld_%ld_%d.%s",
+ path_prefix.c_str(),
+ _version.first,
+ _version.second,
+ _version_hash,
+ segment_id,
+ suffix.c_str());
+ } else {
+ snprintf(file_path,
+ sizeof(file_path),
+ "%s_%ld_%ld_%ld_%d_%d.%s",
+ path_prefix.c_str(),
+ _version.first,
+ _version.second,
+ _version_hash,
+ _segment_group_id, segment_id,
+ suffix.c_str());
+ }
+
+ return file_path;
+}
+
+string SegmentGroup::construct_index_file_path(int32_t segment_group_id,
int32_t segment_id) const {
if (_is_pending) {
- return _tablet->construct_pending_index_file_path(_transaction_id,
_segment_group_id, segment);
+ return _construct_pending_file_path(segment_id, ".idx");
} else {
- return _tablet->construct_index_file_path(_version, _version_hash,
_segment_group_id, segment);
+ return _construct_file_path(segment_id, ".idx");
}
}
-string SegmentGroup::construct_data_file_path(int32_t segment_group_id,
int32_t segment) const {
+string SegmentGroup::construct_data_file_path(int32_t segment_group_id,
int32_t segment_id) const {
if (_is_pending) {
- return _tablet->construct_pending_data_file_path(_transaction_id,
segment_group_id, segment);
+ return _construct_pending_file_path(segment_id, ".dat");
} else {
- return _tablet->construct_data_file_path(_version, _version_hash,
segment_group_id, segment);
+ return _construct_file_path(segment_id, ".dat");
}
}
@@ -205,15 +252,15 @@ OLAPStatus
SegmentGroup::add_column_statistics_for_linked_schema_change(
return OLAP_SUCCESS;
}
- //Should use _tablet->num_key_fields(), not column_statistic_fields.size()
+ //Should use _num_key_fields, not column_statistic_fields.size()
//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 < _tablet->num_key_fields(); ++i) {
- WrapperField* first =
WrapperField::create(_tablet->tablet_schema()[i]);
+ for (size_t i = 0; i < _num_key_fields; ++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->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);
@@ -224,13 +271,13 @@ OLAPStatus
SegmentGroup::add_column_statistics_for_linked_schema_change(
OLAPStatus SegmentGroup::add_column_statistics(
const std::vector<std::pair<WrapperField*, WrapperField*>>&
column_statistic_fields) {
- DCHECK(column_statistic_fields.size() == _tablet->num_key_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->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->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);
@@ -242,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() == _tablet->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->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->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));
@@ -276,28 +323,26 @@ OLAPStatus SegmentGroup::load() {
}
if (_index.init(_short_key_length, _new_short_key_length,
- _tablet->num_short_key_fields(), &_short_key_info_list) !=
OLAP_SUCCESS) {
+ _num_short_key_fields, &_short_key_info_list) !=
OLAP_SUCCESS) {
OLAP_LOG_WARNING("fail to create MemIndex. [num_segment=%d]",
_num_segments);
return res;
}
// for each segment
for (uint32_t seg_id = 0; seg_id < _num_segments; ++seg_id) {
- if (COLUMN_ORIENTED_FILE == _tablet->data_file_type()) {
- string seg_path = construct_data_file_path(_segment_group_id,
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 << "']";
- _check_io_error(res);
- return res;
- }
+ string seg_path = construct_data_file_path(_segment_group_id, 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 << "']";
+
+ return res;
}
-
+
// 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))
!= OLAP_SUCCESS) {
LOG(WARNING) << "fail to load segment. [path='" << path << "']";
- _check_io_error(res);
+
return res;
}
}
@@ -352,15 +397,13 @@ OLAPStatus SegmentGroup::validate() {
// 检查index文件头
if ((res = index_file_header.validate(index_path)) != OLAP_SUCCESS) {
- LOG(WARNING) << "validate index file error. [file='" << index_path
<< "']";
- _check_io_error(res);
+ LOG(WARNING) << "validate index file error. [file='" << index_path
<< "']";
return res;
}
// 检查data文件头
if ((res = data_file_header.validate(data_path)) != OLAP_SUCCESS) {
- LOG(WARNING) << "validate data file error. [file='" << data_path
<< "']";
- _check_io_error(res);
+ LOG(WARNING) << "validate data file error. [file='" << data_path
<< "']";
return res;
}
}
@@ -372,7 +415,7 @@ OLAPStatus SegmentGroup::find_row_block(const RowCursor&
key,
RowCursor* helper_cursor,
bool find_last,
RowBlockPosition* pos) const {
- TABLE_PARAM_VALIDATE();
+ SEGMENT_GROUP_PARAM_VALIDATE();
POS_PARAM_VALIDATE(pos);
// 将这部分逻辑从memindex移出来,这样可以复用find。
@@ -397,7 +440,7 @@ OLAPStatus SegmentGroup::find_short_key(const RowCursor&
key,
RowCursor* helper_cursor,
bool find_last,
RowBlockPosition* pos) const {
- TABLE_PARAM_VALIDATE();
+ SEGMENT_GROUP_PARAM_VALIDATE();
POS_PARAM_VALIDATE(pos);
// 由于find会从前一个segment找起,如果前一个segment中恰好没有该key,
@@ -417,28 +460,28 @@ OLAPStatus SegmentGroup::find_short_key(const RowCursor&
key,
}
OLAPStatus SegmentGroup::get_row_block_entry(const RowBlockPosition& pos,
EntrySlice* entry) const {
- TABLE_PARAM_VALIDATE();
+ SEGMENT_GROUP_PARAM_VALIDATE();
SLICE_PARAM_VALIDATE(entry);
return _index.get_entry(_index.get_offset(pos), entry);
}
OLAPStatus SegmentGroup::find_first_row_block(RowBlockPosition* position)
const {
- TABLE_PARAM_VALIDATE();
+ SEGMENT_GROUP_PARAM_VALIDATE();
POS_PARAM_VALIDATE(position);
return _index.get_row_block_position(_index.find_first(), position);
}
OLAPStatus SegmentGroup::find_last_row_block(RowBlockPosition* position) const
{
- TABLE_PARAM_VALIDATE();
+ SEGMENT_GROUP_PARAM_VALIDATE();
POS_PARAM_VALIDATE(position);
return _index.get_row_block_position(_index.find_last(), position);
}
OLAPStatus SegmentGroup::find_next_row_block(RowBlockPosition* pos, bool* eof)
const {
- TABLE_PARAM_VALIDATE();
+ SEGMENT_GROUP_PARAM_VALIDATE();
POS_PARAM_VALIDATE(pos);
POS_PARAM_VALIDATE(eof);
@@ -480,7 +523,7 @@ OLAPStatus SegmentGroup::find_prev_point(
}
OLAPStatus SegmentGroup::advance_row_block(int64_t num_row_blocks,
RowBlockPosition* position) const {
- TABLE_PARAM_VALIDATE();
+ SEGMENT_GROUP_PARAM_VALIDATE();
POS_PARAM_VALIDATE(position);
OLAPIndexOffset off = _index.get_offset(*position);
@@ -512,7 +555,7 @@ OLAPStatus SegmentGroup::add_segment() {
index_header->set_end_version(_version.second);
index_header->set_cumulative_version_hash(_version_hash);
index_header->set_segment(_num_segments - 1);
- index_header->set_num_rows_per_block(_tablet->num_rows_per_row_block());
+ index_header->set_num_rows_per_block(_num_rows_per_row_block);
index_header->set_delete_flag(_delete_flag);
index_header->set_null_supported(true);
@@ -524,7 +567,7 @@ OLAPStatus SegmentGroup::add_segment() {
return OLAP_ERR_MALLOC_ERROR;
}
- if (_current_index_row.init(_tablet->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;
}
@@ -551,7 +594,6 @@ OLAPStatus SegmentGroup::add_short_key(const RowCursor&
short_key, const uint32_
char errmsg[64];
LOG(WARNING) << "can not create file. [file_path='" << file_path
<< "' err='" << strerror_r(errno, errmsg, 64) << "']";
- _check_io_error(res);
return res;
}
_new_segment_created = true;
@@ -559,7 +601,6 @@ OLAPStatus SegmentGroup::add_short_key(const RowCursor&
short_key, const uint32_
// 准备FileHeader
if ((res = _file_header.prepare(&_current_file_handler)) !=
OLAP_SUCCESS) {
OLAP_LOG_WARNING("write file header error. [err=%m]");
- _check_io_error(res);
return res;
}
@@ -567,7 +608,6 @@ OLAPStatus SegmentGroup::add_short_key(const RowCursor&
short_key, const uint32_
if (_current_file_handler.seek(_file_header.size(), SEEK_SET) == -1) {
OLAP_LOG_WARNING("lseek header file error. [err=%m]");
res = OLAP_ERR_IO_ERROR;
- _check_io_error(res);
return res;
}
}
@@ -585,14 +625,13 @@ OLAPStatus SegmentGroup::add_short_key(const RowCursor&
short_key, const uint32_
// 写入Short Key对应的数据
if ((res = _current_file_handler.write(_short_key_buf, _short_key_length))
!= OLAP_SUCCESS) {
OLAP_LOG_WARNING("write short key failed. [err=%m]");
- _check_io_error(res);
+
return res;
}
// 写入对应的数据文件偏移量
if ((res = _current_file_handler.write(&data_offset, sizeof(data_offset)))
!= OLAP_SUCCESS) {
OLAP_LOG_WARNING("write data_offset failed. [err=%m]");
- _check_io_error(res);
return res;
}
@@ -610,7 +649,7 @@ OLAPStatus SegmentGroup::finalize_segment(uint32_t
data_segment_size, int64_t nu
int file_length = _current_file_handler.tell();
if (file_length == -1) {
OLAP_LOG_WARNING("get file_length error. [err=%m]");
- _check_io_error(res);
+
return OLAP_ERR_IO_ERROR;
}
@@ -622,7 +661,7 @@ OLAPStatus SegmentGroup::finalize_segment(uint32_t
data_segment_size, int64_t nu
// 写入更新之后的FileHeader
if ((res = _file_header.serialize(&_current_file_handler)) !=
OLAP_SUCCESS) {
OLAP_LOG_WARNING("write file header error. [err=%m]");
- _check_io_error(res);
+
return res;
}
@@ -631,7 +670,7 @@ OLAPStatus SegmentGroup::finalize_segment(uint32_t
data_segment_size, int64_t nu
if ((res = _current_file_handler.close()) != OLAP_SUCCESS) {
OLAP_LOG_WARNING("close file error. [err=%m]");
- _check_io_error(res);
+
return res;
}
@@ -639,21 +678,32 @@ OLAPStatus SegmentGroup::finalize_segment(uint32_t
data_segment_size, int64_t nu
return OLAP_SUCCESS;
}
-void SegmentGroup::sync() {
- if (_current_file_handler.sync() == -1) {
- OLAP_LOG_WARNING("fail to sync file.[err=%m]");
- _tablet->set_io_error();
- }
+uint64_t SegmentGroup::num_index_entries() const {
+ return _index.count();
}
-void SegmentGroup::_check_io_error(OLAPStatus res) {
- if (is_io_error(res)) {
- _tablet->set_io_error();
- }
+const RowFields& SegmentGroup::get_tablet_schema() {
+ return _tablet_schema;
}
-uint64_t SegmentGroup::num_index_entries() const {
- return _index.count();
+int SegmentGroup::get_num_key_fields)() {
+ return _num_key_fields;
+}
+
+int SegmentGroup::get_num_short_key_fields() {
+ return _num_short_key_fields;
+}
+
+int SegmentGroup::get_num_rows_per_row_block() {
+ return _num_rows_per_row_block;
+}
+
+std::string SegmentGroup::get_rowset_path_prefix() {
+ return _rowset_path_prefix;
+}
+
+int64_t SegmentGroup::get_tablet_id() {
+ return _tablet_id;
}
}
diff --git a/be/src/olap/segment_group.h b/be/src/olap/rowset/segment_group.h
similarity index 85%
rename from be/src/olap/segment_group.h
rename to be/src/olap/rowset/segment_group.h
index 2239befe..59a16a6d 100644
--- a/be/src/olap/segment_group.h
+++ b/be/src/olap/rowset/segment_group.h
@@ -15,7 +15,8 @@
// specific language governing permissions and limitations
// under the License.
-#pragma once
+#ifndef DORIS_BE_SRC_OLAP_ROWSET_SEGMENT_GROUP_H
+#define DORIS_BE_SRC_OLAP_ROWSET_SEGMENT_GROUP_H
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/mutex.hpp>
@@ -32,7 +33,6 @@
#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/olap_index.h"
#include "olap/utils.h"
@@ -47,12 +47,14 @@ namespace doris {
class SegmentGroup {
friend class MemIndex;
public:
- SegmentGroup(Tablet* tablet, 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,
Version version,
+ VersionHash version_hash, bool delete_flag, int segment_group_id,
int32_t num_segments);
- SegmentGroup(Tablet* tablet, bool delete_flag, int32_t segment_group_id,
- int32_t num_segments, bool is_pending,
- TPartitionId partition_id, TTransactionId transaction_id);
+ 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,
+ int32_t segment_group_id, int32_t num_segments, bool is_pending,
+ TPartitionId partition_id, TTransactionId transaction_id);
virtual ~SegmentGroup();
@@ -140,7 +142,6 @@ class SegmentGroup {
OLAPStatus add_short_key(const RowCursor& short_key, const uint32_t
data_offset);
OLAPStatus add_row_block(const RowBlock& row_block, const uint32_t
data_offset);
OLAPStatus finalize_segment(uint32_t data_segment_size, int64_t num_rows);
- void sync();
// reference count
void acquire();
@@ -151,11 +152,6 @@ class SegmentGroup {
// delete all files (*.idx; *.dat)
void delete_all_files();
- // getters and setters.
- // get associated Tablet pointer
- inline Tablet* tablet() const { return _tablet; }
- inline void set_tablet(Tablet* tablet) { _tablet = tablet; }
-
inline Version version() const { return _version; }
inline VersionHash version_hash() const { return _version_hash; }
@@ -233,14 +229,34 @@ class SegmentGroup {
return _index.get_null_supported(seg_id);
}
- std::string construct_index_file_path(int32_t segment_group_id, int32_t
segment) const;
- std::string construct_data_file_path(int32_t segment_group_id, int32_t
segment) const;
+ std::string construct_index_file_path(int32_t segment) const;
+ std::string construct_data_file_path(int32_t segment) const;
void publish_version(Version version, VersionHash version_hash);
+ const RowFields& get_tablet_schema();
+
+ int get_num_key_fields();
+
+ int get_num_short_key_fields();
+
+ int get_num_rows_per_row_block();
+
+ std::string get_rowset_path_prefix();
+
+ int64_t get_tablet_id();
+
private:
- void _check_io_error(OLAPStatus res);
+ std::string _construct_pending_file_path(int32_t segment, const
std::string& suffix);
+
+ std::string _construct_file_path(int32_t segment, const std::string&
suffix);
- Tablet* _tablet; // tablet definition for this segmentgroup
+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
+ std::string _rowset_path_prefix; // path of rowset
Version _version; // version of associated data file
VersionHash _version_hash; // version hash for this segmentgroup
bool _delete_flag;
@@ -288,3 +304,5 @@ class SegmentGroup {
};
}
+
+#endif // DORIS_BE_SRC_OLAP_ROWSET_SEGMENT_GROUP_H
\ No newline at end of file
diff --git a/be/src/olap/segment_reader.cpp
b/be/src/olap/rowset/segment_reader.cpp
similarity index 95%
rename from be/src/olap/segment_reader.cpp
rename to be/src/olap/rowset/segment_reader.cpp
index 6ae5744c..430d8f2e 100644
--- a/be/src/olap/segment_reader.cpp
+++ b/be/src/olap/rowset/segment_reader.cpp
@@ -26,7 +26,7 @@
#include "olap/out_stream.h"
#include "olap/olap_cond.h"
#include "olap/row_block.h"
-#include "olap/segment_group.h"
+#include "olap/rowset/segment_group.h"
namespace doris {
@@ -34,7 +34,6 @@ static const uint32_t MIN_FILTER_BLOCK_NUM = 10;
SegmentReader::SegmentReader(
const std::string file,
- Tablet* tablet,
SegmentGroup* segment_group,
uint32_t segment_id,
const std::vector<uint32_t>& used_columns,
@@ -46,7 +45,6 @@ SegmentReader::SegmentReader(
RuntimeState* runtime_state,
OlapReaderStatistics* stats) :
_file_name(file),
- _tablet(tablet),
_segment_group(segment_group),
_segment_id(segment_id),
_conditions(conditions),
@@ -187,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 = _tablet->num_rows_per_row_block();
+ _num_rows_in_block = _segment_group->num_rows_per_row_block();
}
_set_column_map();
@@ -489,7 +487,7 @@ OLAPStatus SegmentReader::_pick_row_groups(uint32_t
first_block, uint32_t last_b
timer.reset();
for (auto& i : _conditions->columns()) {
- FieldAggregationMethod aggregation =
_tablet->get_aggregation_by_index(i.first);
+ FieldAggregationMethod aggregation =
_get_aggregation_by_index(i.first);
bool is_continue = (aggregation == OLAP_FIELD_AGGREGATION_NONE
|| (aggregation == OLAP_FIELD_AGGREGATION_REPLACE
&& _segment_group->version().first == 0));
@@ -530,7 +528,7 @@ OLAPStatus SegmentReader::_pick_row_groups(uint32_t
first_block, uint32_t last_b
}
for (uint32_t i : _load_bf_columns) {
- FieldAggregationMethod aggregation =
_tablet->get_aggregation_by_index(i);
+ FieldAggregationMethod aggregation = _get_aggregation_by_index(i);
bool is_continue = (aggregation == OLAP_FIELD_AGGREGATION_NONE
|| (aggregation == OLAP_FIELD_AGGREGATION_REPLACE
&& _segment_group->version().first == 0));
@@ -631,7 +629,7 @@ OLAPStatus SegmentReader::_load_index(bool is_using_cache) {
}
ColumnId table_column_id =
_unique_id_to_tablet_id_map[unique_column_id];
- FieldType type = _tablet->get_field_type_by_index(table_column_id);
+ FieldType type = _get_field_type_by_index(table_column_id);
char* stream_buffer = NULL;
char key_buf[OLAP_LRU_CACHE_MAX_KEY_LENTH];
@@ -716,14 +714,12 @@ OLAPStatus SegmentReader::_load_index(bool
is_using_cache) {
}
if (_block_count != expected_blocks) {
- OLAP_LOG_WARNING("something wrong while reading index,
expected=%lu, actual=%lu",
- expected_blocks, _block_count);
- OLAP_LOG_WARNING("_header_message().number_of_rows()=%d,"
- "_header_message().num_rows_per_block()=%d,
tablet='%s', version='%d-%d'",
- _header_message().number_of_rows(),
_header_message().num_rows_per_block(),
- _segment_group->tablet()->full_name().c_str(),
- _segment_group->version().first,
_segment_group->version().second);
- LOG(WARNING) << "version:" << _segment_group->version().first <<
"-" << _segment_group->version().second;
+ LOG(WARNING) << "something wrong while reading index, expected="
<<expected_blocks
+ << ", actual=" << _block_count;
+ LOG(WARNING) << "_header_message().number_of_rows()=" <<
_header_message().number_of_rows()
+ << ", _header_message().num_rows_per_block()=" <<
_header_message().num_rows_per_block()
+ << ", tablet_id=" << _segment_group->get_tablet_id()
+ << ", version='" << _segment_group->version().first << "-"
<< _segment_group->version().second << "'";
return OLAP_ERR_FILE_FORMAT_ERROR;
}
}
@@ -809,13 +805,13 @@ OLAPStatus SegmentReader::_read_all_data_streams(size_t*
buffer_size) {
}
OLAPStatus SegmentReader::_create_reader(size_t* buffer_size) {
- _column_readers.resize(_tablet->tablet_schema().size(), nullptr);
- _column_indices.resize(_tablet->tablet_schema().size(), nullptr);
+ _column_readers.resize(_segment_group->get_tablet_schema().size(),
nullptr);
+ _column_indices.resize(_segment_group->get_tablet_schema().size(),
nullptr);
for (auto table_column_id : _used_columns) {
ColumnId unique_column_id =
_tablet_id_to_unique_id_map[table_column_id];
// 当前是不会出现table和segment的schema不一致的情况的
std::unique_ptr<ColumnReader>
reader(ColumnReader::create(table_column_id,
- _tablet->tablet_schema(),
+ _segment_group->get_tablet_schema(),
_unique_id_to_tablet_id_map,
_unique_id_to_segment_id_map,
_encodings_map));
@@ -857,14 +853,14 @@ OLAPStatus SegmentReader::_seek_to_block_directly(
PositionProvider position(&_column_indices[cid]->entry(block_id));
if (OLAP_SUCCESS != (res = _column_readers[cid]->seek(&position))) {
if (OLAP_ERR_COLUMN_STREAM_EOF == res) {
- VLOG(3) << "Stream EOF. tablet_id=" << _tablet->tablet_id()
+ VLOG(3) << "Stream EOF. tablet_id=" <<
_segment_group->get_tablet_id()
<< ", column_id=" <<
_column_readers[cid]->column_unique_id()
<< ", block_id=" << block_id;
return OLAP_ERR_DATA_EOF;
} else {
OLAP_LOG_WARNING("fail to seek to block. "
"[tablet_id=%ld column_id=%u block_id=%lu]",
- _tablet->tablet_id(),
_column_readers[cid]->column_unique_id(), block_id);
+ _segment_group->get_tablet_id(),
_column_readers[cid]->column_unique_id(), block_id);
return OLAP_ERR_COLUMN_SEEK_ERROR;
}
}
diff --git a/be/src/olap/segment_reader.h b/be/src/olap/rowset/segment_reader.h
similarity index 94%
rename from be/src/olap/segment_reader.h
rename to be/src/olap/rowset/segment_reader.h
index 03db6ddb..5a610b9e 100644
--- a/be/src/olap/segment_reader.h
+++ b/be/src/olap/rowset/segment_reader.h
@@ -15,8 +15,8 @@
// specific language governing permissions and limitations
// under the License.
-#ifndef DORIS_BE_SRC_OLAP_COLUMN_FILE_SEGMENT_READER_H
-#define DORIS_BE_SRC_OLAP_COLUMN_FILE_SEGMENT_READER_H
+#ifndef DORIS_BE_SRC_OLAP_ROWSET_SEGMENT_READER_H
+#define DORIS_BE_SRC_OLAP_ROWSET_SEGMENT_READER_H
#include <gen_cpp/column_data_file.pb.h>
#include <gen_cpp/olap_common.pb.h>
@@ -37,7 +37,6 @@
#include "olap/olap_cond.h"
#include "olap/olap_define.h"
#include "olap/storage_engine.h"
-#include "olap/tablet.h"
#include "olap/row_cursor.h"
#include "runtime/runtime_state.h"
#include "runtime/mem_pool.h"
@@ -55,7 +54,6 @@ class ColumnReader;
class SegmentReader {
public:
explicit SegmentReader(const std::string file,
- Tablet* tablet,
SegmentGroup* segment_group,
uint32_t segment_id,
const std::vector<uint32_t>& return_columns,
@@ -232,7 +230,7 @@ class SegmentReader {
// 获取当前的table级schema。
inline const std::vector<FieldInfo>& tablet_schema() {
- return _tablet->tablet_schema();
+ return _segment_group->tablet_schema();
}
inline const ColumnDataHeaderMessage& _header_message() {
@@ -263,6 +261,24 @@ class SegmentReader {
OLAPStatus _load_to_vectorized_row_batch(
VectorizedRowBatch* batch, size_t size);
+ FieldAggregationMethod _get_aggregation_by_index(uint32_t index) {
+ const RowFields& tablet_schema = _segment_group->get_tablet_schema();
+ if (index < tablet_schema.size()) {
+ return tablet_schema[index].aggregation;
+ }
+
+ return OLAP_FIELD_AGGREGATION_UNKNOWN;
+ }
+
+ FieldType _get_field_type_by_index(uint32_t index) {
+ const RowFields& tablet_schema = _segment_group->get_tablet_schema();
+ if (index < tablet_schema.size()) {
+ return tablet_schema[index].type;
+ }
+
+ return OLAP_FIELD_TYPE_NONE;
+ }
+
private:
static const int32_t BYTE_STREAM_POSITIONS = 1;
static const int32_t RUN_LENGTH_BYTE_POSITIONS = BYTE_STREAM_POSITIONS + 1;
@@ -277,7 +293,6 @@ class SegmentReader {
std::string _file_name; // 文件名
doris::FileHandler _file_handler; // 文件handler
- Tablet* _tablet;
SegmentGroup* _segment_group;
uint32_t _segment_id;
@@ -364,4 +379,4 @@ class SegmentReader {
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_COLUMN_FILE_SEGMENT_READER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_SEGMENT_READER_H
\ No newline at end of file
diff --git a/be/src/olap/segment_writer.cpp
b/be/src/olap/rowset/segment_writer.cpp
similarity index 100%
rename from be/src/olap/segment_writer.cpp
rename to be/src/olap/rowset/segment_writer.cpp
diff --git a/be/src/olap/segment_writer.h b/be/src/olap/rowset/segment_writer.h
similarity index 91%
rename from be/src/olap/segment_writer.h
rename to be/src/olap/rowset/segment_writer.h
index 64daf8fc..9b653e6a 100644
--- a/be/src/olap/segment_writer.h
+++ b/be/src/olap/rowset/segment_writer.h
@@ -15,11 +15,11 @@
// specific language governing permissions and limitations
// under the License.
-#ifndef DORIS_BE_SRC_OLAP_COLUMN_FILE_SEGMENT_WRITER_H
-#define DORIS_BE_SRC_OLAP_COLUMN_FILE_SEGMENT_WRITER_H
+#ifndef DORIS_BE_SRC_OLAP_ROWSET_SEGMENT_WRITER_H
+#define DORIS_BE_SRC_OLAP_ROWSET_SEGMENT_WRITER_H
#include "olap/olap_define.h"
-#include "olap/data_writer.h"
+#include "olap/rowset/data_writer.h"
namespace doris {
@@ -60,4 +60,4 @@ class SegmentWriter {
} // namespace doris
-#endif // DORIS_BE_SRC_OLAP_COLUMN_FILE_SEGMENT_WRITER_H
+#endif // DORIS_BE_SRC_OLAP_ROWSET_SEGMENT_WRITER_H
\ No newline at end of file
diff --git a/be/src/olap/schema_change.cpp b/be/src/olap/schema_change.cpp
index fbe69ee6..e9e9d42e 100644
--- a/be/src/olap/schema_change.cpp
+++ b/be/src/olap/schema_change.cpp
@@ -23,14 +23,13 @@
#include <algorithm>
#include <vector>
-#include "olap/column_data.h"
+#include "olap/rowset/column_data.h"
#include "olap/merger.h"
-#include "olap/column_data.h"
#include "olap/storage_engine.h"
#include "olap/tablet.h"
#include "olap/row_block.h"
#include "olap/row_cursor.h"
-#include "olap/data_writer.h"
+#include "olap/rowset/data_writer.h"
#include "olap/wrapper_field.h"
#include "common/resource_tls.h"
#include "agent/cgroups_mgr.h"
diff --git a/be/src/olap/schema_change.h b/be/src/olap/schema_change.h
index 03f6ca66..3f9ff7c2 100644
--- a/be/src/olap/schema_change.h
+++ b/be/src/olap/schema_change.h
@@ -24,7 +24,7 @@
#include "gen_cpp/AgentService_types.h"
#include "olap/delete_handler.h"
-#include "olap/column_data.h"
+#include "olap/rowset/column_data.h"
namespace doris {
// defined in 'field.h'
diff --git a/be/src/olap/storage_engine.cpp b/be/src/olap/storage_engine.cpp
index 263d4f7a..dcf6aee2 100644
--- a/be/src/olap/storage_engine.cpp
+++ b/be/src/olap/storage_engine.cpp
@@ -44,7 +44,7 @@
#include "olap/schema_change.h"
#include "olap/data_dir.h"
#include "olap/utils.h"
-#include "olap/data_writer.h"
+#include "olap/rowset/data_writer.h"
#include "util/time.h"
#include "util/doris_metrics.h"
#include "util/pretty_printer.h"
diff --git a/be/src/olap/storage_engine.h b/be/src/olap/storage_engine.h
index 9ced675a..d1fcee4f 100644
--- a/be/src/olap/storage_engine.h
+++ b/be/src/olap/storage_engine.h
@@ -357,11 +357,15 @@ class StorageEngine {
const std::vector<VersionEntity>& shortest_version_entity,
TabletMeta* header);
+ // TODO: hkp
+ // rewrite this function
OLAPStatus _link_index_and_data_files(
const std::string& header_path,
const TabletSharedPtr& ref_tablet,
const std::vector<VersionEntity>& version_entity_vec);
+ // TODO: hkp
+ // rewrite this function
OLAPStatus _copy_index_and_data_files(
const std::string& header_path,
const TabletSharedPtr& ref_tablet,
@@ -384,12 +388,16 @@ class StorageEngine {
const TSnapshotRequest& request,
DataDir* store);
+ // TODO: hkp
+ // rewrite this function
std::string _construct_index_file_path(
const std::string& tablet_path_prefix,
const Version& version,
VersionHash version_hash,
int32_t segment_group_id, int32_t segment) const;
+ // TODO: hkp
+ // rewrite this function
std::string _construct_data_file_path(
const std::string& tablet_path_prefix,
const Version& version,
diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp
index 0201ac75..46d49649 100644
--- a/be/src/olap/tablet.cpp
+++ b/be/src/olap/tablet.cpp
@@ -28,7 +28,7 @@
#include <boost/filesystem.hpp>
#include "olap/field.h"
-#include "olap/column_data.h"
+#include "olap/rowset/column_data.h"
#include "olap/olap_common.h"
#include "olap/olap_define.h"
#include "olap/storage_engine.h"
@@ -39,7 +39,7 @@
#include "util/defer_op.h"
#include "olap/tablet_meta_manager.h"
#include "olap/utils.h"
-#include "olap/data_writer.h"
+#include "olap/rowset/data_writer.h"
using std::pair;
using std::map;
diff --git a/be/src/olap/tablet_manager.cpp b/be/src/olap/tablet_manager.cpp
index 1ae53793..41ab3a8d 100644
--- a/be/src/olap/tablet_manager.cpp
+++ b/be/src/olap/tablet_manager.cpp
@@ -44,7 +44,7 @@
#include "olap/schema_change.h"
#include "olap/data_dir.h"
#include "olap/utils.h"
-#include "olap/data_writer.h"
+#include "olap/rowset/data_writer.h"
#include "util/time.h"
#include "util/doris_metrics.h"
#include "util/pretty_printer.h"
@@ -1302,4 +1302,4 @@ TabletSharedPtr
TabletManager::_get_tablet_with_no_lock(TTabletId tablet_id, Sch
return tablet;
} // _get_tablet_with_no_lock
-} // doris
\ No newline at end of file
+} // doris
diff --git a/be/src/olap/txn_manager.cpp b/be/src/olap/txn_manager.cpp
index ddbce658..20005c45 100644
--- a/be/src/olap/txn_manager.cpp
+++ b/be/src/olap/txn_manager.cpp
@@ -44,7 +44,7 @@
#include "olap/schema_change.h"
#include "olap/data_dir.h"
#include "olap/utils.h"
-#include "olap/data_writer.h"
+#include "olap/rowset/data_writer.h"
#include "util/time.h"
#include "util/doris_metrics.h"
#include "util/pretty_printer.h"
@@ -197,4 +197,4 @@ bool TxnManager::has_txn(TPartitionId partition_id,
TTransactionId transaction_i
return found;
}
-} // namespace doris
\ No newline at end of file
+} // namespace doris
diff --git a/gensrc/proto/olap_file.proto b/gensrc/proto/olap_file.proto
index 3a45ed0b..90da7919 100644
--- a/gensrc/proto/olap_file.proto
+++ b/gensrc/proto/olap_file.proto
@@ -72,25 +72,30 @@ enum RowsetState {
message RowsetMetaPb {
required int64 rowset_id = 1;
optional int64 tablet_id = 2;
- optional int32 tablet_schema_hash = 3;
- optional RowsetType rowset_type = 4;
- optional RowsetState rowset_state = 5;
- // Rowset data version range
- optional int32 start_version = 6;
- optional int32 end_version = 7;
- optional int32 row_number = 8;
- // unit in byte
- optional int64 total_disk_size = 9;
- optional int64 data_disk_size = 10;
- optional int64 index_disk_size = 11;
+ optional int64 txn_id = 3;
+ optional int32 tablet_schema_hash = 4;
+ optional RowsetType rowset_type = 5;
+ optional RowsetState rowset_state = 6;
+ optional int32 start_version = 7;
+ optional int32 end_version = 8;
+ optional int64 version_hash = 9;
+ optional int32 row_number = 10;
+ optional int64 total_disk_size = 11;
+ optional int64 data_disk_size = 12;
+ optional int64 index_disk_size = 13;
// column min/max/null flag statistic info
- repeated ColumnPruning column_statistics = 12;
- optional DeleteConditionMessage delete_predicate = 13;
- optional int64 txn_id = 14;
- // spare field id 15-49 for future use
+ repeated ColumnPruning column_statistics = 14;
+ optional DeleteConditionMessage delete_predicate = 15;
+ optional bool empty = 16;
+ optional string rowset_path = 17;
+ // spare field id for future use
optional bytes extra_properties = 50;
}
+message AlphaRowsetExtraMetaPb {
+ repeated PSegmentGroup segment_groups = 1;
+}
+
message PSegmentGroup {
required int32 segment_group_id = 1;
required int32 num_segments = 2;
@@ -173,6 +178,9 @@ message OLAPHeaderMessage {
optional int64 tablet_id = 20;
optional int32 schema_hash = 21;
optional uint64 shard = 22;
+ repeated RowsetMetaPb rowsets = 23;
+ repeated RowsetMetaPb pending_rowsets = 24;
+ repeated RowsetMetaPb incremental_rowsets = 25;
}
message OLAPIndexHeaderMessage {
----------------------------------------------------------------
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]