Skip to content

Commit 1f2381a

Browse files
authored
Get rid of unnecessary code (#10410)
1 parent e2fabd1 commit 1f2381a

File tree

8 files changed

+38
-105
lines changed

8 files changed

+38
-105
lines changed

ydb/core/wrappers/abstract.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
#include <ydb/core/protos/flat_scheme_op.pb.h>
44
#include <ydb/core/wrappers/events/abstract.h>
55
#include <ydb/core/wrappers/events/common.h>
6-
#include <ydb/core/wrappers/events/delete_objects.h>
76
#include <ydb/core/wrappers/events/get_object.h>
8-
#include <ydb/core/wrappers/events/list_objects.h>
97
#include <ydb/core/wrappers/events/object_exists.h>
108

119
#include <memory>

ydb/core/wrappers/events/common.h

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct TRequestWithBody: public TGenericRequest<TDerived, EventType, T> {
6565
using TBase = TRequestWithBody<TDerived, EventType, T>;
6666
};
6767

68-
template <typename TDerived, ui32 EventType, typename T, typename U = T>
68+
template <typename TDerived, ui32 EventType, typename T, typename U = T, bool HasKey = true>
6969
struct TGenericResponse: public NActors::TEventLocal<TDerived, EventType> {
7070
private:
7171
IRequestContext::TPtr RequestContext;
@@ -90,6 +90,7 @@ struct TGenericResponse: public NActors::TEventLocal<TDerived, EventType> {
9090
, Key(key)
9191
, Result(TDerived::ResultFromOutcome(outcome))
9292
{
93+
static_assert(HasKey, "Object has no key");
9394
}
9495

9596
bool IsSuccess() const {
@@ -114,11 +115,17 @@ struct TGenericResponse: public NActors::TEventLocal<TDerived, EventType> {
114115
return outcome;
115116
}
116117

118+
virtual TString ToStringBody() const {
119+
auto result = TStringBuilder();
120+
if constexpr (HasKey) {
121+
result << " Key: " << (Key ? "null" : *Key);
122+
}
123+
result << " Result: " << Result;
124+
return result;
125+
}
126+
117127
TString ToString() const override {
118-
return TStringBuilder() << this->ToStringHeader() << " {"
119-
<< " Key: " << (Key ? "null" : *Key)
120-
<< " Result: " << Result
121-
<< " }";
128+
return TStringBuilder() << this->ToStringHeader() << " {" << ToStringBody() << " }";
122129
}
123130
};
124131

@@ -143,12 +150,10 @@ struct TResponseWithBody: public TGenericResponse<TDerived, EventType, T, U> {
143150
{
144151
}
145152

146-
TString ToString() const override {
147-
return TStringBuilder() << this->ToStringHeader() << " {"
148-
<< " Key: " << (this->Key ? "null" : *this->Key)
149-
<< " Result: " << this->Result
150-
<< " Body: " << Body.size() << "b"
151-
<< " }";
153+
TString ToStringBody() const override {
154+
return TStringBuilder()
155+
<< TBase::ToStringBody()
156+
<< " Body: " << Body.size() << "b";
152157
}
153158
};
154159

@@ -160,48 +165,48 @@ struct TResponseWithBody: public TGenericResponse<TDerived, EventType, T, U> {
160165
#define DEFINE_GENERIC_REQUEST(name) \
161166
DEFINE_REQUEST(name, TGenericRequest)
162167

163-
#define DECLARE_GENERIC_RESPONSE(name) \
164-
struct TEv##name##Response: public TGenericResponse<TEv##name##Response, Ev##name##Response, Aws::S3::Model::name##Result> { \
168+
#define DECLARE_GENERIC_RESPONSE_K(name, hasKey) \
169+
struct TEv##name##Response: public TGenericResponse<TEv##name##Response, Ev##name##Response, Aws::S3::Model::name##Result, Aws::S3::Model::name##Result, hasKey> { \
165170
private: \
166-
using TBase = TGenericResponse<TEv##name##Response, Ev##name##Response, Aws::S3::Model::name##Result>; \
171+
using TBase = TGenericResponse<TEv##name##Response, Ev##name##Response, Aws::S3::Model::name##Result, Aws::S3::Model::name##Result, hasKey>; \
167172
public: \
168173
using TBase::TBase;
169174

170-
#define DECLARE_RESPONSE_WITH_BODY(name, result_t) \
171-
struct TEv##name##Response: public TResponseWithBody<TEv##name##Response, Ev##name##Response, Aws::S3::Model::name##Result, result_t> { \
172-
private: \
173-
using TBase = TResponseWithBody<TEv##name##Response, Ev##name##Response, Aws::S3::Model::name##Result, result_t>; \
174-
public: \
175-
using TBase::TBase;
175+
#define DEFINE_GENERIC_RESPONSE_K(name, hasKey) \
176+
DECLARE_GENERIC_RESPONSE_K(name, hasKey) \
177+
}
176178

177179
#define DEFINE_GENERIC_RESPONSE(name) \
178-
DECLARE_GENERIC_RESPONSE(name) \
179-
}
180+
DEFINE_GENERIC_RESPONSE_K(name, true)
180181

181-
#define DEFINE_GENERIC_REQUEST_RESPONSE(name) \
182+
#define DEFINE_GENERIC_REQUEST_RESPONSE_K(name, hasKey) \
182183
DEFINE_GENERIC_REQUEST(name); \
183-
DEFINE_GENERIC_RESPONSE(name)
184+
DEFINE_GENERIC_RESPONSE_K(name, hasKey)
185+
186+
#define DEFINE_GENERIC_REQUEST_RESPONSE(name) \
187+
DEFINE_GENERIC_REQUEST_RESPONSE_K(name, true)
184188

185189
DEFINE_REQUEST(PutObject, TRequestWithBody);
186190
DEFINE_GENERIC_RESPONSE(PutObject);
187191

188192
DEFINE_REQUEST(UploadPart, TRequestWithBody);
189193
DEFINE_GENERIC_RESPONSE(UploadPart);
190194

191-
DEFINE_GENERIC_REQUEST_RESPONSE(HeadObject);
192-
DEFINE_GENERIC_REQUEST_RESPONSE(DeleteObject);
193-
DEFINE_GENERIC_REQUEST_RESPONSE(CreateMultipartUpload);
194-
DEFINE_GENERIC_REQUEST_RESPONSE(CompleteMultipartUpload);
195195
DEFINE_GENERIC_REQUEST_RESPONSE(AbortMultipartUpload);
196-
197-
DEFINE_GENERIC_REQUEST(UploadPartCopy);
198-
DEFINE_GENERIC_RESPONSE(UploadPartCopy);
196+
DEFINE_GENERIC_REQUEST_RESPONSE(CompleteMultipartUpload);
197+
DEFINE_GENERIC_REQUEST_RESPONSE(CreateMultipartUpload);
198+
DEFINE_GENERIC_REQUEST_RESPONSE(DeleteObject);
199+
DEFINE_GENERIC_REQUEST_RESPONSE_K(DeleteObjects, false);
200+
DEFINE_GENERIC_REQUEST_RESPONSE(HeadObject);
201+
DEFINE_GENERIC_REQUEST_RESPONSE_K(ListObjects, false);
202+
DEFINE_GENERIC_REQUEST_RESPONSE(UploadPartCopy);
199203

200204
#undef DEFINE_REQUEST
201205
#undef DEFINE_GENERIC_REQUEST
202-
#undef DECLARE_GENERIC_RESPONSE
203-
#undef DECLARE_RESPONSE_WITH_BODY
206+
#undef DECLARE_GENERIC_RESPONSE_K
204207
#undef DEFINE_GENERIC_RESPONSE
208+
#undef DEFINE_GENERIC_RESPONSE_K
205209
#undef DEFINE_GENERIC_REQUEST_RESPONSE
210+
#undef DEFINE_GENERIC_REQUEST_RESPONSE_K
206211

207212
}

ydb/core/wrappers/events/delete_objects.cpp

Lines changed: 0 additions & 5 deletions
This file was deleted.

ydb/core/wrappers/events/delete_objects.h

Lines changed: 0 additions & 24 deletions
This file was deleted.

ydb/core/wrappers/events/list_objects.cpp

Lines changed: 0 additions & 5 deletions
This file was deleted.

ydb/core/wrappers/events/list_objects.h

Lines changed: 0 additions & 24 deletions
This file was deleted.

ydb/core/wrappers/events/ya.make

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ IF (OS_WINDOWS)
77
ELSE()
88
SRCS(
99
common.cpp
10-
list_objects.cpp
1110
object_exists.cpp
12-
delete_objects.cpp
1311
get_object.cpp
1412
s3_out.cpp
1513
abstract.cpp

ydb/core/wrappers/s3_storage.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@
77
#include <contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentials.h>
88
#include <contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSClient.h>
99
#include <contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/ClientConfiguration.h>
10-
#include <contrib/libs/aws-sdk-cpp/aws-cpp-sdk-s3/include/aws/s3/model/AbortMultipartUploadRequest.h>
11-
#include <contrib/libs/aws-sdk-cpp/aws-cpp-sdk-s3/include/aws/s3/model/CreateMultipartUploadRequest.h>
12-
#include <contrib/libs/aws-sdk-cpp/aws-cpp-sdk-s3/include/aws/s3/model/CompleteMultipartUploadRequest.h>
13-
#include <contrib/libs/aws-sdk-cpp/aws-cpp-sdk-s3/include/aws/s3/model/DeleteObjectRequest.h>
14-
#include <contrib/libs/aws-sdk-cpp/aws-cpp-sdk-s3/include/aws/s3/model/GetObjectRequest.h>
15-
#include <contrib/libs/aws-sdk-cpp/aws-cpp-sdk-s3/include/aws/s3/model/HeadObjectRequest.h>
16-
#include <contrib/libs/aws-sdk-cpp/aws-cpp-sdk-s3/include/aws/s3/model/PutObjectRequest.h>
17-
#include <contrib/libs/aws-sdk-cpp/aws-cpp-sdk-s3/include/aws/s3/model/StorageClass.h>
18-
#include <contrib/libs/aws-sdk-cpp/aws-cpp-sdk-s3/include/aws/s3/model/UploadPartCopyRequest.h>
19-
#include <contrib/libs/aws-sdk-cpp/aws-cpp-sdk-s3/include/aws/s3/model/UploadPartRequest.h>
2010
#include <contrib/libs/aws-sdk-cpp/aws-cpp-sdk-s3/include/aws/s3/S3Client.h>
2111

2212
#include <ydb/library/actors/core/log.h>

0 commit comments

Comments
 (0)