Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 committed Jul 4, 2024
1 parent 4757d19 commit 933324b
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 86 deletions.
92 changes: 43 additions & 49 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -135,54 +135,48 @@ SpacesInSquareBrackets: false
Standard: c++17
TabWidth: 4
UseTab: Never




IndentAccessModifiers: false;
IndentCaseBlocks: false;
IndentGotoLabels: true;
IndentPPDirectives: FormatStyle::PPDIS_None;
IndentRequires: false;
PPIndentWidth: -1;
InsertTrailingCommas: FormatStyle::TCS_None;
LambdaBodyIndentation: FormatStyle::LBI_Signature;
ObjCBinPackProtocolList: FormatStyle::BPS_Auto;
ObjCBreakBeforeNestedBlockParam: true;
ReferenceAlignment: FormatStyle::RAS_Pointer;
SeparateDefinitionBlocks: FormatStyle::SDS_Leave;
ShortNamespaceLines: 1;
UseCRLF: false;
RemoveBracesLLVM: false;
SpaceInEmptyBlock: false;
SpacesInLineCommentPrefix: {/*Minimum=*/1, /*Maximum=*/-1u};
SpaceAfterLogicalNot: false;
SpaceAfterTemplateKeyword: true;
SpaceAroundPointerQualifiers: FormatStyle::SAPQ_Default;
SpaceBeforeCaseColon: false;
SpaceBeforeCtorInitializerColon: true;
SpaceBeforeInheritanceColon: true;
AfterControlStatements: true;
AfterForeachMacros: true;
AfterIfMacros: true;
SpaceBeforeRangeBasedForLoopColon: true;
SpaceBeforeCpp11BracedList: false;
SpaceBeforeSquareBrackets: false;
BitFieldColonSpacing: FormatStyle::BFCS_Both;
SpacesInConditionalStatement: false;
PenaltyBreakAssignment: prec::Assignment;
PenaltyBreakOpenParenthesis: 0;
PenaltyBreakTemplateDeclaration: prec::Relational;
PenaltyIndentedWhitespace: 0;
SortJavaStaticImport: FormatStyle::SJSIO_Before;
SortUsingDeclarations: true;
StatementAttributeLikeMacros.push_back("Q_EMIT");
StatementMacros.push_back("Q_UNUSED");
StatementMacros.push_back("QT_REQUIRE_VERSION");
WhitespaceSensitiveMacros.push_back("STRINGIZE");
WhitespaceSensitiveMacros.push_back("PP_STRINGIZE");
WhitespaceSensitiveMacros.push_back("BOOST_PP_STRINGIZE");
WhitespaceSensitiveMacros.push_back("NS_SWIFT_NAME");
WhitespaceSensitiveMacros.push_back("CF_SWIFT_NAME");
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentRequires: false
PPIndentWidth: -1
InsertTrailingCommas: None
LambdaBodyIndentation: Signature
ObjCBinPackProtocolList: Auto
ObjCBreakBeforeNestedBlockParam: true
ReferenceAlignment: Pointer
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
UseCRLF: false
RemoveBracesLLVM: false
SpaceInEmptyBlock: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeCaseColon: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterIfMacros: true
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
SpacesInConditionalStatement: false
PenaltyBreakAssignment: 4
PenaltyBreakOpenParenthesis: 0
PenaltyBreakTemplateDeclaration: 4
PenaltyIndentedWhitespace: 0
SortJavaStaticImport: Before
SortUsingDeclarations: true
StatementAttributeLikeMacros: [ Q_EMIT]
StatementMacros: [ Q_UNUSED, QT_REQUIRE_VERSION]
WhitespaceSensitiveMacros: [ STRINGIZE, PP_STRINGIZE, BOOST_PP_STRINGIZE, NS_SWIFT_NAME, CF_SWIFT_NAME]
...

14 changes: 7 additions & 7 deletions src/meta/duplication/duplication_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ class duplication_info
bool all_checkpoint_has_prepared()
{
int prepared = 0;
bool completed =
std::all_of(_progress.begin(),
_progress.end(),
[&](std::pair<int, partition_progress> item) -> bool {
prepared = item.second.checkpoint_prepared ? prepared + 1 : prepared;
return item.second.checkpoint_prepared;
});
bool completed = std::all_of(_progress.begin(),
_progress.end(),
[&](std::pair<int, partition_progress> item) -> bool {
prepared = item.second.checkpoint_prepared ? prepared + 1
: prepared;
return item.second.checkpoint_prepared;
});
if (!completed) {
LOG_WARNING("replica checkpoint still running: {}/{}", prepared, _progress.size());
}
Expand Down
4 changes: 2 additions & 2 deletions src/meta/meta_split_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ void meta_split_service::do_control_single(std::shared_ptr<app_state> app, contr

auto iter = app->helpers->split_states.status.find(parent_pidx);
if (iter == app->helpers->split_states.status.end()) {
response.err =
control_type == split_control_type::PAUSE ? ERR_CHILD_REGISTERED : ERR_INVALID_STATE;
response.err = control_type == split_control_type::PAUSE ? ERR_CHILD_REGISTERED
: ERR_INVALID_STATE;
response.__set_hint_msg(fmt::format("partition[{}] is not splitting", parent_pidx));
LOG_ERROR("{} split for app({}) failed, {}",
control_type_str(control_type),
Expand Down
4 changes: 2 additions & 2 deletions src/meta/meta_state_service_simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ error_code meta_state_service_simple::apply_transaction(

error_code meta_state_service_simple::initialize(const std::vector<std::string> &args)
{
const char *work_dir =
args.empty() ? service_app::current_service_app_info().data_dir.c_str() : args[0].c_str();
const char *work_dir = args.empty() ? service_app::current_service_app_info().data_dir.c_str()
: args[0].c_str();

_offset = 0;
std::string log_path = dsn::utils::filesystem::path_combine(work_dir, "meta_state_service.log");
Expand Down
4 changes: 2 additions & 2 deletions src/meta/meta_state_service_utils_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ struct on_delete : operation
return;
}

auto type =
args->is_recursively_delete ? op_type::OP_DELETE_RECURSIVELY : op_type::OP_DELETE;
auto type = args->is_recursively_delete ? op_type::OP_DELETE_RECURSIVELY
: op_type::OP_DELETE;
operation::on_error(this, type, ec, args->node);
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/meta/server_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1383,8 +1383,8 @@ void server_state::recall_app(dsn::message_ex *msg)
if (has_seconds_expired(target_app->expire_second)) {
response.err = ERR_APP_NOT_EXIST;
} else {
std::string &new_app_name =
(request.new_app_name == "") ? target_app->app_name : request.new_app_name;
std::string &new_app_name = (request.new_app_name == "") ? target_app->app_name
: request.new_app_name;
if (_exist_apps.find(new_app_name) != _exist_apps.end()) {
response.err = ERR_INVALID_PARAMETERS;
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/replica/bulk_load/replica_bulk_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1031,8 +1031,8 @@ void replica_bulk_loader::report_group_cleaned_up(bulk_load_response &response)
for (const auto &target_hp : _replica->_primary_states.membership.hp_secondaries) {
const auto &secondary_state =
_replica->_primary_states.secondary_bulk_load_states[target_hp];
bool is_cleaned_up =
secondary_state.__isset.is_cleaned_up ? secondary_state.is_cleaned_up : false;
bool is_cleaned_up = secondary_state.__isset.is_cleaned_up ? secondary_state.is_cleaned_up
: false;
LOG_INFO_PREFIX(
"secondary = {}, bulk load states cleaned_up = {}", target_hp, is_cleaned_up);
SET_VALUE_FROM_HOST_PORT(response, group_bulk_load_state, target_hp, secondary_state);
Expand Down
12 changes: 6 additions & 6 deletions src/replica/mutation_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ void mutation_log_private::get_in_memory_mutations(decree start_decree,
for (auto &mu : issued_write->mutations()) {
// if start_ballot is invalid or equal to mu.ballot, check decree
// otherwise check ballot
ballot current_ballot =
(start_ballot == invalid_ballot) ? invalid_ballot : mu->get_ballot();
ballot current_ballot = (start_ballot == invalid_ballot) ? invalid_ballot
: mu->get_ballot();
if ((mu->get_decree() >= start_decree && start_ballot == current_ballot) ||
current_ballot > start_ballot) {
mutation_list.push_back(mutation::copy_no_reply(mu));
Expand All @@ -179,8 +179,8 @@ void mutation_log_private::get_in_memory_mutations(decree start_decree,
for (auto &mu : pending_mutations) {
// if start_ballot is invalid or equal to mu.ballot, check decree
// otherwise check ballot
ballot current_ballot =
(start_ballot == invalid_ballot) ? invalid_ballot : mu->get_ballot();
ballot current_ballot = (start_ballot == invalid_ballot) ? invalid_ballot
: mu->get_ballot();
if ((mu->get_decree() >= start_decree && start_ballot == current_ballot) ||
current_ballot > start_ballot) {
mutation_list.push_back(mutation::copy_no_reply(mu));
Expand Down Expand Up @@ -537,8 +537,8 @@ error_code mutation_log::open(replay_callback read_callback,
end_offset);

if (ERR_OK == err) {
_global_start_offset =
_log_files.size() > 0 ? _log_files.begin()->second->start_offset() : 0;
_global_start_offset = _log_files.size() > 0 ? _log_files.begin()->second->start_offset()
: 0;
_global_end_offset = end_offset;
_last_file_index = _log_files.size() > 0 ? _log_files.rbegin()->first : 0;
_is_opened = true;
Expand Down
4 changes: 2 additions & 2 deletions src/replica/test/mock_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ class mock_mutation_log_private : public mutation_log_private
std::vector<mutation_ptr> &mutation_list) const override
{
for (auto &mu : _mu_list) {
ballot current_ballot =
(start_ballot == invalid_ballot) ? invalid_ballot : mu->get_ballot();
ballot current_ballot = (start_ballot == invalid_ballot) ? invalid_ballot
: mu->get_ballot();
if ((mu->get_decree() >= start_decree && start_ballot == current_ballot) ||
current_ballot > start_ballot) {
mutation_list.push_back(mu);
Expand Down
4 changes: 2 additions & 2 deletions src/server/pegasus_server_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ class pegasus_server_impl : public pegasus_read_service
bool check_value_if_nearby(uint64_t base_value, uint64_t check_value)
{
uint64_t gap = base_value / 4;
uint64_t actual_gap =
(base_value < check_value) ? check_value - base_value : base_value - check_value;
uint64_t actual_gap = (base_value < check_value) ? check_value - base_value
: base_value - check_value;
return actual_gap <= gap;
}

Expand Down
8 changes: 4 additions & 4 deletions src/server/pegasus_write_service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ class pegasus_write_service::impl : public dsn::replication::replica_base

if (!passed) {
// check not passed, return proper error code to user
resp.error =
invalid_argument ? rocksdb::Status::kInvalidArgument : rocksdb::Status::kTryAgain;
resp.error = invalid_argument ? rocksdb::Status::kInvalidArgument
: rocksdb::Status::kTryAgain;
}

return rocksdb::Status::kOk;
Expand Down Expand Up @@ -468,8 +468,8 @@ class pegasus_write_service::impl : public dsn::replication::replica_base

if (!passed) {
// check not passed, return proper error code to user
resp.error =
invalid_argument ? rocksdb::Status::kInvalidArgument : rocksdb::Status::kTryAgain;
resp.error = invalid_argument ? rocksdb::Status::kInvalidArgument
: rocksdb::Status::kTryAgain;
}
return rocksdb::Status::kOk;
}
Expand Down
4 changes: 2 additions & 2 deletions src/shell/commands/bulk_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ bool control_bulk_load_helper(command_executor *e,
err = dsn::error_s::make(err_resp.get_value().err);
hint_msg = err_resp.get_value().hint_msg;
}
std::string type_str =
type == dsn::replication::bulk_load_control_type::BLC_PAUSE ? "pause" : "restart";
std::string type_str = type == dsn::replication::bulk_load_control_type::BLC_PAUSE ? "pause"
: "restart";
if (!err.is_ok()) {
fmt::print(
stderr, "{} bulk load failed, error={} [hint:\"{}\"]\n", type_str, err, hint_msg);
Expand Down
4 changes: 2 additions & 2 deletions src/shell/commands/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ bool mlog_dump(command_executor *e, shell_context *sc, arguments args)
} else if (msg->local_rpc_code == ::dsn::apps::RPC_RRDB_RRDB_CHECK_AND_SET) {
dsn::apps::check_and_set_request update;
dsn::unmarshall(request, update);
auto set_sort_key =
update.set_diff_sort_key ? update.set_sort_key : update.check_sort_key;
auto set_sort_key = update.set_diff_sort_key ? update.set_sort_key
: update.check_sort_key;
std::string check_operand;
if (pegasus::cas_is_check_operand_needed(update.check_type)) {
check_operand = fmt::format(
Expand Down
4 changes: 2 additions & 2 deletions src/utils/binary_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ binary_writer::binary_writer(int reserveBufferSize)
{
_total_size = 0;
_buffers.reserve(1);
_reserved_size_per_buffer =
(reserveBufferSize == 0) ? _reserved_size_per_buffer_static : reserveBufferSize;
_reserved_size_per_buffer = (reserveBufferSize == 0) ? _reserved_size_per_buffer_static
: reserveBufferSize;
_current_buffer = nullptr;
_current_offset = 0;
_current_buffer_length = 0;
Expand Down

0 comments on commit 933324b

Please sign in to comment.