Skip to content

Commit e9148d6

Browse files
generatedunixname89002005232357facebook-github-bot
authored andcommitted
Revert D79818821
Summary: This diff reverts D79818821 Discovered faas dependency on unresolved definitions of schema.thrift Depends on D79818821 Reviewed By: thedavekwon Differential Revision: D79905130 fbshipit-source-id: 1eb66662c1dcbcf95ecdb3da2d76e612dea38517
1 parent d74a2ee commit e9148d6

File tree

1 file changed

+19
-39
lines changed

1 file changed

+19
-39
lines changed

third-party/thrift/src/thrift/lib/cpp2/schema/detail/SchemaBackedResolver.cpp

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,6 @@ class SchemaIndex {
123123
folly::F14FastMap<std::string_view, DefinitionKeyRef>;
124124
DefinitionKeysByUri definitionKeysByUri_;
125125

126-
// A set of unresolved definition keys collected while updating indexes.
127-
// This can be used to detect missing definitions in selective resolver.
128-
folly::F14FastSet<DefinitionKeyRef, DefinitionKeyHash, DefinitionKeyEqual>
129-
unresolvedDefinitionRefs_;
130-
131126
void updateProgramsById(
132127
ProgramsById&, const type::Schema&, const DefinitionsByKey&);
133128
void updateValuesById(ValuesById&, const type::Schema& schema);
@@ -201,13 +196,9 @@ class SchemaIndex {
201196
* definitions are lazily resolved. This means that it's safe to call
202197
* typeOf(...) even if the pointed-to type has not been seen yet.
203198
*/
204-
TypeRef typeOf(const type::TypeStruct&);
205-
TypeRef typeOf(const type::Type& type) { return typeOf(type.toThrift()); }
206-
207-
template <typename T>
208-
detail::Lazy<T> createLazyUnresolved(const type::DefinitionKey& key) {
209-
unresolvedDefinitionRefs_.insert(key);
210-
return typename detail::Lazy<T>::Unresolved(resolver_, key);
199+
TypeRef typeOf(const type::TypeStruct&) const;
200+
TypeRef typeOf(const type::Type& type) const {
201+
return typeOf(type.toThrift());
211202
}
212203

213204
Resolver& resolver_;
@@ -219,31 +210,20 @@ class SchemaIndex {
219210
const DefinitionNode* definitionForUri(std::string_view uri) const;
220211
ProgramNode::IncludesList programs() const;
221212

222-
void updateIndices(const type::Schema& schema, bool resolve = false) {
213+
void updateIndices(const type::Schema& schema) {
223214
updateDefinitionsByKey(
224215
definitionsByKey_, schema, createProgramIdsByDefinitionKey(schema));
225216
updateProgramsById(programsById_, schema, definitionsByKey_);
226217
updateValuesById(valuesById_, schema);
227218
updateDefinitionKeysByUri(definitionKeysByUri_, definitionsByKey_);
228-
229-
auto unresolved = std::move(unresolvedDefinitionRefs_);
230-
if (!resolve) {
231-
return;
232-
}
233-
for (const auto& keyRef : unresolved) {
234-
if (!definitionsByKey_.contains(keyRef)) {
235-
folly::throw_exception<InvalidSyntaxGraphError>(
236-
"There are unresolved definitions.");
237-
}
238-
}
239219
}
240220
};
241221

242222
class FullyResolvedSchemaRefBackedResolver : public SchemaBackedResolver {
243223
public:
244224
explicit FullyResolvedSchemaRefBackedResolver(const type::Schema& schema)
245225
: schema_(schema) {
246-
index_->updateIndices(schema_, true);
226+
index_->updateIndices(schema_);
247227
}
248228

249229
const ProgramNode& programOf(const type::ProgramId& id) const override {
@@ -268,7 +248,7 @@ class FullyResolvedSchemaBackedResolver : public SchemaBackedResolver {
268248
public:
269249
explicit FullyResolvedSchemaBackedResolver(type::Schema&& schema)
270250
: schema_(std::move(schema)) {
271-
index_->updateIndices(schema_, true);
251+
index_->updateIndices(schema_);
272252
}
273253

274254
const ProgramNode& programOf(const type::ProgramId& id) const override {
@@ -363,7 +343,7 @@ const type::DefinitionKey& SchemaIndex::definitionKeyOf(
363343
}
364344
}
365345

366-
TypeRef SchemaIndex::typeOf(const type::TypeStruct& type) {
346+
TypeRef SchemaIndex::typeOf(const type::TypeStruct& type) const {
367347
return TypeRef([&]() -> TypeRef::Alternative {
368348
using T = type::TypeName::Type;
369349
T t = type.name()->getType();
@@ -387,20 +367,20 @@ TypeRef SchemaIndex::typeOf(const type::TypeStruct& type) {
387367
case T::binaryType:
388368
return Primitive::BINARY;
389369
case T::enumType:
390-
return createLazyUnresolved<EnumNode>(
391-
definitionKeyOf(*type.name()->enumType()));
370+
return detail::Lazy<EnumNode>::Unresolved(
371+
resolver_, definitionKeyOf(*type.name()->enumType()));
392372
case T::typedefType:
393-
return createLazyUnresolved<TypedefNode>(
394-
definitionKeyOf(*type.name()->typedefType()));
373+
return detail::Lazy<TypedefNode>::Unresolved(
374+
resolver_, definitionKeyOf(*type.name()->typedefType()));
395375
case T::structType:
396-
return createLazyUnresolved<StructNode>(
397-
definitionKeyOf(*type.name()->structType()));
376+
return detail::Lazy<StructNode>::Unresolved(
377+
resolver_, definitionKeyOf(*type.name()->structType()));
398378
case T::unionType:
399-
return createLazyUnresolved<UnionNode>(
400-
definitionKeyOf(*type.name()->unionType()));
379+
return detail::Lazy<UnionNode>::Unresolved(
380+
resolver_, definitionKeyOf(*type.name()->unionType()));
401381
case T::exceptionType:
402-
return createLazyUnresolved<ExceptionNode>(
403-
definitionKeyOf(*type.name()->exceptionType()));
382+
return detail::Lazy<ExceptionNode>::Unresolved(
383+
resolver_, definitionKeyOf(*type.name()->exceptionType()));
404384
case T::listType: {
405385
const auto& params = *type.params();
406386
if (params.size() != 1) {
@@ -717,8 +697,8 @@ FunctionNode SchemaIndex::createFunction(
717697
auto interaction = [&]() -> std::optional<detail::Lazy<InteractionNode>> {
718698
if (const auto& interactionTypeUri = *function.interactionType()->uri();
719699
!isEmptyTypeUri(interactionTypeUri)) {
720-
return createLazyUnresolved<InteractionNode>(
721-
definitionKeyOf(interactionTypeUri));
700+
return detail::Lazy<InteractionNode>::Unresolved(
701+
resolver_, definitionKeyOf(interactionTypeUri));
722702
}
723703
return std::nullopt;
724704
}();

0 commit comments

Comments
 (0)