grpc 1.43.1 → 1.44.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +84 -64
- data/include/grpc/grpc_security.h +10 -0
- data/include/grpc/impl/codegen/compression_types.h +0 -2
- data/include/grpc/impl/codegen/grpc_types.h +6 -0
- data/src/core/ext/filters/client_channel/backend_metric.h +1 -1
- data/src/core/ext/filters/client_channel/client_channel.cc +62 -68
- data/src/core/ext/filters/client_channel/client_channel.h +8 -8
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +1 -1
- data/src/core/ext/filters/client_channel/config_selector.h +4 -4
- data/src/core/ext/filters/client_channel/dynamic_filters.h +1 -1
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +16 -14
- data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +4 -3
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +6 -5
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +3 -7
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +31 -32
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +0 -7
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +43 -29
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +6 -2
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +120 -68
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +60 -48
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +62 -61
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +16 -11
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +11 -5
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +19 -15
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +14 -12
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +3 -2
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +50 -105
- data/src/core/ext/filters/client_channel/lb_policy.cc +15 -14
- data/src/core/ext/filters/client_channel/lb_policy.h +19 -3
- data/src/core/ext/filters/client_channel/resolver/binder/binder_resolver.cc +3 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +207 -81
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +22 -12
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +19 -15
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +23 -38
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +118 -207
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +25 -32
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +82 -73
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +10 -10
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +2 -1
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +2 -5
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +5 -5
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +157 -67
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +2 -2
- data/src/core/ext/filters/client_channel/retry_filter.cc +37 -64
- data/src/core/ext/filters/client_channel/retry_service_config.cc +1 -1
- data/src/core/ext/filters/client_channel/retry_service_config.h +1 -1
- data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +1 -1
- data/src/core/ext/filters/client_channel/subchannel.cc +12 -16
- data/src/core/ext/filters/client_channel/subchannel.h +2 -3
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +37 -48
- data/src/core/ext/filters/fault_injection/service_config_parser.cc +6 -8
- data/src/core/ext/filters/fault_injection/service_config_parser.h +1 -1
- data/src/core/ext/filters/http/client/http_client_filter.cc +51 -122
- data/src/core/ext/filters/http/client_authority_filter.cc +8 -24
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +42 -140
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +5 -25
- data/src/core/ext/filters/http/server/http_server_filter.cc +50 -135
- data/src/core/ext/filters/message_size/message_size_filter.cc +1 -1
- data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
- data/src/core/ext/filters/rbac/rbac_filter.cc +157 -0
- data/src/core/ext/filters/rbac/rbac_filter.h +74 -0
- data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +605 -0
- data/src/core/ext/filters/rbac/rbac_service_config_parser.h +70 -0
- data/src/core/ext/filters/server_config_selector/server_config_selector.h +3 -2
- data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +11 -6
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +1 -1
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +1 -1
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +89 -29
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +0 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +45 -186
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +0 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +341 -279
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +69 -159
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h +2 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +19 -32
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +0 -1
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +94 -1
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +2 -24
- data/src/core/ext/transport/chttp2/transport/internal.h +0 -33
- data/src/core/ext/transport/chttp2/transport/parsing.cc +0 -6
- data/src/core/ext/transport/chttp2/transport/writing.cc +47 -116
- data/src/core/ext/transport/inproc/inproc_plugin.cc +0 -4
- data/src/core/ext/transport/inproc/inproc_transport.cc +11 -63
- data/src/core/ext/transport/inproc/inproc_transport.h +0 -3
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.c +61 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.h +146 -0
- data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.c +188 -0
- data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.h +70 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/rbac/v3/rbac.upbdefs.c +56 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/rbac/v3/rbac.upbdefs.h +40 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/checked.upbdefs.c +154 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/checked.upbdefs.h +95 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/eval.upbdefs.c +58 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/eval.upbdefs.h +55 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/explain.upbdefs.c +44 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/explain.upbdefs.h +40 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/syntax.upbdefs.c +153 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/syntax.upbdefs.h +100 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/value.upbdefs.c +75 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/value.upbdefs.h +55 -0
- data/src/core/ext/xds/upb_utils.h +65 -0
- data/src/core/ext/xds/xds_api.cc +81 -3458
- data/src/core/ext/xds/xds_api.h +56 -611
- data/src/core/ext/xds/xds_bootstrap.cc +189 -125
- data/src/core/ext/xds/xds_bootstrap.h +20 -15
- data/src/core/ext/xds/xds_certificate_provider.h +1 -0
- data/src/core/ext/xds/xds_channel_creds.cc +108 -0
- data/src/core/ext/xds/xds_channel_creds.h +50 -0
- data/src/core/ext/xds/xds_client.cc +584 -994
- data/src/core/ext/xds/xds_client.h +78 -135
- data/src/core/ext/xds/xds_cluster.cc +451 -0
- data/src/core/ext/xds/xds_cluster.h +111 -0
- data/src/core/ext/xds/xds_common_types.cc +388 -0
- data/src/core/ext/xds/xds_common_types.h +110 -0
- data/src/core/ext/xds/xds_endpoint.cc +364 -0
- data/src/core/ext/xds/xds_endpoint.h +135 -0
- data/src/core/ext/xds/xds_http_filters.cc +5 -0
- data/src/core/ext/xds/xds_http_rbac_filter.cc +563 -0
- data/src/core/ext/xds/xds_http_rbac_filter.h +54 -0
- data/src/core/ext/xds/xds_listener.cc +1036 -0
- data/src/core/ext/xds/xds_listener.h +220 -0
- data/src/core/ext/{transport/chttp2/transport/hpack_utils.h → xds/xds_resource_type.cc} +12 -9
- data/src/core/ext/xds/xds_resource_type.h +98 -0
- data/src/core/ext/xds/xds_resource_type_impl.h +87 -0
- data/src/core/ext/xds/xds_route_config.cc +993 -0
- data/src/core/ext/xds/xds_route_config.h +215 -0
- data/src/core/ext/xds/xds_routing.cc +11 -8
- data/src/core/ext/xds/xds_routing.h +8 -5
- data/src/core/ext/xds/xds_server_config_fetcher.cc +159 -99
- data/src/core/lib/address_utils/parse_address.cc +20 -0
- data/src/core/lib/address_utils/parse_address.h +5 -0
- data/src/core/lib/address_utils/sockaddr_utils.cc +33 -36
- data/src/core/lib/address_utils/sockaddr_utils.h +1 -16
- data/src/core/lib/backoff/backoff.cc +4 -30
- data/src/core/lib/backoff/backoff.h +3 -3
- data/src/core/lib/channel/channel_args.cc +0 -1
- data/src/core/lib/channel/channel_stack.cc +8 -0
- data/src/core/lib/channel/channel_stack.h +1 -1
- data/src/core/lib/channel/channel_stack_builder.cc +5 -9
- data/src/core/lib/channel/channel_stack_builder.h +4 -7
- data/src/core/lib/channel/channelz.cc +1 -0
- data/src/core/lib/compression/compression.cc +19 -111
- data/src/core/lib/compression/compression_internal.cc +142 -202
- data/src/core/lib/compression/compression_internal.h +64 -69
- data/src/core/lib/compression/message_compress.cc +11 -11
- data/src/core/lib/compression/message_compress.h +2 -2
- data/src/core/lib/gpr/useful.h +4 -0
- data/src/core/lib/gprpp/bitset.h +7 -0
- data/src/core/lib/gprpp/chunked_vector.h +45 -3
- data/src/core/lib/gprpp/status_helper.cc +20 -28
- data/src/core/lib/gprpp/status_helper.h +6 -19
- data/src/core/lib/gprpp/table.h +11 -0
- data/src/core/lib/http/httpcli.cc +37 -46
- data/src/core/lib/http/httpcli.h +3 -15
- data/src/core/lib/iomgr/call_combiner.cc +15 -4
- data/src/core/lib/iomgr/closure.h +29 -9
- data/src/core/lib/iomgr/combiner.cc +25 -3
- data/src/core/lib/iomgr/error.cc +2 -0
- data/src/core/lib/iomgr/error.h +3 -0
- data/src/core/lib/iomgr/event_engine/iomgr.cc +3 -2
- data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +6 -0
- data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +2 -0
- data/src/core/lib/iomgr/event_engine/resolver.cc +66 -48
- data/src/core/lib/iomgr/event_engine/resolver.h +56 -0
- data/src/core/lib/iomgr/exec_ctx.cc +22 -9
- data/src/core/lib/iomgr/executor.cc +10 -1
- data/src/core/lib/iomgr/fork_posix.cc +3 -2
- data/src/core/lib/iomgr/iomgr_custom.cc +4 -1
- data/src/core/lib/iomgr/iomgr_posix.cc +2 -2
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +2 -2
- data/src/core/lib/iomgr/iomgr_windows.cc +2 -2
- data/src/core/lib/iomgr/port.h +2 -2
- data/src/core/lib/iomgr/resolve_address.cc +5 -24
- data/src/core/lib/iomgr/resolve_address.h +47 -44
- data/src/core/lib/iomgr/resolve_address_custom.cc +131 -109
- data/src/core/lib/iomgr/resolve_address_custom.h +101 -19
- data/src/core/lib/iomgr/resolve_address_impl.h +59 -0
- data/src/core/lib/iomgr/resolve_address_posix.cc +82 -66
- data/src/core/lib/iomgr/resolve_address_posix.h +47 -0
- data/src/core/lib/iomgr/resolve_address_windows.cc +93 -74
- data/src/core/lib/iomgr/resolve_address_windows.h +47 -0
- data/src/core/lib/iomgr/resolved_address.h +39 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +1 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +1 -0
- data/src/core/lib/iomgr/unix_sockets_posix.cc +22 -34
- data/src/core/lib/iomgr/unix_sockets_posix.h +4 -7
- data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +6 -15
- data/src/core/lib/matchers/matchers.cc +1 -1
- data/src/core/lib/promise/activity.h +49 -20
- data/src/core/lib/promise/detail/status.h +5 -0
- data/src/core/{ext/filters/client_channel → lib/resolver}/resolver.cc +17 -25
- data/src/core/{ext/filters/client_channel → lib/resolver}/resolver.h +43 -44
- data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_factory.h +10 -5
- data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_registry.cc +3 -2
- data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_registry.h +4 -5
- data/src/core/{ext/filters/client_channel → lib/resolver}/server_address.cc +1 -1
- data/src/core/{ext/filters/client_channel → lib/resolver}/server_address.h +4 -4
- data/src/core/lib/resource_quota/api.h +0 -1
- data/src/core/lib/{gprpp → resource_quota}/arena.cc +16 -13
- data/src/core/lib/{gprpp → resource_quota}/arena.h +24 -13
- data/src/core/lib/security/authorization/evaluate_args.cc +30 -15
- data/src/core/lib/security/authorization/evaluate_args.h +1 -0
- data/src/core/lib/security/authorization/grpc_authorization_engine.cc +60 -0
- data/src/core/lib/security/authorization/grpc_authorization_engine.h +62 -0
- data/src/core/lib/security/authorization/matchers.cc +227 -0
- data/src/core/lib/security/authorization/matchers.h +211 -0
- data/src/core/lib/security/authorization/rbac_policy.cc +442 -0
- data/src/core/lib/security/authorization/rbac_policy.h +170 -0
- data/src/core/lib/security/context/security_context.cc +4 -2
- data/src/core/lib/security/context/security_context.h +1 -1
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +5 -5
- data/src/core/lib/security/credentials/composite/composite_credentials.h +4 -3
- data/src/core/lib/security/credentials/credentials.h +10 -20
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +6 -9
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +7 -9
- data/src/core/lib/security/credentials/external/external_account_credentials.h +2 -7
- data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +2 -3
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +5 -4
- data/src/core/lib/security/credentials/fake/fake_credentials.h +8 -7
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +2 -5
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +16 -19
- data/src/core/lib/security/credentials/iam/iam_credentials.h +6 -5
- data/src/core/lib/security/credentials/jwt/json_token.cc +4 -6
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +16 -28
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +8 -8
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +6 -13
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +44 -57
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +13 -15
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +6 -7
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +5 -4
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +1 -10
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +6 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +7 -0
- data/src/core/lib/security/credentials/xds/xds_credentials.h +1 -1
- data/src/core/lib/security/security_connector/security_connector.cc +0 -4
- data/src/core/lib/security/security_connector/security_connector.h +5 -1
- data/src/core/lib/security/security_connector/ssl_utils.cc +14 -24
- data/src/core/lib/security/security_connector/ssl_utils.h +5 -14
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +2 -3
- data/src/core/lib/security/transport/auth_filters.h +7 -0
- data/src/core/lib/security/transport/client_auth_filter.cc +53 -33
- data/src/core/lib/security/transport/server_auth_filter.cc +40 -35
- data/src/core/{ext → lib}/service_config/service_config.cc +2 -2
- data/src/core/{ext → lib}/service_config/service_config.h +4 -4
- data/src/core/{ext → lib}/service_config/service_config_call_data.h +5 -5
- data/src/core/{ext → lib}/service_config/service_config_parser.cc +1 -1
- data/src/core/{ext → lib}/service_config/service_config_parser.h +3 -3
- data/src/core/lib/slice/slice.cc +3 -1
- data/src/core/lib/slice/slice.h +43 -13
- data/src/core/lib/slice/slice_intern.cc +3 -101
- data/src/core/lib/slice/slice_internal.h +1 -2
- data/src/core/lib/slice/slice_refcount.h +4 -13
- data/src/core/lib/slice/slice_refcount_base.h +0 -16
- data/src/core/lib/surface/call.cc +140 -382
- data/src/core/lib/surface/call.h +4 -4
- data/src/core/lib/surface/channel.cc +42 -44
- data/src/core/lib/surface/channel.h +4 -4
- data/src/core/lib/surface/init.cc +0 -2
- data/src/core/lib/surface/lame_client.cc +0 -1
- data/src/core/lib/surface/server.cc +12 -29
- data/src/core/lib/surface/server.h +2 -2
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/error_utils.h +14 -0
- data/src/core/lib/transport/metadata_batch.h +799 -717
- data/src/core/lib/transport/parsed_metadata.cc +2 -0
- data/src/core/lib/transport/parsed_metadata.h +95 -92
- data/src/core/lib/transport/timeout_encoding.cc +200 -66
- data/src/core/lib/transport/timeout_encoding.h +40 -10
- data/src/core/lib/transport/transport.h +1 -1
- data/src/core/lib/transport/transport_op_string.cc +6 -39
- data/src/core/lib/uri/uri_parser.cc +223 -53
- data/src/core/lib/uri/uri_parser.h +36 -23
- data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -3
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -1
- data/src/core/tsi/ssl/session_cache/ssl_session.h +2 -4
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +3 -5
- data/src/core/tsi/ssl_transport_security.cc +53 -13
- data/src/core/tsi/ssl_transport_security.h +18 -6
- data/src/ruby/ext/grpc/extconf.rb +10 -3
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +2 -1
- data/third_party/abseil-cpp/absl/base/internal/fast_type_id.h +48 -0
- data/third_party/abseil-cpp/absl/random/bernoulli_distribution.h +200 -0
- data/third_party/abseil-cpp/absl/random/beta_distribution.h +427 -0
- data/third_party/abseil-cpp/absl/random/discrete_distribution.cc +98 -0
- data/third_party/abseil-cpp/absl/random/discrete_distribution.h +247 -0
- data/third_party/abseil-cpp/absl/random/distributions.h +452 -0
- data/third_party/abseil-cpp/absl/random/exponential_distribution.h +165 -0
- data/third_party/abseil-cpp/absl/random/gaussian_distribution.cc +104 -0
- data/third_party/abseil-cpp/absl/random/gaussian_distribution.h +275 -0
- data/third_party/abseil-cpp/absl/random/internal/distribution_caller.h +92 -0
- data/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h +268 -0
- data/third_party/abseil-cpp/absl/random/internal/fastmath.h +57 -0
- data/third_party/abseil-cpp/absl/random/internal/generate_real.h +144 -0
- data/third_party/abseil-cpp/absl/random/internal/iostream_state_saver.h +245 -0
- data/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h +150 -0
- data/third_party/abseil-cpp/absl/random/internal/pcg_engine.h +308 -0
- data/third_party/abseil-cpp/absl/random/internal/platform.h +171 -0
- data/third_party/abseil-cpp/absl/random/internal/pool_urbg.cc +253 -0
- data/third_party/abseil-cpp/absl/random/internal/pool_urbg.h +131 -0
- data/third_party/abseil-cpp/absl/random/internal/randen.cc +91 -0
- data/third_party/abseil-cpp/absl/random/internal/randen.h +102 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +221 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_detect.h +33 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_engine.h +239 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc +526 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_hwaes.h +50 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_round_keys.cc +462 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_slow.cc +471 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_slow.h +40 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_traits.h +88 -0
- data/third_party/abseil-cpp/absl/random/internal/salted_seed_seq.h +167 -0
- data/third_party/abseil-cpp/absl/random/internal/seed_material.cc +267 -0
- data/third_party/abseil-cpp/absl/random/internal/seed_material.h +104 -0
- data/third_party/abseil-cpp/absl/random/internal/traits.h +101 -0
- data/third_party/abseil-cpp/absl/random/internal/uniform_helper.h +244 -0
- data/third_party/abseil-cpp/absl/random/internal/wide_multiply.h +111 -0
- data/third_party/abseil-cpp/absl/random/log_uniform_int_distribution.h +257 -0
- data/third_party/abseil-cpp/absl/random/poisson_distribution.h +258 -0
- data/third_party/abseil-cpp/absl/random/random.h +189 -0
- data/third_party/abseil-cpp/absl/random/seed_gen_exception.cc +46 -0
- data/third_party/abseil-cpp/absl/random/seed_gen_exception.h +55 -0
- data/third_party/abseil-cpp/absl/random/seed_sequences.cc +29 -0
- data/third_party/abseil-cpp/absl/random/seed_sequences.h +110 -0
- data/third_party/abseil-cpp/absl/random/uniform_int_distribution.h +275 -0
- data/third_party/abseil-cpp/absl/random/uniform_real_distribution.h +202 -0
- data/third_party/abseil-cpp/absl/random/zipf_distribution.h +271 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/base64/base64.c +13 -0
- data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +21 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +12 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +1 -2
- data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/mem.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7.c +29 -0
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +1 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/base64.h +8 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +13 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +10 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +1 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +9 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/pkcs8.h +6 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +23 -2
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +4 -0
- data/third_party/xxhash/xxhash.h +607 -352
- metadata +149 -77
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_index.h +0 -107
- data/src/core/ext/transport/chttp2/transport/hpack_utils.cc +0 -46
- data/src/core/ext/transport/chttp2/transport/popularity_count.h +0 -60
- data/src/core/lib/compression/algorithm_metadata.h +0 -62
- data/src/core/lib/compression/compression_args.cc +0 -140
- data/src/core/lib/compression/compression_args.h +0 -58
- data/src/core/lib/compression/stream_compression.cc +0 -81
- data/src/core/lib/compression/stream_compression.h +0 -117
- data/src/core/lib/compression/stream_compression_gzip.cc +0 -231
- data/src/core/lib/compression/stream_compression_gzip.h +0 -28
- data/src/core/lib/compression/stream_compression_identity.cc +0 -91
- data/src/core/lib/compression/stream_compression_identity.h +0 -29
- data/src/core/lib/security/credentials/credentials_metadata.cc +0 -61
- data/src/core/lib/slice/static_slice.cc +0 -377
- data/src/core/lib/slice/static_slice.h +0 -300
- data/src/core/lib/transport/metadata.cc +0 -714
- data/src/core/lib/transport/metadata.h +0 -449
- data/src/core/lib/transport/metadata_batch.cc +0 -99
- data/src/core/lib/transport/static_metadata.cc +0 -1032
- data/src/core/lib/transport/static_metadata.h +0 -322
- data/src/core/lib/transport/status_metadata.cc +0 -63
- data/src/core/lib/transport/status_metadata.h +0 -48
@@ -0,0 +1,104 @@
|
|
1
|
+
// BEGIN GENERATED CODE; DO NOT EDIT
|
2
|
+
// clang-format off
|
3
|
+
|
4
|
+
#include "absl/random/gaussian_distribution.h"
|
5
|
+
|
6
|
+
namespace absl {
|
7
|
+
ABSL_NAMESPACE_BEGIN
|
8
|
+
namespace random_internal {
|
9
|
+
|
10
|
+
const gaussian_distribution_base::Tables
|
11
|
+
gaussian_distribution_base::zg_ = {
|
12
|
+
{3.7130862467425505, 3.442619855899000214, 3.223084984581141565,
|
13
|
+
3.083228858216868318, 2.978696252647779819, 2.894344007021528942,
|
14
|
+
2.82312535054891045, 2.761169372387176857, 2.706113573121819549,
|
15
|
+
2.656406411261359679, 2.610972248431847387, 2.56903362592493778,
|
16
|
+
2.530009672388827457, 2.493454522095372106, 2.459018177411830486,
|
17
|
+
2.426420645533749809, 2.395434278011062457, 2.365871370117638595,
|
18
|
+
2.337575241339236776, 2.310413683698762988, 2.284274059677471769,
|
19
|
+
2.25905957386919809, 2.234686395590979036, 2.21108140887870297,
|
20
|
+
2.188180432076048731, 2.165926793748921497, 2.144270182360394905,
|
21
|
+
2.123165708673976138, 2.102573135189237608, 2.082456237992015957,
|
22
|
+
2.062782274508307978, 2.043521536655067194, 2.02464697337738464,
|
23
|
+
2.006133869963471206, 1.987959574127619033, 1.970103260854325633,
|
24
|
+
1.952545729553555764, 1.935269228296621957, 1.918257300864508963,
|
25
|
+
1.901494653105150423, 1.884967035707758143, 1.868661140994487768,
|
26
|
+
1.852564511728090002, 1.836665460258444904, 1.820952996596124418,
|
27
|
+
1.805416764219227366, 1.790046982599857506, 1.77483439558606837,
|
28
|
+
1.759770224899592339, 1.744846128113799244, 1.730054160563729182,
|
29
|
+
1.71538674071366648, 1.700836618569915748, 1.686396846779167014,
|
30
|
+
1.6720607540975998, 1.657821920954023254, 1.643674156862867441,
|
31
|
+
1.629611479470633562, 1.615628095043159629, 1.601718380221376581,
|
32
|
+
1.587876864890574558, 1.574098216022999264, 1.560377222366167382,
|
33
|
+
1.546708779859908844, 1.533087877674041755, 1.519509584765938559,
|
34
|
+
1.505969036863201937, 1.492461423781352714, 1.478981976989922842,
|
35
|
+
1.465525957342709296, 1.452088642889222792, 1.438665316684561546,
|
36
|
+
1.425251254514058319, 1.411841712447055919, 1.398431914131003539,
|
37
|
+
1.385017037732650058, 1.371592202427340812, 1.358152454330141534,
|
38
|
+
1.34469275175354519, 1.331207949665625279, 1.317692783209412299,
|
39
|
+
1.304141850128615054, 1.290549591926194894, 1.27691027356015363,
|
40
|
+
1.263217961454619287, 1.249466499573066436, 1.23564948326336066,
|
41
|
+
1.221760230539994385, 1.207791750415947662, 1.193736707833126465,
|
42
|
+
1.17958738466398616, 1.165335636164750222, 1.150972842148865416,
|
43
|
+
1.136489852013158774, 1.121876922582540237, 1.107123647534034028,
|
44
|
+
1.092218876907275371, 1.077150624892893482, 1.061905963694822042,
|
45
|
+
1.046470900764042922, 1.030830236068192907, 1.014967395251327842,
|
46
|
+
0.9988642334929808131, 0.9825008035154263464, 0.9658550794011470098,
|
47
|
+
0.9489026255113034436, 0.9316161966151479401, 0.9139652510230292792,
|
48
|
+
0.8959153525809346874, 0.8774274291129204872, 0.8584568431938099931,
|
49
|
+
0.8389522142975741614, 0.8188539067003538507, 0.7980920606440534693,
|
50
|
+
0.7765839878947563557, 0.7542306644540520688, 0.7309119106424850631,
|
51
|
+
0.7064796113354325779, 0.6807479186691505202, 0.6534786387399710295,
|
52
|
+
0.6243585973360461505, 0.5929629424714434327, 0.5586921784081798625,
|
53
|
+
0.5206560387620546848, 0.4774378372966830431, 0.4265479863554152429,
|
54
|
+
0.3628714310970211909, 0.2723208648139477384, 0},
|
55
|
+
{0.001014352564120377413, 0.002669629083880922793, 0.005548995220771345792,
|
56
|
+
0.008624484412859888607, 0.01183947865788486861, 0.01516729801054656976,
|
57
|
+
0.01859210273701129151, 0.02210330461592709475, 0.02569329193593428151,
|
58
|
+
0.02935631744000685023, 0.03308788614622575758, 0.03688438878665621645,
|
59
|
+
0.04074286807444417458, 0.04466086220049143157, 0.04863629585986780496,
|
60
|
+
0.05266740190305100461, 0.05675266348104984759, 0.06089077034804041277,
|
61
|
+
0.06508058521306804567, 0.06932111739357792179, 0.07361150188411341722,
|
62
|
+
0.07795098251397346301, 0.08233889824223575293, 0.08677467189478028919,
|
63
|
+
0.09125780082683036809, 0.095787849121731522, 0.1003644410286559929,
|
64
|
+
0.1049872554094214289, 0.1096560210148404546, 0.1143705124488661323,
|
65
|
+
0.1191305467076509556, 0.1239359802028679736, 0.1287867061959434012,
|
66
|
+
0.1336826525834396151, 0.1386237799845948804, 0.1436100800906280339,
|
67
|
+
0.1486415742423425057, 0.1537183122081819397, 0.1588403711394795748,
|
68
|
+
0.1640078546834206341, 0.1692208922373653057, 0.1744796383307898324,
|
69
|
+
0.1797842721232958407, 0.1851349970089926078, 0.1905320403191375633,
|
70
|
+
0.1959756531162781534, 0.2014661100743140865, 0.2070037094399269362,
|
71
|
+
0.2125887730717307134, 0.2182216465543058426, 0.2239026993850088965,
|
72
|
+
0.229632325232116602, 0.2354109422634795556, 0.2412389935454402889,
|
73
|
+
0.2471169475123218551, 0.2530452985073261551, 0.2590245673962052742,
|
74
|
+
0.2650553022555897087, 0.271138079138385224, 0.2772735029191887857,
|
75
|
+
0.2834622082232336471, 0.2897048604429605656, 0.2960021568469337061,
|
76
|
+
0.3023548277864842593, 0.3087636380061818397, 0.3152293880650116065,
|
77
|
+
0.3217529158759855901, 0.3283350983728509642, 0.3349768533135899506,
|
78
|
+
0.3416791412315512977, 0.3484429675463274756, 0.355269384847918035,
|
79
|
+
0.3621594953693184626, 0.3691144536644731522, 0.376135469510563536,
|
80
|
+
0.3832238110559021416, 0.3903808082373155797, 0.3976078564938743676,
|
81
|
+
0.404906420807223999, 0.4122780401026620578, 0.4197243320495753771,
|
82
|
+
0.4272469983049970721, 0.4348478302499918513, 0.4425287152754694975,
|
83
|
+
0.4502916436820402768, 0.458138716267873114, 0.4660721526894572309,
|
84
|
+
0.4740943006930180559, 0.4822076463294863724, 0.4904148252838453348,
|
85
|
+
0.4987186354709807201, 0.5071220510755701794, 0.5156282382440030565,
|
86
|
+
0.5242405726729852944, 0.5329626593838373561, 0.5417983550254266145,
|
87
|
+
0.5507517931146057588, 0.5598274127040882009, 0.5690299910679523787,
|
88
|
+
0.5783646811197646898, 0.5878370544347081283, 0.5974531509445183408,
|
89
|
+
0.6072195366251219584, 0.6171433708188825973, 0.6272324852499290282,
|
90
|
+
0.6374954773350440806, 0.6479418211102242475, 0.6585820000500898219,
|
91
|
+
0.6694276673488921414, 0.6804918409973358395, 0.6917891434366769676,
|
92
|
+
0.7033360990161600101, 0.7151515074105005976, 0.7272569183441868201,
|
93
|
+
0.7396772436726493094, 0.7524415591746134169, 0.7655841738977066102,
|
94
|
+
0.7791460859296898134, 0.7931770117713072832, 0.8077382946829627652,
|
95
|
+
0.8229072113814113187, 0.8387836052959920519, 0.8555006078694531446,
|
96
|
+
0.873243048910072206, 0.8922816507840289901, 0.9130436479717434217,
|
97
|
+
0.9362826816850632339, 0.9635996931270905952, 1}};
|
98
|
+
|
99
|
+
} // namespace random_internal
|
100
|
+
ABSL_NAMESPACE_END
|
101
|
+
} // namespace absl
|
102
|
+
|
103
|
+
// clang-format on
|
104
|
+
// END GENERATED CODE
|
@@ -0,0 +1,275 @@
|
|
1
|
+
// Copyright 2017 The Abseil Authors.
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
|
15
|
+
#ifndef ABSL_RANDOM_GAUSSIAN_DISTRIBUTION_H_
|
16
|
+
#define ABSL_RANDOM_GAUSSIAN_DISTRIBUTION_H_
|
17
|
+
|
18
|
+
// absl::gaussian_distribution implements the Ziggurat algorithm
|
19
|
+
// for generating random gaussian numbers.
|
20
|
+
//
|
21
|
+
// Implementation based on "The Ziggurat Method for Generating Random Variables"
|
22
|
+
// by George Marsaglia and Wai Wan Tsang: http://www.jstatsoft.org/v05/i08/
|
23
|
+
//
|
24
|
+
|
25
|
+
#include <cmath>
|
26
|
+
#include <cstdint>
|
27
|
+
#include <istream>
|
28
|
+
#include <limits>
|
29
|
+
#include <type_traits>
|
30
|
+
|
31
|
+
#include "absl/base/config.h"
|
32
|
+
#include "absl/random/internal/fast_uniform_bits.h"
|
33
|
+
#include "absl/random/internal/generate_real.h"
|
34
|
+
#include "absl/random/internal/iostream_state_saver.h"
|
35
|
+
|
36
|
+
namespace absl {
|
37
|
+
ABSL_NAMESPACE_BEGIN
|
38
|
+
namespace random_internal {
|
39
|
+
|
40
|
+
// absl::gaussian_distribution_base implements the underlying ziggurat algorithm
|
41
|
+
// using the ziggurat tables generated by the gaussian_distribution_gentables
|
42
|
+
// binary.
|
43
|
+
//
|
44
|
+
// The specific algorithm has some of the improvements suggested by the
|
45
|
+
// 2005 paper, "An Improved Ziggurat Method to Generate Normal Random Samples",
|
46
|
+
// Jurgen A Doornik. (https://www.doornik.com/research/ziggurat.pdf)
|
47
|
+
class ABSL_DLL gaussian_distribution_base {
|
48
|
+
public:
|
49
|
+
template <typename URBG>
|
50
|
+
inline double zignor(URBG& g); // NOLINT(runtime/references)
|
51
|
+
|
52
|
+
private:
|
53
|
+
friend class TableGenerator;
|
54
|
+
|
55
|
+
template <typename URBG>
|
56
|
+
inline double zignor_fallback(URBG& g, // NOLINT(runtime/references)
|
57
|
+
bool neg);
|
58
|
+
|
59
|
+
// Constants used for the gaussian distribution.
|
60
|
+
static constexpr double kR = 3.442619855899; // Start of the tail.
|
61
|
+
static constexpr double kRInv = 0.29047645161474317; // ~= (1.0 / kR) .
|
62
|
+
static constexpr double kV = 9.91256303526217e-3;
|
63
|
+
static constexpr uint64_t kMask = 0x07f;
|
64
|
+
|
65
|
+
// The ziggurat tables store the pdf(f) and inverse-pdf(x) for equal-area
|
66
|
+
// points on one-half of the normal distribution, where the pdf function,
|
67
|
+
// pdf = e ^ (-1/2 *x^2), assumes that the mean = 0 & stddev = 1.
|
68
|
+
//
|
69
|
+
// These tables are just over 2kb in size; larger tables might improve the
|
70
|
+
// distributions, but also lead to more cache pollution.
|
71
|
+
//
|
72
|
+
// x = {3.71308, 3.44261, 3.22308, ..., 0}
|
73
|
+
// f = {0.00101, 0.00266, 0.00554, ..., 1}
|
74
|
+
struct Tables {
|
75
|
+
double x[kMask + 2];
|
76
|
+
double f[kMask + 2];
|
77
|
+
};
|
78
|
+
static const Tables zg_;
|
79
|
+
random_internal::FastUniformBits<uint64_t> fast_u64_;
|
80
|
+
};
|
81
|
+
|
82
|
+
} // namespace random_internal
|
83
|
+
|
84
|
+
// absl::gaussian_distribution:
|
85
|
+
// Generates a number conforming to a Gaussian distribution.
|
86
|
+
template <typename RealType = double>
|
87
|
+
class gaussian_distribution : random_internal::gaussian_distribution_base {
|
88
|
+
public:
|
89
|
+
using result_type = RealType;
|
90
|
+
|
91
|
+
class param_type {
|
92
|
+
public:
|
93
|
+
using distribution_type = gaussian_distribution;
|
94
|
+
|
95
|
+
explicit param_type(result_type mean = 0, result_type stddev = 1)
|
96
|
+
: mean_(mean), stddev_(stddev) {}
|
97
|
+
|
98
|
+
// Returns the mean distribution parameter. The mean specifies the location
|
99
|
+
// of the peak. The default value is 0.0.
|
100
|
+
result_type mean() const { return mean_; }
|
101
|
+
|
102
|
+
// Returns the deviation distribution parameter. The default value is 1.0.
|
103
|
+
result_type stddev() const { return stddev_; }
|
104
|
+
|
105
|
+
friend bool operator==(const param_type& a, const param_type& b) {
|
106
|
+
return a.mean_ == b.mean_ && a.stddev_ == b.stddev_;
|
107
|
+
}
|
108
|
+
|
109
|
+
friend bool operator!=(const param_type& a, const param_type& b) {
|
110
|
+
return !(a == b);
|
111
|
+
}
|
112
|
+
|
113
|
+
private:
|
114
|
+
result_type mean_;
|
115
|
+
result_type stddev_;
|
116
|
+
|
117
|
+
static_assert(
|
118
|
+
std::is_floating_point<RealType>::value,
|
119
|
+
"Class-template absl::gaussian_distribution<> must be parameterized "
|
120
|
+
"using a floating-point type.");
|
121
|
+
};
|
122
|
+
|
123
|
+
gaussian_distribution() : gaussian_distribution(0) {}
|
124
|
+
|
125
|
+
explicit gaussian_distribution(result_type mean, result_type stddev = 1)
|
126
|
+
: param_(mean, stddev) {}
|
127
|
+
|
128
|
+
explicit gaussian_distribution(const param_type& p) : param_(p) {}
|
129
|
+
|
130
|
+
void reset() {}
|
131
|
+
|
132
|
+
// Generating functions
|
133
|
+
template <typename URBG>
|
134
|
+
result_type operator()(URBG& g) { // NOLINT(runtime/references)
|
135
|
+
return (*this)(g, param_);
|
136
|
+
}
|
137
|
+
|
138
|
+
template <typename URBG>
|
139
|
+
result_type operator()(URBG& g, // NOLINT(runtime/references)
|
140
|
+
const param_type& p);
|
141
|
+
|
142
|
+
param_type param() const { return param_; }
|
143
|
+
void param(const param_type& p) { param_ = p; }
|
144
|
+
|
145
|
+
result_type(min)() const {
|
146
|
+
return -std::numeric_limits<result_type>::infinity();
|
147
|
+
}
|
148
|
+
result_type(max)() const {
|
149
|
+
return std::numeric_limits<result_type>::infinity();
|
150
|
+
}
|
151
|
+
|
152
|
+
result_type mean() const { return param_.mean(); }
|
153
|
+
result_type stddev() const { return param_.stddev(); }
|
154
|
+
|
155
|
+
friend bool operator==(const gaussian_distribution& a,
|
156
|
+
const gaussian_distribution& b) {
|
157
|
+
return a.param_ == b.param_;
|
158
|
+
}
|
159
|
+
friend bool operator!=(const gaussian_distribution& a,
|
160
|
+
const gaussian_distribution& b) {
|
161
|
+
return a.param_ != b.param_;
|
162
|
+
}
|
163
|
+
|
164
|
+
private:
|
165
|
+
param_type param_;
|
166
|
+
};
|
167
|
+
|
168
|
+
// --------------------------------------------------------------------------
|
169
|
+
// Implementation details only below
|
170
|
+
// --------------------------------------------------------------------------
|
171
|
+
|
172
|
+
template <typename RealType>
|
173
|
+
template <typename URBG>
|
174
|
+
typename gaussian_distribution<RealType>::result_type
|
175
|
+
gaussian_distribution<RealType>::operator()(
|
176
|
+
URBG& g, // NOLINT(runtime/references)
|
177
|
+
const param_type& p) {
|
178
|
+
return p.mean() + p.stddev() * static_cast<result_type>(zignor(g));
|
179
|
+
}
|
180
|
+
|
181
|
+
template <typename CharT, typename Traits, typename RealType>
|
182
|
+
std::basic_ostream<CharT, Traits>& operator<<(
|
183
|
+
std::basic_ostream<CharT, Traits>& os, // NOLINT(runtime/references)
|
184
|
+
const gaussian_distribution<RealType>& x) {
|
185
|
+
auto saver = random_internal::make_ostream_state_saver(os);
|
186
|
+
os.precision(random_internal::stream_precision_helper<RealType>::kPrecision);
|
187
|
+
os << x.mean() << os.fill() << x.stddev();
|
188
|
+
return os;
|
189
|
+
}
|
190
|
+
|
191
|
+
template <typename CharT, typename Traits, typename RealType>
|
192
|
+
std::basic_istream<CharT, Traits>& operator>>(
|
193
|
+
std::basic_istream<CharT, Traits>& is, // NOLINT(runtime/references)
|
194
|
+
gaussian_distribution<RealType>& x) { // NOLINT(runtime/references)
|
195
|
+
using result_type = typename gaussian_distribution<RealType>::result_type;
|
196
|
+
using param_type = typename gaussian_distribution<RealType>::param_type;
|
197
|
+
|
198
|
+
auto saver = random_internal::make_istream_state_saver(is);
|
199
|
+
auto mean = random_internal::read_floating_point<result_type>(is);
|
200
|
+
if (is.fail()) return is;
|
201
|
+
auto stddev = random_internal::read_floating_point<result_type>(is);
|
202
|
+
if (!is.fail()) {
|
203
|
+
x.param(param_type(mean, stddev));
|
204
|
+
}
|
205
|
+
return is;
|
206
|
+
}
|
207
|
+
|
208
|
+
namespace random_internal {
|
209
|
+
|
210
|
+
template <typename URBG>
|
211
|
+
inline double gaussian_distribution_base::zignor_fallback(URBG& g, bool neg) {
|
212
|
+
using random_internal::GeneratePositiveTag;
|
213
|
+
using random_internal::GenerateRealFromBits;
|
214
|
+
|
215
|
+
// This fallback path happens approximately 0.05% of the time.
|
216
|
+
double x, y;
|
217
|
+
do {
|
218
|
+
// kRInv = 1/r, U(0, 1)
|
219
|
+
x = kRInv *
|
220
|
+
std::log(GenerateRealFromBits<double, GeneratePositiveTag, false>(
|
221
|
+
fast_u64_(g)));
|
222
|
+
y = -std::log(
|
223
|
+
GenerateRealFromBits<double, GeneratePositiveTag, false>(fast_u64_(g)));
|
224
|
+
} while ((y + y) < (x * x));
|
225
|
+
return neg ? (x - kR) : (kR - x);
|
226
|
+
}
|
227
|
+
|
228
|
+
template <typename URBG>
|
229
|
+
inline double gaussian_distribution_base::zignor(
|
230
|
+
URBG& g) { // NOLINT(runtime/references)
|
231
|
+
using random_internal::GeneratePositiveTag;
|
232
|
+
using random_internal::GenerateRealFromBits;
|
233
|
+
using random_internal::GenerateSignedTag;
|
234
|
+
|
235
|
+
while (true) {
|
236
|
+
// We use a single uint64_t to generate both a double and a strip.
|
237
|
+
// These bits are unused when the generated double is > 1/2^5.
|
238
|
+
// This may introduce some bias from the duplicated low bits of small
|
239
|
+
// values (those smaller than 1/2^5, which all end up on the left tail).
|
240
|
+
uint64_t bits = fast_u64_(g);
|
241
|
+
int i = static_cast<int>(bits & kMask); // pick a random strip
|
242
|
+
double j = GenerateRealFromBits<double, GenerateSignedTag, false>(
|
243
|
+
bits); // U(-1, 1)
|
244
|
+
const double x = j * zg_.x[i];
|
245
|
+
|
246
|
+
// Retangular box. Handles >97% of all cases.
|
247
|
+
// For any given box, this handles between 75% and 99% of values.
|
248
|
+
// Equivalent to U(01) < (x[i+1] / x[i]), and when i == 0, ~93.5%
|
249
|
+
if (std::abs(x) < zg_.x[i + 1]) {
|
250
|
+
return x;
|
251
|
+
}
|
252
|
+
|
253
|
+
// i == 0: Base box. Sample using a ratio of uniforms.
|
254
|
+
if (i == 0) {
|
255
|
+
// This path happens about 0.05% of the time.
|
256
|
+
return zignor_fallback(g, j < 0);
|
257
|
+
}
|
258
|
+
|
259
|
+
// i > 0: Wedge samples using precomputed values.
|
260
|
+
double v = GenerateRealFromBits<double, GeneratePositiveTag, false>(
|
261
|
+
fast_u64_(g)); // U(0, 1)
|
262
|
+
if ((zg_.f[i + 1] + v * (zg_.f[i] - zg_.f[i + 1])) <
|
263
|
+
std::exp(-0.5 * x * x)) {
|
264
|
+
return x;
|
265
|
+
}
|
266
|
+
|
267
|
+
// The wedge was missed; reject the value and try again.
|
268
|
+
}
|
269
|
+
}
|
270
|
+
|
271
|
+
} // namespace random_internal
|
272
|
+
ABSL_NAMESPACE_END
|
273
|
+
} // namespace absl
|
274
|
+
|
275
|
+
#endif // ABSL_RANDOM_GAUSSIAN_DISTRIBUTION_H_
|
@@ -0,0 +1,92 @@
|
|
1
|
+
//
|
2
|
+
// Copyright 2018 The Abseil Authors.
|
3
|
+
//
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
// you may not use this file except in compliance with the License.
|
6
|
+
// You may obtain a copy of the License at
|
7
|
+
//
|
8
|
+
// https://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
//
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
// See the License for the specific language governing permissions and
|
14
|
+
// limitations under the License.
|
15
|
+
//
|
16
|
+
|
17
|
+
#ifndef ABSL_RANDOM_INTERNAL_DISTRIBUTION_CALLER_H_
|
18
|
+
#define ABSL_RANDOM_INTERNAL_DISTRIBUTION_CALLER_H_
|
19
|
+
|
20
|
+
#include <utility>
|
21
|
+
|
22
|
+
#include "absl/base/config.h"
|
23
|
+
#include "absl/base/internal/fast_type_id.h"
|
24
|
+
#include "absl/utility/utility.h"
|
25
|
+
|
26
|
+
namespace absl {
|
27
|
+
ABSL_NAMESPACE_BEGIN
|
28
|
+
namespace random_internal {
|
29
|
+
|
30
|
+
// DistributionCaller provides an opportunity to overload the general
|
31
|
+
// mechanism for calling a distribution, allowing for mock-RNG classes
|
32
|
+
// to intercept such calls.
|
33
|
+
template <typename URBG>
|
34
|
+
struct DistributionCaller {
|
35
|
+
// SFINAE to detect whether the URBG type includes a member matching
|
36
|
+
// bool InvokeMock(base_internal::FastTypeIdType, void*, void*).
|
37
|
+
//
|
38
|
+
// These live inside BitGenRef so that they have friend access
|
39
|
+
// to MockingBitGen. (see similar methods in DistributionCaller).
|
40
|
+
template <template <class...> class Trait, class AlwaysVoid, class... Args>
|
41
|
+
struct detector : std::false_type {};
|
42
|
+
template <template <class...> class Trait, class... Args>
|
43
|
+
struct detector<Trait, absl::void_t<Trait<Args...>>, Args...>
|
44
|
+
: std::true_type {};
|
45
|
+
|
46
|
+
template <class T>
|
47
|
+
using invoke_mock_t = decltype(std::declval<T*>()->InvokeMock(
|
48
|
+
std::declval<::absl::base_internal::FastTypeIdType>(),
|
49
|
+
std::declval<void*>(), std::declval<void*>()));
|
50
|
+
|
51
|
+
using HasInvokeMock = typename detector<invoke_mock_t, void, URBG>::type;
|
52
|
+
|
53
|
+
// Default implementation of distribution caller.
|
54
|
+
template <typename DistrT, typename... Args>
|
55
|
+
static typename DistrT::result_type Impl(std::false_type, URBG* urbg,
|
56
|
+
Args&&... args) {
|
57
|
+
DistrT dist(std::forward<Args>(args)...);
|
58
|
+
return dist(*urbg);
|
59
|
+
}
|
60
|
+
|
61
|
+
// Mock implementation of distribution caller.
|
62
|
+
// The underlying KeyT must match the KeyT constructed by MockOverloadSet.
|
63
|
+
template <typename DistrT, typename... Args>
|
64
|
+
static typename DistrT::result_type Impl(std::true_type, URBG* urbg,
|
65
|
+
Args&&... args) {
|
66
|
+
using ResultT = typename DistrT::result_type;
|
67
|
+
using ArgTupleT = std::tuple<absl::decay_t<Args>...>;
|
68
|
+
using KeyT = ResultT(DistrT, ArgTupleT);
|
69
|
+
|
70
|
+
ArgTupleT arg_tuple(std::forward<Args>(args)...);
|
71
|
+
ResultT result;
|
72
|
+
if (!urbg->InvokeMock(::absl::base_internal::FastTypeId<KeyT>(), &arg_tuple,
|
73
|
+
&result)) {
|
74
|
+
auto dist = absl::make_from_tuple<DistrT>(arg_tuple);
|
75
|
+
result = dist(*urbg);
|
76
|
+
}
|
77
|
+
return result;
|
78
|
+
}
|
79
|
+
|
80
|
+
// Default implementation of distribution caller.
|
81
|
+
template <typename DistrT, typename... Args>
|
82
|
+
static typename DistrT::result_type Call(URBG* urbg, Args&&... args) {
|
83
|
+
return Impl<DistrT, Args...>(HasInvokeMock{}, urbg,
|
84
|
+
std::forward<Args>(args)...);
|
85
|
+
}
|
86
|
+
};
|
87
|
+
|
88
|
+
} // namespace random_internal
|
89
|
+
ABSL_NAMESPACE_END
|
90
|
+
} // namespace absl
|
91
|
+
|
92
|
+
#endif // ABSL_RANDOM_INTERNAL_DISTRIBUTION_CALLER_H_
|