Skip to content

Commit e84c813

Browse files
committed
Intermediate changes
x-stable-origin-commit: 8b96eef194d7fb3b315816b97322e8dd90bf3d94
1 parent df6e996 commit e84c813

File tree

1,124 files changed

+7615
-5454
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,124 files changed

+7615
-5454
lines changed

.github/workflows/docs_release.yaml

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

library/cpp/actors/interconnect/interconnect_handshake.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,11 @@ namespace NActors {
491491
s << ", errorReason# " << errorReason;
492492
errorCallback(s.Str());
493493
}
494-
} else {
494+
} else if (proto.HasVersionTag()) {
495495
ValidateVersionTag(proto, std::forward<TCallback>(errorCallback));
496+
} else {
497+
LOG_LOG_IC_X(NActorsServices::INTERCONNECT, "ICH09", NLog::PRI_WARN,
498+
"Neither CompatibilityInfo nor VersionTag of the peer can be validated, accepting by default");
496499
}
497500
}
498501

library/cpp/actors/util/rope.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -915,8 +915,6 @@ class TRopeArena {
915915

916916
TAllocateCallback Allocator;
917917
TRope Arena;
918-
size_t Size = 0;
919-
THashSet<const void*> AccountedBuffers;
920918

921919
public:
922920
TRopeArena(TAllocateCallback&& allocator)
@@ -949,16 +947,6 @@ class TRopeArena {
949947

950948
return res;
951949
}
952-
953-
size_t GetSize() const {
954-
return Size;
955-
}
956-
957-
void AccountChunk(const TRcBuf& chunk) {
958-
if (AccountedBuffers.insert(chunk.Backend.UniqueId()).second) {
959-
Size += chunk.GetOccupiedMemorySize();
960-
}
961-
}
962950
};
963951

964952
struct TRopeUtils {
@@ -1131,9 +1119,6 @@ inline TRope TRope::CopySpaceOptimized(TRope&& origin, size_t worstRatioPer1k, T
11311119
}
11321120
res.Size = origin.Size;
11331121
origin = TRope();
1134-
for (const TRcBuf& chunk : res.Chain) {
1135-
arena.AccountChunk(chunk);
1136-
}
11371122
return res;
11381123
}
11391124

library/cpp/grpc/client/grpc_client_low.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ struct TGrpcStatus {
131131
TString Details;
132132
int GRpcStatusCode;
133133
bool InternalError;
134+
std::multimap<TString, TString> ServerTrailingMetadata;
134135

135136
TGrpcStatus()
136137
: GRpcStatusCode(grpc::StatusCode::OK)
@@ -800,6 +801,11 @@ class TStreamRequestReadProcessor
800801
} else if (readCallback) {
801802
if (status.Ok()) {
802803
status = TGrpcStatus(grpc::StatusCode::OUT_OF_RANGE, "Read EOF");
804+
for (const auto& [name, value] : Context.GetServerTrailingMetadata()) {
805+
status.ServerTrailingMetadata.emplace(
806+
TString(name.begin(), name.end()),
807+
TString(value.begin(), value.end()));
808+
}
803809
}
804810
readCallback(std::move(status));
805811
} else if (finishCallback) {
@@ -1196,6 +1202,11 @@ class TStreamRequestReadWriteProcessor
11961202
} else if (readCallback) {
11971203
if (status.Ok()) {
11981204
status = TGrpcStatus(grpc::StatusCode::OUT_OF_RANGE, "Read EOF");
1205+
for (const auto& [name, value] : Context.GetServerTrailingMetadata()) {
1206+
status.ServerTrailingMetadata.emplace(
1207+
TString(name.begin(), name.end()),
1208+
TString(value.begin(), value.end()));
1209+
}
11991210
}
12001211
readCallback(std::move(status));
12011212
} else if (finishCallback) {

library/cpp/protobuf/json/json2proto.cpp

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ Json2SingleField(const NJson::TJsonValue& json,
258258

259259
const NJson::TJsonValue& fieldJson = name ? json[name] : json;
260260

261+
if (name && config.UnknownFieldsCollector) {
262+
config.UnknownFieldsCollector->OnEnterMapItem(name);
263+
}
264+
261265
switch (field.cpp_type()) {
262266
JSON_TO_FIELD(CPPTYPE_INT32, field.name(), fieldJson, IsInteger, SetInt32, GetInteger);
263267
JSON_TO_FIELD(CPPTYPE_INT64, field.name(), fieldJson, IsInteger, SetInt64, GetInteger);
@@ -295,6 +299,10 @@ Json2SingleField(const NJson::TJsonValue& json,
295299
ythrow yexception() << "Unknown protobuf field type: "
296300
<< static_cast<int>(field.cpp_type()) << ".";
297301
}
302+
303+
if (name && config.UnknownFieldsCollector) {
304+
config.UnknownFieldsCollector->OnLeaveMapItem();
305+
}
298306
}
299307

300308
static void
@@ -397,6 +405,10 @@ Json2RepeatedField(const NJson::TJsonValue& json,
397405
if (fieldJson.GetType() == NJson::JSON_UNDEFINED || fieldJson.GetType() == NJson::JSON_NULL)
398406
return;
399407

408+
if (config.UnknownFieldsCollector) {
409+
config.UnknownFieldsCollector->OnEnterMapItem(name);
410+
}
411+
400412
bool isMap = fieldJson.GetType() == NJson::JSON_MAP;
401413
if (isMap) {
402414
if (!config.MapAsObject) {
@@ -421,25 +433,51 @@ Json2RepeatedField(const NJson::TJsonValue& json,
421433
for (const auto& x : jsonMap) {
422434
const TString& key = x.first;
423435
const NJson::TJsonValue& jsonValue = x.second;
436+
if (config.UnknownFieldsCollector) {
437+
config.UnknownFieldsCollector->OnEnterMapItem(key);
438+
}
424439
Json2RepeatedFieldValue(jsonValue, proto, field, config, reflection, key);
440+
if (config.UnknownFieldsCollector) {
441+
config.UnknownFieldsCollector->OnLeaveMapItem();
442+
}
425443
}
426444
} else {
427445
if (config.ReplaceRepeatedFields) {
428446
reflection->ClearField(&proto, &field);
429447
}
430448
if (fieldJson.GetType() == NJson::JSON_ARRAY) {
431449
const NJson::TJsonValue::TArray& jsonArray = fieldJson.GetArray();
450+
ui64 id = 0;
432451
for (const NJson::TJsonValue& jsonValue : jsonArray) {
452+
if (config.UnknownFieldsCollector) {
453+
config.UnknownFieldsCollector->OnEnterArrayItem(id);
454+
}
433455
Json2RepeatedFieldValue(jsonValue, proto, field, config, reflection);
456+
if (config.UnknownFieldsCollector) {
457+
config.UnknownFieldsCollector->OnLeaveArrayItem();
458+
}
459+
++id;
434460
}
435461
} else if (config.ValueVectorizer) {
462+
ui64 id = 0;
436463
for (const NJson::TJsonValue& jsonValue : config.ValueVectorizer(fieldJson)) {
464+
if (config.UnknownFieldsCollector) {
465+
config.UnknownFieldsCollector->OnEnterArrayItem(id);
466+
}
437467
Json2RepeatedFieldValue(jsonValue, proto, field, config, reflection);
468+
if (config.UnknownFieldsCollector) {
469+
config.UnknownFieldsCollector->OnLeaveArrayItem();
470+
}
471+
++id;
438472
}
439473
} else if (config.VectorizeScalars) {
440474
Json2RepeatedFieldValue(fieldJson, proto, field, config, reflection);
441475
}
442476
}
477+
478+
if (config.UnknownFieldsCollector) {
479+
config.UnknownFieldsCollector->OnLeaveMapItem();
480+
}
443481
}
444482

445483
namespace NProtobufJson {
@@ -463,14 +501,18 @@ namespace NProtobufJson {
463501
}
464502
}
465503

466-
if (!config.AllowUnknownFields) {
504+
if (!config.AllowUnknownFields || config.UnknownFieldsCollector) {
467505
THashMap<TString, bool> knownFields;
468506
for (int f = 0, endF = descriptor->field_count(); f < endF; ++f) {
469507
const google::protobuf::FieldDescriptor* field = descriptor->field(f);
470508
knownFields[GetFieldName(*field, config)] = 1;
471509
}
472510
for (const auto& f : json.GetMap()) {
473-
Y_ENSURE(knownFields.contains(f.first), "unknown field \"" << f.first << "\" for \"" << descriptor->full_name() << "\"");
511+
const bool isFieldKnown = knownFields.contains(f.first);
512+
Y_ENSURE(config.AllowUnknownFields || isFieldKnown, "unknown field \"" << f.first << "\" for \"" << descriptor->full_name() << "\"");
513+
if (!isFieldKnown) {
514+
config.UnknownFieldsCollector->OnUnknownField(f.first, *descriptor);
515+
}
474516
}
475517
}
476518
}

library/cpp/protobuf/json/json2proto.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
#include "string_transform.h"
44
#include "name_generator.h"
5+
#include "unknown_fields_collector.h"
56

67
#include <library/cpp/json/json_reader.h>
78
#include <library/cpp/json/json_value.h>
89

10+
#include <util/generic/ptr.h>
911
#include <util/stream/input.h>
1012
#include <util/stream/str.h>
1113
#include <util/stream/mem.h>
@@ -108,6 +110,11 @@ namespace NProtobufJson {
108110
return *this;
109111
}
110112

113+
TSelf& SetUnknownFieldsCollector(TSimpleSharedPtr<IUnknownFieldsCollector> value) {
114+
UnknownFieldsCollector = std::move(value);
115+
return *this;
116+
}
117+
111118
FldNameMode FieldNameMode = FieldNameOriginalCase;
112119
bool AllowUnknownFields = true;
113120

@@ -152,6 +159,9 @@ namespace NProtobufJson {
152159

153160
/// Allow nonstandard conversions, e.g. google.protobuf.Duration from String
154161
bool AllowString2TimeConversion = false;
162+
163+
/// Stores information about unknown fields
164+
TSimpleSharedPtr<IUnknownFieldsCollector> UnknownFieldsCollector = nullptr;
155165
};
156166

157167
/// @throw yexception
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#pragma once
2+
3+
#include <util/generic/string.h>
4+
5+
namespace google {
6+
namespace protobuf {
7+
class FieldDescriptor;
8+
class Descriptor;
9+
}
10+
}
11+
12+
namespace NProtobufJson {
13+
/* Methods OnEnter.../OnLeave... are called on every field of structure
14+
* during traverse and should be used to build context
15+
* Method OnUnknownField are called every time when field which can't
16+
* be mapped
17+
*/
18+
struct IUnknownFieldsCollector {
19+
virtual ~IUnknownFieldsCollector() = default;
20+
21+
virtual void OnEnterMapItem(const TString& key) = 0;
22+
virtual void OnLeaveMapItem() = 0;
23+
24+
virtual void OnEnterArrayItem(ui64 id) = 0;
25+
virtual void OnLeaveArrayItem() = 0;
26+
27+
virtual void OnUnknownField(const TString& key, const google::protobuf::Descriptor& value) = 0;
28+
};
29+
}

0 commit comments

Comments
 (0)