You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by zh...@apache.org on 2019/11/22 16:04:37 UTC
[incubator-doris] branch master updated: Move dtor of BetaRowset to
cpp file (#2276)
This is an automated email from the ASF dual-hosted git repository.
zhaoc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new 7bf8979 Move dtor of BetaRowset to cpp file (#2276)
7bf8979 is described below
commit 7bf89793fd9b6d383dc3a8131b99e2e94b0a5066
Author: LingBin <li...@gmail.com>
AuthorDate: Fri Nov 22 10:04:25 2019 -0600
Move dtor of BetaRowset to cpp file (#2276)
There are many jobs in its dtor, so should not be inline
---
be/src/olap/rowset/beta_rowset.cpp | 16 ++++++++++++----
be/src/olap/rowset/beta_rowset.h | 5 +++--
be/src/olap/rowset/rowset.h | 3 ---
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/be/src/olap/rowset/beta_rowset.cpp b/be/src/olap/rowset/beta_rowset.cpp
index 2e0b7d5..204e581 100644
--- a/be/src/olap/rowset/beta_rowset.cpp
+++ b/be/src/olap/rowset/beta_rowset.cpp
@@ -27,7 +27,8 @@
namespace doris {
-std::string BetaRowset::segment_file_path(const std::string& dir, const RowsetId& rowset_id, int segment_id) {
+std::string BetaRowset::segment_file_path(
+ const std::string& dir, const RowsetId& rowset_id, int segment_id) {
return strings::Substitute("$0/$1_$2.dat", dir, rowset_id.to_string(), segment_id);
}
@@ -37,13 +38,15 @@ BetaRowset::BetaRowset(const TabletSchema* schema,
: Rowset(schema, std::move(rowset_path), std::move(rowset_meta)) {
}
+BetaRowset::~BetaRowset() { }
+
OLAPStatus BetaRowset::init() {
return OLAP_SUCCESS; // no op
}
// `use_cache` is ignored because beta rowset doesn't support fd cache now
-OLAPStatus BetaRowset::do_load_once(bool use_cache) {
- // open all segments under the current rowset
+OLAPStatus BetaRowset::do_load_once(bool /*use_cache*/) {
+ // Open all segments under the current rowset
for (int seg_id = 0; seg_id < num_segments(); ++seg_id) {
std::string seg_path = segment_file_path(_rowset_path, rowset_id(), seg_id);
std::shared_ptr<segment_v2::Segment> segment;
@@ -60,6 +63,7 @@ OLAPStatus BetaRowset::do_load_once(bool use_cache) {
OLAPStatus BetaRowset::create_reader(RowsetReaderSharedPtr* result) {
RETURN_NOT_OK(load());
+ // NOTE: We use std::static_pointer_cast for performance
result->reset(new BetaRowsetReader(std::static_pointer_cast<BetaRowset>(shared_from_this())));
return OLAP_SUCCESS;
}
@@ -80,6 +84,7 @@ OLAPStatus BetaRowset::remove() {
for (int i = 0; i < num_segments(); ++i) {
std::string path = segment_file_path(_rowset_path, rowset_id(), i);
LOG(INFO) << "deleting " << path;
+ // TODO(lingbin): use Env API
if (::remove(path.c_str()) != 0) {
char errmsg[64];
LOG(WARNING) << "failed to delete file. err=" << strerror_r(errno, errmsg, 64)
@@ -97,11 +102,14 @@ OLAPStatus BetaRowset::remove() {
OLAPStatus BetaRowset::link_files_to(const std::string& dir, RowsetId new_rowset_id) {
for (int i = 0; i < num_segments(); ++i) {
std::string dst_link_path = segment_file_path(dir, new_rowset_id, i);
+ // TODO(lingbin): use Env API? or EnvUtil?
if (FileUtils::check_exist(dst_link_path)) {
LOG(WARNING) << "failed to create hard link, file already exist: " << dst_link_path;
return OLAP_ERR_FILE_ALREADY_EXIST;
}
std::string src_file_path = segment_file_path(_rowset_path, rowset_id(), i);
+ // TODO(lingbin): how external storage support link?
+ // use copy? or keep refcount to avoid being delete?
if (link(src_file_path.c_str(), dst_link_path.c_str()) != 0) {
LOG(WARNING) << "fail to create hard link. from=" << src_file_path << ", "
<< "to=" << dst_link_path << ", " << "errno=" << Errno::no();
@@ -136,4 +144,4 @@ bool BetaRowset::check_path(const std::string& path) {
return valid_paths.find(path) != valid_paths.end();
}
-} // namespace doris
\ No newline at end of file
+} // namespace doris
diff --git a/be/src/olap/rowset/beta_rowset.h b/be/src/olap/rowset/beta_rowset.h
index d3ee954..3c6955e 100644
--- a/be/src/olap/rowset/beta_rowset.h
+++ b/be/src/olap/rowset/beta_rowset.h
@@ -34,9 +34,10 @@ class RowsetFactory;
class BetaRowset : public Rowset {
public:
- virtual ~BetaRowset() {}
+ virtual ~BetaRowset();
- static std::string segment_file_path(const std::string& segment_dir, const RowsetId& rowset_id, int segment_id);
+ static std::string segment_file_path(
+ const std::string& segment_dir, const RowsetId& rowset_id, int segment_id);
OLAPStatus create_reader(RowsetReaderSharedPtr* result) override;
diff --git a/be/src/olap/rowset/rowset.h b/be/src/olap/rowset/rowset.h
index 182381c..d07c15e 100644
--- a/be/src/olap/rowset/rowset.h
+++ b/be/src/olap/rowset/rowset.h
@@ -37,9 +37,6 @@ class RowsetFactory;
class RowsetReader;
class TabletSchema;
-// TODO(gaodayue) change to BETA_ROWSET when we're going to release segment v2
-const RowsetTypePB DEFAULT_ROWSET_TYPE = ALPHA_ROWSET;
-
class Rowset : public std::enable_shared_from_this<Rowset> {
public:
virtual ~Rowset() { }
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org