Skip to content

Commit 9fd16db

Browse files
generatedunixname1030151775592158facebook-github-bot
authored andcommitted
ThriftRemoveRefSuffix_iqcloud_nodes_image_enhance
Reviewed By: dtolnay Differential Revision: D76667125 fbshipit-source-id: 2af7fd2c07f394e33123fb0084467c412b35d96c
1 parent b555449 commit 9fd16db

File tree

8 files changed

+68
-73
lines changed

8 files changed

+68
-73
lines changed

third-party/thrift/src/thrift/lib/cpp2/protocol/FieldMask.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,22 +178,22 @@ struct MaskBuilder : type::detail::Wrap<Mask> {
178178
template <typename... Id>
179179
MaskBuilder& includes_map_element(int64_t key, const Mask& mask = allMask()) {
180180
Mask map;
181-
map.includes_map_ref().emplace()[key] = mask;
181+
map.includes_map().emplace()[key] = mask;
182182
return includes<Id...>(map);
183183
}
184184

185185
template <typename... Id>
186186
MaskBuilder& includes_map_element(
187187
std::string key, const Mask& mask = allMask()) {
188188
Mask map;
189-
map.includes_string_map_ref().emplace()[std::move(key)] = mask;
189+
map.includes_string_map().emplace()[std::move(key)] = mask;
190190
return includes<Id...>(map);
191191
}
192192

193193
template <typename... Id>
194194
MaskBuilder& includes_type(type::Type type, const Mask& mask = allMask()) {
195195
Mask typeMap;
196-
typeMap.includes_type_ref().emplace().emplace(std::move(type), mask);
196+
typeMap.includes_type().emplace().emplace(std::move(type), mask);
197197
return includes<Id...>(typeMap);
198198
}
199199

@@ -222,22 +222,22 @@ struct MaskBuilder : type::detail::Wrap<Mask> {
222222
template <typename... Id>
223223
MaskBuilder& excludes_map_element(int64_t key, const Mask& mask = allMask()) {
224224
Mask map;
225-
map.includes_map_ref().emplace()[key] = mask;
225+
map.includes_map().emplace()[key] = mask;
226226
return excludes<Id...>(map);
227227
}
228228

229229
template <typename... Id>
230230
MaskBuilder& excludes_map_element(
231231
std::string key, const Mask& mask = allMask()) {
232232
Mask map;
233-
map.includes_string_map_ref().emplace()[std::move(key)] = mask;
233+
map.includes_string_map().emplace()[std::move(key)] = mask;
234234
return excludes<Id...>(map);
235235
}
236236

237237
template <typename... Id>
238238
MaskBuilder& excludes_type(type::Type type, const Mask& mask = allMask()) {
239239
Mask typeMap;
240-
typeMap.includes_type_ref().emplace().emplace(std::move(type), mask);
240+
typeMap.includes_type().emplace().emplace(std::move(type), mask);
241241
return excludes<Id...>(typeMap);
242242
}
243243

@@ -295,7 +295,7 @@ struct DynamicMaskBuilder : type::detail::Wrap<Mask> {
295295
int64_t key,
296296
const Mask& mask = allMask()) {
297297
Mask map;
298-
map.includes_map_ref().emplace()[key] = mask;
298+
map.includes_map().emplace()[key] = mask;
299299
return includes(path, map);
300300
}
301301

@@ -304,7 +304,7 @@ struct DynamicMaskBuilder : type::detail::Wrap<Mask> {
304304
std::string key,
305305
const Mask& mask = allMask()) {
306306
Mask map;
307-
map.includes_string_map_ref().emplace().emplace(std::move(key), mask);
307+
map.includes_string_map().emplace().emplace(std::move(key), mask);
308308
return includes(path, map);
309309
}
310310

@@ -313,7 +313,7 @@ struct DynamicMaskBuilder : type::detail::Wrap<Mask> {
313313
type::Type type,
314314
const Mask& mask = allMask()) {
315315
Mask typeMap;
316-
typeMap.includes_type_ref().emplace().emplace(std::move(type), mask);
316+
typeMap.includes_type().emplace().emplace(std::move(type), mask);
317317
return includes(path, typeMap);
318318
}
319319

@@ -328,7 +328,7 @@ struct DynamicMaskBuilder : type::detail::Wrap<Mask> {
328328
int64_t key,
329329
const Mask& mask = allMask()) {
330330
Mask map;
331-
map.includes_map_ref().emplace()[key] = mask;
331+
map.includes_map().emplace()[key] = mask;
332332
return excludes(path, map);
333333
}
334334

@@ -337,7 +337,7 @@ struct DynamicMaskBuilder : type::detail::Wrap<Mask> {
337337
std::string key,
338338
const Mask& mask = allMask()) {
339339
Mask map;
340-
map.includes_string_map_ref().emplace().emplace(std::move(key), mask);
340+
map.includes_string_map().emplace().emplace(std::move(key), mask);
341341
return excludes(path, map);
342342
}
343343

@@ -346,7 +346,7 @@ struct DynamicMaskBuilder : type::detail::Wrap<Mask> {
346346
type::Type type,
347347
const Mask& mask = allMask()) {
348348
Mask typeMap;
349-
typeMap.includes_type_ref().emplace().emplace(std::move(type), mask);
349+
typeMap.includes_type().emplace().emplace(std::move(type), mask);
350350
return excludes(path, typeMap);
351351
}
352352

@@ -362,7 +362,7 @@ Mask compare(const T& original, const T& modified) {
362362
is_thrift_class_v<T> || is_thrift_union_v<T>,
363363
"not a thrift struct or union");
364364
Mask result;
365-
detail::compare_impl(original, modified, result.includes_ref().emplace());
365+
detail::compare_impl(original, modified, result.includes().emplace());
366366
return result;
367367
}
368368

third-party/thrift/src/thrift/lib/cpp2/protocol/FieldMaskRef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,10 @@ class MaskRef {
180180
template <typename T>
181181
size_t numFieldsSet() {
182182
throwIfNotFieldMask();
183-
if (auto includes = mask.includes_ref()) {
183+
if (auto includes = mask.includes()) {
184184
return includes->size();
185185
} else {
186-
return op::num_fields<T> - mask.excludes_ref()->size();
186+
return op::num_fields<T> - mask.excludes()->size();
187187
}
188188
}
189189

third-party/thrift/src/thrift/lib/cpp2/protocol/Object.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ std::unique_ptr<folly::IOBuf> serializeObject(
143143
Protocol prot;
144144
folly::IOBufQueue queue(folly::IOBufQueue::cacheChainLength());
145145
prot.setOutput(&queue);
146-
if (protocolData.data()->full_ref()) { // entire object is not parsed
146+
if (protocolData.data()->full()) { // entire object is not parsed
147147
const EncodedValue& value = detail::getByValueId(
148-
*protocolData.values(), protocolData.data()->full_ref().value());
148+
*protocolData.values(), protocolData.data()->full().value());
149149
prot.writeRaw(*value.data());
150-
} else if (!protocolData.data()->fields_ref()) { // entire object is parsed
150+
} else if (!protocolData.data()->fields()) { // entire object is parsed
151151
detail::serializeObject(prot, obj);
152152
} else { // use both object and masked data to serialize
153153
detail::serializeObject(prot, obj, protocolData, *protocolData.data());

third-party/thrift/src/thrift/lib/cpp2/protocol/detail/FieldMask.h

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,52 +47,50 @@ inline bool isExclusive(const Mask& mask) {
4747

4848
// Returns mask == allMask() but faster
4949
inline bool isAllMask(const Mask& mask) {
50-
return mask.excludes_ref() && mask.excludes_ref()->empty();
50+
return mask.excludes() && mask.excludes()->empty();
5151
}
5252

5353
// Returns mask == noneMask() but faster
5454
inline bool isNoneMask(const Mask& mask) {
55-
return mask.includes_ref() && mask.includes_ref()->empty();
55+
return mask.includes() && mask.includes()->empty();
5656
}
5757

5858
// Checks whether it is ALL map mask.
5959
inline bool isAllMapMask(const Mask& mask) {
60-
if (!mask.excludes_map_ref() && !mask.excludes_string_map_ref() &&
61-
!mask.includes_map_ref() && !mask.includes_string_map_ref()) {
60+
if (!mask.excludes_map() && !mask.excludes_string_map() &&
61+
!mask.includes_map() && !mask.includes_string_map()) {
6262
folly::throw_exception<std::runtime_error>("This is not a map mask.");
6363
}
6464

65-
return (mask.excludes_map_ref() && mask.excludes_map_ref()->empty()) ||
66-
(mask.excludes_string_map_ref() &&
67-
mask.excludes_string_map_ref()->empty());
65+
return (mask.excludes_map() && mask.excludes_map()->empty()) ||
66+
(mask.excludes_string_map() && mask.excludes_string_map()->empty());
6867
}
6968

7069
// Checks whether it is NONE map mask.
7170
inline bool isNoneMapMask(const Mask& mask) {
72-
if (!mask.excludes_map_ref() && !mask.excludes_string_map_ref() &&
73-
!mask.includes_map_ref() && !mask.includes_string_map_ref()) {
71+
if (!mask.excludes_map() && !mask.excludes_string_map() &&
72+
!mask.includes_map() && !mask.includes_string_map()) {
7473
folly::throw_exception<std::runtime_error>("This is not a map mask.");
7574
}
7675

77-
return (mask.includes_map_ref() && mask.includes_map_ref()->empty()) ||
78-
(mask.includes_string_map_ref() &&
79-
mask.includes_string_map_ref()->empty());
76+
return (mask.includes_map() && mask.includes_map()->empty()) ||
77+
(mask.includes_string_map() && mask.includes_string_map()->empty());
8078
}
8179

8280
// Checks whether it is ALL type mask.
8381
inline bool isAllTypeMask(const Mask& mask) {
84-
if (!mask.excludes_type_ref() && !mask.includes_type_ref()) {
82+
if (!mask.excludes_type() && !mask.includes_type()) {
8583
folly::throw_exception<std::runtime_error>("This is not a type mask.");
8684
}
87-
return mask.excludes_type_ref() && mask.excludes_type_ref()->empty();
85+
return mask.excludes_type() && mask.excludes_type()->empty();
8886
}
8987

9088
// Checks whether it is NONE type mask.
9189
inline bool isNoneTypeMask(const Mask& mask) {
92-
if (!mask.excludes_type_ref() && !mask.includes_type_ref()) {
90+
if (!mask.excludes_type() && !mask.includes_type()) {
9391
folly::throw_exception<std::runtime_error>("This is not a type mask.");
9492
}
95-
return mask.includes_type_ref() && mask.includes_type_ref()->empty();
93+
return mask.includes_type() && mask.includes_type()->empty();
9694
}
9795

9896
// If mask is a field mask, return it, otherwise return nullptr
@@ -152,7 +150,7 @@ void compare_impl(const T& original, const T& modified, FieldIdToMask& mask) {
152150
using FieldType = op::get_native_type<T, Id>;
153151
if constexpr (is_thrift_class_v<FieldType>) {
154152
compare_impl(
155-
*original_ptr, *modified_ptr, mask[fieldId].includes_ref().emplace());
153+
*original_ptr, *modified_ptr, mask[fieldId].includes().emplace());
156154
return;
157155
}
158156
// The values are different and not nested.

third-party/thrift/src/thrift/lib/cpp2/protocol/detail/FieldMaskUtil.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ bool validate_mask(MaskRef ref) {
5555
ids.reserve(op::num_fields<T>);
5656
op::for_each_ordinal<T>(
5757
[&](auto ord) { ids.insert(op::get_field_id<T, decltype(ord)>()); });
58-
const FieldIdToMask& map = ref.mask.includes_ref()
59-
? ref.mask.includes_ref().value()
60-
: ref.mask.excludes_ref().value();
58+
const FieldIdToMask& map = ref.mask.includes() ? ref.mask.includes().value()
59+
: ref.mask.excludes().value();
6160
for (auto& [id, _] : map) {
6261
// Mask contains a field not in the struct.
6362
if (ids.find(FieldId{id}) == ids.end()) {
@@ -179,7 +178,7 @@ Mask path(const Mask& other) {
179178
Mask mask;
180179
using fieldId = op::get_field_id<T, Id>;
181180
static_assert(fieldId::value != FieldId{});
182-
mask.includes_ref().emplace()[static_cast<int16_t>(fieldId::value)] =
181+
mask.includes().emplace()[static_cast<int16_t>(fieldId::value)] =
183182
path<op::get_type_tag<T, Id>, Ids...>(other);
184183
return mask;
185184
}
@@ -201,15 +200,15 @@ Mask path(
201200
Mask mask;
202201
op::for_each_field_id<T>([&](auto id) {
203202
using Id = decltype(id);
204-
if (mask.includes_ref()) { // already set
203+
if (mask.includes()) { // already set
205204
return;
206205
}
207206
if (op::get_name_v<T, Id> == fieldNames[index]) {
208-
mask.includes_ref().emplace()[folly::to_underlying(id())] =
207+
mask.includes().emplace()[folly::to_underlying(id())] =
209208
path<op::get_type_tag<T, Id>>(fieldNames, index + 1, other);
210209
}
211210
});
212-
if (!mask.includes_ref()) { // field not found
211+
if (!mask.includes()) { // field not found
213212
folly::throw_exception<std::runtime_error>("field doesn't exist");
214213
}
215214
return mask;
@@ -378,7 +377,7 @@ void setMaskedDataFull(
378377
apache::thrift::skip(prot, arg_type);
379378
cursor.clone(encodedValue.data().emplace(), prot.getCursor() - cursor);
380379
const auto pos = folly::to<int32_t>(values.size() - 1);
381-
maskedData.full_ref() = type::ValueId{apache::thrift::util::i32ToZigzag(pos)};
380+
maskedData.full() = type::ValueId{apache::thrift::util::i32ToZigzag(pos)};
382381
}
383382

384383
inline MaskRef getKeyMaskRefByValue(MaskRef maskRef, const Value& value) {
@@ -484,7 +483,7 @@ MaskedDecodeResultValue parseValueWithMask(
484483
}
485484
if constexpr (KeepExcludedData) {
486485
if (!apache::thrift::empty(nestedResult.excluded)) {
487-
result.excluded.fields_ref().ensure()[FieldId{fid}] =
486+
result.excluded.fields().ensure()[FieldId{fid}] =
488487
std::move(nestedResult.excluded);
489488
}
490489
}
@@ -525,7 +524,7 @@ MaskedDecodeResultValue parseValueWithMask(
525524
const auto pos = folly::to<int32_t>(keys.size() - 1);
526525
type::ValueId id =
527526
type::ValueId{apache::thrift::util::i32ToZigzag(pos)};
528-
result.excluded.values_ref().ensure()[id] =
527+
result.excluded.values().ensure()[id] =
529528
std::move(nestedResult.excluded);
530529
}
531530
}

third-party/thrift/src/thrift/lib/cpp2/protocol/detail/Object.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -685,12 +685,12 @@ void writeRawField(
685685
FieldId fieldId,
686686
const MaskedProtocolData& protocolData,
687687
const MaskedData& maskedData) {
688-
const auto& nestedMaskedData = maskedData.fields_ref().value().at(fieldId);
688+
const auto& nestedMaskedData = maskedData.fields().value().at(fieldId);
689689
// When value doesn't exist in the object, maskedData should have full field.
690-
if (!nestedMaskedData.full_ref()) {
690+
if (!nestedMaskedData.full()) {
691691
throw std::runtime_error("incompatible value and maskedData");
692692
}
693-
type::ValueId valueId = nestedMaskedData.full_ref().value();
693+
type::ValueId valueId = nestedMaskedData.full().value();
694694
const EncodedValue& value = getByValueId(*protocolData.values(), valueId);
695695
prot.writeFieldBegin(
696696
"", toTType(*value.wireType()), folly::to_underlying(fieldId));
@@ -706,10 +706,10 @@ void writeRawMapValue(
706706
const MaskedProtocolData& protocolData,
707707
const MaskedData& maskedData) {
708708
// When value doesn't exist in the object, maskedData should have full field.
709-
if (!maskedData.full_ref()) {
709+
if (!maskedData.full()) {
710710
throw std::runtime_error("incompatible value and maskedData");
711711
}
712-
type::ValueId valueId = maskedData.full_ref().value();
712+
type::ValueId valueId = maskedData.full().value();
713713
const EncodedValue& value = getByValueId(*protocolData.values(), valueId);
714714
if (toTType(*value.wireType()) != valueType) {
715715
TProtocolException::throwInvalidFieldData();
@@ -723,7 +723,7 @@ void serializeObject(
723723
const Object& obj,
724724
const MaskedProtocolData& protocolData,
725725
const MaskedData& maskedData) {
726-
if (!maskedData.fields_ref()) {
726+
if (!maskedData.fields()) {
727727
throw std::runtime_error("incompatible value and maskedData");
728728
}
729729
prot.writeStructBegin("");
@@ -732,7 +732,7 @@ void serializeObject(
732732
for (const auto& [fieldId, _] : obj) {
733733
fieldIds.insert(FieldId{fieldId});
734734
}
735-
for (const auto& [fieldId, _] : *maskedData.fields_ref()) {
735+
for (const auto& [fieldId, _] : *maskedData.fields()) {
736736
fieldIds.insert(fieldId);
737737
}
738738

@@ -747,10 +747,10 @@ void serializeObject(
747747
auto fieldType = getTType(fieldVal);
748748
prot.writeFieldBegin("", fieldType, folly::to_underlying(fieldId));
749749
// just serialize the value
750-
if (folly::get_ptr(*maskedData.fields_ref(), fieldId) == nullptr) {
750+
if (folly::get_ptr(*maskedData.fields(), fieldId) == nullptr) {
751751
serializeValue(prot, fieldVal);
752752
} else { // recursively serialize value with maskedData
753-
const auto& nextMaskedData = maskedData.fields_ref().value().at(fieldId);
753+
const auto& nextMaskedData = maskedData.fields().value().at(fieldId);
754754
serializeValue(prot, fieldVal, protocolData, nextMaskedData);
755755
}
756756
prot.writeFieldEnd();
@@ -774,7 +774,7 @@ void serializeValue(
774774
}
775775

776776
if (value.getType() == Value::Type::mapValue) {
777-
if (!maskedData.values_ref()) {
777+
if (!maskedData.values()) {
778778
throw std::runtime_error("incompatible value and maskedData");
779779
}
780780
TType keyType = protocol::T_STRING;
@@ -787,11 +787,11 @@ void serializeValue(
787787
keyType = getTType(mapVal.begin()->first);
788788
valueType = getTType(mapVal.begin()->second);
789789
}
790-
for (auto& [keyValueId, nestedMaskedData] : *maskedData.values_ref()) {
790+
for (auto& [keyValueId, nestedMaskedData] : *maskedData.values()) {
791791
const Value& key = getByValueId(*protocolData.keys(), keyValueId);
792792
if (size == 0) { // need to set keyType and valueType
793793
keyType = getTType(key);
794-
type::ValueId valueId = nestedMaskedData.full_ref().value();
794+
type::ValueId valueId = nestedMaskedData.full().value();
795795
valueType =
796796
toTType(*getByValueId(*protocolData.values(), valueId).wireType());
797797
}
@@ -808,7 +808,7 @@ void serializeValue(
808808
std::equal_to<Value>>
809809
keys;
810810
prot.writeMapBegin(keyType, valueType, size);
811-
for (auto& [keyValueId, nestedMaskedData] : *maskedData.values_ref()) {
811+
for (auto& [keyValueId, nestedMaskedData] : *maskedData.values()) {
812812
const Value& key = getByValueId(*protocolData.keys(), keyValueId);
813813
keys.insert(key);
814814
ensureSameType(key, keyType);

0 commit comments

Comments
 (0)