Skip to content

Import YDB C++ SDK 12 #523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/import_generation.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12
13
2 changes: 1 addition & 1 deletion .github/last_commit.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ec36c2f7151e1e7718c2f0c0b2292383cab01e64
6e380d54416c706390bbe2609c7a054de2bf3b89
3 changes: 2 additions & 1 deletion .github/scripts/copy_sources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ cp -r $1/ydb/public/api/grpc $tmp_dir/src/api
cp -r $1/ydb/public/api/protos $tmp_dir/src/api

rm -r $tmp_dir/src/api/protos/out
rm $tmp_dir/include/ydb-cpp-sdk/type_switcher.h $tmp_dir/src/version.h
rm $tmp_dir/include/ydb-cpp-sdk/type_switcher.h $tmp_dir/include/ydb-cpp-sdk/client/proto/private.h $tmp_dir/src/version.h

cp -r $2/util $tmp_dir
cp -r $2/library $tmp_dir
Expand All @@ -53,6 +53,7 @@ cp $2/LICENSE $tmp_dir
cp $2/README.md $tmp_dir

cp $2/include/ydb-cpp-sdk/type_switcher.h $tmp_dir/include/ydb-cpp-sdk/type_switcher.h
cp $2/include/ydb-cpp-sdk/client/proto/private.h $tmp_dir/include/ydb-cpp-sdk/client/proto/private.h
cp $2/src/version.h $tmp_dir/src/version.h

cd $2
Expand Down
2 changes: 2 additions & 0 deletions include/ydb-cpp-sdk/client/discovery/discovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct TNodeRegistrationSettings : public TSimpleRequestSettings<TNodeRegistrati
FLUENT_SETTING(std::string, DomainPath);
FLUENT_SETTING_DEFAULT(bool, FixedNodeId, false);
FLUENT_SETTING(std::string, Path);
FLUENT_SETTING(std::string, BridgePileName);
};

struct TEndpointInfo {
Expand Down Expand Up @@ -96,6 +97,7 @@ struct TNodeInfo {
std::string Address;
TNodeLocation Location;
uint64_t Expire;
std::optional<uint32_t> BridgePileId;
};

class TNodeRegistrationResult : public TStatus {
Expand Down
6 changes: 6 additions & 0 deletions include/ydb-cpp-sdk/client/proto/accessor.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "private.h"

#include <src/api/protos/ydb_coordination.pb.h>
#include <src/api/protos/ydb_export.pb.h>
#include <src/api/protos/ydb_import.pb.h>
Expand Down Expand Up @@ -45,6 +47,10 @@ class TProtoAccessor {
static const Ydb::Topic::DescribeConsumerResult& GetProto(const NYdb::NTopic::TConsumerDescription& consumerDescription);
static const Ydb::Monitoring::SelfCheckResult& GetProto(const NYdb::NMonitoring::TSelfCheckResult& selfCheckResult);
static const Ydb::Coordination::DescribeNodeResult& GetProto(const NYdb::NCoordination::TNodeDescription &describeNodeResult);
#ifdef YDB_SDK_INTERNAL_CLIENTS
static const Ydb::Replication::DescribeReplicationResult& GetProto(const NYdb::NReplication::TDescribeReplicationResult& desc);
static const Ydb::View::DescribeViewResult& GetProto(const NYdb::NView::TDescribeViewResult& desc);
#endif

static NTable::TQueryStats FromProto(const Ydb::TableStats::QueryStats& queryStats);
static NTable::TTableDescription FromProto(const Ydb::Table::CreateTableRequest& request);
Expand Down
Empty file.
10 changes: 8 additions & 2 deletions include/ydb-cpp-sdk/client/query/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,21 @@ class TResultSetMeta {
public:
TResultSetMeta() = default;

explicit TResultSetMeta(const std::vector<TColumn>& columns)
explicit TResultSetMeta(const std::vector<TColumn>& columns, uint64_t rowsCount = 0, bool finished = false)
: Columns(columns)
, RowsCount(rowsCount)
, Finished(finished)
{}

explicit TResultSetMeta(std::vector<TColumn>&& columns)
explicit TResultSetMeta(std::vector<TColumn>&& columns, uint64_t rowsCount = 0, bool finished = false)
: Columns(std::move(columns))
, RowsCount(rowsCount)
, Finished(finished)
{}

std::vector<TColumn> Columns;
uint64_t RowsCount = 0;
bool Finished = false;
};

class TScriptExecutionOperation : public TOperation {
Expand Down
4 changes: 4 additions & 0 deletions include/ydb-cpp-sdk/client/table/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ class TChangefeedDescription {

// Enable virtual timestamps
TChangefeedDescription& WithVirtualTimestamps();
// Enable schema changes
TChangefeedDescription& WithSchemaChanges();
// Enable resolved timestamps
TChangefeedDescription& WithResolvedTimestamps(const TDuration& interval);
// Customise retention period of underlying topic (24h by default).
Expand All @@ -415,6 +417,7 @@ class TChangefeedDescription {
EChangefeedFormat GetFormat() const;
EChangefeedState GetState() const;
bool GetVirtualTimestamps() const;
bool GetSchemaChanges() const;
const std::optional<TDuration>& GetResolvedTimestamps() const;
bool GetInitialScan() const;
const std::unordered_map<std::string, std::string>& GetAttributes() const;
Expand Down Expand Up @@ -442,6 +445,7 @@ class TChangefeedDescription {
EChangefeedFormat Format_;
EChangefeedState State_ = EChangefeedState::Unknown;
bool VirtualTimestamps_ = false;
bool SchemaChanges_ = false;
std::optional<TDuration> ResolvedTimestamps_;
std::optional<TDuration> RetentionPeriod_;
bool InitialScan_ = false;
Expand Down
1 change: 1 addition & 0 deletions include/ydb-cpp-sdk/client/topic/control_plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class TPartitionConsumerStats {
class TPartitionLocation {
public:
TPartitionLocation(const Ydb::Topic::PartitionLocation& partitionLocation);
TPartitionLocation(std::int32_t nodeId, std::int64_t generation);
int32_t GetNodeId() const;
int64_t GetGeneration() const;

Expand Down
6 changes: 6 additions & 0 deletions include/ydb-cpp-sdk/client/topic/read_events.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#pragma once

#include "codecs.h"
#include "control_plane.h"
#include "events_common.h"

#include <util/datetime/base.h>


namespace NYdb::inline V3::NTopic {

//! Partition session.
Expand Down Expand Up @@ -42,10 +44,14 @@ struct TPartitionSession: public TThrRefBase, public TPrintable<TPartitionSessio
}

protected:

uint64_t PartitionSessionId;
std::string TopicPath;
std::string ReadSessionId;
uint64_t PartitionId;
std::optional<TPartitionLocation> Location;
/*TDirectReadId*/ std::int64_t NextDirectReadId = 1;
std::optional</*TDirectReadId*/ std::int64_t> LastDirectReadId;
};

template<>
Expand Down
3 changes: 3 additions & 0 deletions include/ydb-cpp-sdk/client/topic/read_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ struct TReadSessionSettings: public TRequestSettings<TReadSessionSettings> {
//! AutoPartitioningSupport.
FLUENT_SETTING_DEFAULT(bool, AutoPartitioningSupport, false);

// TODO(qyryq) Uncomment when direct read is ready.
// FLUENT_SETTING_DEFAULT(bool, DirectRead, false);

//! Log.
FLUENT_SETTING_OPTIONAL(TLog, Log);
};
Expand Down
15 changes: 8 additions & 7 deletions include/ydb-cpp-sdk/library/retry/retry_policy.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <util/datetime/base.h>
#include <util/generic/maybe.h>
#include <util/generic/typetraits.h>
#include <util/random/random.h>

Expand Down Expand Up @@ -41,7 +42,7 @@ struct IRetryPolicy {

//! Calculate delay before next retry if next retry is allowed.
//! Returns empty maybe if retry is not allowed anymore.
[[nodiscard]] virtual std::optional<TDuration> GetNextRetryDelay(typename TTypeTraits<TArgs>::TFuncParam... args) = 0;
[[nodiscard]] virtual TMaybe<TDuration> GetNextRetryDelay(typename TTypeTraits<TArgs>::TFuncParam... args) = 0;
};

virtual ~IRetryPolicy() = default;
Expand Down Expand Up @@ -81,8 +82,8 @@ struct TNoRetryPolicy : IRetryPolicy<TArgs...> {
using IRetryState = typename IRetryPolicy<TArgs...>::IRetryState;

struct TNoRetryState : IRetryState {
std::optional<TDuration> GetNextRetryDelay(typename TTypeTraits<TArgs>::TFuncParam...) override {
return std::nullopt;
TMaybe<TDuration> GetNextRetryDelay(typename TTypeTraits<TArgs>::TFuncParam...) override {
return {};
}
};

Expand Down Expand Up @@ -123,10 +124,10 @@ struct TExponentialBackoffPolicy : IRetryPolicy<TArgs...> {
{
}

std::optional<TDuration> GetNextRetryDelay(typename TTypeTraits<TArgs>::TFuncParam... args) override {
TMaybe<TDuration> GetNextRetryDelay(typename TTypeTraits<TArgs>::TFuncParam... args) override {
const ERetryErrorClass errorClass = RetryClassFunction(args...);
if (errorClass == ERetryErrorClass::NoRetry || AttemptsDone >= MaxRetries || StartTime && TInstant::Now() - StartTime >= MaxTime) {
return std::nullopt;
return {};
}

if (errorClass == ERetryErrorClass::LongRetry) {
Expand Down Expand Up @@ -212,10 +213,10 @@ struct TFixedIntervalPolicy : IRetryPolicy<TArgs...> {
{
}

std::optional<TDuration> GetNextRetryDelay(typename TTypeTraits<TArgs>::TFuncParam... args) override {
TMaybe<TDuration> GetNextRetryDelay(typename TTypeTraits<TArgs>::TFuncParam... args) override {
const ERetryErrorClass errorClass = RetryClassFunction(args...);
if (errorClass == ERetryErrorClass::NoRetry || AttemptsDone >= MaxRetries || StartTime && TInstant::Now() - StartTime >= MaxTime) {
return std::nullopt;
return {};
}

const TDuration delay = NRetryDetails::RandomizeDelay(errorClass == ERetryErrorClass::LongRetry ? LongRetryDelay : Delay);
Expand Down
3 changes: 3 additions & 0 deletions src/api/grpc/draft/ydb_dynamic_config_v1.proto
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,7 @@ service DynamicConfigService {

// Generate dynamic config based on cluster's static config.
rpc FetchStartupConfig(DynamicConfig.FetchStartupConfigRequest) returns (DynamicConfig.FetchStartupConfigResponse);

// Get configuration version of nodes.
rpc GetConfigurationVersion(DynamicConfig.GetConfigurationVersionRequest) returns (DynamicConfig.GetConfigurationVersionResponse);
}
39 changes: 39 additions & 0 deletions src/api/protos/draft/ydb_dynamic_config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,42 @@ message FetchStartupConfigResult {
// YAML document with generated dynamic config
string config = 1;
}

message GetConfigurationVersionRequest {
Ydb.Operations.OperationParams operation_params = 1;
// List nodes with different configuration versions
bool list_nodes = 2;
}

message GetConfigurationVersionResponse {
// Result of request will be inside operation.
Ydb.Operations.Operation operation = 1;
}

message NodeInfo {
message Endpoint {
// Node's hostname
string hostname = 1;
// Node's port
uint32 port = 2;
}
// Node's id
uint32 node_id = 1;
// Node's endpoint
Endpoint endpoint = 2;
}

message GetConfigurationVersionResult {
// Count of nodes with V1 configuration version
uint32 v1_nodes = 1;
// List of nodes with V1 configuration version
repeated NodeInfo v1_nodes_list = 2;
// Count of nodes with V2 configuration version
uint32 v2_nodes = 3;
// List of nodes with V2 configuration version
repeated NodeInfo v2_nodes_list = 4;
// Count of nodes with unknown configuration version
uint32 unknown_nodes = 5;
// List of nodes with unknown configuration version
repeated NodeInfo unknown_nodes_list = 6;
}
2 changes: 2 additions & 0 deletions src/api/protos/ydb_discovery.proto
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ message NodeInfo {
optional string address = 5;
optional NodeLocation location = 6;
optional uint64 expire = 7;
optional uint32 bridge_pile_id = 8;
}

message NodeRegistrationRequest {
Expand All @@ -94,6 +95,7 @@ message NodeRegistrationRequest {
optional string domain_path = 6;
optional bool fixed_node_id = 7;
optional string path = 8;
optional string bridge_pile_name = 9;
}

message NodeRegistrationResult {
Expand Down
2 changes: 2 additions & 0 deletions src/api/protos/ydb_query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ message ExecuteQueryRequest {

message ResultSetMeta {
repeated Ydb.Column columns = 1;
uint64 number_rows = 2;
bool finished = 3;
}

message ExecuteQueryResponsePart {
Expand Down
1 change: 1 addition & 0 deletions src/api/protos/ydb_scheme.proto
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ message Entry {
VIEW = 20;
RESOURCE_POOL = 21;
TRANSFER = 23;
SYS_VIEW = 24;
}

// Name of scheme entry (dir2 of /dir1/dir2)
Expand Down
4 changes: 4 additions & 0 deletions src/api/protos/ydb_table.proto
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ message Changefeed {
google.protobuf.Duration resolved_timestamps_interval = 9;
// Partitioning settings of underlying topic.
Topic.PartitioningSettings topic_partitioning_settings = 10;
// Emit schema change events or not
bool schema_changes = 11;
}

message ChangefeedDescription {
Expand Down Expand Up @@ -274,6 +276,8 @@ message ChangefeedDescription {
google.protobuf.Duration resolved_timestamps_interval = 8;
// Progress of initial scan. If unspecified, initial scan was not launched.
InitialScanProgress initial_scan_progress = 9;
// State of emitting of schema change events
bool schema_changes = 10;
}

message StoragePool {
Expand Down
6 changes: 5 additions & 1 deletion src/client/discovery/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ TNodeInfo::TNodeInfo(const Ydb::Discovery::NodeInfo& info)
, Address(info.address())
, Location(info.location())
, Expire(info.expire())
{}
, BridgePileId(info.has_bridge_pile_id() ? std::make_optional(info.bridge_pile_id()) : std::nullopt)
{}

TNodeRegistrationResult::TNodeRegistrationResult(TStatus&& status, const Ydb::Discovery::NodeRegistrationResult& proto)
: TStatus(std::move(status))
Expand Down Expand Up @@ -208,6 +209,9 @@ class TDiscoveryClient::TImpl : public TClientImplCommon<TDiscoveryClient::TImpl
if (!settings.Path_.empty()) {
request.set_path(TStringType{settings.Path_});
}
if (!settings.BridgePileName_.empty()) {
request.set_bridge_pile_name(TStringType{settings.BridgePileName_});
}

auto requestLocation = request.mutable_location();
const auto& location = settings.Location_;
Expand Down
5 changes: 0 additions & 5 deletions src/client/persqueue_public/ut/read_session_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@ class TReadSessionImplTestSetup {
std::shared_ptr<TCallbackContext<TSingleClusterReadSessionImpl>> CbContext;
std::shared_ptr<TThreadPool> ThreadPool;
::IExecutor::TPtr DefaultExecutor;
std::shared_ptr<std::unordered_map<ECodec, THolder<NTopic::ICodec>>> ProvidedCodecs = std::make_shared<std::unordered_map<ECodec, THolder<NTopic::ICodec>>>();
};

class TReorderingExecutor : public ::IExecutor {
Expand Down Expand Up @@ -588,10 +587,6 @@ TReadSessionImplTestSetup::TReadSessionImplTestSetup() {
.Counters(MakeIntrusive<NYdb::NPersQueue::TReaderCounters>(MakeIntrusive<::NMonitoring::TDynamicCounters>()));

Log.SetFormatter(GetPrefixLogFormatter(""));

(*ProvidedCodecs)[ECodec::GZIP] = MakeHolder<NTopic::TGzipCodec>();
(*ProvidedCodecs)[ECodec::LZOP] = MakeHolder<NTopic::TUnsupportedCodec>();
(*ProvidedCodecs)[ECodec::ZSTD] = MakeHolder<NTopic::TZstdCodec>();
}

TReadSessionImplTestSetup::~TReadSessionImplTestSetup() noexcept(false) {
Expand Down
21 changes: 21 additions & 0 deletions src/client/persqueue_public/ut/ut_utils/ut_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,22 @@ using NYdb::NTopic::IAsyncExecutor;

namespace NYdb::NPersQueue::NTests {

struct TPersQueueYdbSdkTestSetupSettings {
TString TestCaseName;
bool Start = true;
TVector<NKikimrServices::EServiceKikimr> LogServices = ::NPersQueue::TTestServer::LOGGED_SERVICES;
NActors::NLog::EPriority LogPriority = NActors::NLog::PRI_DEBUG;
ui32 NodeCount = NKikimr::NPersQueueTests::PQ_DEFAULT_NODE_COUNT;
size_t TopicPartitionsCount = 1;
};

class TPersQueueYdbSdkTestSetup : public ::NPersQueue::SDKTestSetup {
THolder<NYdb::TDriver> Driver;
THolder<NYdb::NPersQueue::TPersQueueClient> PersQueueClient;

TAdaptiveLock Lock;
public:
// TODO(qyryq) Delete this ctor in favor of TPersQueueYdbSdkTestSetupSettings.
TPersQueueYdbSdkTestSetup(const TString& testCaseName, bool start = true,
const TVector<NKikimrServices::EServiceKikimr>& logServices = ::NPersQueue::TTestServer::LOGGED_SERVICES,
NActors::NLog::EPriority logPriority = NActors::NLog::PRI_DEBUG,
Expand All @@ -29,6 +39,17 @@ class TPersQueueYdbSdkTestSetup : public ::NPersQueue::SDKTestSetup {
{
}

TPersQueueYdbSdkTestSetup(TPersQueueYdbSdkTestSetupSettings settings)
: SDKTestSetup(
settings.TestCaseName,
settings.Start,
settings.LogServices,
settings.LogPriority,
settings.NodeCount,
settings.TopicPartitionsCount)
{
}

~TPersQueueYdbSdkTestSetup() {
if (PersQueueClient) {
PersQueueClient = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/client/query/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ TScriptExecutionOperation::TScriptExecutionOperation(TStatus&& status, Ydb::Oper
for (const auto& column : resultSetMeta.columns()) {
columns.emplace_back(column.name(), column.type());
}
Metadata_.ResultSetsMeta.emplace_back(std::move(columns));
Metadata_.ResultSetsMeta.emplace_back(std::move(columns), resultSetMeta.number_rows(), resultSetMeta.finished());
}

if (metadata.has_script_content()) {
Expand Down
Loading
Loading