github-actions[bot] commented on code in PR #29759:
URL: https://github.com/apache/doris/pull/29759#discussion_r1446438837
##########
be/src/olap/wal/wal_dirs_info.cpp:
##########
@@ -38,11 +38,21 @@
_limit = limit;
}
+size_t WalDirInfo::get_used() {
+ std::shared_lock rlock(_lock);
+ return _used;
+}
+
void WalDirInfo::set_used(size_t used) {
std::unique_lock wlock(_lock);
_used = used;
}
+size_t WalDirInfo::get_pre_allocated() {
Review Comment:
warning: method 'get_pre_allocated' can be made const
[readability-make-member-function-const]
be/src/olap/wal/wal_dirs_info.h:43:
```diff
- size_t get_pre_allocated();
+ size_t get_pre_allocated() const;
```
```suggestion
size_t WalDirInfo::get_pre_allocated() const {
```
##########
be/src/olap/wal/wal_dirs_info.cpp:
##########
@@ -144,7 +156,7 @@
->available();
}
-Status WalDirsInfo::update_wal_dir_limit(std::string wal_dir, size_t limit) {
+Status WalDirsInfo::update_wal_dir_limit(const std::string& wal_dir, size_t
limit) {
Review Comment:
warning: method 'update_wal_dir_limit' can be made static
[readability-convert-member-functions-to-static]
be/src/olap/wal/wal_dirs_info.h:69:
```diff
- Status update_wal_dir_limit(const std::string& wal_dir, size_t limit =
-1);
+ static Status update_wal_dir_limit(const std::string& wal_dir, size_t
limit = -1);
```
##########
be/src/olap/wal/wal_dirs_info.cpp:
##########
@@ -177,7 +189,8 @@
return Status::OK();
}
-Status WalDirsInfo::update_wal_dir_pre_allocated(std::string wal_dir, size_t
increase_pre_allocated,
+Status WalDirsInfo::update_wal_dir_pre_allocated(const std::string& wal_dir,
Review Comment:
warning: method 'update_wal_dir_pre_allocated' can be made static
[readability-convert-member-functions-to-static]
be/src/olap/wal/wal_dirs_info.h:73:
```diff
- Status update_wal_dir_pre_allocated(const std::string& wal_dir, size_t
increase_pre_allocated,
+ static Status update_wal_dir_pre_allocated(const std::string& wal_dir,
size_t increase_pre_allocated,
```
##########
be/src/olap/wal/wal_dirs_info.cpp:
##########
@@ -38,11 +38,21 @@ void WalDirInfo::set_limit(size_t limit) {
_limit = limit;
}
+size_t WalDirInfo::get_used() {
Review Comment:
warning: method 'get_used' can be made const
[readability-make-member-function-const]
be/src/olap/wal/wal_dirs_info.h:42:
```diff
- size_t get_used();
+ size_t get_used() const;
```
```suggestion
size_t WalDirInfo::get_used() const {
```
##########
be/src/olap/wal/wal_dirs_info.cpp:
##########
@@ -161,7 +173,7 @@
return Status::OK();
}
-Status WalDirsInfo::update_wal_dir_used(std::string wal_dir, size_t used) {
+Status WalDirsInfo::update_wal_dir_used(const std::string& wal_dir, size_t
used) {
Review Comment:
warning: method 'update_wal_dir_used' can be made static
[readability-convert-member-functions-to-static]
be/src/olap/wal/wal_dirs_info.h:71:
```diff
- Status update_wal_dir_used(const std::string& wal_dir, size_t used =
-1);
+ static Status update_wal_dir_used(const std::string& wal_dir, size_t
used = -1);
```
##########
be/test/olap/wal/test_wal_dirs_info.cpp:
##########
@@ -0,0 +1,129 @@
+// 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 <gtest/gtest.h>
+
+#include <cstddef>
+#include <memory>
+
+#include "olap/wal/wal_dirs_info.h"
+
+namespace doris {
+std::string wal_dir = std::string(getenv("DORIS_HOME")) + "/wal_test";
+
+class WalDirsInfoTest : public testing::Test {
+public:
+ WalDirsInfoTest() = default;
+ ~WalDirsInfoTest() override = default;
+ void SetUp() override {
+ // limit 1000 used 100 preallocated 200 available 700
+ Status st = wal_dirs_info.add(wal_dir_test_1, 0, 0, 0);
+ EXPECT_EQ(st, Status::OK());
+ // limit 1000 used 200 preallocated 300 available 500
+ st = wal_dirs_info.add(wal_dir_test_2, 0, 0, 0);
+ EXPECT_EQ(st, Status::OK());
+ // limit 1000 used 400 preallocated 500 available 100
+ st = wal_dirs_info.add(wal_dir_test_3, 0, 0, 0);
+ EXPECT_EQ(st, Status::OK());
+ }
+ void TearDown() override {}
+
+ WalDirsInfo wal_dirs_info;
+ // exist
+ std::string wal_dir_test_1 = wal_dir + "/test_1";
+ std::string wal_dir_test_2 = wal_dir + "/test_2";
+ std::string wal_dir_test_3 = wal_dir + "/test_3";
+ // not exist
+ std::string wal_dir_test_4 = wal_dir + "/test_4";
+
+private:
+ void set_and_check_success(std::string wal_dir, size_t limit, size_t used,
+ size_t pre_allocated) {
+ Status st = wal_dirs_info.update_wal_dir_limit(wal_dir, limit);
+ EXPECT_EQ(st, Status::OK());
+ std::shared_ptr<WalDirInfo> wal_dir_info;
+ st = wal_dirs_info.get_wal_dir_info(wal_dir, wal_dir_info);
+ EXPECT_EQ(st, Status::OK());
+ EXPECT_EQ(wal_dir_info->get_limit(), limit);
+
+ st = wal_dirs_info.update_wal_dir_used(wal_dir, used);
+ EXPECT_EQ(st, Status::OK());
+ st = wal_dirs_info.get_wal_dir_info(wal_dir, wal_dir_info);
+ EXPECT_EQ(st, Status::OK());
+ EXPECT_EQ(wal_dir_info->get_used(), used);
+
+ st = wal_dirs_info.update_wal_dir_pre_allocated(wal_dir,
pre_allocated, 0);
+ EXPECT_EQ(st, Status::OK());
+ st = wal_dirs_info.get_wal_dir_info(wal_dir, wal_dir_info);
+ EXPECT_EQ(st, Status::OK());
+ EXPECT_EQ(wal_dir_info->get_pre_allocated(), pre_allocated);
+
+ st = wal_dirs_info.update_wal_dir_pre_allocated(wal_dir, 0,
pre_allocated);
+ EXPECT_EQ(st, Status::OK());
+ st = wal_dirs_info.get_wal_dir_info(wal_dir, wal_dir_info);
+ EXPECT_EQ(st, Status::OK());
+ EXPECT_EQ(wal_dir_info->get_pre_allocated(), 0);
+
+ st = wal_dirs_info.update_wal_dir_pre_allocated(wal_dir,
pre_allocated, 0);
+ EXPECT_EQ(st, Status::OK());
+ st = wal_dirs_info.get_wal_dir_info(wal_dir, wal_dir_info);
+ EXPECT_EQ(st, Status::OK());
+ EXPECT_EQ(wal_dir_info->get_pre_allocated(), pre_allocated);
+
+ EXPECT_EQ(wal_dir_info->available(), limit - used - pre_allocated);
+ }
+
+ void set_and_check_fail(std::string wal_dir, size_t limit, size_t used,
size_t pre_allocated) {
Review Comment:
warning: method 'set_and_check_fail' can be made static
[readability-convert-member-functions-to-static]
```suggestion
static void set_and_check_fail(std::string wal_dir, size_t limit, size_t
used, size_t pre_allocated) {
```
##########
be/test/olap/wal/test_wal_dirs_info.cpp:
##########
@@ -0,0 +1,129 @@
+// 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 <gtest/gtest.h>
+
+#include <cstddef>
+#include <memory>
+
+#include "olap/wal/wal_dirs_info.h"
+
+namespace doris {
+std::string wal_dir = std::string(getenv("DORIS_HOME")) + "/wal_test";
+
+class WalDirsInfoTest : public testing::Test {
+public:
+ WalDirsInfoTest() = default;
+ ~WalDirsInfoTest() override = default;
+ void SetUp() override {
Review Comment:
warning: method 'SetUp' can be made static
[readability-convert-member-functions-to-static]
```suggestion
static void SetUp() override {
```
##########
be/test/olap/wal/test_wal_dirs_info.cpp:
##########
@@ -0,0 +1,129 @@
+// 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 <gtest/gtest.h>
+
+#include <cstddef>
+#include <memory>
+
+#include "olap/wal/wal_dirs_info.h"
+
+namespace doris {
+std::string wal_dir = std::string(getenv("DORIS_HOME")) + "/wal_test";
+
+class WalDirsInfoTest : public testing::Test {
+public:
+ WalDirsInfoTest() = default;
+ ~WalDirsInfoTest() override = default;
+ void SetUp() override {
+ // limit 1000 used 100 preallocated 200 available 700
+ Status st = wal_dirs_info.add(wal_dir_test_1, 0, 0, 0);
+ EXPECT_EQ(st, Status::OK());
+ // limit 1000 used 200 preallocated 300 available 500
+ st = wal_dirs_info.add(wal_dir_test_2, 0, 0, 0);
+ EXPECT_EQ(st, Status::OK());
+ // limit 1000 used 400 preallocated 500 available 100
+ st = wal_dirs_info.add(wal_dir_test_3, 0, 0, 0);
+ EXPECT_EQ(st, Status::OK());
+ }
+ void TearDown() override {}
+
+ WalDirsInfo wal_dirs_info;
+ // exist
+ std::string wal_dir_test_1 = wal_dir + "/test_1";
+ std::string wal_dir_test_2 = wal_dir + "/test_2";
+ std::string wal_dir_test_3 = wal_dir + "/test_3";
+ // not exist
+ std::string wal_dir_test_4 = wal_dir + "/test_4";
+
+private:
+ void set_and_check_success(std::string wal_dir, size_t limit, size_t used,
Review Comment:
warning: method 'set_and_check_success' can be made static
[readability-convert-member-functions-to-static]
```suggestion
static void set_and_check_success(std::string wal_dir, size_t limit,
size_t used,
```
##########
be/test/olap/wal/test_wal_dirs_info.cpp:
##########
@@ -0,0 +1,129 @@
+// 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 <gtest/gtest.h>
Review Comment:
warning: 'gtest/gtest.h' file not found [clang-diagnostic-error]
```cpp
#include <gtest/gtest.h>
^
```
##########
be/src/olap/wal/wal_dirs_info.cpp:
##########
@@ -201,4 +214,18 @@
return Status::InternalError("can not find wal dir!");
}
+Status WalDirsInfo::get_wal_dir_info(const std::string& wal_dir,
Review Comment:
warning: method 'get_wal_dir_info' can be made static
[readability-convert-member-functions-to-static]
be/src/olap/wal/wal_dirs_info.h:76:
```diff
- Status get_wal_dir_info(const std::string& wal_dir,
std::shared_ptr<WalDirInfo> wal_dir_info);
+ static Status get_wal_dir_info(const std::string& wal_dir,
std::shared_ptr<WalDirInfo> wal_dir_info);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]