Skip to content

Commit

Permalink
corrections after first review by GitSparTV
Browse files Browse the repository at this point in the history
  • Loading branch information
antonporodnikov committed Mar 6, 2024
1 parent eb0c555 commit d8a3dea
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 28 deletions.
10 changes: 5 additions & 5 deletions client/impl/ydb_internal/grpc_connections/grpc_connections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,11 @@ TDbDriverStatePtr TGRpcConnectionsImpl::GetDriverState(
const std::optional<std::shared_ptr<ICredentialsProviderFactory>>& credentialsProviderFactory
) {
return StateTracker_.GetDriverState(
database.has_value() ? database.value() : DefaultDatabase_,
discoveryEndpoint.has_value() ? discoveryEndpoint.value() : DefaultDiscoveryEndpoint_,
discoveryMode.has_value() ? discoveryMode.value() : DefaultDiscoveryMode_,
sslCredentials.has_value() ? sslCredentials.value() : SslCredentials_,
credentialsProviderFactory.has_value() ? credentialsProviderFactory.value() : DefaultCredentialsProviderFactory_);
database.value_or(DefaultDatabase_),
discoveryEndpoint.value_or(DefaultDiscoveryEndpoint_),
discoveryMode.value_or(DefaultDiscoveryMode_),
sslCredentials.value_or(SslCredentials_),
credentialsProviderFactory.value_or(DefaultCredentialsProviderFactory_));
}

IQueueClientContextPtr TGRpcConnectionsImpl::CreateContext() {
Expand Down
8 changes: 4 additions & 4 deletions client/ydb_datastreams/datastreams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ namespace NYdb::NDataStreams::V1 {
req.set_stream_name(path);
req.set_shard_count(settings.ShardCount_);
if (settings.RetentionStorageMegabytes_.has_value()) {
req.set_retention_storage_megabytes(settings.RetentionStorageMegabytes_.value());
req.set_retention_storage_megabytes(*settings.RetentionStorageMegabytes_);
} else if (settings.RetentionPeriodHours_.has_value()) {
req.set_retention_period_hours(settings.RetentionPeriodHours_.value());
req.set_retention_period_hours(*settings.RetentionPeriodHours_);
} else {
req.set_retention_period_hours(24);
}
Expand Down Expand Up @@ -361,10 +361,10 @@ namespace NYdb::NDataStreams::V1 {
req.set_stream_name(streamName);
req.set_target_shard_count(settings.TargetShardCount_);
if (settings.RetentionPeriodHours_.has_value()) {
req.set_retention_period_hours(settings.RetentionPeriodHours_.value());
req.set_retention_period_hours(*settings.RetentionPeriodHours_);
}
if (settings.RetentionStorageMegabytes_.has_value()) {
req.set_retention_storage_megabytes(settings.RetentionStorageMegabytes_.value());
req.set_retention_storage_megabytes(*settings.RetentionStorageMegabytes_);
}
req.set_write_quota_kb_per_sec(settings.WriteQuotaKbPerSec_);
if (settings.StreamMode_.has_value()) {
Expand Down
4 changes: 2 additions & 2 deletions client/ydb_federated_topic/impl/federated_write_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void TFederatedWriteSession::OpenSubSessionImpl(std::shared_ptr<TDbInfo> db) {
.ReadyToAcceptHander([self = shared_from_this()](NTopic::TWriteSessionEvent::TReadyToAcceptEvent& ev){
TDeferredWrite deferred(self->Subsession);
with_lock(self->Lock) {
Y_ABORT_UNLESS(!(self->PendingToken.has_value()));
Y_ABORT_UNLESS(!self->PendingToken.has_value());
self->PendingToken = std::move(ev.ContinuationToken);
self->PrepareDeferredWrite(deferred);
}
Expand Down Expand Up @@ -262,7 +262,7 @@ void TFederatedWriteSession::WriteInternal(NTopic::TContinuationToken&&, NTopic:
}

bool TFederatedWriteSession::PrepareDeferredWrite(TDeferredWrite& deferred) {
if (!(PendingToken.has_value())) {
if (!PendingToken.has_value()) {
return false;
}
if (OriginalMessagesToPassDown.empty()) {
Expand Down
2 changes: 1 addition & 1 deletion client/ydb_federated_topic/impl/federated_write_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TFederatedWriteSession : public NTopic::IWriteSession,
}

void DoWrite() {
if (!(Token.has_value()) && !(Message.has_value())) {
if (!Token.has_value() && !Message.has_value()) {
return;
}
Y_ABORT_UNLESS(Token.has_value() && Message.has_value());
Expand Down
2 changes: 1 addition & 1 deletion client/ydb_persqueue_core/impl/write_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ std::optional<TContinuationToken> TSimpleBlockingWriteSession::WaitForToken(cons

for (auto event : Writer->GetEvents()) {
if (auto* readyEvent = std::get_if<TWriteSessionEvent::TReadyToAcceptEvent>(&event)) {
Y_ABORT_UNLESS(!(token.has_value()));
Y_ABORT_UNLESS(!token.has_value());
token = std::move(readyEvent->ContinuationToken);
} else if (auto* ackEvent = std::get_if<TWriteSessionEvent::TAcksEvent>(&event)) {
// discard
Expand Down
2 changes: 1 addition & 1 deletion client/ydb_persqueue_core/impl/write_session_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ NThreading::TFuture<void> TWriteSessionImpl::WaitEvent() {
void TWriteSessionImpl::WriteInternal(
TContinuationToken&&, std::string_view data, std::optional<ECodec> codec, ui32 originalSize, std::optional<ui64> seqNo, std::optional<TInstant> createTimestamp
) {
TInstant createdAtValue = createTimestamp.has_value() ? *createTimestamp : TInstant::Now();
TInstant createdAtValue = message.CreateTimestamp_.has_value() ? *message.CreateTimestamp_ : TInstant::Now();
bool readyToAccept = false;
size_t bufferSize = data.size();
with_lock(Lock) {
Expand Down
4 changes: 2 additions & 2 deletions client/ydb_table/impl/table_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1135,12 +1135,12 @@ void TTableClient::TImpl::SetQuery(const TDataQuery& queryData, Ydb::Table::Quer
void TTableClient::TImpl::SetQueryCachePolicy(const std::string&, const TExecDataQuerySettings& settings,
Ydb::Table::QueryCachePolicy* queryCachePolicy)
{
queryCachePolicy->set_keep_in_cache(settings.KeepInQueryCache_ ? settings.KeepInQueryCache_.value() : false);
queryCachePolicy->set_keep_in_cache(settings.KeepInQueryCache_.value_or(false));
}

void TTableClient::TImpl::SetQueryCachePolicy(const TDataQuery&, const TExecDataQuerySettings& settings,
Ydb::Table::QueryCachePolicy* queryCachePolicy) {
queryCachePolicy->set_keep_in_cache(settings.KeepInQueryCache_ ? settings.KeepInQueryCache_.value() : true);
queryCachePolicy->set_keep_in_cache(settings.KeepInQueryCache_.value_or(true));
}

std::optional<std::string> TTableClient::TImpl::GetQueryText(const std::string& queryText) {
Expand Down
2 changes: 1 addition & 1 deletion client/ydb_table/table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,7 @@ static void ConvertCreateTableSettingsToProto(const TCreateTableSettings& settin
for (const auto& familyPolicy : policy.ColumnFamilies_) {
auto* familyProto = proto->mutable_storage_policy()->add_column_families();
if (familyPolicy.Name_) {

familyProto->set_name(familyPolicy.Name_.value());
}
if (familyPolicy.Data_) {
familyProto->mutable_data()->set_media(familyPolicy.Data_.value());
Expand Down
2 changes: 1 addition & 1 deletion client/ydb_topic/impl/write_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ std::optional<TContinuationToken> TSimpleBlockingWriteSession::WaitForToken(cons

for (auto event : Writer->GetEvents()) {
if (auto* readyEvent = std::get_if<TWriteSessionEvent::TReadyToAcceptEvent>(&event)) {
Y_ABORT_UNLESS(!(token.has_value()));
Y_ABORT_UNLESS(!token.has_value());
token = std::move(readyEvent->ContinuationToken);
} else if (auto* ackEvent = std::get_if<TWriteSessionEvent::TAcksEvent>(&event)) {
// discard
Expand Down
6 changes: 3 additions & 3 deletions client/ydb_topic/impl/write_session_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ ui64 TWriteSessionImpl::GetNextIdImpl(const std::optional<ui64>& seqNo) {
Y_ABORT_UNLESS(Lock.IsLocked());

ui64 id = ++NextId;
if (!(AutoSeqNoMode.has_value())) {
AutoSeqNoMode = !(seqNo.has_value());
if (!AutoSeqNoMode.has_value()) {
AutoSeqNoMode = !seqNo.has_value();
}
if (seqNo.has_value()) {
if (!Settings.DeduplicationEnabled_.value_or(true)) {
Expand Down Expand Up @@ -802,7 +802,7 @@ TWriteSessionImpl::TProcessSrvMessageResult TWriteSessionImpl::ProcessServerMess
newLastSeqNo = 0;
}
result.InitSeqNo = newLastSeqNo;
if (!(InitSeqNo.has_value())) {
if (!InitSeqNo.has_value()) {
InitSeqNo = newLastSeqNo;
}

Expand Down
2 changes: 1 addition & 1 deletion library/cpp/getopt/small/modchooser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ int TMainClassArgs::Run(int argc, const char** argv) {
}

const NLastGetopt::TOpts& TMainClassArgs::GetOptions() {
if (!(Opts_.has_value())) {
if (!Opts_.has_value()) {
Opts_ = NLastGetopt::TOpts();
RegisterOptions(Opts_.value());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,6 @@ TEST(PrettyPrinters, String) {
EXPECT_EQ(GtestPrint(std::string_view("hello world")), "\"hello world\"");
}

TEST(PrettyPrinters, Maybe) {
EXPECT_EQ(GtestPrint(std::optional<std::string>("hello world")), "\"hello world\"");
EXPECT_EQ(GtestPrint(std::optional<std::string>()), "nothing");
EXPECT_EQ(GtestPrint(std::nullopt), "nothing");
}

struct T1 {
int x;
};
Expand Down

0 comments on commit d8a3dea

Please sign in to comment.