Skip to content

Commit edc55d1

Browse files
authored
clang-format (oceanbase#318)
### What problem were solved in this pull request? Issue Number: ref oceanbase#260 code format format command: ``` clang-format --Werror --sort-includes -i src/observer/common/types.h ```
1 parent 98707ed commit edc55d1

File tree

8 files changed

+123
-158
lines changed

8 files changed

+123
-158
lines changed

.scanignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker/bin/starter-code.sh

src/observer/common/global_context.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,4 @@ See the Mulan PSL v2 for more details. */
1616

1717
static GlobalContext global_context;
1818

19-
GlobalContext &GlobalContext::instance()
20-
{
21-
return global_context;
22-
}
19+
GlobalContext &GlobalContext::instance() { return global_context; }

src/observer/common/global_context.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class TrxKit;
2525
struct GlobalContext
2626
{
2727
BufferPoolManager *buffer_pool_manager_ = nullptr;
28-
DefaultHandler *handler_ = nullptr;
29-
TrxKit *trx_kit_ = nullptr;
28+
DefaultHandler *handler_ = nullptr;
29+
TrxKit *trx_kit_ = nullptr;
3030

3131
static GlobalContext &instance();
3232
};

src/observer/common/init.cpp

+28-47
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ See the Mulan PSL v2 for more details. */
1414

1515
#include "common/init.h"
1616

17-
#include "common/ini_setting.h"
1817
#include "common/conf/ini.h"
1918
#include "common/lang/string.h"
2019
#include "common/log/log.h"
@@ -24,52 +23,39 @@ See the Mulan PSL v2 for more details. */
2423
#include "common/os/signal.h"
2524
#include "common/seda/init.h"
2625
#include "common/seda/stage_factory.h"
26+
#include "global_context.h"
2727
#include "session/session.h"
2828
#include "session/session_stage.h"
29-
#include "sql/executor/execute_stage.h"
30-
#include "sql/optimizer/optimize_stage.h"
31-
#include "sql/parser/parse_stage.h"
32-
#include "sql/parser/resolve_stage.h"
3329
#include "sql/plan_cache/plan_cache_stage.h"
34-
#include "sql/query_cache/query_cache_stage.h"
3530
#include "storage/buffer/disk_buffer_pool.h"
3631
#include "storage/default/default_handler.h"
3732
#include "storage/trx/trx.h"
38-
#include "global_context.h"
3933

34+
using namespace std;
4035
using namespace common;
4136

4237
bool *&_get_init()
4338
{
44-
static bool util_init = false;
39+
static bool util_init = false;
4540
static bool *util_init_p = &util_init;
4641
return util_init_p;
4742
}
4843

49-
bool get_init()
50-
{
51-
return *_get_init();
52-
}
44+
bool get_init() { return *_get_init(); }
5345

54-
void set_init(bool value)
55-
{
56-
*_get_init() = value;
57-
return;
58-
}
46+
void set_init(bool value) { *_get_init() = value; }
5947

6048
void sig_handler(int sig)
6149
{
6250
// Signal handler will be add in the next step.
6351
// Add action to shutdown
6452

6553
LOG_INFO("Receive one signal of %d.", sig);
66-
67-
return;
6854
}
6955

7056
int init_log(ProcessParam *process_cfg, Ini &properties)
7157
{
72-
const std::string &proc_name = process_cfg->get_process_name();
58+
const string &proc_name = process_cfg->get_process_name();
7359
try {
7460
// we had better alloc one lock to do so, but simplify the logic
7561
if (g_log) {
@@ -78,35 +64,36 @@ int init_log(ProcessParam *process_cfg, Ini &properties)
7864

7965
auto log_context_getter = []() { return reinterpret_cast<intptr_t>(Session::current_session()); };
8066

81-
const std::string log_section_name = "LOG";
82-
std::map<std::string, std::string> log_section = properties.get(log_section_name);
67+
const string log_section_name = "LOG";
68+
map<string, string> log_section = properties.get(log_section_name);
8369

84-
std::string log_file_name;
70+
string log_file_name;
8571

8672
// get log file name
87-
std::string key = "LOG_FILE_NAME";
88-
std::map<std::string, std::string>::iterator it = log_section.find(key);
73+
string key = "LOG_FILE_NAME";
74+
75+
map<string, string>::iterator it = log_section.find(key);
8976
if (it == log_section.end()) {
9077
log_file_name = proc_name + ".log";
91-
std::cout << "Not set log file name, use default " << log_file_name << std::endl;
78+
cout << "Not set log file name, use default " << log_file_name << endl;
9279
} else {
9380
log_file_name = it->second;
9481
}
9582

9683
log_file_name = getAboslutPath(log_file_name.c_str());
9784

9885
LOG_LEVEL log_level = LOG_LEVEL_INFO;
99-
key = ("LOG_FILE_LEVEL");
100-
it = log_section.find(key);
86+
key = ("LOG_FILE_LEVEL");
87+
it = log_section.find(key);
10188
if (it != log_section.end()) {
10289
int log = (int)log_level;
10390
str_to_val(it->second, log);
10491
log_level = (LOG_LEVEL)log;
10592
}
10693

10794
LOG_LEVEL console_level = LOG_LEVEL_INFO;
108-
key = ("LOG_CONSOLE_LEVEL");
109-
it = log_section.find(key);
95+
key = ("LOG_CONSOLE_LEVEL");
96+
it = log_section.find(key);
11097
if (it != log_section.end()) {
11198
int log = (int)console_level;
11299
str_to_val(it->second, log);
@@ -117,7 +104,7 @@ int init_log(ProcessParam *process_cfg, Ini &properties)
117104
g_log->set_context_getter(log_context_getter);
118105

119106
key = ("DefaultLogModules");
120-
it = log_section.find(key);
107+
it = log_section.find(key);
121108
if (it != log_section.end()) {
122109
g_log->set_default_module(it->second);
123110
}
@@ -127,8 +114,8 @@ int init_log(ProcessParam *process_cfg, Ini &properties)
127114
}
128115

129116
return 0;
130-
} catch (std::exception &e) {
131-
std::cerr << "Failed to init log for " << proc_name << SYS_OUTPUT_FILE_POS << SYS_OUTPUT_ERROR << std::endl;
117+
} catch (exception &e) {
118+
cerr << "Failed to init log for " << proc_name << SYS_OUTPUT_FILE_POS << SYS_OUTPUT_ERROR << endl;
132119
return errno;
133120
}
134121

@@ -142,7 +129,6 @@ void cleanup_log()
142129
delete g_log;
143130
g_log = nullptr;
144131
}
145-
return;
146132
}
147133

148134
int prepare_init_seda()
@@ -157,11 +143,11 @@ int init_global_objects(ProcessParam *process_param, Ini &properties)
157143
BufferPoolManager::set_instance(GCTX.buffer_pool_manager_);
158144

159145
GCTX.handler_ = new DefaultHandler();
160-
146+
161147
DefaultHandler::set_default(GCTX.handler_);
162148

163149
int ret = 0;
164-
RC rc = TrxKit::init_global(process_param->trx_kit_name().c_str());
150+
RC rc = TrxKit::init_global(process_param->trx_kit_name().c_str());
165151
if (rc != RC::SUCCESS) {
166152
LOG_ERROR("failed to init trx kit. rc=%s", strrc(rc));
167153
ret = -1;
@@ -196,7 +182,6 @@ int uninit_global_objects()
196182
int init(ProcessParam *process_param)
197183
{
198184
if (get_init()) {
199-
200185
return 0;
201186
}
202187

@@ -207,7 +192,7 @@ int init(ProcessParam *process_param)
207192
if (process_param->is_demon()) {
208193
rc = daemonize_service(process_param->get_std_out().c_str(), process_param->get_std_err().c_str());
209194
if (rc != 0) {
210-
std::cerr << "Shutdown due to failed to daemon current process!" << std::endl;
195+
cerr << "Shutdown due to failed to daemon current process!" << endl;
211196
return rc;
212197
}
213198
}
@@ -220,18 +205,18 @@ int init(ProcessParam *process_param)
220205
// Read Configuration files
221206
rc = get_properties()->load(process_param->get_conf());
222207
if (rc) {
223-
std::cerr << "Failed to load configuration files" << std::endl;
208+
cerr << "Failed to load configuration files" << endl;
224209
return rc;
225210
}
226211

227212
// Init tracer
228213
rc = init_log(process_param, *get_properties());
229214
if (rc) {
230-
std::cerr << "Failed to init Log" << std::endl;
215+
cerr << "Failed to init Log" << endl;
231216
return rc;
232217
}
233218

234-
std::string conf_data;
219+
string conf_data;
235220
get_properties()->to_string(conf_data);
236221
LOG_INFO("Output configuration \n%s", conf_data.c_str());
237222

@@ -266,7 +251,7 @@ int init(ProcessParam *process_param)
266251
void cleanup_util()
267252
{
268253
uninit_global_objects();
269-
254+
270255
if (nullptr != get_properties()) {
271256
delete get_properties();
272257
get_properties() = nullptr;
@@ -278,10 +263,6 @@ void cleanup_util()
278263
cleanup_log();
279264

280265
set_init(false);
281-
return;
282266
}
283267

284-
void cleanup()
285-
{
286-
cleanup_util();
287-
}
268+
void cleanup() { cleanup_util(); }

src/observer/common/init.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ See the Mulan PSL v2 for more details. */
1414

1515
#pragma once
1616

17-
#include "common/os/process_param.h"
1817
#include "common/conf/ini.h"
18+
#include "common/os/process_param.h"
1919

20-
int init(common::ProcessParam *processParam);
20+
int init(common::ProcessParam *processParam);
2121
void cleanup();

src/observer/common/rc.h

+54-54
Original file line numberDiff line numberDiff line change
@@ -19,60 +19,60 @@ See the Mulan PSL v2 for more details. */
1919
* @enum RC
2020
*/
2121

22-
#define DEFINE_RCS \
23-
DEFINE_RC(SUCCESS) \
24-
DEFINE_RC(INVALID_ARGUMENT) \
25-
DEFINE_RC(UNIMPLENMENT) \
26-
DEFINE_RC(SQL_SYNTAX) \
27-
DEFINE_RC(INTERNAL) \
28-
DEFINE_RC(NOMEM) \
29-
DEFINE_RC(NOTFOUND) \
30-
DEFINE_RC(EMPTY) \
31-
DEFINE_RC(BUFFERPOOL_OPEN) \
32-
DEFINE_RC(BUFFERPOOL_NOBUF) \
33-
DEFINE_RC(BUFFERPOOL_INVALID_PAGE_NUM) \
34-
DEFINE_RC(RECORD_OPENNED) \
35-
DEFINE_RC(RECORD_INVALID_RID) \
36-
DEFINE_RC(RECORD_INVALID_KEY) \
37-
DEFINE_RC(RECORD_DUPLICATE_KEY) \
38-
DEFINE_RC(RECORD_NOMEM) \
39-
DEFINE_RC(RECORD_EOF) \
40-
DEFINE_RC(RECORD_NOT_EXIST) \
41-
DEFINE_RC(RECORD_INVISIBLE) \
42-
DEFINE_RC(SCHEMA_DB_EXIST) \
43-
DEFINE_RC(SCHEMA_DB_NOT_EXIST) \
44-
DEFINE_RC(SCHEMA_DB_NOT_OPENED) \
45-
DEFINE_RC(SCHEMA_TABLE_NOT_EXIST) \
46-
DEFINE_RC(SCHEMA_TABLE_EXIST) \
47-
DEFINE_RC(SCHEMA_FIELD_NOT_EXIST) \
48-
DEFINE_RC(SCHEMA_FIELD_MISSING) \
49-
DEFINE_RC(SCHEMA_FIELD_TYPE_MISMATCH) \
50-
DEFINE_RC(SCHEMA_INDEX_NAME_REPEAT) \
51-
DEFINE_RC(IOERR_READ) \
52-
DEFINE_RC(IOERR_WRITE) \
53-
DEFINE_RC(IOERR_ACCESS) \
54-
DEFINE_RC(IOERR_OPEN) \
55-
DEFINE_RC(IOERR_CLOSE) \
56-
DEFINE_RC(IOERR_SEEK) \
57-
DEFINE_RC(IOERR_TOO_LONG) \
58-
DEFINE_RC(IOERR_SYNC) \
59-
DEFINE_RC(LOCKED_UNLOCK) \
60-
DEFINE_RC(LOCKED_NEED_WAIT) \
61-
DEFINE_RC(LOCKED_CONCURRENCY_CONFLICT) \
62-
DEFINE_RC(FILE_EXIST) \
63-
DEFINE_RC(FILE_NOT_EXIST) \
64-
DEFINE_RC(FILE_NAME) \
65-
DEFINE_RC(FILE_BOUND) \
66-
DEFINE_RC(FILE_CREATE) \
67-
DEFINE_RC(FILE_OPEN) \
68-
DEFINE_RC(FILE_NOT_OPENED) \
69-
DEFINE_RC(FILE_CLOSE) \
70-
DEFINE_RC(FILE_REMOVE) \
71-
DEFINE_RC(FILE_SEEK) \
72-
DEFINE_RC(FILE_READ) \
73-
DEFINE_RC(FILE_WRITE) \
74-
DEFINE_RC(VARIABLE_NOT_EXISTS) \
75-
DEFINE_RC(VARIABLE_NOT_VALID) \
22+
#define DEFINE_RCS \
23+
DEFINE_RC(SUCCESS) \
24+
DEFINE_RC(INVALID_ARGUMENT) \
25+
DEFINE_RC(UNIMPLENMENT) \
26+
DEFINE_RC(SQL_SYNTAX) \
27+
DEFINE_RC(INTERNAL) \
28+
DEFINE_RC(NOMEM) \
29+
DEFINE_RC(NOTFOUND) \
30+
DEFINE_RC(EMPTY) \
31+
DEFINE_RC(BUFFERPOOL_OPEN) \
32+
DEFINE_RC(BUFFERPOOL_NOBUF) \
33+
DEFINE_RC(BUFFERPOOL_INVALID_PAGE_NUM) \
34+
DEFINE_RC(RECORD_OPENNED) \
35+
DEFINE_RC(RECORD_INVALID_RID) \
36+
DEFINE_RC(RECORD_INVALID_KEY) \
37+
DEFINE_RC(RECORD_DUPLICATE_KEY) \
38+
DEFINE_RC(RECORD_NOMEM) \
39+
DEFINE_RC(RECORD_EOF) \
40+
DEFINE_RC(RECORD_NOT_EXIST) \
41+
DEFINE_RC(RECORD_INVISIBLE) \
42+
DEFINE_RC(SCHEMA_DB_EXIST) \
43+
DEFINE_RC(SCHEMA_DB_NOT_EXIST) \
44+
DEFINE_RC(SCHEMA_DB_NOT_OPENED) \
45+
DEFINE_RC(SCHEMA_TABLE_NOT_EXIST) \
46+
DEFINE_RC(SCHEMA_TABLE_EXIST) \
47+
DEFINE_RC(SCHEMA_FIELD_NOT_EXIST) \
48+
DEFINE_RC(SCHEMA_FIELD_MISSING) \
49+
DEFINE_RC(SCHEMA_FIELD_TYPE_MISMATCH) \
50+
DEFINE_RC(SCHEMA_INDEX_NAME_REPEAT) \
51+
DEFINE_RC(IOERR_READ) \
52+
DEFINE_RC(IOERR_WRITE) \
53+
DEFINE_RC(IOERR_ACCESS) \
54+
DEFINE_RC(IOERR_OPEN) \
55+
DEFINE_RC(IOERR_CLOSE) \
56+
DEFINE_RC(IOERR_SEEK) \
57+
DEFINE_RC(IOERR_TOO_LONG) \
58+
DEFINE_RC(IOERR_SYNC) \
59+
DEFINE_RC(LOCKED_UNLOCK) \
60+
DEFINE_RC(LOCKED_NEED_WAIT) \
61+
DEFINE_RC(LOCKED_CONCURRENCY_CONFLICT) \
62+
DEFINE_RC(FILE_EXIST) \
63+
DEFINE_RC(FILE_NOT_EXIST) \
64+
DEFINE_RC(FILE_NAME) \
65+
DEFINE_RC(FILE_BOUND) \
66+
DEFINE_RC(FILE_CREATE) \
67+
DEFINE_RC(FILE_OPEN) \
68+
DEFINE_RC(FILE_NOT_OPENED) \
69+
DEFINE_RC(FILE_CLOSE) \
70+
DEFINE_RC(FILE_REMOVE) \
71+
DEFINE_RC(FILE_SEEK) \
72+
DEFINE_RC(FILE_READ) \
73+
DEFINE_RC(FILE_WRITE) \
74+
DEFINE_RC(VARIABLE_NOT_EXISTS) \
75+
DEFINE_RC(VARIABLE_NOT_VALID) \
7676
DEFINE_RC(LOGBUF_FULL)
7777

7878
enum class RC

src/observer/common/types.h

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ See the Mulan PSL v2 for more details. */
1414

1515
#pragma once
1616

17-
1817
/// 磁盘文件,包括存放数据的文件和索引(B+-Tree)文件,都按照页来组织
1918
/// 每一页都有一个编号,称为PageNum
2019
using PageNum = int32_t;

0 commit comments

Comments
 (0)