File tree Expand file tree Collapse file tree 5 files changed +10
-6
lines changed
third-party/thrift/src/thrift/compiler
test/fixtures/service-schema/out Expand file tree Collapse file tree 5 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -913,8 +913,7 @@ class cpp_mstch_service : public mstch_service {
913913 return escape_binary_string (s.identify_definition (*service_));
914914 }
915915 mstch::node definition_key_length () {
916- schematizer s (*service_->program ()->scope (), sm_, {});
917- return escape_binary_string (s.identify_definition (*service_)).length ();
916+ return schematizer::definition_identifier_length ();
918917 }
919918
920919 private:
Original file line number Diff line number Diff line change @@ -949,6 +949,10 @@ std::string_view schematizer::program_checksum(const t_program& program) {
949949 std::string (reinterpret_cast <const char *>(hash), sizeof (hash)));
950950}
951951
952+ size_t schematizer::definition_identifier_length () {
953+ return 16 ;
954+ }
955+
952956std::string schematizer::identify_definition (const t_named& node) {
953957 // @lint-ignore CLANGTIDY facebook-hte-CArray
954958 unsigned char hash[SHA256_DIGEST_LENGTH];
@@ -958,8 +962,8 @@ std::string schematizer::identify_definition(const t_named& node) {
958962 node.program ()->path (),
959963 node.name ());
960964 SHA256 (reinterpret_cast <const unsigned char *>(val.c_str ()), val.size (), hash);
961- constexpr size_t num_bytes = 16 ;
962- return std::string ( reinterpret_cast <const char *>(hash), num_bytes );
965+ return std::string (
966+ reinterpret_cast <const char *>(hash), definition_identifier_length () );
963967}
964968
965969int64_t schematizer::identify_program (const t_program& node) {
Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ class schematizer {
8686 // across runs on different including programs.
8787 std::string identify_definition (const t_named& node);
8888 int64_t identify_program (const t_program& node);
89+ static size_t definition_identifier_length ();
8990
9091 // Get the name of the program's schema const.
9192 static std::string name_schema (source_manager& sm, const t_program& node);
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ apache::thrift::ServiceHandler<::cpp2::PrimitivesService>::CreateMethodMetadataR
2323std::optional<apache::thrift::schema::DefinitionsSchema> apache::thrift::ServiceHandler<::cpp2::PrimitivesService>::getServiceSchema() {
2424 std::optional<apache::thrift::schema::DefinitionsSchema> ret = schema::DefinitionsSchema{};
2525 ret->schema = ::apache::thrift::SchemaRegistry::mergeSchemas (::cpp2::module_constants::_fbthrift_schema_b747839c13cb3aa5_includes ());
26- ret->definitions = { {" \x0d\x05\x1d\xbc\xb2\xd5\x1d\x8f\x95\x45\xbb\x51\xfa\xcf\x0f\xfe " , 64 } };
26+ ret->definitions = { {" \x0d\x05\x1d\xbc\xb2\xd5\x1d\x8f\x95\x45\xbb\x51\xfa\xcf\x0f\xfe " , 16 } };
2727 return ret;
2828}
2929#endif
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ apache::thrift::ServiceHandler<::cpp2::PrimitivesService>::CreateMethodMetadataR
2323std::optional<apache::thrift::schema::DefinitionsSchema> apache::thrift::ServiceHandler<::cpp2::PrimitivesService>::getServiceSchema() {
2424 std::optional<apache::thrift::schema::DefinitionsSchema> ret = schema::DefinitionsSchema{};
2525 ret->schema = ::apache::thrift::SchemaRegistry::mergeSchemas (::cpp2::module_constants::_fbthrift_schema_b747839c13cb3aa5_includes ());
26- ret->definitions = { {" \x0d\x05\x1d\xbc\xb2\xd5\x1d\x8f\x95\x45\xbb\x51\xfa\xcf\x0f\xfe " , 64 } };
26+ ret->definitions = { {" \x0d\x05\x1d\xbc\xb2\xd5\x1d\x8f\x95\x45\xbb\x51\xfa\xcf\x0f\xfe " , 16 } };
2727 return ret;
2828}
2929#endif
You can’t perform that action at this time.
0 commit comments