1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
#pragma once
#include <ydb/public/sdk/cpp/client/ydb_result/result.h>
#include <ydb/public/sdk/cpp/client/ydb_scheme/scheme.h>
#include <ydb/public/sdk/cpp/client/ydb_table/table.h>
namespace Ydb {
namespace LogStore {
class Schema;
class CreateLogStoreRequest;
class CreateLogTableRequest;
class DescribeLogStoreResult;
class DescribeLogTableResult;
}}
namespace NYdb {
namespace NLogStore {
struct TCreateLogStoreSettings : public TOperationRequestSettings<TCreateLogStoreSettings> {
using TSelf = TCreateLogStoreSettings;
};
struct TDropLogStoreSettings : public TOperationRequestSettings<TDropLogStoreSettings> {
using TSelf = TDropLogStoreSettings;
};
struct TDescribeLogStoreSettings : public TOperationRequestSettings<TDescribeLogStoreSettings> {
using TSelf = TDescribeLogStoreSettings;
};
struct TCreateLogTableSettings : public TOperationRequestSettings<TCreateLogTableSettings> {
using TSelf = TCreateLogTableSettings;
};
struct TDropLogTableSettings : public TOperationRequestSettings<TDropLogTableSettings> {
using TSelf = TDropLogTableSettings;
};
struct TDescribeLogTableSettings : public TOperationRequestSettings<TDescribeLogTableSettings> {
using TSelf = TDescribeLogTableSettings;
};
using NTable::TTtlSettings;
using NTable::TAlterTtlSettings;
struct TAlterLogTableSettings : public TOperationRequestSettings<TAlterLogTableSettings> {
using TSelf = TAlterLogTableSettings;
TSelf& AlterTtlSettings(const TMaybe<TAlterTtlSettings>& value);
const TMaybe<TAlterTtlSettings>& GetAlterTtlSettings() const;
private:
TMaybe<TAlterTtlSettings> AlterTtlSettings_;
};
TType MakeColumnType(EPrimitiveType primitiveType);
class TSchema {
public:
TSchema(const TVector<TColumn>& columns = {}, const TVector<TString> primaryKeyColumns = {})
: Columns(columns)
, PrimaryKeyColumns(primaryKeyColumns)
{}
explicit TSchema(const Ydb::LogStore::Schema& schema);
void SerializeTo(Ydb::LogStore::Schema& schema) const;
TVector<TColumn> GetColumns() const {
return Columns;
}
const TVector<TString>& GetPrimaryKeyColumns() const {
return PrimaryKeyColumns;
}
private:
TVector<TColumn> Columns;
TVector<TString> PrimaryKeyColumns;
};
class TLogStoreDescription {
public:
TLogStoreDescription(ui32 columnShardCount, const THashMap<TString, TSchema>& schemaPresets);
TLogStoreDescription(Ydb::LogStore::DescribeLogStoreResult&& desc, const TDescribeLogStoreSettings& describeSettings);
void SerializeTo(Ydb::LogStore::CreateLogStoreRequest& request) const;
const THashMap<TString, TSchema>& GetSchemaPresets() const {
return SchemaPresets;
}
ui32 GetColumnShardCount() const {
return ColumnShardCount;
}
const TString& GetOwner() const {
return Owner;
}
const TVector<NScheme::TPermissions>& GetPermissions() const {
return Permissions;
}
const TVector<NScheme::TPermissions>& GetEffectivePermissions() const {
return EffectivePermissions;
}
private:
ui32 ColumnShardCount;
THashMap<TString, TSchema> SchemaPresets;
TString Owner;
TVector<NScheme::TPermissions> Permissions;
TVector<NScheme::TPermissions> EffectivePermissions;
};
class TLogTableDescription {
public:
TLogTableDescription(const TString& schemaPresetName, const TVector<TString>& shardingColumns,
ui32 columnShardCount, const TMaybe<TTtlSettings>& ttlSettings = {});
TLogTableDescription(const TSchema& schema, const TVector<TString>& shardingColumns,
ui32 columnShardCount, const TMaybe<TTtlSettings>& ttlSettings = {});
TLogTableDescription(Ydb::LogStore::DescribeLogTableResult&& desc, const TDescribeLogTableSettings& describeSettings);
void SerializeTo(Ydb::LogStore::CreateLogTableRequest& request) const;
const TSchema& GetSchema() const {
return Schema;
}
const TVector<TString>& GetShardingColumns() const {
return ShardingColumns;
}
ui32 GetColumnShardCount() const {
return ColumnShardCount;
}
const TMaybe<TTtlSettings>& GetTtlSettings() const {
return TtlSettings;
}
const TString& GetOwner() const {
return Owner;
}
const TVector<NScheme::TPermissions>& GetPermissions() const {
return Permissions;
}
const TVector<NScheme::TPermissions>& GetEffectivePermissions() const {
return EffectivePermissions;
}
private:
const TString SchemaPresetName;
const TSchema Schema;
const TVector<TString> ShardingColumns;
const ui32 ColumnShardCount;
const TMaybe<TTtlSettings> TtlSettings;
TString Owner;
TVector<NScheme::TPermissions> Permissions;
TVector<NScheme::TPermissions> EffectivePermissions;
};
//! Represents result of DescribeLogStore call
class TDescribeLogStoreResult : public TStatus {
public:
TDescribeLogStoreResult(TStatus&& status, Ydb::LogStore::DescribeLogStoreResult&& desc,
const TDescribeLogStoreSettings& describeSettings);
const TLogStoreDescription& GetDescription() const {
return LogStoreDescription_;
}
private:
TLogStoreDescription LogStoreDescription_;
};
//! Represents result of DescribeLogTable call
class TDescribeLogTableResult : public TStatus {
public:
TDescribeLogTableResult(TStatus&& status, Ydb::LogStore::DescribeLogTableResult&& desc,
const TDescribeLogTableSettings& describeSettings);
TLogTableDescription GetDescription() const {
return LogTableDescription_;
}
private:
TLogTableDescription LogTableDescription_;
};
using TAsyncDescribeLogStoreResult = NThreading::TFuture<TDescribeLogStoreResult>;
using TAsyncDescribeLogTableResult = NThreading::TFuture<TDescribeLogTableResult>;
class TLogStoreClient {
class TImpl;
public:
TLogStoreClient(const TDriver& driver, const TCommonClientSettings& settings = TCommonClientSettings());
TAsyncStatus CreateLogStore(const TString& path, TLogStoreDescription&& tableDesc,
const TCreateLogStoreSettings& settings = TCreateLogStoreSettings());
TAsyncDescribeLogStoreResult DescribeLogStore(const TString& path,
const TDescribeLogStoreSettings& settings = TDescribeLogStoreSettings());
TAsyncStatus DropLogStore(const TString& path, const TDropLogStoreSettings& settings = TDropLogStoreSettings());
TAsyncStatus CreateLogTable(const TString& path, TLogTableDescription&& tableDesc,
const TCreateLogTableSettings& settings = TCreateLogTableSettings());
TAsyncDescribeLogTableResult DescribeLogTable(const TString& path,
const TDescribeLogTableSettings& settings = TDescribeLogTableSettings());
TAsyncStatus DropLogTable(const TString& path, const TDropLogTableSettings& settings = TDropLogTableSettings());
TAsyncStatus AlterLogTable(const TString& path, const TAlterLogTableSettings& settings = TAlterLogTableSettings());
private:
std::shared_ptr<TImpl> Impl_;
};
}}
|