diff --git a/go.mod b/go.mod index 1f30907af21..2e61e1e6b57 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcb github.com/felixge/fgprof v0.9.5 github.com/go-kit/log v0.2.1 - github.com/go-openapi/strfmt v0.26.4 + github.com/go-openapi/strfmt v0.27.0 github.com/go-openapi/swag v0.26.0 // indirect github.com/go-redis/redis/v8 v8.11.5 github.com/gogo/protobuf v1.3.2 @@ -24,15 +24,15 @@ require ( github.com/gorilla/mux v1.8.1 github.com/grafana/regexp v0.0.0-20250905093917-f7b3be9d1853 github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 - github.com/hashicorp/consul/api v1.34.3 + github.com/hashicorp/consul/api v1.34.4 github.com/hashicorp/go-cleanhttp v0.5.2 - github.com/hashicorp/go-metrics v0.6.0 + github.com/hashicorp/go-metrics v0.6.1 github.com/hashicorp/go-sockaddr v1.0.7 - github.com/hashicorp/memberlist v0.5.4 + github.com/hashicorp/memberlist v0.6.0 github.com/json-iterator/go v1.1.12 - github.com/klauspost/compress v1.18.7 + github.com/klauspost/compress v1.19.2 github.com/lib/pq v1.11.2 // indirect - github.com/minio/minio-go/v7 v7.2.1 + github.com/minio/minio-go/v7 v7.3.0 github.com/mitchellh/go-wordwrap v1.0.1 github.com/oklog/ulid v1.3.1 github.com/opentracing-contrib/go-grpc v0.1.4 @@ -40,15 +40,15 @@ require ( github.com/opentracing/opentracing-go v1.2.0 github.com/pkg/errors v0.9.1 github.com/prometheus/alertmanager v0.33.0 - github.com/prometheus/client_golang v1.23.2 + github.com/prometheus/client_golang v1.24.1 github.com/prometheus/client_model v0.6.2 - github.com/prometheus/common v0.69.0 + github.com/prometheus/common v0.70.1 // Prometheus maps version 3.x.y to tags v0.30x.y. github.com/prometheus/prometheus v0.309.1 github.com/segmentio/fasthash v1.0.3 github.com/sony/gobreaker v1.0.0 github.com/spf13/afero v1.15.0 - github.com/stretchr/testify v1.11.1 + github.com/stretchr/testify v1.12.1 github.com/thanos-io/objstore v0.0.0-20250804093838-71d60dfee488 github.com/thanos-io/promql-engine v0.0.0-20260729073658-f8bd3f940687 github.com/thanos-io/thanos v0.42.1-0.20260727122508-92397939e4cc @@ -57,15 +57,15 @@ require ( go.etcd.io/etcd/api/v3 v3.5.17 go.etcd.io/etcd/client/pkg/v3 v3.5.17 go.etcd.io/etcd/client/v3 v3.5.17 - go.opentelemetry.io/contrib/propagators/aws v1.44.0 + go.opentelemetry.io/contrib/propagators/aws v1.45.0 go.opentelemetry.io/otel v1.45.0 go.opentelemetry.io/otel/bridge/opentracing v1.45.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.44.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.44.0 - go.opentelemetry.io/otel/sdk v1.44.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.45.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.45.0 + go.opentelemetry.io/otel/sdk v1.45.0 go.opentelemetry.io/otel/trace v1.45.0 go.uber.org/atomic v1.11.0 - golang.org/x/net v0.57.0 + golang.org/x/net v0.58.0 golang.org/x/sync v0.22.0 golang.org/x/time v0.15.0 google.golang.org/grpc v1.83.0 @@ -75,28 +75,28 @@ require ( require ( github.com/VictoriaMetrics/fastcache v1.13.3 - github.com/aws/aws-sdk-go-v2 v1.42.0 - github.com/aws/aws-sdk-go-v2/config v1.32.26 - github.com/aws/aws-sdk-go-v2/service/dynamodb v1.59.1 + github.com/aws/aws-sdk-go-v2 v1.43.6 + github.com/aws/aws-sdk-go-v2/config v1.32.37 + github.com/aws/aws-sdk-go-v2/service/dynamodb v1.63.3 github.com/axiomhq/hyperloglog v0.2.6 github.com/bboreham/go-loser v0.0.0-20230920113527-fcc2c21820a3 github.com/cespare/xxhash/v2 v2.3.0 github.com/edsrzf/mmap-go v1.2.0 - github.com/go-openapi/swag/jsonutils v0.27.0 + github.com/go-openapi/swag/jsonutils v0.28.0 github.com/google/go-cmp v0.7.0 github.com/google/uuid v1.6.0 github.com/hashicorp/golang-lru/v2 v2.0.7 github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 - github.com/oklog/ulid/v2 v2.1.1 - github.com/parquet-go/parquet-go v0.30.1 + github.com/oklog/ulid/v2 v2.1.2 + github.com/parquet-go/parquet-go v0.32.0 github.com/prometheus-community/parquet-common v0.0.0-20260614025832-5f32460b5373 github.com/prometheus/client_golang/exp v0.0.0-20251212205219-7ba246a648ca - github.com/prometheus/procfs v0.21.0 + github.com/prometheus/procfs v0.21.1 github.com/sercand/kuberesolver/v5 v5.1.1 - github.com/tjhop/slog-gokit v0.2.0 - go.opentelemetry.io/collector/pdata v1.61.0 + github.com/tjhop/slog-gokit v0.2.2 + go.opentelemetry.io/collector/pdata v1.65.0 go.uber.org/automaxprocs v1.6.0 - google.golang.org/protobuf v1.36.11 + google.golang.org/protobuf v1.36.12 ) require ( @@ -121,20 +121,20 @@ require ( github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible // indirect github.com/andybalholm/brotli v1.1.1 // indirect github.com/armon/go-metrics v0.4.1 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.19.25 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.29 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.29 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.29 // indirect - github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.30 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.12 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.12.6 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.29 // indirect - github.com/aws/aws-sdk-go-v2/service/signin v1.2.1 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.19.36 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.37 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.37 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.37 // indirect + github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.38 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.17 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.12.14 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.37 // indirect + github.com/aws/aws-sdk-go-v2/service/signin v1.5.6 // indirect github.com/aws/aws-sdk-go-v2/service/sns v1.39.17 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.31.4 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.36.7 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.43.4 // indirect - github.com/aws/smithy-go v1.27.1 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.33.6 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.38.6 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.45.6 // indirect + github.com/aws/smithy-go v1.27.8 // indirect github.com/baidubce/bce-sdk-go v0.9.230 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/blang/semver/v4 v4.0.0 // indirect @@ -171,14 +171,15 @@ require ( github.com/go-openapi/runtime v0.29.4 // indirect github.com/go-openapi/spec v0.22.4 // indirect github.com/go-openapi/swag/cmdutils v0.26.0 // indirect - github.com/go-openapi/swag/conv v0.27.0 // indirect + github.com/go-openapi/swag/conv v0.28.0 // indirect github.com/go-openapi/swag/fileutils v0.26.0 // indirect github.com/go-openapi/swag/jsonname v0.26.0 // indirect github.com/go-openapi/swag/loading v0.26.0 // indirect github.com/go-openapi/swag/mangling v0.26.0 // indirect github.com/go-openapi/swag/netutils v0.26.0 // indirect + github.com/go-openapi/swag/pools v0.28.0 // indirect github.com/go-openapi/swag/stringutils v0.26.0 // indirect - github.com/go-openapi/swag/typeutils v0.27.0 // indirect + github.com/go-openapi/swag/typeutils v0.28.0 // indirect github.com/go-openapi/swag/yamlutils v0.26.0 // indirect github.com/go-openapi/validate v0.25.2 // indirect github.com/go-viper/mapstructure/v2 v2.5.0 // indirect @@ -202,14 +203,14 @@ require ( github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-rootcerts v1.0.2 // indirect github.com/hashicorp/go-version v1.9.0 // indirect - github.com/hashicorp/golang-lru v0.6.0 // indirect - github.com/hashicorp/serf v0.10.1 // indirect + github.com/hashicorp/golang-lru v1.0.2 // indirect + github.com/hashicorp/serf v0.10.4 // indirect github.com/huaweicloud/huaweicloud-sdk-go-obs v3.25.4+incompatible // indirect github.com/jessevdk/go-flags v1.6.1 // indirect github.com/jpillora/backoff v1.0.0 // indirect github.com/julienschmidt/httprouter v1.3.0 // indirect github.com/kamstrup/intmap v0.5.2 // indirect - github.com/klauspost/cpuid/v2 v2.2.11 // indirect + github.com/klauspost/cpuid/v2 v2.4.0 // indirect github.com/klauspost/crc32 v1.3.0 // indirect github.com/knadh/koanf/maps v0.1.2 // indirect github.com/knadh/koanf/providers/confmap v1.0.0 // indirect @@ -217,12 +218,12 @@ require ( github.com/kylelemons/godebug v1.1.0 // indirect github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect - github.com/mattn/go-colorable v0.1.14 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-colorable v0.1.15 // indirect + github.com/mattn/go-isatty v0.0.22 // indirect github.com/mdlayher/socket v0.5.1 // indirect github.com/mdlayher/vsock v1.2.1 // indirect github.com/metalmatze/signal v0.0.0-20210307161603-1c9aa721a97a // indirect - github.com/miekg/dns v1.1.69 // indirect + github.com/miekg/dns v1.1.72 // indirect github.com/minio/crc64nvme v1.1.1 // indirect github.com/minio/md5-simd v1.1.2 // indirect github.com/minio/sha256-simd v1.0.1 // indirect @@ -246,7 +247,6 @@ require ( github.com/pierrec/lz4/v4 v4.1.26 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect - github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus-community/prom-label-proxy v0.11.1 // indirect github.com/prometheus/exporter-toolkit v0.16.0 // indirect github.com/prometheus/otlptranslator v1.0.0 // indirect @@ -261,9 +261,9 @@ require ( github.com/sirupsen/logrus v1.9.4 // indirect github.com/soheilhy/cmux v0.1.5 // indirect github.com/spiffe/go-spiffe/v2 v2.7.0 // indirect - github.com/stretchr/objx v0.5.2 // indirect + github.com/stretchr/objx v0.5.3 // indirect github.com/tencentyun/cos-go-sdk-v5 v0.7.66 // indirect - github.com/tinylib/msgp v1.6.1 // indirect + github.com/tinylib/msgp v1.6.4 // indirect github.com/twmb/franz-go v1.21.2 // indirect github.com/twmb/franz-go/pkg/kmsg v1.13.1 // indirect github.com/twmb/franz-go/plugin/kslog v1.0.0 // indirect @@ -281,7 +281,7 @@ require ( go.opentelemetry.io/collector/confmap v1.48.0 // indirect go.opentelemetry.io/collector/confmap/xconfmap v0.142.0 // indirect go.opentelemetry.io/collector/consumer v1.48.0 // indirect - go.opentelemetry.io/collector/featuregate v1.61.0 // indirect + go.opentelemetry.io/collector/featuregate v1.65.0 // indirect go.opentelemetry.io/collector/pipeline v1.48.0 // indirect go.opentelemetry.io/collector/processor v1.48.0 // indirect go.opentelemetry.io/collector/semconv v0.128.0 // indirect @@ -295,26 +295,26 @@ require ( go.opentelemetry.io/contrib/propagators/ot v1.36.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0 // indirect go.opentelemetry.io/otel/metric v1.45.0 // indirect - go.opentelemetry.io/otel/sdk/metric v1.44.0 // indirect - go.opentelemetry.io/proto/otlp v1.10.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.45.0 // indirect + go.opentelemetry.io/proto/otlp v1.11.0 // indirect go.uber.org/goleak v1.3.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.1 // indirect go.yaml.in/yaml/v2 v2.4.4 // indirect - go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/crypto v0.54.0 // indirect + go.yaml.in/yaml/v3 v3.0.5 // indirect + golang.org/x/crypto v0.55.0 // indirect golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa // indirect - golang.org/x/mod v0.37.0 // indirect + golang.org/x/mod v0.38.0 // indirect golang.org/x/oauth2 v0.36.0 // indirect golang.org/x/sys v0.47.0 // indirect - golang.org/x/text v0.40.0 // indirect - golang.org/x/tools v0.47.0 // indirect + golang.org/x/text v0.41.0 // indirect + golang.org/x/tools v0.48.0 // indirect gonum.org/v1/gonum v0.17.0 // indirect google.golang.org/api v0.264.0 // indirect google.golang.org/genproto v0.0.0-20260128011058-8636f8732409 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20260803160001-6ac0973c030d // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20260803160001-6ac0973c030d // indirect - gopkg.in/ini.v1 v1.67.2 // indirect + gopkg.in/ini.v1 v1.67.3 // indirect gopkg.in/telebot.v3 v3.3.8 // indirect k8s.io/apimachinery v0.34.3 // indirect k8s.io/client-go v0.34.3 // indirect diff --git a/go.sum b/go.sum index c76578a365d..3a94bb5c174 100644 --- a/go.sum +++ b/go.sum @@ -156,46 +156,46 @@ github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJ github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/aws/aws-sdk-go-v2 v1.42.0 h1:XvXMJTkFQtpBKIWZnmr9ZEOc2InWM2yldjXEJ/bymhA= -github.com/aws/aws-sdk-go-v2 v1.42.0/go.mod h1:27+ACypSLljLAEKsCYOmrjKh83vuTRkuAe9Uv/3A4bg= -github.com/aws/aws-sdk-go-v2/config v1.32.26 h1:JI+W5B3jUA8UBz2ggbICGd9UCR6/+SB21G8EFl0SFTQ= -github.com/aws/aws-sdk-go-v2/config v1.32.26/go.mod h1:RLE2Ls/wRstvdSz1GPrIWNnXcKZ/znDdWyMuiQxdBoY= -github.com/aws/aws-sdk-go-v2/credentials v1.19.25 h1:TzPVjfUZ1hsKafvYE+DIzKXIik2KufQxsPHanlkttbo= -github.com/aws/aws-sdk-go-v2/credentials v1.19.25/go.mod h1:K4hw0buguVvtC74HnVfTRr0LzQQHAWPqJbBU9QGk2Pg= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.29 h1:r6qZHbT+wxgWO/e9vYNUEtg7lv5+UN3pRqKhLXvnArg= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.29/go.mod h1:QRnaRcTVGKPGRy8w78HMQtKUGRYcnMZAANATkeVA6Mo= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.29 h1:f3vKqSo13fhTYb+JEcXwXefZQE26I1FB5eTSniU67ko= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.29/go.mod h1:MzoLFUArKGpGD+ukmPiTPG1X5x4o6M2kq4v2dr1FiEc= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.29 h1:RdwIf/CuUsvJX3RgJagbOyotl/cxoLY4xviKuE7p2GY= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.29/go.mod h1:71wt8W2EgswdZy9Mf9KNnzxZ3TiZlv4caKghPktDOkA= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.30 h1:VTGy885W5DKBxWRUJbym9hytNaYzsyaPkCHGRRMAOhU= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.30/go.mod h1:AS0HycUvJRFvTt613AYDOgO2jzw+00cVSMny8XB3yMY= -github.com/aws/aws-sdk-go-v2/service/dynamodb v1.59.1 h1:GaRPmlTeDxjnp6XipIV4b69PJalB59DcMMClFJeHeMw= -github.com/aws/aws-sdk-go-v2/service/dynamodb v1.59.1/go.mod h1:jLkDwIDBkCIpiENQhAOjAR2L9jwj56mZgVEvuro4gUE= +github.com/aws/aws-sdk-go-v2 v1.43.6 h1:RrmFcqCBxkJuf7g1axVo5krB4jM/AO8r5e5oujrgdoQ= +github.com/aws/aws-sdk-go-v2 v1.43.6/go.mod h1:tXpPM+v0D1lndmga+HqqLDIzUFJlEeR21aspVklHF00= +github.com/aws/aws-sdk-go-v2/config v1.32.37 h1:Ljl7LOJB6ym0liuEl0+TZ3d7f5I8MEZN1Cj9PINlj/g= +github.com/aws/aws-sdk-go-v2/config v1.32.37/go.mod h1:WJ7pe7ZPpmG8Q5kKS53zeypIV4FBGACxmte8Uc6SgUc= +github.com/aws/aws-sdk-go-v2/credentials v1.19.36 h1:84s5xMme6ENYEdKG8rsbSFFg/8+lbHBeM9QYSO0gnDk= +github.com/aws/aws-sdk-go-v2/credentials v1.19.36/go.mod h1:c46BLdagDLIswjgt+GeQOslXgeS0E6wCacs5yZbxPGk= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.37 h1:b5tb+CZItBkydC7r3hTNdSO3pszG1R2EtnA+7TePQPk= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.37/go.mod h1:ZQ+6SU9X0oz6+7MUCSswv9Mjci4eaqZr21HI2RVy/yA= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.37 h1:lznzIOvvbqjfe8UAaciCRJgBgJsxuTROKlhZuXQWfv8= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.37/go.mod h1:otfkzyfQeMMLZAqX59GSXTL3o22BR/l6HFaRzzbWSqA= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.37 h1:zCEORWo0eU0gDjG+IyApE/2B+ZGG1m+GU7B263XV8ds= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.37/go.mod h1:i6c0PEl3TNOWxRbQ++KQcVenPWS/GoQeiklKhNuqzJ8= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.38 h1:A3UAuCmx7LyUcrixBTzKJYYIUZ2yTvn6ZhT8PB+7APk= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.38/go.mod h1:1PDUYG9Z+JrbbsobsAZHjWOm9QBT/djiK3QbykTL5Z4= +github.com/aws/aws-sdk-go-v2/service/dynamodb v1.63.3 h1:cVfESNZmZ8L9TkOeNo6u/eNR0ZphBuS1J2GjLBLmEdA= +github.com/aws/aws-sdk-go-v2/service/dynamodb v1.63.3/go.mod h1:n9exrC9k5S+0t6X6LQKHcv7ap1jAEAHY2Sbqhu9mS34= github.com/aws/aws-sdk-go-v2/service/ec2 v1.277.0 h1:RHJSkRXDGkAKrV4CTEsZsZkOmSpxXKO4aKx4rXd94K4= github.com/aws/aws-sdk-go-v2/service/ec2 v1.277.0/go.mod h1:Wg68QRgy2gEGGdmTPU/UbVpdv8sM14bUZmF64KFwAsY= github.com/aws/aws-sdk-go-v2/service/ecs v1.69.5 h1:5nkhwt0d/gjuT3AQ2LUK0aFRNB3MGlzB2elqy/ZsKP4= github.com/aws/aws-sdk-go-v2/service/ecs v1.69.5/go.mod h1:LQMlcWBoiFVD3vUVEz42ST0yTiaDujv2dRE6sXt1yPE= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.12 h1:ZD2+BSw9vFsNlKYIasSNt3uDbjqqXIBcM13UJv/Lx2k= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.12/go.mod h1:Ms4zlcVBbXbiP7EVLhl+lgjvA/a7YphqQ3Ih3174EmI= -github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.12.6 h1:Bs2OwYq0HBgHYwfGmUwYIPtTNaGMGAHkRje4jmW2VoI= -github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.12.6/go.mod h1:OTctu4cW8t7/TRlTKPLT6akzyOkfceMWhtEHqtYDIQQ= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.29 h1:DRebniUGZ2MqiiIVmQJ04vIXr918hubdHMnarSLEWyU= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.29/go.mod h1:LfRkPCD8YHDM2E5eTkos2UpwYeZnBcVarTa8L59bJHA= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.17 h1:OvYZOB3qA6zvfdRFiRFRzVSiElMYrz3GdntkXZxlp1o= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.17/go.mod h1:JgR/2Ew50ACfIWau1oeMRX59tMtC0kM+PYQGEaT04cY= +github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.12.14 h1:fiayMFWJ04EbPboTzc97F4ii4o6bAi0b6Sk8oXUHRUQ= +github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.12.14/go.mod h1:Ki93kowJvAQpSDjMR+QfntVks2FIj2TWdV3jGIWWm10= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.37 h1:a3D4AjrOrTrP8+d9ILBthqrElf0z1JNol09Xvnwcys8= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.37/go.mod h1:ky0gTu+ukvUTuUKFIpp6Wid4oninrkCyvbFkVs0kpHM= github.com/aws/aws-sdk-go-v2/service/lightsail v1.50.10 h1:MQuZZ6Tq1qQabPlkVxrCMdyVl70Ogl4AERZKo+y9Wzo= github.com/aws/aws-sdk-go-v2/service/lightsail v1.50.10/go.mod h1:U5C3JME1ibKESmpzBAqlRpTYZfVbTqrb5ICJm+sVVd8= -github.com/aws/aws-sdk-go-v2/service/signin v1.2.1 h1:BeJmkm5YOZs6lGRGcNoIuLSoTTtGLLCEqlSiRKYodfM= -github.com/aws/aws-sdk-go-v2/service/signin v1.2.1/go.mod h1:LxYujSTLPRlp2vTtcUO/+1ilrew8ytt6SvQyOgejzFQ= +github.com/aws/aws-sdk-go-v2/service/signin v1.5.6 h1:i68sFvXidKlkiSvI7d7Ilc1/UvW4CtBOaivH7jhG4fs= +github.com/aws/aws-sdk-go-v2/service/signin v1.5.6/go.mod h1:/h7Obr9WTtzbjTHGASRQwLN7Bupw+TC3x8x7fyx39hE= github.com/aws/aws-sdk-go-v2/service/sns v1.39.17 h1:synXIPC/L4Cc489P0XDcrVJzHSLj7krKRpFLalbGM2k= github.com/aws/aws-sdk-go-v2/service/sns v1.39.17/go.mod h1:4ABZnI23uNK37waIjGwkubnCwGhepIt9x1GvASfljJA= -github.com/aws/aws-sdk-go-v2/service/sso v1.31.4 h1:i465b/3c7xJd++pobNIDOggouekCuiWOnB0goQJy+94= -github.com/aws/aws-sdk-go-v2/service/sso v1.31.4/go.mod h1:Lk7PlmoTYryQmyBG0EXqj5BcUbj3whXdU2s3yGI3EAc= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.36.7 h1:xbmJAnBbyYPkTzoCNCF/bpJ6ymQHRdXX1vquYfDIGYk= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.36.7/go.mod h1:Q5N6icH+KJZDLh+ESNwzdv6cZ6vLFF/egy3IOxWhmz4= -github.com/aws/aws-sdk-go-v2/service/sts v1.43.4 h1:Np0vmL7op0Zs5xGacYMMX3v5O5pvZ46xhb5LwDgPj8M= -github.com/aws/aws-sdk-go-v2/service/sts v1.43.4/go.mod h1:r8wkDOuLaaMFqFiYAb8dGY2A3gJCOujMc6CFOVC4Zhc= -github.com/aws/smithy-go v1.27.1 h1:4T340VFndXtADGF52gYa1POyL7s9E4Z1OeZ1hCscIw8= -github.com/aws/smithy-go v1.27.1/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= +github.com/aws/aws-sdk-go-v2/service/sso v1.33.6 h1:tpfGChmjUmv3W9WlRvy+stwKDTbFFdq8Zk9DbFPrfMU= +github.com/aws/aws-sdk-go-v2/service/sso v1.33.6/go.mod h1:CSjiDzmG/lsKkTOYjbkM+duLmRlW+LOxD64Na44ijnI= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.38.6 h1:49BBtY68A+KJCQ3a2F3eUe6ROsKucxUdfHKoqorc0wI= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.38.6/go.mod h1:ptG2hbs7QltE1GcQY0MpS4bfrc51KCnBXUr7OT1EEfE= +github.com/aws/aws-sdk-go-v2/service/sts v1.45.6 h1:JvExZWabChDM0qJAirQYGfOYo0ndT3edXj+fqSPNjkE= +github.com/aws/aws-sdk-go-v2/service/sts v1.45.6/go.mod h1:XZcaQkV2cItp6yEkrwljyaPOf22RuX7T43jxap/FOmM= +github.com/aws/smithy-go v1.27.8 h1:FR0dxZfIlV7Z8eh2iHfIofdunw382XsDV3Mxt9nUvRY= +github.com/aws/smithy-go v1.27.8/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= github.com/axiomhq/hyperloglog v0.2.6 h1:sRhvvF3RIXWQgAXaTphLp4yJiX4S0IN3MWTaAgZoRJw= github.com/axiomhq/hyperloglog v0.2.6/go.mod h1:YjX/dQqCR/7QYX0g8mu8UZAjpIenz1FKM71UEsjFoTo= github.com/baidubce/bce-sdk-go v0.9.230 h1:HzELBKiD7QAgYqZ1qHZexoI2A3Lo/6zYGQFvcUbS5cA= @@ -386,34 +386,36 @@ github.com/go-openapi/runtime v0.29.4 h1:k2lDxrGoSAJRdhFG2tONKMpkizY/4X1cciSdtzk github.com/go-openapi/runtime v0.29.4/go.mod h1:K0k/2raY6oqXJnZAgWJB2i/12QKrhUKpZcH4PfV9P18= github.com/go-openapi/spec v0.20.6 h1:ich1RQ3WDbfoeTqTAb+5EIxNmpKVJZWBNah9RAT0jIQ= github.com/go-openapi/spec v0.20.6/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= -github.com/go-openapi/strfmt v0.26.4 h1:yI6IAEfcWow459BD5UzFY430KUwXZwBHrYusPFkhWlc= -github.com/go-openapi/strfmt v0.26.4/go.mod h1:hNJi6nb5ETD6i7A1yRo03M9S6ZoTPPoWff1iUexmfUc= +github.com/go-openapi/strfmt v0.27.0 h1:kbcTeaD9TXuXD0hhMXzuYa1sdTo6+dWGvwjW93E80IM= +github.com/go-openapi/strfmt v0.27.0/go.mod h1:s/qhDqfY72irigXUGJmtgid2Rm+3tnz3k8hZaRmvWYc= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-openapi/swag v0.26.0 h1:GVDXCmfvhfu1BxiHo8/FA+BbKmhecHnG3varjON5/RI= github.com/go-openapi/swag v0.26.0/go.mod h1:82g3193sZJRbocs7bNCqGfIgq8pkuwVwCfhKIRlEQF0= github.com/go-openapi/swag/cmdutils v0.26.0 h1:iowihOcvq7y4egO8cOq0dmfohz6wfeQ63U1EnuhO2TU= github.com/go-openapi/swag/cmdutils v0.26.0/go.mod h1:Sm1MVFMkF6guJJ+pQqHnQA3N0j9qALV3NxzDSv6bETM= -github.com/go-openapi/swag/conv v0.27.0 h1:EKOH4feXrvdo8DbSsXSAqRT8fz1epEnS5O2IfXUOzE8= -github.com/go-openapi/swag/conv v0.27.0/go.mod h1:pfiv0uKQTbaGApk8Zs/lZV3uSjmSpa2FO1y183YngN8= +github.com/go-openapi/swag/conv v0.28.0 h1:GtqqbyFe7vR5Y7ehxG9W6/OvrSFdf1OLeTGp40TqxH8= +github.com/go-openapi/swag/conv v0.28.0/go.mod h1:mbUE+mzctnhxi864m0Q07SpN8OowD9JhxmxuYvZZD/k= github.com/go-openapi/swag/fileutils v0.26.0 h1:WJoPRvsA7QRiiWluowkLJa9jaYR7FCuxmDvnCgaRRxU= github.com/go-openapi/swag/fileutils v0.26.0/go.mod h1:0WDJ7lp67eNjPMO50wAWYlKvhOb6CQ37rzR7wrgI8Tc= github.com/go-openapi/swag/jsonname v0.26.0 h1:gV1NFX9M8avo0YSpmWogqfQISigCmpaiNci8cGECU5w= github.com/go-openapi/swag/jsonname v0.26.0/go.mod h1:urBBR8bZNoDYGr653ynhIx+gTeIz0ARZxHkAPktJK2M= -github.com/go-openapi/swag/jsonutils v0.27.0 h1:VYtd9jEQYeU4j8q5vdn5KWotF4vKywhGdMBrALtAsfE= -github.com/go-openapi/swag/jsonutils v0.27.0/go.mod h1:U7pb8AGuwhok3RDicHeHwSG4L3PXSq6PAL98Aon632g= -github.com/go-openapi/swag/jsonutils/fixtures_test v0.27.0 h1:+d7C7Ur/SsGg/UZ9G0JEovnfRqtMNZCJQGKc2h/ojoE= -github.com/go-openapi/swag/jsonutils/fixtures_test v0.27.0/go.mod h1:mofwUWx70wvskwESqRJ//k/9kURmCgyJl5m5Ppoh5kY= +github.com/go-openapi/swag/jsonutils v0.28.0 h1:YIch6FwO7RXzeAnbO8Tu7dWBZeUEH+4nA0HXltVTnv4= +github.com/go-openapi/swag/jsonutils v0.28.0/go.mod h1:CYM3WlTUcagR2ZoHdz54di/cbBqt82tuxuXgAjxw+mg= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.28.0 h1:qV+VVUAx5Oro8WjVWpZeql7YReTKhT4smR4zhcOQZr0= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.28.0/go.mod h1:mofwUWx70wvskwESqRJ//k/9kURmCgyJl5m5Ppoh5kY= github.com/go-openapi/swag/loading v0.26.0 h1:Apg6zaKhCJurpJer0DCxq99qwmhFddBhaMX7kilDcko= github.com/go-openapi/swag/loading v0.26.0/go.mod h1:dBxQ/6V2uBaAQdevN18VELE6xSpJWZxLX4txe12JwDg= github.com/go-openapi/swag/mangling v0.26.0 h1:Du2YC4YLA/Y5m/YKQd7AnY5qq0wRKSFZTTt8ktFaXcQ= github.com/go-openapi/swag/mangling v0.26.0/go.mod h1:jifS7W9vbg+pw63bT+GI53otluMQL3CeemuyCHKwVx0= github.com/go-openapi/swag/netutils v0.26.0 h1:CmZp+ZT7HrmFwrC3GdGsXBq2+42T1bjKBapcqVpIs3c= github.com/go-openapi/swag/netutils v0.26.0/go.mod h1:5iK+Ok3ZohWWex1C50BFTPexi03UaPwjW4Oj8kgrpwo= +github.com/go-openapi/swag/pools v0.28.0 h1:HPMZWSAfce3rdVTFcjFiCIBtDg9h4x2QlRrHipwhxeU= +github.com/go-openapi/swag/pools v0.28.0/go.mod h1:kVQefhSK5RWuRe7BXsL8htgBPAMpN7HDGpGEknqugeE= github.com/go-openapi/swag/stringutils v0.26.0 h1:qZQngLxs5s7SLijc3N2ZO+fUq2o8LjuWAASSrJuh+xg= github.com/go-openapi/swag/stringutils v0.26.0/go.mod h1:sWn5uY+QIIspwPhvgnqJsH8xqFT2ZbYcvbcFanRyhFE= -github.com/go-openapi/swag/typeutils v0.27.0 h1:aCf4MSGo8NLwZP8Q6t32DWLJSvl/WwNqgmEG+xJ6v2o= -github.com/go-openapi/swag/typeutils v0.27.0/go.mod h1:Srm0xFNRZ1Y+vCxJclo5qzx8aj+1pAKda/YfFPrG0dQ= +github.com/go-openapi/swag/typeutils v0.28.0 h1:nRBKSBXjDgf01VDPB3fWeD9nQuhCOVeIYAkUx2tbkyY= +github.com/go-openapi/swag/typeutils v0.28.0/go.mod h1:Srm0xFNRZ1Y+vCxJclo5qzx8aj+1pAKda/YfFPrG0dQ= github.com/go-openapi/swag/yamlutils v0.26.0 h1:H7O8l/8NJJQ/oiReEN+oMpnGMyt8G0hl460nRZxhLMQ= github.com/go-openapi/swag/yamlutils v0.26.0/go.mod h1:1evKEGAtP37Pkwcc7EWMF0hedX0/x3Rkvei2wtG/TbU= github.com/go-openapi/testify/enable/yaml/v2 v2.6.0 h1:gGHwAJ0R/5jU8BEGDbfRNR3hL68dAVi84WuOApp29B0= @@ -587,8 +589,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFb github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 h1:5VipnvEpbqr2gA2VbM+nYVbkIF28c5ZQfqCBQ5g2xfk= github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0/go.mod h1:Hyl3n6Twe1hvtd9XUXDec4pTvgMSEixRuQKPTMH2bNs= github.com/hashicorp/consul/api v1.12.0/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0= -github.com/hashicorp/consul/api v1.34.3 h1:OiZaQnwkS6uvutie3CF6NFXj8uScNezDlsU9MEqKT0s= -github.com/hashicorp/consul/api v1.34.3/go.mod h1:A4wKd7yw7Wz4zn07p74+o0bLBi5dXsSDMMcMCEinY40= +github.com/hashicorp/consul/api v1.34.4 h1:0U4YZ1Yp7K9WK9ex0gTJraFim26l02wCvsmf2ukalVE= +github.com/hashicorp/consul/api v1.34.4/go.mod h1:vz5gBNeycefpAAVNVbLBFObUu3isju6EK8UVZjXSTWc= github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= github.com/hashicorp/consul/sdk v0.18.1 h1:RDTeBvAeOveI2xI86sV+8WkaN7OkP4zz+cG3fOobDCM= github.com/hashicorp/consul/sdk v0.18.1/go.mod h1:XdP2tEJmAvlK4jgoKTTtohGkRJlS4mU44mv9/sjU21s= @@ -608,11 +610,13 @@ github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVH github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-metrics v0.6.0 h1:+kjWqHRH2HxAocneVfB/BI6EeWUUHyPhyQZozMT8Ed4= -github.com/hashicorp/go-metrics v0.6.0/go.mod h1:0B52B5pZ7+qm5Zhzs8Fygr87isvmUgr0Zv9rmJ9qsnQ= +github.com/hashicorp/go-metrics v0.6.1 h1:V7j9cgHTXl4OebnX3y0l6ZSoO5dTp0VI0K8Y7JfRsS4= +github.com/hashicorp/go-metrics v0.6.1/go.mod h1:XOozbQKeJz12GG8cCcQb/E5vNVeTdJt0aHbM+uHnL1M= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-msgpack v0.5.5 h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI= github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-msgpack/v2 v2.1.5 h1:Ue879bPnutj/hXfmUk6s/jtIK90XxgiUIcXRl656T44= +github.com/hashicorp/go-msgpack/v2 v2.1.5/go.mod h1:bjCsRXpZ7NsJdk45PoCQnzRGDaK8TKm5ZnDI/9y3J4M= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= @@ -635,8 +639,8 @@ github.com/hashicorp/go-version v1.9.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09 github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hashicorp/golang-lru v0.6.0 h1:uL2shRDx7RTrOrTCUZEGP/wJUFiUI8QT6E7z5o8jga4= -github.com/hashicorp/golang-lru v0.6.0/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= +github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= @@ -646,8 +650,8 @@ github.com/hashicorp/nomad/api v0.0.0-20251216171439-1dee0671280e h1:wGl06iy/H90 github.com/hashicorp/nomad/api v0.0.0-20251216171439-1dee0671280e/go.mod h1:sldFTIgs+FsUeKU3LwVjviAIuksxD8TzDOn02MYwslE= github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= github.com/hashicorp/serf v0.9.7/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= -github.com/hashicorp/serf v0.10.1 h1:Z1H2J60yRKvfDYAOZLd2MU0ND4AH/WDz7xYHDWQsIPY= -github.com/hashicorp/serf v0.10.1/go.mod h1:yL2t6BqATOLGc5HF7qbFkTfXoPIY0WZdWHfEvMqbG+4= +github.com/hashicorp/serf v0.10.4 h1:TCQOrJXHZ1Xf80c4WBhMM9OwUFgDaIP0R+YvoQUKadI= +github.com/hashicorp/serf v0.10.4/go.mod h1:l+s5Q1OSPWU6b9l9m7ODJzTp7mLevSaVzAI03Nka2F0= github.com/hetznercloud/hcloud-go/v2 v2.32.0 h1:BRe+k7ESdYv3xQLBGdKUfk+XBFRJNGKzq70nJI24ciM= github.com/hetznercloud/hcloud-go/v2 v2.32.0/go.mod h1:hAanyyfn9M0cMmZ68CXzPCF54KRb9EXd8eiE2FHKGIE= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= @@ -681,11 +685,11 @@ github.com/keybase/go-keychain v0.0.1 h1:way+bWYa6lDppZoZcgMbYsvC7GxljxrskdNInRt github.com/keybase/go-keychain v0.0.1/go.mod h1:PdEILRW3i9D8JcdM+FmY6RwkHGnhHxXwkPPMeUgOK1k= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.18.7 h1:aUyZsS4kH3QTKurYhAOwAHxllVPnOthb3vPfnF1Ehjw= -github.com/klauspost/compress v1.18.7/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ= +github.com/klauspost/compress v1.19.2 h1:hMRETovs/pu/dVWN7zIT1PGG8t509MwT6bO7XSi26R8= +github.com/klauspost/compress v1.19.2/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ= github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.11 h1:0OwqZRYI2rFrjS4kvkDnqJkKHdHaRnCm68/DY4OxRzU= -github.com/klauspost/cpuid/v2 v2.2.11/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= +github.com/klauspost/cpuid/v2 v2.4.0 h1:S6Hrbc7+ywsr0r+RLapfGBHfyefhCTwEh3A0tV913Dw= +github.com/klauspost/cpuid/v2 v2.4.0/go.mod h1:19jmZ9mjzoF//ddRSUsv0zfBTJWh3QJh9FNxZTMrGxU= github.com/klauspost/crc32 v1.3.0 h1:sSmTt3gUt81RP655XGZPElI0PelVTZ6YwCRnPSupoFM= github.com/klauspost/crc32 v1.3.0/go.mod h1:D7kQaZhnkX/Y0tstFGf8VUzv2UofNGqCjnC3zdHB0Hw= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= @@ -736,16 +740,16 @@ github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= -github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= +github.com/mattn/go-colorable v0.1.15 h1:+u9SLTRGnXv73cEsnsmoZBom+dMU88B2M0aDcWy0/jY= +github.com/mattn/go-colorable v0.1.15/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4= +github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mdlayher/socket v0.5.1 h1:VZaqt6RkGkt2OE9l3GcC6nZkqD3xKeQLyfleW/uBcos= github.com/mdlayher/socket v0.5.1/go.mod h1:TjPLHI1UgwEv5J1B5q0zTZq12A/6H7nKmtTanQE37IQ= @@ -755,14 +759,14 @@ github.com/metalmatze/signal v0.0.0-20210307161603-1c9aa721a97a h1:0usWxe5SGXKQo github.com/metalmatze/signal v0.0.0-20210307161603-1c9aa721a97a/go.mod h1:3OETvrxfELvGsU2RoGGWercfeZ4bCL3+SOwzIWtJH/Q= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= -github.com/miekg/dns v1.1.69 h1:Kb7Y/1Jo+SG+a2GtfoFUfDkG//csdRPwRLkCsxDG9Sc= -github.com/miekg/dns v1.1.69/go.mod h1:7OyjD9nEba5OkqQ/hB4fy3PIoxafSZJtducccIelz3g= +github.com/miekg/dns v1.1.72 h1:vhmr+TF2A3tuoGNkLDFK9zi36F2LS+hKTRW0Uf8kbzI= +github.com/miekg/dns v1.1.72/go.mod h1:+EuEPhdHOsfk6Wk5TT2CzssZdqkmFhf8r+aVyDEToIs= github.com/minio/crc64nvme v1.1.1 h1:8dwx/Pz49suywbO+auHCBpCtlW1OfpcLN7wYgVR6wAI= github.com/minio/crc64nvme v1.1.1/go.mod h1:eVfm2fAzLlxMdUGc0EEBGSMmPwmXD5XiNRpnu9J3bvg= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= -github.com/minio/minio-go/v7 v7.2.1 h1:PfBfwvKB/MmqyN8Vb1G9voWisaM9OrLv+WwOvMwS9Dw= -github.com/minio/minio-go/v7 v7.2.1/go.mod h1:EU9hENAStx/xXduNdrGO5e4X5vk19NtgB+RIPjZO8o0= +github.com/minio/minio-go/v7 v7.3.0 h1:HM4pFCSQq/TK+j0/zmorSh5ddh81iDgRgU0BG0Vz/YU= +github.com/minio/minio-go/v7 v7.3.0/go.mod h1:KUPWdecEO1LWyUz+sTGXAuf2jZHrPh5fCsRH86QbPfk= github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= @@ -811,8 +815,8 @@ github.com/oklog/run v1.2.0 h1:O8x3yXwah4A73hJdlrwo/2X6J62gE5qTMusH0dvz60E= github.com/oklog/run v1.2.0/go.mod h1:mgDbKRSwPhJfesJ4PntqFUbKQRZ50NgmZTSPlFA0YFk= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/oklog/ulid/v2 v2.1.1 h1:suPZ4ARWLOJLegGFiZZ1dFAkqzhMjL3J1TzI+5wHz8s= -github.com/oklog/ulid/v2 v2.1.1/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ= +github.com/oklog/ulid/v2 v2.1.2 h1:IEclFb9JNvzYA6MW2SCxbLzcHTVsfqm3PrqGQJH5zec= +github.com/oklog/ulid/v2 v2.1.2/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8= @@ -845,8 +849,8 @@ github.com/parquet-go/bitpack v1.0.0 h1:AUqzlKzPPXf2bCdjfj4sTeacrUwsT7NlcYDMUQxP github.com/parquet-go/bitpack v1.0.0/go.mod h1:XnVk9TH+O40eOOmvpAVZ7K2ocQFrQwysLMnc6M/8lgs= github.com/parquet-go/jsonlite v1.0.0 h1:87QNdi56wOfsE5bdgas0vRzHPxfJgzrXGml1zZdd7VU= github.com/parquet-go/jsonlite v1.0.0/go.mod h1:nDjpkpL4EOtqs6NQugUsi0Rleq9sW/OtC1NnZEnxzF0= -github.com/parquet-go/parquet-go v0.30.1 h1:Oy6ganNrAdFiVwy7wNmWagfPTWA2X9Z3tVHBc7JtuX8= -github.com/parquet-go/parquet-go v0.30.1/go.mod h1:navtkAYr2LGoJVp141oXPlO/sxLvaOe3la2JEoD8+rg= +github.com/parquet-go/parquet-go v0.32.0 h1:NWDqTUHfrCS4cJP/Fj2HlxvqsrVedWG3sayMkf+znzM= +github.com/parquet-go/parquet-go v0.32.0/go.mod h1:navtkAYr2LGoJVp141oXPlO/sxLvaOe3la2JEoD8+rg= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= @@ -885,8 +889,8 @@ github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3O github.com/prometheus/client_golang v1.5.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o= -github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg= +github.com/prometheus/client_golang v1.24.1 h1:JnJkREXzWxUdCuPFpIWZiPispT9xVV59uiuyR2bPlnU= +github.com/prometheus/client_golang v1.24.1/go.mod h1:F+oSRECHg4sse5ucfYpYDeIv/hu68Zo0uoHKetWnzcE= github.com/prometheus/client_golang/exp v0.0.0-20251212205219-7ba246a648ca h1:BOxmsLoL2ymn8lXJtorca7N/m+2vDQUDoEtPjf0iAxA= github.com/prometheus/client_golang/exp v0.0.0-20251212205219-7ba246a648ca/go.mod h1:gndBHh3ZdjBozGcGrjUYjN3UJLRS3l2drALtu4lUt+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= @@ -899,8 +903,8 @@ github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.69.0 h1:OA85nJQS/T/MaYh/Q2CcgDKSGWqNIgrBDvDH85CuiNk= -github.com/prometheus/common v0.69.0/go.mod h1:ZzL3f6u94qUxh9p+tJTrF+FvBS1XXbbRAZCQkytAL0Y= +github.com/prometheus/common v0.70.1 h1:1HvjP4D5oL3t8RsPlwxA9onvvStjtIHYE5XuuwOi/PY= +github.com/prometheus/common v0.70.1/go.mod h1:VdFUQDMZK3VLkurFUVhia6uys/0suUp86TJz5qbJRhc= github.com/prometheus/exporter-toolkit v0.16.0 h1:xT/j7L2XKF+VJd6B4fpUw6xWabHrSmsUf6mYmFqyu0s= github.com/prometheus/exporter-toolkit v0.16.0/go.mod h1:d1EL8Z9674xQe/iWhwP2wDyCEoBPbXVeqDbqAUsgJWY= github.com/prometheus/otlptranslator v1.0.0 h1:s0LJW/iN9dkIH+EnhiD3BlkkP5QVIUVEoIwkU+A6qos= @@ -910,8 +914,8 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.21.0 h1:Qh/e6TlBjZf+XLLqNCqFGmCU6Kj/2Bu7kj3oAc0UnXc= -github.com/prometheus/procfs v0.21.0/go.mod h1:aB55Cww9pdSJVHk0hUf0inxWyyjPogFIjmHKYgMKmtY= +github.com/prometheus/procfs v0.21.1 h1:GljZCt+zSTS+NZq88cyQ1LjZ+RCHp3uVuabBWA5+OJI= +github.com/prometheus/procfs v0.21.1/go.mod h1:aB55Cww9pdSJVHk0hUf0inxWyyjPogFIjmHKYgMKmtY= github.com/prometheus/prometheus v0.309.1 h1:jutK6eCYDpWdPTUbVbkcQsNCMO9CCkSwjQRMLds4jSo= github.com/prometheus/prometheus v0.309.1/go.mod h1:d+dOGiVhuNDa4MaFXHVdnUBy/CzqlcNTooR8oM1wdTU= github.com/prometheus/sigv4 v0.4.1 h1:EIc3j+8NBea9u1iV6O5ZAN8uvPq2xOIUPcqCTivHuXs= @@ -971,8 +975,9 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4= +github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -986,8 +991,9 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= +github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg= github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.563/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.563/go.mod h1:uom4Nvi9W+Qkom0exYiJ9VWJjXwyxtPYTkKkaLMlfE0= @@ -1001,10 +1007,10 @@ github.com/thanos-io/promql-engine v0.0.0-20260729073658-f8bd3f940687 h1:r9VYttK github.com/thanos-io/promql-engine v0.0.0-20260729073658-f8bd3f940687/go.mod h1:uzn40oZHPXvfdP498h+MiRL2fN7RF519gNaV3LyhChc= github.com/thanos-io/thanos v0.42.1-0.20260727122508-92397939e4cc h1:Sx5AfjHy6OspiLdJTFUO8DsfndpMNM8mbkMBMXtVFqc= github.com/thanos-io/thanos v0.42.1-0.20260727122508-92397939e4cc/go.mod h1:GH7XiOiHgMLvIST9qgcy/UuhtV22umoBCXAceOFMzCA= -github.com/tinylib/msgp v1.6.1 h1:ESRv8eL3u+DNHUoSAAQRE50Hm162zqAnBoGv9PzScPY= -github.com/tinylib/msgp v1.6.1/go.mod h1:RSp0LW9oSxFut3KzESt5Voq4GVWyS+PSulT77roAqEA= -github.com/tjhop/slog-gokit v0.2.0 h1:tUNkuukDjpswQ2abhsugEobRRxN1aHEW8h4rvwdHMqU= -github.com/tjhop/slog-gokit v0.2.0/go.mod h1:yA48zAHvV+Sg4z4VRyeFyFUNNXd3JY5Zg84u3USICq0= +github.com/tinylib/msgp v1.6.4 h1:mOwYbyYDLPj35mkA2BjjYejgJk9BuHxDdvRnb6v2ZcQ= +github.com/tinylib/msgp v1.6.4/go.mod h1:RSp0LW9oSxFut3KzESt5Voq4GVWyS+PSulT77roAqEA= +github.com/tjhop/slog-gokit v0.2.2 h1:ev90r/tMq5cx7q6lMuhJ6v7fjsr1bDho7W2BLAFVwtI= +github.com/tjhop/slog-gokit v0.2.2/go.mod h1:yA48zAHvV+Sg4z4VRyeFyFUNNXd3JY5Zg84u3USICq0= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/twmb/franz-go v1.21.2 h1:WrvV/spF48JzcRylqDQy02Vm6V6W4lhtD9Y4BOYNMu4= github.com/twmb/franz-go v1.21.2/go.mod h1:rfoMTnVk7107fhTGxfEKIHP/e7tPe6oyij/ywzO0czk= @@ -1081,12 +1087,12 @@ go.opentelemetry.io/collector/consumer/consumertest v0.142.0 h1:TRt8zR57Vk1PTjtq go.opentelemetry.io/collector/consumer/consumertest v0.142.0/go.mod h1:yq2dhMxFUlCFkRN7LES3fzsTmUDw9VaunyRAka2TEaY= go.opentelemetry.io/collector/consumer/xconsumer v0.142.0 h1:qOoQnLZXQ9sRLexTkkmBx3qfaOmEgco9VBPmryg5UhA= go.opentelemetry.io/collector/consumer/xconsumer v0.142.0/go.mod h1:oPN0yJzEpovwlWvmSaiYgtDqGuOmMMLmmg352sqZdsE= -go.opentelemetry.io/collector/featuregate v1.61.0 h1:XtnQ/XPHLmw9zgg4Cjq/f0rgdqn7z1M10wnmGhgNbYk= -go.opentelemetry.io/collector/featuregate v1.61.0/go.mod h1:4ga1QBMPEejXXmpyJS8lmaRpknJ3Lb9Bvk6e420bUFU= -go.opentelemetry.io/collector/internal/testutil v0.155.0 h1:ExZ3lqM1e1Y83AAXKr6Xsw20v4LHW6GZ8VeLLQHiOrA= -go.opentelemetry.io/collector/internal/testutil v0.155.0/go.mod h1:Jkjs6rkqs973LqgZ0Fe3zrokQRKULYXPIf4HuqStiEE= -go.opentelemetry.io/collector/pdata v1.61.0 h1:EVfGB/9dcyMXhMsZ5kzKeGFJj8QWqvmZjgg4RMjnRhE= -go.opentelemetry.io/collector/pdata v1.61.0/go.mod h1:qYEsyeIJ9tWHb2jSR5HQ9/VmbCGVca+G+ZDAB8dFCMc= +go.opentelemetry.io/collector/featuregate v1.65.0 h1:Dh+uYVB+POc5DTebZRWjtKJolGhevkiIpbHn+zhkq2o= +go.opentelemetry.io/collector/featuregate v1.65.0/go.mod h1:4ga1QBMPEejXXmpyJS8lmaRpknJ3Lb9Bvk6e420bUFU= +go.opentelemetry.io/collector/internal/testutil v0.159.0 h1:/OfAv3ZRIc3eVFFq4bFc+Ju5HQBebiWywgvAcysIX4M= +go.opentelemetry.io/collector/internal/testutil v0.159.0/go.mod h1:Jkjs6rkqs973LqgZ0Fe3zrokQRKULYXPIf4HuqStiEE= +go.opentelemetry.io/collector/pdata v1.65.0 h1:6bQ3sIrEzOdapetxYFjdCns90kKXg1qCoIZ3la1aR5E= +go.opentelemetry.io/collector/pdata v1.65.0/go.mod h1:r5vRY0p7nZcEif06twUW09Sf6vaNsyPzij+EpwI/xeI= go.opentelemetry.io/collector/pdata/pprofile v0.142.0 h1:Ivyw7WY8SIIWqzXsnNmjEgz3ysVs/OkIf0KIpJUnuuo= go.opentelemetry.io/collector/pdata/pprofile v0.142.0/go.mod h1:94GAph54K4WDpYz9xirhroHB3ptNLuPiY02k8fyoNUI= go.opentelemetry.io/collector/pdata/testdata v0.142.0 h1:+jf9RyLWl8WyhIVjpg7yuH+bRdQH4mW20cPtCMlY1cI= @@ -1111,8 +1117,8 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.68.0 h1:CqXxU8V go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.68.0/go.mod h1:BuhAPThV8PBHBvg8ZzZ/Ok3idOdhWIodywz2xEcRbJo= go.opentelemetry.io/contrib/propagators/autoprop v0.61.0 h1:cxOVDJ30qfzV27G5p9WMtJUB/3cXC0iL+u9EV1fSOws= go.opentelemetry.io/contrib/propagators/autoprop v0.61.0/go.mod h1:Y+xiUbWetg65vAroDZcIzJ5wyPNWRH32EoIV9rIaa0g= -go.opentelemetry.io/contrib/propagators/aws v1.44.0 h1:Rtvfd6nTbAF2csjiw41m1DfuqC5TneXs+gB84ZA3gq4= -go.opentelemetry.io/contrib/propagators/aws v1.44.0/go.mod h1:auu0tIyZErQGLLUvOp9DgmhKALIoebR4Fpkt9CT0c0k= +go.opentelemetry.io/contrib/propagators/aws v1.45.0 h1:XIsTznOtglVtajrcqKOfKJzMJtC6GsNYw7kWsnPPB8g= +go.opentelemetry.io/contrib/propagators/aws v1.45.0/go.mod h1:VL8mj7NKnMqLp0jn45wtWgKkcTacucgvBIJoOg2rZHw= go.opentelemetry.io/contrib/propagators/b3 v1.36.0 h1:xrAb/G80z/l5JL6XlmUMSD1i6W8vXkWrLfmkD3w/zZo= go.opentelemetry.io/contrib/propagators/b3 v1.36.0/go.mod h1:UREJtqioFu5awNaCR8aEx7MfJROFlAWb6lPaJFbHaG0= go.opentelemetry.io/contrib/propagators/jaeger v1.36.0 h1:SoCgXYF4ISDtNyfLUzsGDaaudZVTx2yJhOyBO0+/GYk= @@ -1123,33 +1129,33 @@ go.opentelemetry.io/otel v1.45.0 h1:pdrWmLHofpubmArBv1LgFSv1Z0Ie/ppdZzu+kUN5EeU= go.opentelemetry.io/otel v1.45.0/go.mod h1:XZxIqPapzEYnhNSScF5DIqXhm/rYi0FzCe2XddAwZfQ= go.opentelemetry.io/otel/bridge/opentracing v1.45.0 h1:hFf959SYHZpFc8ZWlqiYlnH3Ke5w4fcWZh7He+CmqXk= go.opentelemetry.io/otel/bridge/opentracing v1.45.0/go.mod h1:etOoQoentzhTX0XTaRJmwlsiQx8TXD7mHo76YxNeBYg= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.44.0 h1:4YsVu3B8+3qtWYYrsUYgn0OG78pN0rnNPRGX4SbokQI= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.44.0/go.mod h1:+wnlSn0mD1ADVMe3v9Z/WIaiz6q6gL2J/ejaAmdmv80= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.44.0 h1:qazEJlUOQzhCpzQpFETGby7EdqjI1wsd0W+6Gg1SCTU= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.44.0/go.mod h1:fOD2Yefuxixkx3ahVNf0O/PERb6r4OlbxfATVnYvzCo= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.45.0 h1:QRefszxJmfPdjXUUm3j6iDzY03mTPXMjqErFqQ67vUg= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.45.0/go.mod h1:Tiz03lTBVBrm7eWZBOidzEaYaJa8tjwGUGv6d8mlTyk= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.45.0 h1:fG5MCxGz8+2VtrN/WgqSpJFctVz24gpxj8CxkKmc8Ww= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.45.0/go.mod h1:BmAYTn+3ysbRe+IU2msxmf5Rx3g6DHvex+tWI3LdhYI= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0 h1:3iZJKlCZufyRzPzlQhUIWVmfltrXuGyfjREgGP3UUjc= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0/go.mod h1:/G+nUPfhq2e+qiXMGxMwumDrP5jtzU+mWN7/sjT2rak= go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.36.0 h1:rixTyDGXFxRy1xzhKrotaHy3/KXdPhlWARrCgK+eqUY= go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.36.0/go.mod h1:dowW6UsM9MKbJq5JTz2AMVp3/5iW5I/TStsk8S+CfHw= go.opentelemetry.io/otel/metric v1.45.0 h1:7Eg1uH7CJ5cXv9is6tnBe1FI6rj1nwUdbFypRm3br/M= go.opentelemetry.io/otel/metric v1.45.0/go.mod h1:HAPbm1nd3p1PmFH7v2dR+6BjXxw+Lq4a2+pndMAm08s= -go.opentelemetry.io/otel/metric/x v0.66.0 h1:YkCrx1zLOChi9ZcZ6euupOcsgzbVlec7D/xoEU1+cTA= -go.opentelemetry.io/otel/metric/x v0.66.0/go.mod h1:d1+BDj9t96do0/1LoU1ayfCv79ZgNE41qbhBvnMOBZk= -go.opentelemetry.io/otel/sdk v1.44.0 h1:nHYwb9lK+fJPU/dnT6s7W7Z8itMWyqrnVfbheVYrZ58= -go.opentelemetry.io/otel/sdk v1.44.0/go.mod h1:Osuydd3Se74nqjAKxid74N5eC+jfEqfTegHRnq58oK0= -go.opentelemetry.io/otel/sdk/metric v1.44.0 h1:3LlKgI+VjbVsjNRFZJZAJ30WjXC5VkNRks6si09iEfI= -go.opentelemetry.io/otel/sdk/metric v1.44.0/go.mod h1:5B5pMARnXxKhltooO4xUuCBorl65a4EpnTalObqOigA= +go.opentelemetry.io/otel/metric/x v0.67.0 h1:PcicCNZFkZ4bXfSooXdo3WN7RBOVOtjVdo1wD358Uns= +go.opentelemetry.io/otel/metric/x v0.67.0/go.mod h1:FBjCWZe6wgcqxcMtjdGiClDKXb2YxxXii0CXftE4QtI= +go.opentelemetry.io/otel/sdk v1.45.0 h1:4VVSMgQ83dUgW2aoX5f6JgLvHwIvzcuLnF9lUdCSpCw= +go.opentelemetry.io/otel/sdk v1.45.0/go.mod h1:Sr40LgXV7DsKMMJMKOhUWOgMWTfAaqvm2kF0g7ilwuA= +go.opentelemetry.io/otel/sdk/metric v1.45.0 h1:oVFszMfyj1Am6s24Vtc7wBb8BKLcwepJjNEYILuiE3o= +go.opentelemetry.io/otel/sdk/metric v1.45.0/go.mod h1:vUWUxDZvu1WVRj8JA8S0AdhsPrZoDpA2DdZauIh4mDA= go.opentelemetry.io/otel/trace v1.45.0 h1:l/mP6Uv7oNO7/TblbhpbgMidxhq1uO/rPsikOyVhxag= go.opentelemetry.io/otel/trace v1.45.0/go.mod h1:qoJJA2xNMnxRrdISU/kLtfUH2wNeQbiv+jhs/CxI8bc= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.opentelemetry.io/proto/otlp v1.10.0 h1:IQRWgT5srOCYfiWnpqUYz9CVmbO8bFmKcwYxpuCSL2g= -go.opentelemetry.io/proto/otlp v1.10.0/go.mod h1:/CV4QoCR/S9yaPj8utp3lvQPoqMtxXdzn7ozvvozVqk= -go.opentelemetry.io/proto/slim/otlp v1.10.0 h1:iR97Vs/ZDR+y9TfuP9b1XBtdPWeC+OMslIBmhcLU7jM= -go.opentelemetry.io/proto/slim/otlp v1.10.0/go.mod h1:lV9250stpjYLPNA5viFabIgP2QlUGRT1GdTgAf8SIUk= -go.opentelemetry.io/proto/slim/otlp/collector/profiles/v1development v0.3.0 h1:RUF5rO0hAlgiJt1fzQVzcVs3vZVNHIcMLgOgG4rWNcQ= -go.opentelemetry.io/proto/slim/otlp/collector/profiles/v1development v0.3.0/go.mod h1:I89cynRj8y+383o7tEQVg2SVA6SRgDVIouWPUVXjx0U= -go.opentelemetry.io/proto/slim/otlp/profiles/v1development v0.3.0 h1:CQvJSldHRUN6Z8jsUeYv8J0lXRvygALXIzsmAeCcZE0= -go.opentelemetry.io/proto/slim/otlp/profiles/v1development v0.3.0/go.mod h1:xSQ+mEfJe/GjK1LXEyVOoSI1N9JV9ZI923X5kup43W4= +go.opentelemetry.io/proto/otlp v1.11.0 h1:5rrYs0Ykyj50sdU/JU0x8etU+LubXWb+gED6TbEdMIk= +go.opentelemetry.io/proto/otlp v1.11.0/go.mod h1:SmVizdCOAm3XBtG1g1NnOdhW6jtddT72hLMhv8VwA8E= +go.opentelemetry.io/proto/slim/otlp v1.11.0 h1:zB37f+f99+y6UIZR4h7UpwbXd5kFNyip35U7GaJ/Jik= +go.opentelemetry.io/proto/slim/otlp v1.11.0/go.mod h1:mI3DeND+VXZuA4keqFPKDJ3BklwveYm1JqBcEWKDEOM= +go.opentelemetry.io/proto/slim/otlp/collector/profiles/v1development v0.4.0 h1:mt+DWtks0biKnz0jXMpDbxWN0CHJi6OJDKe4GcREkcs= +go.opentelemetry.io/proto/slim/otlp/collector/profiles/v1development v0.4.0/go.mod h1:7UXaX/7uT+kumUHd3LIWyjMlklEp0mPlrE9xmtbG6/8= +go.opentelemetry.io/proto/slim/otlp/profiles/v1development v0.4.0 h1:rLHkdB6eHDiRSIoz0cvNuTJsVJBxaL6IyS1e9BSaXLY= +go.opentelemetry.io/proto/slim/otlp/profiles/v1development v0.4.0/go.mod h1:BrX0dmOGsMuWNXXbFafTD7Gb6F3yK+2czVQ6+c24Cnk= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= @@ -1167,8 +1173,8 @@ go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc= go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ= go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ= -go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= -go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= +go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= +go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -1182,8 +1188,8 @@ golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= -golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw= -golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk= +golang.org/x/crypto v0.55.0 h1:+KWHjbgOaAQ66dh/YlkZKHlz9ZUlq61AFirAR9ntP8M= +golang.org/x/crypto v0.55.0/go.mod h1:uq0V9dE/fzQuJtbnL+2EhWOE63vo164FY8xqEnV9xis= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1223,8 +1229,8 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ= -golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0= +golang.org/x/mod v0.38.0 h1:MECBjubtXD7yj4HrhIUcywNaGeNVUdfVnxmPajOk4yk= +golang.org/x/mod v0.38.0/go.mod h1:V6Xz0pq8TQ3dGqVQ1FVHuelZpAL0uNhSkk9ogYP3c40= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1277,8 +1283,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= -golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE= -golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU= +golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To= +golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1427,8 +1433,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs= -golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY= +golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8= +golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1492,8 +1498,8 @@ golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.47.0 h1:7Kn5x/d1svx/PzryTsqeoZN4TZwqeH5pGWjefhLi/1Q= -golang.org/x/tools v0.47.0/go.mod h1:dFHnyTvFWY212G+h7ZY4Vsp/K3U4/7W9TyVaAul8uCA= +golang.org/x/tools v0.48.0 h1:3+hClM1aLL5mjMKm5ovokw9epgRXPuu2tILgismM6RE= +golang.org/x/tools v0.48.0/go.mod h1:08xX0orndb/F7jJxGDicx061tyd5pcMto75YMAXr6lk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1632,8 +1638,8 @@ google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/genproto v0.0.0-20260128011058-8636f8732409 h1:VQZ/yAbAtjkHgH80teYd2em3xtIkkHd7ZhqfH2N9CsM= google.golang.org/genproto v0.0.0-20260128011058-8636f8732409/go.mod h1:rxKD3IEILWEu3P44seeNOAwZN4SaoKaQ/2eTg4mM6EM= -google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa h1:Kjn0N0tCrDgiAFW+lGO4JZ3ck44CehvJQMAwj9QF0G8= -google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa/go.mod h1:q4lMZS6kskjT5HvCPrnnypcDPVJqT/f4nfxmkE7gryY= +google.golang.org/genproto/googleapis/api v0.0.0-20260803160001-6ac0973c030d h1:FarXi840EJWSHYTN3ERkADbPWjl307+FGrA22KAVjjc= +google.golang.org/genproto/googleapis/api v0.0.0-20260803160001-6ac0973c030d/go.mod h1:K/+WGbmBY7aNW1HDw1fJnKYo10i0DkAX6pows00dLig= google.golang.org/genproto/googleapis/rpc v0.0.0-20260803160001-6ac0973c030d h1:IL4hdHzcUv2l/gcg98/Rj3FbtE6axwqslOW8SW0C+S0= google.golang.org/genproto/googleapis/rpc v0.0.0-20260803160001-6ac0973c030d/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= @@ -1684,8 +1690,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= -google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= +google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -1698,8 +1704,8 @@ gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWM gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.67.2 h1:JtOSMb9OuaCZKr7h5D/h6iii14sK0hLbplTc6frx4Ss= -gopkg.in/ini.v1 v1.67.2/go.mod h1:x/cyOwCgZqOkJoDIJ3c1KNHMo10+nLGAhh+kn3Zizss= +gopkg.in/ini.v1 v1.67.3 h1:iM9Lhz5MRSGhHVGGwCuzG9KO8PoirCXj/m/qTmOJJQw= +gopkg.in/ini.v1 v1.67.3/go.mod h1:x/cyOwCgZqOkJoDIJ3c1KNHMo10+nLGAhh+kn3Zizss= gopkg.in/telebot.v3 v3.3.8 h1:uVDGjak9l824FN9YARWUHMsiNZnlohAVwUycw21k6t8= gopkg.in/telebot.v3 v3.3.8/go.mod h1:1mlbqcLTVSfK9dx7fdp+Nb5HZsy4LLPtpZTKmwhwtzM= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= diff --git a/vendor/github.com/aws/aws-sdk-go-v2/aws/config.go b/vendor/github.com/aws/aws-sdk-go-v2/aws/config.go index 372b1512487..0183a1222ac 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/aws/config.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/aws/config.go @@ -164,6 +164,14 @@ type Config struct { // the shared config profile attribute request_min_compression_size_bytes RequestMinCompressSizeBytes int64 + // DisableClockSkewCorrection turns off SDK clock skew correction. When set + // the SDK will not adjust request signing timestamps to compensate for + // drift between the client and service clocks. Set to false (enabled) by + // default. This variable is sourced from the environment variable + // AWS_DISABLE_CLOCK_SKEW_CORRECTION or the shared config profile attribute + // disable_clock_skew_correction. + DisableClockSkewCorrection bool + // Controls how a resolved AWS account ID is handled for endpoint routing. AccountIDEndpointMode AccountIDEndpointMode diff --git a/vendor/github.com/aws/aws-sdk-go-v2/aws/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/aws/go_module_metadata.go index 46cb77c209d..dfcdf5f8f53 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/aws/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/aws/go_module_metadata.go @@ -3,4 +3,4 @@ package aws // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.42.0" +const goModuleVersion = "1.43.6" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/metadata.go index d66f0960aa5..ba2082411fb 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/metadata.go @@ -15,6 +15,8 @@ type RegisterServiceMetadata struct { SigningName string Region string OperationName string + + RequiresLegacyEndpoints bool } // ID returns the middleware identifier. @@ -33,10 +35,13 @@ func (s RegisterServiceMetadata) HandleInitialize( ctx = SetSigningName(ctx, s.SigningName) } if len(s.Region) > 0 { - ctx = setRegion(ctx, s.Region) + ctx = SetRegion(ctx, s.Region) } if len(s.OperationName) > 0 { - ctx = setOperationName(ctx, s.OperationName) + ctx = SetOperationName(ctx, s.OperationName) + } + if s.RequiresLegacyEndpoints { + ctx = SetRequiresLegacyEndpoints(ctx, true) } return next.HandleInitialize(ctx, in) } @@ -161,19 +166,19 @@ func SetServiceID(ctx context.Context, value string) context.Context { return middleware.WithStackValue(ctx, serviceIDKey{}, value) } -// setRegion sets the endpoint region on the context. +// SetRegion sets the endpoint region on the context. // // Scoped to stack values. Use github.com/aws/smithy-go/middleware#ClearStackValues // to clear all stack values. -func setRegion(ctx context.Context, value string) context.Context { +func SetRegion(ctx context.Context, value string) context.Context { return middleware.WithStackValue(ctx, regionKey{}, value) } -// setOperationName sets the service operation on the context. +// SetOperationName sets the service operation on the context. // // Scoped to stack values. Use github.com/aws/smithy-go/middleware#ClearStackValues // to clear all stack values. -func setOperationName(ctx context.Context, value string) context.Context { +func SetOperationName(ctx context.Context, value string) context.Context { return middleware.WithStackValue(ctx, operationNameKey{}, value) } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/middleware.go b/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/middleware.go index 6d5f0079c2f..3c4f2caecb7 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/middleware.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/middleware.go @@ -43,7 +43,12 @@ func (r ClientRequestID) HandleBuild(ctx context.Context, in middleware.BuildInp } // RecordResponseTiming records the response timing for the SDK client requests. -type RecordResponseTiming struct{} +type RecordResponseTiming struct { + // DisableClockSkewCorrection suppresses recording of clock skew observed + // from the response, per the Clock Skew Correction SEP. Response timing is + // still recorded. + DisableClockSkewCorrection bool +} // ID is the middleware identifier func (a *RecordResponseTiming) ID() string { @@ -54,14 +59,17 @@ func (a *RecordResponseTiming) ID() string { func (a RecordResponseTiming) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( out middleware.DeserializeOutput, metadata middleware.Metadata, err error, ) { + requestAt := sdk.NowTime() out, metadata, err = next.HandleDeserialize(ctx, in) responseAt := sdk.NowTime() setResponseAt(&metadata, responseAt) var serverTime time.Time + var hasAgeHeader bool switch resp := out.RawResponse.(type) { case *smithyhttp.Response: + hasAgeHeader = len(resp.Header.Get("Age")) > 0 respDateHeader := resp.Header.Get("Date") if len(respDateHeader) == 0 { break @@ -77,14 +85,45 @@ func (a RecordResponseTiming) HandleDeserialize(ctx context.Context, in middlewa setServerTime(&metadata, serverTime) } - if !serverTime.IsZero() { - attemptSkew := serverTime.Sub(responseAt) - setAttemptSkew(&metadata, attemptSkew) + if !a.DisableClockSkewCorrection { + if skew, ok := computeClockSkew(serverTime, requestAt, responseAt, hasAgeHeader); ok { + setAttemptSkew(&metadata, skew) + } } return out, metadata, err } +// maxTrustedRequestDuration bounds how long a request may take before the SDK +// discards the skew measurement derived from its response. A slower round trip +// could only produce a signing failure if it pushed the timestamp outside the +// SigV4 validity window. See the Clock Skew Correction SEP. +const maxTrustedRequestDuration = 15 * time.Minute + +// computeClockSkew derives a clock skew candidate from a response per the Clock +// Skew Correction SEP. It returns ok=false (no candidate) when the Date header +// was absent/unparseable (serverTime zero), the round trip exceeded the maximum +// trusted request duration, or the response was served from a cache (Age +// header present). Otherwise the skew is the difference between the server's +// Date and the midpoint of the request round trip. +func computeClockSkew(serverTime, requestAt, responseAt time.Time, hasAgeHeader bool) (time.Duration, bool) { + if serverTime.IsZero() { + return 0, false + } + + if hasAgeHeader { + return 0, false + } + + elapsed := responseAt.Sub(requestAt) + if elapsed > maxTrustedRequestDuration { + return 0, false + } + + midpoint := requestAt.Add(elapsed / 2) + return serverTime.Sub(midpoint), true +} + type responseAtKey struct{} // GetResponseAt returns the time response was received at. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/aws/retry/middleware.go b/vendor/github.com/aws/aws-sdk-go-v2/aws/retry/middleware.go index ab024de047b..126dcf47bd7 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/aws/retry/middleware.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/aws/retry/middleware.go @@ -48,6 +48,12 @@ type Attempt struct { // call. ClientSkew *atomic.Int64 + // DisableClockSkewCorrection disables clock skew correction per the Clock + // Skew Correction SEP: observed skew is not applied to the signing + // timestamp, not recorded into ClientSkew, and clock skew error codes are + // not treated as retry candidates. + DisableClockSkewCorrection bool + retryer aws.RetryerV2 requestCloner RequestCloner } @@ -88,7 +94,7 @@ func (r *Attempt) HandleFinalize(ctx context.Context, in smithymiddle.FinalizeIn out smithymiddle.FinalizeOutput, metadata smithymiddle.Metadata, err error, ) { var attemptClockSkew time.Duration - if r.ClientSkew != nil { + if !r.DisableClockSkewCorrection && r.ClientSkew != nil { attemptClockSkew = time.Duration(r.ClientSkew.Load()) } @@ -159,7 +165,7 @@ func (r *Attempt) HandleFinalize(ctx context.Context, in smithymiddle.FinalizeIn // this guarantees we are staying on top of the persistent skew value // (either to apply it or to heal it back if the clocks realign) - if r.ClientSkew != nil { + if !r.DisableClockSkewCorrection && r.ClientSkew != nil { if resultSkew, ok := awsmiddle.GetAttemptSkew(metadata); ok { r.ClientSkew.Store(resultSkew.Nanoseconds()) } @@ -245,7 +251,10 @@ func (r *Attempt) handleAttempt( return out, attemptResult, nopRelease, err } - err = wrapAsClockSkew(ctx, err) + if !r.DisableClockSkewCorrection { + candidateSkew, hasCandidateSkew := awsmiddle.GetAttemptSkew(metadata) + err = wrapAsClockSkew(err, candidateSkew, hasCandidateSkew, retryMetadata.AttemptClockSkew) + } //------------------------------ // Is Retryable and Should Retry @@ -316,37 +325,66 @@ func (r *Attempt) handleAttempt( return out, attemptResult, releaseRetryToken, err } -// errors that, if detected when we know there's a clock skew, -// can be retried and have a high chance of success -var possibleSkewCodes = map[string]struct{}{ +// clockSkewCodes are the error codes that may indicate a clock skew problem. +// Per the Clock Skew Correction SEP these are retryable only when the absolute +// skew observed from the response Date header exceeds the detection threshold. +// The SEP does not distinguish "definite" from "possible" skew errors: modern +// services overload a single code (e.g. InvalidSignatureException) for both +// skewed and genuinely malformed signatures, so every code is gated on the +// observed skew. +var clockSkewCodes = map[string]struct{}{ "InvalidSignatureException": {}, "SignatureDoesNotMatch": {}, "AuthFailure": {}, + "RequestTimeTooSkewed": {}, + "AccessDeniedException": {}, } -var definiteSkewCodes = map[string]struct{}{ - "RequestExpired": {}, - "RequestInTheFuture": {}, - "RequestTimeTooSkewed": {}, -} - -// wrapAsClockSkew checks if this error could be related to a clock skew -// error and if so, wrap the error. -func wrapAsClockSkew(ctx context.Context, err error) error { +// wrapAsClockSkew classifies err as a retryable clock skew error when its code +// is a known clock skew code and the signing time diverges from the server +// time by more than the detection threshold. +// +// The signing time is now() + attemptSkew. The server time is now() + +// candidateSkew (derived from the response Date header). The signing error is: +// +// |attemptSkew - candidateSkew| > skewThreshold +// +// This single check covers both fresh skew detection (attemptSkew is zero on +// first attempt, so the error equals |candidateSkew|) and stale offset healing +// (attemptSkew is large but the server and client clocks have realigned, so +// candidateSkew is near zero). +// +// If no candidate was observed (the Date header was absent, unparseable, or +// discarded as untrusted), the error is not treated as clock skew. +func wrapAsClockSkew(err error, candidateSkew time.Duration, hasCandidateSkew bool, attemptSkew time.Duration) error { var v interface{ ErrorCode() string } if !errors.As(err, &v) { return err } - if _, ok := definiteSkewCodes[v.ErrorCode()]; ok { - return &retryableClockSkewError{Err: err} + + if _, ok := clockSkewCodes[v.ErrorCode()]; !ok { + return err } - _, isPossibleSkewCode := possibleSkewCodes[v.ErrorCode()] - if skew := internalcontext.GetAttemptSkewContext(ctx); skew > skewThreshold && isPossibleSkewCode { + + if !hasCandidateSkew { + return err + } + + if absDuration(attemptSkew-candidateSkew) > skewThreshold { return &retryableClockSkewError{Err: err} } + return err } +func absDuration(d time.Duration) time.Duration { + if d < 0 { + return -d + } + + return d +} + // MetricsHeader attaches SDK request metric header for retries to the transport type MetricsHeader struct{} diff --git a/vendor/github.com/aws/aws-sdk-go-v2/aws/transport/http/client.go b/vendor/github.com/aws/aws-sdk-go-v2/aws/transport/http/client.go index 49cc31205c5..94094ec2cdb 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/aws/transport/http/client.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/aws/transport/http/client.go @@ -2,6 +2,7 @@ package http import ( "context" + "crypto/fips140" "crypto/tls" "net" "net/http" @@ -27,6 +28,19 @@ var ( // Default to TLS 1.2 for all HTTPS requests. DefaultHTTPTransportTLSMinVersion uint16 = tls.VersionTLS12 + + // DefaultHTTPTransportTLSCurvePreferencesFIPS is the elliptic curve preference + // list applied to the default transport when the FIPS 140-3 module is active. + // + // Go's default preferences lead with X25519, which crypto/ecdh rejects under + // GODEBUG=fips140=only, failing every TLS handshake the SDK attempts. Only the + // NIST curves are FIPS-approved, so restricting to them keeps the default + // client usable in FIPS deployments. + DefaultHTTPTransportTLSCurvePreferencesFIPS = []tls.CurveID{ + tls.CurveP256, + tls.CurveP384, + tls.CurveP521, + } ) // Timeouts for net.Dialer's network connection. @@ -178,6 +192,16 @@ func defaultDialer() *net.Dialer { } } +// defaultTLSCurvePreferences returns the curve preferences for the default +// transport. Outside FIPS mode it returns nil so Go's own defaults apply, +// preserving X25519 and the post-quantum X25519MLKEM768 hybrid. +func defaultTLSCurvePreferences(fipsEnabled bool) []tls.CurveID { + if !fipsEnabled { + return nil + } + return DefaultHTTPTransportTLSCurvePreferencesFIPS +} + func defaultHTTPTransport() *http.Transport { dialer := defaultDialer() @@ -192,7 +216,8 @@ func defaultHTTPTransport() *http.Transport { ExpectContinueTimeout: DefaultHTTPTransportExpectContinueTimeout, ForceAttemptHTTP2: true, TLSClientConfig: &tls.Config{ - MinVersion: DefaultHTTPTransportTLSMinVersion, + MinVersion: DefaultHTTPTransportTLSMinVersion, + CurvePreferences: defaultTLSCurvePreferences(fips140.Enabled()), }, } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/config/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/config/CHANGELOG.md index 520b2379b9c..46fbf1107a2 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/config/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/config/CHANGELOG.md @@ -1,3 +1,52 @@ +# v1.32.37 (2026-08-14) + +* **Dependency Update**: Update to smithy-go v1.27.8. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.32.36 (2026-08-10) + +* **Dependency Update**: Update to smithy-go v1.27.7. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.32.35 (2026-08-05) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.32.34 (2026-07-31.2) + +* **Dependency Update**: Updated to the latest SDK module versions +* **Dependency Update**: Upgrade to smithy-go v1.27.6 to fix various serde issues in HTTP binding services. + +# v1.32.33 (2026-07-29) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.32.32 (2026-07-28) + +* **Dependency Update**: Update to smithy-go v1.27.5. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.32.31 (2026-07-21) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.32.30 (2026-07-13) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.32.29 (2026-07-08.2) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.32.28 (2026-07-06) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.32.27 (2026-07-01) + +* **Bug Fix**: Bump smithy-go to 1.27.3, fix JSON encorder for document.Number, endpoint host label format validation and CBOR union serialization on new serde +* **Dependency Update**: Updated to the latest SDK module versions + # v1.32.26 (2026-06-29) * **Dependency Update**: Updated to the latest SDK module versions diff --git a/vendor/github.com/aws/aws-sdk-go-v2/config/config.go b/vendor/github.com/aws/aws-sdk-go-v2/config/config.go index c6a6365a39a..f056bf416ec 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/config/config.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/config/config.go @@ -77,6 +77,8 @@ var defaultAWSConfigResolvers = []awsConfigResolver{ // Sets the DisableRequestCompression if present in env var or shared config profile resolveDisableRequestCompression, + // Sets the DisableClockSkewCorrection if present in env var or shared config profile + resolveDisableClockSkewCorrection, // Sets the RequestMinCompressSizeBytes if present in env var or shared config profile resolveRequestMinCompressSizeBytes, diff --git a/vendor/github.com/aws/aws-sdk-go-v2/config/env_config.go b/vendor/github.com/aws/aws-sdk-go-v2/config/env_config.go index f0619ce8548..886aec4c22b 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/config/env_config.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/config/env_config.go @@ -78,6 +78,8 @@ const ( awsDisableRequestCompressionEnv = "AWS_DISABLE_REQUEST_COMPRESSION" awsRequestMinCompressionSizeBytesEnv = "AWS_REQUEST_MIN_COMPRESSION_SIZE_BYTES" + awsDisableClockSkewCorrectionEnv = "AWS_DISABLE_CLOCK_SKEW_CORRECTION" + awsS3DisableExpressSessionAuthEnv = "AWS_S3_DISABLE_EXPRESS_SESSION_AUTH" awsAccountIDEnv = "AWS_ACCOUNT_ID" @@ -293,6 +295,10 @@ type EnvConfig struct { // retrieved from env var AWS_REQUEST_MIN_COMPRESSION_SIZE_BYTES RequestMinCompressSizeBytes *int64 + // determine if clock skew correction is disabled, default to false + // retrieved from env var AWS_DISABLE_CLOCK_SKEW_CORRECTION + DisableClockSkewCorrection *bool + // Whether S3Express auth is disabled. // // This will NOT prevent requests from being made to S3Express buckets, it @@ -364,6 +370,9 @@ func NewEnvConfig() (EnvConfig, error) { if err := setInt64PtrFromEnvVal(&cfg.RequestMinCompressSizeBytes, []string{awsRequestMinCompressionSizeBytesEnv}, smithyrequestcompression.MaxRequestMinCompressSizeBytes); err != nil { return cfg, err } + if err := setBoolPtrFromEnvVal(&cfg.DisableClockSkewCorrection, []string{awsDisableClockSkewCorrectionEnv}); err != nil { + return cfg, err + } if err := setEndpointDiscoveryTypeFromEnvVal(&cfg.EnableEndpointDiscovery, []string{awsEnableEndpointDiscoveryEnv}); err != nil { return cfg, err @@ -453,6 +462,13 @@ func (c EnvConfig) getDisableRequestCompression(context.Context) (bool, bool, er return *c.DisableRequestCompression, true, nil } +func (c EnvConfig) getDisableClockSkewCorrection(context.Context) (bool, bool, error) { + if c.DisableClockSkewCorrection == nil { + return false, false, nil + } + return *c.DisableClockSkewCorrection, true, nil +} + func (c EnvConfig) getRequestMinCompressSizeBytes(context.Context) (int64, bool, error) { if c.RequestMinCompressSizeBytes == nil { return 0, false, nil diff --git a/vendor/github.com/aws/aws-sdk-go-v2/config/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/config/go_module_metadata.go index c92c427c550..69cdc134824 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/config/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/config/go_module_metadata.go @@ -3,4 +3,4 @@ package config // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.32.26" +const goModuleVersion = "1.32.37" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/config/load_options.go b/vendor/github.com/aws/aws-sdk-go-v2/config/load_options.go index 843ea6b7d7f..b7b3d8b2050 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/config/load_options.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/config/load_options.go @@ -214,6 +214,9 @@ type LoadOptions struct { // The inclusive min bytes of a request body that could be compressed RequestMinCompressSizeBytes *int64 + // Specifies whether SDK clock skew correction is disabled + DisableClockSkewCorrection *bool + // Whether S3 Express auth is disabled. S3DisableExpressAuth *bool @@ -299,6 +302,14 @@ func (o LoadOptions) getDisableRequestCompression(ctx context.Context) (bool, bo return *o.DisableRequestCompression, true, nil } +// getDisableClockSkewCorrection returns DisableClockSkewCorrection from config's LoadOptions +func (o LoadOptions) getDisableClockSkewCorrection(ctx context.Context) (bool, bool, error) { + if o.DisableClockSkewCorrection == nil { + return false, false, nil + } + return *o.DisableClockSkewCorrection, true, nil +} + // getRequestMinCompressSizeBytes returns RequestMinCompressSizeBytes from config's LoadOptions func (o LoadOptions) getRequestMinCompressSizeBytes(ctx context.Context) (int64, bool, error) { if o.RequestMinCompressSizeBytes == nil { @@ -369,6 +380,18 @@ func WithDisableRequestCompression(DisableRequestCompression *bool) LoadOptionsF } } +// WithDisableClockSkewCorrection is a helper function to construct functional +// options that sets DisableClockSkewCorrection on config's LoadOptions. +func WithDisableClockSkewCorrection(DisableClockSkewCorrection *bool) LoadOptionsFunc { + return func(o *LoadOptions) error { + if DisableClockSkewCorrection == nil { + return nil + } + o.DisableClockSkewCorrection = DisableClockSkewCorrection + return nil + } +} + // WithRequestMinCompressSizeBytes is a helper function to construct functional options // that sets RequestMinCompressSizeBytes on config's LoadOptions. func WithRequestMinCompressSizeBytes(RequestMinCompressSizeBytes *int64) LoadOptionsFunc { diff --git a/vendor/github.com/aws/aws-sdk-go-v2/config/provider.go b/vendor/github.com/aws/aws-sdk-go-v2/config/provider.go index deabd29c82c..ae298afb60d 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/config/provider.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/config/provider.go @@ -208,6 +208,23 @@ func getDisableRequestCompression(ctx context.Context, configs configs) (value b return } +// disableClockSkewCorrectionProvider provides access to the DisableClockSkewCorrection +type disableClockSkewCorrectionProvider interface { + getDisableClockSkewCorrection(context.Context) (bool, bool, error) +} + +func getDisableClockSkewCorrection(ctx context.Context, configs configs) (value bool, found bool, err error) { + for _, cfg := range configs { + if p, ok := cfg.(disableClockSkewCorrectionProvider); ok { + value, found, err = p.getDisableClockSkewCorrection(ctx) + if err != nil || found { + break + } + } + } + return +} + // requestMinCompressSizeBytesProvider provides access to the MinCompressSizeBytes type requestMinCompressSizeBytesProvider interface { getRequestMinCompressSizeBytes(context.Context) (int64, bool, error) diff --git a/vendor/github.com/aws/aws-sdk-go-v2/config/resolve.go b/vendor/github.com/aws/aws-sdk-go-v2/config/resolve.go index b6796fc87e4..a2c56dc625b 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/config/resolve.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/config/resolve.go @@ -151,6 +151,18 @@ func resolveDisableRequestCompression(ctx context.Context, cfg *aws.Config, conf return nil } +// resolveDisableClockSkewCorrection extracts the DisableClockSkewCorrection from +// the configs slice's SharedConfig or EnvConfig +func resolveDisableClockSkewCorrection(ctx context.Context, cfg *aws.Config, configs configs) error { + disable, _, err := getDisableClockSkewCorrection(ctx, configs) + if err != nil { + return err + } + + cfg.DisableClockSkewCorrection = disable + return nil +} + // resolveRequestMinCompressSizeBytes extracts the RequestMinCompressSizeBytes from the configs slice's // SharedConfig or EnvConfig func resolveRequestMinCompressSizeBytes(ctx context.Context, cfg *aws.Config, configs configs) error { diff --git a/vendor/github.com/aws/aws-sdk-go-v2/config/shared_config.go b/vendor/github.com/aws/aws-sdk-go-v2/config/shared_config.go index 5b251f54f57..40b6daf3cfb 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/config/shared_config.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/config/shared_config.go @@ -113,6 +113,8 @@ const ( disableRequestCompression = "disable_request_compression" requestMinCompressionSizeBytes = "request_min_compression_size_bytes" + disableClockSkewCorrection = "disable_clock_skew_correction" + s3DisableExpressSessionAuthKey = "s3_disable_express_session_auth" accountIDKey = "aws_account_id" @@ -346,6 +348,10 @@ type SharedConfig struct { // retrieved from config file's profile field request_min_compression_size_bytes RequestMinCompressSizeBytes *int64 + // determine if clock skew correction is disabled, default to false + // retrieved from config file's profile field disable_clock_skew_correction + DisableClockSkewCorrection *bool + // Whether S3Express auth is disabled. // // This will NOT prevent requests from being made to S3Express buckets, it @@ -1149,6 +1155,9 @@ func (c *SharedConfig) setFromIniSection(profile string, section ini.Section) er if err := updateDisableRequestCompression(&c.DisableRequestCompression, section, disableRequestCompression); err != nil { return fmt.Errorf("failed to load %s from shared config, %w", disableRequestCompression, err) } + if err := updateDisableRequestCompression(&c.DisableClockSkewCorrection, section, disableClockSkewCorrection); err != nil { + return fmt.Errorf("failed to load %s from shared config, %w", disableClockSkewCorrection, err) + } if err := updateRequestMinCompressSizeBytes(&c.RequestMinCompressSizeBytes, section, requestMinCompressionSizeBytes); err != nil { return fmt.Errorf("failed to load %s from shared config, %w", requestMinCompressionSizeBytes, err) } @@ -1292,6 +1301,13 @@ func (c SharedConfig) getDisableRequestCompression(ctx context.Context) (bool, b return *c.DisableRequestCompression, true, nil } +func (c SharedConfig) getDisableClockSkewCorrection(ctx context.Context) (bool, bool, error) { + if c.DisableClockSkewCorrection == nil { + return false, false, nil + } + return *c.DisableClockSkewCorrection, true, nil +} + func (c SharedConfig) getAccountIDEndpointMode(ctx context.Context) (aws.AccountIDEndpointMode, bool, error) { return c.AccountIDEndpointMode, len(c.AccountIDEndpointMode) > 0, nil } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/credentials/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/credentials/CHANGELOG.md index c348b8e13f4..0c76e1689b6 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/credentials/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/credentials/CHANGELOG.md @@ -1,3 +1,52 @@ +# v1.19.36 (2026-08-14) + +* **Dependency Update**: Update to smithy-go v1.27.8. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.19.35 (2026-08-10) + +* **Dependency Update**: Update to smithy-go v1.27.7. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.19.34 (2026-08-05) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.19.33 (2026-07-31.2) + +* **Dependency Update**: Updated to the latest SDK module versions +* **Dependency Update**: Upgrade to smithy-go v1.27.6 to fix various serde issues in HTTP binding services. + +# v1.19.32 (2026-07-29) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.19.31 (2026-07-28) + +* **Dependency Update**: Update to smithy-go v1.27.5. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.19.30 (2026-07-21) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.19.29 (2026-07-13) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.19.28 (2026-07-08.2) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.19.27 (2026-07-06) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.19.26 (2026-07-01) + +* **Bug Fix**: Bump smithy-go to 1.27.3, fix JSON encorder for document.Number, endpoint host label format validation and CBOR union serialization on new serde +* **Dependency Update**: Updated to the latest SDK module versions + # v1.19.25 (2026-06-29) * **Dependency Update**: Updated to the latest SDK module versions diff --git a/vendor/github.com/aws/aws-sdk-go-v2/credentials/endpointcreds/internal/client/client.go b/vendor/github.com/aws/aws-sdk-go-v2/credentials/endpointcreds/internal/client/client.go index dc291c97cd7..429e3261e50 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/credentials/endpointcreds/internal/client/client.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/credentials/endpointcreds/internal/client/client.go @@ -104,8 +104,6 @@ func (c *Client) GetCredentials(ctx context.Context, params *GetCredentialsInput addProtocolFinalizerMiddlewares(stack, options, "GetCredentials") retry.AddRetryMiddlewares(stack, retry.AddRetryMiddlewaresOptions{Retryer: options.Retryer}) middleware.AddSDKAgentKey(middleware.FeatureMetadata, ServiceID) - smithyhttp.AddErrorCloseResponseBodyMiddleware(stack) - smithyhttp.AddCloseResponseBodyMiddleware(stack) for _, fn := range options.APIOptions { if err := fn(stack); err != nil { diff --git a/vendor/github.com/aws/aws-sdk-go-v2/credentials/endpointcreds/internal/client/middleware.go b/vendor/github.com/aws/aws-sdk-go-v2/credentials/endpointcreds/internal/client/middleware.go index f2820d20eac..ba985890525 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/credentials/endpointcreds/internal/client/middleware.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/credentials/endpointcreds/internal/client/middleware.go @@ -82,12 +82,18 @@ func (d *deserializeOpGetCredential) HandleDeserialize(ctx context.Context, in s out smithymiddleware.DeserializeOutput, metadata smithymiddleware.Metadata, err error, ) { out, metadata, err = next.HandleDeserialize(ctx, in) + + // Close the response body on every exit path in place of the standalone close middleware. + // Deferred in a closure so it observes the final err (this output is not a streaming + // payload, so it is always closed regardless). + response, _ := out.RawResponse.(*smithyhttp.Response) + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + if err != nil { return out, metadata, err } - response, ok := out.RawResponse.(*smithyhttp.Response) - if !ok { + if response == nil { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/credentials/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/credentials/go_module_metadata.go index 084ac978f96..c6e3945b611 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/credentials/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/credentials/go_module_metadata.go @@ -3,4 +3,4 @@ package credentials // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.19.25" +const goModuleVersion = "1.19.36" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/feature/ec2/imds/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/feature/ec2/imds/CHANGELOG.md index a2f7103a97d..36e8bf1af13 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/feature/ec2/imds/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/feature/ec2/imds/CHANGELOG.md @@ -1,3 +1,39 @@ +# v1.18.37 (2026-08-14) + +* **Dependency Update**: Update to smithy-go v1.27.8. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.18.36 (2026-08-10) + +* **Dependency Update**: Update to smithy-go v1.27.7. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.18.35 (2026-08-05) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.18.34 (2026-07-31.2) + +* **Dependency Update**: Updated to the latest SDK module versions +* **Dependency Update**: Upgrade to smithy-go v1.27.6 to fix various serde issues in HTTP binding services. + +# v1.18.33 (2026-07-29) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.18.32 (2026-07-28) + +* **Dependency Update**: Update to smithy-go v1.27.5. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.18.31 (2026-07-21) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.18.30 (2026-07-01) + +* **Dependency Update**: Updated to the latest SDK module versions + # v1.18.29 (2026-06-08) * **Dependency Update**: Updated to the latest SDK module versions diff --git a/vendor/github.com/aws/aws-sdk-go-v2/feature/ec2/imds/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/feature/ec2/imds/go_module_metadata.go index 64d469b041d..cd005e503e5 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/feature/ec2/imds/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/feature/ec2/imds/go_module_metadata.go @@ -3,4 +3,4 @@ package imds // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.18.29" +const goModuleVersion = "1.18.37" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/internal/configsources/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/internal/configsources/CHANGELOG.md index 26f507f8b12..e920b6d94c9 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/internal/configsources/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/internal/configsources/CHANGELOG.md @@ -1,3 +1,39 @@ +# v1.4.37 (2026-08-14) + +* **Dependency Update**: Update to smithy-go v1.27.8. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.4.36 (2026-08-10) + +* **Dependency Update**: Update to smithy-go v1.27.7. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.4.35 (2026-08-05) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.4.34 (2026-07-31.2) + +* **Dependency Update**: Updated to the latest SDK module versions +* **Dependency Update**: Upgrade to smithy-go v1.27.6 to fix various serde issues in HTTP binding services. + +# v1.4.33 (2026-07-29) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.4.32 (2026-07-28) + +* **Dependency Update**: Update to smithy-go v1.27.5. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.4.31 (2026-07-21) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.4.30 (2026-07-01) + +* **Dependency Update**: Updated to the latest SDK module versions + # v1.4.29 (2026-06-08) * **Dependency Update**: Updated to the latest SDK module versions diff --git a/vendor/github.com/aws/aws-sdk-go-v2/internal/configsources/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/internal/configsources/go_module_metadata.go index 851fed2b3ee..12426cc3875 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/internal/configsources/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/internal/configsources/go_module_metadata.go @@ -3,4 +3,4 @@ package configsources // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.4.29" +const goModuleVersion = "1.4.37" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/internal/endpoints/v2/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/internal/endpoints/v2/CHANGELOG.md index 508593b45a8..1f444f7d267 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/internal/endpoints/v2/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/internal/endpoints/v2/CHANGELOG.md @@ -1,3 +1,39 @@ +# v2.7.37 (2026-08-14) + +* **Dependency Update**: Update to smithy-go v1.27.8. +* **Dependency Update**: Updated to the latest SDK module versions + +# v2.7.36 (2026-08-10) + +* **Dependency Update**: Update to smithy-go v1.27.7. +* **Dependency Update**: Updated to the latest SDK module versions + +# v2.7.35 (2026-08-05) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v2.7.34 (2026-07-31.2) + +* **Dependency Update**: Updated to the latest SDK module versions +* **Dependency Update**: Upgrade to smithy-go v1.27.6 to fix various serde issues in HTTP binding services. + +# v2.7.33 (2026-07-29) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v2.7.32 (2026-07-28) + +* **Dependency Update**: Update to smithy-go v1.27.5. +* **Dependency Update**: Updated to the latest SDK module versions + +# v2.7.31 (2026-07-21) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v2.7.30 (2026-07-01) + +* **Dependency Update**: Updated to the latest SDK module versions + # v2.7.29 (2026-06-08) * **Dependency Update**: Updated to the latest SDK module versions diff --git a/vendor/github.com/aws/aws-sdk-go-v2/internal/endpoints/v2/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/internal/endpoints/v2/go_module_metadata.go index 1c161a0a732..3990207edb3 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/internal/endpoints/v2/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/internal/endpoints/v2/go_module_metadata.go @@ -3,4 +3,4 @@ package endpoints // goModuleVersion is the tagged release for this module -const goModuleVersion = "2.7.29" +const goModuleVersion = "2.7.37" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/internal/v4a/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/internal/v4a/CHANGELOG.md index 554f43b5e67..4f576aa2189 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/internal/v4a/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/internal/v4a/CHANGELOG.md @@ -1,3 +1,39 @@ +# v1.4.38 (2026-08-14) + +* **Dependency Update**: Update to smithy-go v1.27.8. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.4.37 (2026-08-10) + +* **Dependency Update**: Update to smithy-go v1.27.7. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.4.36 (2026-08-05) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.4.35 (2026-07-31.2) + +* **Dependency Update**: Updated to the latest SDK module versions +* **Dependency Update**: Upgrade to smithy-go v1.27.6 to fix various serde issues in HTTP binding services. + +# v1.4.34 (2026-07-29) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.4.33 (2026-07-28) + +* **Dependency Update**: Update to smithy-go v1.27.5. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.4.32 (2026-07-21) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.4.31 (2026-07-01) + +* **Dependency Update**: Updated to the latest SDK module versions + # v1.4.30 (2026-06-08) * **Dependency Update**: Updated to the latest SDK module versions diff --git a/vendor/github.com/aws/aws-sdk-go-v2/internal/v4a/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/internal/v4a/go_module_metadata.go index 2703ec797e3..f0ad2caf2de 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/internal/v4a/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/internal/v4a/go_module_metadata.go @@ -3,4 +3,4 @@ package v4a // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.4.30" +const goModuleVersion = "1.4.38" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/CHANGELOG.md index 01a8aa106a4..799cd1c59fc 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/CHANGELOG.md @@ -1,3 +1,57 @@ +# v1.63.3 (2026-08-14) + +* **Dependency Update**: Update to smithy-go v1.27.8. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.63.2 (2026-08-10) + +* **Dependency Update**: Update to smithy-go v1.27.7. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.63.1 (2026-08-05) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.63.0 (2026-08-04) + +* **Feature**: Vector indexes are a type of index in Amazon DynamoDB that enable similarity search on vector embedding stored in your table items. Vector indexes use approximate nearest neighbor search to find items whose vectors are most similar to a query vector that you provide. + +# v1.62.3 (2026-07-31.2) + +* **Dependency Update**: Updated to the latest SDK module versions +* **Dependency Update**: Upgrade to smithy-go v1.27.6 to fix various serde issues in HTTP binding services. + +# v1.62.2 (2026-07-29) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.62.1 (2026-07-28) + +* **Dependency Update**: Update to smithy-go v1.27.5. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.62.0 (2026-07-24) + +* **Feature**: Endpoint test standardizations + +# v1.61.0 (2026-07-21) + +* **Feature**: Add an option to clients to disable clock skew +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.60.1 (2026-07-13) + +* No change notes available for this release. + +# v1.60.0 (2026-07-06) + +* **Feature**: Add request serialization snapshot tests. + +# v1.59.2 (2026-07-01) + +* **Bug Fix**: Bump smithy-go to 1.27.3, fix JSON encorder for document.Number, endpoint host label format validation and CBOR union serialization on new serde +* **Dependency Update**: Updated to the latest SDK module versions + # v1.59.1 (2026-06-29) * No change notes available for this release. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_client.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_client.go index cc9ce6c2b48..cd5d4f24d0e 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_client.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_client.go @@ -277,6 +277,10 @@ func (c *Client) invokeOperation( finalizeClientEndpointResolverOptions(&options) + ctx = setLoggerContext(ctx, options, opID) + + ctx = resolveServiceMetadata(ctx, options, opID) + if err := c.addCommonMiddlewares(stack, options, opID); err != nil { return nil, metadata, err } @@ -393,9 +397,6 @@ func (c *Client) addCommonMiddlewares(stack *middleware.Stack, options Options, if err := addProtocolFinalizerMiddlewares(stack, options, operation); err != nil { return fmt.Errorf("add protocol finalizers: %v", err) } - if err := addSetLoggerMiddleware(stack, options); err != nil { - return err - } if err := addClientRequestID(stack); err != nil { return err } @@ -448,30 +449,6 @@ func resolveAuthSchemes(options *Options) { type noSmithyDocumentSerde = smithydocument.NoSerde -type legacyEndpointContextSetter struct { - LegacyResolver EndpointResolver -} - -func (*legacyEndpointContextSetter) ID() string { - return "legacyEndpointContextSetter" -} - -func (m *legacyEndpointContextSetter) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( - out middleware.InitializeOutput, metadata middleware.Metadata, err error, -) { - if m.LegacyResolver != nil { - ctx = awsmiddleware.SetRequiresLegacyEndpoints(ctx, true) - } - - return next.HandleInitialize(ctx, in) - -} -func addlegacyEndpointContextSetter(stack *middleware.Stack, o Options) error { - return stack.Initialize.Add(&legacyEndpointContextSetter{ - LegacyResolver: o.EndpointResolver, - }, middleware.Before) -} - func resolveDefaultLogger(o *Options) { if o.Logger != nil { return @@ -479,8 +456,9 @@ func resolveDefaultLogger(o *Options) { o.Logger = logging.Nop{} } -func addSetLoggerMiddleware(stack *middleware.Stack, o Options) error { - return middleware.AddSetLoggerMiddleware(stack, o.Logger) +func setLoggerContext(ctx context.Context, options Options, operation string) context.Context { + _ = operation + return middleware.SetLogger(ctx, options.Logger) } func setResolvedDefaultsMode(o *Options) { @@ -501,17 +479,18 @@ func setResolvedDefaultsMode(o *Options) { // NewFromConfig returns a new client from the provided config. func NewFromConfig(cfg aws.Config, optFns ...func(*Options)) *Client { opts := Options{ - Region: cfg.Region, - DefaultsMode: cfg.DefaultsMode, - RuntimeEnvironment: cfg.RuntimeEnvironment, - HTTPClient: cfg.HTTPClient, - Credentials: cfg.Credentials, - APIOptions: cfg.APIOptions, - Logger: cfg.Logger, - ClientLogMode: cfg.ClientLogMode, - AppID: cfg.AppID, - AccountIDEndpointMode: cfg.AccountIDEndpointMode, - AuthSchemePreference: cfg.AuthSchemePreference, + Region: cfg.Region, + DefaultsMode: cfg.DefaultsMode, + RuntimeEnvironment: cfg.RuntimeEnvironment, + HTTPClient: cfg.HTTPClient, + Credentials: cfg.Credentials, + APIOptions: cfg.APIOptions, + Logger: cfg.Logger, + ClientLogMode: cfg.ClientLogMode, + AppID: cfg.AppID, + DisableClockSkewCorrection: cfg.DisableClockSkewCorrection, + AccountIDEndpointMode: cfg.AccountIDEndpointMode, + AuthSchemePreference: cfg.AuthSchemePreference, } resolveAWSRetryerProvider(cfg, &opts) resolveAWSRetryMaxAttempts(cfg, &opts) @@ -719,8 +698,10 @@ func addRawResponseToMetadata(stack *middleware.Stack) error { return stack.Deserialize.Add(&awsmiddleware.AddRawResponse{}, middleware.Before) } -func addRecordResponseTiming(stack *middleware.Stack) error { - return stack.Deserialize.Add(&awsmiddleware.RecordResponseTiming{}, middleware.After) +func addRecordResponseTiming(stack *middleware.Stack, options Options) error { + return stack.Deserialize.Add(&awsmiddleware.RecordResponseTiming{ + DisableClockSkewCorrection: options.DisableClockSkewCorrection, + }, middleware.After) } func addSpanRetryLoop(stack *middleware.Stack, options Options) error { @@ -798,6 +779,7 @@ func addRetry(stack *middleware.Stack, o Options, c *Client) error { m.LogAttempts = o.ClientLogMode.IsRetries() m.OperationMeter = o.MeterProvider.Meter("github.com/aws/aws-sdk-go-v2/service/dynamodb") m.ClientSkew = c.timeOffset + m.DisableClockSkewCorrection = o.DisableClockSkewCorrection }) if err := stack.Finalize.Insert(attempt, "ResolveAuthScheme", middleware.Before); err != nil { return err @@ -1035,12 +1017,16 @@ type IdempotencyTokenProvider interface { GetIdempotencyToken() (string, error) } -func newServiceMetadataMiddleware(region, operation string) *awsmiddleware.RegisterServiceMetadata { - return &awsmiddleware.RegisterServiceMetadata{ - Region: region, - ServiceID: ServiceID, - OperationName: operation, +func resolveServiceMetadata(ctx context.Context, options Options, operation string) context.Context { + ctx = awsmiddleware.SetServiceID(ctx, ServiceID) + if options.Region != "" { + ctx = awsmiddleware.SetRegion(ctx, options.Region) + } + ctx = awsmiddleware.SetOperationName(ctx, operation) + if options.EndpointResolver != nil { + ctx = awsmiddleware.SetRequiresLegacyEndpoints(ctx, true) } + return ctx } func addRecursionDetection(stack *middleware.Stack) error { diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_BatchExecuteStatement.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_BatchExecuteStatement.go index 82201b4843b..9ea3edc72e7 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_BatchExecuteStatement.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_BatchExecuteStatement.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // This operation allows you to perform batch reads or writes on data stored in @@ -92,9 +91,6 @@ func (c *Client) addOperationBatchExecuteStatementMiddlewares(stack *middleware. return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -104,13 +100,7 @@ func (c *Client) addOperationBatchExecuteStatementMiddlewares(stack *middleware. if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { @@ -122,9 +112,6 @@ func (c *Client) addOperationBatchExecuteStatementMiddlewares(stack *middleware. if err = addOpBatchExecuteStatementValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "BatchExecuteStatement"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_BatchGetItem.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_BatchGetItem.go index 70da9d78910..e63263084d0 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_BatchGetItem.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_BatchGetItem.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // The BatchGetItem operation returns the attributes of one or more items from one @@ -240,9 +239,6 @@ func (c *Client) addOperationBatchGetItemMiddlewares(stack *middleware.Stack, op return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -252,13 +248,7 @@ func (c *Client) addOperationBatchGetItemMiddlewares(stack *middleware.Stack, op if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpBatchGetItemDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -273,9 +263,6 @@ func (c *Client) addOperationBatchGetItemMiddlewares(stack *middleware.Stack, op if err = addOpBatchGetItemValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "BatchGetItem"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_BatchWriteItem.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_BatchWriteItem.go index 5d843b37e10..d8b305a301c 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_BatchWriteItem.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_BatchWriteItem.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // The BatchWriteItem operation puts or deletes multiple items in one or more @@ -32,12 +31,12 @@ import ( // iteration would check for unprocessed items and submit a new BatchWriteItem // request with those unprocessed items until all items have been processed. // -// For tables and indexes with provisioned capacity, if none of the items can be -// processed due to insufficient provisioned throughput on all of the tables in the -// request, then BatchWriteItem returns a ProvisionedThroughputExceededException . -// For all tables and indexes, if none of the items can be processed due to other -// throttling scenarios (such as exceeding partition level limits), then -// BatchWriteItem returns a ThrottlingException . +// If BatchWriteItem cannot process any items due to throttling (for example, +// insufficient provisioned throughput on the tables in the request, or +// partition-level or account-level limits), it returns a +// ProvisionedThroughputExceededException or a ThrottlingException . Both indicate +// that the request was throttled; check the ThrottlingReason field in the +// returned exception for details. // // If DynamoDB returns any unprocessed items, you should retry the batch operation // on those items. However, we strongly recommend that you use an exponential @@ -191,6 +190,9 @@ type BatchWriteItemOutput struct { // - TableName - The table that consumed the provisioned throughput. // // - CapacityUnits - The total number of capacity units consumed. + // + // If the table has vector indexes, each element also includes a VectorIndexes + // field with VectorWriteRequestBytes consumed for each affected vector index. ConsumedCapacity []types.ConsumedCapacity // A list of tables that were processed by BatchWriteItem and, for each table, @@ -260,9 +262,6 @@ func (c *Client) addOperationBatchWriteItemMiddlewares(stack *middleware.Stack, return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -272,13 +271,7 @@ func (c *Client) addOperationBatchWriteItemMiddlewares(stack *middleware.Stack, if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpBatchWriteItemDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -293,9 +286,6 @@ func (c *Client) addOperationBatchWriteItemMiddlewares(stack *middleware.Stack, if err = addOpBatchWriteItemValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "BatchWriteItem"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_CreateBackup.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_CreateBackup.go index 886a252620a..db0f82a81dd 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_CreateBackup.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_CreateBackup.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Creates a backup for an existing table. @@ -99,9 +98,6 @@ func (c *Client) addOperationCreateBackupMiddlewares(stack *middleware.Stack, op return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -111,13 +107,7 @@ func (c *Client) addOperationCreateBackupMiddlewares(stack *middleware.Stack, op if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpCreateBackupDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -132,9 +122,6 @@ func (c *Client) addOperationCreateBackupMiddlewares(stack *middleware.Stack, op if err = addOpCreateBackupValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "CreateBackup"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_CreateGlobalTable.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_CreateGlobalTable.go index 4d51eb7a489..743d18378ac 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_CreateGlobalTable.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_CreateGlobalTable.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Creates a global table from an existing table. A global table creates a @@ -121,9 +120,6 @@ func (c *Client) addOperationCreateGlobalTableMiddlewares(stack *middleware.Stac return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -133,13 +129,7 @@ func (c *Client) addOperationCreateGlobalTableMiddlewares(stack *middleware.Stac if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpCreateGlobalTableDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -154,9 +144,6 @@ func (c *Client) addOperationCreateGlobalTableMiddlewares(stack *middleware.Stac if err = addOpCreateGlobalTableValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "CreateGlobalTable"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_CreateTable.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_CreateTable.go index 294ee44a245..9d3802eb1d0 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_CreateTable.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_CreateTable.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // The CreateTable operation adds a new table to your account. In an Amazon Web @@ -259,6 +258,31 @@ type CreateTableInput struct { // [Tagging for DynamoDB]: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tagging.html Tags []types.Tag + // One or more vector indexes to be created on the table. Each vector index + // enables similarity search on a vector attribute. Each element in the list + // consists of: + // + // - IndexName - The name of the vector index. Must be unique within the table. + // + // - VectorAttribute - The attribute that contains vector embeddings. If multiple + // vector indexes reference the same attribute, they must all use the same number + // of dimensions. + // + // - Dimensions - The number of dimensions in each vector. + // + // - DistanceFunction - The distance function used to calculate similarity. Valid + // values: COSINE , EUCLIDEAN , DOT_PRODUCT . + // + // - Projection - Specifies attributes that are copied (projected) from the table + // into the vector index. The total number of projected non-key attributes is + // shared across the vector attribute (counts as 1) and INLINE_FILTER search + // schema elements (each counts as 1). HASH search schema elements do not count + // toward this limit. + // + // - SearchSchema - (Optional) Defines the partition key ( HASH ) and inline + // filter ( INLINE_FILTER ) attributes for the vector index. + VectorIndexes []types.VectorIndex + // Represents the warm throughput (in read units per second and write units per // second) for creating a table. WarmThroughput *types.WarmThroughput @@ -294,9 +318,6 @@ func (c *Client) addOperationCreateTableMiddlewares(stack *middleware.Stack, opt return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -306,13 +327,7 @@ func (c *Client) addOperationCreateTableMiddlewares(stack *middleware.Stack, opt if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpCreateTableDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -327,9 +342,6 @@ func (c *Client) addOperationCreateTableMiddlewares(stack *middleware.Stack, opt if err = addOpCreateTableValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "CreateTable"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DeleteBackup.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DeleteBackup.go index 62b602a4c39..d8a2d35f539 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DeleteBackup.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DeleteBackup.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Deletes an existing backup of a table. @@ -66,9 +65,6 @@ func (c *Client) addOperationDeleteBackupMiddlewares(stack *middleware.Stack, op return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -78,13 +74,7 @@ func (c *Client) addOperationDeleteBackupMiddlewares(stack *middleware.Stack, op if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpDeleteBackupDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -99,9 +89,6 @@ func (c *Client) addOperationDeleteBackupMiddlewares(stack *middleware.Stack, op if err = addOpDeleteBackupValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DeleteBackup"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DeleteItem.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DeleteItem.go index abaff832288..b6fbcd506e7 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DeleteItem.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DeleteItem.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Deletes a single item in a table by primary key. You can perform a conditional @@ -222,6 +221,9 @@ type DeleteItemOutput struct { // returned if the ReturnConsumedCapacity parameter was specified. For more // information, see [Provisioned capacity mode]in the Amazon DynamoDB Developer Guide. // + // If the table has vector indexes, the response includes a VectorIndexes field + // with VectorWriteRequestBytes consumed for each affected vector index. + // // [Provisioned capacity mode]: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/provisioned-capacity-mode.html ConsumedCapacity *types.ConsumedCapacity @@ -262,9 +264,6 @@ func (c *Client) addOperationDeleteItemMiddlewares(stack *middleware.Stack, opti return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -274,13 +273,7 @@ func (c *Client) addOperationDeleteItemMiddlewares(stack *middleware.Stack, opti if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpDeleteItemDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -295,9 +288,6 @@ func (c *Client) addOperationDeleteItemMiddlewares(stack *middleware.Stack, opti if err = addOpDeleteItemValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DeleteItem"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DeleteResourcePolicy.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DeleteResourcePolicy.go index 55afbefa5d0..5026731ba0a 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DeleteResourcePolicy.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DeleteResourcePolicy.go @@ -7,7 +7,6 @@ import ( "fmt" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Deletes the resource-based policy attached to the resource, which can be a @@ -93,9 +92,6 @@ func (c *Client) addOperationDeleteResourcePolicyMiddlewares(stack *middleware.S return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -105,13 +101,7 @@ func (c *Client) addOperationDeleteResourcePolicyMiddlewares(stack *middleware.S if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpDeleteResourcePolicyDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -126,9 +116,6 @@ func (c *Client) addOperationDeleteResourcePolicyMiddlewares(stack *middleware.S if err = addOpDeleteResourcePolicyValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DeleteResourcePolicy"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DeleteTable.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DeleteTable.go index fc50927bafc..ab2735c68cb 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DeleteTable.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DeleteTable.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // The DeleteTable operation deletes a table and all of its items. After a @@ -87,9 +86,6 @@ func (c *Client) addOperationDeleteTableMiddlewares(stack *middleware.Stack, opt return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -99,13 +95,7 @@ func (c *Client) addOperationDeleteTableMiddlewares(stack *middleware.Stack, opt if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpDeleteTableDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -120,9 +110,6 @@ func (c *Client) addOperationDeleteTableMiddlewares(stack *middleware.Stack, opt if err = addOpDeleteTableValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DeleteTable"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeBackup.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeBackup.go index 58ce7629776..dcd54e7aecd 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeBackup.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeBackup.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Describes an existing backup of a table. @@ -66,9 +65,6 @@ func (c *Client) addOperationDescribeBackupMiddlewares(stack *middleware.Stack, return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -78,13 +74,7 @@ func (c *Client) addOperationDescribeBackupMiddlewares(stack *middleware.Stack, if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpDescribeBackupDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -99,9 +89,6 @@ func (c *Client) addOperationDescribeBackupMiddlewares(stack *middleware.Stack, if err = addOpDescribeBackupValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DescribeBackup"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeContinuousBackups.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeContinuousBackups.go index ee0968ff409..e29fcd55181 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeContinuousBackups.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeContinuousBackups.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Checks the status of continuous backups and point in time recovery on the @@ -82,9 +81,6 @@ func (c *Client) addOperationDescribeContinuousBackupsMiddlewares(stack *middlew return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -94,13 +90,7 @@ func (c *Client) addOperationDescribeContinuousBackupsMiddlewares(stack *middlew if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpDescribeContinuousBackupsDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -115,9 +105,6 @@ func (c *Client) addOperationDescribeContinuousBackupsMiddlewares(stack *middlew if err = addOpDescribeContinuousBackupsValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DescribeContinuousBackups"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeContributorInsights.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeContributorInsights.go index 1a6730b8643..9897f13f268 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeContributorInsights.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeContributorInsights.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/aws/smithy-go/middleware" smithytime "github.com/aws/smithy-go/time" - smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" "time" ) @@ -106,9 +105,6 @@ func (c *Client) addOperationDescribeContributorInsightsMiddlewares(stack *middl return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -118,13 +114,7 @@ func (c *Client) addOperationDescribeContributorInsightsMiddlewares(stack *middl if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { @@ -136,9 +126,6 @@ func (c *Client) addOperationDescribeContributorInsightsMiddlewares(stack *middl if err = addOpDescribeContributorInsightsValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DescribeContributorInsights"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeEndpoints.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeEndpoints.go index e21bf097452..4c635f2483e 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeEndpoints.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeEndpoints.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Returns the regional endpoint information. For more information on policy @@ -55,9 +54,6 @@ func (c *Client) addOperationDescribeEndpointsMiddlewares(stack *middleware.Stac return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -67,13 +63,7 @@ func (c *Client) addOperationDescribeEndpointsMiddlewares(stack *middleware.Stac if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { @@ -82,9 +72,6 @@ func (c *Client) addOperationDescribeEndpointsMiddlewares(stack *middleware.Stac if err = addCredentialSource(stack, options); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DescribeEndpoints"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeExport.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeExport.go index 9e749e7ebe5..0b0354a15a7 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeExport.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeExport.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/aws/smithy-go/middleware" smithytime "github.com/aws/smithy-go/time" - smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" "time" ) @@ -66,9 +65,6 @@ func (c *Client) addOperationDescribeExportMiddlewares(stack *middleware.Stack, return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -78,13 +74,7 @@ func (c *Client) addOperationDescribeExportMiddlewares(stack *middleware.Stack, if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { @@ -96,9 +86,6 @@ func (c *Client) addOperationDescribeExportMiddlewares(stack *middleware.Stack, if err = addOpDescribeExportValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DescribeExport"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeGlobalTable.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeGlobalTable.go index c4fbb63b6e5..dfa1ae72f0d 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeGlobalTable.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeGlobalTable.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Returns information about the specified global table. @@ -76,9 +75,6 @@ func (c *Client) addOperationDescribeGlobalTableMiddlewares(stack *middleware.St return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -88,13 +84,7 @@ func (c *Client) addOperationDescribeGlobalTableMiddlewares(stack *middleware.St if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpDescribeGlobalTableDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -109,9 +99,6 @@ func (c *Client) addOperationDescribeGlobalTableMiddlewares(stack *middleware.St if err = addOpDescribeGlobalTableValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DescribeGlobalTable"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeGlobalTableSettings.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeGlobalTableSettings.go index 9b7d5a81cfd..e6b4c75bb25 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeGlobalTableSettings.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeGlobalTableSettings.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Describes Region-specific settings for a global table. @@ -79,9 +78,6 @@ func (c *Client) addOperationDescribeGlobalTableSettingsMiddlewares(stack *middl return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -91,13 +87,7 @@ func (c *Client) addOperationDescribeGlobalTableSettingsMiddlewares(stack *middl if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpDescribeGlobalTableSettingsDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -112,9 +102,6 @@ func (c *Client) addOperationDescribeGlobalTableSettingsMiddlewares(stack *middl if err = addOpDescribeGlobalTableSettingsValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DescribeGlobalTableSettings"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeImport.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeImport.go index a15716b31a8..abb0e8d5037 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeImport.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeImport.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/aws/smithy-go/middleware" smithytime "github.com/aws/smithy-go/time" - smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" "time" ) @@ -70,9 +69,6 @@ func (c *Client) addOperationDescribeImportMiddlewares(stack *middleware.Stack, return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -82,13 +78,7 @@ func (c *Client) addOperationDescribeImportMiddlewares(stack *middleware.Stack, if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { @@ -100,9 +90,6 @@ func (c *Client) addOperationDescribeImportMiddlewares(stack *middleware.Stack, if err = addOpDescribeImportValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DescribeImport"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeKinesisStreamingDestination.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeKinesisStreamingDestination.go index 0da887082c0..b53790792f6 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeKinesisStreamingDestination.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeKinesisStreamingDestination.go @@ -9,7 +9,6 @@ import ( internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" smithytime "github.com/aws/smithy-go/time" - smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" "strconv" "time" @@ -72,9 +71,6 @@ func (c *Client) addOperationDescribeKinesisStreamingDestinationMiddlewares(stac return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -84,13 +80,7 @@ func (c *Client) addOperationDescribeKinesisStreamingDestinationMiddlewares(stac if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpDescribeKinesisStreamingDestinationDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -105,9 +95,6 @@ func (c *Client) addOperationDescribeKinesisStreamingDestinationMiddlewares(stac if err = addOpDescribeKinesisStreamingDestinationValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DescribeKinesisStreamingDestination"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeLimits.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeLimits.go index aa4f9a27b72..ef309b2602a 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeLimits.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeLimits.go @@ -7,7 +7,6 @@ import ( "fmt" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Returns the current provisioned-capacity quotas for your Amazon Web Services @@ -127,9 +126,6 @@ func (c *Client) addOperationDescribeLimitsMiddlewares(stack *middleware.Stack, return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -139,13 +135,7 @@ func (c *Client) addOperationDescribeLimitsMiddlewares(stack *middleware.Stack, if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpDescribeLimitsDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -157,9 +147,6 @@ func (c *Client) addOperationDescribeLimitsMiddlewares(stack *middleware.Stack, if err = addCredentialSource(stack, options); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DescribeLimits"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeTable.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeTable.go index 266568b3794..879098352f1 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeTable.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeTable.go @@ -10,7 +10,6 @@ import ( internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" smithytime "github.com/aws/smithy-go/time" - smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" "time" ) @@ -78,9 +77,6 @@ func (c *Client) addOperationDescribeTableMiddlewares(stack *middleware.Stack, o return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -90,13 +86,7 @@ func (c *Client) addOperationDescribeTableMiddlewares(stack *middleware.Stack, o if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpDescribeTableDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -111,9 +101,6 @@ func (c *Client) addOperationDescribeTableMiddlewares(stack *middleware.Stack, o if err = addOpDescribeTableValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DescribeTable"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeTableReplicaAutoScaling.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeTableReplicaAutoScaling.go index 7c550e29f0e..075e7c98b8d 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeTableReplicaAutoScaling.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeTableReplicaAutoScaling.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Describes auto scaling settings across replicas of the global table at once. @@ -63,9 +62,6 @@ func (c *Client) addOperationDescribeTableReplicaAutoScalingMiddlewares(stack *m return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -75,13 +71,7 @@ func (c *Client) addOperationDescribeTableReplicaAutoScalingMiddlewares(stack *m if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { @@ -93,9 +83,6 @@ func (c *Client) addOperationDescribeTableReplicaAutoScalingMiddlewares(stack *m if err = addOpDescribeTableReplicaAutoScalingValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DescribeTableReplicaAutoScaling"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeTimeToLive.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeTimeToLive.go index 53f7be7f8d7..7bb91a7d4e2 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeTimeToLive.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DescribeTimeToLive.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Gives a description of the Time to Live (TTL) status on the specified table. @@ -65,9 +64,6 @@ func (c *Client) addOperationDescribeTimeToLiveMiddlewares(stack *middleware.Sta return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -77,13 +73,7 @@ func (c *Client) addOperationDescribeTimeToLiveMiddlewares(stack *middleware.Sta if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpDescribeTimeToLiveDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -98,9 +88,6 @@ func (c *Client) addOperationDescribeTimeToLiveMiddlewares(stack *middleware.Sta if err = addOpDescribeTimeToLiveValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DescribeTimeToLive"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DisableKinesisStreamingDestination.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DisableKinesisStreamingDestination.go index 1378c96b2ec..eb2ae77e567 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DisableKinesisStreamingDestination.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_DisableKinesisStreamingDestination.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Stops replication from the DynamoDB table to the Kinesis data stream. This is @@ -83,9 +82,6 @@ func (c *Client) addOperationDisableKinesisStreamingDestinationMiddlewares(stack return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -95,13 +91,7 @@ func (c *Client) addOperationDisableKinesisStreamingDestinationMiddlewares(stack if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpDisableKinesisStreamingDestinationDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -116,9 +106,6 @@ func (c *Client) addOperationDisableKinesisStreamingDestinationMiddlewares(stack if err = addOpDisableKinesisStreamingDestinationValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DisableKinesisStreamingDestination"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_EnableKinesisStreamingDestination.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_EnableKinesisStreamingDestination.go index fd6d5903c75..d1360620b57 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_EnableKinesisStreamingDestination.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_EnableKinesisStreamingDestination.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Starts table data replication to the specified Kinesis data stream at a @@ -85,9 +84,6 @@ func (c *Client) addOperationEnableKinesisStreamingDestinationMiddlewares(stack return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -97,13 +93,7 @@ func (c *Client) addOperationEnableKinesisStreamingDestinationMiddlewares(stack if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpEnableKinesisStreamingDestinationDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -118,9 +108,6 @@ func (c *Client) addOperationEnableKinesisStreamingDestinationMiddlewares(stack if err = addOpEnableKinesisStreamingDestinationValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "EnableKinesisStreamingDestination"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ExecuteStatement.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ExecuteStatement.go index d33de5bf533..6bb4eb504f9 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ExecuteStatement.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ExecuteStatement.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // This operation allows you to perform reads and singleton writes on data stored @@ -140,9 +139,6 @@ func (c *Client) addOperationExecuteStatementMiddlewares(stack *middleware.Stack return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -152,13 +148,7 @@ func (c *Client) addOperationExecuteStatementMiddlewares(stack *middleware.Stack if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { @@ -170,9 +160,6 @@ func (c *Client) addOperationExecuteStatementMiddlewares(stack *middleware.Stack if err = addOpExecuteStatementValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "ExecuteStatement"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ExecuteTransaction.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ExecuteTransaction.go index af10ae61d46..cfb6d4c1cf4 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ExecuteTransaction.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ExecuteTransaction.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // This operation allows you to perform transactional reads or writes on data @@ -80,9 +79,6 @@ func (c *Client) addOperationExecuteTransactionMiddlewares(stack *middleware.Sta return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -92,13 +88,7 @@ func (c *Client) addOperationExecuteTransactionMiddlewares(stack *middleware.Sta if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { @@ -113,9 +103,6 @@ func (c *Client) addOperationExecuteTransactionMiddlewares(stack *middleware.Sta if err = addOpExecuteTransactionValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "ExecuteTransaction"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ExportTableToPointInTime.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ExportTableToPointInTime.go index 81186948fd2..fc00f20cdce 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ExportTableToPointInTime.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ExportTableToPointInTime.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" "time" ) @@ -126,9 +125,6 @@ func (c *Client) addOperationExportTableToPointInTimeMiddlewares(stack *middlewa return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -138,13 +134,7 @@ func (c *Client) addOperationExportTableToPointInTimeMiddlewares(stack *middlewa if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { @@ -159,9 +149,6 @@ func (c *Client) addOperationExportTableToPointInTimeMiddlewares(stack *middlewa if err = addOpExportTableToPointInTimeValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "ExportTableToPointInTime"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_GetItem.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_GetItem.go index 9d27e788a70..df8794cfc57 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_GetItem.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_GetItem.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // The GetItem operation returns a set of attributes for the item with the given @@ -172,9 +171,6 @@ func (c *Client) addOperationGetItemMiddlewares(stack *middleware.Stack, options return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -184,13 +180,7 @@ func (c *Client) addOperationGetItemMiddlewares(stack *middleware.Stack, options if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpGetItemDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -205,9 +195,6 @@ func (c *Client) addOperationGetItemMiddlewares(stack *middleware.Stack, options if err = addOpGetItemValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "GetItem"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_GetResourcePolicy.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_GetResourcePolicy.go index 440b9db6b0e..4b27ae1eb18 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_GetResourcePolicy.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_GetResourcePolicy.go @@ -7,7 +7,6 @@ import ( "fmt" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Returns the resource-based policy document attached to the resource, which can @@ -98,9 +97,6 @@ func (c *Client) addOperationGetResourcePolicyMiddlewares(stack *middleware.Stac return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -110,13 +106,7 @@ func (c *Client) addOperationGetResourcePolicyMiddlewares(stack *middleware.Stac if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpGetResourcePolicyDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -131,9 +121,6 @@ func (c *Client) addOperationGetResourcePolicyMiddlewares(stack *middleware.Stac if err = addOpGetResourcePolicyValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "GetResourcePolicy"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ImportTable.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ImportTable.go index 1ec25bd027a..b6ea5d73b49 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ImportTable.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ImportTable.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Imports table data from an S3 bucket. @@ -104,9 +103,6 @@ func (c *Client) addOperationImportTableMiddlewares(stack *middleware.Stack, opt return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -116,13 +112,7 @@ func (c *Client) addOperationImportTableMiddlewares(stack *middleware.Stack, opt if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { @@ -137,9 +127,6 @@ func (c *Client) addOperationImportTableMiddlewares(stack *middleware.Stack, opt if err = addOpImportTableValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "ImportTable"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListBackups.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListBackups.go index 634a3909e33..e004855b0ca 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListBackups.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListBackups.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" "time" ) @@ -121,9 +120,6 @@ func (c *Client) addOperationListBackupsMiddlewares(stack *middleware.Stack, opt return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -133,13 +129,7 @@ func (c *Client) addOperationListBackupsMiddlewares(stack *middleware.Stack, opt if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpListBackupsDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -151,9 +141,6 @@ func (c *Client) addOperationListBackupsMiddlewares(stack *middleware.Stack, opt if err = addCredentialSource(stack, options); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "ListBackups"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListContributorInsights.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListContributorInsights.go index b4e0428465d..c6c92966c39 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListContributorInsights.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListContributorInsights.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Returns a list of ContributorInsightsSummary for a table and all its global @@ -72,9 +71,6 @@ func (c *Client) addOperationListContributorInsightsMiddlewares(stack *middlewar return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -84,13 +80,7 @@ func (c *Client) addOperationListContributorInsightsMiddlewares(stack *middlewar if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { @@ -99,9 +89,6 @@ func (c *Client) addOperationListContributorInsightsMiddlewares(stack *middlewar if err = addCredentialSource(stack, options); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "ListContributorInsights"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListExports.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListExports.go index 2f291560687..748cfa1fa2c 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListExports.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListExports.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Lists completed exports within the past 90 days, in reverse alphanumeric order @@ -74,9 +73,6 @@ func (c *Client) addOperationListExportsMiddlewares(stack *middleware.Stack, opt return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -86,13 +82,7 @@ func (c *Client) addOperationListExportsMiddlewares(stack *middleware.Stack, opt if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { @@ -101,9 +91,6 @@ func (c *Client) addOperationListExportsMiddlewares(stack *middleware.Stack, opt if err = addCredentialSource(stack, options); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "ListExports"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListGlobalTables.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListGlobalTables.go index d715f7ba457..699e5f4991e 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListGlobalTables.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListGlobalTables.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Lists all global tables that have a replica in the specified Region. @@ -83,9 +82,6 @@ func (c *Client) addOperationListGlobalTablesMiddlewares(stack *middleware.Stack return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -95,13 +91,7 @@ func (c *Client) addOperationListGlobalTablesMiddlewares(stack *middleware.Stack if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpListGlobalTablesDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -113,9 +103,6 @@ func (c *Client) addOperationListGlobalTablesMiddlewares(stack *middleware.Stack if err = addCredentialSource(stack, options); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "ListGlobalTables"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListImports.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListImports.go index 5db278e1e26..6eba6f9569e 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListImports.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListImports.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Lists completed imports within the past 90 days. @@ -73,9 +72,6 @@ func (c *Client) addOperationListImportsMiddlewares(stack *middleware.Stack, opt return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -85,13 +81,7 @@ func (c *Client) addOperationListImportsMiddlewares(stack *middleware.Stack, opt if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { @@ -100,9 +90,6 @@ func (c *Client) addOperationListImportsMiddlewares(stack *middleware.Stack, opt if err = addCredentialSource(stack, options); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "ListImports"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListTables.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListTables.go index 6aaa40f2293..14a59c44fc2 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListTables.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListTables.go @@ -7,7 +7,6 @@ import ( "fmt" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Returns an array of table names associated with the current account and @@ -78,9 +77,6 @@ func (c *Client) addOperationListTablesMiddlewares(stack *middleware.Stack, opti return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -90,13 +86,7 @@ func (c *Client) addOperationListTablesMiddlewares(stack *middleware.Stack, opti if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpListTablesDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -108,9 +98,6 @@ func (c *Client) addOperationListTablesMiddlewares(stack *middleware.Stack, opti if err = addCredentialSource(stack, options); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "ListTables"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListTagsOfResource.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListTagsOfResource.go index 8168ae37ebc..d2cb3ba68f2 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListTagsOfResource.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_ListTagsOfResource.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // List all tags on an Amazon DynamoDB resource. You can call ListTagsOfResource @@ -80,9 +79,6 @@ func (c *Client) addOperationListTagsOfResourceMiddlewares(stack *middleware.Sta return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -92,13 +88,7 @@ func (c *Client) addOperationListTagsOfResourceMiddlewares(stack *middleware.Sta if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpListTagsOfResourceDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -113,9 +103,6 @@ func (c *Client) addOperationListTagsOfResourceMiddlewares(stack *middleware.Sta if err = addOpListTagsOfResourceValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "ListTagsOfResource"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_PutItem.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_PutItem.go index 03ee5452a98..eaf6ffc189d 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_PutItem.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_PutItem.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Creates a new item, or replaces an old item with a new item. If an item that @@ -74,6 +73,18 @@ type PutItemInput struct { // types for those attributes must match those of the schema in the table's // attribute definition. // + // If the table has vector indexes, the following validations apply to write + // operations. A violation of any of these constraints results in a + // ValidationException : + // + // - The vector attribute must be a list of numbers with dimensions matching the + // index configuration. + // + // - Vector values must fit in 32-bit IEEE-754 floating point format (f32). + // + // - Partition key and inline filter attributes defined in the search schema + // must have data types matching the index schema definition. + // // Empty String and Binary attribute values are allowed. Attribute values of type // String and Binary must have a length greater than zero if the attribute is used // as a key attribute for a table or index. @@ -259,6 +270,9 @@ type PutItemOutput struct { // returned if the ReturnConsumedCapacity parameter was specified. For more // information, see [Capacity unity consumption for write operations]in the Amazon DynamoDB Developer Guide. // + // If the table has vector indexes, the response includes a VectorIndexes field + // with VectorWriteRequestBytes consumed for each affected vector index. + // // [Capacity unity consumption for write operations]: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/read-write-operations.html#write-operation-consumption ConsumedCapacity *types.ConsumedCapacity @@ -299,9 +313,6 @@ func (c *Client) addOperationPutItemMiddlewares(stack *middleware.Stack, options return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -311,13 +322,7 @@ func (c *Client) addOperationPutItemMiddlewares(stack *middleware.Stack, options if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpPutItemDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -332,9 +337,6 @@ func (c *Client) addOperationPutItemMiddlewares(stack *middleware.Stack, options if err = addOpPutItemValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "PutItem"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_PutResourcePolicy.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_PutResourcePolicy.go index a77e8d9b1e9..c35f225481a 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_PutResourcePolicy.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_PutResourcePolicy.go @@ -7,7 +7,6 @@ import ( "fmt" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Attaches a resource-based policy document to the resource, which can be a table @@ -122,9 +121,6 @@ func (c *Client) addOperationPutResourcePolicyMiddlewares(stack *middleware.Stac return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -134,13 +130,7 @@ func (c *Client) addOperationPutResourcePolicyMiddlewares(stack *middleware.Stac if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpPutResourcePolicyDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -155,9 +145,6 @@ func (c *Client) addOperationPutResourcePolicyMiddlewares(stack *middleware.Stac if err = addOpPutResourcePolicyValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "PutResourcePolicy"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_Query.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_Query.go index a7dce4efc89..656b602d936 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_Query.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_Query.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // You must provide the name of the partition key attribute and a single value for @@ -464,9 +463,6 @@ func (c *Client) addOperationQueryMiddlewares(stack *middleware.Stack, options O return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -476,13 +472,7 @@ func (c *Client) addOperationQueryMiddlewares(stack *middleware.Stack, options O if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpQueryDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -497,9 +487,6 @@ func (c *Client) addOperationQueryMiddlewares(stack *middleware.Stack, options O if err = addOpQueryValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "Query"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_RestoreTableFromBackup.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_RestoreTableFromBackup.go index 66b1258a610..ec561631f5c 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_RestoreTableFromBackup.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_RestoreTableFromBackup.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Creates a new table from an existing backup. Any number of users can execute up @@ -80,6 +79,12 @@ type RestoreTableFromBackupInput struct { // The new server-side encryption settings for the restored table. SSESpecificationOverride *types.SSESpecification + // The vector indexes for the restored table. If not specified, all vector indexes + // from the backup are restored. The indexes provided must match existing vector + // indexes from the backup. You can choose to exclude some or all of the vector + // indexes at the time of restore. + VectorIndexOverride []types.VectorIndex + noSmithyDocumentSerde } @@ -110,9 +115,6 @@ func (c *Client) addOperationRestoreTableFromBackupMiddlewares(stack *middleware return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -122,13 +124,7 @@ func (c *Client) addOperationRestoreTableFromBackupMiddlewares(stack *middleware if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpRestoreTableFromBackupDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -143,9 +139,6 @@ func (c *Client) addOperationRestoreTableFromBackupMiddlewares(stack *middleware if err = addOpRestoreTableFromBackupValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "RestoreTableFromBackup"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_RestoreTableToPointInTime.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_RestoreTableToPointInTime.go index 263225c9381..1af64495af5 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_RestoreTableToPointInTime.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_RestoreTableToPointInTime.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" "time" ) @@ -80,6 +79,11 @@ type RestoreTableToPointInTimeInput struct { // List of global secondary indexes for the restored table. The indexes provided // should match existing secondary indexes. You can choose to exclude some or all // of the indexes at the time of restore. + // + // The WarmThroughput setting is not supported on global secondary indexes when + // you use RestoreTableToPointInTime . Although WarmThroughput appears in the + // shared index definition, including it in a GlobalSecondaryIndexOverride entry + // causes the request to fail with a validation error. GlobalSecondaryIndexOverride []types.GlobalSecondaryIndex // List of local secondary indexes for the restored table. The indexes provided @@ -112,6 +116,12 @@ type RestoreTableToPointInTimeInput struct { // typically 5 minutes before the current time. UseLatestRestorableTime *bool + // The vector indexes for the restored table. If not specified, all vector indexes + // from the source table are restored. The indexes provided must match existing + // vector indexes from the source table. You can choose to exclude some or all of + // the vector indexes at the time of restore. + VectorIndexOverride []types.VectorIndex + noSmithyDocumentSerde } @@ -142,9 +152,6 @@ func (c *Client) addOperationRestoreTableToPointInTimeMiddlewares(stack *middlew return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -154,13 +161,7 @@ func (c *Client) addOperationRestoreTableToPointInTimeMiddlewares(stack *middlew if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpRestoreTableToPointInTimeDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -175,9 +176,6 @@ func (c *Client) addOperationRestoreTableToPointInTimeMiddlewares(stack *middlew if err = addOpRestoreTableToPointInTimeValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "RestoreTableToPointInTime"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_Scan.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_Scan.go index 9d4b1805b7b..94e0dcdc9d8 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_Scan.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_Scan.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // The Scan operation returns one or more items and item attributes by accessing @@ -395,9 +394,6 @@ func (c *Client) addOperationScanMiddlewares(stack *middleware.Stack, options Op return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -407,13 +403,7 @@ func (c *Client) addOperationScanMiddlewares(stack *middleware.Stack, options Op if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpScanDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -428,9 +418,6 @@ func (c *Client) addOperationScanMiddlewares(stack *middleware.Stack, options Op if err = addOpScanValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "Scan"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_SearchVectors.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_SearchVectors.go new file mode 100644 index 00000000000..e555ed1ea59 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_SearchVectors.go @@ -0,0 +1,187 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package dynamodb + +import ( + "context" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" + "github.com/aws/smithy-go/middleware" + "github.com/aws/smithy-go/ptr" +) + +// Performs a vector similarity search on a vector index associated with an Amazon +// DynamoDB table, and returns the most similar items sorted by similarity score +// based on the distance function configured for the index. +// +// Score interpretation depends on the distance function: +// +// - COSINE - Returns the items with the k smallest scores. Scores range from 0 +// (identical) to 2 (opposite). Lower scores indicate higher similarity. +// +// - EUCLIDEAN - Returns the items with the k smallest scores. Scores represent +// the Euclidean distance between vectors. Lower scores indicate higher similarity. +// +// - DOT_PRODUCT - Returns the items with the k highest scores. Higher scores +// indicate higher similarity. +func (c *Client) SearchVectors(ctx context.Context, params *SearchVectorsInput, optFns ...func(*Options)) (*SearchVectorsOutput, error) { + if params == nil { + params = &SearchVectorsInput{} + } + + result, metadata, err := c.invokeOperation(ctx, "SearchVectors", params, optFns, c.addOperationSearchVectorsMiddlewares) + if err != nil { + return nil, err + } + + out := result.(*SearchVectorsOutput) + out.ResultMetadata = metadata + return out, nil +} + +type SearchVectorsInput struct { + + // The name of the vector index to search. The index must be in the ACTIVE state. + // + // This member is required. + IndexName *string + + // The search vector to compare against the indexed vectors. Each element is a + // 32-bit IEEE-754 floating point number, provided in DynamoDB list format. + // + // The number of dimensions must match the number of dimensions configured for the + // vector index. + // + // This member is required. + SearchVector []types.AttributeValue + + // The name or Amazon Resource Name (ARN) of the table containing the vector index. + // + // This member is required. + TableName *string + + // The number of most similar results to return. + // + // This member is required. + TopK *int32 + + // One or more substitution tokens for attribute names in an expression. Use the # + // character in an expression to dereference an attribute name. + ExpressionAttributeNames map[string]string + + // One or more values that can be substituted in an expression. Use the : + // character in an expression to dereference an attribute value. + ExpressionAttributeValues map[string]types.AttributeValue + + // A string that identifies one or more attributes to retrieve from the index. + // Separate attribute names with commas. If not specified, the operation returns + // all attributes projected into the vector index. + // + // Only attributes projected into the vector index can be retrieved. + ProjectionExpression *string + + // Determines the level of detail about either provisioned or on-demand throughput + // consumption that is returned in the response: + // + // - INDEXES - The response includes the aggregate ConsumedCapacity for the + // operation, together with ConsumedCapacity for each table and secondary index + // that was accessed. + // + // Note that some operations, such as GetItem and BatchGetItem , do not access any + // indexes at all. In these cases, specifying INDEXES will only return + // ConsumedCapacity information for table(s). + // + // - TOTAL - The response includes only the aggregate ConsumedCapacity for the + // operation. + // + // - NONE - No ConsumedCapacity details are included in the response. + ReturnConsumedCapacity types.ReturnConsumedCapacity + + // A condition expression used to filter the vector search results. The expression + // can reference attributes defined in the vector index search schema, including + // HASH and INLINE_FILTER key elements. + // + // Only the equality operator ( = ) is supported for HASH attributes. Comparison + // and range operators are supported for INLINE_FILTER attributes. Only top-level + // attributes from the search schema can be referenced. + SearchConditionExpression *string + + noSmithyDocumentSerde +} + +func (in *SearchVectorsInput) bindEndpointParams(p *EndpointParameters) { + + p.ResourceArn = in.TableName + p.IsSearchOperation = ptr.Bool(true) +} + +type SearchVectorsOutput struct { + + // The capacity units consumed by the SearchVectors operation. Contains + // VectorSearchRequestBytes , which represents the vector search capacity consumed. + ConsumedCapacity *types.VectorCapacity + + // A list of items returned by the vector similarity search, sorted by similarity + // with the most similar item first. Each item contains the projected attributes + // and a similarity score. + SearchResults []types.SearchResultItem + + // Metadata pertaining to the operation's result. + ResultMetadata middleware.Metadata + + noSmithyDocumentSerde +} + +func (c *Client) addOperationSearchVectorsMiddlewares(stack *middleware.Stack, options Options) (err error) { + err = stack.Serialize.Add(&awsAwsjson10_serializeOpSearchVectors{}, middleware.After) + if err != nil { + return err + } + err = stack.Deserialize.Add(&awsAwsjson10_deserializeOpSearchVectors{}, middleware.After) + if err != nil { + return err + } + + if err = addComputeContentLength(stack); err != nil { + return err + } + if err = addResolveEndpointMiddleware(stack, options); err != nil { + return err + } + if err = addComputePayloadSHA256(stack); err != nil { + return err + } + if err = addRecordResponseTiming(stack, options); err != nil { + return err + } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } + if err = addCredentialSource(stack, options); err != nil { + return err + } + if err = addOpSearchVectorsValidationMiddleware(stack); err != nil { + return err + } + if err = addRequestIDRetrieverMiddleware(stack); err != nil { + return err + } + if err = addResponseErrorMiddleware(stack); err != nil { + return err + } + if err = addValidateResponseChecksum(stack, options); err != nil { + return err + } + if err = addAcceptEncodingGzip(stack, options); err != nil { + return err + } + if err = addRequestResponseLogging(stack, options); err != nil { + return err + } + if err = addDisableHTTPSMiddleware(stack, options); err != nil { + return err + } + if err = addInterceptors(stack, options); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_TagResource.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_TagResource.go index 21c620e2223..32ef83d0e22 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_TagResource.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_TagResource.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Associate a set of tags with an Amazon DynamoDB resource. You can then activate @@ -85,9 +84,6 @@ func (c *Client) addOperationTagResourceMiddlewares(stack *middleware.Stack, opt return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -97,13 +93,7 @@ func (c *Client) addOperationTagResourceMiddlewares(stack *middleware.Stack, opt if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpTagResourceDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -118,9 +108,6 @@ func (c *Client) addOperationTagResourceMiddlewares(stack *middleware.Stack, opt if err = addOpTagResourceValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "TagResource"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_TransactGetItems.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_TransactGetItems.go index a38cd39d6da..cac67e2adfb 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_TransactGetItems.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_TransactGetItems.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // TransactGetItems is a synchronous operation that atomically retrieves multiple @@ -115,9 +114,6 @@ func (c *Client) addOperationTransactGetItemsMiddlewares(stack *middleware.Stack return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -127,13 +123,7 @@ func (c *Client) addOperationTransactGetItemsMiddlewares(stack *middleware.Stack if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpTransactGetItemsDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -148,9 +138,6 @@ func (c *Client) addOperationTransactGetItemsMiddlewares(stack *middleware.Stack if err = addOpTransactGetItemsValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "TransactGetItems"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_TransactWriteItems.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_TransactWriteItems.go index 645f3c25c33..170b7bbf294 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_TransactWriteItems.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_TransactWriteItems.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // TransactWriteItems is a synchronous write operation that groups up to 100 @@ -194,6 +193,9 @@ type TransactWriteItemsOutput struct { // The capacity units consumed by the entire TransactWriteItems operation. The // values of the list are ordered according to the ordering of the TransactItems // request parameter. + // + // If the table has vector indexes, each element also includes a VectorIndexes + // field with VectorWriteRequestBytes consumed for each affected vector index. ConsumedCapacity []types.ConsumedCapacity // A list of tables that were processed by TransactWriteItems and, for each table, @@ -217,9 +219,6 @@ func (c *Client) addOperationTransactWriteItemsMiddlewares(stack *middleware.Sta return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -229,13 +228,7 @@ func (c *Client) addOperationTransactWriteItemsMiddlewares(stack *middleware.Sta if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpTransactWriteItemsDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -253,9 +246,6 @@ func (c *Client) addOperationTransactWriteItemsMiddlewares(stack *middleware.Sta if err = addOpTransactWriteItemsValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "TransactWriteItems"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UntagResource.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UntagResource.go index 14e72c040fe..47ecd60e05c 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UntagResource.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UntagResource.go @@ -7,7 +7,6 @@ import ( "fmt" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Removes the association of tags from an Amazon DynamoDB resource. You can call @@ -83,9 +82,6 @@ func (c *Client) addOperationUntagResourceMiddlewares(stack *middleware.Stack, o return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -95,13 +91,7 @@ func (c *Client) addOperationUntagResourceMiddlewares(stack *middleware.Stack, o if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpUntagResourceDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -116,9 +106,6 @@ func (c *Client) addOperationUntagResourceMiddlewares(stack *middleware.Stack, o if err = addOpUntagResourceValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "UntagResource"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateContinuousBackups.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateContinuousBackups.go index 752380475c5..cd7bb22e57f 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateContinuousBackups.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateContinuousBackups.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // UpdateContinuousBackups enables or disables point in time recovery for the @@ -83,9 +82,6 @@ func (c *Client) addOperationUpdateContinuousBackupsMiddlewares(stack *middlewar return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -95,13 +91,7 @@ func (c *Client) addOperationUpdateContinuousBackupsMiddlewares(stack *middlewar if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpUpdateContinuousBackupsDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -116,9 +106,6 @@ func (c *Client) addOperationUpdateContinuousBackupsMiddlewares(stack *middlewar if err = addOpUpdateContinuousBackupsValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "UpdateContinuousBackups"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateContributorInsights.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateContributorInsights.go index 1e3c0fe374e..12ea7d28cc4 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateContributorInsights.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateContributorInsights.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Updates the status for contributor insights for a specific table or index. @@ -92,9 +91,6 @@ func (c *Client) addOperationUpdateContributorInsightsMiddlewares(stack *middlew return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -104,13 +100,7 @@ func (c *Client) addOperationUpdateContributorInsightsMiddlewares(stack *middlew if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { @@ -122,9 +112,6 @@ func (c *Client) addOperationUpdateContributorInsightsMiddlewares(stack *middlew if err = addOpUpdateContributorInsightsValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "UpdateContributorInsights"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateGlobalTable.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateGlobalTable.go index 7b445278f60..508b1f2e055 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateGlobalTable.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateGlobalTable.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Adds or removes replicas in the specified global table. The global table must @@ -104,9 +103,6 @@ func (c *Client) addOperationUpdateGlobalTableMiddlewares(stack *middleware.Stac return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -116,13 +112,7 @@ func (c *Client) addOperationUpdateGlobalTableMiddlewares(stack *middleware.Stac if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpUpdateGlobalTableDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -137,9 +127,6 @@ func (c *Client) addOperationUpdateGlobalTableMiddlewares(stack *middleware.Stac if err = addOpUpdateGlobalTableValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "UpdateGlobalTable"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateGlobalTableSettings.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateGlobalTableSettings.go index 70dc9187772..a0bd3e8d626 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateGlobalTableSettings.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateGlobalTableSettings.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Updates settings for a global table. @@ -107,9 +106,6 @@ func (c *Client) addOperationUpdateGlobalTableSettingsMiddlewares(stack *middlew return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -119,13 +115,7 @@ func (c *Client) addOperationUpdateGlobalTableSettingsMiddlewares(stack *middlew if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpUpdateGlobalTableSettingsDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -140,9 +130,6 @@ func (c *Client) addOperationUpdateGlobalTableSettingsMiddlewares(stack *middlew if err = addOpUpdateGlobalTableSettingsValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "UpdateGlobalTableSettings"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateItem.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateItem.go index 3d30a2c4ffc..e750d194599 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateItem.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateItem.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Edits an existing item's attributes, or adds a new item to the table if it does @@ -306,6 +305,9 @@ type UpdateItemOutput struct { // returned if the ReturnConsumedCapacity parameter was specified. For more // information, see [Capacity unity consumption for write operations]in the Amazon DynamoDB Developer Guide. // + // If the table has vector indexes, the response includes a VectorIndexes field + // with VectorWriteRequestBytes consumed for each affected vector index. + // // [Capacity unity consumption for write operations]: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/read-write-operations.html#write-operation-consumption ConsumedCapacity *types.ConsumedCapacity @@ -346,9 +348,6 @@ func (c *Client) addOperationUpdateItemMiddlewares(stack *middleware.Stack, opti return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -358,13 +357,7 @@ func (c *Client) addOperationUpdateItemMiddlewares(stack *middleware.Stack, opti if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpUpdateItemDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -379,9 +372,6 @@ func (c *Client) addOperationUpdateItemMiddlewares(stack *middleware.Stack, opti if err = addOpUpdateItemValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "UpdateItem"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateKinesisStreamingDestination.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateKinesisStreamingDestination.go index 0dafb8e9607..6d93c6a79f6 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateKinesisStreamingDestination.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateKinesisStreamingDestination.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // The command to update the Kinesis stream destination. @@ -82,9 +81,6 @@ func (c *Client) addOperationUpdateKinesisStreamingDestinationMiddlewares(stack return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -94,13 +90,7 @@ func (c *Client) addOperationUpdateKinesisStreamingDestinationMiddlewares(stack if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpUpdateKinesisStreamingDestinationDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -115,9 +105,6 @@ func (c *Client) addOperationUpdateKinesisStreamingDestinationMiddlewares(stack if err = addOpUpdateKinesisStreamingDestinationValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "UpdateKinesisStreamingDestination"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateTable.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateTable.go index 3f7b4f6c691..9b51aebdb56 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateTable.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateTable.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Modifies the provisioned throughput settings, global secondary indexes, or @@ -170,6 +169,14 @@ type UpdateTableInput struct { // STANDARD_INFREQUENT_ACCESS . TableClass types.TableClass + // A list of vector indexes to be added to or removed from the table. You can add + // or remove one vector index for each UpdateTable operation. + // + // To add a vector index, specify IndexName , VectorAttribute , Dimensions , + // DistanceFunction , and Projection . To remove a vector index, specify only the + // IndexName . + VectorIndexUpdates []types.VectorIndexUpdate + // Represents the warm throughput (in read units per second and write units per // second) for updating a table. WarmThroughput *types.WarmThroughput @@ -205,9 +212,6 @@ func (c *Client) addOperationUpdateTableMiddlewares(stack *middleware.Stack, opt return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -217,13 +221,7 @@ func (c *Client) addOperationUpdateTableMiddlewares(stack *middleware.Stack, opt if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpUpdateTableDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -238,9 +236,6 @@ func (c *Client) addOperationUpdateTableMiddlewares(stack *middleware.Stack, opt if err = addOpUpdateTableValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "UpdateTable"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateTableReplicaAutoScaling.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateTableReplicaAutoScaling.go index b5170fad1d1..f50b6198516 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateTableReplicaAutoScaling.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateTableReplicaAutoScaling.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Updates auto scaling settings on your global tables at once. @@ -75,9 +74,6 @@ func (c *Client) addOperationUpdateTableReplicaAutoScalingMiddlewares(stack *mid return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -87,13 +83,7 @@ func (c *Client) addOperationUpdateTableReplicaAutoScalingMiddlewares(stack *mid if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { @@ -105,9 +95,6 @@ func (c *Client) addOperationUpdateTableReplicaAutoScalingMiddlewares(stack *mid if err = addOpUpdateTableReplicaAutoScalingValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "UpdateTableReplicaAutoScaling"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateTimeToLive.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateTimeToLive.go index 09b6eec480d..af43b6bf311 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateTimeToLive.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/api_op_UpdateTimeToLive.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // The UpdateTimeToLive method enables or disables Time to Live (TTL) for the @@ -100,9 +99,6 @@ func (c *Client) addOperationUpdateTimeToLiveMiddlewares(stack *middleware.Stack return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -112,13 +108,7 @@ func (c *Client) addOperationUpdateTimeToLiveMiddlewares(stack *middleware.Stack if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addOpUpdateTimeToLiveDiscoverEndpointMiddleware(stack, options, c); err != nil { @@ -133,9 +123,6 @@ func (c *Client) addOperationUpdateTimeToLiveMiddlewares(stack *middleware.Stack if err = addOpUpdateTimeToLiveValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "UpdateTimeToLive"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/deserializers.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/deserializers.go index 9574e794057..db5cd2e7fea 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/deserializers.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/deserializers.go @@ -37,15 +37,18 @@ func (m *awsAwsjson10_deserializeOpBatchExecuteStatement) HandleDeserialize(ctx return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorBatchExecuteStatement(response, &metadata) } @@ -154,15 +157,18 @@ func (m *awsAwsjson10_deserializeOpBatchGetItem) HandleDeserialize(ctx context.C return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorBatchGetItem(response, &metadata) } @@ -280,15 +286,18 @@ func (m *awsAwsjson10_deserializeOpBatchWriteItem) HandleDeserialize(ctx context return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorBatchWriteItem(response, &metadata) } @@ -412,15 +421,18 @@ func (m *awsAwsjson10_deserializeOpCreateBackup) HandleDeserialize(ctx context.C return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorCreateBackup(response, &metadata) } @@ -541,15 +553,18 @@ func (m *awsAwsjson10_deserializeOpCreateGlobalTable) HandleDeserialize(ctx cont return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorCreateGlobalTable(response, &metadata) } @@ -664,15 +679,18 @@ func (m *awsAwsjson10_deserializeOpCreateTable) HandleDeserialize(ctx context.Co return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorCreateTable(response, &metadata) } @@ -784,15 +802,18 @@ func (m *awsAwsjson10_deserializeOpDeleteBackup) HandleDeserialize(ctx context.C return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorDeleteBackup(response, &metadata) } @@ -907,15 +928,18 @@ func (m *awsAwsjson10_deserializeOpDeleteItem) HandleDeserialize(ctx context.Con return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorDeleteItem(response, &metadata) } @@ -1045,15 +1069,18 @@ func (m *awsAwsjson10_deserializeOpDeleteResourcePolicy) HandleDeserialize(ctx c return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorDeleteResourcePolicy(response, &metadata) } @@ -1171,15 +1198,18 @@ func (m *awsAwsjson10_deserializeOpDeleteTable) HandleDeserialize(ctx context.Co return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorDeleteTable(response, &metadata) } @@ -1294,15 +1324,18 @@ func (m *awsAwsjson10_deserializeOpDescribeBackup) HandleDeserialize(ctx context return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorDescribeBackup(response, &metadata) } @@ -1411,15 +1444,18 @@ func (m *awsAwsjson10_deserializeOpDescribeContinuousBackups) HandleDeserialize( return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorDescribeContinuousBackups(response, &metadata) } @@ -1528,15 +1564,18 @@ func (m *awsAwsjson10_deserializeOpDescribeContributorInsights) HandleDeserializ return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorDescribeContributorInsights(response, &metadata) } @@ -1642,15 +1681,18 @@ func (m *awsAwsjson10_deserializeOpDescribeEndpoints) HandleDeserialize(ctx cont return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorDescribeEndpoints(response, &metadata) } @@ -1750,15 +1792,18 @@ func (m *awsAwsjson10_deserializeOpDescribeExport) HandleDeserialize(ctx context return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorDescribeExport(response, &metadata) } @@ -1867,15 +1912,18 @@ func (m *awsAwsjson10_deserializeOpDescribeGlobalTable) HandleDeserialize(ctx co return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorDescribeGlobalTable(response, &metadata) } @@ -1984,15 +2032,18 @@ func (m *awsAwsjson10_deserializeOpDescribeGlobalTableSettings) HandleDeserializ return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorDescribeGlobalTableSettings(response, &metadata) } @@ -2101,15 +2152,18 @@ func (m *awsAwsjson10_deserializeOpDescribeImport) HandleDeserialize(ctx context return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorDescribeImport(response, &metadata) } @@ -2212,15 +2266,18 @@ func (m *awsAwsjson10_deserializeOpDescribeKinesisStreamingDestination) HandleDe return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorDescribeKinesisStreamingDestination(response, &metadata) } @@ -2329,15 +2386,18 @@ func (m *awsAwsjson10_deserializeOpDescribeLimits) HandleDeserialize(ctx context return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorDescribeLimits(response, &metadata) } @@ -2443,15 +2503,18 @@ func (m *awsAwsjson10_deserializeOpDescribeTable) HandleDeserialize(ctx context. return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorDescribeTable(response, &metadata) } @@ -2560,15 +2623,18 @@ func (m *awsAwsjson10_deserializeOpDescribeTableReplicaAutoScaling) HandleDeseri return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorDescribeTableReplicaAutoScaling(response, &metadata) } @@ -2674,15 +2740,18 @@ func (m *awsAwsjson10_deserializeOpDescribeTimeToLive) HandleDeserialize(ctx con return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorDescribeTimeToLive(response, &metadata) } @@ -2791,15 +2860,18 @@ func (m *awsAwsjson10_deserializeOpDisableKinesisStreamingDestination) HandleDes return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorDisableKinesisStreamingDestination(response, &metadata) } @@ -2914,15 +2986,18 @@ func (m *awsAwsjson10_deserializeOpEnableKinesisStreamingDestination) HandleDese return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorEnableKinesisStreamingDestination(response, &metadata) } @@ -3037,17 +3112,20 @@ func (m *awsAwsjson10_deserializeOpExecuteStatement) HandleDeserialize(ctx conte return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } - if response.StatusCode < 200 || response.StatusCode >= 300 { - return out, metadata, awsAwsjson10_deserializeOpErrorExecuteStatement(response, &metadata) + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + + if response.StatusCode < 200 || response.StatusCode >= 300 { + return out, metadata, awsAwsjson10_deserializeOpErrorExecuteStatement(response, &metadata) } output := &ExecuteStatementOutput{} out.Result = output @@ -3172,15 +3250,18 @@ func (m *awsAwsjson10_deserializeOpExecuteTransaction) HandleDeserialize(ctx con return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorExecuteTransaction(response, &metadata) } @@ -3304,15 +3385,18 @@ func (m *awsAwsjson10_deserializeOpExportTableToPointInTime) HandleDeserialize(c return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorExportTableToPointInTime(response, &metadata) } @@ -3430,15 +3514,18 @@ func (m *awsAwsjson10_deserializeOpGetItem) HandleDeserialize(ctx context.Contex return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorGetItem(response, &metadata) } @@ -3556,15 +3643,18 @@ func (m *awsAwsjson10_deserializeOpGetResourcePolicy) HandleDeserialize(ctx cont return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorGetResourcePolicy(response, &metadata) } @@ -3676,15 +3766,18 @@ func (m *awsAwsjson10_deserializeOpImportTable) HandleDeserialize(ctx context.Co return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorImportTable(response, &metadata) } @@ -3793,15 +3886,18 @@ func (m *awsAwsjson10_deserializeOpListBackups) HandleDeserialize(ctx context.Co return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorListBackups(response, &metadata) } @@ -3907,15 +4003,18 @@ func (m *awsAwsjson10_deserializeOpListContributorInsights) HandleDeserialize(ct return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorListContributorInsights(response, &metadata) } @@ -4021,15 +4120,18 @@ func (m *awsAwsjson10_deserializeOpListExports) HandleDeserialize(ctx context.Co return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorListExports(response, &metadata) } @@ -4135,15 +4237,18 @@ func (m *awsAwsjson10_deserializeOpListGlobalTables) HandleDeserialize(ctx conte return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorListGlobalTables(response, &metadata) } @@ -4249,15 +4354,18 @@ func (m *awsAwsjson10_deserializeOpListImports) HandleDeserialize(ctx context.Co return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorListImports(response, &metadata) } @@ -4360,15 +4468,18 @@ func (m *awsAwsjson10_deserializeOpListTables) HandleDeserialize(ctx context.Con return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorListTables(response, &metadata) } @@ -4474,15 +4585,18 @@ func (m *awsAwsjson10_deserializeOpListTagsOfResource) HandleDeserialize(ctx con return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorListTagsOfResource(response, &metadata) } @@ -4591,15 +4705,18 @@ func (m *awsAwsjson10_deserializeOpPutItem) HandleDeserialize(ctx context.Contex return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorPutItem(response, &metadata) } @@ -4729,15 +4846,18 @@ func (m *awsAwsjson10_deserializeOpPutResourcePolicy) HandleDeserialize(ctx cont return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorPutResourcePolicy(response, &metadata) } @@ -4855,15 +4975,18 @@ func (m *awsAwsjson10_deserializeOpQuery) HandleDeserialize(ctx context.Context, return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorQuery(response, &metadata) } @@ -4981,15 +5104,18 @@ func (m *awsAwsjson10_deserializeOpRestoreTableFromBackup) HandleDeserialize(ctx return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorRestoreTableFromBackup(response, &metadata) } @@ -5110,15 +5236,18 @@ func (m *awsAwsjson10_deserializeOpRestoreTableToPointInTime) HandleDeserialize( return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorRestoreTableToPointInTime(response, &metadata) } @@ -5242,15 +5371,18 @@ func (m *awsAwsjson10_deserializeOpScan) HandleDeserialize(ctx context.Context, return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorScan(response, &metadata) } @@ -5353,14 +5485,14 @@ func awsAwsjson10_deserializeOpErrorScan(response *smithyhttp.Response, metadata } } -type awsAwsjson10_deserializeOpTagResource struct { +type awsAwsjson10_deserializeOpSearchVectors struct { } -func (*awsAwsjson10_deserializeOpTagResource) ID() string { +func (*awsAwsjson10_deserializeOpSearchVectors) ID() string { return "OperationDeserializer" } -func (m *awsAwsjson10_deserializeOpTagResource) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( +func (m *awsAwsjson10_deserializeOpSearchVectors) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( out middleware.DeserializeOutput, metadata middleware.Metadata, err error, ) { out, metadata, err = next.HandleDeserialize(ctx, in) @@ -5368,31 +5500,56 @@ func (m *awsAwsjson10_deserializeOpTagResource) HandleDeserialize(ctx context.Co return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { - return out, metadata, awsAwsjson10_deserializeOpErrorTagResource(response, &metadata) + return out, metadata, awsAwsjson10_deserializeOpErrorSearchVectors(response, &metadata) } - output := &TagResourceOutput{} + output := &SearchVectorsOutput{} out.Result = output - if _, err = io.Copy(io.Discard, response.Body); err != nil { - return out, metadata, &smithy.DeserializationError{ - Err: fmt.Errorf("failed to discard response body, %w", err), + var buff [1024]byte + ringBuffer := smithyio.NewRingBuffer(buff[:]) + + body := io.TeeReader(response.Body, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + var shape interface{} + if err := decoder.Decode(&shape); err != nil && err != io.EOF { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return out, metadata, err + } + + err = awsAwsjson10_deserializeOpDocumentSearchVectorsOutput(&output, shape) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), } + return out, metadata, err } return out, metadata, err } -func awsAwsjson10_deserializeOpErrorTagResource(response *smithyhttp.Response, metadata *middleware.Metadata) error { +func awsAwsjson10_deserializeOpErrorSearchVectors(response *smithyhttp.Response, metadata *middleware.Metadata) error { var errorBuffer bytes.Buffer if _, err := io.Copy(&errorBuffer, response.Body); err != nil { return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} @@ -5432,18 +5589,15 @@ func awsAwsjson10_deserializeOpErrorTagResource(response *smithyhttp.Response, m case strings.EqualFold("InternalServerError", errorCode): return awsAwsjson10_deserializeErrorInternalServerError(response, errorBody) - case strings.EqualFold("InvalidEndpointException", errorCode): - return awsAwsjson10_deserializeErrorInvalidEndpointException(response, errorBody) - - case strings.EqualFold("LimitExceededException", errorCode): - return awsAwsjson10_deserializeErrorLimitExceededException(response, errorBody) - - case strings.EqualFold("ResourceInUseException", errorCode): - return awsAwsjson10_deserializeErrorResourceInUseException(response, errorBody) + case strings.EqualFold("RequestLimitExceeded", errorCode): + return awsAwsjson10_deserializeErrorRequestLimitExceeded(response, errorBody) case strings.EqualFold("ResourceNotFoundException", errorCode): return awsAwsjson10_deserializeErrorResourceNotFoundException(response, errorBody) + case strings.EqualFold("ThrottlingException", errorCode): + return awsAwsjson10_deserializeErrorThrottlingException(response, errorBody) + default: genericError := &smithy.GenericAPIError{ Code: errorCode, @@ -5454,14 +5608,14 @@ func awsAwsjson10_deserializeOpErrorTagResource(response *smithyhttp.Response, m } } -type awsAwsjson10_deserializeOpTransactGetItems struct { +type awsAwsjson10_deserializeOpTagResource struct { } -func (*awsAwsjson10_deserializeOpTransactGetItems) ID() string { +func (*awsAwsjson10_deserializeOpTagResource) ID() string { return "OperationDeserializer" } -func (m *awsAwsjson10_deserializeOpTransactGetItems) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( +func (m *awsAwsjson10_deserializeOpTagResource) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( out middleware.DeserializeOutput, metadata middleware.Metadata, err error, ) { out, metadata, err = next.HandleDeserialize(ctx, in) @@ -5469,17 +5623,124 @@ func (m *awsAwsjson10_deserializeOpTransactGetItems) HandleDeserialize(ctx conte return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } - if response.StatusCode < 200 || response.StatusCode >= 300 { - return out, metadata, awsAwsjson10_deserializeOpErrorTransactGetItems(response, &metadata) + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + + if response.StatusCode < 200 || response.StatusCode >= 300 { + return out, metadata, awsAwsjson10_deserializeOpErrorTagResource(response, &metadata) + } + output := &TagResourceOutput{} + out.Result = output + + if _, err = io.Copy(io.Discard, response.Body); err != nil { + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to discard response body, %w", err), + } + } + + return out, metadata, err +} + +func awsAwsjson10_deserializeOpErrorTagResource(response *smithyhttp.Response, metadata *middleware.Metadata) error { + var errorBuffer bytes.Buffer + if _, err := io.Copy(&errorBuffer, response.Body); err != nil { + return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} + } + errorBody := bytes.NewReader(errorBuffer.Bytes()) + + errorCode := "UnknownError" + errorMessage := errorCode + + headerCode := response.Header.Get("X-Amzn-ErrorType") + + var buff [1024]byte + ringBuffer := smithyio.NewRingBuffer(buff[:]) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + bodyInfo, err := getProtocolErrorInfo(decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + errorBody.Seek(0, io.SeekStart) + if typ, ok := resolveProtocolErrorType(headerCode, bodyInfo); ok { + errorCode = restjson.SanitizeErrorCode(typ) + } + if len(bodyInfo.Message) != 0 { + errorMessage = bodyInfo.Message + } + switch { + case strings.EqualFold("InternalServerError", errorCode): + return awsAwsjson10_deserializeErrorInternalServerError(response, errorBody) + + case strings.EqualFold("InvalidEndpointException", errorCode): + return awsAwsjson10_deserializeErrorInvalidEndpointException(response, errorBody) + + case strings.EqualFold("LimitExceededException", errorCode): + return awsAwsjson10_deserializeErrorLimitExceededException(response, errorBody) + + case strings.EqualFold("ResourceInUseException", errorCode): + return awsAwsjson10_deserializeErrorResourceInUseException(response, errorBody) + + case strings.EqualFold("ResourceNotFoundException", errorCode): + return awsAwsjson10_deserializeErrorResourceNotFoundException(response, errorBody) + + default: + genericError := &smithy.GenericAPIError{ + Code: errorCode, + Message: errorMessage, + } + return genericError + + } +} + +type awsAwsjson10_deserializeOpTransactGetItems struct { +} + +func (*awsAwsjson10_deserializeOpTransactGetItems) ID() string { + return "OperationDeserializer" +} + +func (m *awsAwsjson10_deserializeOpTransactGetItems) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( + out middleware.DeserializeOutput, metadata middleware.Metadata, err error, +) { + out, metadata, err = next.HandleDeserialize(ctx, in) + if err != nil { + return out, metadata, err + } + + response, ok := out.RawResponse.(*smithyhttp.Response) + if !ok { + return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} + } + + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + + if response.StatusCode < 200 || response.StatusCode >= 300 { + return out, metadata, awsAwsjson10_deserializeOpErrorTransactGetItems(response, &metadata) } output := &TransactGetItemsOutput{} out.Result = output @@ -5598,15 +5859,18 @@ func (m *awsAwsjson10_deserializeOpTransactWriteItems) HandleDeserialize(ctx con return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorTransactWriteItems(response, &metadata) } @@ -5733,15 +5997,18 @@ func (m *awsAwsjson10_deserializeOpUntagResource) HandleDeserialize(ctx context. return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorUntagResource(response, &metadata) } @@ -5834,15 +6101,18 @@ func (m *awsAwsjson10_deserializeOpUpdateContinuousBackups) HandleDeserialize(ct return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorUpdateContinuousBackups(response, &metadata) } @@ -5954,15 +6224,18 @@ func (m *awsAwsjson10_deserializeOpUpdateContributorInsights) HandleDeserialize( return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorUpdateContributorInsights(response, &metadata) } @@ -6068,15 +6341,18 @@ func (m *awsAwsjson10_deserializeOpUpdateGlobalTable) HandleDeserialize(ctx cont return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorUpdateGlobalTable(response, &metadata) } @@ -6194,15 +6470,18 @@ func (m *awsAwsjson10_deserializeOpUpdateGlobalTableSettings) HandleDeserialize( return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorUpdateGlobalTableSettings(response, &metadata) } @@ -6323,15 +6602,18 @@ func (m *awsAwsjson10_deserializeOpUpdateItem) HandleDeserialize(ctx context.Con return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorUpdateItem(response, &metadata) } @@ -6461,15 +6743,18 @@ func (m *awsAwsjson10_deserializeOpUpdateKinesisStreamingDestination) HandleDese return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorUpdateKinesisStreamingDestination(response, &metadata) } @@ -6584,15 +6869,18 @@ func (m *awsAwsjson10_deserializeOpUpdateTable) HandleDeserialize(ctx context.Co return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorUpdateTable(response, &metadata) } @@ -6707,15 +6995,18 @@ func (m *awsAwsjson10_deserializeOpUpdateTableReplicaAutoScaling) HandleDeserial return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorUpdateTableReplicaAutoScaling(response, &metadata) } @@ -6827,15 +7118,18 @@ func (m *awsAwsjson10_deserializeOpUpdateTimeToLive) HandleDeserialize(ctx conte return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsjson10_deserializeOpErrorUpdateTimeToLive(response, &metadata) } @@ -9865,6 +10159,11 @@ func awsAwsjson10_deserializeDocumentConsumedCapacity(v **types.ConsumedCapacity sv.TableName = ptr.String(jtv) } + case "VectorIndexes": + if err := awsAwsjson10_deserializeDocumentVectorIndexesCapacityMap(&sv.VectorIndexes, value); err != nil { + return err + } + case "WriteCapacityUnits": if value != nil { switch jtv := value.(type) { @@ -15334,7 +15633,7 @@ func awsAwsjson10_deserializeDocumentS3BucketSource(v **types.S3BucketSource, va return nil } -func awsAwsjson10_deserializeDocumentSecondaryIndexesCapacityMap(v *map[string]types.Capacity, value interface{}) error { +func awsAwsjson10_deserializeDocumentSearchResultItem(v **types.SearchResultItem, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } @@ -15347,31 +15646,218 @@ func awsAwsjson10_deserializeDocumentSecondaryIndexesCapacityMap(v *map[string]t return fmt.Errorf("unexpected JSON type %v", value) } - var mv map[string]types.Capacity + var sv *types.SearchResultItem if *v == nil { - mv = map[string]types.Capacity{} + sv = &types.SearchResultItem{} } else { - mv = *v + sv = *v } for key, value := range shape { - var parsedVal types.Capacity - mapVar := parsedVal - destAddr := &mapVar - if err := awsAwsjson10_deserializeDocumentCapacity(&destAddr, value); err != nil { - return err - } - parsedVal = *destAddr - mv[key] = parsedVal + switch key { + case "Item": + if err := awsAwsjson10_deserializeDocumentAttributeMap(&sv.Item, value); err != nil { + return err + } - } - *v = mv - return nil -} + case "Score": + if value != nil { + switch jtv := value.(type) { + case json.Number: + f64, err := jtv.Float64() + if err != nil { + return err + } + sv.Score = f64 -func awsAwsjson10_deserializeDocumentSourceTableDetails(v **types.SourceTableDetails, value interface{}) error { - if v == nil { - return fmt.Errorf("unexpected nil of type %T", v) + case string: + var f64 float64 + switch { + case strings.EqualFold(jtv, "NaN"): + f64 = math.NaN() + + case strings.EqualFold(jtv, "Infinity"): + f64 = math.Inf(1) + + case strings.EqualFold(jtv, "-Infinity"): + f64 = math.Inf(-1) + + default: + return fmt.Errorf("unknown JSON number value: %s", jtv) + + } + sv.Score = f64 + + default: + return fmt.Errorf("expected ScoreNumber to be a JSON Number, got %T instead", value) + + } + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentSearchResultList(v *[]types.SearchResultItem, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.([]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var cv []types.SearchResultItem + if *v == nil { + cv = []types.SearchResultItem{} + } else { + cv = *v + } + + for _, value := range shape { + var col types.SearchResultItem + destAddr := &col + if err := awsAwsjson10_deserializeDocumentSearchResultItem(&destAddr, value); err != nil { + return err + } + col = *destAddr + cv = append(cv, col) + + } + *v = cv + return nil +} + +func awsAwsjson10_deserializeDocumentSearchSchema(v *[]types.SearchSchemaElement, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.([]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var cv []types.SearchSchemaElement + if *v == nil { + cv = []types.SearchSchemaElement{} + } else { + cv = *v + } + + for _, value := range shape { + var col types.SearchSchemaElement + destAddr := &col + if err := awsAwsjson10_deserializeDocumentSearchSchemaElement(&destAddr, value); err != nil { + return err + } + col = *destAddr + cv = append(cv, col) + + } + *v = cv + return nil +} + +func awsAwsjson10_deserializeDocumentSearchSchemaElement(v **types.SearchSchemaElement, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *types.SearchSchemaElement + if *v == nil { + sv = &types.SearchSchemaElement{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "AttributeName": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected AttributeName to be of type string, got %T instead", value) + } + sv.AttributeName = ptr.String(jtv) + } + + case "SearchSchemaElementType": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected SearchSchemaElementType to be of type string, got %T instead", value) + } + sv.SearchSchemaElementType = types.SearchSchemaElementType(jtv) + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentSecondaryIndexesCapacityMap(v *map[string]types.Capacity, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var mv map[string]types.Capacity + if *v == nil { + mv = map[string]types.Capacity{} + } else { + mv = *v + } + + for key, value := range shape { + var parsedVal types.Capacity + mapVar := parsedVal + destAddr := &mapVar + if err := awsAwsjson10_deserializeDocumentCapacity(&destAddr, value); err != nil { + return err + } + parsedVal = *destAddr + mv[key] = parsedVal + + } + *v = mv + return nil +} + +func awsAwsjson10_deserializeDocumentSourceTableDetails(v **types.SourceTableDetails, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil @@ -15540,6 +16026,11 @@ func awsAwsjson10_deserializeDocumentSourceTableFeatureDetails(v **types.SourceT return err } + case "VectorIndexes": + if err := awsAwsjson10_deserializeDocumentVectorIndexes(&sv.VectorIndexes, value); err != nil { + return err + } + default: _, _ = key, value @@ -15986,6 +16477,11 @@ func awsAwsjson10_deserializeDocumentTableCreationParameters(v **types.TableCrea sv.TableName = ptr.String(jtv) } + case "VectorIndexes": + if err := awsAwsjson10_deserializeDocumentVectorIndexList(&sv.VectorIndexes, value); err != nil { + return err + } + default: _, _ = key, value @@ -16219,6 +16715,11 @@ func awsAwsjson10_deserializeDocumentTableDescription(v **types.TableDescription sv.TableStatus = types.TableStatus(jtv) } + case "VectorIndexes": + if err := awsAwsjson10_deserializeDocumentVectorIndexDescriptionList(&sv.VectorIndexes, value); err != nil { + return err + } + case "WarmThroughput": if err := awsAwsjson10_deserializeDocumentTableWarmThroughputDescription(&sv.WarmThroughput, value); err != nil { return err @@ -16574,13 +17075,656 @@ func awsAwsjson10_deserializeDocumentThrottlingReason(v **types.ThrottlingReason sv.Reason = ptr.String(jtv) } - case "resource": - if value != nil { - jtv, ok := value.(string) - if !ok { - return fmt.Errorf("expected Resource to be of type string, got %T instead", value) - } - sv.Resource = ptr.String(jtv) + case "resource": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected Resource to be of type string, got %T instead", value) + } + sv.Resource = ptr.String(jtv) + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentThrottlingReasonList(v *[]types.ThrottlingReason, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.([]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var cv []types.ThrottlingReason + if *v == nil { + cv = []types.ThrottlingReason{} + } else { + cv = *v + } + + for _, value := range shape { + var col types.ThrottlingReason + destAddr := &col + if err := awsAwsjson10_deserializeDocumentThrottlingReason(&destAddr, value); err != nil { + return err + } + col = *destAddr + cv = append(cv, col) + + } + *v = cv + return nil +} + +func awsAwsjson10_deserializeDocumentTimeToLiveDescription(v **types.TimeToLiveDescription, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *types.TimeToLiveDescription + if *v == nil { + sv = &types.TimeToLiveDescription{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "AttributeName": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected TimeToLiveAttributeName to be of type string, got %T instead", value) + } + sv.AttributeName = ptr.String(jtv) + } + + case "TimeToLiveStatus": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected TimeToLiveStatus to be of type string, got %T instead", value) + } + sv.TimeToLiveStatus = types.TimeToLiveStatus(jtv) + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentTimeToLiveSpecification(v **types.TimeToLiveSpecification, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *types.TimeToLiveSpecification + if *v == nil { + sv = &types.TimeToLiveSpecification{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "AttributeName": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected TimeToLiveAttributeName to be of type string, got %T instead", value) + } + sv.AttributeName = ptr.String(jtv) + } + + case "Enabled": + if value != nil { + jtv, ok := value.(bool) + if !ok { + return fmt.Errorf("expected TimeToLiveEnabled to be of type *bool, got %T instead", value) + } + sv.Enabled = ptr.Bool(jtv) + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentTransactionCanceledException(v **types.TransactionCanceledException, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *types.TransactionCanceledException + if *v == nil { + sv = &types.TransactionCanceledException{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "CancellationReasons": + if err := awsAwsjson10_deserializeDocumentCancellationReasonList(&sv.CancellationReasons, value); err != nil { + return err + } + + case "message", "Message": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected ErrorMessage to be of type string, got %T instead", value) + } + sv.Message = ptr.String(jtv) + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentTransactionConflictException(v **types.TransactionConflictException, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *types.TransactionConflictException + if *v == nil { + sv = &types.TransactionConflictException{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "message", "Message": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected ErrorMessage to be of type string, got %T instead", value) + } + sv.Message = ptr.String(jtv) + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentTransactionInProgressException(v **types.TransactionInProgressException, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *types.TransactionInProgressException + if *v == nil { + sv = &types.TransactionInProgressException{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "message", "Message": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected ErrorMessage to be of type string, got %T instead", value) + } + sv.Message = ptr.String(jtv) + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentUpdateKinesisStreamingConfiguration(v **types.UpdateKinesisStreamingConfiguration, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *types.UpdateKinesisStreamingConfiguration + if *v == nil { + sv = &types.UpdateKinesisStreamingConfiguration{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "ApproximateCreationDateTimePrecision": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected ApproximateCreationDateTimePrecision to be of type string, got %T instead", value) + } + sv.ApproximateCreationDateTimePrecision = types.ApproximateCreationDateTimePrecision(jtv) + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentVectorAttributeDefinition(v **types.VectorAttributeDefinition, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *types.VectorAttributeDefinition + if *v == nil { + sv = &types.VectorAttributeDefinition{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "AttributeName": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected VectorAttributeName to be of type string, got %T instead", value) + } + sv.AttributeName = ptr.String(jtv) + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentVectorCapacity(v **types.VectorCapacity, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *types.VectorCapacity + if *v == nil { + sv = &types.VectorCapacity{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "VectorSearchRequestBytes": + if value != nil { + switch jtv := value.(type) { + case json.Number: + f64, err := jtv.Float64() + if err != nil { + return err + } + sv.VectorSearchRequestBytes = ptr.Float64(f64) + + case string: + var f64 float64 + switch { + case strings.EqualFold(jtv, "NaN"): + f64 = math.NaN() + + case strings.EqualFold(jtv, "Infinity"): + f64 = math.Inf(1) + + case strings.EqualFold(jtv, "-Infinity"): + f64 = math.Inf(-1) + + default: + return fmt.Errorf("unknown JSON number value: %s", jtv) + + } + sv.VectorSearchRequestBytes = ptr.Float64(f64) + + default: + return fmt.Errorf("expected ConsumedCapacityUnits to be a JSON Number, got %T instead", value) + + } + } + + case "VectorWriteRequestBytes": + if value != nil { + switch jtv := value.(type) { + case json.Number: + f64, err := jtv.Float64() + if err != nil { + return err + } + sv.VectorWriteRequestBytes = ptr.Float64(f64) + + case string: + var f64 float64 + switch { + case strings.EqualFold(jtv, "NaN"): + f64 = math.NaN() + + case strings.EqualFold(jtv, "Infinity"): + f64 = math.Inf(1) + + case strings.EqualFold(jtv, "-Infinity"): + f64 = math.Inf(-1) + + default: + return fmt.Errorf("unknown JSON number value: %s", jtv) + + } + sv.VectorWriteRequestBytes = ptr.Float64(f64) + + default: + return fmt.Errorf("expected ConsumedCapacityUnits to be a JSON Number, got %T instead", value) + + } + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentVectorIndex(v **types.VectorIndex, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *types.VectorIndex + if *v == nil { + sv = &types.VectorIndex{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "Dimensions": + if value != nil { + jtv, ok := value.(json.Number) + if !ok { + return fmt.Errorf("expected PositiveLongObject to be json.Number, got %T instead", value) + } + i64, err := jtv.Int64() + if err != nil { + return err + } + sv.Dimensions = ptr.Int64(i64) + } + + case "DistanceFunction": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected VectorDistanceFunction to be of type string, got %T instead", value) + } + sv.DistanceFunction = types.VectorDistanceFunction(jtv) + } + + case "IndexName": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected IndexName to be of type string, got %T instead", value) + } + sv.IndexName = ptr.String(jtv) + } + + case "Projection": + if err := awsAwsjson10_deserializeDocumentProjection(&sv.Projection, value); err != nil { + return err + } + + case "SearchSchema": + if err := awsAwsjson10_deserializeDocumentSearchSchema(&sv.SearchSchema, value); err != nil { + return err + } + + case "VectorAttribute": + if err := awsAwsjson10_deserializeDocumentVectorAttributeDefinition(&sv.VectorAttribute, value); err != nil { + return err + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentVectorIndexDescription(v **types.VectorIndexDescription, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *types.VectorIndexDescription + if *v == nil { + sv = &types.VectorIndexDescription{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "Backfilling": + if value != nil { + jtv, ok := value.(bool) + if !ok { + return fmt.Errorf("expected Backfilling to be of type *bool, got %T instead", value) + } + sv.Backfilling = ptr.Bool(jtv) + } + + case "Dimensions": + if value != nil { + jtv, ok := value.(json.Number) + if !ok { + return fmt.Errorf("expected PositiveLongObject to be json.Number, got %T instead", value) + } + i64, err := jtv.Int64() + if err != nil { + return err + } + sv.Dimensions = ptr.Int64(i64) + } + + case "DistanceFunction": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected VectorDistanceFunction to be of type string, got %T instead", value) + } + sv.DistanceFunction = types.VectorDistanceFunction(jtv) + } + + case "IndexArn": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", value) + } + sv.IndexArn = ptr.String(jtv) + } + + case "IndexName": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected IndexName to be of type string, got %T instead", value) + } + sv.IndexName = ptr.String(jtv) + } + + case "IndexSizeBytes": + if value != nil { + jtv, ok := value.(json.Number) + if !ok { + return fmt.Errorf("expected LongObject to be json.Number, got %T instead", value) + } + i64, err := jtv.Int64() + if err != nil { + return err + } + sv.IndexSizeBytes = ptr.Int64(i64) + } + + case "IndexStatus": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected IndexStatus to be of type string, got %T instead", value) + } + sv.IndexStatus = types.IndexStatus(jtv) + } + + case "ItemCount": + if value != nil { + jtv, ok := value.(json.Number) + if !ok { + return fmt.Errorf("expected LongObject to be json.Number, got %T instead", value) + } + i64, err := jtv.Int64() + if err != nil { + return err + } + sv.ItemCount = ptr.Int64(i64) + } + + case "Projection": + if err := awsAwsjson10_deserializeDocumentProjection(&sv.Projection, value); err != nil { + return err + } + + case "SearchSchema": + if err := awsAwsjson10_deserializeDocumentSearchSchema(&sv.SearchSchema, value); err != nil { + return err + } + + case "VectorAttribute": + if err := awsAwsjson10_deserializeDocumentVectorAttributeDefinition(&sv.VectorAttribute, value); err != nil { + return err } default: @@ -16592,7 +17736,7 @@ func awsAwsjson10_deserializeDocumentThrottlingReason(v **types.ThrottlingReason return nil } -func awsAwsjson10_deserializeDocumentThrottlingReasonList(v *[]types.ThrottlingReason, value interface{}) error { +func awsAwsjson10_deserializeDocumentVectorIndexDescriptionList(v *[]types.VectorIndexDescription, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } @@ -16605,17 +17749,17 @@ func awsAwsjson10_deserializeDocumentThrottlingReasonList(v *[]types.ThrottlingR return fmt.Errorf("unexpected JSON type %v", value) } - var cv []types.ThrottlingReason + var cv []types.VectorIndexDescription if *v == nil { - cv = []types.ThrottlingReason{} + cv = []types.VectorIndexDescription{} } else { cv = *v } for _, value := range shape { - var col types.ThrottlingReason + var col types.VectorIndexDescription destAddr := &col - if err := awsAwsjson10_deserializeDocumentThrottlingReason(&destAddr, value); err != nil { + if err := awsAwsjson10_deserializeDocumentVectorIndexDescription(&destAddr, value); err != nil { return err } col = *destAddr @@ -16626,7 +17770,7 @@ func awsAwsjson10_deserializeDocumentThrottlingReasonList(v *[]types.ThrottlingR return nil } -func awsAwsjson10_deserializeDocumentTimeToLiveDescription(v **types.TimeToLiveDescription, value interface{}) error { +func awsAwsjson10_deserializeDocumentVectorIndexes(v *[]types.VectorIndexInfo, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } @@ -16634,48 +17778,33 @@ func awsAwsjson10_deserializeDocumentTimeToLiveDescription(v **types.TimeToLiveD return nil } - shape, ok := value.(map[string]interface{}) + shape, ok := value.([]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } - var sv *types.TimeToLiveDescription + var cv []types.VectorIndexInfo if *v == nil { - sv = &types.TimeToLiveDescription{} + cv = []types.VectorIndexInfo{} } else { - sv = *v + cv = *v } - for key, value := range shape { - switch key { - case "AttributeName": - if value != nil { - jtv, ok := value.(string) - if !ok { - return fmt.Errorf("expected TimeToLiveAttributeName to be of type string, got %T instead", value) - } - sv.AttributeName = ptr.String(jtv) - } - - case "TimeToLiveStatus": - if value != nil { - jtv, ok := value.(string) - if !ok { - return fmt.Errorf("expected TimeToLiveStatus to be of type string, got %T instead", value) - } - sv.TimeToLiveStatus = types.TimeToLiveStatus(jtv) - } - - default: - _, _ = key, value - + for _, value := range shape { + var col types.VectorIndexInfo + destAddr := &col + if err := awsAwsjson10_deserializeDocumentVectorIndexInfo(&destAddr, value); err != nil { + return err } + col = *destAddr + cv = append(cv, col) + } - *v = sv + *v = cv return nil } -func awsAwsjson10_deserializeDocumentTimeToLiveSpecification(v **types.TimeToLiveSpecification, value interface{}) error { +func awsAwsjson10_deserializeDocumentVectorIndexesCapacityMap(v *map[string]types.VectorCapacity, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } @@ -16688,43 +17817,29 @@ func awsAwsjson10_deserializeDocumentTimeToLiveSpecification(v **types.TimeToLiv return fmt.Errorf("unexpected JSON type %v", value) } - var sv *types.TimeToLiveSpecification + var mv map[string]types.VectorCapacity if *v == nil { - sv = &types.TimeToLiveSpecification{} + mv = map[string]types.VectorCapacity{} } else { - sv = *v + mv = *v } for key, value := range shape { - switch key { - case "AttributeName": - if value != nil { - jtv, ok := value.(string) - if !ok { - return fmt.Errorf("expected TimeToLiveAttributeName to be of type string, got %T instead", value) - } - sv.AttributeName = ptr.String(jtv) - } - - case "Enabled": - if value != nil { - jtv, ok := value.(bool) - if !ok { - return fmt.Errorf("expected TimeToLiveEnabled to be of type *bool, got %T instead", value) - } - sv.Enabled = ptr.Bool(jtv) - } - - default: - _, _ = key, value - + var parsedVal types.VectorCapacity + mapVar := parsedVal + destAddr := &mapVar + if err := awsAwsjson10_deserializeDocumentVectorCapacity(&destAddr, value); err != nil { + return err } + parsedVal = *destAddr + mv[key] = parsedVal + } - *v = sv + *v = mv return nil } -func awsAwsjson10_deserializeDocumentTransactionCanceledException(v **types.TransactionCanceledException, value interface{}) error { +func awsAwsjson10_deserializeDocumentVectorIndexInfo(v **types.VectorIndexInfo, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } @@ -16737,107 +17852,59 @@ func awsAwsjson10_deserializeDocumentTransactionCanceledException(v **types.Tran return fmt.Errorf("unexpected JSON type %v", value) } - var sv *types.TransactionCanceledException + var sv *types.VectorIndexInfo if *v == nil { - sv = &types.TransactionCanceledException{} + sv = &types.VectorIndexInfo{} } else { sv = *v } for key, value := range shape { switch key { - case "CancellationReasons": - if err := awsAwsjson10_deserializeDocumentCancellationReasonList(&sv.CancellationReasons, value); err != nil { - return err + case "Dimensions": + if value != nil { + jtv, ok := value.(json.Number) + if !ok { + return fmt.Errorf("expected PositiveLongObject to be json.Number, got %T instead", value) + } + i64, err := jtv.Int64() + if err != nil { + return err + } + sv.Dimensions = ptr.Int64(i64) } - case "message", "Message": + case "DistanceFunction": if value != nil { jtv, ok := value.(string) if !ok { - return fmt.Errorf("expected ErrorMessage to be of type string, got %T instead", value) + return fmt.Errorf("expected VectorDistanceFunction to be of type string, got %T instead", value) } - sv.Message = ptr.String(jtv) + sv.DistanceFunction = types.VectorDistanceFunction(jtv) } - default: - _, _ = key, value - - } - } - *v = sv - return nil -} - -func awsAwsjson10_deserializeDocumentTransactionConflictException(v **types.TransactionConflictException, value interface{}) error { - if v == nil { - return fmt.Errorf("unexpected nil of type %T", v) - } - if value == nil { - return nil - } - - shape, ok := value.(map[string]interface{}) - if !ok { - return fmt.Errorf("unexpected JSON type %v", value) - } - - var sv *types.TransactionConflictException - if *v == nil { - sv = &types.TransactionConflictException{} - } else { - sv = *v - } - - for key, value := range shape { - switch key { - case "message", "Message": + case "IndexName": if value != nil { jtv, ok := value.(string) if !ok { - return fmt.Errorf("expected ErrorMessage to be of type string, got %T instead", value) + return fmt.Errorf("expected IndexName to be of type string, got %T instead", value) } - sv.Message = ptr.String(jtv) + sv.IndexName = ptr.String(jtv) } - default: - _, _ = key, value - - } - } - *v = sv - return nil -} - -func awsAwsjson10_deserializeDocumentTransactionInProgressException(v **types.TransactionInProgressException, value interface{}) error { - if v == nil { - return fmt.Errorf("unexpected nil of type %T", v) - } - if value == nil { - return nil - } - - shape, ok := value.(map[string]interface{}) - if !ok { - return fmt.Errorf("unexpected JSON type %v", value) - } + case "Projection": + if err := awsAwsjson10_deserializeDocumentProjection(&sv.Projection, value); err != nil { + return err + } - var sv *types.TransactionInProgressException - if *v == nil { - sv = &types.TransactionInProgressException{} - } else { - sv = *v - } + case "SearchSchema": + if err := awsAwsjson10_deserializeDocumentSearchSchema(&sv.SearchSchema, value); err != nil { + return err + } - for key, value := range shape { - switch key { - case "message", "Message": - if value != nil { - jtv, ok := value.(string) - if !ok { - return fmt.Errorf("expected ErrorMessage to be of type string, got %T instead", value) - } - sv.Message = ptr.String(jtv) + case "VectorAttribute": + if err := awsAwsjson10_deserializeDocumentVectorAttributeDefinition(&sv.VectorAttribute, value); err != nil { + return err } default: @@ -16849,7 +17916,7 @@ func awsAwsjson10_deserializeDocumentTransactionInProgressException(v **types.Tr return nil } -func awsAwsjson10_deserializeDocumentUpdateKinesisStreamingConfiguration(v **types.UpdateKinesisStreamingConfiguration, value interface{}) error { +func awsAwsjson10_deserializeDocumentVectorIndexList(v *[]types.VectorIndex, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } @@ -16857,35 +17924,29 @@ func awsAwsjson10_deserializeDocumentUpdateKinesisStreamingConfiguration(v **typ return nil } - shape, ok := value.(map[string]interface{}) + shape, ok := value.([]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } - var sv *types.UpdateKinesisStreamingConfiguration + var cv []types.VectorIndex if *v == nil { - sv = &types.UpdateKinesisStreamingConfiguration{} + cv = []types.VectorIndex{} } else { - sv = *v + cv = *v } - for key, value := range shape { - switch key { - case "ApproximateCreationDateTimePrecision": - if value != nil { - jtv, ok := value.(string) - if !ok { - return fmt.Errorf("expected ApproximateCreationDateTimePrecision to be of type string, got %T instead", value) - } - sv.ApproximateCreationDateTimePrecision = types.ApproximateCreationDateTimePrecision(jtv) - } - - default: - _, _ = key, value - + for _, value := range shape { + var col types.VectorIndex + destAddr := &col + if err := awsAwsjson10_deserializeDocumentVectorIndex(&destAddr, value); err != nil { + return err } + col = *destAddr + cv = append(cv, col) + } - *v = sv + *v = cv return nil } @@ -19011,6 +20072,47 @@ func awsAwsjson10_deserializeOpDocumentScanOutput(v **ScanOutput, value interfac return nil } +func awsAwsjson10_deserializeOpDocumentSearchVectorsOutput(v **SearchVectorsOutput, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *SearchVectorsOutput + if *v == nil { + sv = &SearchVectorsOutput{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "ConsumedCapacity": + if err := awsAwsjson10_deserializeDocumentVectorCapacity(&sv.ConsumedCapacity, value); err != nil { + return err + } + + case "SearchResults": + if err := awsAwsjson10_deserializeDocumentSearchResultList(&sv.SearchResults, value); err != nil { + return err + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + func awsAwsjson10_deserializeOpDocumentTransactGetItemsOutput(v **TransactGetItemsOutput, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/endpoints.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/endpoints.go index 4cf69274193..96da0657c65 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/endpoints.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/endpoints.go @@ -296,6 +296,12 @@ type EndpointParameters struct { // // Parameter is required. ResourceArnList []string + + // Set to true for SearchVectors to route to the Search FQDN + // + // Parameter is + // required. + IsSearchOperation *bool } // ValidateRequired validates required parameters are set. @@ -326,11 +332,12 @@ func (p EndpointParameters) WithDefaults() EndpointParameters { const bddRoot int32 = 2 -var bddNodes = [201]int32{ - -1, 1, -1, 0, 5, 3, 1, 4, 100000025, 2, 100000001, 65, 1, 63, 6, 2, 52, 7, 3, 8, 100000025, 4, 51, 9, 6, 30, 10, 9, 11, 100000011, 10, 13, 12, 26, 100000019, 100000011, 11, 29, 14, 12, 15, 20, 13, 16, 20, 14, 17, 20, 15, 18, 20, 16, 19, 20, 17, 100000022, 20, 18, 21, 27, 19, 22, 27, 20, 23, 27, 21, 24, 27, 22, 25, 27, 23, 26, 27, 24, 100000023, 27, 25, 28, 29, 27, 100000024, 100000017, 26, 100000018, 100000011, 7, 31, 100000021, 9, 32, 100000020, 10, 34, 33, 26, 100000019, 100000020, 11, 50, 35, 12, 36, 41, 13, 37, 41, 14, 38, 41, 15, 39, 41, 16, 40, 41, 17, 100000014, 41, 18, 42, 48, 19, 43, 48, 20, 44, 48, 21, 45, 48, 22, 46, 48, 23, 47, 48, 24, 100000015, 48, 25, 49, 50, 27, 100000016, 100000017, 26, 100000018, 100000020, 6, 100000006, 100000007, 3, 53, 100000025, 4, 100000005, 54, 5, 56, 55, 6, 100000010, 100000013, 6, 60, 57, 9, 58, 59, 26, 100000008, 59, 28, 100000011, 100000012, 7, 61, 100000010, 9, 62, 100000009, 26, 100000008, 100000009, 2, 100000001, 64, 3, 66, 65, 6, 100000002, 100000004, 6, 100000002, 67, 8, 100000003, 100000004} +var bddNodes = [246]int32{ + -1, 1, -1, 0, 6, 3, 1, 4, 100000035, 2, 100000001, 5, 3, 100000002, 100000004, 1, 77, 7, 2, 61, 8, 3, 34, 9, 4, 10, 100000035, 5, 100000007, 11, 11, 12, 69, 12, 14, 13, 28, 100000025, 69, 13, 33, 15, 14, 16, 21, 15, 17, 21, 16, 18, 21, 17, 19, 21, 18, 20, 21, 19, 32, 21, 20, 22, 28, 21, 23, 28, 22, 24, 28, 23, 25, 28, 24, 26, 28, 25, 27, 28, 26, 31, 28, 27, 29, 33, 29, 30, 100000023, 31, 100000033, 100000034, 31, 100000031, 100000032, 31, 100000029, 100000030, 28, 100000024, 69, 4, 35, 100000035, 5, 100000006, 36, 9, 37, 100000028, 11, 38, 60, 12, 40, 39, 28, 100000025, 60, 13, 59, 41, 14, 42, 47, 15, 43, 47, 16, 44, 47, 17, 45, 47, 18, 46, 47, 19, 58, 47, 20, 48, 54, 21, 49, 54, 22, 50, 54, 23, 51, 54, 24, 52, 54, 25, 53, 54, 26, 57, 54, 27, 55, 59, 29, 56, 100000023, 31, 100000021, 100000022, 31, 100000019, 100000020, 31, 100000017, 100000018, 28, 100000024, 60, 31, 100000026, 100000027, 3, 70, 62, 4, 63, 100000035, 5, 100000005, 64, 6, 65, 100000016, 11, 66, 67, 28, 100000008, 67, 30, 69, 68, 31, 100000014, 100000015, 31, 100000012, 100000013, 4, 71, 100000035, 5, 100000005, 72, 6, 73, 100000011, 9, 74, 100000011, 11, 75, 76, 28, 100000008, 76, 31, 100000009, 100000010, 2, 100000001, 78, 3, 100000002, 79, 4, 80, 100000004, 7, 81, 100000004, 8, 100000003, 82, 10, 100000003, 100000004} type conditionContext struct { PartitionResult *awsrulesfn.PartitionConfig + parsedEndpoint *rulesfn.URL ParsedArn_ssa_2 *awsrulesfn.ARN FirstArn *string ParsedArn_ssa_1 *awsrulesfn.ARN @@ -345,80 +352,102 @@ func evalCondition(idx int, params *EndpointParameters, c *conditionContext) boo case 2: return *params.UseFIPS == true case 3: + return *params.UseDualStack == true + case 4: if v := awsrulesfn.GetPartition(*params.Region); v != nil { c.PartitionResult = v return true } return false - case 4: - return *params.Region == "local" case 5: - return c.PartitionResult.SupportsFIPS == true + return *params.Region == "local" case 6: - return *params.UseDualStack == true + return c.PartitionResult.SupportsFIPS == true case 7: - return c.PartitionResult.SupportsDualStack == true + if v := rulesfn.ParseURL(*params.Endpoint); v != nil { + c.parsedEndpoint = v + return true + } + return false case 8: return func() string { var out strings.Builder - out.WriteString("https://dynamodb.") + out.WriteString("dynamodb.") out.WriteString(*params.Region) out.WriteString(".") out.WriteString(c.PartitionResult.DualStackDnsSuffix) return out.String() - }() == *params.Endpoint + }() == c.parsedEndpoint.Authority case 9: - return params.AccountIdEndpointMode != nil + return c.PartitionResult.SupportsDualStack == true case 10: - return c.PartitionResult.Name == "aws" + return func() string { + var out strings.Builder + out.WriteString("search-dynamodb.") + out.WriteString(*params.Region) + out.WriteString(".") + out.WriteString(c.PartitionResult.DualStackDnsSuffix) + return out.String() + }() == c.parsedEndpoint.Authority case 11: - return *params.AccountIdEndpointMode == "disabled" + return params.AccountIdEndpointMode != nil case 12: - return params.ResourceArn != nil + return c.PartitionResult.Name == "aws" case 13: + return *params.AccountIdEndpointMode == "disabled" + case 14: + return params.ResourceArn != nil + case 15: if v := awsrulesfn.ParseARN(*params.ResourceArn); v != nil { c.ParsedArn_ssa_2 = v return true } return false - case 14: - return c.ParsedArn_ssa_2.Region == *params.Region - case 15: - return c.ParsedArn_ssa_2.Service == "dynamodb" case 16: - return rulesfn.IsValidHostLabel(c.ParsedArn_ssa_2.AccountId, false) + return c.ParsedArn_ssa_2.Region == *params.Region case 17: - return rulesfn.IsValidHostLabel(c.ParsedArn_ssa_2.Region, false) + return c.ParsedArn_ssa_2.Service == "dynamodb" case 18: - return params.ResourceArnList != nil + return rulesfn.IsValidHostLabel(c.ParsedArn_ssa_2.Region, false) case 19: + return rulesfn.IsValidHostLabel(c.ParsedArn_ssa_2.AccountId, false) + case 20: + return params.ResourceArnList != nil + case 21: if v := rulesfn.StringSlice(params.ResourceArnList).Get(0); v != nil { c.FirstArn = v return true } return false - case 20: + case 22: if v := awsrulesfn.ParseARN(*c.FirstArn); v != nil { c.ParsedArn_ssa_1 = v return true } return false - case 21: + case 23: return c.ParsedArn_ssa_1.Region == *params.Region - case 22: + case 24: return c.ParsedArn_ssa_1.Service == "dynamodb" - case 23: + case 25: return rulesfn.IsValidHostLabel(c.ParsedArn_ssa_1.AccountId, false) - case 24: + case 26: return rulesfn.IsValidHostLabel(c.ParsedArn_ssa_1.Region, false) - case 25: + case 27: return params.AccountId != nil - case 26: + case 28: return *params.AccountIdEndpointMode == "required" - case 27: + case 29: return rulesfn.IsValidHostLabel(*params.AccountId, false) - case 28: + case 30: return c.PartitionResult.Name == "aws-us-gov" + case 31: + return func() bool { + if v := params.IsSearchOperation; v != nil { + return *v + } + return false + }() == true } return false } @@ -463,10 +492,10 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( SchemeID: "sigv4", SignerProperties: func() smithy.Properties { var sp smithy.Properties + smithyhttp.SetSigV4SigningRegion(&sp, "us-east-1") + smithyhttp.SetSigV4SigningName(&sp, "dynamodb") smithyhttp.SetSigV4ASigningName(&sp, "dynamodb") - - smithyhttp.SetSigV4SigningRegion(&sp, "us-east-1") return sp }(), }, @@ -479,7 +508,7 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( case 9: uriString := func() string { var out strings.Builder - out.WriteString("https://dynamodb-fips.") + out.WriteString("https://search-dynamodb-fips.") out.WriteString(*params.Region) out.WriteString(".") out.WriteString(c.PartitionResult.DualStackDnsSuffix) @@ -494,8 +523,42 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( Headers: http.Header{}, }, nil case 10: - return smithyendpoints.Endpoint{}, fmt.Errorf("endpoint rule error, %s", "FIPS and DualStack are enabled, but this partition does not support one or both") + uriString := func() string { + var out strings.Builder + out.WriteString("https://dynamodb-fips.") + out.WriteString(*params.Region) + out.WriteString(".") + out.WriteString(c.PartitionResult.DualStackDnsSuffix) + return out.String() + }() + uri, err := url.Parse(uriString) + if err != nil { + return smithyendpoints.Endpoint{}, fmt.Errorf("Failed to parse uri: %s", uriString) + } + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + }, nil case 11: + return smithyendpoints.Endpoint{}, fmt.Errorf("endpoint rule error, %s", "FIPS and DualStack are enabled, but this partition does not support one or both") + case 12: + uriString := func() string { + var out strings.Builder + out.WriteString("https://search-dynamodb.") + out.WriteString(*params.Region) + out.WriteString(".") + out.WriteString(c.PartitionResult.DnsSuffix) + return out.String() + }() + uri, err := url.Parse(uriString) + if err != nil { + return smithyendpoints.Endpoint{}, fmt.Errorf("Failed to parse uri: %s", uriString) + } + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + }, nil + case 13: uriString := func() string { var out strings.Builder out.WriteString("https://dynamodb.") @@ -512,7 +575,24 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( URI: *uri, Headers: http.Header{}, }, nil - case 12: + case 14: + uriString := func() string { + var out strings.Builder + out.WriteString("https://search-dynamodb-fips.") + out.WriteString(*params.Region) + out.WriteString(".") + out.WriteString(c.PartitionResult.DnsSuffix) + return out.String() + }() + uri, err := url.Parse(uriString) + if err != nil { + return smithyendpoints.Endpoint{}, fmt.Errorf("Failed to parse uri: %s", uriString) + } + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + }, nil + case 15: uriString := func() string { var out strings.Builder out.WriteString("https://dynamodb-fips.") @@ -529,9 +609,35 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( URI: *uri, Headers: http.Header{}, }, nil - case 13: + case 16: return smithyendpoints.Endpoint{}, fmt.Errorf("endpoint rule error, %s", "FIPS is enabled but this partition does not support FIPS") - case 14: + case 17: + uriString := func() string { + var out strings.Builder + out.WriteString("https://") + out.WriteString(c.ParsedArn_ssa_2.AccountId) + out.WriteString(".search-ddb.") + out.WriteString(*params.Region) + out.WriteString(".") + out.WriteString(c.PartitionResult.DualStackDnsSuffix) + return out.String() + }() + uri, err := url.Parse(uriString) + if err != nil { + return smithyendpoints.Endpoint{}, fmt.Errorf("Failed to parse uri: %s", uriString) + } + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: func() smithy.Properties { + var out smithy.Properties + out.Set("metricValues", []interface{}{ + "O", + }) + return out + }(), + }, nil + case 18: uriString := func() string { var out strings.Builder out.WriteString("https://") @@ -557,7 +663,33 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( return out }(), }, nil - case 15: + case 19: + uriString := func() string { + var out strings.Builder + out.WriteString("https://") + out.WriteString(c.ParsedArn_ssa_1.AccountId) + out.WriteString(".search-ddb.") + out.WriteString(*params.Region) + out.WriteString(".") + out.WriteString(c.PartitionResult.DualStackDnsSuffix) + return out.String() + }() + uri, err := url.Parse(uriString) + if err != nil { + return smithyendpoints.Endpoint{}, fmt.Errorf("Failed to parse uri: %s", uriString) + } + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: func() smithy.Properties { + var out smithy.Properties + out.Set("metricValues", []interface{}{ + "O", + }) + return out + }(), + }, nil + case 20: uriString := func() string { var out strings.Builder out.WriteString("https://") @@ -583,7 +715,33 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( return out }(), }, nil - case 16: + case 21: + uriString := func() string { + var out strings.Builder + out.WriteString("https://") + out.WriteString(*params.AccountId) + out.WriteString(".search-ddb.") + out.WriteString(*params.Region) + out.WriteString(".") + out.WriteString(c.PartitionResult.DualStackDnsSuffix) + return out.String() + }() + uri, err := url.Parse(uriString) + if err != nil { + return smithyendpoints.Endpoint{}, fmt.Errorf("Failed to parse uri: %s", uriString) + } + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: func() smithy.Properties { + var out smithy.Properties + out.Set("metricValues", []interface{}{ + "O", + }) + return out + }(), + }, nil + case 22: uriString := func() string { var out strings.Builder out.WriteString("https://") @@ -609,13 +767,30 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( return out }(), }, nil - case 17: + case 23: return smithyendpoints.Endpoint{}, fmt.Errorf("endpoint rule error, %s", "Credentials-sourced account ID parameter is invalid") - case 18: + case 24: return smithyendpoints.Endpoint{}, fmt.Errorf("endpoint rule error, %s", "AccountIdEndpointMode is required but no AccountID was provided or able to be loaded") - case 19: + case 25: return smithyendpoints.Endpoint{}, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: AccountIdEndpointMode is required but account endpoints are not supported in this partition") - case 20: + case 26: + uriString := func() string { + var out strings.Builder + out.WriteString("https://search-dynamodb.") + out.WriteString(*params.Region) + out.WriteString(".") + out.WriteString(c.PartitionResult.DualStackDnsSuffix) + return out.String() + }() + uri, err := url.Parse(uriString) + if err != nil { + return smithyendpoints.Endpoint{}, fmt.Errorf("Failed to parse uri: %s", uriString) + } + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + }, nil + case 27: uriString := func() string { var out strings.Builder out.WriteString("https://dynamodb.") @@ -632,9 +807,35 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( URI: *uri, Headers: http.Header{}, }, nil - case 21: + case 28: return smithyendpoints.Endpoint{}, fmt.Errorf("endpoint rule error, %s", "DualStack is enabled but this partition does not support DualStack") - case 22: + case 29: + uriString := func() string { + var out strings.Builder + out.WriteString("https://") + out.WriteString(c.ParsedArn_ssa_2.AccountId) + out.WriteString(".search-ddb.") + out.WriteString(*params.Region) + out.WriteString(".") + out.WriteString(c.PartitionResult.DnsSuffix) + return out.String() + }() + uri, err := url.Parse(uriString) + if err != nil { + return smithyendpoints.Endpoint{}, fmt.Errorf("Failed to parse uri: %s", uriString) + } + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: func() smithy.Properties { + var out smithy.Properties + out.Set("metricValues", []interface{}{ + "O", + }) + return out + }(), + }, nil + case 30: uriString := func() string { var out strings.Builder out.WriteString("https://") @@ -660,7 +861,33 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( return out }(), }, nil - case 23: + case 31: + uriString := func() string { + var out strings.Builder + out.WriteString("https://") + out.WriteString(c.ParsedArn_ssa_1.AccountId) + out.WriteString(".search-ddb.") + out.WriteString(*params.Region) + out.WriteString(".") + out.WriteString(c.PartitionResult.DnsSuffix) + return out.String() + }() + uri, err := url.Parse(uriString) + if err != nil { + return smithyendpoints.Endpoint{}, fmt.Errorf("Failed to parse uri: %s", uriString) + } + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: func() smithy.Properties { + var out smithy.Properties + out.Set("metricValues", []interface{}{ + "O", + }) + return out + }(), + }, nil + case 32: uriString := func() string { var out strings.Builder out.WriteString("https://") @@ -686,7 +913,33 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( return out }(), }, nil - case 24: + case 33: + uriString := func() string { + var out strings.Builder + out.WriteString("https://") + out.WriteString(*params.AccountId) + out.WriteString(".search-ddb.") + out.WriteString(*params.Region) + out.WriteString(".") + out.WriteString(c.PartitionResult.DnsSuffix) + return out.String() + }() + uri, err := url.Parse(uriString) + if err != nil { + return smithyendpoints.Endpoint{}, fmt.Errorf("Failed to parse uri: %s", uriString) + } + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: func() smithy.Properties { + var out smithy.Properties + out.Set("metricValues", []interface{}{ + "O", + }) + return out + }(), + }, nil + case 34: uriString := func() string { var out strings.Builder out.WriteString("https://") @@ -712,7 +965,7 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( return out }(), }, nil - case 25: + case 35: return smithyendpoints.Endpoint{}, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: Missing Region") } return smithyendpoints.Endpoint{}, fmt.Errorf("endpoint rule error, invalid result index: %d", idx) diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/generated.json b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/generated.json index f306b0cb12e..8725d337e50 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/generated.json +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/generated.json @@ -54,6 +54,7 @@ "api_op_RestoreTableFromBackup.go", "api_op_RestoreTableToPointInTime.go", "api_op_Scan.go", + "api_op_SearchVectors.go", "api_op_TagResource.go", "api_op_TransactGetItems.go", "api_op_TransactWriteItems.go", @@ -77,6 +78,8 @@ "internal/endpoints/endpoints.go", "internal/endpoints/endpoints_test.go", "options.go", + "request_snapshot_test.go", + "response_snapshot_test.go", "serializers.go", "snapshot_test.go", "sra_operation_order_test.go", diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/go_module_metadata.go index 5c7766d0f2a..7894a4ce7b4 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/go_module_metadata.go @@ -3,4 +3,4 @@ package dynamodb // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.59.1" +const goModuleVersion = "1.63.3" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/options.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/options.go index 5db1ed2b917..c74fb1f830b 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/options.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/options.go @@ -47,6 +47,11 @@ type Options struct { // clients initial default settings. DefaultsMode aws.DefaultsMode + // Disables SDK clock skew correction. When set, the SDK will not adjust request + // signing timestamps to compensate for clock drift between the client and the + // service. + DisableClockSkewCorrection bool + // Allows you to disable the client's validation of response integrity using CRC32 // checksum. Enabled by default. DisableValidateResponseChecksum bool diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/serializers.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/serializers.go index 5316f9f4abd..a425e77f8b8 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/serializers.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/serializers.go @@ -2702,6 +2702,67 @@ func (m *awsAwsjson10_serializeOpScan) HandleSerialize(ctx context.Context, in m return next.HandleSerialize(ctx, in) } +type awsAwsjson10_serializeOpSearchVectors struct { +} + +func (*awsAwsjson10_serializeOpSearchVectors) ID() string { + return "OperationSerializer" +} + +func (m *awsAwsjson10_serializeOpSearchVectors) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( + out middleware.SerializeOutput, metadata middleware.Metadata, err error, +) { + _, span := tracing.StartSpan(ctx, "OperationSerializer") + endTimer := startMetricTimer(ctx, "client.call.serialization_duration") + defer endTimer() + defer span.End() + request, ok := in.Request.(*smithyhttp.Request) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} + } + + input, ok := in.Parameters.(*SearchVectorsInput) + _ = input + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} + } + + operationPath := "/" + if len(request.Request.URL.Path) == 0 { + request.Request.URL.Path = operationPath + } else { + request.Request.URL.Path = path.Join(request.Request.URL.Path, operationPath) + if request.Request.URL.Path != "/" && operationPath[len(operationPath)-1] == '/' { + request.Request.URL.Path += "/" + } + } + request.Request.Method = "POST" + httpBindingEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) + if err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") + httpBindingEncoder.SetHeader("X-Amz-Target").String("DynamoDB_20120810.SearchVectors") + + jsonEncoder := smithyjson.NewEncoder() + if err := awsAwsjson10_serializeOpDocumentSearchVectorsInput(input, jsonEncoder.Value); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if request.Request, err = httpBindingEncoder.Encode(request.Request); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + in.Request = request + + endTimer() + span.End() + return next.HandleSerialize(ctx, in) +} + type awsAwsjson10_serializeOpTagResource struct { } @@ -3988,6 +4049,49 @@ func awsAwsjson10_serializeDocumentCreateReplicationGroupMemberAction(v *types.C return nil } +func awsAwsjson10_serializeDocumentCreateVectorIndexAction(v *types.CreateVectorIndexAction, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + if v.Dimensions != nil { + ok := object.Key("Dimensions") + ok.Long(*v.Dimensions) + } + + if len(v.DistanceFunction) > 0 { + ok := object.Key("DistanceFunction") + ok.String(string(v.DistanceFunction)) + } + + if v.IndexName != nil { + ok := object.Key("IndexName") + ok.String(*v.IndexName) + } + + if v.Projection != nil { + ok := object.Key("Projection") + if err := awsAwsjson10_serializeDocumentProjection(v.Projection, ok); err != nil { + return err + } + } + + if v.SearchSchema != nil { + ok := object.Key("SearchSchema") + if err := awsAwsjson10_serializeDocumentSearchSchema(v.SearchSchema, ok); err != nil { + return err + } + } + + if v.VectorAttribute != nil { + ok := object.Key("VectorAttribute") + if err := awsAwsjson10_serializeDocumentVectorAttributeDefinition(v.VectorAttribute, ok); err != nil { + return err + } + } + + return nil +} + func awsAwsjson10_serializeDocumentCsvHeaderList(v []string, value smithyjson.Value) error { array := value.Array() defer array.Close() @@ -4123,6 +4227,18 @@ func awsAwsjson10_serializeDocumentDeleteRequest(v *types.DeleteRequest, value s return nil } +func awsAwsjson10_serializeDocumentDeleteVectorIndexAction(v *types.DeleteVectorIndexAction, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + if v.IndexName != nil { + ok := object.Key("IndexName") + ok.String(*v.IndexName) + } + + return nil +} + func awsAwsjson10_serializeDocumentEnableKinesisStreamingConfiguration(v *types.EnableKinesisStreamingConfiguration, value smithyjson.Value) error { object := value.Object() defer object.Close() @@ -5250,6 +5366,52 @@ func awsAwsjson10_serializeDocumentS3BucketSource(v *types.S3BucketSource, value return nil } +func awsAwsjson10_serializeDocumentSearchSchema(v []types.SearchSchemaElement, value smithyjson.Value) error { + array := value.Array() + defer array.Close() + + for i := range v { + av := array.Value() + if err := awsAwsjson10_serializeDocumentSearchSchemaElement(&v[i], av); err != nil { + return err + } + } + return nil +} + +func awsAwsjson10_serializeDocumentSearchSchemaElement(v *types.SearchSchemaElement, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + if v.AttributeName != nil { + ok := object.Key("AttributeName") + ok.String(*v.AttributeName) + } + + if len(v.SearchSchemaElementType) > 0 { + ok := object.Key("SearchSchemaElementType") + ok.String(string(v.SearchSchemaElementType)) + } + + return nil +} + +func awsAwsjson10_serializeDocumentSearchVectorList(v []types.AttributeValue, value smithyjson.Value) error { + array := value.Array() + defer array.Close() + + for i := range v { + av := array.Value() + if vv := v[i]; vv == nil { + continue + } + if err := awsAwsjson10_serializeDocumentAttributeValue(v[i], av); err != nil { + return err + } + } + return nil +} + func awsAwsjson10_serializeDocumentSSESpecification(v *types.SSESpecification, value smithyjson.Value) error { object := value.Object() defer object.Close() @@ -5356,6 +5518,13 @@ func awsAwsjson10_serializeDocumentTableCreationParameters(v *types.TableCreatio ok.String(*v.TableName) } + if v.VectorIndexes != nil { + ok := object.Key("VectorIndexes") + if err := awsAwsjson10_serializeDocumentVectorIndexList(v.VectorIndexes, ok); err != nil { + return err + } + } + return nil } @@ -5628,6 +5797,108 @@ func awsAwsjson10_serializeDocumentUpdateReplicationGroupMemberAction(v *types.U return nil } +func awsAwsjson10_serializeDocumentVectorAttributeDefinition(v *types.VectorAttributeDefinition, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + if v.AttributeName != nil { + ok := object.Key("AttributeName") + ok.String(*v.AttributeName) + } + + return nil +} + +func awsAwsjson10_serializeDocumentVectorIndex(v *types.VectorIndex, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + if v.Dimensions != nil { + ok := object.Key("Dimensions") + ok.Long(*v.Dimensions) + } + + if len(v.DistanceFunction) > 0 { + ok := object.Key("DistanceFunction") + ok.String(string(v.DistanceFunction)) + } + + if v.IndexName != nil { + ok := object.Key("IndexName") + ok.String(*v.IndexName) + } + + if v.Projection != nil { + ok := object.Key("Projection") + if err := awsAwsjson10_serializeDocumentProjection(v.Projection, ok); err != nil { + return err + } + } + + if v.SearchSchema != nil { + ok := object.Key("SearchSchema") + if err := awsAwsjson10_serializeDocumentSearchSchema(v.SearchSchema, ok); err != nil { + return err + } + } + + if v.VectorAttribute != nil { + ok := object.Key("VectorAttribute") + if err := awsAwsjson10_serializeDocumentVectorAttributeDefinition(v.VectorAttribute, ok); err != nil { + return err + } + } + + return nil +} + +func awsAwsjson10_serializeDocumentVectorIndexList(v []types.VectorIndex, value smithyjson.Value) error { + array := value.Array() + defer array.Close() + + for i := range v { + av := array.Value() + if err := awsAwsjson10_serializeDocumentVectorIndex(&v[i], av); err != nil { + return err + } + } + return nil +} + +func awsAwsjson10_serializeDocumentVectorIndexUpdate(v *types.VectorIndexUpdate, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + if v.Create != nil { + ok := object.Key("Create") + if err := awsAwsjson10_serializeDocumentCreateVectorIndexAction(v.Create, ok); err != nil { + return err + } + } + + if v.Delete != nil { + ok := object.Key("Delete") + if err := awsAwsjson10_serializeDocumentDeleteVectorIndexAction(v.Delete, ok); err != nil { + return err + } + } + + return nil +} + +func awsAwsjson10_serializeDocumentVectorIndexUpdateList(v []types.VectorIndexUpdate, value smithyjson.Value) error { + array := value.Array() + defer array.Close() + + for i := range v { + av := array.Value() + if err := awsAwsjson10_serializeDocumentVectorIndexUpdate(&v[i], av); err != nil { + return err + } + } + return nil +} + func awsAwsjson10_serializeDocumentWarmThroughput(v *types.WarmThroughput, value smithyjson.Value) error { object := value.Object() defer object.Close() @@ -5879,6 +6150,13 @@ func awsAwsjson10_serializeOpDocumentCreateTableInput(v *CreateTableInput, value } } + if v.VectorIndexes != nil { + ok := object.Key("VectorIndexes") + if err := awsAwsjson10_serializeDocumentVectorIndexList(v.VectorIndexes, ok); err != nil { + return err + } + } + if v.WarmThroughput != nil { ok := object.Key("WarmThroughput") if err := awsAwsjson10_serializeDocumentWarmThroughput(v.WarmThroughput, ok); err != nil { @@ -6848,6 +7126,13 @@ func awsAwsjson10_serializeOpDocumentRestoreTableFromBackupInput(v *RestoreTable ok.String(*v.TargetTableName) } + if v.VectorIndexOverride != nil { + ok := object.Key("VectorIndexOverride") + if err := awsAwsjson10_serializeDocumentVectorIndexList(v.VectorIndexOverride, ok); err != nil { + return err + } + } + return nil } @@ -6920,6 +7205,13 @@ func awsAwsjson10_serializeOpDocumentRestoreTableToPointInTimeInput(v *RestoreTa ok.Boolean(*v.UseLatestRestorableTime) } + if v.VectorIndexOverride != nil { + ok := object.Key("VectorIndexOverride") + if err := awsAwsjson10_serializeDocumentVectorIndexList(v.VectorIndexOverride, ok); err != nil { + return err + } + } + return nil } @@ -7020,6 +7312,64 @@ func awsAwsjson10_serializeOpDocumentScanInput(v *ScanInput, value smithyjson.Va return nil } +func awsAwsjson10_serializeOpDocumentSearchVectorsInput(v *SearchVectorsInput, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + if v.ExpressionAttributeNames != nil { + ok := object.Key("ExpressionAttributeNames") + if err := awsAwsjson10_serializeDocumentExpressionAttributeNameMap(v.ExpressionAttributeNames, ok); err != nil { + return err + } + } + + if v.ExpressionAttributeValues != nil { + ok := object.Key("ExpressionAttributeValues") + if err := awsAwsjson10_serializeDocumentExpressionAttributeValueMap(v.ExpressionAttributeValues, ok); err != nil { + return err + } + } + + if v.IndexName != nil { + ok := object.Key("IndexName") + ok.String(*v.IndexName) + } + + if v.ProjectionExpression != nil { + ok := object.Key("ProjectionExpression") + ok.String(*v.ProjectionExpression) + } + + if len(v.ReturnConsumedCapacity) > 0 { + ok := object.Key("ReturnConsumedCapacity") + ok.String(string(v.ReturnConsumedCapacity)) + } + + if v.SearchConditionExpression != nil { + ok := object.Key("SearchConditionExpression") + ok.String(*v.SearchConditionExpression) + } + + if v.SearchVector != nil { + ok := object.Key("SearchVector") + if err := awsAwsjson10_serializeDocumentSearchVectorList(v.SearchVector, ok); err != nil { + return err + } + } + + if v.TableName != nil { + ok := object.Key("TableName") + ok.String(*v.TableName) + } + + if v.TopK != nil { + ok := object.Key("TopK") + ok.Integer(*v.TopK) + } + + return nil +} + func awsAwsjson10_serializeOpDocumentTagResourceInput(v *TagResourceInput, value smithyjson.Value) error { object := value.Object() defer object.Close() @@ -7410,6 +7760,13 @@ func awsAwsjson10_serializeOpDocumentUpdateTableInput(v *UpdateTableInput, value ok.String(*v.TableName) } + if v.VectorIndexUpdates != nil { + ok := object.Key("VectorIndexUpdates") + if err := awsAwsjson10_serializeDocumentVectorIndexUpdateList(v.VectorIndexUpdates, ok); err != nil { + return err + } + } + if v.WarmThroughput != nil { ok := object.Key("WarmThroughput") if err := awsAwsjson10_serializeDocumentWarmThroughput(v.WarmThroughput, ok); err != nil { diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/types/enums.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/types/enums.go index c9beca8696c..8bd97fef518 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/types/enums.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/types/enums.go @@ -784,6 +784,25 @@ func (ScalarAttributeType) Values() []ScalarAttributeType { } } +type SearchSchemaElementType string + +// Enum values for SearchSchemaElementType +const ( + SearchSchemaElementTypeHash SearchSchemaElementType = "HASH" + SearchSchemaElementTypeInlineFilter SearchSchemaElementType = "INLINE_FILTER" +) + +// Values returns all known values for SearchSchemaElementType. Note that this can +// be expanded in the future, and so it is only as up to date as the client. +// +// The ordering of this slice is not guaranteed to be stable across updates. +func (SearchSchemaElementType) Values() []SearchSchemaElementType { + return []SearchSchemaElementType{ + "HASH", + "INLINE_FILTER", + } +} + type Select string // Enum values for Select @@ -947,6 +966,27 @@ func (TimeToLiveStatus) Values() []TimeToLiveStatus { } } +type VectorDistanceFunction string + +// Enum values for VectorDistanceFunction +const ( + VectorDistanceFunctionCosine VectorDistanceFunction = "COSINE" + VectorDistanceFunctionDotProduct VectorDistanceFunction = "DOT_PRODUCT" + VectorDistanceFunctionEuclidean VectorDistanceFunction = "EUCLIDEAN" +) + +// Values returns all known values for VectorDistanceFunction. Note that this can +// be expanded in the future, and so it is only as up to date as the client. +// +// The ordering of this slice is not guaranteed to be stable across updates. +func (VectorDistanceFunction) Values() []VectorDistanceFunction { + return []VectorDistanceFunction{ + "COSINE", + "DOT_PRODUCT", + "EUCLIDEAN", + } +} + type WitnessStatus string // Enum values for WitnessStatus diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/types/errors.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/types/errors.go index 3774a406e5f..3d62100e2ee 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/types/errors.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/types/errors.go @@ -961,7 +961,10 @@ func (e *ThrottlingException) ErrorFault() smithy.ErrorFault { return smithy.Fau // // DynamoDB lists the cancellation reasons on the CancellationReasons property. // Transaction cancellation reasons are ordered in the order of requested items, if -// an item has no error it will have None code and Null message. +// an item has no error it will have None code and Null message. The None code is +// returned as the literal string "None" , not a null or absent value; the message +// field is omitted entirely for an item that has no error. This is important to +// note when using an SDK that surfaces the code as an optional or nullable type. // // Cancellation reason codes and possible error messages: // diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/types/types.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/types/types.go index cfcc5041669..c595325e485 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/types/types.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/types/types.go @@ -897,6 +897,11 @@ type ConsumedCapacity struct { // in the response. TableName *string + // The amount of throughput consumed on each vector index affected by the + // operation. Each entry contains VectorWriteRequestBytes (for write operations) + // or VectorSearchRequestBytes (for search operations). + VectorIndexes map[string]VectorCapacity + // The total number of write capacity units consumed by the operation. WriteCapacityUnits *float64 @@ -1049,6 +1054,43 @@ type CreateReplicationGroupMemberAction struct { noSmithyDocumentSerde } +// A new vector index to be added to a table. +type CreateVectorIndexAction struct { + + // The number of dimensions in each vector. + // + // This member is required. + Dimensions *int64 + + // The distance function used to calculate similarity. Valid values: COSINE , + // EUCLIDEAN , DOT_PRODUCT . + // + // This member is required. + DistanceFunction VectorDistanceFunction + + // The name of the vector index. Must be unique within the table. + // + // This member is required. + IndexName *string + + // Specifies attributes that are copied (projected) from the table into the vector + // index. + // + // This member is required. + Projection *Projection + + // The attribute that contains vector embeddings. If multiple vector indexes + // reference the same attribute, they must all use the same number of dimensions. + // + // This member is required. + VectorAttribute *VectorAttributeDefinition + + // The partition key and inline filter attribute definitions for the vector index. + SearchSchema []SearchSchemaElement + + noSmithyDocumentSerde +} + // Processing options for the CSV file being imported. type CsvOptions struct { @@ -1156,6 +1198,17 @@ type DeleteRequest struct { noSmithyDocumentSerde } +// A vector index to be removed from a table. +type DeleteVectorIndexAction struct { + + // The name of the vector index to delete. + // + // This member is required. + IndexName *string + + noSmithyDocumentSerde +} + // Enables setting the configuration for Kinesis Streaming. type EnableKinesisStreamingConfiguration struct { @@ -1885,8 +1938,7 @@ type ImportSummary struct { // this import task. CloudWatchLogGroupArn *string - // The time at which this import task ended. (Does this include the successful - // complete creation of the table it was imported to?) + // The time at which this import task ended. EndTime *time.Time // The Amazon Resource Number (ARN) corresponding to the import request. @@ -2001,6 +2053,14 @@ type IncrementalExportSpecification struct { // The view type that was chosen for the export. Valid values are // NEW_AND_OLD_IMAGES and NEW_IMAGES . The default value is NEW_AND_OLD_IMAGES . + // + // NEW_AND_OLD_IMAGES exports both the new and old images of each changed item, + // while NEW_IMAGES exports only the new (latest) image. The view type you choose + // determines the structure of each item in the output for insert , update , and + // delete operations. For details and examples of how each view type shapes the + // export output, see [DynamoDB table export output format]in the Amazon DynamoDB Developer Guide. + // + // [DynamoDB table export output format]: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/S3DataExport.Output.html ExportViewType ExportViewType noSmithyDocumentSerde @@ -2488,10 +2548,18 @@ type ProvisionedThroughputDescription struct { // DynamoDB returns a ThrottlingException . Eventually consistent reads require // less effort than strongly consistent reads, so a setting of 50 ReadCapacityUnits // per second provides 100 eventually consistent ReadCapacityUnits per second. + // + // For a table or global secondary index that uses on-demand capacity mode ( + // PAY_PER_REQUEST ), this value is 0 , because on-demand mode does not use + // provisioned throughput. ReadCapacityUnits *int64 // The maximum number of writes consumed per second before DynamoDB returns a // ThrottlingException . + // + // For a table or global secondary index that uses on-demand capacity mode ( + // PAY_PER_REQUEST ), this value is 0 , because on-demand mode does not use + // provisioned throughput. WriteCapacityUnits *int64 noSmithyDocumentSerde @@ -3006,6 +3074,44 @@ type S3BucketSource struct { noSmithyDocumentSerde } +// A single result from a SearchVectors operation. +type SearchResultItem struct { + + // A map of attribute names to AttributeValue objects, representing the projected + // attributes of the item returned by the vector search. + Item map[string]AttributeValue + + // The similarity score for this item relative to the search vector. The + // interpretation depends on the distance function configured for the vector index. + Score float64 + + noSmithyDocumentSerde +} + +// An element in the search schema of a vector index. +type SearchSchemaElement struct { + + // The name of the attribute. + // + // This member is required. + AttributeName *string + + // The role of the attribute in the search schema. Valid values: + // + // - HASH - A partition key that partitions the vector index for independent + // scaling. When specified, you must provide this attribute's value in the + // SearchConditionExpression . + // + // - INLINE_FILTER - An attribute projected into the vector index for filtering + // at the storage layer during search. Inline filters are optional in the + // SearchConditionExpression . + // + // This member is required. + SearchSchemaElementType SearchSchemaElementType + + noSmithyDocumentSerde +} + // Contains the details of the table when the backup was created. type SourceTableDetails struct { @@ -3085,6 +3191,11 @@ type SourceTableFeatureDetails struct { // Time to Live settings on the table when the backup was created. TimeToLiveDescription *TimeToLiveDescription + // The vector index properties for the table at the time the backup was created, + // including the index name, vector attribute, dimensions, distance function, + // search schema, and projection. + VectorIndexes []VectorIndexInfo + noSmithyDocumentSerde } @@ -3253,6 +3364,9 @@ type TableCreationParameters struct { // Represents the settings used to enable server-side encryption. SSESpecification *SSESpecification + // The vector indexes of the table to be created as part of the import operation. + VectorIndexes []VectorIndex + noSmithyDocumentSerde } @@ -3512,7 +3626,8 @@ type TableDescription struct { // Contains details of the table class. TableClassSummary *TableClassSummary - // Unique identifier for the table for which the backup was created. + // A unique identifier for the table, in UUID format, generated by DynamoDB when + // the table is created. TableId *string // The name of the table. @@ -3546,6 +3661,40 @@ type TableDescription struct { // information. TableStatus TableStatus + // The vector indexes, if any, on the table. Each element is composed of: + // + // - IndexName - The name of the vector index. + // + // - IndexStatus - The current status of the vector index: CREATING , ACTIVE , or + // DELETING . + // + // - Backfilling - Specifies whether the index is currently backfilling. During + // backfill, SearchVectors operations might return incomplete results. + // + // - VectorAttribute - The attribute that contains vector embeddings. + // + // - Dimensions - The number of dimensions in each vector. + // + // - DistanceFunction - The distance function used to calculate similarity ( + // COSINE , EUCLIDEAN , or DOT_PRODUCT ). + // + // - SearchSchema - The partition key and inline filter attributes for the vector + // index. + // + // - Projection - Specifies attributes that are copied (projected) from the table + // into the vector index. + // + // - IndexArn - The Amazon Resource Name (ARN) that uniquely identifies the index. + // + // - IndexSizeBytes - The total size of the vector index, in bytes. Amazon + // DynamoDB updates this value approximately every six hours. Recent changes might + // not be reflected in this value. + // + // - ItemCount - The number of items indexed in the vector index. Amazon DynamoDB + // updates this value approximately every six hours. Recent changes might not be + // reflected in this value. + VectorIndexes []VectorIndexDescription + // Describes the warm throughput value of the base table. WarmThroughput *TableWarmThroughputDescription @@ -3821,6 +3970,163 @@ type UpdateReplicationGroupMemberAction struct { noSmithyDocumentSerde } +// The definition of a vector attribute for a vector index. +type VectorAttributeDefinition struct { + + // The name of the vector attribute. + // + // This member is required. + AttributeName *string + + noSmithyDocumentSerde +} + +// The consumed capacity for vector index operations, including vector search +// request bytes and vector write request bytes. +type VectorCapacity struct { + + // The number of vector search request bytes consumed by a SearchVectors operation. + VectorSearchRequestBytes *float64 + + // The number of vector write request bytes consumed when writing to a vector + // index. Reported for write operations that modify attributes indexed by a vector + // index. + VectorWriteRequestBytes *float64 + + noSmithyDocumentSerde +} + +// Contains the configuration settings for a vector index, including the index +// name, vector attribute, dimensions, distance function, search schema, and +// projection. +type VectorIndex struct { + + // The number of dimensions in each vector. + // + // This member is required. + Dimensions *int64 + + // The distance function used to calculate similarity between vectors. Valid + // values: COSINE , EUCLIDEAN , DOT_PRODUCT . + // + // This member is required. + DistanceFunction VectorDistanceFunction + + // The name of the vector index. + // + // This member is required. + IndexName *string + + // Specifies attributes that are copied (projected) from the table into the vector + // index. + // + // This member is required. + Projection *Projection + + // The vector attribute configuration for the index. + // + // This member is required. + VectorAttribute *VectorAttributeDefinition + + // The search schema that defines partition key and inline filter attributes for + // the vector index. + SearchSchema []SearchSchemaElement + + noSmithyDocumentSerde +} + +// Contains the current state and configuration of a vector index, including its +// status, size, item count, and the settings specified when the index was created. +type VectorIndexDescription struct { + + // Specifies whether the index is currently backfilling. During backfill, + // SearchVectors operations might return incomplete results. + Backfilling *bool + + // The number of dimensions in each vector. + Dimensions *int64 + + // The distance function used to calculate similarity between vectors. + DistanceFunction VectorDistanceFunction + + // The Amazon Resource Name (ARN) that uniquely identifies the vector index. + IndexArn *string + + // The name of the vector index. + IndexName *string + + // The total size of the vector index, in bytes. Amazon DynamoDB updates this + // value approximately every six hours. Recent changes might not be reflected in + // this value. + IndexSizeBytes *int64 + + // The current state of the vector index: + // + // - CREATING - The index is being created. + // + // - ACTIVE - The index is ready for use. + // + // - DELETING - The index is being deleted. + IndexStatus IndexStatus + + // The number of items indexed in the vector index. Amazon DynamoDB updates this + // value approximately every six hours. Recent changes might not be reflected in + // this value. + ItemCount *int64 + + // Specifies attributes that are copied (projected) from the table into the vector + // index. + Projection *Projection + + // The search schema that defines partition key and inline filter attributes for + // the vector index. + SearchSchema []SearchSchemaElement + + // The vector attribute configuration for the index. + VectorAttribute *VectorAttributeDefinition + + noSmithyDocumentSerde +} + +// Contains the configuration of a vector index as it existed at the time a backup +// was created. +type VectorIndexInfo struct { + + // The number of dimensions in each vector. + Dimensions *int64 + + // The distance function used to calculate similarity between vectors. + DistanceFunction VectorDistanceFunction + + // The name of the vector index. + IndexName *string + + // Specifies attributes that are copied (projected) from the table into the vector + // index. + Projection *Projection + + // The search schema that defines partition key and inline filter attributes for + // the vector index. + SearchSchema []SearchSchemaElement + + // The vector attribute configuration for the index. + VectorAttribute *VectorAttributeDefinition + + noSmithyDocumentSerde +} + +// A vector index to be added to or removed from a table. +type VectorIndexUpdate struct { + + // The configuration for creating a new vector index on the table. + Create *CreateVectorIndexAction + + // The configuration for deleting an existing vector index from the table. + Delete *DeleteVectorIndexAction + + noSmithyDocumentSerde +} + // Provides visibility into the number of read and write operations your table or // secondary index can instantaneously support. The settings can be modified using // the UpdateTable operation to meet the throughput requirements of an upcoming diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/validators.go b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/validators.go index cd5187a3076..435b56e94c6 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/validators.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/dynamodb/validators.go @@ -730,6 +730,26 @@ func (m *validateOpScan) HandleInitialize(ctx context.Context, in middleware.Ini return next.HandleInitialize(ctx, in) } +type validateOpSearchVectors struct { +} + +func (*validateOpSearchVectors) ID() string { + return "OperationInputValidation" +} + +func (m *validateOpSearchVectors) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( + out middleware.InitializeOutput, metadata middleware.Metadata, err error, +) { + input, ok := in.Parameters.(*SearchVectorsInput) + if !ok { + return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters) + } + if err := validateOpSearchVectorsInput(input); err != nil { + return out, metadata, err + } + return next.HandleInitialize(ctx, in) +} + type validateOpTagResource struct { } @@ -1134,6 +1154,10 @@ func addOpScanValidationMiddleware(stack *middleware.Stack) error { return stack.Initialize.Add(&validateOpScan{}, middleware.After) } +func addOpSearchVectorsValidationMiddleware(stack *middleware.Stack) error { + return stack.Initialize.Add(&validateOpSearchVectors{}, middleware.After) +} + func addOpTagResourceValidationMiddleware(stack *middleware.Stack) error { return stack.Initialize.Add(&validateOpTagResource{}, middleware.After) } @@ -1438,6 +1462,42 @@ func validateCreateReplicationGroupMemberAction(v *types.CreateReplicationGroupM } } +func validateCreateVectorIndexAction(v *types.CreateVectorIndexAction) error { + if v == nil { + return nil + } + invalidParams := smithy.InvalidParamsError{Context: "CreateVectorIndexAction"} + if v.IndexName == nil { + invalidParams.Add(smithy.NewErrParamRequired("IndexName")) + } + if v.VectorAttribute == nil { + invalidParams.Add(smithy.NewErrParamRequired("VectorAttribute")) + } else if v.VectorAttribute != nil { + if err := validateVectorAttributeDefinition(v.VectorAttribute); err != nil { + invalidParams.AddNested("VectorAttribute", err.(smithy.InvalidParamsError)) + } + } + if v.SearchSchema != nil { + if err := validateSearchSchema(v.SearchSchema); err != nil { + invalidParams.AddNested("SearchSchema", err.(smithy.InvalidParamsError)) + } + } + if v.Projection == nil { + invalidParams.Add(smithy.NewErrParamRequired("Projection")) + } + if v.Dimensions == nil { + invalidParams.Add(smithy.NewErrParamRequired("Dimensions")) + } + if len(v.DistanceFunction) == 0 { + invalidParams.Add(smithy.NewErrParamRequired("DistanceFunction")) + } + if invalidParams.Len() > 0 { + return invalidParams + } else { + return nil + } +} + func validateDelete(v *types.Delete) error { if v == nil { return nil @@ -1531,6 +1591,21 @@ func validateDeleteRequest(v *types.DeleteRequest) error { } } +func validateDeleteVectorIndexAction(v *types.DeleteVectorIndexAction) error { + if v == nil { + return nil + } + invalidParams := smithy.InvalidParamsError{Context: "DeleteVectorIndexAction"} + if v.IndexName == nil { + invalidParams.Add(smithy.NewErrParamRequired("IndexName")) + } + if invalidParams.Len() > 0 { + return invalidParams + } else { + return nil + } +} + func validateFilterConditionMap(v map[string]types.Condition) error { if v == nil { return nil @@ -2278,6 +2353,41 @@ func validateS3BucketSource(v *types.S3BucketSource) error { } } +func validateSearchSchema(v []types.SearchSchemaElement) error { + if v == nil { + return nil + } + invalidParams := smithy.InvalidParamsError{Context: "SearchSchema"} + for i := range v { + if err := validateSearchSchemaElement(&v[i]); err != nil { + invalidParams.AddNested(fmt.Sprintf("[%d]", i), err.(smithy.InvalidParamsError)) + } + } + if invalidParams.Len() > 0 { + return invalidParams + } else { + return nil + } +} + +func validateSearchSchemaElement(v *types.SearchSchemaElement) error { + if v == nil { + return nil + } + invalidParams := smithy.InvalidParamsError{Context: "SearchSchemaElement"} + if v.AttributeName == nil { + invalidParams.Add(smithy.NewErrParamRequired("AttributeName")) + } + if len(v.SearchSchemaElementType) == 0 { + invalidParams.Add(smithy.NewErrParamRequired("SearchSchemaElementType")) + } + if invalidParams.Len() > 0 { + return invalidParams + } else { + return nil + } +} + func validateStreamSpecification(v *types.StreamSpecification) error { if v == nil { return nil @@ -2325,6 +2435,11 @@ func validateTableCreationParameters(v *types.TableCreationParameters) error { invalidParams.AddNested("GlobalSecondaryIndexes", err.(smithy.InvalidParamsError)) } } + if v.VectorIndexes != nil { + if err := validateVectorIndexList(v.VectorIndexes); err != nil { + invalidParams.AddNested("VectorIndexes", err.(smithy.InvalidParamsError)) + } + } if invalidParams.Len() > 0 { return invalidParams } else { @@ -2531,6 +2646,113 @@ func validateUpdateReplicationGroupMemberAction(v *types.UpdateReplicationGroupM } } +func validateVectorAttributeDefinition(v *types.VectorAttributeDefinition) error { + if v == nil { + return nil + } + invalidParams := smithy.InvalidParamsError{Context: "VectorAttributeDefinition"} + if v.AttributeName == nil { + invalidParams.Add(smithy.NewErrParamRequired("AttributeName")) + } + if invalidParams.Len() > 0 { + return invalidParams + } else { + return nil + } +} + +func validateVectorIndex(v *types.VectorIndex) error { + if v == nil { + return nil + } + invalidParams := smithy.InvalidParamsError{Context: "VectorIndex"} + if v.IndexName == nil { + invalidParams.Add(smithy.NewErrParamRequired("IndexName")) + } + if v.VectorAttribute == nil { + invalidParams.Add(smithy.NewErrParamRequired("VectorAttribute")) + } else if v.VectorAttribute != nil { + if err := validateVectorAttributeDefinition(v.VectorAttribute); err != nil { + invalidParams.AddNested("VectorAttribute", err.(smithy.InvalidParamsError)) + } + } + if v.SearchSchema != nil { + if err := validateSearchSchema(v.SearchSchema); err != nil { + invalidParams.AddNested("SearchSchema", err.(smithy.InvalidParamsError)) + } + } + if v.Projection == nil { + invalidParams.Add(smithy.NewErrParamRequired("Projection")) + } + if v.Dimensions == nil { + invalidParams.Add(smithy.NewErrParamRequired("Dimensions")) + } + if len(v.DistanceFunction) == 0 { + invalidParams.Add(smithy.NewErrParamRequired("DistanceFunction")) + } + if invalidParams.Len() > 0 { + return invalidParams + } else { + return nil + } +} + +func validateVectorIndexList(v []types.VectorIndex) error { + if v == nil { + return nil + } + invalidParams := smithy.InvalidParamsError{Context: "VectorIndexList"} + for i := range v { + if err := validateVectorIndex(&v[i]); err != nil { + invalidParams.AddNested(fmt.Sprintf("[%d]", i), err.(smithy.InvalidParamsError)) + } + } + if invalidParams.Len() > 0 { + return invalidParams + } else { + return nil + } +} + +func validateVectorIndexUpdate(v *types.VectorIndexUpdate) error { + if v == nil { + return nil + } + invalidParams := smithy.InvalidParamsError{Context: "VectorIndexUpdate"} + if v.Create != nil { + if err := validateCreateVectorIndexAction(v.Create); err != nil { + invalidParams.AddNested("Create", err.(smithy.InvalidParamsError)) + } + } + if v.Delete != nil { + if err := validateDeleteVectorIndexAction(v.Delete); err != nil { + invalidParams.AddNested("Delete", err.(smithy.InvalidParamsError)) + } + } + if invalidParams.Len() > 0 { + return invalidParams + } else { + return nil + } +} + +func validateVectorIndexUpdateList(v []types.VectorIndexUpdate) error { + if v == nil { + return nil + } + invalidParams := smithy.InvalidParamsError{Context: "VectorIndexUpdateList"} + for i := range v { + if err := validateVectorIndexUpdate(&v[i]); err != nil { + invalidParams.AddNested(fmt.Sprintf("[%d]", i), err.(smithy.InvalidParamsError)) + } + } + if invalidParams.Len() > 0 { + return invalidParams + } else { + return nil + } +} + func validateWriteRequest(v *types.WriteRequest) error { if v == nil { return nil @@ -2706,6 +2928,11 @@ func validateOpCreateTableInput(v *CreateTableInput) error { invalidParams.AddNested("Tags", err.(smithy.InvalidParamsError)) } } + if v.VectorIndexes != nil { + if err := validateVectorIndexList(v.VectorIndexes); err != nil { + invalidParams.AddNested("VectorIndexes", err.(smithy.InvalidParamsError)) + } + } if invalidParams.Len() > 0 { return invalidParams } else { @@ -3193,6 +3420,11 @@ func validateOpRestoreTableFromBackupInput(v *RestoreTableFromBackupInput) error invalidParams.AddNested("ProvisionedThroughputOverride", err.(smithy.InvalidParamsError)) } } + if v.VectorIndexOverride != nil { + if err := validateVectorIndexList(v.VectorIndexOverride); err != nil { + invalidParams.AddNested("VectorIndexOverride", err.(smithy.InvalidParamsError)) + } + } if invalidParams.Len() > 0 { return invalidParams } else { @@ -3223,6 +3455,11 @@ func validateOpRestoreTableToPointInTimeInput(v *RestoreTableToPointInTimeInput) invalidParams.AddNested("ProvisionedThroughputOverride", err.(smithy.InvalidParamsError)) } } + if v.VectorIndexOverride != nil { + if err := validateVectorIndexList(v.VectorIndexOverride); err != nil { + invalidParams.AddNested("VectorIndexOverride", err.(smithy.InvalidParamsError)) + } + } if invalidParams.Len() > 0 { return invalidParams } else { @@ -3250,6 +3487,30 @@ func validateOpScanInput(v *ScanInput) error { } } +func validateOpSearchVectorsInput(v *SearchVectorsInput) error { + if v == nil { + return nil + } + invalidParams := smithy.InvalidParamsError{Context: "SearchVectorsInput"} + if v.TableName == nil { + invalidParams.Add(smithy.NewErrParamRequired("TableName")) + } + if v.IndexName == nil { + invalidParams.Add(smithy.NewErrParamRequired("IndexName")) + } + if v.SearchVector == nil { + invalidParams.Add(smithy.NewErrParamRequired("SearchVector")) + } + if v.TopK == nil { + invalidParams.Add(smithy.NewErrParamRequired("TopK")) + } + if invalidParams.Len() > 0 { + return invalidParams + } else { + return nil + } +} + func validateOpTagResourceInput(v *TagResourceInput) error { if v == nil { return nil @@ -3494,6 +3755,11 @@ func validateOpUpdateTableInput(v *UpdateTableInput) error { invalidParams.AddNested("GlobalTableWitnessUpdates", err.(smithy.InvalidParamsError)) } } + if v.VectorIndexUpdates != nil { + if err := validateVectorIndexUpdateList(v.VectorIndexUpdates); err != nil { + invalidParams.AddNested("VectorIndexUpdates", err.(smithy.InvalidParamsError)) + } + } if invalidParams.Len() > 0 { return invalidParams } else { diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding/CHANGELOG.md index 2fb0269e710..bdb3895e832 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding/CHANGELOG.md @@ -1,3 +1,23 @@ +# v1.13.17 (2026-08-14) + +* **Dependency Update**: Update to smithy-go v1.27.8. + +# v1.13.16 (2026-08-10) + +* **Dependency Update**: Update to smithy-go v1.27.7. + +# v1.13.15 (2026-07-31.2) + +* **Dependency Update**: Upgrade to smithy-go v1.27.6 to fix various serde issues in HTTP binding services. + +# v1.13.14 (2026-07-28) + +* **Dependency Update**: Update to smithy-go v1.27.5. + +# v1.13.13 (2026-07-01) + +* No change notes available for this release. + # v1.13.12 (2026-06-04) * **Dependency Update**: Update to smithy-go v1.27.1 to fix several union-related deserialization bugs in schema-serde-enabled services. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding/go_module_metadata.go index b769e842733..7c31cf92ee4 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding/go_module_metadata.go @@ -3,4 +3,4 @@ package acceptencoding // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.13.12" +const goModuleVersion = "1.13.17" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery/CHANGELOG.md index cfcd48ae2b1..5ea3cbb1291 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery/CHANGELOG.md @@ -1,3 +1,39 @@ +# v1.12.14 (2026-08-14) + +* **Dependency Update**: Update to smithy-go v1.27.8. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.12.13 (2026-08-10) + +* **Dependency Update**: Update to smithy-go v1.27.7. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.12.12 (2026-08-05) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.12.11 (2026-07-31.2) + +* **Dependency Update**: Updated to the latest SDK module versions +* **Dependency Update**: Upgrade to smithy-go v1.27.6 to fix various serde issues in HTTP binding services. + +# v1.12.10 (2026-07-29) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.12.9 (2026-07-28) + +* **Dependency Update**: Update to smithy-go v1.27.5. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.12.8 (2026-07-21) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.12.7 (2026-07-01) + +* **Dependency Update**: Updated to the latest SDK module versions + # v1.12.6 (2026-06-08) * **Dependency Update**: Updated to the latest SDK module versions diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery/go_module_metadata.go index 19fd00e2c08..2b646755776 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery/go_module_metadata.go @@ -3,4 +3,4 @@ package endpointdiscovery // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.12.6" +const goModuleVersion = "1.12.14" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/presigned-url/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/presigned-url/CHANGELOG.md index 2a082b44f71..2886a705e0c 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/presigned-url/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/presigned-url/CHANGELOG.md @@ -1,3 +1,39 @@ +# v1.13.37 (2026-08-14) + +* **Dependency Update**: Update to smithy-go v1.27.8. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.13.36 (2026-08-10) + +* **Dependency Update**: Update to smithy-go v1.27.7. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.13.35 (2026-08-05) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.13.34 (2026-07-31.2) + +* **Dependency Update**: Updated to the latest SDK module versions +* **Dependency Update**: Upgrade to smithy-go v1.27.6 to fix various serde issues in HTTP binding services. + +# v1.13.33 (2026-07-29) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.13.32 (2026-07-28) + +* **Dependency Update**: Update to smithy-go v1.27.5. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.13.31 (2026-07-21) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.13.30 (2026-07-01) + +* **Dependency Update**: Updated to the latest SDK module versions + # v1.13.29 (2026-06-08) * **Dependency Update**: Updated to the latest SDK module versions diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/presigned-url/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/presigned-url/go_module_metadata.go index 84b406a7846..9ed94b8e2ef 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/presigned-url/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/presigned-url/go_module_metadata.go @@ -3,4 +3,4 @@ package presignedurl // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.13.29" +const goModuleVersion = "1.13.37" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/CHANGELOG.md index cf926f5bc5a..4686a1438ee 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/CHANGELOG.md @@ -1,3 +1,53 @@ +# v1.5.6 (2026-08-14) + +* **Dependency Update**: Update to smithy-go v1.27.8. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.5.5 (2026-08-10) + +* **Dependency Update**: Update to smithy-go v1.27.7. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.5.4 (2026-08-05) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.5.3 (2026-07-31.2) + +* **Dependency Update**: Updated to the latest SDK module versions +* **Dependency Update**: Upgrade to smithy-go v1.27.6 to fix various serde issues in HTTP binding services. + +# v1.5.2 (2026-07-29) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.5.1 (2026-07-28) + +* **Dependency Update**: Update to smithy-go v1.27.5. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.5.0 (2026-07-21) + +* **Feature**: Add an option to clients to disable clock skew +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.4.1 (2026-07-13) + +* No change notes available for this release. + +# v1.4.0 (2026-07-08.2) + +* **Feature**: Adds support for OAuth 2.0 token operations in AWS Sign-In, CreateOAuth2TokenWithIAM (client credentials flow), IntrospectOAuth2TokenWithIAM (token inspection), and RevokeOAuth2TokenWithIAM (token revocation). + +# v1.3.0 (2026-07-06) + +* **Feature**: Add request serialization snapshot tests. + +# v1.2.2 (2026-07-01) + +* **Bug Fix**: Bump smithy-go to 1.27.3, fix JSON encorder for document.Number, endpoint host label format validation and CBOR union serialization on new serde +* **Dependency Update**: Updated to the latest SDK module versions + # v1.2.1 (2026-06-29) * No change notes available for this release. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_client.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_client.go index 545b8f1066b..569cc4bb9a9 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_client.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_client.go @@ -263,6 +263,10 @@ func (c *Client) invokeOperation( finalizeClientEndpointResolverOptions(&options) + ctx = setLoggerContext(ctx, options, opID) + + ctx = resolveServiceMetadata(ctx, options, opID) + if err := c.addCommonMiddlewares(stack, options, opID); err != nil { return nil, metadata, err } @@ -379,9 +383,6 @@ func (c *Client) addCommonMiddlewares(stack *middleware.Stack, options Options, if err := addProtocolFinalizerMiddlewares(stack, options, operation); err != nil { return fmt.Errorf("add protocol finalizers: %v", err) } - if err := addSetLoggerMiddleware(stack, options); err != nil { - return err - } if err := addClientRequestID(stack); err != nil { return err } @@ -434,30 +435,6 @@ func resolveAuthSchemes(options *Options) { type noSmithyDocumentSerde = smithydocument.NoSerde -type legacyEndpointContextSetter struct { - LegacyResolver EndpointResolver -} - -func (*legacyEndpointContextSetter) ID() string { - return "legacyEndpointContextSetter" -} - -func (m *legacyEndpointContextSetter) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( - out middleware.InitializeOutput, metadata middleware.Metadata, err error, -) { - if m.LegacyResolver != nil { - ctx = awsmiddleware.SetRequiresLegacyEndpoints(ctx, true) - } - - return next.HandleInitialize(ctx, in) - -} -func addlegacyEndpointContextSetter(stack *middleware.Stack, o Options) error { - return stack.Initialize.Add(&legacyEndpointContextSetter{ - LegacyResolver: o.EndpointResolver, - }, middleware.Before) -} - func resolveDefaultLogger(o *Options) { if o.Logger != nil { return @@ -465,8 +442,9 @@ func resolveDefaultLogger(o *Options) { o.Logger = logging.Nop{} } -func addSetLoggerMiddleware(stack *middleware.Stack, o Options) error { - return middleware.AddSetLoggerMiddleware(stack, o.Logger) +func setLoggerContext(ctx context.Context, options Options, operation string) context.Context { + _ = operation + return middleware.SetLogger(ctx, options.Logger) } func setResolvedDefaultsMode(o *Options) { @@ -487,16 +465,17 @@ func setResolvedDefaultsMode(o *Options) { // NewFromConfig returns a new client from the provided config. func NewFromConfig(cfg aws.Config, optFns ...func(*Options)) *Client { opts := Options{ - Region: cfg.Region, - DefaultsMode: cfg.DefaultsMode, - RuntimeEnvironment: cfg.RuntimeEnvironment, - HTTPClient: cfg.HTTPClient, - Credentials: cfg.Credentials, - APIOptions: cfg.APIOptions, - Logger: cfg.Logger, - ClientLogMode: cfg.ClientLogMode, - AppID: cfg.AppID, - AuthSchemePreference: cfg.AuthSchemePreference, + Region: cfg.Region, + DefaultsMode: cfg.DefaultsMode, + RuntimeEnvironment: cfg.RuntimeEnvironment, + HTTPClient: cfg.HTTPClient, + Credentials: cfg.Credentials, + APIOptions: cfg.APIOptions, + Logger: cfg.Logger, + ClientLogMode: cfg.ClientLogMode, + AppID: cfg.AppID, + DisableClockSkewCorrection: cfg.DisableClockSkewCorrection, + AuthSchemePreference: cfg.AuthSchemePreference, } resolveAWSRetryerProvider(cfg, &opts) resolveAWSRetryMaxAttempts(cfg, &opts) @@ -693,8 +672,10 @@ func addRawResponseToMetadata(stack *middleware.Stack) error { return stack.Deserialize.Add(&awsmiddleware.AddRawResponse{}, middleware.Before) } -func addRecordResponseTiming(stack *middleware.Stack) error { - return stack.Deserialize.Add(&awsmiddleware.RecordResponseTiming{}, middleware.After) +func addRecordResponseTiming(stack *middleware.Stack, options Options) error { + return stack.Deserialize.Add(&awsmiddleware.RecordResponseTiming{ + DisableClockSkewCorrection: options.DisableClockSkewCorrection, + }, middleware.After) } func addSpanRetryLoop(stack *middleware.Stack, options Options) error { @@ -772,6 +753,7 @@ func addRetry(stack *middleware.Stack, o Options, c *Client) error { m.LogAttempts = o.ClientLogMode.IsRetries() m.OperationMeter = o.MeterProvider.Meter("github.com/aws/aws-sdk-go-v2/service/signin") m.ClientSkew = c.timeOffset + m.DisableClockSkewCorrection = o.DisableClockSkewCorrection }) if err := stack.Finalize.Insert(attempt, "ResolveAuthScheme", middleware.Before); err != nil { return err @@ -879,12 +861,16 @@ type IdempotencyTokenProvider interface { GetIdempotencyToken() (string, error) } -func newServiceMetadataMiddleware(region, operation string) *awsmiddleware.RegisterServiceMetadata { - return &awsmiddleware.RegisterServiceMetadata{ - Region: region, - ServiceID: ServiceID, - OperationName: operation, +func resolveServiceMetadata(ctx context.Context, options Options, operation string) context.Context { + ctx = awsmiddleware.SetServiceID(ctx, ServiceID) + if options.Region != "" { + ctx = awsmiddleware.SetRegion(ctx, options.Region) + } + ctx = awsmiddleware.SetOperationName(ctx, operation) + if options.EndpointResolver != nil { + ctx = awsmiddleware.SetRequiresLegacyEndpoints(ctx, true) } + return ctx } func addRecursionDetection(stack *middleware.Stack) error { diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_CreateOAuth2Token.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_CreateOAuth2Token.go index 415f9a2b4d5..de7d50f9b18 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_CreateOAuth2Token.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_CreateOAuth2Token.go @@ -7,7 +7,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/signin/types" "github.com/aws/smithy-go/middleware" "github.com/aws/smithy-go/ptr" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // CreateOAuth2Token API @@ -117,22 +116,13 @@ func (c *Client) addOperationCreateOAuth2TokenMiddlewares(stack *middleware.Stac return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } if err = addResolveEndpointMiddleware(stack, options); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -141,9 +131,6 @@ func (c *Client) addOperationCreateOAuth2TokenMiddlewares(stack *middleware.Stac if err = addOpCreateOAuth2TokenValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "CreateOAuth2Token"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_CreateOAuth2TokenWithIAM.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_CreateOAuth2TokenWithIAM.go new file mode 100644 index 00000000000..5fd96524797 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_CreateOAuth2TokenWithIAM.go @@ -0,0 +1,121 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package signin + +import ( + "context" + "github.com/aws/smithy-go/middleware" + "github.com/aws/smithy-go/ptr" +) + +// Grants permission to exchange client credentials for an OAuth 2.0 access token +// scoped to a resource that can be used to access AWS services from applications +func (c *Client) CreateOAuth2TokenWithIAM(ctx context.Context, params *CreateOAuth2TokenWithIAMInput, optFns ...func(*Options)) (*CreateOAuth2TokenWithIAMOutput, error) { + if params == nil { + params = &CreateOAuth2TokenWithIAMInput{} + } + + result, metadata, err := c.invokeOperation(ctx, "CreateOAuth2TokenWithIAM", params, optFns, c.addOperationCreateOAuth2TokenWithIAMMiddlewares) + if err != nil { + return nil, err + } + + out := result.(*CreateOAuth2TokenWithIAMOutput) + out.ResultMetadata = metadata + return out, nil +} + +// Input structure for CreateOAuth2TokenWithIAM operation +type CreateOAuth2TokenWithIAMInput struct { + + // OAuth 2.0 grant type. Must be "client_credentials". + // + // This member is required. + GrantType *string + + // The OAuth resource for which the access token is requested. Example: + // "aws-mcp.amazonaws.com". + // + // This member is required. + Resource *string + + noSmithyDocumentSerde +} + +func (in *CreateOAuth2TokenWithIAMInput) bindEndpointParams(p *EndpointParameters) { + + p.IsOAuthEndpoint = ptr.Bool(true) +} + +// Output structure for CreateOAuth2TokenWithIAM operation +// +// Contains the JWT access token, token type, and expiration per RFC 6749 §5.1. +type CreateOAuth2TokenWithIAMOutput struct { + + // JWT access token containing principal identity, resource scope, and session + // metadata + // + // This member is required. + AccessToken *string + + // Token lifetime in seconds. Value is the minimum of session validity and 1 hour. + // + // This member is required. + ExpiresIn *int32 + + // Always "Bearer" per OAuth 2.1 specification + // + // This member is required. + TokenType *string + + // Metadata pertaining to the operation's result. + ResultMetadata middleware.Metadata + + noSmithyDocumentSerde +} + +func (c *Client) addOperationCreateOAuth2TokenWithIAMMiddlewares(stack *middleware.Stack, options Options) (err error) { + err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateOAuth2TokenWithIAM{}, middleware.After) + if err != nil { + return err + } + err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateOAuth2TokenWithIAM{}, middleware.After) + if err != nil { + return err + } + + if err = addComputeContentLength(stack); err != nil { + return err + } + if err = addResolveEndpointMiddleware(stack, options); err != nil { + return err + } + if err = addComputePayloadSHA256(stack); err != nil { + return err + } + if err = addRecordResponseTiming(stack, options); err != nil { + return err + } + if err = addCredentialSource(stack, options); err != nil { + return err + } + if err = addOpCreateOAuth2TokenWithIAMValidationMiddleware(stack); err != nil { + return err + } + if err = addRequestIDRetrieverMiddleware(stack); err != nil { + return err + } + if err = addResponseErrorMiddleware(stack); err != nil { + return err + } + if err = addRequestResponseLogging(stack, options); err != nil { + return err + } + if err = addDisableHTTPSMiddleware(stack, options); err != nil { + return err + } + if err = addInterceptors(stack, options); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_DeleteConsoleAuthorizationConfiguration.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_DeleteConsoleAuthorizationConfiguration.go index a9c42942acb..d1a28728d55 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_DeleteConsoleAuthorizationConfiguration.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_DeleteConsoleAuthorizationConfiguration.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aws/smithy-go/middleware" "github.com/aws/smithy-go/ptr" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Delete console authorization configuration with automatic scope detection @@ -73,9 +72,6 @@ func (c *Client) addOperationDeleteConsoleAuthorizationConfigurationMiddlewares( return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -85,21 +81,12 @@ func (c *Client) addOperationDeleteConsoleAuthorizationConfigurationMiddlewares( if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DeleteConsoleAuthorizationConfiguration"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_DeleteResourcePermissionStatement.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_DeleteResourcePermissionStatement.go index add06008dbf..a730417ff69 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_DeleteResourcePermissionStatement.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_DeleteResourcePermissionStatement.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/aws/smithy-go/middleware" "github.com/aws/smithy-go/ptr" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Remove a permission statement from the account's SignIn resource-based policy @@ -63,9 +62,6 @@ func (c *Client) addOperationDeleteResourcePermissionStatementMiddlewares(stack return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -75,13 +71,7 @@ func (c *Client) addOperationDeleteResourcePermissionStatementMiddlewares(stack if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -93,9 +83,6 @@ func (c *Client) addOperationDeleteResourcePermissionStatementMiddlewares(stack if err = addOpDeleteResourcePermissionStatementValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DeleteResourcePermissionStatement"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_GetConsoleAuthorizationConfiguration.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_GetConsoleAuthorizationConfiguration.go index 2def43d98e5..64060707cf1 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_GetConsoleAuthorizationConfiguration.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_GetConsoleAuthorizationConfiguration.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aws/smithy-go/middleware" "github.com/aws/smithy-go/ptr" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Get console authorization configuration with automatic scope detection @@ -73,9 +72,6 @@ func (c *Client) addOperationGetConsoleAuthorizationConfigurationMiddlewares(sta return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -85,21 +81,12 @@ func (c *Client) addOperationGetConsoleAuthorizationConfigurationMiddlewares(sta if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "GetConsoleAuthorizationConfiguration"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_GetResourcePolicy.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_GetResourcePolicy.go index 9b571203c5d..08cb6cb06e4 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_GetResourcePolicy.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_GetResourcePolicy.go @@ -7,7 +7,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/signin/types" "github.com/aws/smithy-go/middleware" "github.com/aws/smithy-go/ptr" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Retrieve the account's consolidated SignIn resource-based policy @@ -60,9 +59,6 @@ func (c *Client) addOperationGetResourcePolicyMiddlewares(stack *middleware.Stac return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -72,21 +68,12 @@ func (c *Client) addOperationGetResourcePolicyMiddlewares(stack *middleware.Stac if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "GetResourcePolicy"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_IntrospectOAuth2TokenWithIAM.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_IntrospectOAuth2TokenWithIAM.go new file mode 100644 index 00000000000..ebfa6563cbf --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_IntrospectOAuth2TokenWithIAM.go @@ -0,0 +1,171 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package signin + +import ( + "context" + "github.com/aws/smithy-go/middleware" + "github.com/aws/smithy-go/ptr" +) + +// Grants permission to inspect the metadata and state of an OAuth 2.0 access +// token or refresh token +// +// Implements RFC 7662 OAuth 2.0 Token Introspection over a SigV4-authenticated +// endpoint. Inspects the metadata of an access_token or refresh_token issued by +// AWS Sign-In and returns the claims associated with it. +// +// Inactive token semantics (RFC 7662 §2.2): when the supplied token is unknown, +// expired, revoked, malformed, or owned by a different account, the response body +// is exactly { "active": false } with all other claims omitted. +func (c *Client) IntrospectOAuth2TokenWithIAM(ctx context.Context, params *IntrospectOAuth2TokenWithIAMInput, optFns ...func(*Options)) (*IntrospectOAuth2TokenWithIAMOutput, error) { + if params == nil { + params = &IntrospectOAuth2TokenWithIAMInput{} + } + + result, metadata, err := c.invokeOperation(ctx, "IntrospectOAuth2TokenWithIAM", params, optFns, c.addOperationIntrospectOAuth2TokenWithIAMMiddlewares) + if err != nil { + return nil, err + } + + out := result.(*IntrospectOAuth2TokenWithIAMOutput) + out.ResultMetadata = metadata + return out, nil +} + +// Input structure for IntrospectOAuth2TokenWithIAM operation +// +// RFC 7662 §2.1 introspection request. Contains the token to inspect and an +// optional hint about the token's type. +type IntrospectOAuth2TokenWithIAMInput struct { + + // The string value of the token to introspect. May be either an access_token or a + // refresh_token issued by AWS Sign-In. + // + // This member is required. + Token *string + + // Optional hint about the type of the token submitted for introspection. The + // server uses this hint to optimize lookup, but still falls back to the other + // token type on miss. Allowed values: access_token, refresh_token. + TokenTypeHint *string + + noSmithyDocumentSerde +} + +func (in *IntrospectOAuth2TokenWithIAMInput) bindEndpointParams(p *EndpointParameters) { + + p.IsOAuthEndpoint = ptr.Bool(true) +} + +// Output structure for IntrospectOAuth2TokenWithIAM operation +// +// RFC 7662 §2.2 introspection response. Only active is required; all other claims +// are omitted when the token is inactive. +type IntrospectOAuth2TokenWithIAMOutput struct { + + // Indicates whether the token is currently active. true only when the token is + // valid, has not expired, has not been revoked, and belongs to the caller's + // account. + // + // This member is required. + Active *bool + + // 12-digit AWS account ID of the token's subject principal. + AccountId *string + + // Audience of the token: the OAuth resource the token is scoped to (for example, + // "aws-mcp.amazonaws.com"). Omitted for refresh tokens. + Aud *string + + // Client identifier for the OAuth 2.0 client that requested the token. + ClientId *string + + // Token expiration time as a NumericDate (Unix epoch seconds). + Exp *int64 + + // Token issuance time as a NumericDate (Unix epoch seconds). + Iat *int64 + + // Issuer of the token. Always "signin.amazonaws.com" for AWS Sign-In. + Iss *string + + // Unique identifier for the token. + Jti *string + + // Token "not before" time as a NumericDate (Unix epoch seconds). + Nbf *int64 + + // The OAuth resource the token is scoped to during Human OAuth flow. Only present + // for refresh token introspection. + Resource *string + + // AWS Sign-In session ARN bound to the token, of the form + // arn:aws:signin:{region}:{account}:session/{uuid}. + SigninSession *string + + // Subject of the token: the IAM principal ARN. For assumed-role sessions, this is + // the session ARN (matches sts:GetCallerIdentity's Arn field), e.g. + // arn:aws:sts::123456789012:assumed-role/MyRole/session-name. + Sub *string + + // Indicates which kind of token was introspected. One of "access_token" or + // "refresh_token". + TokenType *string + + // User identifier matching sts:GetCallerIdentity's UserId field for the token's + // subject principal (e.g. "AIDAEXAMPLE" for an IAM user, or + // "AROAEXAMPLE:session-name" for an assumed role). + UserId *string + + // Metadata pertaining to the operation's result. + ResultMetadata middleware.Metadata + + noSmithyDocumentSerde +} + +func (c *Client) addOperationIntrospectOAuth2TokenWithIAMMiddlewares(stack *middleware.Stack, options Options) (err error) { + err = stack.Serialize.Add(&awsRestjson1_serializeOpIntrospectOAuth2TokenWithIAM{}, middleware.After) + if err != nil { + return err + } + err = stack.Deserialize.Add(&awsRestjson1_deserializeOpIntrospectOAuth2TokenWithIAM{}, middleware.After) + if err != nil { + return err + } + + if err = addComputeContentLength(stack); err != nil { + return err + } + if err = addResolveEndpointMiddleware(stack, options); err != nil { + return err + } + if err = addComputePayloadSHA256(stack); err != nil { + return err + } + if err = addRecordResponseTiming(stack, options); err != nil { + return err + } + if err = addCredentialSource(stack, options); err != nil { + return err + } + if err = addOpIntrospectOAuth2TokenWithIAMValidationMiddleware(stack); err != nil { + return err + } + if err = addRequestIDRetrieverMiddleware(stack); err != nil { + return err + } + if err = addResponseErrorMiddleware(stack); err != nil { + return err + } + if err = addRequestResponseLogging(stack, options); err != nil { + return err + } + if err = addDisableHTTPSMiddleware(stack, options); err != nil { + return err + } + if err = addInterceptors(stack, options); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_ListResourcePermissionStatements.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_ListResourcePermissionStatements.go index 46a4c6c89f2..a22859f4e7a 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_ListResourcePermissionStatements.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_ListResourcePermissionStatements.go @@ -8,7 +8,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/signin/types" "github.com/aws/smithy-go/middleware" "github.com/aws/smithy-go/ptr" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Retrieve all permission statements in the account's SignIn resource-based policy @@ -71,9 +70,6 @@ func (c *Client) addOperationListResourcePermissionStatementsMiddlewares(stack * return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -83,21 +79,12 @@ func (c *Client) addOperationListResourcePermissionStatementsMiddlewares(stack * if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "ListResourcePermissionStatements"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_PutConsoleAuthorizationConfiguration.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_PutConsoleAuthorizationConfiguration.go index d54b0d42190..08b5bf3faa9 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_PutConsoleAuthorizationConfiguration.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_PutConsoleAuthorizationConfiguration.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aws/smithy-go/middleware" "github.com/aws/smithy-go/ptr" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Enable console authorization configuration with automatic scope detection @@ -73,9 +72,6 @@ func (c *Client) addOperationPutConsoleAuthorizationConfigurationMiddlewares(sta return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -85,21 +81,12 @@ func (c *Client) addOperationPutConsoleAuthorizationConfigurationMiddlewares(sta if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "PutConsoleAuthorizationConfiguration"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_PutResourcePermissionStatement.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_PutResourcePermissionStatement.go index e04aaba5c2c..14e93c19a82 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_PutResourcePermissionStatement.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_PutResourcePermissionStatement.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/aws/smithy-go/middleware" "github.com/aws/smithy-go/ptr" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Create a permission statement in the account's SignIn resource-based policy @@ -86,9 +85,6 @@ func (c *Client) addOperationPutResourcePermissionStatementMiddlewares(stack *mi return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -98,13 +94,7 @@ func (c *Client) addOperationPutResourcePermissionStatementMiddlewares(stack *mi if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -113,9 +103,6 @@ func (c *Client) addOperationPutResourcePermissionStatementMiddlewares(stack *mi if err = addIdempotencyToken_opPutResourcePermissionStatementMiddleware(stack, options); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "PutResourcePermissionStatement"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_RevokeOAuth2TokenWithIAM.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_RevokeOAuth2TokenWithIAM.go new file mode 100644 index 00000000000..f72427aef43 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/api_op_RevokeOAuth2TokenWithIAM.go @@ -0,0 +1,109 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package signin + +import ( + "context" + "github.com/aws/smithy-go/middleware" + "github.com/aws/smithy-go/ptr" +) + +// Grants permission to revoke an OAuth 2.0 refresh token and its associated +// refresh tokens +// +// Revokes a refresh_token issued by AWS Sign-In, invalidating the entire token +// chain so that the refresh_token can no longer be used to mint new access_tokens. +// +// Idempotency: revoking an already-revoked, expired, or otherwise invalid token +// still returns 200 OK with an empty body. Only the refresh_token type is +// accepted. +func (c *Client) RevokeOAuth2TokenWithIAM(ctx context.Context, params *RevokeOAuth2TokenWithIAMInput, optFns ...func(*Options)) (*RevokeOAuth2TokenWithIAMOutput, error) { + if params == nil { + params = &RevokeOAuth2TokenWithIAMInput{} + } + + result, metadata, err := c.invokeOperation(ctx, "RevokeOAuth2TokenWithIAM", params, optFns, c.addOperationRevokeOAuth2TokenWithIAMMiddlewares) + if err != nil { + return nil, err + } + + out := result.(*RevokeOAuth2TokenWithIAMOutput) + out.ResultMetadata = metadata + return out, nil +} + +// Input structure for RevokeOAuth2TokenWithIAM operation +// +// RFC 7009 §2.1 revocation request. Contains the refresh_token to revoke. +type RevokeOAuth2TokenWithIAMInput struct { + + // The refresh_token to revoke. Must be a refresh_token issued by AWS Sign-In + // (prefix "ASOR"); access_tokens are not accepted for revocation. + // + // This member is required. + Token *string + + noSmithyDocumentSerde +} + +func (in *RevokeOAuth2TokenWithIAMInput) bindEndpointParams(p *EndpointParameters) { + + p.IsOAuthEndpoint = ptr.Bool(true) +} + +// Output structure for RevokeOAuth2TokenWithIAM operation +// +// RFC 7009 §2.2 revocation response. The endpoint returns 200 OK with an empty +// body on success; there are no response fields. +type RevokeOAuth2TokenWithIAMOutput struct { + // Metadata pertaining to the operation's result. + ResultMetadata middleware.Metadata + + noSmithyDocumentSerde +} + +func (c *Client) addOperationRevokeOAuth2TokenWithIAMMiddlewares(stack *middleware.Stack, options Options) (err error) { + err = stack.Serialize.Add(&awsRestjson1_serializeOpRevokeOAuth2TokenWithIAM{}, middleware.After) + if err != nil { + return err + } + err = stack.Deserialize.Add(&awsRestjson1_deserializeOpRevokeOAuth2TokenWithIAM{}, middleware.After) + if err != nil { + return err + } + + if err = addComputeContentLength(stack); err != nil { + return err + } + if err = addResolveEndpointMiddleware(stack, options); err != nil { + return err + } + if err = addComputePayloadSHA256(stack); err != nil { + return err + } + if err = addRecordResponseTiming(stack, options); err != nil { + return err + } + if err = addCredentialSource(stack, options); err != nil { + return err + } + if err = addOpRevokeOAuth2TokenWithIAMValidationMiddleware(stack); err != nil { + return err + } + if err = addRequestIDRetrieverMiddleware(stack); err != nil { + return err + } + if err = addResponseErrorMiddleware(stack); err != nil { + return err + } + if err = addRequestResponseLogging(stack, options); err != nil { + return err + } + if err = addDisableHTTPSMiddleware(stack, options); err != nil { + return err + } + if err = addInterceptors(stack, options); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/deserializers.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/deserializers.go index 12208eaafaa..cc6b07d95cc 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/deserializers.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/deserializers.go @@ -34,15 +34,18 @@ func (m *awsRestjson1_deserializeOpCreateOAuth2Token) HandleDeserialize(ctx cont return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorCreateOAuth2Token(response, &metadata) } @@ -180,14 +183,14 @@ func awsRestjson1_deserializeOpDocumentCreateOAuth2TokenOutput(v **CreateOAuth2T return nil } -type awsRestjson1_deserializeOpDeleteConsoleAuthorizationConfiguration struct { +type awsRestjson1_deserializeOpCreateOAuth2TokenWithIAM struct { } -func (*awsRestjson1_deserializeOpDeleteConsoleAuthorizationConfiguration) ID() string { +func (*awsRestjson1_deserializeOpCreateOAuth2TokenWithIAM) ID() string { return "OperationDeserializer" } -func (m *awsRestjson1_deserializeOpDeleteConsoleAuthorizationConfiguration) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( +func (m *awsRestjson1_deserializeOpCreateOAuth2TokenWithIAM) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( out middleware.DeserializeOutput, metadata middleware.Metadata, err error, ) { out, metadata, err = next.HandleDeserialize(ctx, in) @@ -195,15 +198,208 @@ func (m *awsRestjson1_deserializeOpDeleteConsoleAuthorizationConfiguration) Hand return out, metadata, err } + response, ok := out.RawResponse.(*smithyhttp.Response) + if !ok { + return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} + } + + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + _, span := tracing.StartSpan(ctx, "OperationDeserializer") endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") defer endTimer() defer span.End() + + if response.StatusCode < 200 || response.StatusCode >= 300 { + return out, metadata, awsRestjson1_deserializeOpErrorCreateOAuth2TokenWithIAM(response, &metadata) + } + output := &CreateOAuth2TokenWithIAMOutput{} + out.Result = output + + var buff [1024]byte + ringBuffer := smithyio.NewRingBuffer(buff[:]) + + body := io.TeeReader(response.Body, ringBuffer) + + decoder := json.NewDecoder(body) + decoder.UseNumber() + var shape interface{} + if err := decoder.Decode(&shape); err != nil && err != io.EOF { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return out, metadata, err + } + + err = awsRestjson1_deserializeOpDocumentCreateOAuth2TokenWithIAMOutput(&output, shape) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body with invalid JSON, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + span.End() + return out, metadata, err +} + +func awsRestjson1_deserializeOpErrorCreateOAuth2TokenWithIAM(response *smithyhttp.Response, metadata *middleware.Metadata) error { + var errorBuffer bytes.Buffer + if _, err := io.Copy(&errorBuffer, response.Body); err != nil { + return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} + } + errorBody := bytes.NewReader(errorBuffer.Bytes()) + + errorCode := "UnknownError" + errorMessage := errorCode + + headerCode := response.Header.Get("X-Amzn-ErrorType") + if len(headerCode) != 0 { + errorCode = restjson.SanitizeErrorCode(headerCode) + } + + var buff [1024]byte + ringBuffer := smithyio.NewRingBuffer(buff[:]) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + jsonCode, message, err := restjson.GetErrorInfo(decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + errorBody.Seek(0, io.SeekStart) + if len(headerCode) == 0 && len(jsonCode) != 0 { + errorCode = restjson.SanitizeErrorCode(jsonCode) + } + if len(message) != 0 { + errorMessage = message + } + + switch { + case strings.EqualFold("AccessDeniedException", errorCode): + return awsRestjson1_deserializeErrorAccessDeniedException(response, errorBody) + + case strings.EqualFold("InternalServerException", errorCode): + return awsRestjson1_deserializeErrorInternalServerException(response, errorBody) + + case strings.EqualFold("TooManyRequestsError", errorCode): + return awsRestjson1_deserializeErrorTooManyRequestsError(response, errorBody) + + case strings.EqualFold("ValidationException", errorCode): + return awsRestjson1_deserializeErrorValidationException(response, errorBody) + + default: + genericError := &smithy.GenericAPIError{ + Code: errorCode, + Message: errorMessage, + } + return genericError + + } +} + +func awsRestjson1_deserializeOpDocumentCreateOAuth2TokenWithIAMOutput(v **CreateOAuth2TokenWithIAMOutput, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *CreateOAuth2TokenWithIAMOutput + if *v == nil { + sv = &CreateOAuth2TokenWithIAMOutput{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "access_token": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected OAuthAccessToken to be of type string, got %T instead", value) + } + sv.AccessToken = ptr.String(jtv) + } + + case "expires_in": + if value != nil { + jtv, ok := value.(json.Number) + if !ok { + return fmt.Errorf("expected TokenExpiresIn to be json.Number, got %T instead", value) + } + i64, err := jtv.Int64() + if err != nil { + return err + } + sv.ExpiresIn = ptr.Int32(int32(i64)) + } + + case "token_type": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected BearerTokenType to be of type string, got %T instead", value) + } + sv.TokenType = ptr.String(jtv) + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +type awsRestjson1_deserializeOpDeleteConsoleAuthorizationConfiguration struct { +} + +func (*awsRestjson1_deserializeOpDeleteConsoleAuthorizationConfiguration) ID() string { + return "OperationDeserializer" +} + +func (m *awsRestjson1_deserializeOpDeleteConsoleAuthorizationConfiguration) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( + out middleware.DeserializeOutput, metadata middleware.Metadata, err error, +) { + out, metadata, err = next.HandleDeserialize(ctx, in) + if err != nil { + return out, metadata, err + } + response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorDeleteConsoleAuthorizationConfiguration(response, &metadata) } @@ -381,15 +577,18 @@ func (m *awsRestjson1_deserializeOpDeleteResourcePermissionStatement) HandleDese return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorDeleteResourcePermissionStatement(response, &metadata) } @@ -481,15 +680,18 @@ func (m *awsRestjson1_deserializeOpGetConsoleAuthorizationConfiguration) HandleD return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorGetConsoleAuthorizationConfiguration(response, &metadata) } @@ -667,15 +869,18 @@ func (m *awsRestjson1_deserializeOpGetResourcePolicy) HandleDeserialize(ctx cont return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorGetResourcePolicy(response, &metadata) } @@ -813,14 +1018,14 @@ func awsRestjson1_deserializeOpDocumentGetResourcePolicyOutput(v **GetResourcePo return nil } -type awsRestjson1_deserializeOpListResourcePermissionStatements struct { +type awsRestjson1_deserializeOpIntrospectOAuth2TokenWithIAM struct { } -func (*awsRestjson1_deserializeOpListResourcePermissionStatements) ID() string { +func (*awsRestjson1_deserializeOpIntrospectOAuth2TokenWithIAM) ID() string { return "OperationDeserializer" } -func (m *awsRestjson1_deserializeOpListResourcePermissionStatements) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( +func (m *awsRestjson1_deserializeOpIntrospectOAuth2TokenWithIAM) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( out middleware.DeserializeOutput, metadata middleware.Metadata, err error, ) { out, metadata, err = next.HandleDeserialize(ctx, in) @@ -828,19 +1033,22 @@ func (m *awsRestjson1_deserializeOpListResourcePermissionStatements) HandleDeser return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { - return out, metadata, awsRestjson1_deserializeOpErrorListResourcePermissionStatements(response, &metadata) + return out, metadata, awsRestjson1_deserializeOpErrorIntrospectOAuth2TokenWithIAM(response, &metadata) } - output := &ListResourcePermissionStatementsOutput{} + output := &IntrospectOAuth2TokenWithIAMOutput{} out.Result = output var buff [1024]byte @@ -861,7 +1069,7 @@ func (m *awsRestjson1_deserializeOpListResourcePermissionStatements) HandleDeser return out, metadata, err } - err = awsRestjson1_deserializeOpDocumentListResourcePermissionStatementsOutput(&output, shape) + err = awsRestjson1_deserializeOpDocumentIntrospectOAuth2TokenWithIAMOutput(&output, shape) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) @@ -875,7 +1083,7 @@ func (m *awsRestjson1_deserializeOpListResourcePermissionStatements) HandleDeser return out, metadata, err } -func awsRestjson1_deserializeOpErrorListResourcePermissionStatements(response *smithyhttp.Response, metadata *middleware.Metadata) error { +func awsRestjson1_deserializeOpErrorIntrospectOAuth2TokenWithIAM(response *smithyhttp.Response, metadata *middleware.Metadata) error { var errorBuffer bytes.Buffer if _, err := io.Copy(&errorBuffer, response.Body); err != nil { return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} @@ -922,9 +1130,6 @@ func awsRestjson1_deserializeOpErrorListResourcePermissionStatements(response *s case strings.EqualFold("InternalServerException", errorCode): return awsRestjson1_deserializeErrorInternalServerException(response, errorBody) - case strings.EqualFold("ResourceNotFoundException", errorCode): - return awsRestjson1_deserializeErrorResourceNotFoundException(response, errorBody) - case strings.EqualFold("TooManyRequestsError", errorCode): return awsRestjson1_deserializeErrorTooManyRequestsError(response, errorBody) @@ -941,7 +1146,7 @@ func awsRestjson1_deserializeOpErrorListResourcePermissionStatements(response *s } } -func awsRestjson1_deserializeOpDocumentListResourcePermissionStatementsOutput(v **ListResourcePermissionStatementsOutput, value interface{}) error { +func awsRestjson1_deserializeOpDocumentIntrospectOAuth2TokenWithIAMOutput(v **IntrospectOAuth2TokenWithIAMOutput, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } @@ -954,31 +1159,155 @@ func awsRestjson1_deserializeOpDocumentListResourcePermissionStatementsOutput(v return fmt.Errorf("unexpected JSON type %v", value) } - var sv *ListResourcePermissionStatementsOutput + var sv *IntrospectOAuth2TokenWithIAMOutput if *v == nil { - sv = &ListResourcePermissionStatementsOutput{} + sv = &IntrospectOAuth2TokenWithIAMOutput{} } else { sv = *v } for key, value := range shape { switch key { - case "nextToken": + case "account_id": if value != nil { jtv, ok := value.(string) if !ok { - return fmt.Errorf("expected NextToken to be of type string, got %T instead", value) + return fmt.Errorf("expected AccountId to be of type string, got %T instead", value) } - sv.NextToken = ptr.String(jtv) + sv.AccountId = ptr.String(jtv) } - case "permissionStatements": - if err := awsRestjson1_deserializeDocumentPermissionStatementSummaries(&sv.PermissionStatements, value); err != nil { - return err + case "active": + if value != nil { + jtv, ok := value.(bool) + if !ok { + return fmt.Errorf("expected Boolean to be of type *bool, got %T instead", value) + } + sv.Active = ptr.Bool(jtv) } - default: - _, _ = key, value + case "aud": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", value) + } + sv.Aud = ptr.String(jtv) + } + + case "client_id": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", value) + } + sv.ClientId = ptr.String(jtv) + } + + case "exp": + if value != nil { + jtv, ok := value.(json.Number) + if !ok { + return fmt.Errorf("expected Long to be json.Number, got %T instead", value) + } + i64, err := jtv.Int64() + if err != nil { + return err + } + sv.Exp = ptr.Int64(i64) + } + + case "iat": + if value != nil { + jtv, ok := value.(json.Number) + if !ok { + return fmt.Errorf("expected Long to be json.Number, got %T instead", value) + } + i64, err := jtv.Int64() + if err != nil { + return err + } + sv.Iat = ptr.Int64(i64) + } + + case "iss": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", value) + } + sv.Iss = ptr.String(jtv) + } + + case "jti": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", value) + } + sv.Jti = ptr.String(jtv) + } + + case "nbf": + if value != nil { + jtv, ok := value.(json.Number) + if !ok { + return fmt.Errorf("expected Long to be json.Number, got %T instead", value) + } + i64, err := jtv.Int64() + if err != nil { + return err + } + sv.Nbf = ptr.Int64(i64) + } + + case "resource": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", value) + } + sv.Resource = ptr.String(jtv) + } + + case "signin_session": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", value) + } + sv.SigninSession = ptr.String(jtv) + } + + case "sub": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", value) + } + sv.Sub = ptr.String(jtv) + } + + case "token_type": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected IntrospectedTokenType to be of type string, got %T instead", value) + } + sv.TokenType = ptr.String(jtv) + } + + case "user_id": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", value) + } + sv.UserId = ptr.String(jtv) + } + + default: + _, _ = key, value } } @@ -986,14 +1315,14 @@ func awsRestjson1_deserializeOpDocumentListResourcePermissionStatementsOutput(v return nil } -type awsRestjson1_deserializeOpPutConsoleAuthorizationConfiguration struct { +type awsRestjson1_deserializeOpListResourcePermissionStatements struct { } -func (*awsRestjson1_deserializeOpPutConsoleAuthorizationConfiguration) ID() string { +func (*awsRestjson1_deserializeOpListResourcePermissionStatements) ID() string { return "OperationDeserializer" } -func (m *awsRestjson1_deserializeOpPutConsoleAuthorizationConfiguration) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( +func (m *awsRestjson1_deserializeOpListResourcePermissionStatements) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( out middleware.DeserializeOutput, metadata middleware.Metadata, err error, ) { out, metadata, err = next.HandleDeserialize(ctx, in) @@ -1001,15 +1330,194 @@ func (m *awsRestjson1_deserializeOpPutConsoleAuthorizationConfiguration) HandleD return out, metadata, err } + response, ok := out.RawResponse.(*smithyhttp.Response) + if !ok { + return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} + } + + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + _, span := tracing.StartSpan(ctx, "OperationDeserializer") endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") defer endTimer() defer span.End() + + if response.StatusCode < 200 || response.StatusCode >= 300 { + return out, metadata, awsRestjson1_deserializeOpErrorListResourcePermissionStatements(response, &metadata) + } + output := &ListResourcePermissionStatementsOutput{} + out.Result = output + + var buff [1024]byte + ringBuffer := smithyio.NewRingBuffer(buff[:]) + + body := io.TeeReader(response.Body, ringBuffer) + + decoder := json.NewDecoder(body) + decoder.UseNumber() + var shape interface{} + if err := decoder.Decode(&shape); err != nil && err != io.EOF { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return out, metadata, err + } + + err = awsRestjson1_deserializeOpDocumentListResourcePermissionStatementsOutput(&output, shape) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body with invalid JSON, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + span.End() + return out, metadata, err +} + +func awsRestjson1_deserializeOpErrorListResourcePermissionStatements(response *smithyhttp.Response, metadata *middleware.Metadata) error { + var errorBuffer bytes.Buffer + if _, err := io.Copy(&errorBuffer, response.Body); err != nil { + return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} + } + errorBody := bytes.NewReader(errorBuffer.Bytes()) + + errorCode := "UnknownError" + errorMessage := errorCode + + headerCode := response.Header.Get("X-Amzn-ErrorType") + if len(headerCode) != 0 { + errorCode = restjson.SanitizeErrorCode(headerCode) + } + + var buff [1024]byte + ringBuffer := smithyio.NewRingBuffer(buff[:]) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + jsonCode, message, err := restjson.GetErrorInfo(decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + errorBody.Seek(0, io.SeekStart) + if len(headerCode) == 0 && len(jsonCode) != 0 { + errorCode = restjson.SanitizeErrorCode(jsonCode) + } + if len(message) != 0 { + errorMessage = message + } + + switch { + case strings.EqualFold("AccessDeniedException", errorCode): + return awsRestjson1_deserializeErrorAccessDeniedException(response, errorBody) + + case strings.EqualFold("InternalServerException", errorCode): + return awsRestjson1_deserializeErrorInternalServerException(response, errorBody) + + case strings.EqualFold("ResourceNotFoundException", errorCode): + return awsRestjson1_deserializeErrorResourceNotFoundException(response, errorBody) + + case strings.EqualFold("TooManyRequestsError", errorCode): + return awsRestjson1_deserializeErrorTooManyRequestsError(response, errorBody) + + case strings.EqualFold("ValidationException", errorCode): + return awsRestjson1_deserializeErrorValidationException(response, errorBody) + + default: + genericError := &smithy.GenericAPIError{ + Code: errorCode, + Message: errorMessage, + } + return genericError + + } +} + +func awsRestjson1_deserializeOpDocumentListResourcePermissionStatementsOutput(v **ListResourcePermissionStatementsOutput, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *ListResourcePermissionStatementsOutput + if *v == nil { + sv = &ListResourcePermissionStatementsOutput{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "nextToken": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected NextToken to be of type string, got %T instead", value) + } + sv.NextToken = ptr.String(jtv) + } + + case "permissionStatements": + if err := awsRestjson1_deserializeDocumentPermissionStatementSummaries(&sv.PermissionStatements, value); err != nil { + return err + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +type awsRestjson1_deserializeOpPutConsoleAuthorizationConfiguration struct { +} + +func (*awsRestjson1_deserializeOpPutConsoleAuthorizationConfiguration) ID() string { + return "OperationDeserializer" +} + +func (m *awsRestjson1_deserializeOpPutConsoleAuthorizationConfiguration) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( + out middleware.DeserializeOutput, metadata middleware.Metadata, err error, +) { + out, metadata, err = next.HandleDeserialize(ctx, in) + if err != nil { + return out, metadata, err + } + response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorPutConsoleAuthorizationConfiguration(response, &metadata) } @@ -1190,15 +1698,18 @@ func (m *awsRestjson1_deserializeOpPutResourcePermissionStatement) HandleDeseria return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorPutResourcePermissionStatement(response, &metadata) } @@ -1346,6 +1857,106 @@ func awsRestjson1_deserializeOpDocumentPutResourcePermissionStatementOutput(v ** return nil } +type awsRestjson1_deserializeOpRevokeOAuth2TokenWithIAM struct { +} + +func (*awsRestjson1_deserializeOpRevokeOAuth2TokenWithIAM) ID() string { + return "OperationDeserializer" +} + +func (m *awsRestjson1_deserializeOpRevokeOAuth2TokenWithIAM) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( + out middleware.DeserializeOutput, metadata middleware.Metadata, err error, +) { + out, metadata, err = next.HandleDeserialize(ctx, in) + if err != nil { + return out, metadata, err + } + + response, ok := out.RawResponse.(*smithyhttp.Response) + if !ok { + return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} + } + + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + + if response.StatusCode < 200 || response.StatusCode >= 300 { + return out, metadata, awsRestjson1_deserializeOpErrorRevokeOAuth2TokenWithIAM(response, &metadata) + } + output := &RevokeOAuth2TokenWithIAMOutput{} + out.Result = output + + span.End() + return out, metadata, err +} + +func awsRestjson1_deserializeOpErrorRevokeOAuth2TokenWithIAM(response *smithyhttp.Response, metadata *middleware.Metadata) error { + var errorBuffer bytes.Buffer + if _, err := io.Copy(&errorBuffer, response.Body); err != nil { + return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} + } + errorBody := bytes.NewReader(errorBuffer.Bytes()) + + errorCode := "UnknownError" + errorMessage := errorCode + + headerCode := response.Header.Get("X-Amzn-ErrorType") + if len(headerCode) != 0 { + errorCode = restjson.SanitizeErrorCode(headerCode) + } + + var buff [1024]byte + ringBuffer := smithyio.NewRingBuffer(buff[:]) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + jsonCode, message, err := restjson.GetErrorInfo(decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + errorBody.Seek(0, io.SeekStart) + if len(headerCode) == 0 && len(jsonCode) != 0 { + errorCode = restjson.SanitizeErrorCode(jsonCode) + } + if len(message) != 0 { + errorMessage = message + } + + switch { + case strings.EqualFold("AccessDeniedException", errorCode): + return awsRestjson1_deserializeErrorAccessDeniedException(response, errorBody) + + case strings.EqualFold("InternalServerException", errorCode): + return awsRestjson1_deserializeErrorInternalServerException(response, errorBody) + + case strings.EqualFold("TooManyRequestsError", errorCode): + return awsRestjson1_deserializeErrorTooManyRequestsError(response, errorBody) + + case strings.EqualFold("ValidationException", errorCode): + return awsRestjson1_deserializeErrorValidationException(response, errorBody) + + default: + genericError := &smithy.GenericAPIError{ + Code: errorCode, + Message: errorMessage, + } + return genericError + + } +} + func awsRestjson1_deserializeErrorAccessDeniedException(response *smithyhttp.Response, errorBody *bytes.Reader) error { output := &types.AccessDeniedException{} var buff [1024]byte diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/endpoints.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/endpoints.go index 16944632691..52c68b3570a 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/endpoints.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/endpoints.go @@ -276,6 +276,12 @@ type EndpointParameters struct { // Parameter is // required. IsControlPlane *bool + + // Indicates if the operation targets the OAuth token endpoint + // + // Parameter is + // required. + IsOAuthEndpoint *bool } // ValidateRequired validates required parameters are set. @@ -306,8 +312,8 @@ func (p EndpointParameters) WithDefaults() EndpointParameters { const bddRoot int32 = 2 -var bddNodes = [99]int32{ - -1, 1, -1, 0, 4, 3, 2, 30, 100000025, 1, 24, 5, 2, 30, 6, 3, 7, 26, 4, 18, 8, 5, 17, 9, 6, 100000004, 10, 7, 100000005, 11, 10, 100000006, 12, 12, 100000007, 13, 13, 100000008, 14, 14, 100000009, 15, 15, 100000010, 16, 16, 100000011, 100000014, 8, 100000022, 100000023, 5, 22, 19, 9, 100000012, 20, 10, 100000013, 21, 11, 100000020, 100000021, 8, 23, 100000019, 11, 100000018, 100000019, 2, 29, 25, 3, 32, 26, 4, 27, 100000025, 5, 100000025, 28, 9, 100000012, 100000025, 3, 32, 30, 4, 100000015, 31, 5, 100000016, 100000017, 6, 100000001, 33, 7, 100000002, 100000003} +var bddNodes = [120]int32{ + -1, 1, -1, 0, 6, 3, 2, 36, 4, 4, 5, 100000027, 6, 100000004, 100000027, 1, 29, 7, 2, 36, 8, 3, 9, 31, 4, 22, 10, 5, 19, 11, 7, 21, 12, 8, 100000007, 13, 10, 100000008, 14, 12, 100000009, 15, 13, 100000010, 16, 14, 100000011, 17, 15, 100000012, 18, 16, 100000013, 100000016, 6, 100000005, 20, 7, 21, 100000006, 17, 100000024, 100000025, 6, 100000004, 23, 7, 27, 24, 9, 100000014, 25, 10, 100000015, 26, 11, 100000022, 100000023, 11, 28, 100000021, 17, 100000020, 100000021, 2, 35, 30, 3, 39, 31, 4, 32, 100000027, 6, 100000004, 33, 7, 100000027, 34, 9, 100000014, 100000027, 3, 39, 36, 4, 38, 37, 7, 100000018, 100000019, 6, 100000004, 100000017, 5, 100000001, 40, 8, 100000002, 100000003} type conditionContext struct { PartitionResult *awsrulesfn.PartitionConfig @@ -335,13 +341,18 @@ func evalCondition(idx int, params *EndpointParameters, c *conditionContext) boo case 4: return *params.UseFIPS == true case 5: - return *params.UseDualStack == true - case 6: return c.PartitionResult.Name == "aws" + case 6: + return func() bool { + if v := params.IsOAuthEndpoint; v != nil { + return *v + } + return false + }() == true case 7: - return c.PartitionResult.Name == "aws-cn" + return *params.UseDualStack == true case 8: - return c.PartitionResult.SupportsDualStack == true + return c.PartitionResult.Name == "aws-cn" case 9: return *params.Region == "us-gov-west-1" case 10: @@ -358,6 +369,8 @@ func evalCondition(idx int, params *EndpointParameters, c *conditionContext) boo return c.PartitionResult.Name == "aws-iso-e" case 16: return c.PartitionResult.Name == "aws-eusc" + case 17: + return c.PartitionResult.SupportsDualStack == true } return false } @@ -467,6 +480,41 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( }(), }, nil case 4: + return smithyendpoints.Endpoint{}, fmt.Errorf("endpoint rule error, %s", "FIPS endpoints are not supported for OAuth operations. Disable FIPS or use a non-OAuth operation.") + case 5: + uriString := func() string { + var out strings.Builder + out.WriteString("https://") + out.WriteString(*params.Region) + out.WriteString(".oauth.signin.aws") + return out.String() + }() + uri, err := url.Parse(uriString) + if err != nil { + return smithyendpoints.Endpoint{}, fmt.Errorf("Failed to parse uri: %s", uriString) + } + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: func() smithy.Properties { + var out smithy.Properties + smithyauth.SetAuthOptions(&out, []*smithyauth.Option{ + { + SchemeID: "sigv4", + SignerProperties: func() smithy.Properties { + var sp smithy.Properties + smithyhttp.SetSigV4SigningName(&sp, "signin") + smithyhttp.SetSigV4ASigningName(&sp, "signin") + + smithyhttp.SetSigV4SigningRegion(&sp, *params.Region) + return sp + }(), + }, + }) + return out + }(), + }, nil + case 6: uriString := func() string { var out strings.Builder out.WriteString("https://") @@ -482,7 +530,7 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( URI: *uri, Headers: http.Header{}, }, nil - case 5: + case 7: uriString := func() string { var out strings.Builder out.WriteString("https://") @@ -498,7 +546,7 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( URI: *uri, Headers: http.Header{}, }, nil - case 6: + case 8: uriString := func() string { var out strings.Builder out.WriteString("https://") @@ -514,7 +562,7 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( URI: *uri, Headers: http.Header{}, }, nil - case 7: + case 9: uriString := func() string { var out strings.Builder out.WriteString("https://") @@ -530,7 +578,7 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( URI: *uri, Headers: http.Header{}, }, nil - case 8: + case 10: uriString := func() string { var out strings.Builder out.WriteString("https://") @@ -546,7 +594,7 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( URI: *uri, Headers: http.Header{}, }, nil - case 9: + case 11: uriString := func() string { var out strings.Builder out.WriteString("https://") @@ -562,7 +610,7 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( URI: *uri, Headers: http.Header{}, }, nil - case 10: + case 12: uriString := func() string { var out strings.Builder out.WriteString("https://") @@ -578,7 +626,7 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( URI: *uri, Headers: http.Header{}, }, nil - case 11: + case 13: uriString := func() string { var out strings.Builder out.WriteString("https://") @@ -594,7 +642,7 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( URI: *uri, Headers: http.Header{}, }, nil - case 12: + case 14: uriString := "https://signin-fips.amazonaws-us-gov.com" uri, err := url.Parse(uriString) if err != nil { @@ -604,7 +652,7 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( URI: *uri, Headers: http.Header{}, }, nil - case 13: + case 15: uriString := func() string { var out strings.Builder out.WriteString("https://") @@ -620,7 +668,7 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( URI: *uri, Headers: http.Header{}, }, nil - case 14: + case 16: uriString := func() string { var out strings.Builder out.WriteString("https://") @@ -637,11 +685,11 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( URI: *uri, Headers: http.Header{}, }, nil - case 15: + case 17: return smithyendpoints.Endpoint{}, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: FIPS and custom endpoint are not supported") - case 16: + case 18: return smithyendpoints.Endpoint{}, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: Dualstack and custom endpoint are not supported") - case 17: + case 19: uriString := *params.Endpoint uri, err := url.Parse(uriString) if err != nil { @@ -651,7 +699,7 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( URI: *uri, Headers: http.Header{}, }, nil - case 18: + case 20: uriString := func() string { var out strings.Builder out.WriteString("https://signin-fips.") @@ -668,9 +716,9 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( URI: *uri, Headers: http.Header{}, }, nil - case 19: + case 21: return smithyendpoints.Endpoint{}, fmt.Errorf("endpoint rule error, %s", "FIPS and DualStack are enabled, but this partition does not support one or both") - case 20: + case 22: uriString := func() string { var out strings.Builder out.WriteString("https://signin-fips.") @@ -687,9 +735,9 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( URI: *uri, Headers: http.Header{}, }, nil - case 21: + case 23: return smithyendpoints.Endpoint{}, fmt.Errorf("endpoint rule error, %s", "FIPS is enabled but this partition does not support FIPS") - case 22: + case 24: uriString := func() string { var out strings.Builder out.WriteString("https://signin.") @@ -706,9 +754,9 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( URI: *uri, Headers: http.Header{}, }, nil - case 23: + case 25: return smithyendpoints.Endpoint{}, fmt.Errorf("endpoint rule error, %s", "DualStack is enabled but this partition does not support DualStack") - case 24: + case 26: uriString := func() string { var out strings.Builder out.WriteString("https://signin.") @@ -725,7 +773,7 @@ func resolveResult(idx int32, params *EndpointParameters, c *conditionContext) ( URI: *uri, Headers: http.Header{}, }, nil - case 25: + case 27: return smithyendpoints.Endpoint{}, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: Missing Region") } return smithyendpoints.Endpoint{}, fmt.Errorf("endpoint rule error, invalid result index: %d", idx) diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/generated.json b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/generated.json index 4965af44178..762cc709c93 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/generated.json +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/generated.json @@ -9,13 +9,16 @@ "api_client.go", "api_client_test.go", "api_op_CreateOAuth2Token.go", + "api_op_CreateOAuth2TokenWithIAM.go", "api_op_DeleteConsoleAuthorizationConfiguration.go", "api_op_DeleteResourcePermissionStatement.go", "api_op_GetConsoleAuthorizationConfiguration.go", "api_op_GetResourcePolicy.go", + "api_op_IntrospectOAuth2TokenWithIAM.go", "api_op_ListResourcePermissionStatements.go", "api_op_PutConsoleAuthorizationConfiguration.go", "api_op_PutResourcePermissionStatement.go", + "api_op_RevokeOAuth2TokenWithIAM.go", "auth.go", "deserializers.go", "doc.go", @@ -26,6 +29,8 @@ "internal/endpoints/endpoints.go", "internal/endpoints/endpoints_test.go", "options.go", + "request_snapshot_test.go", + "response_snapshot_test.go", "serializers.go", "snapshot_test.go", "sra_operation_order_test.go", diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/go_module_metadata.go index 685df38e364..308c6cc0d61 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/go_module_metadata.go @@ -3,4 +3,4 @@ package signin // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.2.1" +const goModuleVersion = "1.5.6" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/options.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/options.go index 551d20c28cd..9b7248ff303 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/options.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/options.go @@ -44,6 +44,11 @@ type Options struct { // clients initial default settings. DefaultsMode aws.DefaultsMode + // Disables SDK clock skew correction. When set, the SDK will not adjust request + // signing timestamps to compensate for clock drift between the client and the + // service. + DisableClockSkewCorrection bool + // The endpoint options to be used when attempting to resolve an endpoint. EndpointOptions EndpointResolverOptions diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/serializers.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/serializers.go index fe87e71f886..d245732cccd 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/serializers.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/serializers.go @@ -97,6 +97,92 @@ func awsRestjson1_serializeOpHttpBindingsCreateOAuth2TokenInput(v *CreateOAuth2T return nil } +type awsRestjson1_serializeOpCreateOAuth2TokenWithIAM struct { +} + +func (*awsRestjson1_serializeOpCreateOAuth2TokenWithIAM) ID() string { + return "OperationSerializer" +} + +func (m *awsRestjson1_serializeOpCreateOAuth2TokenWithIAM) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( + out middleware.SerializeOutput, metadata middleware.Metadata, err error, +) { + _, span := tracing.StartSpan(ctx, "OperationSerializer") + endTimer := startMetricTimer(ctx, "client.call.serialization_duration") + defer endTimer() + defer span.End() + request, ok := in.Request.(*smithyhttp.Request) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} + } + + input, ok := in.Parameters.(*CreateOAuth2TokenWithIAMInput) + _ = input + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} + } + + opPath, opQuery := httpbinding.SplitURI("/v1/token?x-amz-client-auth-method=iam") + request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath) + request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery) + request.Method = "POST" + var restEncoder *httpbinding.Encoder + if request.URL.RawPath == "" { + restEncoder, err = httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) + } else { + request.URL.RawPath = smithyhttp.JoinPath(request.URL.RawPath, opPath) + restEncoder, err = httpbinding.NewEncoderWithRawPath(request.URL.Path, request.URL.RawPath, request.URL.RawQuery, request.Header) + } + + if err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + restEncoder.SetHeader("Content-Type").String("application/json") + + jsonEncoder := smithyjson.NewEncoder() + if err := awsRestjson1_serializeOpDocumentCreateOAuth2TokenWithIAMInput(input, jsonEncoder.Value); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if request.Request, err = restEncoder.Encode(request.Request); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + in.Request = request + + endTimer() + span.End() + return next.HandleSerialize(ctx, in) +} +func awsRestjson1_serializeOpHttpBindingsCreateOAuth2TokenWithIAMInput(v *CreateOAuth2TokenWithIAMInput, encoder *httpbinding.Encoder) error { + if v == nil { + return fmt.Errorf("unsupported serialization of nil %T", v) + } + + return nil +} + +func awsRestjson1_serializeOpDocumentCreateOAuth2TokenWithIAMInput(v *CreateOAuth2TokenWithIAMInput, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + if v.GrantType != nil { + ok := object.Key("grant_type") + ok.String(*v.GrantType) + } + + if v.Resource != nil { + ok := object.Key("resource") + ok.String(*v.Resource) + } + + return nil +} + type awsRestjson1_serializeOpDeleteConsoleAuthorizationConfiguration struct { } @@ -403,6 +489,92 @@ func awsRestjson1_serializeOpHttpBindingsGetResourcePolicyInput(v *GetResourcePo return nil } +type awsRestjson1_serializeOpIntrospectOAuth2TokenWithIAM struct { +} + +func (*awsRestjson1_serializeOpIntrospectOAuth2TokenWithIAM) ID() string { + return "OperationSerializer" +} + +func (m *awsRestjson1_serializeOpIntrospectOAuth2TokenWithIAM) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( + out middleware.SerializeOutput, metadata middleware.Metadata, err error, +) { + _, span := tracing.StartSpan(ctx, "OperationSerializer") + endTimer := startMetricTimer(ctx, "client.call.serialization_duration") + defer endTimer() + defer span.End() + request, ok := in.Request.(*smithyhttp.Request) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} + } + + input, ok := in.Parameters.(*IntrospectOAuth2TokenWithIAMInput) + _ = input + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} + } + + opPath, opQuery := httpbinding.SplitURI("/v1/introspect?x-amz-client-auth-method=iam") + request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath) + request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery) + request.Method = "POST" + var restEncoder *httpbinding.Encoder + if request.URL.RawPath == "" { + restEncoder, err = httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) + } else { + request.URL.RawPath = smithyhttp.JoinPath(request.URL.RawPath, opPath) + restEncoder, err = httpbinding.NewEncoderWithRawPath(request.URL.Path, request.URL.RawPath, request.URL.RawQuery, request.Header) + } + + if err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + restEncoder.SetHeader("Content-Type").String("application/json") + + jsonEncoder := smithyjson.NewEncoder() + if err := awsRestjson1_serializeOpDocumentIntrospectOAuth2TokenWithIAMInput(input, jsonEncoder.Value); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if request.Request, err = restEncoder.Encode(request.Request); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + in.Request = request + + endTimer() + span.End() + return next.HandleSerialize(ctx, in) +} +func awsRestjson1_serializeOpHttpBindingsIntrospectOAuth2TokenWithIAMInput(v *IntrospectOAuth2TokenWithIAMInput, encoder *httpbinding.Encoder) error { + if v == nil { + return fmt.Errorf("unsupported serialization of nil %T", v) + } + + return nil +} + +func awsRestjson1_serializeOpDocumentIntrospectOAuth2TokenWithIAMInput(v *IntrospectOAuth2TokenWithIAMInput, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + if v.Token != nil { + ok := object.Key("token") + ok.String(*v.Token) + } + + if v.TokenTypeHint != nil { + ok := object.Key("token_type_hint") + ok.String(*v.TokenTypeHint) + } + + return nil +} + type awsRestjson1_serializeOpListResourcePermissionStatements struct { } @@ -686,6 +858,87 @@ func awsRestjson1_serializeOpDocumentPutResourcePermissionStatementInput(v *PutR return nil } +type awsRestjson1_serializeOpRevokeOAuth2TokenWithIAM struct { +} + +func (*awsRestjson1_serializeOpRevokeOAuth2TokenWithIAM) ID() string { + return "OperationSerializer" +} + +func (m *awsRestjson1_serializeOpRevokeOAuth2TokenWithIAM) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( + out middleware.SerializeOutput, metadata middleware.Metadata, err error, +) { + _, span := tracing.StartSpan(ctx, "OperationSerializer") + endTimer := startMetricTimer(ctx, "client.call.serialization_duration") + defer endTimer() + defer span.End() + request, ok := in.Request.(*smithyhttp.Request) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} + } + + input, ok := in.Parameters.(*RevokeOAuth2TokenWithIAMInput) + _ = input + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} + } + + opPath, opQuery := httpbinding.SplitURI("/v1/revoke?x-amz-client-auth-method=iam") + request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath) + request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery) + request.Method = "POST" + var restEncoder *httpbinding.Encoder + if request.URL.RawPath == "" { + restEncoder, err = httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) + } else { + request.URL.RawPath = smithyhttp.JoinPath(request.URL.RawPath, opPath) + restEncoder, err = httpbinding.NewEncoderWithRawPath(request.URL.Path, request.URL.RawPath, request.URL.RawQuery, request.Header) + } + + if err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + restEncoder.SetHeader("Content-Type").String("application/json") + + jsonEncoder := smithyjson.NewEncoder() + if err := awsRestjson1_serializeOpDocumentRevokeOAuth2TokenWithIAMInput(input, jsonEncoder.Value); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if request.Request, err = restEncoder.Encode(request.Request); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + in.Request = request + + endTimer() + span.End() + return next.HandleSerialize(ctx, in) +} +func awsRestjson1_serializeOpHttpBindingsRevokeOAuth2TokenWithIAMInput(v *RevokeOAuth2TokenWithIAMInput, encoder *httpbinding.Encoder) error { + if v == nil { + return fmt.Errorf("unsupported serialization of nil %T", v) + } + + return nil +} + +func awsRestjson1_serializeOpDocumentRevokeOAuth2TokenWithIAMInput(v *RevokeOAuth2TokenWithIAMInput, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + if v.Token != nil { + ok := object.Key("token") + ok.String(*v.Token) + } + + return nil +} + func awsRestjson1_serializeDocumentCreateOAuth2TokenRequestBody(v *types.CreateOAuth2TokenRequestBody, value smithyjson.Value) error { object := value.Object() defer object.Close() diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/types/types.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/types/types.go index aa4f7ecbe40..9e8bab7577c 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/types/types.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/types/types.go @@ -8,9 +8,7 @@ import ( // AWS credentials structure containing temporary access credentials // -// The scoped-down, 15 minute duration AWS credentials. Scoping down will be based -// on CLI policy (CLI team needs to create it). Similar to cloud shell -// implementation. +// Scoped, temporary AWS credentials with a 15-minute duration. type AccessToken struct { // AWS access key ID for temporary credentials diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/validators.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/validators.go index 8570cc5dbb5..8049ca28508 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/validators.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/validators.go @@ -30,6 +30,26 @@ func (m *validateOpCreateOAuth2Token) HandleInitialize(ctx context.Context, in m return next.HandleInitialize(ctx, in) } +type validateOpCreateOAuth2TokenWithIAM struct { +} + +func (*validateOpCreateOAuth2TokenWithIAM) ID() string { + return "OperationInputValidation" +} + +func (m *validateOpCreateOAuth2TokenWithIAM) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( + out middleware.InitializeOutput, metadata middleware.Metadata, err error, +) { + input, ok := in.Parameters.(*CreateOAuth2TokenWithIAMInput) + if !ok { + return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters) + } + if err := validateOpCreateOAuth2TokenWithIAMInput(input); err != nil { + return out, metadata, err + } + return next.HandleInitialize(ctx, in) +} + type validateOpDeleteResourcePermissionStatement struct { } @@ -50,14 +70,66 @@ func (m *validateOpDeleteResourcePermissionStatement) HandleInitialize(ctx conte return next.HandleInitialize(ctx, in) } +type validateOpIntrospectOAuth2TokenWithIAM struct { +} + +func (*validateOpIntrospectOAuth2TokenWithIAM) ID() string { + return "OperationInputValidation" +} + +func (m *validateOpIntrospectOAuth2TokenWithIAM) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( + out middleware.InitializeOutput, metadata middleware.Metadata, err error, +) { + input, ok := in.Parameters.(*IntrospectOAuth2TokenWithIAMInput) + if !ok { + return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters) + } + if err := validateOpIntrospectOAuth2TokenWithIAMInput(input); err != nil { + return out, metadata, err + } + return next.HandleInitialize(ctx, in) +} + +type validateOpRevokeOAuth2TokenWithIAM struct { +} + +func (*validateOpRevokeOAuth2TokenWithIAM) ID() string { + return "OperationInputValidation" +} + +func (m *validateOpRevokeOAuth2TokenWithIAM) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( + out middleware.InitializeOutput, metadata middleware.Metadata, err error, +) { + input, ok := in.Parameters.(*RevokeOAuth2TokenWithIAMInput) + if !ok { + return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters) + } + if err := validateOpRevokeOAuth2TokenWithIAMInput(input); err != nil { + return out, metadata, err + } + return next.HandleInitialize(ctx, in) +} + func addOpCreateOAuth2TokenValidationMiddleware(stack *middleware.Stack) error { return stack.Initialize.Add(&validateOpCreateOAuth2Token{}, middleware.After) } +func addOpCreateOAuth2TokenWithIAMValidationMiddleware(stack *middleware.Stack) error { + return stack.Initialize.Add(&validateOpCreateOAuth2TokenWithIAM{}, middleware.After) +} + func addOpDeleteResourcePermissionStatementValidationMiddleware(stack *middleware.Stack) error { return stack.Initialize.Add(&validateOpDeleteResourcePermissionStatement{}, middleware.After) } +func addOpIntrospectOAuth2TokenWithIAMValidationMiddleware(stack *middleware.Stack) error { + return stack.Initialize.Add(&validateOpIntrospectOAuth2TokenWithIAM{}, middleware.After) +} + +func addOpRevokeOAuth2TokenWithIAMValidationMiddleware(stack *middleware.Stack) error { + return stack.Initialize.Add(&validateOpRevokeOAuth2TokenWithIAM{}, middleware.After) +} + func validateCreateOAuth2TokenRequestBody(v *types.CreateOAuth2TokenRequestBody) error { if v == nil { return nil @@ -95,6 +167,24 @@ func validateOpCreateOAuth2TokenInput(v *CreateOAuth2TokenInput) error { } } +func validateOpCreateOAuth2TokenWithIAMInput(v *CreateOAuth2TokenWithIAMInput) error { + if v == nil { + return nil + } + invalidParams := smithy.InvalidParamsError{Context: "CreateOAuth2TokenWithIAMInput"} + if v.GrantType == nil { + invalidParams.Add(smithy.NewErrParamRequired("GrantType")) + } + if v.Resource == nil { + invalidParams.Add(smithy.NewErrParamRequired("Resource")) + } + if invalidParams.Len() > 0 { + return invalidParams + } else { + return nil + } +} + func validateOpDeleteResourcePermissionStatementInput(v *DeleteResourcePermissionStatementInput) error { if v == nil { return nil @@ -109,3 +199,33 @@ func validateOpDeleteResourcePermissionStatementInput(v *DeleteResourcePermissio return nil } } + +func validateOpIntrospectOAuth2TokenWithIAMInput(v *IntrospectOAuth2TokenWithIAMInput) error { + if v == nil { + return nil + } + invalidParams := smithy.InvalidParamsError{Context: "IntrospectOAuth2TokenWithIAMInput"} + if v.Token == nil { + invalidParams.Add(smithy.NewErrParamRequired("Token")) + } + if invalidParams.Len() > 0 { + return invalidParams + } else { + return nil + } +} + +func validateOpRevokeOAuth2TokenWithIAMInput(v *RevokeOAuth2TokenWithIAMInput) error { + if v == nil { + return nil + } + invalidParams := smithy.InvalidParamsError{Context: "RevokeOAuth2TokenWithIAMInput"} + if v.Token == nil { + invalidParams.Add(smithy.NewErrParamRequired("Token")) + } + if invalidParams.Len() > 0 { + return invalidParams + } else { + return nil + } +} diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/CHANGELOG.md index c15b7e19da8..a2a5c95002f 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/CHANGELOG.md @@ -1,3 +1,49 @@ +# v1.33.6 (2026-08-14) + +* **Dependency Update**: Update to smithy-go v1.27.8. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.33.5 (2026-08-10) + +* **Dependency Update**: Update to smithy-go v1.27.7. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.33.4 (2026-08-05) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.33.3 (2026-07-31.2) + +* **Dependency Update**: Updated to the latest SDK module versions +* **Dependency Update**: Upgrade to smithy-go v1.27.6 to fix various serde issues in HTTP binding services. + +# v1.33.2 (2026-07-29) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.33.1 (2026-07-28) + +* **Dependency Update**: Update to smithy-go v1.27.5. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.33.0 (2026-07-21) + +* **Feature**: Add an option to clients to disable clock skew +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.32.1 (2026-07-13) + +* No change notes available for this release. + +# v1.32.0 (2026-07-06) + +* **Feature**: Add request serialization snapshot tests. + +# v1.31.5 (2026-07-01) + +* **Bug Fix**: Bump smithy-go to 1.27.3, fix JSON encorder for document.Number, endpoint host label format validation and CBOR union serialization on new serde +* **Dependency Update**: Updated to the latest SDK module versions + # v1.31.4 (2026-06-29) * No change notes available for this release. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_client.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_client.go index 127944307d2..9e6f5b2bf37 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_client.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_client.go @@ -259,6 +259,10 @@ func (c *Client) invokeOperation( finalizeClientEndpointResolverOptions(&options) + ctx = setLoggerContext(ctx, options, opID) + + ctx = resolveServiceMetadata(ctx, options, opID) + if err := c.addCommonMiddlewares(stack, options, opID); err != nil { return nil, metadata, err } @@ -375,9 +379,6 @@ func (c *Client) addCommonMiddlewares(stack *middleware.Stack, options Options, if err := addProtocolFinalizerMiddlewares(stack, options, operation); err != nil { return fmt.Errorf("add protocol finalizers: %v", err) } - if err := addSetLoggerMiddleware(stack, options); err != nil { - return err - } if err := addClientRequestID(stack); err != nil { return err } @@ -430,30 +431,6 @@ func resolveAuthSchemes(options *Options) { type noSmithyDocumentSerde = smithydocument.NoSerde -type legacyEndpointContextSetter struct { - LegacyResolver EndpointResolver -} - -func (*legacyEndpointContextSetter) ID() string { - return "legacyEndpointContextSetter" -} - -func (m *legacyEndpointContextSetter) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( - out middleware.InitializeOutput, metadata middleware.Metadata, err error, -) { - if m.LegacyResolver != nil { - ctx = awsmiddleware.SetRequiresLegacyEndpoints(ctx, true) - } - - return next.HandleInitialize(ctx, in) - -} -func addlegacyEndpointContextSetter(stack *middleware.Stack, o Options) error { - return stack.Initialize.Add(&legacyEndpointContextSetter{ - LegacyResolver: o.EndpointResolver, - }, middleware.Before) -} - func resolveDefaultLogger(o *Options) { if o.Logger != nil { return @@ -461,8 +438,9 @@ func resolveDefaultLogger(o *Options) { o.Logger = logging.Nop{} } -func addSetLoggerMiddleware(stack *middleware.Stack, o Options) error { - return middleware.AddSetLoggerMiddleware(stack, o.Logger) +func setLoggerContext(ctx context.Context, options Options, operation string) context.Context { + _ = operation + return middleware.SetLogger(ctx, options.Logger) } func setResolvedDefaultsMode(o *Options) { @@ -483,16 +461,17 @@ func setResolvedDefaultsMode(o *Options) { // NewFromConfig returns a new client from the provided config. func NewFromConfig(cfg aws.Config, optFns ...func(*Options)) *Client { opts := Options{ - Region: cfg.Region, - DefaultsMode: cfg.DefaultsMode, - RuntimeEnvironment: cfg.RuntimeEnvironment, - HTTPClient: cfg.HTTPClient, - Credentials: cfg.Credentials, - APIOptions: cfg.APIOptions, - Logger: cfg.Logger, - ClientLogMode: cfg.ClientLogMode, - AppID: cfg.AppID, - AuthSchemePreference: cfg.AuthSchemePreference, + Region: cfg.Region, + DefaultsMode: cfg.DefaultsMode, + RuntimeEnvironment: cfg.RuntimeEnvironment, + HTTPClient: cfg.HTTPClient, + Credentials: cfg.Credentials, + APIOptions: cfg.APIOptions, + Logger: cfg.Logger, + ClientLogMode: cfg.ClientLogMode, + AppID: cfg.AppID, + DisableClockSkewCorrection: cfg.DisableClockSkewCorrection, + AuthSchemePreference: cfg.AuthSchemePreference, } resolveAWSRetryerProvider(cfg, &opts) resolveAWSRetryMaxAttempts(cfg, &opts) @@ -689,8 +668,10 @@ func addRawResponseToMetadata(stack *middleware.Stack) error { return stack.Deserialize.Add(&awsmiddleware.AddRawResponse{}, middleware.Before) } -func addRecordResponseTiming(stack *middleware.Stack) error { - return stack.Deserialize.Add(&awsmiddleware.RecordResponseTiming{}, middleware.After) +func addRecordResponseTiming(stack *middleware.Stack, options Options) error { + return stack.Deserialize.Add(&awsmiddleware.RecordResponseTiming{ + DisableClockSkewCorrection: options.DisableClockSkewCorrection, + }, middleware.After) } func addSpanRetryLoop(stack *middleware.Stack, options Options) error { @@ -761,6 +742,7 @@ func addRetry(stack *middleware.Stack, o Options, c *Client) error { m.LogAttempts = o.ClientLogMode.IsRetries() m.OperationMeter = o.MeterProvider.Meter("github.com/aws/aws-sdk-go-v2/service/sso") m.ClientSkew = c.timeOffset + m.DisableClockSkewCorrection = o.DisableClockSkewCorrection }) if err := stack.Finalize.Insert(attempt, "ResolveAuthScheme", middleware.Before); err != nil { return err @@ -863,12 +845,16 @@ func resolveMeterProvider(options *Options) { } } -func newServiceMetadataMiddleware(region, operation string) *awsmiddleware.RegisterServiceMetadata { - return &awsmiddleware.RegisterServiceMetadata{ - Region: region, - ServiceID: ServiceID, - OperationName: operation, +func resolveServiceMetadata(ctx context.Context, options Options, operation string) context.Context { + ctx = awsmiddleware.SetServiceID(ctx, ServiceID) + if options.Region != "" { + ctx = awsmiddleware.SetRegion(ctx, options.Region) + } + ctx = awsmiddleware.SetOperationName(ctx, operation) + if options.EndpointResolver != nil { + ctx = awsmiddleware.SetRequiresLegacyEndpoints(ctx, true) } + return ctx } func addRecursionDetection(stack *middleware.Stack) error { diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_op_GetRoleCredentials.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_op_GetRoleCredentials.go index a6532c20f14..83666293b70 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_op_GetRoleCredentials.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_op_GetRoleCredentials.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/service/sso/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Returns the STS short-term credentials for a given role name that is assigned @@ -70,22 +69,13 @@ func (c *Client) addOperationGetRoleCredentialsMiddlewares(stack *middleware.Sta return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } if err = addResolveEndpointMiddleware(stack, options); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -94,9 +84,6 @@ func (c *Client) addOperationGetRoleCredentialsMiddlewares(stack *middleware.Sta if err = addOpGetRoleCredentialsValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "GetRoleCredentials"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_op_ListAccountRoles.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_op_ListAccountRoles.go index b48097259ad..0bd420d8fdf 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_op_ListAccountRoles.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_op_ListAccountRoles.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/aws/aws-sdk-go-v2/service/sso/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Lists all roles that are assigned to the user for a given AWS account. @@ -76,22 +75,13 @@ func (c *Client) addOperationListAccountRolesMiddlewares(stack *middleware.Stack return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } if err = addResolveEndpointMiddleware(stack, options); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -100,9 +90,6 @@ func (c *Client) addOperationListAccountRolesMiddlewares(stack *middleware.Stack if err = addOpListAccountRolesValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "ListAccountRoles"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_op_ListAccounts.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_op_ListAccounts.go index 6142a5d39e9..ae1fd14aefe 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_op_ListAccounts.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_op_ListAccounts.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/aws/aws-sdk-go-v2/service/sso/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Lists all AWS accounts assigned to the user. These AWS accounts are assigned by @@ -75,22 +74,13 @@ func (c *Client) addOperationListAccountsMiddlewares(stack *middleware.Stack, op return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } if err = addResolveEndpointMiddleware(stack, options); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -99,9 +89,6 @@ func (c *Client) addOperationListAccountsMiddlewares(stack *middleware.Stack, op if err = addOpListAccountsValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "ListAccounts"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_op_Logout.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_op_Logout.go index ccafa26f4cf..49aa156d352 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_op_Logout.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/api_op_Logout.go @@ -5,7 +5,6 @@ package sso import ( "context" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Removes the locally stored SSO tokens from the client-side cache and sends an @@ -69,22 +68,13 @@ func (c *Client) addOperationLogoutMiddlewares(stack *middleware.Stack, options return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } if err = addResolveEndpointMiddleware(stack, options); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -93,9 +83,6 @@ func (c *Client) addOperationLogoutMiddlewares(stack *middleware.Stack, options if err = addOpLogoutValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "Logout"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/deserializers.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/deserializers.go index bfa1758c8a7..dbc691c49e8 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/deserializers.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/deserializers.go @@ -34,15 +34,18 @@ func (m *awsRestjson1_deserializeOpGetRoleCredentials) HandleDeserialize(ctx con return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorGetRoleCredentials(response, &metadata) } @@ -195,15 +198,18 @@ func (m *awsRestjson1_deserializeOpListAccountRoles) HandleDeserialize(ctx conte return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorListAccountRoles(response, &metadata) } @@ -365,15 +371,18 @@ func (m *awsRestjson1_deserializeOpListAccounts) HandleDeserialize(ctx context.C return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorListAccounts(response, &metadata) } @@ -535,15 +544,18 @@ func (m *awsRestjson1_deserializeOpLogout) HandleDeserialize(ctx context.Context return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorLogout(response, &metadata) } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/generated.json b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/generated.json index 39a393d441c..7aca52b604f 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/generated.json +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/generated.json @@ -22,6 +22,8 @@ "internal/endpoints/endpoints.go", "internal/endpoints/endpoints_test.go", "options.go", + "request_snapshot_test.go", + "response_snapshot_test.go", "serializers.go", "snapshot_test.go", "sra_operation_order_test.go", diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/go_module_metadata.go index 7bc725826c3..332de17ff03 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/go_module_metadata.go @@ -3,4 +3,4 @@ package sso // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.31.4" +const goModuleVersion = "1.33.6" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/options.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/options.go index 8b4e34d0642..fbe3ff2a2e2 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/options.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/options.go @@ -44,6 +44,11 @@ type Options struct { // clients initial default settings. DefaultsMode aws.DefaultsMode + // Disables SDK clock skew correction. When set, the SDK will not adjust request + // signing timestamps to compensate for clock drift between the client and the + // service. + DisableClockSkewCorrection bool + // The endpoint options to be used when attempting to resolve an endpoint. EndpointOptions EndpointResolverOptions diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/CHANGELOG.md index f0bac803b8a..b3b446d0f45 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/CHANGELOG.md @@ -1,3 +1,49 @@ +# v1.38.6 (2026-08-14) + +* **Dependency Update**: Update to smithy-go v1.27.8. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.38.5 (2026-08-10) + +* **Dependency Update**: Update to smithy-go v1.27.7. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.38.4 (2026-08-05) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.38.3 (2026-07-31.2) + +* **Dependency Update**: Updated to the latest SDK module versions +* **Dependency Update**: Upgrade to smithy-go v1.27.6 to fix various serde issues in HTTP binding services. + +# v1.38.2 (2026-07-29) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.38.1 (2026-07-28) + +* **Dependency Update**: Update to smithy-go v1.27.5. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.38.0 (2026-07-21) + +* **Feature**: Add an option to clients to disable clock skew +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.37.1 (2026-07-13) + +* No change notes available for this release. + +# v1.37.0 (2026-07-06) + +* **Feature**: Add request serialization snapshot tests. + +# v1.36.8 (2026-07-01) + +* **Bug Fix**: Bump smithy-go to 1.27.3, fix JSON encorder for document.Number, endpoint host label format validation and CBOR union serialization on new serde +* **Dependency Update**: Updated to the latest SDK module versions + # v1.36.7 (2026-06-29) * No change notes available for this release. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_client.go b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_client.go index ebdaff6e62e..26c0798b6c2 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_client.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_client.go @@ -259,6 +259,10 @@ func (c *Client) invokeOperation( finalizeClientEndpointResolverOptions(&options) + ctx = setLoggerContext(ctx, options, opID) + + ctx = resolveServiceMetadata(ctx, options, opID) + if err := c.addCommonMiddlewares(stack, options, opID); err != nil { return nil, metadata, err } @@ -375,9 +379,6 @@ func (c *Client) addCommonMiddlewares(stack *middleware.Stack, options Options, if err := addProtocolFinalizerMiddlewares(stack, options, operation); err != nil { return fmt.Errorf("add protocol finalizers: %v", err) } - if err := addSetLoggerMiddleware(stack, options); err != nil { - return err - } if err := addClientRequestID(stack); err != nil { return err } @@ -430,30 +431,6 @@ func resolveAuthSchemes(options *Options) { type noSmithyDocumentSerde = smithydocument.NoSerde -type legacyEndpointContextSetter struct { - LegacyResolver EndpointResolver -} - -func (*legacyEndpointContextSetter) ID() string { - return "legacyEndpointContextSetter" -} - -func (m *legacyEndpointContextSetter) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( - out middleware.InitializeOutput, metadata middleware.Metadata, err error, -) { - if m.LegacyResolver != nil { - ctx = awsmiddleware.SetRequiresLegacyEndpoints(ctx, true) - } - - return next.HandleInitialize(ctx, in) - -} -func addlegacyEndpointContextSetter(stack *middleware.Stack, o Options) error { - return stack.Initialize.Add(&legacyEndpointContextSetter{ - LegacyResolver: o.EndpointResolver, - }, middleware.Before) -} - func resolveDefaultLogger(o *Options) { if o.Logger != nil { return @@ -461,8 +438,9 @@ func resolveDefaultLogger(o *Options) { o.Logger = logging.Nop{} } -func addSetLoggerMiddleware(stack *middleware.Stack, o Options) error { - return middleware.AddSetLoggerMiddleware(stack, o.Logger) +func setLoggerContext(ctx context.Context, options Options, operation string) context.Context { + _ = operation + return middleware.SetLogger(ctx, options.Logger) } func setResolvedDefaultsMode(o *Options) { @@ -483,16 +461,17 @@ func setResolvedDefaultsMode(o *Options) { // NewFromConfig returns a new client from the provided config. func NewFromConfig(cfg aws.Config, optFns ...func(*Options)) *Client { opts := Options{ - Region: cfg.Region, - DefaultsMode: cfg.DefaultsMode, - RuntimeEnvironment: cfg.RuntimeEnvironment, - HTTPClient: cfg.HTTPClient, - Credentials: cfg.Credentials, - APIOptions: cfg.APIOptions, - Logger: cfg.Logger, - ClientLogMode: cfg.ClientLogMode, - AppID: cfg.AppID, - AuthSchemePreference: cfg.AuthSchemePreference, + Region: cfg.Region, + DefaultsMode: cfg.DefaultsMode, + RuntimeEnvironment: cfg.RuntimeEnvironment, + HTTPClient: cfg.HTTPClient, + Credentials: cfg.Credentials, + APIOptions: cfg.APIOptions, + Logger: cfg.Logger, + ClientLogMode: cfg.ClientLogMode, + AppID: cfg.AppID, + DisableClockSkewCorrection: cfg.DisableClockSkewCorrection, + AuthSchemePreference: cfg.AuthSchemePreference, } resolveAWSRetryerProvider(cfg, &opts) resolveAWSRetryMaxAttempts(cfg, &opts) @@ -689,8 +668,10 @@ func addRawResponseToMetadata(stack *middleware.Stack) error { return stack.Deserialize.Add(&awsmiddleware.AddRawResponse{}, middleware.Before) } -func addRecordResponseTiming(stack *middleware.Stack) error { - return stack.Deserialize.Add(&awsmiddleware.RecordResponseTiming{}, middleware.After) +func addRecordResponseTiming(stack *middleware.Stack, options Options) error { + return stack.Deserialize.Add(&awsmiddleware.RecordResponseTiming{ + DisableClockSkewCorrection: options.DisableClockSkewCorrection, + }, middleware.After) } func addSpanRetryLoop(stack *middleware.Stack, options Options) error { @@ -761,6 +742,7 @@ func addRetry(stack *middleware.Stack, o Options, c *Client) error { m.LogAttempts = o.ClientLogMode.IsRetries() m.OperationMeter = o.MeterProvider.Meter("github.com/aws/aws-sdk-go-v2/service/ssooidc") m.ClientSkew = c.timeOffset + m.DisableClockSkewCorrection = o.DisableClockSkewCorrection }) if err := stack.Finalize.Insert(attempt, "ResolveAuthScheme", middleware.Before); err != nil { return err @@ -863,12 +845,16 @@ func resolveMeterProvider(options *Options) { } } -func newServiceMetadataMiddleware(region, operation string) *awsmiddleware.RegisterServiceMetadata { - return &awsmiddleware.RegisterServiceMetadata{ - Region: region, - ServiceID: ServiceID, - OperationName: operation, +func resolveServiceMetadata(ctx context.Context, options Options, operation string) context.Context { + ctx = awsmiddleware.SetServiceID(ctx, ServiceID) + if options.Region != "" { + ctx = awsmiddleware.SetRegion(ctx, options.Region) + } + ctx = awsmiddleware.SetOperationName(ctx, operation) + if options.EndpointResolver != nil { + ctx = awsmiddleware.SetRequiresLegacyEndpoints(ctx, true) } + return ctx } func addRecursionDetection(stack *middleware.Stack) error { diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_op_CreateToken.go b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_op_CreateToken.go index 5c1df1c088b..628e10486a8 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_op_CreateToken.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_op_CreateToken.go @@ -5,7 +5,6 @@ package ssooidc import ( "context" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Creates and returns access and refresh tokens for clients that are @@ -140,22 +139,13 @@ func (c *Client) addOperationCreateTokenMiddlewares(stack *middleware.Stack, opt return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } if err = addResolveEndpointMiddleware(stack, options); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -164,9 +154,6 @@ func (c *Client) addOperationCreateTokenMiddlewares(stack *middleware.Stack, opt if err = addOpCreateTokenValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "CreateToken"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_op_CreateTokenWithIAM.go b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_op_CreateTokenWithIAM.go index 088e7f2ec88..ce634d260b2 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_op_CreateTokenWithIAM.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_op_CreateTokenWithIAM.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/service/ssooidc/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Creates and returns access and refresh tokens for authorized client @@ -184,9 +183,6 @@ func (c *Client) addOperationCreateTokenWithIAMMiddlewares(stack *middleware.Sta return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -196,13 +192,7 @@ func (c *Client) addOperationCreateTokenWithIAMMiddlewares(stack *middleware.Sta if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -211,9 +201,6 @@ func (c *Client) addOperationCreateTokenWithIAMMiddlewares(stack *middleware.Sta if err = addOpCreateTokenWithIAMValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "CreateTokenWithIAM"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_op_RegisterClient.go b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_op_RegisterClient.go index 4632f365695..755ed68b7b7 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_op_RegisterClient.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_op_RegisterClient.go @@ -5,7 +5,6 @@ package ssooidc import ( "context" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Registers a public client with IAM Identity Center. This allows clients to @@ -111,22 +110,13 @@ func (c *Client) addOperationRegisterClientMiddlewares(stack *middleware.Stack, return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } if err = addResolveEndpointMiddleware(stack, options); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -135,9 +125,6 @@ func (c *Client) addOperationRegisterClientMiddlewares(stack *middleware.Stack, if err = addOpRegisterClientValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "RegisterClient"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_op_StartDeviceAuthorization.go b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_op_StartDeviceAuthorization.go index 3417f8dbd33..7a05e9f640d 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_op_StartDeviceAuthorization.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/api_op_StartDeviceAuthorization.go @@ -5,7 +5,6 @@ package ssooidc import ( "context" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Initiates device authorization by requesting a pair of verification codes from @@ -93,22 +92,13 @@ func (c *Client) addOperationStartDeviceAuthorizationMiddlewares(stack *middlewa return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } if err = addResolveEndpointMiddleware(stack, options); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -117,9 +107,6 @@ func (c *Client) addOperationStartDeviceAuthorizationMiddlewares(stack *middlewa if err = addOpStartDeviceAuthorizationValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "StartDeviceAuthorization"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/deserializers.go b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/deserializers.go index fb9a0df5194..da4a9e2f540 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/deserializers.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/deserializers.go @@ -34,15 +34,18 @@ func (m *awsRestjson1_deserializeOpCreateToken) HandleDeserialize(ctx context.Co return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorCreateToken(response, &metadata) } @@ -260,15 +263,18 @@ func (m *awsRestjson1_deserializeOpCreateTokenWithIAM) HandleDeserialize(ctx con return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorCreateTokenWithIAM(response, &metadata) } @@ -508,15 +514,18 @@ func (m *awsRestjson1_deserializeOpRegisterClient) HandleDeserialize(ctx context return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorRegisterClient(response, &metadata) } @@ -735,15 +744,18 @@ func (m *awsRestjson1_deserializeOpStartDeviceAuthorization) HandleDeserialize(c return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorStartDeviceAuthorization(response, &metadata) } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/generated.json b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/generated.json index 1e34b9a9d50..8f46b38d329 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/generated.json +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/generated.json @@ -22,6 +22,8 @@ "internal/endpoints/endpoints.go", "internal/endpoints/endpoints_test.go", "options.go", + "request_snapshot_test.go", + "response_snapshot_test.go", "serializers.go", "snapshot_test.go", "sra_operation_order_test.go", diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/go_module_metadata.go index d1f579cfae8..48d809654db 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/go_module_metadata.go @@ -3,4 +3,4 @@ package ssooidc // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.36.7" +const goModuleVersion = "1.38.6" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/options.go b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/options.go index c2eac091904..73a47ccfb8c 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/options.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/options.go @@ -44,6 +44,11 @@ type Options struct { // clients initial default settings. DefaultsMode aws.DefaultsMode + // Disables SDK clock skew correction. When set, the SDK will not adjust request + // signing timestamps to compensate for clock drift between the client and the + // service. + DisableClockSkewCorrection bool + // The endpoint options to be used when attempting to resolve an endpoint. EndpointOptions EndpointResolverOptions diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/CHANGELOG.md index d0dbd1b80f9..33bbd24cfb6 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/CHANGELOG.md @@ -1,3 +1,49 @@ +# v1.45.6 (2026-08-14) + +* **Dependency Update**: Update to smithy-go v1.27.8. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.45.5 (2026-08-10) + +* **Dependency Update**: Update to smithy-go v1.27.7. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.45.4 (2026-08-05) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.45.3 (2026-07-31.2) + +* **Dependency Update**: Updated to the latest SDK module versions +* **Dependency Update**: Upgrade to smithy-go v1.27.6 to fix various serde issues in HTTP binding services. + +# v1.45.2 (2026-07-29) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.45.1 (2026-07-28) + +* **Dependency Update**: Update to smithy-go v1.27.5. +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.45.0 (2026-07-21) + +* **Feature**: Add an option to clients to disable clock skew +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.44.1 (2026-07-13) + +* No change notes available for this release. + +# v1.44.0 (2026-07-06) + +* **Feature**: Add request serialization snapshot tests. + +# v1.43.5 (2026-07-01) + +* **Bug Fix**: Bump smithy-go to 1.27.3, fix JSON encorder for document.Number, endpoint host label format validation and CBOR union serialization on new serde +* **Dependency Update**: Updated to the latest SDK module versions + # v1.43.4 (2026-06-29) * No change notes available for this release. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_client.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_client.go index c0d927a0c8d..78dd88486e7 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_client.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_client.go @@ -268,6 +268,10 @@ func (c *Client) invokeOperation( finalizeClientEndpointResolverOptions(&options) + ctx = setLoggerContext(ctx, options, opID) + + ctx = resolveServiceMetadata(ctx, options, opID) + if err := c.addCommonMiddlewares(stack, options, opID); err != nil { return nil, metadata, err } @@ -384,9 +388,6 @@ func (c *Client) addCommonMiddlewares(stack *middleware.Stack, options Options, if err := addProtocolFinalizerMiddlewares(stack, options, operation); err != nil { return fmt.Errorf("add protocol finalizers: %v", err) } - if err := addSetLoggerMiddleware(stack, options); err != nil { - return err - } if err := addClientRequestID(stack); err != nil { return err } @@ -444,30 +445,6 @@ func resolveAuthSchemes(options *Options) { type noSmithyDocumentSerde = smithydocument.NoSerde -type legacyEndpointContextSetter struct { - LegacyResolver EndpointResolver -} - -func (*legacyEndpointContextSetter) ID() string { - return "legacyEndpointContextSetter" -} - -func (m *legacyEndpointContextSetter) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( - out middleware.InitializeOutput, metadata middleware.Metadata, err error, -) { - if m.LegacyResolver != nil { - ctx = awsmiddleware.SetRequiresLegacyEndpoints(ctx, true) - } - - return next.HandleInitialize(ctx, in) - -} -func addlegacyEndpointContextSetter(stack *middleware.Stack, o Options) error { - return stack.Initialize.Add(&legacyEndpointContextSetter{ - LegacyResolver: o.EndpointResolver, - }, middleware.Before) -} - func resolveDefaultLogger(o *Options) { if o.Logger != nil { return @@ -475,8 +452,9 @@ func resolveDefaultLogger(o *Options) { o.Logger = logging.Nop{} } -func addSetLoggerMiddleware(stack *middleware.Stack, o Options) error { - return middleware.AddSetLoggerMiddleware(stack, o.Logger) +func setLoggerContext(ctx context.Context, options Options, operation string) context.Context { + _ = operation + return middleware.SetLogger(ctx, options.Logger) } func setResolvedDefaultsMode(o *Options) { @@ -497,16 +475,17 @@ func setResolvedDefaultsMode(o *Options) { // NewFromConfig returns a new client from the provided config. func NewFromConfig(cfg aws.Config, optFns ...func(*Options)) *Client { opts := Options{ - Region: cfg.Region, - DefaultsMode: cfg.DefaultsMode, - RuntimeEnvironment: cfg.RuntimeEnvironment, - HTTPClient: cfg.HTTPClient, - Credentials: cfg.Credentials, - APIOptions: cfg.APIOptions, - Logger: cfg.Logger, - ClientLogMode: cfg.ClientLogMode, - AppID: cfg.AppID, - AuthSchemePreference: cfg.AuthSchemePreference, + Region: cfg.Region, + DefaultsMode: cfg.DefaultsMode, + RuntimeEnvironment: cfg.RuntimeEnvironment, + HTTPClient: cfg.HTTPClient, + Credentials: cfg.Credentials, + APIOptions: cfg.APIOptions, + Logger: cfg.Logger, + ClientLogMode: cfg.ClientLogMode, + AppID: cfg.AppID, + DisableClockSkewCorrection: cfg.DisableClockSkewCorrection, + AuthSchemePreference: cfg.AuthSchemePreference, } resolveAWSRetryerProvider(cfg, &opts) resolveAWSRetryMaxAttempts(cfg, &opts) @@ -703,8 +682,10 @@ func addRawResponseToMetadata(stack *middleware.Stack) error { return stack.Deserialize.Add(&awsmiddleware.AddRawResponse{}, middleware.Before) } -func addRecordResponseTiming(stack *middleware.Stack) error { - return stack.Deserialize.Add(&awsmiddleware.RecordResponseTiming{}, middleware.After) +func addRecordResponseTiming(stack *middleware.Stack, options Options) error { + return stack.Deserialize.Add(&awsmiddleware.RecordResponseTiming{ + DisableClockSkewCorrection: options.DisableClockSkewCorrection, + }, middleware.After) } func addSpanRetryLoop(stack *middleware.Stack, options Options) error { @@ -775,6 +756,7 @@ func addRetry(stack *middleware.Stack, o Options, c *Client) error { m.LogAttempts = o.ClientLogMode.IsRetries() m.OperationMeter = o.MeterProvider.Meter("github.com/aws/aws-sdk-go-v2/service/sts") m.ClientSkew = c.timeOffset + m.DisableClockSkewCorrection = o.DisableClockSkewCorrection }) if err := stack.Finalize.Insert(attempt, "ResolveAuthScheme", middleware.Before); err != nil { return err @@ -901,12 +883,16 @@ func resolveMeterProvider(options *Options) { } } -func newServiceMetadataMiddleware(region, operation string) *awsmiddleware.RegisterServiceMetadata { - return &awsmiddleware.RegisterServiceMetadata{ - Region: region, - ServiceID: ServiceID, - OperationName: operation, +func resolveServiceMetadata(ctx context.Context, options Options, operation string) context.Context { + ctx = awsmiddleware.SetServiceID(ctx, ServiceID) + if options.Region != "" { + ctx = awsmiddleware.SetRegion(ctx, options.Region) + } + ctx = awsmiddleware.SetOperationName(ctx, operation) + if options.EndpointResolver != nil { + ctx = awsmiddleware.SetRequiresLegacyEndpoints(ctx, true) } + return ctx } func addRecursionDetection(stack *middleware.Stack) error { diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_AssumeRole.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_AssumeRole.go index a1c0534bc54..ba1798d541d 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_AssumeRole.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_AssumeRole.go @@ -7,7 +7,6 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/signer/v4" "github.com/aws/aws-sdk-go-v2/service/sts/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Returns a set of temporary security credentials that you can use to access @@ -422,9 +421,6 @@ func (c *Client) addOperationAssumeRoleMiddlewares(stack *middleware.Stack, opti return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -434,13 +430,7 @@ func (c *Client) addOperationAssumeRoleMiddlewares(stack *middleware.Stack, opti if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -449,9 +439,6 @@ func (c *Client) addOperationAssumeRoleMiddlewares(stack *middleware.Stack, opti if err = addOpAssumeRoleValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "AssumeRole"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_AssumeRoleWithSAML.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_AssumeRoleWithSAML.go index 16ffcf2efba..565120003a8 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_AssumeRoleWithSAML.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_AssumeRoleWithSAML.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/service/sts/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Returns a set of temporary security credentials for users who have been @@ -360,22 +359,13 @@ func (c *Client) addOperationAssumeRoleWithSAMLMiddlewares(stack *middleware.Sta return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } if err = addResolveEndpointMiddleware(stack, options); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -384,9 +374,6 @@ func (c *Client) addOperationAssumeRoleWithSAMLMiddlewares(stack *middleware.Sta if err = addOpAssumeRoleWithSAMLValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "AssumeRoleWithSAML"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_AssumeRoleWithWebIdentity.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_AssumeRoleWithWebIdentity.go index 2fe5f9284f1..f1bd15a00e7 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_AssumeRoleWithWebIdentity.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_AssumeRoleWithWebIdentity.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/service/sts/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Returns a set of temporary security credentials for users who have been @@ -377,22 +376,13 @@ func (c *Client) addOperationAssumeRoleWithWebIdentityMiddlewares(stack *middlew return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } if err = addResolveEndpointMiddleware(stack, options); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -401,9 +391,6 @@ func (c *Client) addOperationAssumeRoleWithWebIdentityMiddlewares(stack *middlew if err = addOpAssumeRoleWithWebIdentityValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "AssumeRoleWithWebIdentity"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_AssumeRoot.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_AssumeRoot.go index 353512bb265..1687dc74e50 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_AssumeRoot.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_AssumeRoot.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/service/sts/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Returns a set of short term credentials you can use to perform privileged tasks @@ -131,9 +130,6 @@ func (c *Client) addOperationAssumeRootMiddlewares(stack *middleware.Stack, opti return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -143,13 +139,7 @@ func (c *Client) addOperationAssumeRootMiddlewares(stack *middleware.Stack, opti if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -158,9 +148,6 @@ func (c *Client) addOperationAssumeRootMiddlewares(stack *middleware.Stack, opti if err = addOpAssumeRootValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "AssumeRoot"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_DecodeAuthorizationMessage.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_DecodeAuthorizationMessage.go index 2e54340ef41..819b5d9f2f7 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_DecodeAuthorizationMessage.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_DecodeAuthorizationMessage.go @@ -5,7 +5,6 @@ package sts import ( "context" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Decodes additional information about the authorization status of a request from @@ -91,9 +90,6 @@ func (c *Client) addOperationDecodeAuthorizationMessageMiddlewares(stack *middle return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -103,13 +99,7 @@ func (c *Client) addOperationDecodeAuthorizationMessageMiddlewares(stack *middle if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -118,9 +108,6 @@ func (c *Client) addOperationDecodeAuthorizationMessageMiddlewares(stack *middle if err = addOpDecodeAuthorizationMessageValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "DecodeAuthorizationMessage"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetAccessKeyInfo.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetAccessKeyInfo.go index c1e9af44033..cf424c8625b 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetAccessKeyInfo.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetAccessKeyInfo.go @@ -5,7 +5,6 @@ package sts import ( "context" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Returns the account identifier for the specified access key ID. @@ -82,9 +81,6 @@ func (c *Client) addOperationGetAccessKeyInfoMiddlewares(stack *middleware.Stack return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -94,13 +90,7 @@ func (c *Client) addOperationGetAccessKeyInfoMiddlewares(stack *middleware.Stack if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -109,9 +99,6 @@ func (c *Client) addOperationGetAccessKeyInfoMiddlewares(stack *middleware.Stack if err = addOpGetAccessKeyInfoValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "GetAccessKeyInfo"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetCallerIdentity.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetCallerIdentity.go index 7c2b4e92203..d4148a1c35b 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetCallerIdentity.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetCallerIdentity.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws/signer/v4" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Returns details about the IAM user or role whose credentials are used to call @@ -73,9 +72,6 @@ func (c *Client) addOperationGetCallerIdentityMiddlewares(stack *middleware.Stac return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -85,21 +81,12 @@ func (c *Client) addOperationGetCallerIdentityMiddlewares(stack *middleware.Stac if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "GetCallerIdentity"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetDelegatedAccessToken.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetDelegatedAccessToken.go index e00165161e3..e0e06728908 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetDelegatedAccessToken.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetDelegatedAccessToken.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/service/sts/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Exchanges a trade-in token for temporary Amazon Web Services credentials with @@ -71,9 +70,6 @@ func (c *Client) addOperationGetDelegatedAccessTokenMiddlewares(stack *middlewar return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -83,13 +79,7 @@ func (c *Client) addOperationGetDelegatedAccessTokenMiddlewares(stack *middlewar if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -98,9 +88,6 @@ func (c *Client) addOperationGetDelegatedAccessTokenMiddlewares(stack *middlewar if err = addOpGetDelegatedAccessTokenValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "GetDelegatedAccessToken"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetFederationToken.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetFederationToken.go index ba5f92bef8c..606d0cdc267 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetFederationToken.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetFederationToken.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/service/sts/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Returns a set of temporary security credentials (consisting of an access key @@ -295,9 +294,6 @@ func (c *Client) addOperationGetFederationTokenMiddlewares(stack *middleware.Sta return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -307,13 +303,7 @@ func (c *Client) addOperationGetFederationTokenMiddlewares(stack *middleware.Sta if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -322,9 +312,6 @@ func (c *Client) addOperationGetFederationTokenMiddlewares(stack *middleware.Sta if err = addOpGetFederationTokenValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "GetFederationToken"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetSessionToken.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetSessionToken.go index 644e95ece86..873090b1e91 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetSessionToken.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetSessionToken.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/service/sts/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" ) // Returns a set of temporary credentials for an Amazon Web Services account or @@ -144,9 +143,6 @@ func (c *Client) addOperationGetSessionTokenMiddlewares(stack *middleware.Stack, return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -156,21 +152,12 @@ func (c *Client) addOperationGetSessionTokenMiddlewares(stack *middleware.Stack, if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "GetSessionToken"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetWebIdentityToken.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetWebIdentityToken.go index 09cbebc2531..4525e2e247c 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetWebIdentityToken.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetWebIdentityToken.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/service/sts/types" "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" "time" ) @@ -94,9 +93,6 @@ func (c *Client) addOperationGetWebIdentityTokenMiddlewares(stack *middleware.St return err } - if err = addlegacyEndpointContextSetter(stack, options); err != nil { - return err - } if err = addComputeContentLength(stack); err != nil { return err } @@ -106,13 +102,7 @@ func (c *Client) addOperationGetWebIdentityTokenMiddlewares(stack *middleware.St if err = addComputePayloadSHA256(stack); err != nil { return err } - if err = addRecordResponseTiming(stack); err != nil { - return err - } - if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { - return err - } - if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + if err = addRecordResponseTiming(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { @@ -121,9 +111,6 @@ func (c *Client) addOperationGetWebIdentityTokenMiddlewares(stack *middleware.St if err = addOpGetWebIdentityTokenValidationMiddleware(stack); err != nil { return err } - if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "GetWebIdentityToken"), middleware.Before); err != nil { - return err - } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/deserializers.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/deserializers.go index 8c1ce351616..45e073ffdc4 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/deserializers.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/deserializers.go @@ -38,15 +38,18 @@ func (m *awsAwsquery_deserializeOpAssumeRole) HandleDeserialize(ctx context.Cont return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsquery_deserializeOpErrorAssumeRole(response, &metadata) } @@ -159,15 +162,18 @@ func (m *awsAwsquery_deserializeOpAssumeRoleWithSAML) HandleDeserialize(ctx cont return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsquery_deserializeOpErrorAssumeRoleWithSAML(response, &metadata) } @@ -286,15 +292,18 @@ func (m *awsAwsquery_deserializeOpAssumeRoleWithWebIdentity) HandleDeserialize(c return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsquery_deserializeOpErrorAssumeRoleWithWebIdentity(response, &metadata) } @@ -416,15 +425,18 @@ func (m *awsAwsquery_deserializeOpAssumeRoot) HandleDeserialize(ctx context.Cont return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsquery_deserializeOpErrorAssumeRoot(response, &metadata) } @@ -531,15 +543,18 @@ func (m *awsAwsquery_deserializeOpDecodeAuthorizationMessage) HandleDeserialize( return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsquery_deserializeOpErrorDecodeAuthorizationMessage(response, &metadata) } @@ -643,15 +658,18 @@ func (m *awsAwsquery_deserializeOpGetAccessKeyInfo) HandleDeserialize(ctx contex return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsquery_deserializeOpErrorGetAccessKeyInfo(response, &metadata) } @@ -752,15 +770,18 @@ func (m *awsAwsquery_deserializeOpGetCallerIdentity) HandleDeserialize(ctx conte return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsquery_deserializeOpErrorGetCallerIdentity(response, &metadata) } @@ -861,15 +882,18 @@ func (m *awsAwsquery_deserializeOpGetDelegatedAccessToken) HandleDeserialize(ctx return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsquery_deserializeOpErrorGetDelegatedAccessToken(response, &metadata) } @@ -979,15 +1003,18 @@ func (m *awsAwsquery_deserializeOpGetFederationToken) HandleDeserialize(ctx cont return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsquery_deserializeOpErrorGetFederationToken(response, &metadata) } @@ -1097,15 +1124,18 @@ func (m *awsAwsquery_deserializeOpGetSessionToken) HandleDeserialize(ctx context return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsquery_deserializeOpErrorGetSessionToken(response, &metadata) } @@ -1209,15 +1239,18 @@ func (m *awsAwsquery_deserializeOpGetWebIdentityToken) HandleDeserialize(ctx con return out, metadata, err } - _, span := tracing.StartSpan(ctx, "OperationDeserializer") - endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") - defer endTimer() - defer span.End() response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } + defer func() { smithyhttp.CloseResponseBody(ctx, response, false, err) }() + + _, span := tracing.StartSpan(ctx, "OperationDeserializer") + endTimer := startMetricTimer(ctx, "client.call.deserialization_duration") + defer endTimer() + defer span.End() + if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsAwsquery_deserializeOpErrorGetWebIdentityToken(response, &metadata) } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/generated.json b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/generated.json index 2fc7b400f7c..6a759b4cc20 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/generated.json +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/generated.json @@ -32,6 +32,8 @@ "internal/endpoints/endpoints.go", "internal/endpoints/endpoints_test.go", "options.go", + "request_snapshot_test.go", + "response_snapshot_test.go", "serializers.go", "snapshot_test.go", "sra_operation_order_test.go", diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/go_module_metadata.go index 92bbf3754ba..f2b5c084672 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/go_module_metadata.go @@ -3,4 +3,4 @@ package sts // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.43.4" +const goModuleVersion = "1.45.6" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/options.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/options.go index a9f2361fd32..b3c9df17f3c 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/options.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/options.go @@ -46,6 +46,11 @@ type Options struct { // clients initial default settings. DefaultsMode aws.DefaultsMode + // Disables SDK clock skew correction. When set, the SDK will not adjust request + // signing timestamps to compensate for clock drift between the client and the + // service. + DisableClockSkewCorrection bool + // The endpoint options to be used when attempting to resolve an endpoint. EndpointOptions EndpointResolverOptions diff --git a/vendor/github.com/aws/smithy-go/AGENTS.md b/vendor/github.com/aws/smithy-go/AGENTS.md index e2a75b8ea19..de1e3b2bbe9 100644 --- a/vendor/github.com/aws/smithy-go/AGENTS.md +++ b/vendor/github.com/aws/smithy-go/AGENTS.md @@ -68,8 +68,9 @@ cd codegen && ./gradlew build cd codegen && ./gradlew publishToMavenLocal ``` -The codegen artifact version is fixed at `0.1.0` and is not published to -Maven Central — you **MUST** `publishToMavenLocal`. +The codegen artifact version is published to Maven Central and bumped on each +release. For local development against unreleased codegen changes, use +`publishToMavenLocal` and point consumers at `mavenLocal()`. ## Runtime architecture diff --git a/vendor/github.com/aws/smithy-go/CHANGELOG.md b/vendor/github.com/aws/smithy-go/CHANGELOG.md index 6ff611a8df0..88de0403e0b 100644 --- a/vendor/github.com/aws/smithy-go/CHANGELOG.md +++ b/vendor/github.com/aws/smithy-go/CHANGELOG.md @@ -1,3 +1,70 @@ +# Release (2026-08-14) + +## General Highlights +* **Dependency Update**: Updated to the latest SDK module versions + +## Module Highlights +* `github.com/aws/smithy-go`: v1.27.8 + * **Bug Fix**: Restore draining the HTTP response body in `CloseResponseBody` to avoid issues with TCP connection reuse. + +# Release (2026-08-07) + +## General Highlights +* **Dependency Update**: Updated to the latest SDK module versions + +## Module Highlights +* `github.com/aws/smithy-go`: v1.27.7 + * **Bug Fix**: Don't serialize unset JSON documents as `nil` in structure members. + * **Bug Fix**: Fix a deserialization panic around collection members in recursive shape configs. + +# Release (2026-07-31) + +## General Highlights +* **Dependency Update**: Updated to the latest SDK module versions + +## Module Highlights +* `github.com/aws/smithy-go`: v1.27.6 + * **Bug Fix**: Fix failure to deserialize any `@httpPayload` struct with a non-string member. + * **Bug Fix**: Fix failure to serialize any `@httpPayload` struct with a nested struct. + +# Release (2026-07-27) + +## General Highlights +* **Dependency Update**: Updated to the latest SDK module versions + +## Module Highlights +* `github.com/aws/smithy-go`: v1.27.5 + * **Bug Fix**: Fix a performance issue in awsQuery with large response payloads. + +# Release (2026-07-16) + +## General Highlights +* **Dependency Update**: Updated to the latest SDK module versions + +## Module Highlights +* `github.com/aws/smithy-go/aws-http-auth`: [v1.2.1](aws-http-auth/CHANGELOG.md#v121-2026-07-16) + * **Bug Fix**: Use r.URL.Host when r.Host is unset. +* `github.com/aws/smithy-go/aws-http-auth-schemes`: [v1.0.0](aws-http-auth-schemes/CHANGELOG.md#v100-2026-07-16) + * **Release**: Module `github.com/aws/smithy-go/aws-http-auth-schemes` adds generic smithy-go client support for AWS Sigv4 and Sigv4a. + +# Release (2026-06-26) + +## General Highlights +* **Dependency Update**: Updated to the latest SDK module versions + +## Module Highlights +* `github.com/aws/smithy-go`: v1.27.3 + * **Bug Fix**: Fix bug in JSON doc encoder and endpoint host label format validation + +# Release (2026-06-05) + +## General Highlights +* **Dependency Update**: Updated to the latest SDK module versions + +## Module Highlights +* `github.com/aws/smithy-go`: v1.27.2 + * **Bug Fix**: Fix incorrect serialization of unions in CBOR-based protocols. + # Release (2026-06-04) ## General Highlights diff --git a/vendor/github.com/aws/smithy-go/README.md b/vendor/github.com/aws/smithy-go/README.md index c5e14564b41..ac5a0a6139f 100644 --- a/vendor/github.com/aws/smithy-go/README.md +++ b/vendor/github.com/aws/smithy-go/README.md @@ -11,8 +11,8 @@ The smithy-go runtime requires a minimum version of Go 1.24. ## :warning: Client codegen is unstable The client code generator in this repository powers the aws-sdk-go-v2. -Arbitrary client generation, while technically possible, is in an early stage -of development: +Arbitrary client generation, while possible, is in an early stage of +development: * Generated clients are missing certain features that were originally implemented SDK-side (e.g. retries) @@ -32,8 +32,6 @@ This repository implements the following Smithy build plugins: | `go-server-codegen` | `software.amazon.smithy.go:smithy-go-codegen` | Implements Go server code generation for Smithy models. | | `go-shape-codegen` | `software.amazon.smithy.go:smithy-go-codegen` | Implements Go shape code generation (types only) for Smithy models. | -**NOTE: Build plugins are not currently published to mavenCentral. You must publish to mavenLocal to make the build plugins visible to the Smithy CLI. The artifact version is currently fixed at 0.1.0.** - ## `go-codegen` ### Configuration @@ -79,7 +77,7 @@ example created from `smithy init`: ], "maven": { "dependencies": [ - "software.amazon.smithy.go:smithy-go-codegen:0.1.0" + "software.amazon.smithy.go:smithy-go-codegen:[0.1.0,2.0)" ] }, "plugins": { diff --git a/vendor/github.com/aws/smithy-go/encoding/json/value.go b/vendor/github.com/aws/smithy-go/encoding/json/value.go index b41ff1e15c2..eac49c44c2e 100644 --- a/vendor/github.com/aws/smithy-go/encoding/json/value.go +++ b/vendor/github.com/aws/smithy-go/encoding/json/value.go @@ -106,6 +106,11 @@ func (jv Value) BigInteger(v *big.Int) { // BigDecimal encodes v as JSON value func (jv Value) BigDecimal(v *big.Float) { + if v.Sign() == 0 && v.Signbit() { + // Preserve negative zero sign which Int64() would lose. + jv.w.Write([]byte("-0")) + return + } if i, accuracy := v.Int64(); accuracy == big.Exact { jv.Long(i) return diff --git a/vendor/github.com/aws/smithy-go/endpoints/private/rulesfn/uri.go b/vendor/github.com/aws/smithy-go/endpoints/private/rulesfn/uri.go index 0c11541276b..68828dbfe94 100644 --- a/vendor/github.com/aws/smithy-go/endpoints/private/rulesfn/uri.go +++ b/vendor/github.com/aws/smithy-go/endpoints/private/rulesfn/uri.go @@ -27,6 +27,9 @@ func IsValidHostLabel(input string, allowSubDomains bool) bool { if !smithyhttp.ValidHostLabel(label) { return false } + if label[0] == '-' || label[len(label)-1] == '-' { + return false + } } return true diff --git a/vendor/github.com/aws/smithy-go/go_module_metadata.go b/vendor/github.com/aws/smithy-go/go_module_metadata.go index ba81f77281f..005dac8f6dd 100644 --- a/vendor/github.com/aws/smithy-go/go_module_metadata.go +++ b/vendor/github.com/aws/smithy-go/go_module_metadata.go @@ -3,4 +3,4 @@ package smithy // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.27.1" +const goModuleVersion = "1.27.8" diff --git a/vendor/github.com/aws/smithy-go/schema.go b/vendor/github.com/aws/smithy-go/schema.go index 6293d34b1e3..8e9c209a580 100644 --- a/vendor/github.com/aws/smithy-go/schema.go +++ b/vendor/github.com/aws/smithy-go/schema.go @@ -71,8 +71,9 @@ type Schema struct { directMask uint64 // bitmask: bit i set means indexed[i] was declared directly on this schema targetID ShapeID // for member schemas, the target's shape ID - listMember *Schema - mapKey, mapValue *Schema + // resolved on the fly and cached + listMember atomic.Pointer[Schema] + mapKey, mapValue atomic.Pointer[Schema] ext [numExtensionSlots]unsafe.Pointer // lazily-computed codec extensions, accessed atomically } @@ -126,9 +127,6 @@ func (s *Schema) AddMember(name string, target *Schema, ts ...Trait) *Schema { traits: cloneTraits(target.traits), directMask: 0, // inherited traits are not direct targetID: target.id, - listMember: target.listMember, - mapKey: target.mapKey, - mapValue: target.mapValue, } // member-declared traits override and are direct @@ -143,14 +141,6 @@ func (s *Schema) AddMember(name string, target *Schema, ts ...Trait) *Schema { atomic.StorePointer(&s.ext[i], nil) } - switch name { - case "member": - s.listMember = m - case "key": - s.mapKey = m - case "value": - s.mapValue = m - } return m } @@ -176,17 +166,31 @@ func cloneTraits(src map[ShapeID]Trait) map[ShapeID]Trait { // ListMember returns the "member" schema for list types. func (s *Schema) ListMember() *Schema { - return s.listMember + return s.lookup(&s.listMember, "member") } // MapKey returns the "key" schema for map types. func (s *Schema) MapKey() *Schema { - return s.mapKey + return s.lookup(&s.mapKey, "key") } // MapValue returns the "value" schema for map types. func (s *Schema) MapValue() *Schema { - return s.mapValue + return s.lookup(&s.mapValue, "value") +} + +func (s *Schema) lookup(cached *atomic.Pointer[Schema], name string) *Schema { + if v := cached.Load(); v != nil { + return v + } + + m, ok := s.members[name] + if !ok { + return nil + } + + cached.Store(m) + return m } // MemberName returns the member component of the schema's shape ID. diff --git a/vendor/github.com/aws/smithy-go/schema_ext.go b/vendor/github.com/aws/smithy-go/schema_ext.go index 7503b30b806..e98427ae345 100644 --- a/vendor/github.com/aws/smithy-go/schema_ext.go +++ b/vendor/github.com/aws/smithy-go/schema_ext.go @@ -9,13 +9,14 @@ import ( // (JSON, CBOR, etc.) uses a distinct slot to cache precomputed data. type ExtensionID int -const numExtensionSlots = 4 +const numExtensionSlots = 5 const ( - ExtJSON ExtensionID = iota // transport/http/protocol/internal/json - ExtCBOR // transport/http/protocol/internal/cbor - ExtXML // transport/http/protocol/internal/xml - ExtQuery // transport/http/protocol/internal/query + ExtJSON ExtensionID = iota // transport/http/protocol/internal/json + ExtCBOR // transport/http/protocol/internal/cbor + ExtXML // transport/http/protocol/internal/xml + ExtQuery // transport/http/protocol/internal/query + ExtHTTPBinding // transport/http/protocol/internal/httpbinding ) // SchemaExtension retrieves or lazily computes the extension for the given diff --git a/vendor/github.com/aws/smithy-go/transport/http/host.go b/vendor/github.com/aws/smithy-go/transport/http/host.go index db9801bea52..b504a455da2 100644 --- a/vendor/github.com/aws/smithy-go/transport/http/host.go +++ b/vendor/github.com/aws/smithy-go/transport/http/host.go @@ -69,7 +69,7 @@ func ValidPortNumber(port string) bool { return true } -// ValidHostLabel returns whether the label is a valid RFC 3986 host label. +// ValidHostLabel returns whether the label is a valid RFC 952/1123 host label. func ValidHostLabel(label string) bool { if l := len(label); l == 0 || l > 63 { return false diff --git a/vendor/github.com/aws/smithy-go/transport/http/middleware_close_response_body.go b/vendor/github.com/aws/smithy-go/transport/http/middleware_close_response_body.go index 914338f2e75..a7e70b1cb50 100644 --- a/vendor/github.com/aws/smithy-go/transport/http/middleware_close_response_body.go +++ b/vendor/github.com/aws/smithy-go/transport/http/middleware_close_response_body.go @@ -8,9 +8,35 @@ import ( "github.com/aws/smithy-go/middleware" ) +// CloseResponseBody closes the HTTP response body. It leaves the body open only +// for a successful response whose payload is a caller-owned stream (isStreaming +// with a nil opErr); on error, or for a non-streaming response, it closes the +// body — an error response body is diagnostic, not a caller-owned stream. +func CloseResponseBody(ctx context.Context, resp *Response, isStreaming bool, opErr error) { + if resp == nil || resp.Body == nil { + return + } + if isStreaming && opErr == nil { + return + } + + // Drain to EOF before closing; a body closed while unread prevents + // connection reuse. + if _, copyErr := io.Copy(io.Discard, resp.Body); copyErr != nil { + middleware.GetLogger(ctx).Logf(logging.Warn, "failed to discard remaining HTTP response body, this may affect connection reuse") + } + + if closeErr := resp.Body.Close(); closeErr != nil { + middleware.GetLogger(ctx).Logf(logging.Warn, "failed to close HTTP response body, this may affect connection reuse") + } +} + // AddErrorCloseResponseBodyMiddleware adds the middleware to automatically // close the response body of an operation request if the request response // failed. +// +// Deprecated: generated operation deserializers now close the response body +// via CloseResponseBody, so this middleware is no longer used. func AddErrorCloseResponseBodyMiddleware(stack *middleware.Stack) error { return stack.Deserialize.Insert(&errorCloseResponseBodyMiddleware{}, "OperationDeserializer", middleware.Before) } @@ -42,6 +68,9 @@ func (m *errorCloseResponseBodyMiddleware) HandleDeserialize( // AddCloseResponseBodyMiddleware adds the middleware to automatically close // the response body of an operation request, after the response had been // deserialized. +// +// Deprecated: generated operation deserializers now close the response body +// via CloseResponseBody, so this middleware is no longer used. func AddCloseResponseBodyMiddleware(stack *middleware.Stack) error { return stack.Deserialize.Insert(&closeResponseBody{}, "OperationDeserializer", middleware.Before) } diff --git a/vendor/github.com/go-openapi/strfmt/.gitignore b/vendor/github.com/go-openapi/strfmt/.gitignore index bbdffea78a0..20c4e0fa048 100644 --- a/vendor/github.com/go-openapi/strfmt/.gitignore +++ b/vendor/github.com/go-openapi/strfmt/.gitignore @@ -4,3 +4,4 @@ .env .mcp.json go.work.sum +.worktrees diff --git a/vendor/github.com/go-openapi/strfmt/.golangci.yml b/vendor/github.com/go-openapi/strfmt/.golangci.yml index 8a3b3bff7c4..31480c7138a 100644 --- a/vendor/github.com/go-openapi/strfmt/.golangci.yml +++ b/vendor/github.com/go-openapi/strfmt/.golangci.yml @@ -6,6 +6,8 @@ linters: - depguard - funlen - gomoddirectives + - gomodguard + - gomodguard_v2 - godox - exhaustruct - nlreturn diff --git a/vendor/github.com/go-openapi/strfmt/CONTRIBUTORS.md b/vendor/github.com/go-openapi/strfmt/CONTRIBUTORS.md index 4aa4fcb54fc..fa17ff3111c 100644 --- a/vendor/github.com/go-openapi/strfmt/CONTRIBUTORS.md +++ b/vendor/github.com/go-openapi/strfmt/CONTRIBUTORS.md @@ -4,12 +4,12 @@ | Total Contributors | Total Contributions | | --- | --- | -| 40 | 239 | +| 41 | 243 | | Username | All Time Contribution Count | All Commits | | --- | --- | --- | | @casualjim | 88 | | -| @fredbi | 71 | | +| @fredbi | 74 | | | @youyuanwu | 13 | | | @jlambatl | 9 | | | @GlenDC | 5 | | @@ -26,6 +26,7 @@ | @bg451 | 2 | | | @aleksandr-vin | 2 | | | @ujjwalsh | 1 | | +| @patchwright | 1 | | | @kenjones-cisco | 1 | | | @jwalter1-quest | 1 | | | @ccoVeille | 1 | | diff --git a/vendor/github.com/go-openapi/strfmt/README.md b/vendor/github.com/go-openapi/strfmt/README.md index 4afef43733d..15ee0e5826d 100644 --- a/vendor/github.com/go-openapi/strfmt/README.md +++ b/vendor/github.com/go-openapi/strfmt/README.md @@ -67,7 +67,7 @@ It also provides convenient extensions to go-openapi users. - [x] go-openapi custom format extensions - bsonobjectid (BSON objectID) - creditcard - - duration (e.g. "3 weeks", "1ms") + - duration (e.g. "3 weeks", "1ms") (aka "duration-human") - hexcolor (e.g. "#FFFFFF") - isbn, isbn10, isbn13 - mac (e.g "01:02:03:04:05:06") @@ -76,11 +76,26 @@ It also provides convenient extensions to go-openapi users. - uuid, uuid3, uuid4, uuid5, uuid7 - cidr (e.g. "192.0.2.1/24", "2001:db8:a0b:12f0::1/32") - ulid (e.g. "00000PP9HGSBSSDZ1JTEXBJ0PW", [spec](https://github.com/ulid/spec)) +- [x] JSON-schema draft 2020 formats + - duration-iso8601 B(e.g. "P2W") > NOTE: as the name stands for, this package is intended to support string formatting only. > It does not provide validation for numerical values with swagger format extension for JSON types "number" or > "integer" (e.g. float, double, int32...). +## Durations + +We have 2 very different definitions of the "duration" format: the "human-readable" duration that used to be just "duration", +and the new "duration-iso8601". There is no "dual" parser that accepts both formats: types are specialized. + +To clarify the situation, a new alias for the duration format is introduced "duration-human" (e.g. "1 ms"), as opposed to +"duration-iso8601". + +The `Default` format registry wires "duration-human" as the default mapping for "duration" +(preexisting behavior, no breaking change - aligned with Swagger 2.0 which did not define "duration"). + +A new `JSONSchema2020` registry wires "duration-iso8601" as the default mapping for "duration". + ### Type conversion All types defined here are stringers and may be converted to strings with `.String()`. @@ -104,6 +119,7 @@ List of defined types: - Date - DateTime - Duration +- DurationISO8601 and `ISODuration[P ISODurationPolicy]` (for optional behavior) - Email - HexColor - Hostname diff --git a/vendor/github.com/go-openapi/strfmt/bson.go b/vendor/github.com/go-openapi/strfmt/bson.go index 16a83f64086..b0c05d83bcc 100644 --- a/vendor/github.com/go-openapi/strfmt/bson.go +++ b/vendor/github.com/go-openapi/strfmt/bson.go @@ -10,11 +10,6 @@ import ( "fmt" ) -func init() { //nolint:gochecknoinits // registers bsonobjectid format in the default registry - var id ObjectId - Default.Add("bsonobjectid", &id, IsBSONObjectID) -} - // IsBSONObjectID returns true when the string is a valid BSON [ObjectId]. func IsBSONObjectID(str string) bool { _, err := objectIDFromHex(str) diff --git a/vendor/github.com/go-openapi/strfmt/country.go b/vendor/github.com/go-openapi/strfmt/country.go new file mode 100644 index 00000000000..39aeb3d7861 --- /dev/null +++ b/vendor/github.com/go-openapi/strfmt/country.go @@ -0,0 +1,173 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + +package strfmt + +import ( + "database/sql/driver" + "encoding/json" + "fmt" + + "github.com/go-openapi/strfmt/internal/countries" +) + +// Country represents an ISO 3166 country alpha-3 or alpha-2 code as a string format. +// +// swagger:strfmt country. +type Country struct { + countries.Country + + l int +} + +const ( + alpha2Len = 2 + alpha3Len = 3 +) + +// IsCountry checks if a string is a valid ISO 3166 country format. +func IsCountry(str string) bool { + _, err := ParseCountry(str) + + return err == nil +} + +// ParseCountry parses a string that represents a valid [Country]. +func ParseCountry(str string) (Country, error) { + l := len(str) + switch l { + case alpha3Len: + c, ok := countries.CountriesISO3[str] + if !ok { + return Country{}, fmt.Errorf("unrecognized strfmt.Country %q: %w", str, ErrFormat) + } + + return Country{Country: c, l: alpha3Len}, nil + case alpha2Len: + c, ok := countries.CountriesISO2[str] + if !ok { + return Country{}, fmt.Errorf("unrecognized strfmt.Country %q: %w", str, ErrFormat) + } + + return Country{Country: c, l: alpha2Len}, nil + default: + return Country{}, fmt.Errorf("invalid length for strfmt.Country in: %q: %w", str, ErrFormat) + } +} + +// MarshalText returns this instance into text. +func (u Country) MarshalText() ([]byte, error) { + return []byte(u.String()), nil +} + +// UnmarshalText hydrates this instance from text. +func (u *Country) UnmarshalText(data []byte) error { // validation is performed later on + c, err := ParseCountry(string(data)) + if err != nil { + return err + } + + *u = c + + return nil +} + +// Scan read a value from a database driver. +func (u *Country) Scan(raw any) error { + switch v := raw.(type) { + case []byte: + c, err := ParseCountry(string(v)) + if err != nil { + return err + } + *u = c + case string: + c, err := ParseCountry(v) + if err != nil { + return err + } + *u = c + default: + return fmt.Errorf("cannot sql.Scan() strfmt.Country from: %#v: %w", v, ErrFormat) + } + + return nil +} + +// Value converts a value to a database driver value. +func (u Country) Value() (driver.Value, error) { + return driver.Value(u.String()), nil +} + +func (u Country) String() string { + switch u.l { + case alpha3Len: + return u.ISOAlpha3 + case alpha2Len: + return u.ISOAlpha2 + default: + return "" + } +} + +// MarshalJSON returns the [Country] as JSON. +func (u Country) MarshalJSON() ([]byte, error) { + return json.Marshal(u.String()) +} + +// UnmarshalJSON sets the [Country] from JSON. +func (u *Country) UnmarshalJSON(data []byte) error { + if string(data) == jsonNull { + return nil + } + var ustr string + if err := json.Unmarshal(data, &ustr); err != nil { + return err + } + + c, err := ParseCountry(ustr) + if err != nil { + return err + } + + *u = c + + return nil +} + +// DeepCopyInto copies the receiver and writes its value into out. +func (u *Country) DeepCopyInto(out *Country) { + *out = *u +} + +// DeepCopy copies the receiver into a new [Country]. +func (u *Country) DeepCopy() *Country { + if u == nil { + return nil + } + + out := new(Country) + u.DeepCopyInto(out) + + return out +} + +// GobEncode implements the gob.GobEncoder interface. +func (u Country) GobEncode() ([]byte, error) { + return u.MarshalText() +} + +// GobDecode implements the gob.GobDecoder interface. +func (u *Country) GobDecode(data []byte) error { + return u.UnmarshalText(data) +} + +// MarshalBinary implements the encoding.[encoding.BinaryMarshaler] interface. +func (u Country) MarshalBinary() ([]byte, error) { + return u.MarshalText() +} + +// UnmarshalBinary implements the encoding.[encoding.BinaryUnmarshaler] interface. +func (u *Country) UnmarshalBinary(data []byte) error { + return u.UnmarshalText(data) +} diff --git a/vendor/github.com/go-openapi/strfmt/currency.go b/vendor/github.com/go-openapi/strfmt/currency.go new file mode 100644 index 00000000000..7af115663f2 --- /dev/null +++ b/vendor/github.com/go-openapi/strfmt/currency.go @@ -0,0 +1,146 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + +package strfmt + +import ( + "database/sql/driver" + "encoding/json" + "fmt" + + "golang.org/x/text/currency" +) + +// Currency represents an ISO 4217 currency alpha-3 code as a string format. +// +// # Implementation +// +// golang.org/x/text/currency +// +// swagger:strfmt currency. +type Currency struct { + currency.Unit +} + +// IsCurrency checks if a string is a valid currency format. +func IsCurrency(str string) bool { + _, err := ParseCurrency(str) + + return err == nil +} + +// ParseCurrency parses a string that represents a valid [Currency]. +func ParseCurrency(str string) (Currency, error) { + cur, err := currency.ParseISO(str) + + return Currency{Unit: cur}, err +} + +// MarshalText returns this instance into text. +func (u Currency) MarshalText() ([]byte, error) { + return []byte(u.Unit.String()), nil +} + +// UnmarshalText hydrates this instance from text. +func (u *Currency) UnmarshalText(data []byte) error { // validation is performed later on + cur, err := ParseCurrency(string(data)) + if err != nil { + return err + } + *u = cur + + return nil +} + +// Scan read a value from a database driver. +func (u *Currency) Scan(raw any) error { + switch v := raw.(type) { + case []byte: + cur, err := ParseCurrency(string(v)) + if err != nil { + return err + } + *u = cur + case string: + cur, err := ParseCurrency(v) + if err != nil { + return err + } + *u = cur + default: + return fmt.Errorf("cannot sql.Scan() strfmt.Currency from: %#v: %w", v, ErrFormat) + } + + return nil +} + +// Value converts a value to a database driver value. +func (u Currency) Value() (driver.Value, error) { + return driver.Value(u.String()), nil +} + +func (u Currency) String() string { + return u.Unit.String() +} + +// MarshalJSON returns the [Currency] as JSON. +func (u Currency) MarshalJSON() ([]byte, error) { + return json.Marshal(u.String()) +} + +// UnmarshalJSON sets the [Currency] from JSON. +func (u *Currency) UnmarshalJSON(data []byte) error { + if string(data) == jsonNull { + return nil + } + var ustr string + if err := json.Unmarshal(data, &ustr); err != nil { + return err + } + + cur, err := ParseCurrency(ustr) + if err != nil { + return err + } + + *u = cur + + return nil +} + +// DeepCopyInto copies the receiver and writes its value into out. +func (u *Currency) DeepCopyInto(out *Currency) { + *out = *u +} + +// DeepCopy copies the receiver into a new [Currency]. +func (u *Currency) DeepCopy() *Currency { + if u == nil { + return nil + } + + out := new(Currency) + u.DeepCopyInto(out) + + return out +} + +// GobEncode implements the gob.GobEncoder interface. +func (u Currency) GobEncode() ([]byte, error) { + return u.MarshalText() +} + +// GobDecode implements the gob.GobDecoder interface. +func (u *Currency) GobDecode(data []byte) error { + return u.UnmarshalText(data) +} + +// MarshalBinary implements the encoding.[encoding.BinaryMarshaler] interface. +func (u Currency) MarshalBinary() ([]byte, error) { + return u.MarshalText() +} + +// UnmarshalBinary implements the encoding.[encoding.BinaryUnmarshaler] interface. +func (u *Currency) UnmarshalBinary(data []byte) error { + return u.UnmarshalText(data) +} diff --git a/vendor/github.com/go-openapi/strfmt/date.go b/vendor/github.com/go-openapi/strfmt/date.go index 59ee1f11216..6d0e8a01ac8 100644 --- a/vendor/github.com/go-openapi/strfmt/date.go +++ b/vendor/github.com/go-openapi/strfmt/date.go @@ -10,11 +10,6 @@ import ( "time" ) -func init() { //nolint:gochecknoinits // registers date format in the default registry - d := Date{} - Default.Add("date", &d, IsDate) -} - // IsDate returns true when the string is a valid date. func IsDate(str string) bool { _, err := time.Parse(RFC3339FullDate, str) diff --git a/vendor/github.com/go-openapi/strfmt/default.go b/vendor/github.com/go-openapi/strfmt/default.go index 725cc0e1a60..bcc57e6fad3 100644 --- a/vendor/github.com/go-openapi/strfmt/default.go +++ b/vendor/github.com/go-openapi/strfmt/default.go @@ -32,22 +32,22 @@ const ( ) const ( - // UUIDPattern Regex for [UUID] that allows uppercase + // UUIDPattern Regex for [UUID] that allows uppercase. // // Deprecated: [strfmt] no longer uses regular expressions to validate UUIDs. UUIDPattern = `(?i)(^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$)|(^[0-9a-f]{32}$)` - // UUID3Pattern Regex for [UUID3] that allows uppercase + // UUID3Pattern Regex for [UUID3] that allows uppercase. // // Deprecated: [strfmt] no longer uses regular expressions to validate UUIDs. UUID3Pattern = `(?i)(^[0-9a-f]{8}-[0-9a-f]{4}-3[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$)|(^[0-9a-f]{12}3[0-9a-f]{3}?[0-9a-f]{16}$)` - // UUID4Pattern Regex for [UUID4] that allows uppercase + // UUID4Pattern Regex for [UUID4] that allows uppercase. // // Deprecated: [strfmt] no longer uses regular expressions to validate UUIDs. UUID4Pattern = `(?i)(^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$)|(^[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15}$)` - // UUID5Pattern Regex for [UUID]5 that allows uppercase + // UUID5Pattern Regex for [UUID]5 that allows uppercase. // // Deprecated: [strfmt] no longer uses regular expressions to validate UUIDs. UUID5Pattern = `(?i)(^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$)|(^[0-9a-f]{12}5[0-9a-f]{3}[89ab][0-9a-f]{15}$)` @@ -88,8 +88,8 @@ var ( // IsHostname returns true when the string is a valid hostname. // -// It follows the rules detailed at https://url.spec.whatwg.org/#concept-host-parser -// and implemented by most modern web browsers. +// It follows the rules detailed at https://url.spec.whatwg.org/#concept-host-parser and implemented by most modern web +// browsers. // // It supports IDNA rules regarding internationalized names with unicode. // @@ -142,13 +142,13 @@ func IsHostname(str string) bool { return true } -// domainEndsAsNumber determines if a domain name ends with a decimal, octal or hex digit, -// accounting for a possible trailing dot (the last part being empty in that case). +// domainEndsAsNumber determines if a domain name ends with a decimal, octal or hex digit, accounting for a possible +// trailing dot (the last part being empty in that case). // // It returns the last non-trailing dot part and if that part consists only of (dec/hex/oct) digits. func domainEndsAsNumber(parts []string) (lastPart string, lastIndex int, ok bool) { - // NOTE: using ParseUint(x, 0, 32) is not an option, as the IPv4 format supported why WHATWG - // doesn't support notations such as "0b1001" (binary digits) or "0o666" (alternate notation for octal digits). + // NOTE: using ParseUint(x, 0, 32) is not an option, as the IPv4 format supported why WHATWG doesn't support notations + // such as "0b1001" (binary digits) or "0o666" (alternate notation for octal digits). lastIndex = len(parts) - 1 lastPart = parts[lastIndex] if len(lastPart) == 0 { @@ -233,8 +233,9 @@ func isValidIPv6(str string) bool { // "0o07.2.3.4" func isValidIPv4(parts []string) bool { // NOTE: using ParseUint(x, 0, 32) is not an option, even though it would simplify this code a lot. - // The IPv4 format supported why WHATWG doesn't support notations such as "0b1001" (binary digits) - // or "0o666" (alternate notation for octal digits). + // + // The IPv4 format supported why WHATWG doesn't support notations such as "0b1001" (binary digits) or "0o666" + // (alternate notation for octal digits). const ( maxPartsInIPv4 = 4 maxDigitsInPart = 11 // max size of a 4-bytes hex or octal digit @@ -376,101 +377,22 @@ func IsEmail(str string) bool { return e == nil && addr.Address != "" } -func init() { //nolint:gochecknoinits // registers all default string formats in the registry - // register formats in the default registry: - // - byte - // - creditcard - // - email - // - hexcolor - // - hostname - // - ipv4 - // - ipv6 - // - cidr - // - isbn - // - isbn10 - // - isbn13 - // - mac - // - password - // - rgbcolor - // - ssn - // - uri - // - uuid - // - uuid3 - // - uuid4 - // - uuid5 - // - uuid7 - u := URI("") - Default.Add("uri", &u, isRequestURI) - - eml := Email("") - Default.Add("email", &eml, IsEmail) - - hn := Hostname("") - Default.Add("hostname", &hn, IsHostname) - - ip4 := IPv4("") - Default.Add("ipv4", &ip4, isIPv4) - - ip6 := IPv6("") - Default.Add("ipv6", &ip6, isIPv6) - - cidr := CIDR("") - Default.Add("cidr", &cidr, isCIDR) - - mac := MAC("") - Default.Add("mac", &mac, isMAC) - - uid := UUID("") - Default.Add("uuid", &uid, IsUUID) - - uid3 := UUID3("") - Default.Add("uuid3", &uid3, IsUUID3) - - uid4 := UUID4("") - Default.Add("uuid4", &uid4, IsUUID4) - - uid5 := UUID5("") - Default.Add("uuid5", &uid5, IsUUID5) - - uid7 := UUID7("") - Default.Add("uuid7", &uid7, IsUUID7) - - isbn := ISBN("") - Default.Add("isbn", &isbn, func(str string) bool { return isISBN10(str) || isISBN13(str) }) - - isbn10 := ISBN10("") - Default.Add("isbn10", &isbn10, isISBN10) - - isbn13 := ISBN13("") - Default.Add("isbn13", &isbn13, isISBN13) - - cc := CreditCard("") - Default.Add("creditcard", &cc, isCreditCard) - - ssn := SSN("") - Default.Add("ssn", &ssn, isSSN) - - hc := HexColor("") - Default.Add("hexcolor", &hc, isHexcolor) - - rc := RGBColor("") - Default.Add("rgbcolor", &rc, isRGBcolor) - - b64 := Base64([]byte(nil)) - Default.Add("byte", &b64, isBase64) - - pw := Password("") - Default.Add("password", &pw, func(_ string) bool { return true }) -} +// base64Encoding is the canonical alphabet for the [Base64] format. +// +// OpenAPI `format: byte` means standard base64 (RFC 4648 §4, the `+/` alphabet), not base64url. +// This is the single seam every [Base64] path encodes and decodes through, so a future URL-safe variant only swaps the +// encoding here. +// See go-openapi/strfmt#87. +var base64Encoding = base64.StdEncoding //nolint:gochecknoglobals // canonical alphabet seam for the Base64 format -// Base64 represents a base64 encoded string, using URLEncoding alphabet. +// Base64 represents a base64 encoded string, using the standard RFC 4648 alphabet. // // swagger:strfmt byte. type Base64 []byte // MarshalText turns this instance into text. func (b Base64) MarshalText() ([]byte, error) { - enc := base64.URLEncoding + enc := base64Encoding src := []byte(b) buf := make([]byte, enc.EncodedLen(len(src))) enc.Encode(buf, src) @@ -479,7 +401,7 @@ func (b Base64) MarshalText() ([]byte, error) { // UnmarshalText hydrates this instance from text. func (b *Base64) UnmarshalText(data []byte) error { // validation is performed later on - enc := base64.URLEncoding + enc := base64Encoding dbuf := make([]byte, enc.DecodedLen(len(data))) n, err := enc.Decode(dbuf, data) @@ -495,14 +417,14 @@ func (b *Base64) UnmarshalText(data []byte) error { // validation is performed l func (b *Base64) Scan(raw any) error { switch v := raw.(type) { case []byte: - dbuf := make([]byte, base64.StdEncoding.DecodedLen(len(v))) - n, err := base64.StdEncoding.Decode(dbuf, v) + dbuf := make([]byte, base64Encoding.DecodedLen(len(v))) + n, err := base64Encoding.Decode(dbuf, v) if err != nil { return err } *b = dbuf[:n] case string: - vv, err := base64.StdEncoding.DecodeString(v) + vv, err := base64Encoding.DecodeString(v) if err != nil { return err } @@ -520,7 +442,7 @@ func (b Base64) Value() (driver.Value, error) { } func (b Base64) String() string { - return base64.StdEncoding.EncodeToString([]byte(b)) + return base64Encoding.EncodeToString([]byte(b)) } // MarshalJSON returns the Base64 as JSON. @@ -534,7 +456,7 @@ func (b *Base64) UnmarshalJSON(data []byte) error { if err := json.Unmarshal(data, &b64str); err != nil { return err } - vb, err := base64.StdEncoding.DecodeString(b64str) + vb, err := base64Encoding.DecodeString(b64str) if err != nil { return err } @@ -1040,7 +962,7 @@ func (u *MAC) DeepCopy() *MAC { return out } -// UUID represents a [uuid] string format +// UUID represents a [uuid] string format. // // swagger:strfmt uuid. type UUID string @@ -1905,6 +1827,7 @@ func (r *RGBColor) DeepCopy() *RGBColor { } // Password represents a password. +// // This has no validations and is mainly used as a marker for UI components. // // swagger:strfmt password. @@ -1978,11 +1901,10 @@ func (r *Password) DeepCopy() *Password { } func isRequestURI(rawurl string) bool { - // url.ParseRequestURI assumes the input contains no "#fragment" - // (RFC 3986 §3.5). A URI with a fragment and an empty path, such as - // "https://host#@frag", is therefore misread as userinfo and rejected - // as "invalid userinfo". Strip the fragment first so the absolute - // request URI validates, matching url.Parse's RFC 3986 handling. + // url.ParseRequestURI assumes the input contains no "#fragment" (RFC 3986 §3.5). + // A URI with a fragment and an empty path, such as "https://host#@frag", is therefore misread as userinfo and rejected + // as "invalid userinfo". + // Strip the fragment first so the absolute request URI validates, matching url.Parse's RFC 3986 handling. if i := strings.IndexByte(rawurl, '#'); i >= 0 { rawurl = rawurl[:i] } @@ -2009,19 +1931,20 @@ func isCIDR(str string) bool { } // isMAC checks if a string is valid MAC address. +// // Possible MAC formats: -// 01:23:45:67:89:ab -// 01:23:45:67:89:ab:cd:ef -// 01-23-45-67-89-ab -// 01-23-45-67-89-ab-cd-ef -// 0123.4567.89ab -// 0123.4567.89ab.cdef. +// - 01:23:45:67:89:ab +// - 01:23:45:67:89:ab:cd:ef +// - 01-23-45-67-89-ab +// - 01-23-45-67-89-ab-cd-ef +// - 0123.4567.89ab 0123.4567.89ab.cdef func isMAC(str string) bool { _, err := net.ParseMAC(str) return err == nil } // isISBN checks if the string is an ISBN (version 10 or 13). +// // If version value is not equal to 10 or 13, it will be checks both variants. func isISBN(str string, version int) bool { sanitized := whiteSpacesAndMinus.ReplaceAllString(str, "") @@ -2120,7 +2043,7 @@ func isRGBcolor(str string) bool { // isBase64 checks if a string is base64 encoded. func isBase64(str string) bool { - _, err := base64.StdEncoding.DecodeString(str) + _, err := base64Encoding.DecodeString(str) return err == nil } diff --git a/vendor/github.com/go-openapi/strfmt/duration.go b/vendor/github.com/go-openapi/strfmt/duration.go index f2ab7ff8348..fc4de0d14c2 100644 --- a/vendor/github.com/go-openapi/strfmt/duration.go +++ b/vendor/github.com/go-openapi/strfmt/duration.go @@ -12,11 +12,6 @@ import ( "unicode" ) -func init() { //nolint:gochecknoinits // registers duration format in the default registry - d := Duration(0) - Default.Add("duration", &d, IsDuration) -} - const ( hoursInDay = 24 daysInWeek = 7 @@ -174,6 +169,9 @@ func ParseDuration(s string) (time.Duration, error) { scale float64 = 1 // value = v + f/scale ) s = strings.TrimLeftFunc(s, unicode.IsSpace) + if s == "" { + break + } // The next character must be 0-9.] if s[0] != '.' && ('0' > s[0] || s[0] > '9') { diff --git a/vendor/github.com/go-openapi/strfmt/duration_iso8601.go b/vendor/github.com/go-openapi/strfmt/duration_iso8601.go new file mode 100644 index 00000000000..9fded035ae2 --- /dev/null +++ b/vendor/github.com/go-openapi/strfmt/duration_iso8601.go @@ -0,0 +1,583 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + +package strfmt + +import ( + "database/sql/driver" + "encoding/json" + "fmt" + "math" + "strconv" + "strings" + "time" +) + +// ISO 8601 duration unit lengths, expressed in nanoseconds. +// +// Calendar units are collapsed to fixed lengths (a year is 365 days, a month is 30 days): a [time.Duration] cannot +// carry calendar context, so this conversion is inherently lossy and not calendar-correct. +// It matches the historical behaviour of ISO duration libraries in this space. +const ( + isoSecond = uint64(time.Second) + isoMinute = uint64(time.Minute) + isoHour = uint64(time.Hour) + isoDay = 24 * isoHour + isoWeek = 7 * isoDay + isoMonth = 30 * isoDay + isoYear = 365 * isoDay + + // maxDurationMagnitude is 1<<63: the magnitude of [math.MinInt64], and one more than [math.MaxInt64]. + // + // A parsed magnitude may reach exactly this value only for a negative duration (yielding [math.MinInt64]). + maxDurationMagnitude = uint64(1) << 63 +) + +// Base-10 parsing / formatting constants (decimalBase lives in default.go). +const ( + // decimalAccMax bounds a uint64 accumulator so that acc*decimalBase + 9 cannot overflow. + decimalAccMax = (math.MaxUint64 - (decimalBase - 1)) / decimalBase + // nanoDigits is the number of fractional digits in one whole second (nanosecond precision). + nanoDigits = 9 +) + +// ISODuration is an ISO 8601 / RFC 3339 duration (e.g. "P1Y2M3DT4H5M6S", "P2W"). +// +// The type parameter P selects the parsing policy at compile time (see [ISODurationPolicy]). +// Every instantiation is a distinct type that round-trips through JSON, text, SQL and BSON. +// Use the [DurationISO8601] alias for the strict, spec-compliant default. +// +// Like [time.Duration], it stores a nanosecond count; the largest representable duration is approximately 290 years. +// Calendar units are collapsed to fixed lengths (year = 365 days, month = 30 days), which is lossy by nature. +// +// This generic type carries no swagger:strfmt annotation: go-swagger binds a concrete format name to the +// [DurationISO8601] alias, not to a generic declaration. +type ISODuration[P ISODurationPolicy] time.Duration + +// DurationISO8601 is the strict, spec-compliant ISO 8601 duration: the JSON Schema draft 2020 "duration" format +// (RFC 3339 Appendix A). +// +// It binds to the explicit, unambiguous "duration-iso8601" handle. Plain "duration" is a context-dependent +// default resolved by the registry ([Default] → human, [JSONSchema2020Registry] → ISO), not by this static type. +// +// swagger:strfmt duration-iso8601. +type DurationISO8601 = ISODuration[DurationStrict] + +// ParseISO8601Duration parses an ISO 8601 / RFC 3339 duration string. +// +// With no options it enforces the strict RFC 3339 Appendix A grammar. +// Options relax individual rules for programmatic callers. +func ParseISO8601Duration(s string, opts ...ISODurationOption) (time.Duration, error) { + cfg := DurationStrict{}.isoDurationConfig() + for _, o := range opts { + o(&cfg) + } + return parseISO8601Duration(s, cfg) +} + +// --- Format / encoding methods --- + +// String renders the duration in canonical ISO 8601 form. +// +// Unlike [ISODuration.MarshalText], String is a best-effort display form: it always renders the true value (lossless), +// even under a strict policy that could not serialize it (e.g. a sign or sub-second precision). +func (d ISODuration[P]) String() string { return isoFormat(time.Duration(d)) } + +// MarshalText implements [encoding.TextMarshaler], applying the policy P: a strict policy errors on a value it cannot +// represent (see [isoEmit]). +func (d ISODuration[P]) MarshalText() ([]byte, error) { + var p P + s, err := isoEmit(time.Duration(d), p.isoDurationConfig()) + if err != nil { + return nil, err + } + return []byte(s), nil +} + +// UnmarshalText implements [encoding.TextUnmarshaler], applying the policy P. +func (d *ISODuration[P]) UnmarshalText(text []byte) error { + var p P + dd, err := parseISO8601Duration(string(text), p.isoDurationConfig()) + if err != nil { + return err + } + *d = ISODuration[P](dd) + return nil +} + +// MarshalJSON returns the duration as a JSON string, applying the policy P. +func (d ISODuration[P]) MarshalJSON() ([]byte, error) { + var p P + s, err := isoEmit(time.Duration(d), p.isoDurationConfig()) + if err != nil { + return nil, err + } + return json.Marshal(s) +} + +// UnmarshalJSON sets the duration from a JSON string, applying the policy P. +func (d *ISODuration[P]) UnmarshalJSON(data []byte) error { + if string(data) == jsonNull { + return nil + } + var str string + if err := json.Unmarshal(data, &str); err != nil { + return err + } + var p P + dd, err := parseISO8601Duration(str, p.isoDurationConfig()) + if err != nil { + return err + } + *d = ISODuration[P](dd) + return nil +} + +// Scan reads a duration (nanoseconds) from a database driver value. +func (d *ISODuration[P]) Scan(raw any) error { + switch v := raw.(type) { + case int64: + *d = ISODuration[P](v) + case float64: + *d = ISODuration[P](int64(v)) + case nil: + *d = ISODuration[P](0) + default: + return fmt.Errorf("cannot sql.Scan() strfmt.ISODuration from: %#v: %w", v, ErrFormat) + } + return nil +} + +// Value writes the duration as a nanosecond count. +func (d ISODuration[P]) Value() (driver.Value, error) { + return driver.Value(int64(d)), nil +} + +// Equal reports whether two durations are equal. +func (d ISODuration[P]) Equal(other ISODuration[P]) bool { return d == other } + +// DeepCopyInto copies the receiver into out. +func (d *ISODuration[P]) DeepCopyInto(out *ISODuration[P]) { *out = *d } + +// DeepCopy copies the receiver into a new value. +func (d *ISODuration[P]) DeepCopy() *ISODuration[P] { + if d == nil { + return nil + } + out := new(ISODuration[P]) + d.DeepCopyInto(out) + return out +} + +// IsDurationISO8601 returns true if the string is a valid strict ISO 8601 duration. +func IsDurationISO8601(s string) bool { + _, err := parseISO8601Duration(s, DurationStrict{}.isoDurationConfig()) + return err == nil +} + +func isoDurationError(input, msg string) error { + return fmt.Errorf("invalid ISO 8601 duration %q: %s: %w", input, msg, ErrFormat) +} + +// section positions used to enforce component ordering (strictly increasing). +// +//nolint:gochecknoglobals,mnd // immutable ordinal lookup tables; the integers are sequence positions, not magic constants +var ( + isoDatePos = map[byte]int{'Y': 1, 'M': 2, 'W': 3, 'D': 4} + isoTimePos = map[byte]int{'H': 1, 'M': 2, 'S': 3} +) + +// isoDateSlot maps the year/month/day designators to contiguous slots for the strict anchoring (gap) check. +// +// 'W' is deliberately excluded: in strict mode it is exclusive, so it never coexists with Y/M/D. +func isoDateSlot(des byte) (int, bool) { + switch des { + case 'Y': + return 0, true + case 'M': + return 1, true + case 'D': + return 2, true //nolint:mnd // contiguous slot index (Y=0, M=1, D=2), not a magic constant + default: + return 0, false + } +} + +//nolint:gocognit,gocyclo,cyclop // a single-pass grammar scanner; the branches mirror the ABNF. +func parseISO8601Duration(input string, cfg isoDurationConfig) (time.Duration, error) { + s := input + if cfg.allowSpace { + s = strings.TrimSpace(s) + } + + neg := false + if cfg.allowSign && s != "" && (s[0] == '+' || s[0] == '-') { + neg = s[0] == '-' + s = s[1:] + } + + if s == "" || s[0] != 'P' { + return 0, isoDurationError(input, `must start with "P"`) + } + s = s[1:] + if s == "" { + return 0, isoDurationError(input, "no components after P") + } + + var ( + total uint64 + inTime bool + seenAny bool + weekSeen bool + fractionUsed bool + lastDatePos int + lastTimePos int + datePresent [3]bool // Y, M, D — for the anchoring (gap) check + timePresent [3]bool // H, M, S + ) + + for s != "" { + c := s[0] + + if c == 'T' { + if inTime { + return 0, isoDurationError(input, `duplicate "T" separator`) + } + if weekSeen && !cfg.weekCombinable { + return 0, isoDurationError(input, `"W" cannot be combined with other components`) + } + inTime = true + s = s[1:] + if s == "" { + return 0, isoDurationError(input, `no components after "T"`) + } + continue + } + + // A fraction, if any, must be on the least significant component: nothing may follow it. + if fractionUsed { + return 0, isoDurationError(input, "a fraction is only allowed on the least significant component") + } + + // Scan the integer part (ASCII digits only). + i := 0 + for i < len(s) && s[i] >= '0' && s[i] <= '9' { + i++ + } + if i == 0 { + return 0, isoDurationError(input, fmt.Sprintf("expected a digit, got %q", s[0])) + } + intPart := s[:i] + + // Optional decimal fraction. + var fracPart string + hasFrac := false + if i < len(s) && (s[i] == '.' || s[i] == ',') { + if !cfg.allowFraction { + return 0, isoDurationError(input, "decimal fraction is not allowed") + } + hasFrac = true + j := i + 1 + for j < len(s) && s[j] >= '0' && s[j] <= '9' { + j++ + } + fracPart = s[i+1 : j] + i = j + } + + if i >= len(s) { + return 0, isoDurationError(input, "value without a unit designator") + } + des := s[i] + s = s[i+1:] + + unit, err := isoResolveUnit(input, des, inTime, cfg, + &lastDatePos, &lastTimePos, &weekSeen, seenAny, &datePresent, &timePresent) + if err != nil { + return 0, err + } + seenAny = true + if hasFrac { + fractionUsed = true + } + + val, err := isoScaleValue(input, intPart, fracPart, unit) + if err != nil { + return 0, err + } + + // Accumulate with the stdlib overflow discipline: the magnitude may reach 1<<63 only for a negative duration. + if total > maxDurationMagnitude-val { + return 0, isoDurationError(input, "value out of range") + } + total += val + } + + if inTime && !timePresent[0] && !timePresent[1] && !timePresent[2] { + return 0, isoDurationError(input, `no components after "T"`) + } + if !seenAny { + return 0, isoDurationError(input, "no components") + } + + // Strict anchoring: the present Y/M/D and H/M/S components must each form a contiguous run (e.g. P1Y2D and PT1H2S are + // rejected). + if !cfg.relaxAnchoring { + if err := isoCheckContiguous(input, datePresent, "date"); err != nil { + return 0, err + } + if err := isoCheckContiguous(input, timePresent, "time"); err != nil { + return 0, err + } + } + + if total > maxDurationMagnitude-1 { + if neg && total == maxDurationMagnitude { + return math.MinInt64, nil + } + return 0, isoDurationError(input, "value out of range") + } + if neg { + return -time.Duration(total), nil + } + return time.Duration(total), nil +} + +// isoResolveUnit validates a designator in context (section, ordering, week +// exclusivity) and returns its unit length in nanoseconds. +func isoResolveUnit( + input string, des byte, inTime bool, cfg isoDurationConfig, + lastDatePos, lastTimePos *int, weekSeen *bool, seenAny bool, + datePresent, timePresent *[3]bool, +) (uint64, error) { + if inTime { + pos, ok := isoTimePos[des] + if !ok { + return 0, isoDurationError(input, fmt.Sprintf("%q is not a valid time-section designator", des)) + } + if pos <= *lastTimePos { + return 0, isoDurationError(input, fmt.Sprintf("designator %q is out of order", des)) + } + *lastTimePos = pos + timePresent[pos-1] = true + switch des { + case 'H': + return isoHour, nil + case 'M': + return isoMinute, nil + default: // 'S' + return isoSecond, nil + } + } + + pos, ok := isoDatePos[des] + if !ok { + return 0, isoDurationError(input, fmt.Sprintf("%q is not a valid date-section designator", des)) + } + if pos <= *lastDatePos { + return 0, isoDurationError(input, fmt.Sprintf("designator %q is out of order", des)) + } + + if des == 'W' { + if !cfg.weekCombinable && seenAny { + return 0, isoDurationError(input, `"W" cannot be combined with other components`) + } + *lastDatePos = pos + *weekSeen = true + return isoWeek, nil + } + + if *weekSeen && !cfg.weekCombinable { + return 0, isoDurationError(input, `"W" cannot be combined with other components`) + } + *lastDatePos = pos + if slot, ok := isoDateSlot(des); ok { + datePresent[slot] = true + } + switch des { + case 'Y': + return isoYear, nil + case 'M': + return isoMonth, nil + default: // 'D' + return isoDay, nil + } +} + +// isoCheckContiguous rejects gaps in a section's component chain. +func isoCheckContiguous(input string, present [3]bool, section string) error { + first, last := -1, -1 + for i, p := range present { + if p { + if first < 0 { + first = i + } + last = i + } + } + if first < 0 { + return nil + } + for i := first; i <= last; i++ { + if !present[i] { + return isoDurationError(input, "non-contiguous "+section+" components (a gap in the unit chain)") + } + } + return nil +} + +// isoScaleValue converts an integer (and optional fractional) component to nanoseconds, checking every overflow +// boundary. +func isoScaleValue(input, intPart, fracPart string, unit uint64) (uint64, error) { + v, ok := isoParseUint(intPart) + if !ok { + return 0, isoDurationError(input, "value out of range") + } + // Bound v*unit to the duration magnitude *before* multiplying, so the later fractional addition cannot wrap a uint64. + if v > maxDurationMagnitude/unit { + return 0, isoDurationError(input, "value out of range") + } + val := v * unit + + if fracPart != "" { + f, scale := isoParseFraction(fracPart) + if f > 0 { + // float64 is accurate enough for a sub-unit fraction (matches the standard library technique); the magnitude stays + // below the uint64 ceiling because val <= 1<<63 and the addend is < unit. + val += uint64(float64(f) * (float64(unit) / float64(scale))) + if val > maxDurationMagnitude { + return 0, isoDurationError(input, "value out of range") + } + } + } + + return val, nil +} + +// isoParseUint parses digits into a uint64, reporting overflow. +func isoParseUint(s string) (uint64, bool) { + var v uint64 + for i := range len(s) { + if v > decimalAccMax { + return 0, false + } + v = v*decimalBase + uint64(s[i]-'0') + } + + return v, true +} + +// isoParseFraction parses fractional digits into (value, scale=10^len), capping precision at 18 digits so the value +// stays exact in the subsequent float maths. +func isoParseFraction(s string) (uint64, uint64) { + const maxFracDigits = 18 + if len(s) > maxFracDigits { + s = s[:maxFracDigits] + } + var f, scale uint64 = 0, 1 + for i := range len(s) { + f = f*decimalBase + uint64(s[i]-'0') + scale *= decimalBase + } + + return f, scale +} + +// isoFormat renders a duration in canonical ISO 8601 form (P[n]DT[n]H[n]M[n]S). +// +// Intermediate zero time components are emitted when needed to keep the output contiguous (e.g. 1h5s → "PT1H0M5S"), +// so the structure is always syntactically valid ISO 8601. Years, months and weeks are not reconstructed (a +// [time.Duration] does not carry calendar context); a fractional second is emitted losslessly, and a negative duration +// is prefixed with "-". +func isoFormat(d time.Duration) string { + if d == 0 { + return "PT0S" + } + neg := d < 0 + var u uint64 + if neg { + u = uint64(-d) + } else { + u = uint64(d) + } + + days := u / isoDay + u %= isoDay + hours := u / isoHour + u %= isoHour + minutes := u / isoMinute + u %= isoMinute + seconds := u / isoSecond + frac := u % isoSecond + + var b strings.Builder + if neg { + b.WriteByte('-') + } + + b.WriteByte('P') + if days > 0 { + b.WriteString(strconv.FormatUint(days, decimalBase)) + b.WriteByte('D') + } + isoWriteTimeSection(&b, hours, minutes, seconds, frac) + + return b.String() +} + +// isoWriteTimeSection appends the "T…" part of a canonical ISO 8601 duration, emitting a zero-minute filler when it +// must bridge hours and seconds so the output stays contiguous (e.g. 1h5s → "T1H0M5S"). +func isoWriteTimeSection(b *strings.Builder, hours, minutes, seconds, frac uint64) { + hasH := hours > 0 + hasM := minutes > 0 + hasS := seconds > 0 || frac > 0 + if !hasH && !hasM && !hasS { + return + } + + b.WriteByte('T') + if hasH { + b.WriteString(strconv.FormatUint(hours, decimalBase)) + b.WriteByte('H') + } + + // Emit minutes if non-zero, or as a zero filler bridging hours and seconds. + if hasM || (hasH && hasS) { + b.WriteString(strconv.FormatUint(minutes, decimalBase)) + b.WriteByte('M') + } + + if hasS { + b.WriteString(strconv.FormatUint(seconds, decimalBase)) + if frac > 0 { + b.WriteByte('.') + b.WriteString(isoFormatFraction(frac)) + } + b.WriteByte('S') + } +} + +// isoEmit renders d under the given policy. +// +// A policy that forbids a feature the value requires (a sign, or sub-second precision) cannot represent it, and returns +// an error rather than emitting output a matching parser would reject. +func isoEmit(d time.Duration, cfg isoDurationConfig) (string, error) { + if !cfg.allowSign && d < 0 { + return "", fmt.Errorf("a negative duration cannot be represented under this ISO 8601 policy: %w", ErrFormat) + } + + if !cfg.allowFraction && d%time.Second != 0 { + return "", fmt.Errorf("sub-second precision cannot be represented under this ISO 8601 policy: %w", ErrFormat) + } + + return isoFormat(d), nil +} + +// isoFormatFraction renders a nanosecond remainder (0..1e9) as its 9-digit fractional part with trailing zeros trimmed. +func isoFormatFraction(frac uint64) string { + s := strconv.FormatUint(frac, decimalBase) + if len(s) < nanoDigits { + s = strings.Repeat("0", nanoDigits-len(s)) + s + } + return strings.TrimRight(s, "0") +} diff --git a/vendor/github.com/go-openapi/strfmt/duration_iso8601_options.go b/vendor/github.com/go-openapi/strfmt/duration_iso8601_options.go new file mode 100644 index 00000000000..4f90a5c5a5a --- /dev/null +++ b/vendor/github.com/go-openapi/strfmt/duration_iso8601_options.go @@ -0,0 +1,80 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + +package strfmt + +// ISODurationPolicy is a compile-time policy selecting the parsing behaviour of an [ISODuration]. +// +// It is a phantom type parameter: a zero-size value whose single method yields the parser configuration. +// See [DurationStrict] and [DurationLenient]. +type ISODurationPolicy interface { + isoDurationConfig() isoDurationConfig +} + +// isoDurationConfig holds the leniency knobs of the ISO 8601 duration parser. +// +// The zero value is the strict RFC 3339 Appendix A grammar (the JSON Schema "duration" format): every field false. +type isoDurationConfig struct { + allowFraction bool // accept a decimal fraction on the least significant component + allowSign bool // accept a leading '+' or '-' + allowSpace bool // tolerate surrounding whitespace + weekCombinable bool // allow the 'W' designator to combine with other components + relaxAnchoring bool // allow gaps in the component chain (e.g. P1Y2D, PT1H2S) +} + +// DurationStrict is the strict RFC 3339 Appendix A policy. +// +// This is the grammar that the JSON Schema "duration" format is defined against (draft 2020): +// no fraction, no sign, no whitespace, strict ordering and anchoring, and an exclusive 'W' designator. +type DurationStrict struct{} + +func (DurationStrict) isoDurationConfig() isoDurationConfig { return isoDurationConfig{} } + +// DurationLenient relaxes every strictness knob. +// +// It accepts a decimal fraction on the least significant component, a leading sign, surrounding whitespace, +// component chains with gaps (e.g. P1Y2D), and a 'W' designator combined with other components. +// +// It remains ordered (P2D1Y is still rejected). +type DurationLenient struct{} + +func (DurationLenient) isoDurationConfig() isoDurationConfig { + return isoDurationConfig{ + allowFraction: true, + allowSign: true, + allowSpace: true, + weekCombinable: true, + relaxAnchoring: true, + } +} + +// ISODurationOption relaxes the strict parser on the explicit [ParseISO8601Duration] path, for programmatic callers. +// +// It has no effect on the registry / struct-field decode path, which is governed by the type's policy. +type ISODurationOption func(*isoDurationConfig) + +// WithISOFractions accepts a decimal fraction on the least significant component. +func WithISOFractions() ISODurationOption { + return func(c *isoDurationConfig) { c.allowFraction = true } +} + +// WithISOSign accepts a leading '+' or '-'. +func WithISOSign() ISODurationOption { return func(c *isoDurationConfig) { c.allowSign = true } } + +// WithISOSpace tolerates surrounding whitespace. +func WithISOSpace() ISODurationOption { return func(c *isoDurationConfig) { c.allowSpace = true } } + +// WithISOWeekCombinable allows the 'W' designator to combine with other components. +func WithISOWeekCombinable() ISODurationOption { + return func(c *isoDurationConfig) { c.weekCombinable = true } +} + +// WithISORelaxedAnchoring allows gaps in the component chain (e.g. P1Y2D, PT1H2S). +func WithISORelaxedAnchoring() ISODurationOption { + return func(c *isoDurationConfig) { c.relaxAnchoring = true } +} + +// WithISOLenient relaxes every strictness knob (see [DurationLenient]). +func WithISOLenient() ISODurationOption { + return func(c *isoDurationConfig) { *c = DurationLenient{}.isoDurationConfig() } +} diff --git a/vendor/github.com/go-openapi/strfmt/format.go b/vendor/github.com/go-openapi/strfmt/format.go index e494dd7b83d..09c37542546 100644 --- a/vendor/github.com/go-openapi/strfmt/format.go +++ b/vendor/github.com/go-openapi/strfmt/format.go @@ -10,15 +10,11 @@ import ( "slices" "strings" "sync" - "time" "github.com/go-openapi/errors" "github.com/go-viper/mapstructure/v2" ) -// Default is the default formats registry. -var Default = NewSeededFormats(nil, nil) //nolint:gochecknoglobals // package-level default registry, by design - // Validator represents a validator for a string format. type Validator func(string) bool @@ -48,11 +44,28 @@ type knownFormat struct { } // NameNormalizer is a function that normalizes a format name. +// +// The default duration format corresponds to "duration-human". type NameNormalizer func(string) string +var dashReplacer = strings.NewReplacer("-", "") //nolint:gochecknoglobals // it's okay to use a global private replacer + // DefaultNameNormalizer removes all dashes. func DefaultNameNormalizer(name string) string { - return strings.ReplaceAll(name, "-", "") + if name == "duration" { + name = "duration-human" + } + + return dashReplacer.Replace(name) +} + +// JSONSchema2020Normalizer is like [NameNormalizer] but adopts "duration-iso8601" as the default "duration" format. +func JSONSchema2020Normalizer(name string) string { + if name == "duration" { + name = "duration-iso8601" + } + + return dashReplacer.Replace(name) } type defaultFormats struct { @@ -63,6 +76,11 @@ type defaultFormats struct { } // MapStructureHookFunc is a decode hook function for mapstructure. +// +// A registered format is decoded by delegating to the destination type's own +// [encoding.TextUnmarshaler], so the mapstructure path is identical to the JSON +// and [defaultFormats.Parse] paths. New formats are picked up automatically as +// soon as they are registered — no per-type wiring here. func (f *defaultFormats) MapStructureHookFunc() mapstructure.DecodeHookFunc { //nolint:ireturn // returns interface required by mapstructure return func(from reflect.Type, to reflect.Type, obj any) (any, error) { if from.Kind() != reflect.String { @@ -74,85 +92,25 @@ func (f *defaultFormats) MapStructureHookFunc() mapstructure.DecodeHookFunc { // } for _, v := range f.data { - tpe, _ := f.GetType(v.Name) - if to == tpe { - return decodeFormatFromString(v.Name, data) + if to != v.Type { + continue } - } - return data, nil - } -} -// decodeFormatFromString decodes a string into the appropriate format type by name. -func decodeFormatFromString(name, data string) (any, error) { //nolint:gocyclo,cyclop // flat switch over format names, no real complexity - switch name { - case "date": - d, err := time.ParseInLocation(RFC3339FullDate, data, DefaultTimeLocation) - if err != nil { - return nil, err - } - return Date(d), nil - case "datetime": - if len(data) == 0 { - return nil, fmt.Errorf("empty string is an invalid datetime format: %w", ErrFormat) - } - return ParseDateTime(data) - case "duration": - dur, err := ParseDuration(data) - if err != nil { - return nil, err - } - return Duration(dur), nil - case "uri": - return URI(data), nil - case "email": - return Email(data), nil - case "uuid": - return UUID(data), nil - case "uuid3": - return UUID3(data), nil - case "uuid4": - return UUID4(data), nil - case "uuid5": - return UUID5(data), nil - case "uuid7": - return UUID7(data), nil - case "hostname": - return Hostname(data), nil - case "ipv4": - return IPv4(data), nil - case "ipv6": - return IPv6(data), nil - case "cidr": - return CIDR(data), nil - case "mac": - return MAC(data), nil - case "isbn": - return ISBN(data), nil - case "isbn10": - return ISBN10(data), nil - case "isbn13": - return ISBN13(data), nil - case "creditcard": - return CreditCard(data), nil - case "ssn": - return SSN(data), nil - case "hexcolor": - return HexColor(data), nil - case "rgbcolor": - return RGBColor(data), nil - case "byte": - return Base64(data), nil - case "password": - return Password(data), nil - case "ulid": - ulid, err := ParseULID(data) - if err != nil { - return nil, err + // reflect.New yields an addressable *T so the (pointer-receiver) + // TextUnmarshaler can hydrate it; we hand back the dereferenced + // value to match the destination field's (value) type. + nw := reflect.New(v.Type).Interface() + dec, isText := nw.(encoding.TextUnmarshaler) + if !isText { + return nil, errors.InvalidTypeName(v.Name) + } + if err := dec.UnmarshalText([]byte(data)); err != nil { + return nil, err + } + return reflect.ValueOf(nw).Elem().Interface(), nil } - return ulid, nil - default: - return nil, errors.InvalidTypeName(name) + + return data, nil } } diff --git a/vendor/github.com/go-openapi/strfmt/internal/countries/countries.go b/vendor/github.com/go-openapi/strfmt/internal/countries/countries.go new file mode 100644 index 00000000000..7f13c0cfe35 --- /dev/null +++ b/vendor/github.com/go-openapi/strfmt/internal/countries/countries.go @@ -0,0 +1,512 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by gen.go; DO NOT EDIT. + +package countries + +// CountriesISO3 indexes ISO3166 countries by their alpha-3 code. +var CountriesISO3 = map[string]Country{ + "ABW": {Name: "Aruba", ISOAlpha3: "ABW", ISOAlpha2: "AW", Code: "533"}, + "AFG": {Name: "Afghanistan", ISOAlpha3: "AFG", ISOAlpha2: "AF", Code: "004"}, + "AGO": {Name: "Angola", ISOAlpha3: "AGO", ISOAlpha2: "AO", Code: "024"}, + "AIA": {Name: "Anguilla", ISOAlpha3: "AIA", ISOAlpha2: "AI", Code: "660"}, + "ALA": {Name: "Åland Islands", ISOAlpha3: "ALA", ISOAlpha2: "AX", Code: "248"}, + "ALB": {Name: "Albania", ISOAlpha3: "ALB", ISOAlpha2: "AL", Code: "008"}, + "AND": {Name: "Andorra", ISOAlpha3: "AND", ISOAlpha2: "AD", Code: "020"}, + "ARE": {Name: "United Arab Emirates", ISOAlpha3: "ARE", ISOAlpha2: "AE", Code: "784"}, + "ARG": {Name: "Argentina", ISOAlpha3: "ARG", ISOAlpha2: "AR", Code: "032"}, + "ARM": {Name: "Armenia", ISOAlpha3: "ARM", ISOAlpha2: "AM", Code: "051"}, + "ASM": {Name: "American Samoa", ISOAlpha3: "ASM", ISOAlpha2: "AS", Code: "016"}, + "ATA": {Name: "Antarctica", ISOAlpha3: "ATA", ISOAlpha2: "AQ", Code: "010"}, + "ATF": {Name: "French Southern Territories", ISOAlpha3: "ATF", ISOAlpha2: "TF", Code: "260"}, + "ATG": {Name: "Antigua and Barbuda", ISOAlpha3: "ATG", ISOAlpha2: "AG", Code: "028"}, + "AUS": {Name: "Australia", ISOAlpha3: "AUS", ISOAlpha2: "AU", Code: "036"}, + "AUT": {Name: "Austria", ISOAlpha3: "AUT", ISOAlpha2: "AT", Code: "040"}, + "AZE": {Name: "Azerbaijan", ISOAlpha3: "AZE", ISOAlpha2: "AZ", Code: "031"}, + "BDI": {Name: "Burundi", ISOAlpha3: "BDI", ISOAlpha2: "BI", Code: "108"}, + "BEL": {Name: "Belgium", ISOAlpha3: "BEL", ISOAlpha2: "BE", Code: "056"}, + "BEN": {Name: "Benin", ISOAlpha3: "BEN", ISOAlpha2: "BJ", Code: "204"}, + "BES": {Name: "Bonaire, Sint Eustatius and Saba", ISOAlpha3: "BES", ISOAlpha2: "BQ", Code: "535"}, + "BFA": {Name: "Burkina Faso", ISOAlpha3: "BFA", ISOAlpha2: "BF", Code: "854"}, + "BGD": {Name: "Bangladesh", ISOAlpha3: "BGD", ISOAlpha2: "BD", Code: "050"}, + "BGR": {Name: "Bulgaria", ISOAlpha3: "BGR", ISOAlpha2: "BG", Code: "100"}, + "BHR": {Name: "Bahrain", ISOAlpha3: "BHR", ISOAlpha2: "BH", Code: "048"}, + "BHS": {Name: "Bahamas", ISOAlpha3: "BHS", ISOAlpha2: "BS", Code: "044"}, + "BIH": {Name: "Bosnia and Herzegovina", ISOAlpha3: "BIH", ISOAlpha2: "BA", Code: "070"}, + "BLM": {Name: "Saint Barthélemy", ISOAlpha3: "BLM", ISOAlpha2: "BL", Code: "652"}, + "BLR": {Name: "Belarus", ISOAlpha3: "BLR", ISOAlpha2: "BY", Code: "112"}, + "BLZ": {Name: "Belize", ISOAlpha3: "BLZ", ISOAlpha2: "BZ", Code: "084"}, + "BMU": {Name: "Bermuda", ISOAlpha3: "BMU", ISOAlpha2: "BM", Code: "060"}, + "BOL": {Name: "Bolivia (Plurinational State of)", ISOAlpha3: "BOL", ISOAlpha2: "BO", Code: "068"}, + "BRA": {Name: "Brazil", ISOAlpha3: "BRA", ISOAlpha2: "BR", Code: "076"}, + "BRB": {Name: "Barbados", ISOAlpha3: "BRB", ISOAlpha2: "BB", Code: "052"}, + "BRN": {Name: "Brunei Darussalam", ISOAlpha3: "BRN", ISOAlpha2: "BN", Code: "096"}, + "BTN": {Name: "Bhutan", ISOAlpha3: "BTN", ISOAlpha2: "BT", Code: "064"}, + "BVT": {Name: "Bouvet Island", ISOAlpha3: "BVT", ISOAlpha2: "BV", Code: "074"}, + "BWA": {Name: "Botswana", ISOAlpha3: "BWA", ISOAlpha2: "BW", Code: "072"}, + "CAF": {Name: "Central African Republic", ISOAlpha3: "CAF", ISOAlpha2: "CF", Code: "140"}, + "CAN": {Name: "Canada", ISOAlpha3: "CAN", ISOAlpha2: "CA", Code: "124"}, + "CCK": {Name: "Cocos (Keeling) Islands", ISOAlpha3: "CCK", ISOAlpha2: "CC", Code: "166"}, + "CHE": {Name: "Switzerland", ISOAlpha3: "CHE", ISOAlpha2: "CH", Code: "756"}, + "CHL": {Name: "Chile", ISOAlpha3: "CHL", ISOAlpha2: "CL", Code: "152"}, + "CHN": {Name: "China", ISOAlpha3: "CHN", ISOAlpha2: "CN", Code: "156"}, + "CIV": {Name: "Côte d'Ivoire", ISOAlpha3: "CIV", ISOAlpha2: "CI", Code: "384"}, + "CMR": {Name: "Cameroon", ISOAlpha3: "CMR", ISOAlpha2: "CM", Code: "120"}, + "COD": {Name: "Congo, Democratic Republic of the", ISOAlpha3: "COD", ISOAlpha2: "CD", Code: "180"}, + "COG": {Name: "Congo", ISOAlpha3: "COG", ISOAlpha2: "CG", Code: "178"}, + "COK": {Name: "Cook Islands", ISOAlpha3: "COK", ISOAlpha2: "CK", Code: "184"}, + "COL": {Name: "Colombia", ISOAlpha3: "COL", ISOAlpha2: "CO", Code: "170"}, + "COM": {Name: "Comoros", ISOAlpha3: "COM", ISOAlpha2: "KM", Code: "174"}, + "CPV": {Name: "Cabo Verde", ISOAlpha3: "CPV", ISOAlpha2: "CV", Code: "132"}, + "CRI": {Name: "Costa Rica", ISOAlpha3: "CRI", ISOAlpha2: "CR", Code: "188"}, + "CUB": {Name: "Cuba", ISOAlpha3: "CUB", ISOAlpha2: "CU", Code: "192"}, + "CUW": {Name: "Curaçao", ISOAlpha3: "CUW", ISOAlpha2: "CW", Code: "531"}, + "CXR": {Name: "Christmas Island", ISOAlpha3: "CXR", ISOAlpha2: "CX", Code: "162"}, + "CYM": {Name: "Cayman Islands", ISOAlpha3: "CYM", ISOAlpha2: "KY", Code: "136"}, + "CYP": {Name: "Cyprus", ISOAlpha3: "CYP", ISOAlpha2: "CY", Code: "196"}, + "CZE": {Name: "Czechia", ISOAlpha3: "CZE", ISOAlpha2: "CZ", Code: "203"}, + "DEU": {Name: "Germany", ISOAlpha3: "DEU", ISOAlpha2: "DE", Code: "276"}, + "DJI": {Name: "Djibouti", ISOAlpha3: "DJI", ISOAlpha2: "DJ", Code: "262"}, + "DMA": {Name: "Dominica", ISOAlpha3: "DMA", ISOAlpha2: "DM", Code: "212"}, + "DNK": {Name: "Denmark", ISOAlpha3: "DNK", ISOAlpha2: "DK", Code: "208"}, + "DOM": {Name: "Dominican Republic", ISOAlpha3: "DOM", ISOAlpha2: "DO", Code: "214"}, + "DZA": {Name: "Algeria", ISOAlpha3: "DZA", ISOAlpha2: "DZ", Code: "012"}, + "ECU": {Name: "Ecuador", ISOAlpha3: "ECU", ISOAlpha2: "EC", Code: "218"}, + "EGY": {Name: "Egypt", ISOAlpha3: "EGY", ISOAlpha2: "EG", Code: "818"}, + "ERI": {Name: "Eritrea", ISOAlpha3: "ERI", ISOAlpha2: "ER", Code: "232"}, + "ESH": {Name: "Western Sahara", ISOAlpha3: "ESH", ISOAlpha2: "EH", Code: "732"}, + "ESP": {Name: "Spain", ISOAlpha3: "ESP", ISOAlpha2: "ES", Code: "724"}, + "EST": {Name: "Estonia", ISOAlpha3: "EST", ISOAlpha2: "EE", Code: "233"}, + "ETH": {Name: "Ethiopia", ISOAlpha3: "ETH", ISOAlpha2: "ET", Code: "231"}, + "FIN": {Name: "Finland", ISOAlpha3: "FIN", ISOAlpha2: "FI", Code: "246"}, + "FJI": {Name: "Fiji", ISOAlpha3: "FJI", ISOAlpha2: "FJ", Code: "242"}, + "FLK": {Name: "Falkland Islands (Malvinas)", ISOAlpha3: "FLK", ISOAlpha2: "FK", Code: "238"}, + "FRA": {Name: "France", ISOAlpha3: "FRA", ISOAlpha2: "FR", Code: "250"}, + "FRO": {Name: "Faroe Islands", ISOAlpha3: "FRO", ISOAlpha2: "FO", Code: "234"}, + "FSM": {Name: "Micronesia (Federated States of)", ISOAlpha3: "FSM", ISOAlpha2: "FM", Code: "583"}, + "GAB": {Name: "Gabon", ISOAlpha3: "GAB", ISOAlpha2: "GA", Code: "266"}, + "GBR": {Name: "United Kingdom of Great Britain and Northern Ireland", ISOAlpha3: "GBR", ISOAlpha2: "GB", Code: "826"}, + "GEO": {Name: "Georgia", ISOAlpha3: "GEO", ISOAlpha2: "GE", Code: "268"}, + "GGY": {Name: "Guernsey", ISOAlpha3: "GGY", ISOAlpha2: "GG", Code: "831"}, + "GHA": {Name: "Ghana", ISOAlpha3: "GHA", ISOAlpha2: "GH", Code: "288"}, + "GIB": {Name: "Gibraltar", ISOAlpha3: "GIB", ISOAlpha2: "GI", Code: "292"}, + "GIN": {Name: "Guinea", ISOAlpha3: "GIN", ISOAlpha2: "GN", Code: "324"}, + "GLP": {Name: "Guadeloupe", ISOAlpha3: "GLP", ISOAlpha2: "GP", Code: "312"}, + "GMB": {Name: "Gambia", ISOAlpha3: "GMB", ISOAlpha2: "GM", Code: "270"}, + "GNB": {Name: "Guinea-Bissau", ISOAlpha3: "GNB", ISOAlpha2: "GW", Code: "624"}, + "GNQ": {Name: "Equatorial Guinea", ISOAlpha3: "GNQ", ISOAlpha2: "GQ", Code: "226"}, + "GRC": {Name: "Greece", ISOAlpha3: "GRC", ISOAlpha2: "GR", Code: "300"}, + "GRD": {Name: "Grenada", ISOAlpha3: "GRD", ISOAlpha2: "GD", Code: "308"}, + "GRL": {Name: "Greenland", ISOAlpha3: "GRL", ISOAlpha2: "GL", Code: "304"}, + "GTM": {Name: "Guatemala", ISOAlpha3: "GTM", ISOAlpha2: "GT", Code: "320"}, + "GUF": {Name: "French Guiana", ISOAlpha3: "GUF", ISOAlpha2: "GF", Code: "254"}, + "GUM": {Name: "Guam", ISOAlpha3: "GUM", ISOAlpha2: "GU", Code: "316"}, + "GUY": {Name: "Guyana", ISOAlpha3: "GUY", ISOAlpha2: "GY", Code: "328"}, + "HKG": {Name: "Hong Kong", ISOAlpha3: "HKG", ISOAlpha2: "HK", Code: "344"}, + "HMD": {Name: "Heard Island and McDonald Islands", ISOAlpha3: "HMD", ISOAlpha2: "HM", Code: "334"}, + "HND": {Name: "Honduras", ISOAlpha3: "HND", ISOAlpha2: "HN", Code: "340"}, + "HRV": {Name: "Croatia", ISOAlpha3: "HRV", ISOAlpha2: "HR", Code: "191"}, + "HTI": {Name: "Haiti", ISOAlpha3: "HTI", ISOAlpha2: "HT", Code: "332"}, + "HUN": {Name: "Hungary", ISOAlpha3: "HUN", ISOAlpha2: "HU", Code: "348"}, + "IDN": {Name: "Indonesia", ISOAlpha3: "IDN", ISOAlpha2: "ID", Code: "360"}, + "IMN": {Name: "Isle of Man", ISOAlpha3: "IMN", ISOAlpha2: "IM", Code: "833"}, + "IND": {Name: "India", ISOAlpha3: "IND", ISOAlpha2: "IN", Code: "356"}, + "IOT": {Name: "British Indian Ocean Territory", ISOAlpha3: "IOT", ISOAlpha2: "IO", Code: "086"}, + "IRL": {Name: "Ireland", ISOAlpha3: "IRL", ISOAlpha2: "IE", Code: "372"}, + "IRN": {Name: "Iran (Islamic Republic of)", ISOAlpha3: "IRN", ISOAlpha2: "IR", Code: "364"}, + "IRQ": {Name: "Iraq", ISOAlpha3: "IRQ", ISOAlpha2: "IQ", Code: "368"}, + "ISL": {Name: "Iceland", ISOAlpha3: "ISL", ISOAlpha2: "IS", Code: "352"}, + "ISR": {Name: "Israel", ISOAlpha3: "ISR", ISOAlpha2: "IL", Code: "376"}, + "ITA": {Name: "Italy", ISOAlpha3: "ITA", ISOAlpha2: "IT", Code: "380"}, + "JAM": {Name: "Jamaica", ISOAlpha3: "JAM", ISOAlpha2: "JM", Code: "388"}, + "JEY": {Name: "Jersey", ISOAlpha3: "JEY", ISOAlpha2: "JE", Code: "832"}, + "JOR": {Name: "Jordan", ISOAlpha3: "JOR", ISOAlpha2: "JO", Code: "400"}, + "JPN": {Name: "Japan", ISOAlpha3: "JPN", ISOAlpha2: "JP", Code: "392"}, + "KAZ": {Name: "Kazakhstan", ISOAlpha3: "KAZ", ISOAlpha2: "KZ", Code: "398"}, + "KEN": {Name: "Kenya", ISOAlpha3: "KEN", ISOAlpha2: "KE", Code: "404"}, + "KGZ": {Name: "Kyrgyzstan", ISOAlpha3: "KGZ", ISOAlpha2: "KG", Code: "417"}, + "KHM": {Name: "Cambodia", ISOAlpha3: "KHM", ISOAlpha2: "KH", Code: "116"}, + "KIR": {Name: "Kiribati", ISOAlpha3: "KIR", ISOAlpha2: "KI", Code: "296"}, + "KNA": {Name: "Saint Kitts and Nevis", ISOAlpha3: "KNA", ISOAlpha2: "KN", Code: "659"}, + "KOR": {Name: "Korea, Republic of", ISOAlpha3: "KOR", ISOAlpha2: "KR", Code: "410"}, + "KWT": {Name: "Kuwait", ISOAlpha3: "KWT", ISOAlpha2: "KW", Code: "414"}, + "LAO": {Name: "Lao People's Democratic Republic", ISOAlpha3: "LAO", ISOAlpha2: "LA", Code: "418"}, + "LBN": {Name: "Lebanon", ISOAlpha3: "LBN", ISOAlpha2: "LB", Code: "422"}, + "LBR": {Name: "Liberia", ISOAlpha3: "LBR", ISOAlpha2: "LR", Code: "430"}, + "LBY": {Name: "Libya", ISOAlpha3: "LBY", ISOAlpha2: "LY", Code: "434"}, + "LCA": {Name: "Saint Lucia", ISOAlpha3: "LCA", ISOAlpha2: "LC", Code: "662"}, + "LIE": {Name: "Liechtenstein", ISOAlpha3: "LIE", ISOAlpha2: "LI", Code: "438"}, + "LKA": {Name: "Sri Lanka", ISOAlpha3: "LKA", ISOAlpha2: "LK", Code: "144"}, + "LSO": {Name: "Lesotho", ISOAlpha3: "LSO", ISOAlpha2: "LS", Code: "426"}, + "LTU": {Name: "Lithuania", ISOAlpha3: "LTU", ISOAlpha2: "LT", Code: "440"}, + "LUX": {Name: "Luxembourg", ISOAlpha3: "LUX", ISOAlpha2: "LU", Code: "442"}, + "LVA": {Name: "Latvia", ISOAlpha3: "LVA", ISOAlpha2: "LV", Code: "428"}, + "MAC": {Name: "Macao", ISOAlpha3: "MAC", ISOAlpha2: "MO", Code: "446"}, + "MAF": {Name: "Saint Martin (French part)", ISOAlpha3: "MAF", ISOAlpha2: "MF", Code: "663"}, + "MAR": {Name: "Morocco", ISOAlpha3: "MAR", ISOAlpha2: "MA", Code: "504"}, + "MCO": {Name: "Monaco", ISOAlpha3: "MCO", ISOAlpha2: "MC", Code: "492"}, + "MDA": {Name: "Moldova, Republic of", ISOAlpha3: "MDA", ISOAlpha2: "MD", Code: "498"}, + "MDG": {Name: "Madagascar", ISOAlpha3: "MDG", ISOAlpha2: "MG", Code: "450"}, + "MDV": {Name: "Maldives", ISOAlpha3: "MDV", ISOAlpha2: "MV", Code: "462"}, + "MEX": {Name: "Mexico", ISOAlpha3: "MEX", ISOAlpha2: "MX", Code: "484"}, + "MHL": {Name: "Marshall Islands", ISOAlpha3: "MHL", ISOAlpha2: "MH", Code: "584"}, + "MKD": {Name: "North Macedonia", ISOAlpha3: "MKD", ISOAlpha2: "MK", Code: "807"}, + "MLI": {Name: "Mali", ISOAlpha3: "MLI", ISOAlpha2: "ML", Code: "466"}, + "MLT": {Name: "Malta", ISOAlpha3: "MLT", ISOAlpha2: "MT", Code: "470"}, + "MMR": {Name: "Myanmar", ISOAlpha3: "MMR", ISOAlpha2: "MM", Code: "104"}, + "MNE": {Name: "Montenegro", ISOAlpha3: "MNE", ISOAlpha2: "ME", Code: "499"}, + "MNG": {Name: "Mongolia", ISOAlpha3: "MNG", ISOAlpha2: "MN", Code: "496"}, + "MNP": {Name: "Northern Mariana Islands", ISOAlpha3: "MNP", ISOAlpha2: "MP", Code: "580"}, + "MOZ": {Name: "Mozambique", ISOAlpha3: "MOZ", ISOAlpha2: "MZ", Code: "508"}, + "MRT": {Name: "Mauritania", ISOAlpha3: "MRT", ISOAlpha2: "MR", Code: "478"}, + "MSR": {Name: "Montserrat", ISOAlpha3: "MSR", ISOAlpha2: "MS", Code: "500"}, + "MTQ": {Name: "Martinique", ISOAlpha3: "MTQ", ISOAlpha2: "MQ", Code: "474"}, + "MUS": {Name: "Mauritius", ISOAlpha3: "MUS", ISOAlpha2: "MU", Code: "480"}, + "MWI": {Name: "Malawi", ISOAlpha3: "MWI", ISOAlpha2: "MW", Code: "454"}, + "MYS": {Name: "Malaysia", ISOAlpha3: "MYS", ISOAlpha2: "MY", Code: "458"}, + "MYT": {Name: "Mayotte", ISOAlpha3: "MYT", ISOAlpha2: "YT", Code: "175"}, + "NAM": {Name: "Namibia", ISOAlpha3: "NAM", ISOAlpha2: "NA", Code: "516"}, + "NCL": {Name: "New Caledonia", ISOAlpha3: "NCL", ISOAlpha2: "NC", Code: "540"}, + "NER": {Name: "Niger", ISOAlpha3: "NER", ISOAlpha2: "NE", Code: "562"}, + "NFK": {Name: "Norfolk Island", ISOAlpha3: "NFK", ISOAlpha2: "NF", Code: "574"}, + "NGA": {Name: "Nigeria", ISOAlpha3: "NGA", ISOAlpha2: "NG", Code: "566"}, + "NIC": {Name: "Nicaragua", ISOAlpha3: "NIC", ISOAlpha2: "NI", Code: "558"}, + "NIU": {Name: "Niue", ISOAlpha3: "NIU", ISOAlpha2: "NU", Code: "570"}, + "NLD": {Name: "Netherlands", ISOAlpha3: "NLD", ISOAlpha2: "NL", Code: "528"}, + "NOR": {Name: "Norway", ISOAlpha3: "NOR", ISOAlpha2: "NO", Code: "578"}, + "NPL": {Name: "Nepal", ISOAlpha3: "NPL", ISOAlpha2: "NP", Code: "524"}, + "NRU": {Name: "Nauru", ISOAlpha3: "NRU", ISOAlpha2: "NR", Code: "520"}, + "NZL": {Name: "New Zealand", ISOAlpha3: "NZL", ISOAlpha2: "NZ", Code: "554"}, + "OMN": {Name: "Oman", ISOAlpha3: "OMN", ISOAlpha2: "OM", Code: "512"}, + "PAK": {Name: "Pakistan", ISOAlpha3: "PAK", ISOAlpha2: "PK", Code: "586"}, + "PAN": {Name: "Panama", ISOAlpha3: "PAN", ISOAlpha2: "PA", Code: "591"}, + "PCN": {Name: "Pitcairn", ISOAlpha3: "PCN", ISOAlpha2: "PN", Code: "612"}, + "PER": {Name: "Peru", ISOAlpha3: "PER", ISOAlpha2: "PE", Code: "604"}, + "PHL": {Name: "Philippines", ISOAlpha3: "PHL", ISOAlpha2: "PH", Code: "608"}, + "PLW": {Name: "Palau", ISOAlpha3: "PLW", ISOAlpha2: "PW", Code: "585"}, + "PNG": {Name: "Papua New Guinea", ISOAlpha3: "PNG", ISOAlpha2: "PG", Code: "598"}, + "POL": {Name: "Poland", ISOAlpha3: "POL", ISOAlpha2: "PL", Code: "616"}, + "PRI": {Name: "Puerto Rico", ISOAlpha3: "PRI", ISOAlpha2: "PR", Code: "630"}, + "PRK": {Name: "Korea (Democratic People's Republic of)", ISOAlpha3: "PRK", ISOAlpha2: "KP", Code: "408"}, + "PRT": {Name: "Portugal", ISOAlpha3: "PRT", ISOAlpha2: "PT", Code: "620"}, + "PRY": {Name: "Paraguay", ISOAlpha3: "PRY", ISOAlpha2: "PY", Code: "600"}, + "PSE": {Name: "Palestine, State of", ISOAlpha3: "PSE", ISOAlpha2: "PS", Code: "275"}, + "PYF": {Name: "French Polynesia", ISOAlpha3: "PYF", ISOAlpha2: "PF", Code: "258"}, + "QAT": {Name: "Qatar", ISOAlpha3: "QAT", ISOAlpha2: "QA", Code: "634"}, + "REU": {Name: "Réunion", ISOAlpha3: "REU", ISOAlpha2: "RE", Code: "638"}, + "ROU": {Name: "Romania", ISOAlpha3: "ROU", ISOAlpha2: "RO", Code: "642"}, + "RUS": {Name: "Russian Federation", ISOAlpha3: "RUS", ISOAlpha2: "RU", Code: "643"}, + "RWA": {Name: "Rwanda", ISOAlpha3: "RWA", ISOAlpha2: "RW", Code: "646"}, + "SAU": {Name: "Saudi Arabia", ISOAlpha3: "SAU", ISOAlpha2: "SA", Code: "682"}, + "SDN": {Name: "Sudan", ISOAlpha3: "SDN", ISOAlpha2: "SD", Code: "729"}, + "SEN": {Name: "Senegal", ISOAlpha3: "SEN", ISOAlpha2: "SN", Code: "686"}, + "SGP": {Name: "Singapore", ISOAlpha3: "SGP", ISOAlpha2: "SG", Code: "702"}, + "SGS": {Name: "South Georgia and the South Sandwich Islands", ISOAlpha3: "SGS", ISOAlpha2: "GS", Code: "239"}, + "SHN": {Name: "Saint Helena, Ascension and Tristan da Cunha", ISOAlpha3: "SHN", ISOAlpha2: "SH", Code: "654"}, + "SJM": {Name: "Svalbard and Jan Mayen", ISOAlpha3: "SJM", ISOAlpha2: "SJ", Code: "744"}, + "SLB": {Name: "Solomon Islands", ISOAlpha3: "SLB", ISOAlpha2: "SB", Code: "090"}, + "SLE": {Name: "Sierra Leone", ISOAlpha3: "SLE", ISOAlpha2: "SL", Code: "694"}, + "SLV": {Name: "El Salvador", ISOAlpha3: "SLV", ISOAlpha2: "SV", Code: "222"}, + "SMR": {Name: "San Marino", ISOAlpha3: "SMR", ISOAlpha2: "SM", Code: "674"}, + "SOM": {Name: "Somalia", ISOAlpha3: "SOM", ISOAlpha2: "SO", Code: "706"}, + "SPM": {Name: "Saint Pierre and Miquelon", ISOAlpha3: "SPM", ISOAlpha2: "PM", Code: "666"}, + "SRB": {Name: "Serbia", ISOAlpha3: "SRB", ISOAlpha2: "RS", Code: "688"}, + "SSD": {Name: "South Sudan", ISOAlpha3: "SSD", ISOAlpha2: "SS", Code: "728"}, + "STP": {Name: "Sao Tome and Principe", ISOAlpha3: "STP", ISOAlpha2: "ST", Code: "678"}, + "SUR": {Name: "Suriname", ISOAlpha3: "SUR", ISOAlpha2: "SR", Code: "740"}, + "SVK": {Name: "Slovakia", ISOAlpha3: "SVK", ISOAlpha2: "SK", Code: "703"}, + "SVN": {Name: "Slovenia", ISOAlpha3: "SVN", ISOAlpha2: "SI", Code: "705"}, + "SWE": {Name: "Sweden", ISOAlpha3: "SWE", ISOAlpha2: "SE", Code: "752"}, + "SWZ": {Name: "Eswatini", ISOAlpha3: "SWZ", ISOAlpha2: "SZ", Code: "748"}, + "SXM": {Name: "Sint Maarten (Dutch part)", ISOAlpha3: "SXM", ISOAlpha2: "SX", Code: "534"}, + "SYC": {Name: "Seychelles", ISOAlpha3: "SYC", ISOAlpha2: "SC", Code: "690"}, + "SYR": {Name: "Syrian Arab Republic", ISOAlpha3: "SYR", ISOAlpha2: "SY", Code: "760"}, + "TCA": {Name: "Turks and Caicos Islands", ISOAlpha3: "TCA", ISOAlpha2: "TC", Code: "796"}, + "TCD": {Name: "Chad", ISOAlpha3: "TCD", ISOAlpha2: "TD", Code: "148"}, + "TGO": {Name: "Togo", ISOAlpha3: "TGO", ISOAlpha2: "TG", Code: "768"}, + "THA": {Name: "Thailand", ISOAlpha3: "THA", ISOAlpha2: "TH", Code: "764"}, + "TJK": {Name: "Tajikistan", ISOAlpha3: "TJK", ISOAlpha2: "TJ", Code: "762"}, + "TKL": {Name: "Tokelau", ISOAlpha3: "TKL", ISOAlpha2: "TK", Code: "772"}, + "TKM": {Name: "Turkmenistan", ISOAlpha3: "TKM", ISOAlpha2: "TM", Code: "795"}, + "TLS": {Name: "Timor-Leste", ISOAlpha3: "TLS", ISOAlpha2: "TL", Code: "626"}, + "TON": {Name: "Tonga", ISOAlpha3: "TON", ISOAlpha2: "TO", Code: "776"}, + "TTO": {Name: "Trinidad and Tobago", ISOAlpha3: "TTO", ISOAlpha2: "TT", Code: "780"}, + "TUN": {Name: "Tunisia", ISOAlpha3: "TUN", ISOAlpha2: "TN", Code: "788"}, + "TUR": {Name: "Turkey", ISOAlpha3: "TUR", ISOAlpha2: "TR", Code: "792"}, + "TUV": {Name: "Tuvalu", ISOAlpha3: "TUV", ISOAlpha2: "TV", Code: "798"}, + "TWN": {Name: "Taiwan, Province of China", ISOAlpha3: "TWN", ISOAlpha2: "TW", Code: "158"}, + "TZA": {Name: "Tanzania, United Republic of", ISOAlpha3: "TZA", ISOAlpha2: "TZ", Code: "834"}, + "UGA": {Name: "Uganda", ISOAlpha3: "UGA", ISOAlpha2: "UG", Code: "800"}, + "UKR": {Name: "Ukraine", ISOAlpha3: "UKR", ISOAlpha2: "UA", Code: "804"}, + "UMI": {Name: "United States Minor Outlying Islands", ISOAlpha3: "UMI", ISOAlpha2: "UM", Code: "581"}, + "URY": {Name: "Uruguay", ISOAlpha3: "URY", ISOAlpha2: "UY", Code: "858"}, + "USA": {Name: "United States of America", ISOAlpha3: "USA", ISOAlpha2: "US", Code: "840"}, + "UZB": {Name: "Uzbekistan", ISOAlpha3: "UZB", ISOAlpha2: "UZ", Code: "860"}, + "VAT": {Name: "Holy See", ISOAlpha3: "VAT", ISOAlpha2: "VA", Code: "336"}, + "VCT": {Name: "Saint Vincent and the Grenadines", ISOAlpha3: "VCT", ISOAlpha2: "VC", Code: "670"}, + "VEN": {Name: "Venezuela (Bolivarian Republic of)", ISOAlpha3: "VEN", ISOAlpha2: "VE", Code: "862"}, + "VGB": {Name: "Virgin Islands (British)", ISOAlpha3: "VGB", ISOAlpha2: "VG", Code: "092"}, + "VIR": {Name: "Virgin Islands (U.S.)", ISOAlpha3: "VIR", ISOAlpha2: "VI", Code: "850"}, + "VNM": {Name: "Viet Nam", ISOAlpha3: "VNM", ISOAlpha2: "VN", Code: "704"}, + "VUT": {Name: "Vanuatu", ISOAlpha3: "VUT", ISOAlpha2: "VU", Code: "548"}, + "WLF": {Name: "Wallis and Futuna", ISOAlpha3: "WLF", ISOAlpha2: "WF", Code: "876"}, + "WSM": {Name: "Samoa", ISOAlpha3: "WSM", ISOAlpha2: "WS", Code: "882"}, + "YEM": {Name: "Yemen", ISOAlpha3: "YEM", ISOAlpha2: "YE", Code: "887"}, + "ZAF": {Name: "South Africa", ISOAlpha3: "ZAF", ISOAlpha2: "ZA", Code: "710"}, + "ZMB": {Name: "Zambia", ISOAlpha3: "ZMB", ISOAlpha2: "ZM", Code: "894"}, + "ZWE": {Name: "Zimbabwe", ISOAlpha3: "ZWE", ISOAlpha2: "ZW", Code: "716"}, +} + +// CountriesISO2 indexes ISO3166 countries by their alpha-2 code. +var CountriesISO2 = map[string]Country{ + "AD": {Name: "Andorra", ISOAlpha3: "AND", ISOAlpha2: "AD", Code: "020"}, + "AE": {Name: "United Arab Emirates", ISOAlpha3: "ARE", ISOAlpha2: "AE", Code: "784"}, + "AF": {Name: "Afghanistan", ISOAlpha3: "AFG", ISOAlpha2: "AF", Code: "004"}, + "AG": {Name: "Antigua and Barbuda", ISOAlpha3: "ATG", ISOAlpha2: "AG", Code: "028"}, + "AI": {Name: "Anguilla", ISOAlpha3: "AIA", ISOAlpha2: "AI", Code: "660"}, + "AL": {Name: "Albania", ISOAlpha3: "ALB", ISOAlpha2: "AL", Code: "008"}, + "AM": {Name: "Armenia", ISOAlpha3: "ARM", ISOAlpha2: "AM", Code: "051"}, + "AO": {Name: "Angola", ISOAlpha3: "AGO", ISOAlpha2: "AO", Code: "024"}, + "AQ": {Name: "Antarctica", ISOAlpha3: "ATA", ISOAlpha2: "AQ", Code: "010"}, + "AR": {Name: "Argentina", ISOAlpha3: "ARG", ISOAlpha2: "AR", Code: "032"}, + "AS": {Name: "American Samoa", ISOAlpha3: "ASM", ISOAlpha2: "AS", Code: "016"}, + "AT": {Name: "Austria", ISOAlpha3: "AUT", ISOAlpha2: "AT", Code: "040"}, + "AU": {Name: "Australia", ISOAlpha3: "AUS", ISOAlpha2: "AU", Code: "036"}, + "AW": {Name: "Aruba", ISOAlpha3: "ABW", ISOAlpha2: "AW", Code: "533"}, + "AX": {Name: "Åland Islands", ISOAlpha3: "ALA", ISOAlpha2: "AX", Code: "248"}, + "AZ": {Name: "Azerbaijan", ISOAlpha3: "AZE", ISOAlpha2: "AZ", Code: "031"}, + "BA": {Name: "Bosnia and Herzegovina", ISOAlpha3: "BIH", ISOAlpha2: "BA", Code: "070"}, + "BB": {Name: "Barbados", ISOAlpha3: "BRB", ISOAlpha2: "BB", Code: "052"}, + "BD": {Name: "Bangladesh", ISOAlpha3: "BGD", ISOAlpha2: "BD", Code: "050"}, + "BE": {Name: "Belgium", ISOAlpha3: "BEL", ISOAlpha2: "BE", Code: "056"}, + "BF": {Name: "Burkina Faso", ISOAlpha3: "BFA", ISOAlpha2: "BF", Code: "854"}, + "BG": {Name: "Bulgaria", ISOAlpha3: "BGR", ISOAlpha2: "BG", Code: "100"}, + "BH": {Name: "Bahrain", ISOAlpha3: "BHR", ISOAlpha2: "BH", Code: "048"}, + "BI": {Name: "Burundi", ISOAlpha3: "BDI", ISOAlpha2: "BI", Code: "108"}, + "BJ": {Name: "Benin", ISOAlpha3: "BEN", ISOAlpha2: "BJ", Code: "204"}, + "BL": {Name: "Saint Barthélemy", ISOAlpha3: "BLM", ISOAlpha2: "BL", Code: "652"}, + "BM": {Name: "Bermuda", ISOAlpha3: "BMU", ISOAlpha2: "BM", Code: "060"}, + "BN": {Name: "Brunei Darussalam", ISOAlpha3: "BRN", ISOAlpha2: "BN", Code: "096"}, + "BO": {Name: "Bolivia (Plurinational State of)", ISOAlpha3: "BOL", ISOAlpha2: "BO", Code: "068"}, + "BQ": {Name: "Bonaire, Sint Eustatius and Saba", ISOAlpha3: "BES", ISOAlpha2: "BQ", Code: "535"}, + "BR": {Name: "Brazil", ISOAlpha3: "BRA", ISOAlpha2: "BR", Code: "076"}, + "BS": {Name: "Bahamas", ISOAlpha3: "BHS", ISOAlpha2: "BS", Code: "044"}, + "BT": {Name: "Bhutan", ISOAlpha3: "BTN", ISOAlpha2: "BT", Code: "064"}, + "BV": {Name: "Bouvet Island", ISOAlpha3: "BVT", ISOAlpha2: "BV", Code: "074"}, + "BW": {Name: "Botswana", ISOAlpha3: "BWA", ISOAlpha2: "BW", Code: "072"}, + "BY": {Name: "Belarus", ISOAlpha3: "BLR", ISOAlpha2: "BY", Code: "112"}, + "BZ": {Name: "Belize", ISOAlpha3: "BLZ", ISOAlpha2: "BZ", Code: "084"}, + "CA": {Name: "Canada", ISOAlpha3: "CAN", ISOAlpha2: "CA", Code: "124"}, + "CC": {Name: "Cocos (Keeling) Islands", ISOAlpha3: "CCK", ISOAlpha2: "CC", Code: "166"}, + "CD": {Name: "Congo, Democratic Republic of the", ISOAlpha3: "COD", ISOAlpha2: "CD", Code: "180"}, + "CF": {Name: "Central African Republic", ISOAlpha3: "CAF", ISOAlpha2: "CF", Code: "140"}, + "CG": {Name: "Congo", ISOAlpha3: "COG", ISOAlpha2: "CG", Code: "178"}, + "CH": {Name: "Switzerland", ISOAlpha3: "CHE", ISOAlpha2: "CH", Code: "756"}, + "CI": {Name: "Côte d'Ivoire", ISOAlpha3: "CIV", ISOAlpha2: "CI", Code: "384"}, + "CK": {Name: "Cook Islands", ISOAlpha3: "COK", ISOAlpha2: "CK", Code: "184"}, + "CL": {Name: "Chile", ISOAlpha3: "CHL", ISOAlpha2: "CL", Code: "152"}, + "CM": {Name: "Cameroon", ISOAlpha3: "CMR", ISOAlpha2: "CM", Code: "120"}, + "CN": {Name: "China", ISOAlpha3: "CHN", ISOAlpha2: "CN", Code: "156"}, + "CO": {Name: "Colombia", ISOAlpha3: "COL", ISOAlpha2: "CO", Code: "170"}, + "CR": {Name: "Costa Rica", ISOAlpha3: "CRI", ISOAlpha2: "CR", Code: "188"}, + "CU": {Name: "Cuba", ISOAlpha3: "CUB", ISOAlpha2: "CU", Code: "192"}, + "CV": {Name: "Cabo Verde", ISOAlpha3: "CPV", ISOAlpha2: "CV", Code: "132"}, + "CW": {Name: "Curaçao", ISOAlpha3: "CUW", ISOAlpha2: "CW", Code: "531"}, + "CX": {Name: "Christmas Island", ISOAlpha3: "CXR", ISOAlpha2: "CX", Code: "162"}, + "CY": {Name: "Cyprus", ISOAlpha3: "CYP", ISOAlpha2: "CY", Code: "196"}, + "CZ": {Name: "Czechia", ISOAlpha3: "CZE", ISOAlpha2: "CZ", Code: "203"}, + "DE": {Name: "Germany", ISOAlpha3: "DEU", ISOAlpha2: "DE", Code: "276"}, + "DJ": {Name: "Djibouti", ISOAlpha3: "DJI", ISOAlpha2: "DJ", Code: "262"}, + "DK": {Name: "Denmark", ISOAlpha3: "DNK", ISOAlpha2: "DK", Code: "208"}, + "DM": {Name: "Dominica", ISOAlpha3: "DMA", ISOAlpha2: "DM", Code: "212"}, + "DO": {Name: "Dominican Republic", ISOAlpha3: "DOM", ISOAlpha2: "DO", Code: "214"}, + "DZ": {Name: "Algeria", ISOAlpha3: "DZA", ISOAlpha2: "DZ", Code: "012"}, + "EC": {Name: "Ecuador", ISOAlpha3: "ECU", ISOAlpha2: "EC", Code: "218"}, + "EE": {Name: "Estonia", ISOAlpha3: "EST", ISOAlpha2: "EE", Code: "233"}, + "EG": {Name: "Egypt", ISOAlpha3: "EGY", ISOAlpha2: "EG", Code: "818"}, + "EH": {Name: "Western Sahara", ISOAlpha3: "ESH", ISOAlpha2: "EH", Code: "732"}, + "ER": {Name: "Eritrea", ISOAlpha3: "ERI", ISOAlpha2: "ER", Code: "232"}, + "ES": {Name: "Spain", ISOAlpha3: "ESP", ISOAlpha2: "ES", Code: "724"}, + "ET": {Name: "Ethiopia", ISOAlpha3: "ETH", ISOAlpha2: "ET", Code: "231"}, + "FI": {Name: "Finland", ISOAlpha3: "FIN", ISOAlpha2: "FI", Code: "246"}, + "FJ": {Name: "Fiji", ISOAlpha3: "FJI", ISOAlpha2: "FJ", Code: "242"}, + "FK": {Name: "Falkland Islands (Malvinas)", ISOAlpha3: "FLK", ISOAlpha2: "FK", Code: "238"}, + "FM": {Name: "Micronesia (Federated States of)", ISOAlpha3: "FSM", ISOAlpha2: "FM", Code: "583"}, + "FO": {Name: "Faroe Islands", ISOAlpha3: "FRO", ISOAlpha2: "FO", Code: "234"}, + "FR": {Name: "France", ISOAlpha3: "FRA", ISOAlpha2: "FR", Code: "250"}, + "GA": {Name: "Gabon", ISOAlpha3: "GAB", ISOAlpha2: "GA", Code: "266"}, + "GB": {Name: "United Kingdom of Great Britain and Northern Ireland", ISOAlpha3: "GBR", ISOAlpha2: "GB", Code: "826"}, + "GD": {Name: "Grenada", ISOAlpha3: "GRD", ISOAlpha2: "GD", Code: "308"}, + "GE": {Name: "Georgia", ISOAlpha3: "GEO", ISOAlpha2: "GE", Code: "268"}, + "GF": {Name: "French Guiana", ISOAlpha3: "GUF", ISOAlpha2: "GF", Code: "254"}, + "GG": {Name: "Guernsey", ISOAlpha3: "GGY", ISOAlpha2: "GG", Code: "831"}, + "GH": {Name: "Ghana", ISOAlpha3: "GHA", ISOAlpha2: "GH", Code: "288"}, + "GI": {Name: "Gibraltar", ISOAlpha3: "GIB", ISOAlpha2: "GI", Code: "292"}, + "GL": {Name: "Greenland", ISOAlpha3: "GRL", ISOAlpha2: "GL", Code: "304"}, + "GM": {Name: "Gambia", ISOAlpha3: "GMB", ISOAlpha2: "GM", Code: "270"}, + "GN": {Name: "Guinea", ISOAlpha3: "GIN", ISOAlpha2: "GN", Code: "324"}, + "GP": {Name: "Guadeloupe", ISOAlpha3: "GLP", ISOAlpha2: "GP", Code: "312"}, + "GQ": {Name: "Equatorial Guinea", ISOAlpha3: "GNQ", ISOAlpha2: "GQ", Code: "226"}, + "GR": {Name: "Greece", ISOAlpha3: "GRC", ISOAlpha2: "GR", Code: "300"}, + "GS": {Name: "South Georgia and the South Sandwich Islands", ISOAlpha3: "SGS", ISOAlpha2: "GS", Code: "239"}, + "GT": {Name: "Guatemala", ISOAlpha3: "GTM", ISOAlpha2: "GT", Code: "320"}, + "GU": {Name: "Guam", ISOAlpha3: "GUM", ISOAlpha2: "GU", Code: "316"}, + "GW": {Name: "Guinea-Bissau", ISOAlpha3: "GNB", ISOAlpha2: "GW", Code: "624"}, + "GY": {Name: "Guyana", ISOAlpha3: "GUY", ISOAlpha2: "GY", Code: "328"}, + "HK": {Name: "Hong Kong", ISOAlpha3: "HKG", ISOAlpha2: "HK", Code: "344"}, + "HM": {Name: "Heard Island and McDonald Islands", ISOAlpha3: "HMD", ISOAlpha2: "HM", Code: "334"}, + "HN": {Name: "Honduras", ISOAlpha3: "HND", ISOAlpha2: "HN", Code: "340"}, + "HR": {Name: "Croatia", ISOAlpha3: "HRV", ISOAlpha2: "HR", Code: "191"}, + "HT": {Name: "Haiti", ISOAlpha3: "HTI", ISOAlpha2: "HT", Code: "332"}, + "HU": {Name: "Hungary", ISOAlpha3: "HUN", ISOAlpha2: "HU", Code: "348"}, + "ID": {Name: "Indonesia", ISOAlpha3: "IDN", ISOAlpha2: "ID", Code: "360"}, + "IE": {Name: "Ireland", ISOAlpha3: "IRL", ISOAlpha2: "IE", Code: "372"}, + "IL": {Name: "Israel", ISOAlpha3: "ISR", ISOAlpha2: "IL", Code: "376"}, + "IM": {Name: "Isle of Man", ISOAlpha3: "IMN", ISOAlpha2: "IM", Code: "833"}, + "IN": {Name: "India", ISOAlpha3: "IND", ISOAlpha2: "IN", Code: "356"}, + "IO": {Name: "British Indian Ocean Territory", ISOAlpha3: "IOT", ISOAlpha2: "IO", Code: "086"}, + "IQ": {Name: "Iraq", ISOAlpha3: "IRQ", ISOAlpha2: "IQ", Code: "368"}, + "IR": {Name: "Iran (Islamic Republic of)", ISOAlpha3: "IRN", ISOAlpha2: "IR", Code: "364"}, + "IS": {Name: "Iceland", ISOAlpha3: "ISL", ISOAlpha2: "IS", Code: "352"}, + "IT": {Name: "Italy", ISOAlpha3: "ITA", ISOAlpha2: "IT", Code: "380"}, + "JE": {Name: "Jersey", ISOAlpha3: "JEY", ISOAlpha2: "JE", Code: "832"}, + "JM": {Name: "Jamaica", ISOAlpha3: "JAM", ISOAlpha2: "JM", Code: "388"}, + "JO": {Name: "Jordan", ISOAlpha3: "JOR", ISOAlpha2: "JO", Code: "400"}, + "JP": {Name: "Japan", ISOAlpha3: "JPN", ISOAlpha2: "JP", Code: "392"}, + "KE": {Name: "Kenya", ISOAlpha3: "KEN", ISOAlpha2: "KE", Code: "404"}, + "KG": {Name: "Kyrgyzstan", ISOAlpha3: "KGZ", ISOAlpha2: "KG", Code: "417"}, + "KH": {Name: "Cambodia", ISOAlpha3: "KHM", ISOAlpha2: "KH", Code: "116"}, + "KI": {Name: "Kiribati", ISOAlpha3: "KIR", ISOAlpha2: "KI", Code: "296"}, + "KM": {Name: "Comoros", ISOAlpha3: "COM", ISOAlpha2: "KM", Code: "174"}, + "KN": {Name: "Saint Kitts and Nevis", ISOAlpha3: "KNA", ISOAlpha2: "KN", Code: "659"}, + "KP": {Name: "Korea (Democratic People's Republic of)", ISOAlpha3: "PRK", ISOAlpha2: "KP", Code: "408"}, + "KR": {Name: "Korea, Republic of", ISOAlpha3: "KOR", ISOAlpha2: "KR", Code: "410"}, + "KW": {Name: "Kuwait", ISOAlpha3: "KWT", ISOAlpha2: "KW", Code: "414"}, + "KY": {Name: "Cayman Islands", ISOAlpha3: "CYM", ISOAlpha2: "KY", Code: "136"}, + "KZ": {Name: "Kazakhstan", ISOAlpha3: "KAZ", ISOAlpha2: "KZ", Code: "398"}, + "LA": {Name: "Lao People's Democratic Republic", ISOAlpha3: "LAO", ISOAlpha2: "LA", Code: "418"}, + "LB": {Name: "Lebanon", ISOAlpha3: "LBN", ISOAlpha2: "LB", Code: "422"}, + "LC": {Name: "Saint Lucia", ISOAlpha3: "LCA", ISOAlpha2: "LC", Code: "662"}, + "LI": {Name: "Liechtenstein", ISOAlpha3: "LIE", ISOAlpha2: "LI", Code: "438"}, + "LK": {Name: "Sri Lanka", ISOAlpha3: "LKA", ISOAlpha2: "LK", Code: "144"}, + "LR": {Name: "Liberia", ISOAlpha3: "LBR", ISOAlpha2: "LR", Code: "430"}, + "LS": {Name: "Lesotho", ISOAlpha3: "LSO", ISOAlpha2: "LS", Code: "426"}, + "LT": {Name: "Lithuania", ISOAlpha3: "LTU", ISOAlpha2: "LT", Code: "440"}, + "LU": {Name: "Luxembourg", ISOAlpha3: "LUX", ISOAlpha2: "LU", Code: "442"}, + "LV": {Name: "Latvia", ISOAlpha3: "LVA", ISOAlpha2: "LV", Code: "428"}, + "LY": {Name: "Libya", ISOAlpha3: "LBY", ISOAlpha2: "LY", Code: "434"}, + "MA": {Name: "Morocco", ISOAlpha3: "MAR", ISOAlpha2: "MA", Code: "504"}, + "MC": {Name: "Monaco", ISOAlpha3: "MCO", ISOAlpha2: "MC", Code: "492"}, + "MD": {Name: "Moldova, Republic of", ISOAlpha3: "MDA", ISOAlpha2: "MD", Code: "498"}, + "ME": {Name: "Montenegro", ISOAlpha3: "MNE", ISOAlpha2: "ME", Code: "499"}, + "MF": {Name: "Saint Martin (French part)", ISOAlpha3: "MAF", ISOAlpha2: "MF", Code: "663"}, + "MG": {Name: "Madagascar", ISOAlpha3: "MDG", ISOAlpha2: "MG", Code: "450"}, + "MH": {Name: "Marshall Islands", ISOAlpha3: "MHL", ISOAlpha2: "MH", Code: "584"}, + "MK": {Name: "North Macedonia", ISOAlpha3: "MKD", ISOAlpha2: "MK", Code: "807"}, + "ML": {Name: "Mali", ISOAlpha3: "MLI", ISOAlpha2: "ML", Code: "466"}, + "MM": {Name: "Myanmar", ISOAlpha3: "MMR", ISOAlpha2: "MM", Code: "104"}, + "MN": {Name: "Mongolia", ISOAlpha3: "MNG", ISOAlpha2: "MN", Code: "496"}, + "MO": {Name: "Macao", ISOAlpha3: "MAC", ISOAlpha2: "MO", Code: "446"}, + "MP": {Name: "Northern Mariana Islands", ISOAlpha3: "MNP", ISOAlpha2: "MP", Code: "580"}, + "MQ": {Name: "Martinique", ISOAlpha3: "MTQ", ISOAlpha2: "MQ", Code: "474"}, + "MR": {Name: "Mauritania", ISOAlpha3: "MRT", ISOAlpha2: "MR", Code: "478"}, + "MS": {Name: "Montserrat", ISOAlpha3: "MSR", ISOAlpha2: "MS", Code: "500"}, + "MT": {Name: "Malta", ISOAlpha3: "MLT", ISOAlpha2: "MT", Code: "470"}, + "MU": {Name: "Mauritius", ISOAlpha3: "MUS", ISOAlpha2: "MU", Code: "480"}, + "MV": {Name: "Maldives", ISOAlpha3: "MDV", ISOAlpha2: "MV", Code: "462"}, + "MW": {Name: "Malawi", ISOAlpha3: "MWI", ISOAlpha2: "MW", Code: "454"}, + "MX": {Name: "Mexico", ISOAlpha3: "MEX", ISOAlpha2: "MX", Code: "484"}, + "MY": {Name: "Malaysia", ISOAlpha3: "MYS", ISOAlpha2: "MY", Code: "458"}, + "MZ": {Name: "Mozambique", ISOAlpha3: "MOZ", ISOAlpha2: "MZ", Code: "508"}, + "NA": {Name: "Namibia", ISOAlpha3: "NAM", ISOAlpha2: "NA", Code: "516"}, + "NC": {Name: "New Caledonia", ISOAlpha3: "NCL", ISOAlpha2: "NC", Code: "540"}, + "NE": {Name: "Niger", ISOAlpha3: "NER", ISOAlpha2: "NE", Code: "562"}, + "NF": {Name: "Norfolk Island", ISOAlpha3: "NFK", ISOAlpha2: "NF", Code: "574"}, + "NG": {Name: "Nigeria", ISOAlpha3: "NGA", ISOAlpha2: "NG", Code: "566"}, + "NI": {Name: "Nicaragua", ISOAlpha3: "NIC", ISOAlpha2: "NI", Code: "558"}, + "NL": {Name: "Netherlands", ISOAlpha3: "NLD", ISOAlpha2: "NL", Code: "528"}, + "NO": {Name: "Norway", ISOAlpha3: "NOR", ISOAlpha2: "NO", Code: "578"}, + "NP": {Name: "Nepal", ISOAlpha3: "NPL", ISOAlpha2: "NP", Code: "524"}, + "NR": {Name: "Nauru", ISOAlpha3: "NRU", ISOAlpha2: "NR", Code: "520"}, + "NU": {Name: "Niue", ISOAlpha3: "NIU", ISOAlpha2: "NU", Code: "570"}, + "NZ": {Name: "New Zealand", ISOAlpha3: "NZL", ISOAlpha2: "NZ", Code: "554"}, + "OM": {Name: "Oman", ISOAlpha3: "OMN", ISOAlpha2: "OM", Code: "512"}, + "PA": {Name: "Panama", ISOAlpha3: "PAN", ISOAlpha2: "PA", Code: "591"}, + "PE": {Name: "Peru", ISOAlpha3: "PER", ISOAlpha2: "PE", Code: "604"}, + "PF": {Name: "French Polynesia", ISOAlpha3: "PYF", ISOAlpha2: "PF", Code: "258"}, + "PG": {Name: "Papua New Guinea", ISOAlpha3: "PNG", ISOAlpha2: "PG", Code: "598"}, + "PH": {Name: "Philippines", ISOAlpha3: "PHL", ISOAlpha2: "PH", Code: "608"}, + "PK": {Name: "Pakistan", ISOAlpha3: "PAK", ISOAlpha2: "PK", Code: "586"}, + "PL": {Name: "Poland", ISOAlpha3: "POL", ISOAlpha2: "PL", Code: "616"}, + "PM": {Name: "Saint Pierre and Miquelon", ISOAlpha3: "SPM", ISOAlpha2: "PM", Code: "666"}, + "PN": {Name: "Pitcairn", ISOAlpha3: "PCN", ISOAlpha2: "PN", Code: "612"}, + "PR": {Name: "Puerto Rico", ISOAlpha3: "PRI", ISOAlpha2: "PR", Code: "630"}, + "PS": {Name: "Palestine, State of", ISOAlpha3: "PSE", ISOAlpha2: "PS", Code: "275"}, + "PT": {Name: "Portugal", ISOAlpha3: "PRT", ISOAlpha2: "PT", Code: "620"}, + "PW": {Name: "Palau", ISOAlpha3: "PLW", ISOAlpha2: "PW", Code: "585"}, + "PY": {Name: "Paraguay", ISOAlpha3: "PRY", ISOAlpha2: "PY", Code: "600"}, + "QA": {Name: "Qatar", ISOAlpha3: "QAT", ISOAlpha2: "QA", Code: "634"}, + "RE": {Name: "Réunion", ISOAlpha3: "REU", ISOAlpha2: "RE", Code: "638"}, + "RO": {Name: "Romania", ISOAlpha3: "ROU", ISOAlpha2: "RO", Code: "642"}, + "RS": {Name: "Serbia", ISOAlpha3: "SRB", ISOAlpha2: "RS", Code: "688"}, + "RU": {Name: "Russian Federation", ISOAlpha3: "RUS", ISOAlpha2: "RU", Code: "643"}, + "RW": {Name: "Rwanda", ISOAlpha3: "RWA", ISOAlpha2: "RW", Code: "646"}, + "SA": {Name: "Saudi Arabia", ISOAlpha3: "SAU", ISOAlpha2: "SA", Code: "682"}, + "SB": {Name: "Solomon Islands", ISOAlpha3: "SLB", ISOAlpha2: "SB", Code: "090"}, + "SC": {Name: "Seychelles", ISOAlpha3: "SYC", ISOAlpha2: "SC", Code: "690"}, + "SD": {Name: "Sudan", ISOAlpha3: "SDN", ISOAlpha2: "SD", Code: "729"}, + "SE": {Name: "Sweden", ISOAlpha3: "SWE", ISOAlpha2: "SE", Code: "752"}, + "SG": {Name: "Singapore", ISOAlpha3: "SGP", ISOAlpha2: "SG", Code: "702"}, + "SH": {Name: "Saint Helena, Ascension and Tristan da Cunha", ISOAlpha3: "SHN", ISOAlpha2: "SH", Code: "654"}, + "SI": {Name: "Slovenia", ISOAlpha3: "SVN", ISOAlpha2: "SI", Code: "705"}, + "SJ": {Name: "Svalbard and Jan Mayen", ISOAlpha3: "SJM", ISOAlpha2: "SJ", Code: "744"}, + "SK": {Name: "Slovakia", ISOAlpha3: "SVK", ISOAlpha2: "SK", Code: "703"}, + "SL": {Name: "Sierra Leone", ISOAlpha3: "SLE", ISOAlpha2: "SL", Code: "694"}, + "SM": {Name: "San Marino", ISOAlpha3: "SMR", ISOAlpha2: "SM", Code: "674"}, + "SN": {Name: "Senegal", ISOAlpha3: "SEN", ISOAlpha2: "SN", Code: "686"}, + "SO": {Name: "Somalia", ISOAlpha3: "SOM", ISOAlpha2: "SO", Code: "706"}, + "SR": {Name: "Suriname", ISOAlpha3: "SUR", ISOAlpha2: "SR", Code: "740"}, + "SS": {Name: "South Sudan", ISOAlpha3: "SSD", ISOAlpha2: "SS", Code: "728"}, + "ST": {Name: "Sao Tome and Principe", ISOAlpha3: "STP", ISOAlpha2: "ST", Code: "678"}, + "SV": {Name: "El Salvador", ISOAlpha3: "SLV", ISOAlpha2: "SV", Code: "222"}, + "SX": {Name: "Sint Maarten (Dutch part)", ISOAlpha3: "SXM", ISOAlpha2: "SX", Code: "534"}, + "SY": {Name: "Syrian Arab Republic", ISOAlpha3: "SYR", ISOAlpha2: "SY", Code: "760"}, + "SZ": {Name: "Eswatini", ISOAlpha3: "SWZ", ISOAlpha2: "SZ", Code: "748"}, + "TC": {Name: "Turks and Caicos Islands", ISOAlpha3: "TCA", ISOAlpha2: "TC", Code: "796"}, + "TD": {Name: "Chad", ISOAlpha3: "TCD", ISOAlpha2: "TD", Code: "148"}, + "TF": {Name: "French Southern Territories", ISOAlpha3: "ATF", ISOAlpha2: "TF", Code: "260"}, + "TG": {Name: "Togo", ISOAlpha3: "TGO", ISOAlpha2: "TG", Code: "768"}, + "TH": {Name: "Thailand", ISOAlpha3: "THA", ISOAlpha2: "TH", Code: "764"}, + "TJ": {Name: "Tajikistan", ISOAlpha3: "TJK", ISOAlpha2: "TJ", Code: "762"}, + "TK": {Name: "Tokelau", ISOAlpha3: "TKL", ISOAlpha2: "TK", Code: "772"}, + "TL": {Name: "Timor-Leste", ISOAlpha3: "TLS", ISOAlpha2: "TL", Code: "626"}, + "TM": {Name: "Turkmenistan", ISOAlpha3: "TKM", ISOAlpha2: "TM", Code: "795"}, + "TN": {Name: "Tunisia", ISOAlpha3: "TUN", ISOAlpha2: "TN", Code: "788"}, + "TO": {Name: "Tonga", ISOAlpha3: "TON", ISOAlpha2: "TO", Code: "776"}, + "TR": {Name: "Turkey", ISOAlpha3: "TUR", ISOAlpha2: "TR", Code: "792"}, + "TT": {Name: "Trinidad and Tobago", ISOAlpha3: "TTO", ISOAlpha2: "TT", Code: "780"}, + "TV": {Name: "Tuvalu", ISOAlpha3: "TUV", ISOAlpha2: "TV", Code: "798"}, + "TW": {Name: "Taiwan, Province of China", ISOAlpha3: "TWN", ISOAlpha2: "TW", Code: "158"}, + "TZ": {Name: "Tanzania, United Republic of", ISOAlpha3: "TZA", ISOAlpha2: "TZ", Code: "834"}, + "UA": {Name: "Ukraine", ISOAlpha3: "UKR", ISOAlpha2: "UA", Code: "804"}, + "UG": {Name: "Uganda", ISOAlpha3: "UGA", ISOAlpha2: "UG", Code: "800"}, + "UM": {Name: "United States Minor Outlying Islands", ISOAlpha3: "UMI", ISOAlpha2: "UM", Code: "581"}, + "US": {Name: "United States of America", ISOAlpha3: "USA", ISOAlpha2: "US", Code: "840"}, + "UY": {Name: "Uruguay", ISOAlpha3: "URY", ISOAlpha2: "UY", Code: "858"}, + "UZ": {Name: "Uzbekistan", ISOAlpha3: "UZB", ISOAlpha2: "UZ", Code: "860"}, + "VA": {Name: "Holy See", ISOAlpha3: "VAT", ISOAlpha2: "VA", Code: "336"}, + "VC": {Name: "Saint Vincent and the Grenadines", ISOAlpha3: "VCT", ISOAlpha2: "VC", Code: "670"}, + "VE": {Name: "Venezuela (Bolivarian Republic of)", ISOAlpha3: "VEN", ISOAlpha2: "VE", Code: "862"}, + "VG": {Name: "Virgin Islands (British)", ISOAlpha3: "VGB", ISOAlpha2: "VG", Code: "092"}, + "VI": {Name: "Virgin Islands (U.S.)", ISOAlpha3: "VIR", ISOAlpha2: "VI", Code: "850"}, + "VN": {Name: "Viet Nam", ISOAlpha3: "VNM", ISOAlpha2: "VN", Code: "704"}, + "VU": {Name: "Vanuatu", ISOAlpha3: "VUT", ISOAlpha2: "VU", Code: "548"}, + "WF": {Name: "Wallis and Futuna", ISOAlpha3: "WLF", ISOAlpha2: "WF", Code: "876"}, + "WS": {Name: "Samoa", ISOAlpha3: "WSM", ISOAlpha2: "WS", Code: "882"}, + "YE": {Name: "Yemen", ISOAlpha3: "YEM", ISOAlpha2: "YE", Code: "887"}, + "YT": {Name: "Mayotte", ISOAlpha3: "MYT", ISOAlpha2: "YT", Code: "175"}, + "ZA": {Name: "South Africa", ISOAlpha3: "ZAF", ISOAlpha2: "ZA", Code: "710"}, + "ZM": {Name: "Zambia", ISOAlpha3: "ZMB", ISOAlpha2: "ZM", Code: "894"}, + "ZW": {Name: "Zimbabwe", ISOAlpha3: "ZWE", ISOAlpha2: "ZW", Code: "716"}, +} diff --git a/vendor/github.com/go-openapi/strfmt/internal/countries/country.go b/vendor/github.com/go-openapi/strfmt/internal/countries/country.go new file mode 100644 index 00000000000..774051430eb --- /dev/null +++ b/vendor/github.com/go-openapi/strfmt/internal/countries/country.go @@ -0,0 +1,15 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + +//go:generate go run gen.go -- countries.go +package countries + +// Country identifies a country with its english name, and ISO3166 codes. +// +//nolint:tagliatelle // JSON tags mirror the iso3166.json source keys (alpha-3, alpha-2, country-code); renaming them breaks the embedded-JSON unmarshal. +type Country struct { + Name string `json:"name"` + ISOAlpha3 string `json:"alpha-3"` + ISOAlpha2 string `json:"alpha-2"` + Code string `json:"country-code"` +} diff --git a/vendor/github.com/go-openapi/strfmt/internal/countries/iso3166.json b/vendor/github.com/go-openapi/strfmt/internal/countries/iso3166.json new file mode 100644 index 00000000000..b2c0b5c5017 --- /dev/null +++ b/vendor/github.com/go-openapi/strfmt/internal/countries/iso3166.json @@ -0,0 +1,251 @@ +[ +{"name":"Afghanistan","alpha-2":"AF","alpha-3":"AFG","country-code":"004","iso_3166-2":"ISO 3166-2:AF","region":"Asia","sub-region":"Southern Asia","intermediate-region":"","region-code":"142","sub-region-code":"034","intermediate-region-code":""}, +{"name":"Åland Islands","alpha-2":"AX","alpha-3":"ALA","country-code":"248","iso_3166-2":"ISO 3166-2:AX","region":"Europe","sub-region":"Northern Europe","intermediate-region":"","region-code":"150","sub-region-code":"154","intermediate-region-code":""}, +{"name":"Albania","alpha-2":"AL","alpha-3":"ALB","country-code":"008","iso_3166-2":"ISO 3166-2:AL","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""}, +{"name":"Algeria","alpha-2":"DZ","alpha-3":"DZA","country-code":"012","iso_3166-2":"ISO 3166-2:DZ","region":"Africa","sub-region":"Northern Africa","intermediate-region":"","region-code":"002","sub-region-code":"015","intermediate-region-code":""}, +{"name":"American Samoa","alpha-2":"AS","alpha-3":"ASM","country-code":"016","iso_3166-2":"ISO 3166-2:AS","region":"Oceania","sub-region":"Polynesia","intermediate-region":"","region-code":"009","sub-region-code":"061","intermediate-region-code":""}, +{"name":"Andorra","alpha-2":"AD","alpha-3":"AND","country-code":"020","iso_3166-2":"ISO 3166-2:AD","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""}, +{"name":"Angola","alpha-2":"AO","alpha-3":"AGO","country-code":"024","iso_3166-2":"ISO 3166-2:AO","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Middle Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"017"}, +{"name":"Anguilla","alpha-2":"AI","alpha-3":"AIA","country-code":"660","iso_3166-2":"ISO 3166-2:AI","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Antarctica","alpha-2":"AQ","alpha-3":"ATA","country-code":"010","iso_3166-2":"ISO 3166-2:AQ","region":"","sub-region":"","intermediate-region":"","region-code":"","sub-region-code":"","intermediate-region-code":""}, +{"name":"Antigua and Barbuda","alpha-2":"AG","alpha-3":"ATG","country-code":"028","iso_3166-2":"ISO 3166-2:AG","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Argentina","alpha-2":"AR","alpha-3":"ARG","country-code":"032","iso_3166-2":"ISO 3166-2:AR","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"South America","region-code":"019","sub-region-code":"419","intermediate-region-code":"005"}, +{"name":"Armenia","alpha-2":"AM","alpha-3":"ARM","country-code":"051","iso_3166-2":"ISO 3166-2:AM","region":"Asia","sub-region":"Western Asia","intermediate-region":"","region-code":"142","sub-region-code":"145","intermediate-region-code":""}, +{"name":"Aruba","alpha-2":"AW","alpha-3":"ABW","country-code":"533","iso_3166-2":"ISO 3166-2:AW","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Australia","alpha-2":"AU","alpha-3":"AUS","country-code":"036","iso_3166-2":"ISO 3166-2:AU","region":"Oceania","sub-region":"Australia and New Zealand","intermediate-region":"","region-code":"009","sub-region-code":"053","intermediate-region-code":""}, +{"name":"Austria","alpha-2":"AT","alpha-3":"AUT","country-code":"040","iso_3166-2":"ISO 3166-2:AT","region":"Europe","sub-region":"Western Europe","intermediate-region":"","region-code":"150","sub-region-code":"155","intermediate-region-code":""}, +{"name":"Azerbaijan","alpha-2":"AZ","alpha-3":"AZE","country-code":"031","iso_3166-2":"ISO 3166-2:AZ","region":"Asia","sub-region":"Western Asia","intermediate-region":"","region-code":"142","sub-region-code":"145","intermediate-region-code":""}, +{"name":"Bahamas","alpha-2":"BS","alpha-3":"BHS","country-code":"044","iso_3166-2":"ISO 3166-2:BS","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Bahrain","alpha-2":"BH","alpha-3":"BHR","country-code":"048","iso_3166-2":"ISO 3166-2:BH","region":"Asia","sub-region":"Western Asia","intermediate-region":"","region-code":"142","sub-region-code":"145","intermediate-region-code":""}, +{"name":"Bangladesh","alpha-2":"BD","alpha-3":"BGD","country-code":"050","iso_3166-2":"ISO 3166-2:BD","region":"Asia","sub-region":"Southern Asia","intermediate-region":"","region-code":"142","sub-region-code":"034","intermediate-region-code":""}, +{"name":"Barbados","alpha-2":"BB","alpha-3":"BRB","country-code":"052","iso_3166-2":"ISO 3166-2:BB","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Belarus","alpha-2":"BY","alpha-3":"BLR","country-code":"112","iso_3166-2":"ISO 3166-2:BY","region":"Europe","sub-region":"Eastern Europe","intermediate-region":"","region-code":"150","sub-region-code":"151","intermediate-region-code":""}, +{"name":"Belgium","alpha-2":"BE","alpha-3":"BEL","country-code":"056","iso_3166-2":"ISO 3166-2:BE","region":"Europe","sub-region":"Western Europe","intermediate-region":"","region-code":"150","sub-region-code":"155","intermediate-region-code":""}, +{"name":"Belize","alpha-2":"BZ","alpha-3":"BLZ","country-code":"084","iso_3166-2":"ISO 3166-2:BZ","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Central America","region-code":"019","sub-region-code":"419","intermediate-region-code":"013"}, +{"name":"Benin","alpha-2":"BJ","alpha-3":"BEN","country-code":"204","iso_3166-2":"ISO 3166-2:BJ","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Western Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"011"}, +{"name":"Bermuda","alpha-2":"BM","alpha-3":"BMU","country-code":"060","iso_3166-2":"ISO 3166-2:BM","region":"Americas","sub-region":"Northern America","intermediate-region":"","region-code":"019","sub-region-code":"021","intermediate-region-code":""}, +{"name":"Bhutan","alpha-2":"BT","alpha-3":"BTN","country-code":"064","iso_3166-2":"ISO 3166-2:BT","region":"Asia","sub-region":"Southern Asia","intermediate-region":"","region-code":"142","sub-region-code":"034","intermediate-region-code":""}, +{"name":"Bolivia (Plurinational State of)","alpha-2":"BO","alpha-3":"BOL","country-code":"068","iso_3166-2":"ISO 3166-2:BO","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"South America","region-code":"019","sub-region-code":"419","intermediate-region-code":"005"}, +{"name":"Bonaire, Sint Eustatius and Saba","alpha-2":"BQ","alpha-3":"BES","country-code":"535","iso_3166-2":"ISO 3166-2:BQ","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Bosnia and Herzegovina","alpha-2":"BA","alpha-3":"BIH","country-code":"070","iso_3166-2":"ISO 3166-2:BA","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""}, +{"name":"Botswana","alpha-2":"BW","alpha-3":"BWA","country-code":"072","iso_3166-2":"ISO 3166-2:BW","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Southern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"018"}, +{"name":"Bouvet Island","alpha-2":"BV","alpha-3":"BVT","country-code":"074","iso_3166-2":"ISO 3166-2:BV","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"South America","region-code":"019","sub-region-code":"419","intermediate-region-code":"005"}, +{"name":"Brazil","alpha-2":"BR","alpha-3":"BRA","country-code":"076","iso_3166-2":"ISO 3166-2:BR","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"South America","region-code":"019","sub-region-code":"419","intermediate-region-code":"005"}, +{"name":"British Indian Ocean Territory","alpha-2":"IO","alpha-3":"IOT","country-code":"086","iso_3166-2":"ISO 3166-2:IO","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Brunei Darussalam","alpha-2":"BN","alpha-3":"BRN","country-code":"096","iso_3166-2":"ISO 3166-2:BN","region":"Asia","sub-region":"South-eastern Asia","intermediate-region":"","region-code":"142","sub-region-code":"035","intermediate-region-code":""}, +{"name":"Bulgaria","alpha-2":"BG","alpha-3":"BGR","country-code":"100","iso_3166-2":"ISO 3166-2:BG","region":"Europe","sub-region":"Eastern Europe","intermediate-region":"","region-code":"150","sub-region-code":"151","intermediate-region-code":""}, +{"name":"Burkina Faso","alpha-2":"BF","alpha-3":"BFA","country-code":"854","iso_3166-2":"ISO 3166-2:BF","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Western Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"011"}, +{"name":"Burundi","alpha-2":"BI","alpha-3":"BDI","country-code":"108","iso_3166-2":"ISO 3166-2:BI","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Cabo Verde","alpha-2":"CV","alpha-3":"CPV","country-code":"132","iso_3166-2":"ISO 3166-2:CV","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Western Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"011"}, +{"name":"Cambodia","alpha-2":"KH","alpha-3":"KHM","country-code":"116","iso_3166-2":"ISO 3166-2:KH","region":"Asia","sub-region":"South-eastern Asia","intermediate-region":"","region-code":"142","sub-region-code":"035","intermediate-region-code":""}, +{"name":"Cameroon","alpha-2":"CM","alpha-3":"CMR","country-code":"120","iso_3166-2":"ISO 3166-2:CM","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Middle Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"017"}, +{"name":"Canada","alpha-2":"CA","alpha-3":"CAN","country-code":"124","iso_3166-2":"ISO 3166-2:CA","region":"Americas","sub-region":"Northern America","intermediate-region":"","region-code":"019","sub-region-code":"021","intermediate-region-code":""}, +{"name":"Cayman Islands","alpha-2":"KY","alpha-3":"CYM","country-code":"136","iso_3166-2":"ISO 3166-2:KY","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Central African Republic","alpha-2":"CF","alpha-3":"CAF","country-code":"140","iso_3166-2":"ISO 3166-2:CF","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Middle Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"017"}, +{"name":"Chad","alpha-2":"TD","alpha-3":"TCD","country-code":"148","iso_3166-2":"ISO 3166-2:TD","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Middle Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"017"}, +{"name":"Chile","alpha-2":"CL","alpha-3":"CHL","country-code":"152","iso_3166-2":"ISO 3166-2:CL","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"South America","region-code":"019","sub-region-code":"419","intermediate-region-code":"005"}, +{"name":"China","alpha-2":"CN","alpha-3":"CHN","country-code":"156","iso_3166-2":"ISO 3166-2:CN","region":"Asia","sub-region":"Eastern Asia","intermediate-region":"","region-code":"142","sub-region-code":"030","intermediate-region-code":""}, +{"name":"Christmas Island","alpha-2":"CX","alpha-3":"CXR","country-code":"162","iso_3166-2":"ISO 3166-2:CX","region":"Oceania","sub-region":"Australia and New Zealand","intermediate-region":"","region-code":"009","sub-region-code":"053","intermediate-region-code":""}, +{"name":"Cocos (Keeling) Islands","alpha-2":"CC","alpha-3":"CCK","country-code":"166","iso_3166-2":"ISO 3166-2:CC","region":"Oceania","sub-region":"Australia and New Zealand","intermediate-region":"","region-code":"009","sub-region-code":"053","intermediate-region-code":""}, +{"name":"Colombia","alpha-2":"CO","alpha-3":"COL","country-code":"170","iso_3166-2":"ISO 3166-2:CO","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"South America","region-code":"019","sub-region-code":"419","intermediate-region-code":"005"}, +{"name":"Comoros","alpha-2":"KM","alpha-3":"COM","country-code":"174","iso_3166-2":"ISO 3166-2:KM","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Congo","alpha-2":"CG","alpha-3":"COG","country-code":"178","iso_3166-2":"ISO 3166-2:CG","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Middle Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"017"}, +{"name":"Congo, Democratic Republic of the","alpha-2":"CD","alpha-3":"COD","country-code":"180","iso_3166-2":"ISO 3166-2:CD","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Middle Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"017"}, +{"name":"Cook Islands","alpha-2":"CK","alpha-3":"COK","country-code":"184","iso_3166-2":"ISO 3166-2:CK","region":"Oceania","sub-region":"Polynesia","intermediate-region":"","region-code":"009","sub-region-code":"061","intermediate-region-code":""}, +{"name":"Costa Rica","alpha-2":"CR","alpha-3":"CRI","country-code":"188","iso_3166-2":"ISO 3166-2:CR","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Central America","region-code":"019","sub-region-code":"419","intermediate-region-code":"013"}, +{"name":"Côte d'Ivoire","alpha-2":"CI","alpha-3":"CIV","country-code":"384","iso_3166-2":"ISO 3166-2:CI","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Western Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"011"}, +{"name":"Croatia","alpha-2":"HR","alpha-3":"HRV","country-code":"191","iso_3166-2":"ISO 3166-2:HR","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""}, +{"name":"Cuba","alpha-2":"CU","alpha-3":"CUB","country-code":"192","iso_3166-2":"ISO 3166-2:CU","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Curaçao","alpha-2":"CW","alpha-3":"CUW","country-code":"531","iso_3166-2":"ISO 3166-2:CW","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Cyprus","alpha-2":"CY","alpha-3":"CYP","country-code":"196","iso_3166-2":"ISO 3166-2:CY","region":"Asia","sub-region":"Western Asia","intermediate-region":"","region-code":"142","sub-region-code":"145","intermediate-region-code":""}, +{"name":"Czechia","alpha-2":"CZ","alpha-3":"CZE","country-code":"203","iso_3166-2":"ISO 3166-2:CZ","region":"Europe","sub-region":"Eastern Europe","intermediate-region":"","region-code":"150","sub-region-code":"151","intermediate-region-code":""}, +{"name":"Denmark","alpha-2":"DK","alpha-3":"DNK","country-code":"208","iso_3166-2":"ISO 3166-2:DK","region":"Europe","sub-region":"Northern Europe","intermediate-region":"","region-code":"150","sub-region-code":"154","intermediate-region-code":""}, +{"name":"Djibouti","alpha-2":"DJ","alpha-3":"DJI","country-code":"262","iso_3166-2":"ISO 3166-2:DJ","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Dominica","alpha-2":"DM","alpha-3":"DMA","country-code":"212","iso_3166-2":"ISO 3166-2:DM","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Dominican Republic","alpha-2":"DO","alpha-3":"DOM","country-code":"214","iso_3166-2":"ISO 3166-2:DO","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Ecuador","alpha-2":"EC","alpha-3":"ECU","country-code":"218","iso_3166-2":"ISO 3166-2:EC","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"South America","region-code":"019","sub-region-code":"419","intermediate-region-code":"005"}, +{"name":"Egypt","alpha-2":"EG","alpha-3":"EGY","country-code":"818","iso_3166-2":"ISO 3166-2:EG","region":"Africa","sub-region":"Northern Africa","intermediate-region":"","region-code":"002","sub-region-code":"015","intermediate-region-code":""}, +{"name":"El Salvador","alpha-2":"SV","alpha-3":"SLV","country-code":"222","iso_3166-2":"ISO 3166-2:SV","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Central America","region-code":"019","sub-region-code":"419","intermediate-region-code":"013"}, +{"name":"Equatorial Guinea","alpha-2":"GQ","alpha-3":"GNQ","country-code":"226","iso_3166-2":"ISO 3166-2:GQ","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Middle Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"017"}, +{"name":"Eritrea","alpha-2":"ER","alpha-3":"ERI","country-code":"232","iso_3166-2":"ISO 3166-2:ER","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Estonia","alpha-2":"EE","alpha-3":"EST","country-code":"233","iso_3166-2":"ISO 3166-2:EE","region":"Europe","sub-region":"Northern Europe","intermediate-region":"","region-code":"150","sub-region-code":"154","intermediate-region-code":""}, +{"name":"Eswatini","alpha-2":"SZ","alpha-3":"SWZ","country-code":"748","iso_3166-2":"ISO 3166-2:SZ","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Southern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"018"}, +{"name":"Ethiopia","alpha-2":"ET","alpha-3":"ETH","country-code":"231","iso_3166-2":"ISO 3166-2:ET","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Falkland Islands (Malvinas)","alpha-2":"FK","alpha-3":"FLK","country-code":"238","iso_3166-2":"ISO 3166-2:FK","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"South America","region-code":"019","sub-region-code":"419","intermediate-region-code":"005"}, +{"name":"Faroe Islands","alpha-2":"FO","alpha-3":"FRO","country-code":"234","iso_3166-2":"ISO 3166-2:FO","region":"Europe","sub-region":"Northern Europe","intermediate-region":"","region-code":"150","sub-region-code":"154","intermediate-region-code":""}, +{"name":"Fiji","alpha-2":"FJ","alpha-3":"FJI","country-code":"242","iso_3166-2":"ISO 3166-2:FJ","region":"Oceania","sub-region":"Melanesia","intermediate-region":"","region-code":"009","sub-region-code":"054","intermediate-region-code":""}, +{"name":"Finland","alpha-2":"FI","alpha-3":"FIN","country-code":"246","iso_3166-2":"ISO 3166-2:FI","region":"Europe","sub-region":"Northern Europe","intermediate-region":"","region-code":"150","sub-region-code":"154","intermediate-region-code":""}, +{"name":"France","alpha-2":"FR","alpha-3":"FRA","country-code":"250","iso_3166-2":"ISO 3166-2:FR","region":"Europe","sub-region":"Western Europe","intermediate-region":"","region-code":"150","sub-region-code":"155","intermediate-region-code":""}, +{"name":"French Guiana","alpha-2":"GF","alpha-3":"GUF","country-code":"254","iso_3166-2":"ISO 3166-2:GF","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"South America","region-code":"019","sub-region-code":"419","intermediate-region-code":"005"}, +{"name":"French Polynesia","alpha-2":"PF","alpha-3":"PYF","country-code":"258","iso_3166-2":"ISO 3166-2:PF","region":"Oceania","sub-region":"Polynesia","intermediate-region":"","region-code":"009","sub-region-code":"061","intermediate-region-code":""}, +{"name":"French Southern Territories","alpha-2":"TF","alpha-3":"ATF","country-code":"260","iso_3166-2":"ISO 3166-2:TF","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Gabon","alpha-2":"GA","alpha-3":"GAB","country-code":"266","iso_3166-2":"ISO 3166-2:GA","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Middle Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"017"}, +{"name":"Gambia","alpha-2":"GM","alpha-3":"GMB","country-code":"270","iso_3166-2":"ISO 3166-2:GM","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Western Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"011"}, +{"name":"Georgia","alpha-2":"GE","alpha-3":"GEO","country-code":"268","iso_3166-2":"ISO 3166-2:GE","region":"Asia","sub-region":"Western Asia","intermediate-region":"","region-code":"142","sub-region-code":"145","intermediate-region-code":""}, +{"name":"Germany","alpha-2":"DE","alpha-3":"DEU","country-code":"276","iso_3166-2":"ISO 3166-2:DE","region":"Europe","sub-region":"Western Europe","intermediate-region":"","region-code":"150","sub-region-code":"155","intermediate-region-code":""}, +{"name":"Ghana","alpha-2":"GH","alpha-3":"GHA","country-code":"288","iso_3166-2":"ISO 3166-2:GH","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Western Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"011"}, +{"name":"Gibraltar","alpha-2":"GI","alpha-3":"GIB","country-code":"292","iso_3166-2":"ISO 3166-2:GI","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""}, +{"name":"Greece","alpha-2":"GR","alpha-3":"GRC","country-code":"300","iso_3166-2":"ISO 3166-2:GR","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""}, +{"name":"Greenland","alpha-2":"GL","alpha-3":"GRL","country-code":"304","iso_3166-2":"ISO 3166-2:GL","region":"Americas","sub-region":"Northern America","intermediate-region":"","region-code":"019","sub-region-code":"021","intermediate-region-code":""}, +{"name":"Grenada","alpha-2":"GD","alpha-3":"GRD","country-code":"308","iso_3166-2":"ISO 3166-2:GD","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Guadeloupe","alpha-2":"GP","alpha-3":"GLP","country-code":"312","iso_3166-2":"ISO 3166-2:GP","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Guam","alpha-2":"GU","alpha-3":"GUM","country-code":"316","iso_3166-2":"ISO 3166-2:GU","region":"Oceania","sub-region":"Micronesia","intermediate-region":"","region-code":"009","sub-region-code":"057","intermediate-region-code":""}, +{"name":"Guatemala","alpha-2":"GT","alpha-3":"GTM","country-code":"320","iso_3166-2":"ISO 3166-2:GT","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Central America","region-code":"019","sub-region-code":"419","intermediate-region-code":"013"}, +{"name":"Guernsey","alpha-2":"GG","alpha-3":"GGY","country-code":"831","iso_3166-2":"ISO 3166-2:GG","region":"Europe","sub-region":"Northern Europe","intermediate-region":"Channel Islands","region-code":"150","sub-region-code":"154","intermediate-region-code":"830"}, +{"name":"Guinea","alpha-2":"GN","alpha-3":"GIN","country-code":"324","iso_3166-2":"ISO 3166-2:GN","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Western Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"011"}, +{"name":"Guinea-Bissau","alpha-2":"GW","alpha-3":"GNB","country-code":"624","iso_3166-2":"ISO 3166-2:GW","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Western Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"011"}, +{"name":"Guyana","alpha-2":"GY","alpha-3":"GUY","country-code":"328","iso_3166-2":"ISO 3166-2:GY","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"South America","region-code":"019","sub-region-code":"419","intermediate-region-code":"005"}, +{"name":"Haiti","alpha-2":"HT","alpha-3":"HTI","country-code":"332","iso_3166-2":"ISO 3166-2:HT","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Heard Island and McDonald Islands","alpha-2":"HM","alpha-3":"HMD","country-code":"334","iso_3166-2":"ISO 3166-2:HM","region":"Oceania","sub-region":"Australia and New Zealand","intermediate-region":"","region-code":"009","sub-region-code":"053","intermediate-region-code":""}, +{"name":"Holy See","alpha-2":"VA","alpha-3":"VAT","country-code":"336","iso_3166-2":"ISO 3166-2:VA","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""}, +{"name":"Honduras","alpha-2":"HN","alpha-3":"HND","country-code":"340","iso_3166-2":"ISO 3166-2:HN","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Central America","region-code":"019","sub-region-code":"419","intermediate-region-code":"013"}, +{"name":"Hong Kong","alpha-2":"HK","alpha-3":"HKG","country-code":"344","iso_3166-2":"ISO 3166-2:HK","region":"Asia","sub-region":"Eastern Asia","intermediate-region":"","region-code":"142","sub-region-code":"030","intermediate-region-code":""}, +{"name":"Hungary","alpha-2":"HU","alpha-3":"HUN","country-code":"348","iso_3166-2":"ISO 3166-2:HU","region":"Europe","sub-region":"Eastern Europe","intermediate-region":"","region-code":"150","sub-region-code":"151","intermediate-region-code":""}, +{"name":"Iceland","alpha-2":"IS","alpha-3":"ISL","country-code":"352","iso_3166-2":"ISO 3166-2:IS","region":"Europe","sub-region":"Northern Europe","intermediate-region":"","region-code":"150","sub-region-code":"154","intermediate-region-code":""}, +{"name":"India","alpha-2":"IN","alpha-3":"IND","country-code":"356","iso_3166-2":"ISO 3166-2:IN","region":"Asia","sub-region":"Southern Asia","intermediate-region":"","region-code":"142","sub-region-code":"034","intermediate-region-code":""}, +{"name":"Indonesia","alpha-2":"ID","alpha-3":"IDN","country-code":"360","iso_3166-2":"ISO 3166-2:ID","region":"Asia","sub-region":"South-eastern Asia","intermediate-region":"","region-code":"142","sub-region-code":"035","intermediate-region-code":""}, +{"name":"Iran (Islamic Republic of)","alpha-2":"IR","alpha-3":"IRN","country-code":"364","iso_3166-2":"ISO 3166-2:IR","region":"Asia","sub-region":"Southern Asia","intermediate-region":"","region-code":"142","sub-region-code":"034","intermediate-region-code":""}, +{"name":"Iraq","alpha-2":"IQ","alpha-3":"IRQ","country-code":"368","iso_3166-2":"ISO 3166-2:IQ","region":"Asia","sub-region":"Western Asia","intermediate-region":"","region-code":"142","sub-region-code":"145","intermediate-region-code":""}, +{"name":"Ireland","alpha-2":"IE","alpha-3":"IRL","country-code":"372","iso_3166-2":"ISO 3166-2:IE","region":"Europe","sub-region":"Northern Europe","intermediate-region":"","region-code":"150","sub-region-code":"154","intermediate-region-code":""}, +{"name":"Isle of Man","alpha-2":"IM","alpha-3":"IMN","country-code":"833","iso_3166-2":"ISO 3166-2:IM","region":"Europe","sub-region":"Northern Europe","intermediate-region":"","region-code":"150","sub-region-code":"154","intermediate-region-code":""}, +{"name":"Israel","alpha-2":"IL","alpha-3":"ISR","country-code":"376","iso_3166-2":"ISO 3166-2:IL","region":"Asia","sub-region":"Western Asia","intermediate-region":"","region-code":"142","sub-region-code":"145","intermediate-region-code":""}, +{"name":"Italy","alpha-2":"IT","alpha-3":"ITA","country-code":"380","iso_3166-2":"ISO 3166-2:IT","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""}, +{"name":"Jamaica","alpha-2":"JM","alpha-3":"JAM","country-code":"388","iso_3166-2":"ISO 3166-2:JM","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Japan","alpha-2":"JP","alpha-3":"JPN","country-code":"392","iso_3166-2":"ISO 3166-2:JP","region":"Asia","sub-region":"Eastern Asia","intermediate-region":"","region-code":"142","sub-region-code":"030","intermediate-region-code":""}, +{"name":"Jersey","alpha-2":"JE","alpha-3":"JEY","country-code":"832","iso_3166-2":"ISO 3166-2:JE","region":"Europe","sub-region":"Northern Europe","intermediate-region":"Channel Islands","region-code":"150","sub-region-code":"154","intermediate-region-code":"830"}, +{"name":"Jordan","alpha-2":"JO","alpha-3":"JOR","country-code":"400","iso_3166-2":"ISO 3166-2:JO","region":"Asia","sub-region":"Western Asia","intermediate-region":"","region-code":"142","sub-region-code":"145","intermediate-region-code":""}, +{"name":"Kazakhstan","alpha-2":"KZ","alpha-3":"KAZ","country-code":"398","iso_3166-2":"ISO 3166-2:KZ","region":"Asia","sub-region":"Central Asia","intermediate-region":"","region-code":"142","sub-region-code":"143","intermediate-region-code":""}, +{"name":"Kenya","alpha-2":"KE","alpha-3":"KEN","country-code":"404","iso_3166-2":"ISO 3166-2:KE","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Kiribati","alpha-2":"KI","alpha-3":"KIR","country-code":"296","iso_3166-2":"ISO 3166-2:KI","region":"Oceania","sub-region":"Micronesia","intermediate-region":"","region-code":"009","sub-region-code":"057","intermediate-region-code":""}, +{"name":"Korea (Democratic People's Republic of)","alpha-2":"KP","alpha-3":"PRK","country-code":"408","iso_3166-2":"ISO 3166-2:KP","region":"Asia","sub-region":"Eastern Asia","intermediate-region":"","region-code":"142","sub-region-code":"030","intermediate-region-code":""}, +{"name":"Korea, Republic of","alpha-2":"KR","alpha-3":"KOR","country-code":"410","iso_3166-2":"ISO 3166-2:KR","region":"Asia","sub-region":"Eastern Asia","intermediate-region":"","region-code":"142","sub-region-code":"030","intermediate-region-code":""}, +{"name":"Kuwait","alpha-2":"KW","alpha-3":"KWT","country-code":"414","iso_3166-2":"ISO 3166-2:KW","region":"Asia","sub-region":"Western Asia","intermediate-region":"","region-code":"142","sub-region-code":"145","intermediate-region-code":""}, +{"name":"Kyrgyzstan","alpha-2":"KG","alpha-3":"KGZ","country-code":"417","iso_3166-2":"ISO 3166-2:KG","region":"Asia","sub-region":"Central Asia","intermediate-region":"","region-code":"142","sub-region-code":"143","intermediate-region-code":""}, +{"name":"Lao People's Democratic Republic","alpha-2":"LA","alpha-3":"LAO","country-code":"418","iso_3166-2":"ISO 3166-2:LA","region":"Asia","sub-region":"South-eastern Asia","intermediate-region":"","region-code":"142","sub-region-code":"035","intermediate-region-code":""}, +{"name":"Latvia","alpha-2":"LV","alpha-3":"LVA","country-code":"428","iso_3166-2":"ISO 3166-2:LV","region":"Europe","sub-region":"Northern Europe","intermediate-region":"","region-code":"150","sub-region-code":"154","intermediate-region-code":""}, +{"name":"Lebanon","alpha-2":"LB","alpha-3":"LBN","country-code":"422","iso_3166-2":"ISO 3166-2:LB","region":"Asia","sub-region":"Western Asia","intermediate-region":"","region-code":"142","sub-region-code":"145","intermediate-region-code":""}, +{"name":"Lesotho","alpha-2":"LS","alpha-3":"LSO","country-code":"426","iso_3166-2":"ISO 3166-2:LS","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Southern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"018"}, +{"name":"Liberia","alpha-2":"LR","alpha-3":"LBR","country-code":"430","iso_3166-2":"ISO 3166-2:LR","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Western Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"011"}, +{"name":"Libya","alpha-2":"LY","alpha-3":"LBY","country-code":"434","iso_3166-2":"ISO 3166-2:LY","region":"Africa","sub-region":"Northern Africa","intermediate-region":"","region-code":"002","sub-region-code":"015","intermediate-region-code":""}, +{"name":"Liechtenstein","alpha-2":"LI","alpha-3":"LIE","country-code":"438","iso_3166-2":"ISO 3166-2:LI","region":"Europe","sub-region":"Western Europe","intermediate-region":"","region-code":"150","sub-region-code":"155","intermediate-region-code":""}, +{"name":"Lithuania","alpha-2":"LT","alpha-3":"LTU","country-code":"440","iso_3166-2":"ISO 3166-2:LT","region":"Europe","sub-region":"Northern Europe","intermediate-region":"","region-code":"150","sub-region-code":"154","intermediate-region-code":""}, +{"name":"Luxembourg","alpha-2":"LU","alpha-3":"LUX","country-code":"442","iso_3166-2":"ISO 3166-2:LU","region":"Europe","sub-region":"Western Europe","intermediate-region":"","region-code":"150","sub-region-code":"155","intermediate-region-code":""}, +{"name":"Macao","alpha-2":"MO","alpha-3":"MAC","country-code":"446","iso_3166-2":"ISO 3166-2:MO","region":"Asia","sub-region":"Eastern Asia","intermediate-region":"","region-code":"142","sub-region-code":"030","intermediate-region-code":""}, +{"name":"Madagascar","alpha-2":"MG","alpha-3":"MDG","country-code":"450","iso_3166-2":"ISO 3166-2:MG","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Malawi","alpha-2":"MW","alpha-3":"MWI","country-code":"454","iso_3166-2":"ISO 3166-2:MW","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Malaysia","alpha-2":"MY","alpha-3":"MYS","country-code":"458","iso_3166-2":"ISO 3166-2:MY","region":"Asia","sub-region":"South-eastern Asia","intermediate-region":"","region-code":"142","sub-region-code":"035","intermediate-region-code":""}, +{"name":"Maldives","alpha-2":"MV","alpha-3":"MDV","country-code":"462","iso_3166-2":"ISO 3166-2:MV","region":"Asia","sub-region":"Southern Asia","intermediate-region":"","region-code":"142","sub-region-code":"034","intermediate-region-code":""}, +{"name":"Mali","alpha-2":"ML","alpha-3":"MLI","country-code":"466","iso_3166-2":"ISO 3166-2:ML","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Western Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"011"}, +{"name":"Malta","alpha-2":"MT","alpha-3":"MLT","country-code":"470","iso_3166-2":"ISO 3166-2:MT","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""}, +{"name":"Marshall Islands","alpha-2":"MH","alpha-3":"MHL","country-code":"584","iso_3166-2":"ISO 3166-2:MH","region":"Oceania","sub-region":"Micronesia","intermediate-region":"","region-code":"009","sub-region-code":"057","intermediate-region-code":""}, +{"name":"Martinique","alpha-2":"MQ","alpha-3":"MTQ","country-code":"474","iso_3166-2":"ISO 3166-2:MQ","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Mauritania","alpha-2":"MR","alpha-3":"MRT","country-code":"478","iso_3166-2":"ISO 3166-2:MR","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Western Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"011"}, +{"name":"Mauritius","alpha-2":"MU","alpha-3":"MUS","country-code":"480","iso_3166-2":"ISO 3166-2:MU","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Mayotte","alpha-2":"YT","alpha-3":"MYT","country-code":"175","iso_3166-2":"ISO 3166-2:YT","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Mexico","alpha-2":"MX","alpha-3":"MEX","country-code":"484","iso_3166-2":"ISO 3166-2:MX","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Central America","region-code":"019","sub-region-code":"419","intermediate-region-code":"013"}, +{"name":"Micronesia (Federated States of)","alpha-2":"FM","alpha-3":"FSM","country-code":"583","iso_3166-2":"ISO 3166-2:FM","region":"Oceania","sub-region":"Micronesia","intermediate-region":"","region-code":"009","sub-region-code":"057","intermediate-region-code":""}, +{"name":"Moldova, Republic of","alpha-2":"MD","alpha-3":"MDA","country-code":"498","iso_3166-2":"ISO 3166-2:MD","region":"Europe","sub-region":"Eastern Europe","intermediate-region":"","region-code":"150","sub-region-code":"151","intermediate-region-code":""}, +{"name":"Monaco","alpha-2":"MC","alpha-3":"MCO","country-code":"492","iso_3166-2":"ISO 3166-2:MC","region":"Europe","sub-region":"Western Europe","intermediate-region":"","region-code":"150","sub-region-code":"155","intermediate-region-code":""}, +{"name":"Mongolia","alpha-2":"MN","alpha-3":"MNG","country-code":"496","iso_3166-2":"ISO 3166-2:MN","region":"Asia","sub-region":"Eastern Asia","intermediate-region":"","region-code":"142","sub-region-code":"030","intermediate-region-code":""}, +{"name":"Montenegro","alpha-2":"ME","alpha-3":"MNE","country-code":"499","iso_3166-2":"ISO 3166-2:ME","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""}, +{"name":"Montserrat","alpha-2":"MS","alpha-3":"MSR","country-code":"500","iso_3166-2":"ISO 3166-2:MS","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Morocco","alpha-2":"MA","alpha-3":"MAR","country-code":"504","iso_3166-2":"ISO 3166-2:MA","region":"Africa","sub-region":"Northern Africa","intermediate-region":"","region-code":"002","sub-region-code":"015","intermediate-region-code":""}, +{"name":"Mozambique","alpha-2":"MZ","alpha-3":"MOZ","country-code":"508","iso_3166-2":"ISO 3166-2:MZ","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Myanmar","alpha-2":"MM","alpha-3":"MMR","country-code":"104","iso_3166-2":"ISO 3166-2:MM","region":"Asia","sub-region":"South-eastern Asia","intermediate-region":"","region-code":"142","sub-region-code":"035","intermediate-region-code":""}, +{"name":"Namibia","alpha-2":"NA","alpha-3":"NAM","country-code":"516","iso_3166-2":"ISO 3166-2:NA","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Southern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"018"}, +{"name":"Nauru","alpha-2":"NR","alpha-3":"NRU","country-code":"520","iso_3166-2":"ISO 3166-2:NR","region":"Oceania","sub-region":"Micronesia","intermediate-region":"","region-code":"009","sub-region-code":"057","intermediate-region-code":""}, +{"name":"Nepal","alpha-2":"NP","alpha-3":"NPL","country-code":"524","iso_3166-2":"ISO 3166-2:NP","region":"Asia","sub-region":"Southern Asia","intermediate-region":"","region-code":"142","sub-region-code":"034","intermediate-region-code":""}, +{"name":"Netherlands","alpha-2":"NL","alpha-3":"NLD","country-code":"528","iso_3166-2":"ISO 3166-2:NL","region":"Europe","sub-region":"Western Europe","intermediate-region":"","region-code":"150","sub-region-code":"155","intermediate-region-code":""}, +{"name":"New Caledonia","alpha-2":"NC","alpha-3":"NCL","country-code":"540","iso_3166-2":"ISO 3166-2:NC","region":"Oceania","sub-region":"Melanesia","intermediate-region":"","region-code":"009","sub-region-code":"054","intermediate-region-code":""}, +{"name":"New Zealand","alpha-2":"NZ","alpha-3":"NZL","country-code":"554","iso_3166-2":"ISO 3166-2:NZ","region":"Oceania","sub-region":"Australia and New Zealand","intermediate-region":"","region-code":"009","sub-region-code":"053","intermediate-region-code":""}, +{"name":"Nicaragua","alpha-2":"NI","alpha-3":"NIC","country-code":"558","iso_3166-2":"ISO 3166-2:NI","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Central America","region-code":"019","sub-region-code":"419","intermediate-region-code":"013"}, +{"name":"Niger","alpha-2":"NE","alpha-3":"NER","country-code":"562","iso_3166-2":"ISO 3166-2:NE","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Western Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"011"}, +{"name":"Nigeria","alpha-2":"NG","alpha-3":"NGA","country-code":"566","iso_3166-2":"ISO 3166-2:NG","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Western Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"011"}, +{"name":"Niue","alpha-2":"NU","alpha-3":"NIU","country-code":"570","iso_3166-2":"ISO 3166-2:NU","region":"Oceania","sub-region":"Polynesia","intermediate-region":"","region-code":"009","sub-region-code":"061","intermediate-region-code":""}, +{"name":"Norfolk Island","alpha-2":"NF","alpha-3":"NFK","country-code":"574","iso_3166-2":"ISO 3166-2:NF","region":"Oceania","sub-region":"Australia and New Zealand","intermediate-region":"","region-code":"009","sub-region-code":"053","intermediate-region-code":""}, +{"name":"North Macedonia","alpha-2":"MK","alpha-3":"MKD","country-code":"807","iso_3166-2":"ISO 3166-2:MK","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""}, +{"name":"Northern Mariana Islands","alpha-2":"MP","alpha-3":"MNP","country-code":"580","iso_3166-2":"ISO 3166-2:MP","region":"Oceania","sub-region":"Micronesia","intermediate-region":"","region-code":"009","sub-region-code":"057","intermediate-region-code":""}, +{"name":"Norway","alpha-2":"NO","alpha-3":"NOR","country-code":"578","iso_3166-2":"ISO 3166-2:NO","region":"Europe","sub-region":"Northern Europe","intermediate-region":"","region-code":"150","sub-region-code":"154","intermediate-region-code":""}, +{"name":"Oman","alpha-2":"OM","alpha-3":"OMN","country-code":"512","iso_3166-2":"ISO 3166-2:OM","region":"Asia","sub-region":"Western Asia","intermediate-region":"","region-code":"142","sub-region-code":"145","intermediate-region-code":""}, +{"name":"Pakistan","alpha-2":"PK","alpha-3":"PAK","country-code":"586","iso_3166-2":"ISO 3166-2:PK","region":"Asia","sub-region":"Southern Asia","intermediate-region":"","region-code":"142","sub-region-code":"034","intermediate-region-code":""}, +{"name":"Palau","alpha-2":"PW","alpha-3":"PLW","country-code":"585","iso_3166-2":"ISO 3166-2:PW","region":"Oceania","sub-region":"Micronesia","intermediate-region":"","region-code":"009","sub-region-code":"057","intermediate-region-code":""}, +{"name":"Palestine, State of","alpha-2":"PS","alpha-3":"PSE","country-code":"275","iso_3166-2":"ISO 3166-2:PS","region":"Asia","sub-region":"Western Asia","intermediate-region":"","region-code":"142","sub-region-code":"145","intermediate-region-code":""}, +{"name":"Panama","alpha-2":"PA","alpha-3":"PAN","country-code":"591","iso_3166-2":"ISO 3166-2:PA","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Central America","region-code":"019","sub-region-code":"419","intermediate-region-code":"013"}, +{"name":"Papua New Guinea","alpha-2":"PG","alpha-3":"PNG","country-code":"598","iso_3166-2":"ISO 3166-2:PG","region":"Oceania","sub-region":"Melanesia","intermediate-region":"","region-code":"009","sub-region-code":"054","intermediate-region-code":""}, +{"name":"Paraguay","alpha-2":"PY","alpha-3":"PRY","country-code":"600","iso_3166-2":"ISO 3166-2:PY","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"South America","region-code":"019","sub-region-code":"419","intermediate-region-code":"005"}, +{"name":"Peru","alpha-2":"PE","alpha-3":"PER","country-code":"604","iso_3166-2":"ISO 3166-2:PE","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"South America","region-code":"019","sub-region-code":"419","intermediate-region-code":"005"}, +{"name":"Philippines","alpha-2":"PH","alpha-3":"PHL","country-code":"608","iso_3166-2":"ISO 3166-2:PH","region":"Asia","sub-region":"South-eastern Asia","intermediate-region":"","region-code":"142","sub-region-code":"035","intermediate-region-code":""}, +{"name":"Pitcairn","alpha-2":"PN","alpha-3":"PCN","country-code":"612","iso_3166-2":"ISO 3166-2:PN","region":"Oceania","sub-region":"Polynesia","intermediate-region":"","region-code":"009","sub-region-code":"061","intermediate-region-code":""}, +{"name":"Poland","alpha-2":"PL","alpha-3":"POL","country-code":"616","iso_3166-2":"ISO 3166-2:PL","region":"Europe","sub-region":"Eastern Europe","intermediate-region":"","region-code":"150","sub-region-code":"151","intermediate-region-code":""}, +{"name":"Portugal","alpha-2":"PT","alpha-3":"PRT","country-code":"620","iso_3166-2":"ISO 3166-2:PT","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""}, +{"name":"Puerto Rico","alpha-2":"PR","alpha-3":"PRI","country-code":"630","iso_3166-2":"ISO 3166-2:PR","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Qatar","alpha-2":"QA","alpha-3":"QAT","country-code":"634","iso_3166-2":"ISO 3166-2:QA","region":"Asia","sub-region":"Western Asia","intermediate-region":"","region-code":"142","sub-region-code":"145","intermediate-region-code":""}, +{"name":"Réunion","alpha-2":"RE","alpha-3":"REU","country-code":"638","iso_3166-2":"ISO 3166-2:RE","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Romania","alpha-2":"RO","alpha-3":"ROU","country-code":"642","iso_3166-2":"ISO 3166-2:RO","region":"Europe","sub-region":"Eastern Europe","intermediate-region":"","region-code":"150","sub-region-code":"151","intermediate-region-code":""}, +{"name":"Russian Federation","alpha-2":"RU","alpha-3":"RUS","country-code":"643","iso_3166-2":"ISO 3166-2:RU","region":"Europe","sub-region":"Eastern Europe","intermediate-region":"","region-code":"150","sub-region-code":"151","intermediate-region-code":""}, +{"name":"Rwanda","alpha-2":"RW","alpha-3":"RWA","country-code":"646","iso_3166-2":"ISO 3166-2:RW","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Saint Barthélemy","alpha-2":"BL","alpha-3":"BLM","country-code":"652","iso_3166-2":"ISO 3166-2:BL","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Saint Helena, Ascension and Tristan da Cunha","alpha-2":"SH","alpha-3":"SHN","country-code":"654","iso_3166-2":"ISO 3166-2:SH","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Western Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"011"}, +{"name":"Saint Kitts and Nevis","alpha-2":"KN","alpha-3":"KNA","country-code":"659","iso_3166-2":"ISO 3166-2:KN","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Saint Lucia","alpha-2":"LC","alpha-3":"LCA","country-code":"662","iso_3166-2":"ISO 3166-2:LC","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Saint Martin (French part)","alpha-2":"MF","alpha-3":"MAF","country-code":"663","iso_3166-2":"ISO 3166-2:MF","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Saint Pierre and Miquelon","alpha-2":"PM","alpha-3":"SPM","country-code":"666","iso_3166-2":"ISO 3166-2:PM","region":"Americas","sub-region":"Northern America","intermediate-region":"","region-code":"019","sub-region-code":"021","intermediate-region-code":""}, +{"name":"Saint Vincent and the Grenadines","alpha-2":"VC","alpha-3":"VCT","country-code":"670","iso_3166-2":"ISO 3166-2:VC","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Samoa","alpha-2":"WS","alpha-3":"WSM","country-code":"882","iso_3166-2":"ISO 3166-2:WS","region":"Oceania","sub-region":"Polynesia","intermediate-region":"","region-code":"009","sub-region-code":"061","intermediate-region-code":""}, +{"name":"San Marino","alpha-2":"SM","alpha-3":"SMR","country-code":"674","iso_3166-2":"ISO 3166-2:SM","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""}, +{"name":"Sao Tome and Principe","alpha-2":"ST","alpha-3":"STP","country-code":"678","iso_3166-2":"ISO 3166-2:ST","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Middle Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"017"}, +{"name":"Saudi Arabia","alpha-2":"SA","alpha-3":"SAU","country-code":"682","iso_3166-2":"ISO 3166-2:SA","region":"Asia","sub-region":"Western Asia","intermediate-region":"","region-code":"142","sub-region-code":"145","intermediate-region-code":""}, +{"name":"Senegal","alpha-2":"SN","alpha-3":"SEN","country-code":"686","iso_3166-2":"ISO 3166-2:SN","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Western Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"011"}, +{"name":"Serbia","alpha-2":"RS","alpha-3":"SRB","country-code":"688","iso_3166-2":"ISO 3166-2:RS","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""}, +{"name":"Seychelles","alpha-2":"SC","alpha-3":"SYC","country-code":"690","iso_3166-2":"ISO 3166-2:SC","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Sierra Leone","alpha-2":"SL","alpha-3":"SLE","country-code":"694","iso_3166-2":"ISO 3166-2:SL","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Western Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"011"}, +{"name":"Singapore","alpha-2":"SG","alpha-3":"SGP","country-code":"702","iso_3166-2":"ISO 3166-2:SG","region":"Asia","sub-region":"South-eastern Asia","intermediate-region":"","region-code":"142","sub-region-code":"035","intermediate-region-code":""}, +{"name":"Sint Maarten (Dutch part)","alpha-2":"SX","alpha-3":"SXM","country-code":"534","iso_3166-2":"ISO 3166-2:SX","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Slovakia","alpha-2":"SK","alpha-3":"SVK","country-code":"703","iso_3166-2":"ISO 3166-2:SK","region":"Europe","sub-region":"Eastern Europe","intermediate-region":"","region-code":"150","sub-region-code":"151","intermediate-region-code":""}, +{"name":"Slovenia","alpha-2":"SI","alpha-3":"SVN","country-code":"705","iso_3166-2":"ISO 3166-2:SI","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""}, +{"name":"Solomon Islands","alpha-2":"SB","alpha-3":"SLB","country-code":"090","iso_3166-2":"ISO 3166-2:SB","region":"Oceania","sub-region":"Melanesia","intermediate-region":"","region-code":"009","sub-region-code":"054","intermediate-region-code":""}, +{"name":"Somalia","alpha-2":"SO","alpha-3":"SOM","country-code":"706","iso_3166-2":"ISO 3166-2:SO","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"South Africa","alpha-2":"ZA","alpha-3":"ZAF","country-code":"710","iso_3166-2":"ISO 3166-2:ZA","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Southern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"018"}, +{"name":"South Georgia and the South Sandwich Islands","alpha-2":"GS","alpha-3":"SGS","country-code":"239","iso_3166-2":"ISO 3166-2:GS","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"South America","region-code":"019","sub-region-code":"419","intermediate-region-code":"005"}, +{"name":"South Sudan","alpha-2":"SS","alpha-3":"SSD","country-code":"728","iso_3166-2":"ISO 3166-2:SS","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Spain","alpha-2":"ES","alpha-3":"ESP","country-code":"724","iso_3166-2":"ISO 3166-2:ES","region":"Europe","sub-region":"Southern Europe","intermediate-region":"","region-code":"150","sub-region-code":"039","intermediate-region-code":""}, +{"name":"Sri Lanka","alpha-2":"LK","alpha-3":"LKA","country-code":"144","iso_3166-2":"ISO 3166-2:LK","region":"Asia","sub-region":"Southern Asia","intermediate-region":"","region-code":"142","sub-region-code":"034","intermediate-region-code":""}, +{"name":"Sudan","alpha-2":"SD","alpha-3":"SDN","country-code":"729","iso_3166-2":"ISO 3166-2:SD","region":"Africa","sub-region":"Northern Africa","intermediate-region":"","region-code":"002","sub-region-code":"015","intermediate-region-code":""}, +{"name":"Suriname","alpha-2":"SR","alpha-3":"SUR","country-code":"740","iso_3166-2":"ISO 3166-2:SR","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"South America","region-code":"019","sub-region-code":"419","intermediate-region-code":"005"}, +{"name":"Svalbard and Jan Mayen","alpha-2":"SJ","alpha-3":"SJM","country-code":"744","iso_3166-2":"ISO 3166-2:SJ","region":"Europe","sub-region":"Northern Europe","intermediate-region":"","region-code":"150","sub-region-code":"154","intermediate-region-code":""}, +{"name":"Sweden","alpha-2":"SE","alpha-3":"SWE","country-code":"752","iso_3166-2":"ISO 3166-2:SE","region":"Europe","sub-region":"Northern Europe","intermediate-region":"","region-code":"150","sub-region-code":"154","intermediate-region-code":""}, +{"name":"Switzerland","alpha-2":"CH","alpha-3":"CHE","country-code":"756","iso_3166-2":"ISO 3166-2:CH","region":"Europe","sub-region":"Western Europe","intermediate-region":"","region-code":"150","sub-region-code":"155","intermediate-region-code":""}, +{"name":"Syrian Arab Republic","alpha-2":"SY","alpha-3":"SYR","country-code":"760","iso_3166-2":"ISO 3166-2:SY","region":"Asia","sub-region":"Western Asia","intermediate-region":"","region-code":"142","sub-region-code":"145","intermediate-region-code":""}, +{"name":"Taiwan, Province of China","alpha-2":"TW","alpha-3":"TWN","country-code":"158","iso_3166-2":"ISO 3166-2:TW","region":"Asia","sub-region":"Eastern Asia","intermediate-region":"","region-code":"142","sub-region-code":"030","intermediate-region-code":""}, +{"name":"Tajikistan","alpha-2":"TJ","alpha-3":"TJK","country-code":"762","iso_3166-2":"ISO 3166-2:TJ","region":"Asia","sub-region":"Central Asia","intermediate-region":"","region-code":"142","sub-region-code":"143","intermediate-region-code":""}, +{"name":"Tanzania, United Republic of","alpha-2":"TZ","alpha-3":"TZA","country-code":"834","iso_3166-2":"ISO 3166-2:TZ","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Thailand","alpha-2":"TH","alpha-3":"THA","country-code":"764","iso_3166-2":"ISO 3166-2:TH","region":"Asia","sub-region":"South-eastern Asia","intermediate-region":"","region-code":"142","sub-region-code":"035","intermediate-region-code":""}, +{"name":"Timor-Leste","alpha-2":"TL","alpha-3":"TLS","country-code":"626","iso_3166-2":"ISO 3166-2:TL","region":"Asia","sub-region":"South-eastern Asia","intermediate-region":"","region-code":"142","sub-region-code":"035","intermediate-region-code":""}, +{"name":"Togo","alpha-2":"TG","alpha-3":"TGO","country-code":"768","iso_3166-2":"ISO 3166-2:TG","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Western Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"011"}, +{"name":"Tokelau","alpha-2":"TK","alpha-3":"TKL","country-code":"772","iso_3166-2":"ISO 3166-2:TK","region":"Oceania","sub-region":"Polynesia","intermediate-region":"","region-code":"009","sub-region-code":"061","intermediate-region-code":""}, +{"name":"Tonga","alpha-2":"TO","alpha-3":"TON","country-code":"776","iso_3166-2":"ISO 3166-2:TO","region":"Oceania","sub-region":"Polynesia","intermediate-region":"","region-code":"009","sub-region-code":"061","intermediate-region-code":""}, +{"name":"Trinidad and Tobago","alpha-2":"TT","alpha-3":"TTO","country-code":"780","iso_3166-2":"ISO 3166-2:TT","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Tunisia","alpha-2":"TN","alpha-3":"TUN","country-code":"788","iso_3166-2":"ISO 3166-2:TN","region":"Africa","sub-region":"Northern Africa","intermediate-region":"","region-code":"002","sub-region-code":"015","intermediate-region-code":""}, +{"name":"Turkey","alpha-2":"TR","alpha-3":"TUR","country-code":"792","iso_3166-2":"ISO 3166-2:TR","region":"Asia","sub-region":"Western Asia","intermediate-region":"","region-code":"142","sub-region-code":"145","intermediate-region-code":""}, +{"name":"Turkmenistan","alpha-2":"TM","alpha-3":"TKM","country-code":"795","iso_3166-2":"ISO 3166-2:TM","region":"Asia","sub-region":"Central Asia","intermediate-region":"","region-code":"142","sub-region-code":"143","intermediate-region-code":""}, +{"name":"Turks and Caicos Islands","alpha-2":"TC","alpha-3":"TCA","country-code":"796","iso_3166-2":"ISO 3166-2:TC","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Tuvalu","alpha-2":"TV","alpha-3":"TUV","country-code":"798","iso_3166-2":"ISO 3166-2:TV","region":"Oceania","sub-region":"Polynesia","intermediate-region":"","region-code":"009","sub-region-code":"061","intermediate-region-code":""}, +{"name":"Uganda","alpha-2":"UG","alpha-3":"UGA","country-code":"800","iso_3166-2":"ISO 3166-2:UG","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Ukraine","alpha-2":"UA","alpha-3":"UKR","country-code":"804","iso_3166-2":"ISO 3166-2:UA","region":"Europe","sub-region":"Eastern Europe","intermediate-region":"","region-code":"150","sub-region-code":"151","intermediate-region-code":""}, +{"name":"United Arab Emirates","alpha-2":"AE","alpha-3":"ARE","country-code":"784","iso_3166-2":"ISO 3166-2:AE","region":"Asia","sub-region":"Western Asia","intermediate-region":"","region-code":"142","sub-region-code":"145","intermediate-region-code":""}, +{"name":"United Kingdom of Great Britain and Northern Ireland","alpha-2":"GB","alpha-3":"GBR","country-code":"826","iso_3166-2":"ISO 3166-2:GB","region":"Europe","sub-region":"Northern Europe","intermediate-region":"","region-code":"150","sub-region-code":"154","intermediate-region-code":""}, +{"name":"United States of America","alpha-2":"US","alpha-3":"USA","country-code":"840","iso_3166-2":"ISO 3166-2:US","region":"Americas","sub-region":"Northern America","intermediate-region":"","region-code":"019","sub-region-code":"021","intermediate-region-code":""}, +{"name":"United States Minor Outlying Islands","alpha-2":"UM","alpha-3":"UMI","country-code":"581","iso_3166-2":"ISO 3166-2:UM","region":"Oceania","sub-region":"Micronesia","intermediate-region":"","region-code":"009","sub-region-code":"057","intermediate-region-code":""}, +{"name":"Uruguay","alpha-2":"UY","alpha-3":"URY","country-code":"858","iso_3166-2":"ISO 3166-2:UY","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"South America","region-code":"019","sub-region-code":"419","intermediate-region-code":"005"}, +{"name":"Uzbekistan","alpha-2":"UZ","alpha-3":"UZB","country-code":"860","iso_3166-2":"ISO 3166-2:UZ","region":"Asia","sub-region":"Central Asia","intermediate-region":"","region-code":"142","sub-region-code":"143","intermediate-region-code":""}, +{"name":"Vanuatu","alpha-2":"VU","alpha-3":"VUT","country-code":"548","iso_3166-2":"ISO 3166-2:VU","region":"Oceania","sub-region":"Melanesia","intermediate-region":"","region-code":"009","sub-region-code":"054","intermediate-region-code":""}, +{"name":"Venezuela (Bolivarian Republic of)","alpha-2":"VE","alpha-3":"VEN","country-code":"862","iso_3166-2":"ISO 3166-2:VE","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"South America","region-code":"019","sub-region-code":"419","intermediate-region-code":"005"}, +{"name":"Viet Nam","alpha-2":"VN","alpha-3":"VNM","country-code":"704","iso_3166-2":"ISO 3166-2:VN","region":"Asia","sub-region":"South-eastern Asia","intermediate-region":"","region-code":"142","sub-region-code":"035","intermediate-region-code":""}, +{"name":"Virgin Islands (British)","alpha-2":"VG","alpha-3":"VGB","country-code":"092","iso_3166-2":"ISO 3166-2:VG","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Virgin Islands (U.S.)","alpha-2":"VI","alpha-3":"VIR","country-code":"850","iso_3166-2":"ISO 3166-2:VI","region":"Americas","sub-region":"Latin America and the Caribbean","intermediate-region":"Caribbean","region-code":"019","sub-region-code":"419","intermediate-region-code":"029"}, +{"name":"Wallis and Futuna","alpha-2":"WF","alpha-3":"WLF","country-code":"876","iso_3166-2":"ISO 3166-2:WF","region":"Oceania","sub-region":"Polynesia","intermediate-region":"","region-code":"009","sub-region-code":"061","intermediate-region-code":""}, +{"name":"Western Sahara","alpha-2":"EH","alpha-3":"ESH","country-code":"732","iso_3166-2":"ISO 3166-2:EH","region":"Africa","sub-region":"Northern Africa","intermediate-region":"","region-code":"002","sub-region-code":"015","intermediate-region-code":""}, +{"name":"Yemen","alpha-2":"YE","alpha-3":"YEM","country-code":"887","iso_3166-2":"ISO 3166-2:YE","region":"Asia","sub-region":"Western Asia","intermediate-region":"","region-code":"142","sub-region-code":"145","intermediate-region-code":""}, +{"name":"Zambia","alpha-2":"ZM","alpha-3":"ZMB","country-code":"894","iso_3166-2":"ISO 3166-2:ZM","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"}, +{"name":"Zimbabwe","alpha-2":"ZW","alpha-3":"ZWE","country-code":"716","iso_3166-2":"ISO 3166-2:ZW","region":"Africa","sub-region":"Sub-Saharan Africa","intermediate-region":"Eastern Africa","region-code":"002","sub-region-code":"202","intermediate-region-code":"014"} +] diff --git a/vendor/github.com/go-openapi/strfmt/mongo.go b/vendor/github.com/go-openapi/strfmt/mongo.go index be904ffa5de..15bfbed192f 100644 --- a/vendor/github.com/go-openapi/strfmt/mongo.go +++ b/vendor/github.com/go-openapi/strfmt/mongo.go @@ -4,7 +4,6 @@ package strfmt import ( - "encoding/base64" "encoding/binary" "fmt" "time" @@ -41,6 +40,8 @@ var ( _ bsonUnmarshaler = &Base64{} _ bsonMarshaler = Duration(0) _ bsonUnmarshaler = (*Duration)(nil) + _ bsonMarshaler = DurationISO8601(0) + _ bsonUnmarshaler = (*DurationISO8601)(nil) _ bsonMarshaler = DateTime{} _ bsonUnmarshaler = &DateTime{} _ bsonMarshaler = ULID{} @@ -92,6 +93,10 @@ var ( _ bsonValueUnmarshaler = &DateTime{} _ bsonValueMarshaler = ObjectId{} _ bsonValueUnmarshaler = &ObjectId{} + _ bsonMarshaler = Currency{} + _ bsonUnmarshaler = (*Currency)(nil) + _ bsonMarshaler = Country{} + _ bsonUnmarshaler = (*Country)(nil) ) const ( @@ -140,7 +145,7 @@ func (b *Base64) UnmarshalBSON(data []byte) error { return fmt.Errorf("couldn't unmarshal bson bytes as base64: %w", ErrFormat) } - vb, err := base64.StdEncoding.DecodeString(s) + vb, err := base64Encoding.DecodeString(s) if err != nil { return err } @@ -171,6 +176,38 @@ func (d *Duration) UnmarshalBSON(data []byte) error { return nil } +// MarshalBSON renders the [ISODuration] as a BSON document. +// +// BSON is a storage boundary (like SQL): the value is emitted losslessly with [ISODuration.String], regardless of the +// policy P — a strict policy that could not serialize a sign or sub-second precision on the interchange path must still +// be persistable. +func (d ISODuration[P]) MarshalBSON() ([]byte, error) { + return bsonlite.C.MarshalDoc(d.String()) +} + +// UnmarshalBSON reads an [ISODuration] from a BSON document. +// +// The stored value is our own canonical output, so it is parsed leniently: BSON is trusted storage, not external +// interchange, and must round-trip whatever [ISODuration.MarshalBSON] emitted even under a strict policy P. +func (d *ISODuration[P]) UnmarshalBSON(data []byte) error { + v, err := bsonlite.C.UnmarshalDoc(data) + if err != nil { + return err + } + + s, ok := v.(string) + if !ok { + return fmt.Errorf("couldn't unmarshal bson bytes value as ISODuration: %w", ErrFormat) + } + + rd, err := parseISO8601Duration(s, DurationLenient{}.isoDurationConfig()) + if err != nil { + return err + } + *d = ISODuration[P](rd) + return nil +} + // MarshalBSON renders the [DateTime] as a BSON document. func (t DateTime) MarshalBSON() ([]byte, error) { tNorm := NormalizeTimeForMarshal(time.Time(t)) @@ -599,3 +636,47 @@ func (id *ObjectId) UnmarshalBSONValue(_ byte, data []byte) error { *id = ObjectId(oid) return nil } + +// MarshalBSON document from this value. +func (u Currency) MarshalBSON() ([]byte, error) { + return bsonlite.C.MarshalDoc(u.String()) +} + +// UnmarshalBSON document into this value. +func (u *Currency) UnmarshalBSON(data []byte) error { + s, err := unmarshalBSONString(data, "Currency") + if err != nil { + return err + } + + cur, err := ParseCurrency(s) + if err != nil { + return err + } + + *u = cur + + return nil +} + +// MarshalBSON document from this value. +func (u Country) MarshalBSON() ([]byte, error) { + return bsonlite.C.MarshalDoc(u.String()) +} + +// UnmarshalBSON document into this value. +func (u *Country) UnmarshalBSON(data []byte) error { + s, err := unmarshalBSONString(data, "Country") + if err != nil { + return err + } + + cur, err := ParseCountry(s) + if err != nil { + return err + } + + *u = cur + + return nil +} diff --git a/vendor/github.com/go-openapi/strfmt/register.go b/vendor/github.com/go-openapi/strfmt/register.go new file mode 100644 index 00000000000..4a4c185b53a --- /dev/null +++ b/vendor/github.com/go-openapi/strfmt/register.go @@ -0,0 +1,138 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + +package strfmt + +// Default is the default formats registry. +// +// NOTE: format "duration" is wire by default onto "duration-human". +var Default Registry //nolint:gochecknoglobals // package-level default registry, by design + +// JSONSchema2020Registry is the format registry with JSONSchema draft 2020 formats (e.g. duration is an iso8601 duration). +var JSONSchema2020Registry Registry //nolint:gochecknoglobals // package-level default registry, by design + +func init() { //nolint:gochecknoinits // registers all default string formats in the registry + // register formats in the default registry: + // - byte + // - creditcard + // - email + // - hexcolor + // - hostname + // - ipv4 + // - ipv6 + // - cidr + // - isbn + // - isbn10 + // - isbn13 + // - mac + // - password + // - rgbcolor + // - ssn + // - uri + // - uuid + // - uuid3 + // - uuid4 + // - uuid5 + // - uuid7 + // - ulid + // - date, date-time + // - duration, duration-human, duration-iso8601 + // - objectid + // - currency, country + Default = NewSeededFormats(nil, nil) + + u := URI("") + Default.Add("uri", &u, isRequestURI) + + eml := Email("") + Default.Add("email", &eml, IsEmail) + + hn := Hostname("") + Default.Add("hostname", &hn, IsHostname) + + ip4 := IPv4("") + Default.Add("ipv4", &ip4, isIPv4) + + ip6 := IPv6("") + Default.Add("ipv6", &ip6, isIPv6) + + cidr := CIDR("") + Default.Add("cidr", &cidr, isCIDR) + + mac := MAC("") + Default.Add("mac", &mac, isMAC) + + uid := UUID("") + Default.Add("uuid", &uid, IsUUID) + + uid3 := UUID3("") + Default.Add("uuid3", &uid3, IsUUID3) + + uid4 := UUID4("") + Default.Add("uuid4", &uid4, IsUUID4) + + uid5 := UUID5("") + Default.Add("uuid5", &uid5, IsUUID5) + + uid7 := UUID7("") + Default.Add("uuid7", &uid7, IsUUID7) + + isbn := ISBN("") + Default.Add("isbn", &isbn, func(str string) bool { return isISBN10(str) || isISBN13(str) }) + + isbn10 := ISBN10("") + Default.Add("isbn10", &isbn10, isISBN10) + + isbn13 := ISBN13("") + Default.Add("isbn13", &isbn13, isISBN13) + + cc := CreditCard("") + Default.Add("creditcard", &cc, isCreditCard) + + ssn := SSN("") + Default.Add("ssn", &ssn, isSSN) + + hc := HexColor("") + Default.Add("hexcolor", &hc, isHexcolor) + + rc := RGBColor("") + Default.Add("rgbcolor", &rc, isRGBcolor) + + b64 := Base64([]byte(nil)) + Default.Add("byte", &b64, isBase64) + + pw := Password("") + Default.Add("password", &pw, func(_ string) bool { return true }) + + d := Date{} + Default.Add("date", &d, IsDate) + + dt := DateTime{} + Default.Add("datetime", &dt, IsDateTime) + + du := Duration(0) + Default.Add("duration", &du, IsDuration) + Default.Add("duration-human", &du, IsDuration) + + di := DurationISO8601(0) + Default.Add("duration-iso8601", &di, IsDurationISO8601) + + var id ObjectId + Default.Add("bsonobjectid", &id, IsBSONObjectID) + + ulid := ULID{} + Default.Add("ulid", &ulid, IsULID) + + cur := Currency{} + Default.Add("currency", &cur, IsCurrency) + + co := Country{} + Default.Add("country", &co, IsCountry) + + def, ok := Default.(*defaultFormats) + if !ok { + panic("internal error: can't initialize") + } + + JSONSchema2020Registry = NewSeededFormats(def.data, JSONSchema2020Normalizer) +} diff --git a/vendor/github.com/go-openapi/strfmt/time.go b/vendor/github.com/go-openapi/strfmt/time.go index 1fde8c6b119..94e409e0637 100644 --- a/vendor/github.com/go-openapi/strfmt/time.go +++ b/vendor/github.com/go-openapi/strfmt/time.go @@ -17,11 +17,6 @@ import ( // Unix 0 for an EST timezone is not equivalent to a UTC timezone. var UnixZero = time.Unix(0, 0).UTC() //nolint:gochecknoglobals // package-level sentinel value for unix epoch -func init() { //nolint:gochecknoinits // registers datetime format in the default registry - dt := DateTime{} - Default.Add("datetime", &dt, IsDateTime) -} - // IsDateTime returns true when the string is a valid date-time. // // JSON datetime format consist of a date and a time separated by a "T", e.g. 2012-04-23T18:25:43.511Z. diff --git a/vendor/github.com/go-openapi/strfmt/ulid.go b/vendor/github.com/go-openapi/strfmt/ulid.go index f05d22c5187..38809adba42 100644 --- a/vendor/github.com/go-openapi/strfmt/ulid.go +++ b/vendor/github.com/go-openapi/strfmt/ulid.go @@ -69,11 +69,6 @@ var ( ULIDValueOverrideFunc = ULIDValueDefaultFunc ) -func init() { //nolint:gochecknoinits // registers ulid format in the default registry - ulid := ULID{} - Default.Add("ulid", &ulid, IsULID) -} - // IsULID checks if provided string is [ULID] format // Be noticed that this function considers overflowed [ULID] as non-[ulid]. // For more details see https://github.com/[ulid]/spec diff --git a/vendor/github.com/go-openapi/swag/conv/format.go b/vendor/github.com/go-openapi/swag/conv/format.go index 5b87b8e146b..e14e5bfcfb9 100644 --- a/vendor/github.com/go-openapi/swag/conv/format.go +++ b/vendor/github.com/go-openapi/swag/conv/format.go @@ -7,14 +7,16 @@ import ( "strconv" ) +const baseDecimal = 10 + // FormatInteger turns an integer type into a string. func FormatInteger[T Signed](value T) string { - return strconv.FormatInt(int64(value), 10) + return strconv.FormatInt(int64(value), baseDecimal) } // FormatUinteger turns an unsigned integer type into a string. func FormatUinteger[T Unsigned](value T) string { - return strconv.FormatUint(uint64(value), 10) + return strconv.FormatUint(uint64(value), baseDecimal) } // FormatFloat turns a floating point numerical value into a string. @@ -26,3 +28,23 @@ func FormatFloat[T Float](value T) string { func FormatBool(value bool) string { return strconv.FormatBool(value) } + +// AppendInteger appends the decimal representation of an integer to a slice of bytes. +func AppendInteger[T Signed](dst []byte, value T) []byte { + return strconv.AppendInt(dst, int64(value), baseDecimal) +} + +// AppendUinteger appends the decimal representation of an unsigned integer to a slice of bytes. +func AppendUinteger[T Unsigned](dst []byte, value T) []byte { + return strconv.AppendUint(dst, uint64(value), baseDecimal) +} + +// AppendFloat appends the decimal representation of a floating point number to a slice of bytes. +func AppendFloat[T Float](dst []byte, value T) []byte { + return strconv.AppendFloat(dst, float64(value), 'g', -1, bitsize(value)) +} + +// AppendBool appends the text representation of a boolean to a slice of bytes. +func AppendBool(dst []byte, value bool) []byte { + return strconv.AppendBool(dst, value) +} diff --git a/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/adapter.go b/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/adapter.go index 0213ff5c29f..94185f79c10 100644 --- a/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/adapter.go +++ b/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/adapter.go @@ -5,6 +5,7 @@ package json import ( stdjson "encoding/json" + "fmt" "github.com/go-openapi/swag/jsonutils/adapters/ifaces" "github.com/go-openapi/swag/typeutils" @@ -24,11 +25,16 @@ var ErrStdlib jsonError = "error from the JSON adapter stdlib" var _ ifaces.Adapter = &Adapter{} type Adapter struct { + options } // NewAdapter yields an [ifaces.Adapter] using the standard library. -func NewAdapter() *Adapter { - return &Adapter{} +func NewAdapter(opts ...Option) *Adapter { + var o options + + return &Adapter{ + options: buildOptions(o, opts), + } } func (a *Adapter) Marshal(value any) ([]byte, error) { @@ -40,45 +46,18 @@ func (a *Adapter) Unmarshal(data []byte, value any) error { } func (a *Adapter) OrderedMarshal(value ifaces.Ordered) ([]byte, error) { - w := poolOfWriters.Borrow() - defer func() { - poolOfWriters.Redeem(w) - }() - - if typeutils.IsNil(value) { - w.RawString("null") - - return w.BuildBytes() - } - - w.RawByte('{') - first := true - for k, v := range value.OrderedItems() { - if first { - first = false - } else { - w.RawByte(',') - } + w, redeem := poolOfWriters.BorrowWithRedeem() + defer redeem() + w.setBuf() - w.String(k) - w.RawByte(':') - - switch val := v.(type) { - case ifaces.Ordered: - w.Raw(a.OrderedMarshal(val)) - default: - w.Raw(stdjson.Marshal(v)) - } - } - - w.RawByte('}') + a.orderedMarshal(w, value, 1) return w.BuildBytes() } func (a *Adapter) OrderedUnmarshal(data []byte, value ifaces.SetOrdered) error { var m MapSlice - if err := m.OrderedUnmarshalJSON(data); err != nil { + if err := m.orderedUnmarshalJSON(data, a.maxDepth()); err != nil { return err } @@ -112,4 +91,43 @@ func (a *Adapter) Redeem() { } func (a *Adapter) Reset() { + a.options = options{} +} + +// orderedMarshal writes value to w, tracking the container nesting depth to guard +// against stack overflow on deeply nested structures. +func (a *Adapter) orderedMarshal(w *jwriter, value ifaces.Ordered, depth int) { + if typeutils.IsNil(value) { + w.RawString("null") + + return + } + + if maxDepth := a.maxDepth(); depth > maxDepth { + w.SetErr(fmt.Errorf("maximum nesting depth of %d exceeded: %w", maxDepth, ErrStdlib)) + + return + } + + w.RawByte('{') + first := true + for k, v := range value.OrderedItems() { + if first { + first = false + } else { + w.RawByte(',') + } + + w.String(k) + w.RawByte(':') + + switch val := v.(type) { + case ifaces.Ordered: + a.orderedMarshal(w, val, depth+1) + default: + w.Raw(stdjson.Marshal(v)) + } + } + + w.RawByte('}') } diff --git a/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/lexer.go b/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/lexer.go index b5aa1c7972e..ac81cbc75fa 100644 --- a/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/lexer.go +++ b/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/lexer.go @@ -54,7 +54,7 @@ func (t token) Delim() byte { return 0 } - return byte(r) + return byte(r) //nolint:gosec // delimiter runes are single byte } type tokenKind uint8 @@ -91,6 +91,13 @@ type jlexer struct { // current token next token // started bool + + // depth tracks the current JSON container nesting level, and maxDepth caps it + // to guard against stack-overflow on adversarially deep documents. The standard + // library's streaming [encoding/json.Decoder.Token] API (used here) does not + // enforce the max-depth guard that [encoding/json.Unmarshal] provides, so we do. + depth int + maxDepth int } type bytesReader struct { @@ -130,7 +137,8 @@ var _ io.Reader = &bytesReader{} func newLexer(data []byte) *jlexer { l := &jlexer{ // current: undefToken, - next: undefToken, + next: undefToken, + maxDepth: defaultMaxNestingDepth, } l.buf = &bytesReader{ buf: data, @@ -143,7 +151,11 @@ func newLexer(data []byte) *jlexer { func (l *jlexer) Reset() { l.err = nil l.next = undefToken - // leave l.dec and l.buf alone, since they are replaced at every Borrow + l.depth = 0 + l.maxDepth = defaultMaxNestingDepth + l.dec = nil + // leave l.buf alone, since they are replaced at every Borrow + l.buf = nil } func (l *jlexer) Error() error { @@ -228,6 +240,21 @@ func (l *jlexer) Delim(c byte) { if tok.Delim() != c { l.err = fmt.Errorf("expected delimiter '%q' but got '%q': %w", c, tok.Delim(), ErrStdlib) + + return + } + + // Track container nesting depth centrally: every '{' or '[' opens a level and + // every '}' or ']' closes one. This guards the mutually-recursive unmarshal + // routines (unmarshalObject/unmarshalArray/asInterface) against stack overflow. + switch c { + case '{', '[': + l.depth++ + if l.maxDepth > 0 && l.depth > l.maxDepth { + l.err = fmt.Errorf("maximum nesting depth of %d exceeded: %w", l.maxDepth, ErrStdlib) + } + case '}', ']': + l.depth-- } } @@ -318,3 +345,12 @@ func (l *jlexer) fetchToken() token { return token{Token: jtok} } + +func (l *jlexer) setBuf(data []byte) func() { + rdr, redeemBuf := poolOfReaders.BorrowWithRedeem() + l.buf = rdr + l.buf.buf = data + l.dec = stdjson.NewDecoder(l.buf) // cannot pool, not exposed by the encoding/json API + + return redeemBuf +} diff --git a/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/options.go b/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/options.go new file mode 100644 index 00000000000..f114f1f1a1a --- /dev/null +++ b/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/options.go @@ -0,0 +1,52 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + +package json + +// defaultMaxNestingDepth is the default maximum number of nested JSON containers +// ('{' or '[') that the ordered-JSON marshaler and unmarshaler will process before +// returning an error. +// +// It mirrors the limit enforced by the standard library's [encoding/json] decoder +// (see encoding/json's internal maxNestingDepth), which this adapter would otherwise +// not benefit from since it drives [encoding/json.Decoder.Token] directly. +const defaultMaxNestingDepth = 10000 + +// Option selects options for the stdlib adapter. +type Option func(o options) options + +type options struct { + maxNestingDepth int +} + +func buildOptions(o options, opts []Option) options { + for _, apply := range opts { + o = apply(o) + } + + return o +} + +// maxDepth returns the configured maximum nesting depth, or the default when unset. +func (o options) maxDepth() int { + if o.maxNestingDepth <= 0 { + return defaultMaxNestingDepth + } + + return o.maxNestingDepth +} + +// WithMaxNestingDepth sets the maximum number of nested JSON containers accepted +// when marshaling or unmarshaling ordered JSON. +// +// A value <= 0 selects the default (10,000). +// +// This guards against stack-overflow crashes on deeply nested (possibly adversarial) +// JSON documents or in-memory structures. +func WithMaxNestingDepth(depth int) Option { + return func(o options) options { + o.maxNestingDepth = depth + + return o + } +} diff --git a/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/ordered_map.go b/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/ordered_map.go index 54deef406f3..a5a8f4b6317 100644 --- a/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/ordered_map.go +++ b/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/ordered_map.go @@ -70,12 +70,11 @@ func (s MapSlice) MarshalJSON() ([]byte, error) { } func (s MapSlice) OrderedMarshalJSON() ([]byte, error) { - w := poolOfWriters.Borrow() - defer func() { - poolOfWriters.Redeem(w) - }() + w, redeem := poolOfWriters.BorrowWithRedeem() + defer redeem() + w.setBuf() - s.marshalObject(w) + s.marshalObject(w, 1) return w.BuildBytes() // this clones data, so it's okay to redeem the writer and its buffer } @@ -88,23 +87,38 @@ func (s *MapSlice) UnmarshalJSON(data []byte) error { } func (s *MapSlice) OrderedUnmarshalJSON(data []byte) error { - l := poolOfLexers.Borrow(data) - defer func() { - poolOfLexers.Redeem(l) - }() + return s.orderedUnmarshalJSON(data, defaultMaxNestingDepth) +} + +func (s *MapSlice) orderedUnmarshalJSON(data []byte, maxDepth int) error { + l, redeem := poolOfLexers.BorrowWithRedeem() + defer redeem() + + redeemBuf := l.setBuf(data) + defer redeemBuf() + + if maxDepth > 0 { + l.maxDepth = maxDepth + } s.unmarshalObject(l) return l.Error() } -func (s MapSlice) marshalObject(w *jwriter) { +func (s MapSlice) marshalObject(w *jwriter, depth int) { if s == nil { w.RawString("null") return } + if depth > defaultMaxNestingDepth { + w.SetErr(fmt.Errorf("maximum nesting depth of %d exceeded: %w", defaultMaxNestingDepth, ErrStdlib)) + + return + } + w.RawByte('{') if len(s) == 0 { @@ -113,11 +127,11 @@ func (s MapSlice) marshalObject(w *jwriter) { return } - s[0].marshalJSON(w) + s[0].marshalJSON(w, depth) for i := 1; i < len(s); i++ { w.RawByte(',') - s[i].marshalJSON(w) + s[i].marshalJSON(w, depth) } w.RawByte('}') @@ -162,9 +176,18 @@ type MapItem struct { Value any } -func (s MapItem) marshalJSON(w *jwriter) { +func (s MapItem) marshalJSON(w *jwriter, depth int) { w.String(s.Key) w.RawByte(':') + + // Recurse internally for nested ordered maps so the depth guard is not lost across + // the stdjson.Marshal boundary (which would reset it and re-enable stack overflow). + if nested, ok := s.Value.(MapSlice); ok { + nested.marshalObject(w, depth+1) + + return + } + w.Raw(stdjson.Marshal(s.Value)) } diff --git a/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/pool.go b/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/pool.go index 709b97c3046..2f06b88e808 100644 --- a/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/pool.go +++ b/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/pool.go @@ -4,118 +4,15 @@ package json import ( - "encoding/json" - "sync" - "github.com/go-openapi/swag/jsonutils/adapters/ifaces" + "github.com/go-openapi/swag/pools" ) -type adaptersPool struct { - sync.Pool -} - -func (p *adaptersPool) Borrow() *Adapter { - return p.Get().(*Adapter) -} - -func (p *adaptersPool) BorrowIface() ifaces.Adapter { - return p.Get().(*Adapter) -} - -func (p *adaptersPool) Redeem(a *Adapter) { - p.Put(a) -} - -type writersPool struct { - sync.Pool -} - -func (p *writersPool) Borrow() *jwriter { - ptr := p.Get() - - jw := ptr.(*jwriter) - jw.Reset() - - return jw -} - -func (p *writersPool) Redeem(w *jwriter) { - p.Put(w) -} - -type lexersPool struct { - sync.Pool -} - -func (p *lexersPool) Borrow(data []byte) *jlexer { - ptr := p.Get() - - l := ptr.(*jlexer) - l.buf = poolOfReaders.Borrow(data) - l.dec = json.NewDecoder(l.buf) // cannot pool, not exposed by the encoding/json API - l.Reset() - - return l -} - -func (p *lexersPool) Redeem(l *jlexer) { - l.dec = nil - discard := l.buf - l.buf = nil - poolOfReaders.Redeem(discard) - p.Put(l) -} - -type readersPool struct { - sync.Pool -} - -func (p *readersPool) Borrow(data []byte) *bytesReader { - ptr := p.Get() - - b := ptr.(*bytesReader) - b.Reset() - b.buf = data - - return b -} - -func (p *readersPool) Redeem(b *bytesReader) { - p.Put(b) -} - var ( - poolOfAdapters = &adaptersPool{ - Pool: sync.Pool{ - New: func() any { - return NewAdapter() - }, - }, - } - - poolOfWriters = &writersPool{ - Pool: sync.Pool{ - New: func() any { - return newJWriter() - }, - }, - } - - poolOfLexers = &lexersPool{ - Pool: sync.Pool{ - New: func() any { - return newLexer(nil) - }, - }, - } - - poolOfReaders = &readersPool{ - Pool: sync.Pool{ - New: func() any { - return &bytesReader{} - }, - }, - } + poolOfAdapters = pools.New[Adapter]() + poolOfWriters = pools.NewRedeemable[jwriter]() + poolOfLexers = pools.NewRedeemable[jlexer]() + poolOfReaders = pools.NewRedeemable[bytesReader]() ) // BorrowAdapter borrows an [Adapter] from the pool, recycling already allocated instances. @@ -124,10 +21,12 @@ func BorrowAdapter() *Adapter { } // BorrowAdapterIface borrows a stdlib [Adapter] and converts it directly -// to [ifaces.Adapter]. This is useful to avoid further allocations when -// translating the concrete type into an interface. +// to [ifaces.Adapter]. +// +// This is useful to avoid further allocations when translating the concrete type into +// an interface. func BorrowAdapterIface() ifaces.Adapter { - return poolOfAdapters.BorrowIface() + return poolOfAdapters.Borrow() } // RedeemAdapter redeems an [Adapter] to the pool, so it may be recycled. diff --git a/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/register.go b/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/register.go index fc8818694ea..0dec85425ba 100644 --- a/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/register.go +++ b/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/register.go @@ -10,14 +10,22 @@ import ( "github.com/go-openapi/swag/jsonutils/adapters/ifaces" ) -func Register(dispatcher ifaces.Registrar) { +func Register(dispatcher ifaces.Registrar, opts ...Option) { t := reflect.TypeOf(Adapter{}) + var o options + o = buildOptions(o, opts) + dispatcher.RegisterFor( ifaces.RegistryEntry{ - Who: fmt.Sprintf("%s.%s", t.PkgPath(), t.Name()), - What: ifaces.AllCapabilities, - Constructor: BorrowAdapterIface, - Support: support, + Who: fmt.Sprintf("%s.%s", t.PkgPath(), t.Name()), + What: ifaces.AllCapabilities, + Constructor: func() ifaces.Adapter { + a := BorrowAdapter() + a.options = o + + return a + }, + Support: support, }) } diff --git a/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/writer.go b/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/writer.go index dc2325c1a30..c84e02cd838 100644 --- a/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/writer.go +++ b/vendor/github.com/go-openapi/swag/jsonutils/adapters/stdlib/json/writer.go @@ -14,17 +14,21 @@ type jwriter struct { err error } -func newJWriter() *jwriter { - buf := make([]byte, 0, sensibleBufferSize) - - return &jwriter{buf: bytes.NewBuffer(buf)} -} - func (w *jwriter) Reset() { - w.buf.Reset() + if w.buf != nil { + w.buf.Reset() + } w.err = nil } +// SetErr records the first error encountered while building the JSON output. +func (w *jwriter) SetErr(err error) { + if w.err != nil { + return + } + w.err = err +} + func (w *jwriter) RawString(s string) { if w.err != nil { return @@ -73,3 +77,12 @@ func (w *jwriter) BuildBytes() ([]byte, error) { return bytes.Clone(w.buf.Bytes()), nil } + +func (w *jwriter) setBuf() { + if w.buf != nil { + return + } + + buf := make([]byte, 0, sensibleBufferSize) + w.buf = bytes.NewBuffer(buf) +} diff --git a/vendor/github.com/go-openapi/swag/pools/LICENSE b/vendor/github.com/go-openapi/swag/pools/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/vendor/github.com/go-openapi/swag/pools/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/go-openapi/swag/pools/README.md b/vendor/github.com/go-openapi/swag/pools/README.md new file mode 100644 index 00000000000..1966461cb54 --- /dev/null +++ b/vendor/github.com/go-openapi/swag/pools/README.md @@ -0,0 +1 @@ +# pools diff --git a/vendor/github.com/go-openapi/swag/pools/debug.go b/vendor/github.com/go-openapi/swag/pools/debug.go new file mode 100644 index 00000000000..94415e989e4 --- /dev/null +++ b/vendor/github.com/go-openapi/swag/pools/debug.go @@ -0,0 +1,17 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + +package pools + +// TB is the subset of [testing.TB] used by [AssertNoLeaks]. +// +// It is satisfied by *[testing.T] and *[testing.B]. +// +// A local interface is used (rather than importing "testing") so that the +// release build does not pull the testing package — and its flags — into +// production binaries. +type TB interface { + Helper() + Errorf(format string, args ...any) + Logf(format string, args ...any) +} diff --git a/vendor/github.com/go-openapi/swag/pools/debug_off.go b/vendor/github.com/go-openapi/swag/pools/debug_off.go new file mode 100644 index 00000000000..9163d6d60e4 --- /dev/null +++ b/vendor/github.com/go-openapi/swag/pools/debug_off.go @@ -0,0 +1,51 @@ +//go:build !poolsdebug + +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + +package pools + +// This is the release implementation of the pool instrumentation: it does +// nothing. +// +// tracker is an empty struct, so it adds no field to the pool types and its +// methods inline away to nothing. +// +// Build with -tags poolsdebug to get the instrumented variant (see +// debug_on.go). + +// debugBuild reports whether the pool instrumentation is compiled in (the +// poolsdebug tag). +const debugBuild = false + +// DebugBuild reports whether the pool instrumentation is compiled in (the +// poolsdebug build tag). +// +// It lets a test that must run in both modes skip the parts that are invalid +// under instrumentation — e.g. an allocation-count assertion, since the +// instrumented build allocates a per-borrow tracker. +const DebugBuild = debugBuild + +type tracker[T any] struct{} + +func (tracker[T]) register() {} + +func (tracker[T]) onBorrow(*T) {} + +func (tracker[T]) onRedeem(*T) {} + +func (tracker[T]) borrowRedeemer(_ *T, cached func()) func() { return cached } + +// AssertNoLeaks reports whether every borrowed object has been redeemed across +// all pools. +// +// It is only meaningful in the instrumented build (-tags poolsdebug). +// +// In a release build it is a no-op that always reports true, so the same test +// can run in both modes. +func AssertNoLeaks(TB) bool { return true } + +// ResetTracking clears all recorded borrow/redeem tracking. +// +// This is a no-op in a release build. +func ResetTracking() {} diff --git a/vendor/github.com/go-openapi/swag/pools/debug_on.go b/vendor/github.com/go-openapi/swag/pools/debug_on.go new file mode 100644 index 00000000000..64ccc57d38f --- /dev/null +++ b/vendor/github.com/go-openapi/swag/pools/debug_on.go @@ -0,0 +1,237 @@ +//go:build poolsdebug + +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + +package pools + +import ( + "fmt" + "runtime" + "sync" +) + +// This is the instrumented implementation of the pool tracking, enabled with +// -tags poolsdebug. +// +// Each pool carries a tracker that records, per recycled pointer, whether it is +// currently borrowed or redeemed, together with the call sites of the last +// borrow and redeem. +// It panics loudly (with those call sites) when it detects misuse: +// +// - a double redeem (the same object returned to the pool twice — corrupts sync.Pool); +// - for the redeemable pools, a redeem of a stale borrow (the slot was re-borrowed since — the +// ABA case the production atomic guard cannot catch), thanks to a per-borrow generation; +// - a redeem of an object the pool never handed out; +// - a borrow of an object still checked out (a symptom of an earlier double-Put). +// +// Borrowed-but-never-redeemed objects (leaks) are reported by [AssertNoLeaks]. + +// debugBuild reports whether the pool instrumentation is compiled in (the +// poolsdebug tag). +const debugBuild = true + +// DebugBuild reports whether the pool instrumentation is compiled in (the +// poolsdebug build tag). +// +// See the release-build doc for usage. +const DebugBuild = debugBuild + +type trackStatus uint8 + +const ( + trackBorrowed trackStatus = iota + 1 + trackRedeemed +) + +type trackEntry struct { + status trackStatus + gen uint64 // identifies the current borrow, to detect a redeem racing a re-borrow (ABA) + borrowedAt string + redeemedAt string +} + +type tracker[T any] struct { + mu sync.Mutex + entries map[*T]*trackEntry + nextGen uint64 +} + +func (t *tracker[T]) register() { + t.mu.Lock() + if t.entries == nil { + t.entries = make(map[*T]*trackEntry) + } + t.mu.Unlock() + + registerLeakChecker(t) +} + +// markBorrow records a borrow of ptr and returns its generation. +// +// Caller must hold no lock. +func (t *tracker[T]) markBorrow(ptr *T, site string) uint64 { + t.mu.Lock() + defer t.mu.Unlock() + + e := t.entries[ptr] + if e == nil { + e = &trackEntry{} + t.entries[ptr] = e + } else if e.status == trackBorrowed { + panic(fmt.Sprintf( + "pools: borrow of an object still checked out (borrowed at %s); "+ + "this usually means it was redeemed twice earlier", e.borrowedAt)) + } + + t.nextGen++ + e.status = trackBorrowed + e.gen = t.nextGen + e.borrowedAt = site + + return t.nextGen +} + +// markRedeem validates and records a redeem of ptr. gen is the borrow +// generation the caller is redeeming, or 0 to skip the ABA check (plain +// Pool[T], which has no per-borrow token). +func (t *tracker[T]) markRedeem(ptr *T, gen uint64, site string) { + t.mu.Lock() + defer t.mu.Unlock() + + e := t.entries[ptr] + switch { + case e == nil: + panic("pools: redeem of an object this pool never handed out") + case e.status != trackBorrowed: + panic(fmt.Sprintf("pools: double redeem (first redeemed at %s)", e.redeemedAt)) + case gen != 0 && e.gen != gen: + panic(fmt.Sprintf( + "pools: redeem of a stale borrow (the slot was re-borrowed at %s since this borrow); "+ + "a redeem is racing a re-borrow of the same slot (ABA)", e.borrowedAt)) + } + + e.status = trackRedeemed + e.redeemedAt = site +} + +const stackOffset = 3 + +func (t *tracker[T]) onBorrow(ptr *T) { + t.markBorrow(ptr, caller(stackOffset)) +} + +func (t *tracker[T]) onRedeem(ptr *T) { + t.markRedeem(ptr, 0, caller(stackOffset)) +} + +// borrowRedeemer records the borrow and returns a generation-stamped redeemer +// that validates the redeem (catching double-redeem and ABA) before delegating +// to the cached redeemer. +func (t *tracker[T]) borrowRedeemer(ptr *T, cached func()) func() { + gen := t.markBorrow(ptr, caller(stackOffset)) + + return func() { + t.markRedeem(ptr, gen, caller(stackOffset-1)) + cached() + } +} + +func (t *tracker[T]) checkLeaks(tb TB) bool { + t.mu.Lock() + defer t.mu.Unlock() + + ok := true + for _, e := range t.entries { + if e.status != trackRedeemed { + tb.Logf("pools: object borrowed but never redeemed (borrowed at %s)", e.borrowedAt) + ok = false + } + } + + return ok +} + +func (t *tracker[T]) resetTracking() { + t.mu.Lock() + t.entries = make(map[*T]*trackEntry) + t.nextGen = 0 + t.mu.Unlock() +} + +// leakChecker is the build-erased view of a tracker that the global registry +// holds, so trackers of different element types can be checked uniformly. +type leakChecker interface { + checkLeaks(tb TB) bool + resetTracking() +} + +var ( + registryMu sync.Mutex + registry []leakChecker +) + +func registerLeakChecker(c leakChecker) { + registryMu.Lock() + registry = append(registry, c) + registryMu.Unlock() +} + +// AssertNoLeaks reports whether every borrowed object has been redeemed across +// all pools created so far. +// +// It logs the borrow call site of each leaked object and fails tb when any are +// found. +// +// Typical use, with [ResetTracking] to isolate the test from earlier ones: +// +// func TestX(t *testing.T) { +// pools.ResetTracking() +// t.Cleanup(func() { pools.AssertNoLeaks(t) }) +// // ... exercise code that borrows/redeems ... +// } +func AssertNoLeaks(tb TB) bool { + tb.Helper() + registryMu.Lock() + defer registryMu.Unlock() + + ok := true + for _, c := range registry { + if !c.checkLeaks(tb) { + ok = false + } + } + if !ok { + tb.Errorf("pools: leaked pooled objects detected (borrowed but never redeemed)") + } + + return ok +} + +// ResetTracking clears all recorded borrow/redeem tracking across every pool. +// +// Call it at the start of a test so leaks from earlier tests are not attributed +// to it. +func ResetTracking() { + registryMu.Lock() + defer registryMu.Unlock() + + for _, c := range registry { + c.resetTracking() + } +} + +// caller returns "file:line" of the frame skip levels above caller itself. +func caller(skip int) string { + pc, _, _, ok := runtime.Caller(skip) + if !ok { + return "unknown" + } + fn := runtime.FuncForPC(pc) + if fn == nil { + return "unknown" + } + file, line := fn.FileLine(pc) + + return fmt.Sprintf("%s:%d", file, line) +} diff --git a/vendor/github.com/go-openapi/swag/pools/doc.go b/vendor/github.com/go-openapi/swag/pools/doc.go new file mode 100644 index 00000000000..395c24d29a6 --- /dev/null +++ b/vendor/github.com/go-openapi/swag/pools/doc.go @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + +// Package pools provide utilities to recycle allocated objects. +// +// This package provides: +// +// - a generic [Pool] type that wraps [sync.Pool], +// - a [PoolRedeemable] variant that hands out a cached redeem closure, +// - a [PoolSlice] for recycling slices without juggling pointers. +// +// # Debug build +// +// Building with the "poolsdebug" tag (go test -tags poolsdebug ./...) turns on +// instrumentation that tracks every borrow and redeem and panics on misuse: +// +// - double redeem (including the A -> B -> A case for the redeemable pools), +// - redeem of a foreign object, +// - borrow of an object still checked out +// +// It reports the offending call sites. +// +// [AssertNoLeaks] then reports any object borrowed but never redeemed. +// +// The instrumentation is a no-op with zero overhead when the tag is absent. +package pools diff --git a/vendor/github.com/go-openapi/swag/pools/pools.go b/vendor/github.com/go-openapi/swag/pools/pools.go new file mode 100644 index 00000000000..d78ea5790a3 --- /dev/null +++ b/vendor/github.com/go-openapi/swag/pools/pools.go @@ -0,0 +1,410 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + +package pools + +import ( + "iter" + "slices" + "sync" + "sync/atomic" +) + +// Resettable is an interface for types that want to recycle a clean instance +// from a [Pool]. +// +// When T (or rather *T) implements [Resettable], the pool calls Reset on an +// instance both when it is redeemed and when it is borrowed: +// +// - on redeem, so that no references held by the instance are retained while it sits idle in the +// pool (which would pin a reference graph alive across a GC cycle); +// - on borrow, so that the next borrower receives a clean object regardless of how the instance +// reached the pool. +// +// Reset must be safe to call more than once on the same instance (it runs at +// least twice per cycle). +type Resettable interface { + Reset() +} + +// resetIfResettable calls Reset on v when *T implements [Resettable]. +func resetIfResettable[T any](v *T) { + if r, ok := any(v).(Resettable); ok { + r.Reset() + } +} + +// borrow state of a [redeemable] wrapper, used to detect double-redeem. +const ( + stateIdle uint32 = iota // sitting in the pool (or freshly created), not checked out + stateBorrowed // checked out by a borrower +) + +type redeemable[T any] struct { + inner *T + redeemer func() + // state guards against a double-redeem (the same wrapper Put into the pool + // twice, which would let one object be handed to two borrowers). + // + // It is set to stateBorrowed on borrow and atomically flipped back to + // stateIdle on redeem; a redeem that finds it already idle panics. + state atomic.Uint32 +} + +// redeemPanic is the message raised when a slot is redeemed while already idle. +const redeemPanic = "pools: " + + "double redeem detected (object already returned to the pool); " + + "a borrowed object must be redeemed exactly once" + +// Pool wraps a [sync.Pool] to make it available for any type. +// +// T must be the value type of the pooled object (e.g. Pool[bytes.Buffer]): +// [Pool.Borrow] returns a *T. Using a pointer type as T (e.g. +// Pool[*bytes.Buffer]) would yield a **T and is almost certainly a mistake. +type Pool[T any] struct { + pool sync.Pool + tracker tracker[T] // empty (zero-cost) unless built with the poolsdebug tag +} + +// PoolRedeemable wraps a [sync.Pool] to make it available for any type. +// +// It differs from [Pool] in the way objects are redeemed to the pool: borrowing +// also yields a cached redeem closure, so no closure is allocated at redeem +// time. +type PoolRedeemable[T any] struct { + pool sync.Pool + tracker tracker[redeemable[T]] // empty (zero-cost) unless built with the poolsdebug tag +} + +// New builds a new [Pool] to recycle allocations of type T explicitly using +// [Pool.Redeem] and the allocated pointer. +// +// Freshly allocated instances of type T are set to their zero value; like +// recycled instances they are reset (if [Resettable]) when borrowed, so +// [Pool.Borrow] always yields a clean object. +func New[T any]() *Pool[T] { + p := &Pool[T]{} + p.pool = sync.Pool{ + New: func() any { + return new(T) + }, + } + p.tracker.register() + + return p +} + +// NewRedeemable builds a new redeemable [Pool] to recycle allocations of type +// T, and use the inner redeemer to relinquish objects to the pool. +func NewRedeemable[T any]() *PoolRedeemable[T] { + p := &PoolRedeemable[T]{} + p.pool = sync.Pool{ + New: func() any { + r := &redeemable[T]{inner: new(T)} + r.redeemer = func() { + if !r.state.CompareAndSwap(stateBorrowed, stateIdle) { + panic(redeemPanic) + } + resetIfResettable(r.inner) + p.pool.Put(r) + } + + return r + }, + } + p.tracker.register() + + return p +} + +// Borrow an instance from the pool. +// +// If the type implements [Resettable], the returned instance is reset before +// being handed out, so it is always clean. +func (p *Pool[T]) Borrow() *T { + target := p.pool.Get().(*T) + resetIfResettable(target) + p.tracker.onBorrow(target) + + return target +} + +// Redeem a borrowed instance to the pool. +// +// A nil pointer is ignored (it would otherwise corrupt the pool: a typed-nil +// boxed into an interface is not the nil interface that [sync.Pool.Put] skips). +// +// The instance is reset (if it implements [Resettable]) before being returned +// to the pool. +// After calling Redeem, the caller must drop its reference to ptr: continuing +// to use it is a use-after-redeem bug. +// +// Unlike [PoolRedeemable], this plain pool holds no per-object state, so it +// cannot detect a double-redeem of the same pointer (which corrupts the pool). +// +// Prefer [PoolRedeemable] when you want that guard, or the debug build for full +// tracking. +func (p *Pool[T]) Redeem(ptr *T) { + if ptr == nil { + return + } + p.tracker.onRedeem(ptr) + resetIfResettable(ptr) + p.pool.Put(ptr) +} + +// BorrowWithRedeem borrows an instance from the pool and provides the +// corresponding redeem function. +// +// This is useful for instance to use with defer. +// +// The instance is reset (if it implements [Resettable]) both when borrowed and +// when the returned redeem closure is called. +// After calling the redeem closure, the caller must drop its reference to the +// returned instance. +// +// Calling the redeem closure more than once panics (see [redeemable.state]): a +// borrowed instance must be redeemed exactly once. +func (p *PoolRedeemable[T]) BorrowWithRedeem() (*T, func()) { + container := p.pool.Get().(*redeemable[T]) + container.state.Store(stateBorrowed) + resetIfResettable(container.inner) + + // In release builds borrowRedeemer returns container.redeemer unchanged (zero + // cost). + // Under the poolsdebug tag it returns a generation-stamped wrapper that tracks + // the borrow and detects double-redeem (incl. + // + // ABA), foreign-redeem and leaks. + return container.inner, p.tracker.borrowRedeemer(container, container.redeemer) +} + +// Slice is a struct that wraps a slice []T. +// +// This is useful to borrow and redeem slices from a pool, without having to +// constantly manipulate pointers to the slice. +// +// The wrapper holds the authoritative slice header. +// +// Its mutating methods ([Slice.Append], [Slice.Concat], [Slice.Grow]) return +// the current backing slice for convenience, so it reads as an idiomatic []T. +// +// But the returned slice is only a snapshot of the wrapper's state at that +// moment: if you keep it and grow it yourself with the builtin append and it +// reallocates, the new backing array lives only in your local copy and is NOT +// tracked by the wrapper — it will not be recycled when the wrapper is +// redeemed (and a later borrower would get the old, smaller array). +// +// Rule of thumb: it is fine to read or pass the returned []T to a consumer; but +// if you plan to grow the slice, keep calling the wrapper's methods so the +// growth is tracked and recycled. +type Slice[T any] struct { + length int + inner []T +} + +// Slice returns the inner slice. +// +// Treat the result as a read-only view (for ranging or passing to a consumer), +// valid until the next mutation or redeem. +// To grow or append, use the wrapper methods so the new backing array is +// tracked and recycled (see [Slice]). +func (s *Slice[T]) Slice() []T { + return s.inner +} + +// Grow the inner slice so it can accommodate at least size more elements +// without reallocating, and return the current backing slice. +// +// Growth is tracked by the wrapper, so the enlarged backing array is recycled +// on redeem. +// See [Slice] for the caveat about growing the returned slice yourself. +func (s *Slice[T]) Grow(size int) []T { + s.inner = slices.Grow(s.inner, size) + + return s.inner +} + +func (s *Slice[T]) Len() int { + return len(s.inner) +} + +func (s *Slice[T]) Cap() int { + return cap(s.inner) +} + +// Append elements to the inner slice and return the current backing slice. +// +// This should be preferred to the append builtin if you plan that the slice will +// grow and you want the newly allocated space to be tracked and recycled. +// See [Slice] for the caveat about growing the returned slice yourself. +func (s *Slice[T]) Append(elems ...T) []T { + s.inner = append(s.inner, elems...) + + return s.inner +} + +// Concat another slice to the inner slice and return the current backing slice. +// +// Unlike [slices.Concat], this reuses the inner slice's capacity instead of +// always allocating a fresh backing array. +// See [Slice] for the caveat about growing the returned slice yourself. +func (s *Slice[T]) Concat(slice []T) []T { + s.inner = append(s.inner, slice...) + + return s.inner +} + +// IndexedElems iterates over the inner slice. +func (s *Slice[T]) IndexedElems() iter.Seq2[int, T] { + return func(yield func(int, T) bool) { + for i, elem := range s.inner { + if !yield(i, elem) { + return + } + } + } +} + +// Reset the inner slice to its configured initial length, keeping allocated +// capacity. +// +// All elements are zeroed, so the pool never retains stale element references +// (which would keep a referenced graph alive for slices of pointers) and so a +// [WithLength] slice is handed out clean rather than carrying data from a +// previous borrower. +func (s *Slice[T]) Reset() { + clear(s.inner) + if s.length > cap(s.inner) { + s.inner = slices.Grow(s.inner[:0], s.length) + } + s.inner = s.inner[:s.length] +} + +// Clip removes unused capacity from the inner slice. +func (s *Slice[T]) Clip() { + s.inner = slices.Clip(s.inner) +} + +// resetWithCapacity discards the current backing array and replaces it with a +// fresh one of the configured length and the given capacity. +// +// It is used by a capacity-capped pool to stop recycling an oversized backing +// array (the old array is left for the GC). +func (s *Slice[T]) resetWithCapacity(capacity int) { + s.inner = make([]T, s.length, max(s.length, capacity)) +} + +// PoolSlice is a pool of [Slice[T]]. +// +// [PoolSlice.BorrowWithRedeem] will return an empty inner slice by default. +// This default may be altered using [WithMinimumCapacity]. +// +// Use [PoolSlice.BorrowWithSizeAndRedeem] or [Slice.Grow] to grow the capacity +// of the inner slice. +type PoolSlice[T any] struct { + // redeemable is held as an unexported field rather than embedded, so the + // underlying [PoolRedeemable] and its [sync.Pool] are not part of PoolSlice's + // public surface. + redeemable *PoolRedeemable[Slice[T]] +} + +// PoolSliceOption alters the default settings to allocate new pooled slices +type PoolSliceOption func(*poolSliceOptions) + +type poolSliceOptions struct { + minCapacity int + length int + maxCapacity int +} + +func WithMinimumCapacity(size int) PoolSliceOption { + return func(o *poolSliceOptions) { + o.minCapacity = size + } +} + +// WithMaxCapacity bounds the capacity of recycled slices. +// +// When a borrowed slice has grown past size at redeem time, its (oversized) +// backing array is discarded and replaced with a fresh one sized to the minimum +// capacity, instead of being recycled. +// +// This stops the pool from accumulating large backing arrays after an +// occasional large request, keeping the steady-state memory bounded. +// +// The trade-off: a workload that genuinely needs slices larger than size will +// reallocate on every cycle. +// Set size from the high-water mark you actually expect, not below it. +// A size of 0 (the default) means no cap: grown slices are recycled as-is. +func WithMaxCapacity(size int) PoolSliceOption { + return func(o *poolSliceOptions) { + o.maxCapacity = size + } +} + +// WithLength ensures that the borrowed slices have a fixed given initial +// length. +// +// By default, the borrowed slices are reset to length 0. +func WithLength(size int) PoolSliceOption { + return func(o *poolSliceOptions) { + o.length = size + } +} + +// NewPoolSlice builds a pool to recycle slices of type []T. +func NewPoolSlice[T any](opts ...PoolSliceOption) *PoolSlice[T] { + var o poolSliceOptions + for _, apply := range opts { + apply(&o) + } + + rp := &PoolRedeemable[Slice[T]]{} + rp.pool = sync.Pool{ + New: func() any { + s := &redeemable[Slice[T]]{ + inner: &Slice[T]{ + length: o.length, + inner: make([]T, o.length, max(o.length, o.minCapacity)), + }, + } + + s.redeemer = func() { + if !s.state.CompareAndSwap(stateBorrowed, stateIdle) { + panic(redeemPanic) + } + if o.maxCapacity > 0 && s.inner.Cap() > o.maxCapacity { + s.inner.resetWithCapacity(o.minCapacity) + } else { + s.inner.Reset() + } + rp.pool.Put(s) + } + + return s + }, + } + rp.tracker.register() + + return &PoolSlice[T]{redeemable: rp} +} + +// BorrowWithRedeem returns the slice wrapper and the redeem closure to +// relinquish the allocated wrapper. +// +// The wrapper is reset (elements zeroed, length restored) both on borrow and +// when the redeem closure is called. +// Calling the redeem closure more than once panics. +func (p *PoolSlice[T]) BorrowWithRedeem() (*Slice[T], func()) { + return p.redeemable.BorrowWithRedeem() +} + +// BorrowWithSizeAndRedeem borrows a slice []T from the pool and ensures that +// its capacity is at least the provided size. +func (p *PoolSlice[T]) BorrowWithSizeAndRedeem(size int) (*Slice[T], func()) { + s, redeem := p.BorrowWithRedeem() + s.Grow(size) + + return s, redeem +} diff --git a/vendor/github.com/hashicorp/consul/api/config_entry.go b/vendor/github.com/hashicorp/consul/api/config_entry.go index e82e14749db..84155086295 100644 --- a/vendor/github.com/hashicorp/consul/api/config_entry.go +++ b/vendor/github.com/hashicorp/consul/api/config_entry.go @@ -43,6 +43,7 @@ const ( const ( BuiltinAWSLambdaExtension string = "builtin/aws/lambda" BuiltinExtAuthzExtension string = "builtin/ext-authz" + BuiltinExtProcExtension string = "builtin/ext-proc" BuiltinLuaExtension string = "builtin/lua" BuiltinOTELAccessLoggingExtension string = "builtin/otel-access-logging" BuiltinPropertyOverrideExtension string = "builtin/property-override" diff --git a/vendor/github.com/hashicorp/consul/api/config_entry_gateways.go b/vendor/github.com/hashicorp/consul/api/config_entry_gateways.go index 6397088c9e8..457e4b33b01 100644 --- a/vendor/github.com/hashicorp/consul/api/config_entry_gateways.go +++ b/vendor/github.com/hashicorp/consul/api/config_entry_gateways.go @@ -250,6 +250,15 @@ type APIGatewayConfigEntry struct { // Defaults contains default upstream limits for all route destination services. Defaults *UpstreamLimits `json:",omitempty"` + + // ExtAuthz is the gateway-wide external authorization toggle. It controls the + // default ext_authz posture for every endpoint behind this gateway when the + // builtin/ext-authz EnvoyExtension is applied via service-defaults. When nil + // (omitted) ext_authz is enabled by default; when set with Enabled=false the + // filter defaults to disabled and routes must opt in individually. Per-route + // http-route ExtAuthz filters take precedence over this toggle. + ExtAuthz *APIGatewayExtAuthz `json:",omitempty"` + // Status is the asynchronous status which an APIGateway propagates to the user. Status ConfigEntryStatus @@ -279,6 +288,16 @@ func (g *APIGatewayConfigEntry) GetMeta() map[string]string { return g.Meta } func (g *APIGatewayConfigEntry) GetCreateIndex() uint64 { return g.CreateIndex } func (g *APIGatewayConfigEntry) GetModifyIndex() uint64 { return g.ModifyIndex } +// APIGatewayExtAuthz is the gateway-wide external authorization toggle on an +// APIGatewayConfigEntry. See APIGatewayConfigEntry.ExtAuthz. +type APIGatewayExtAuthz struct { + // Enabled controls the default ext_authz posture for all endpoints behind + // the gateway. When false the ext_authz filter defaults to disabled and + // individual http-route rules must opt in. When the containing ExtAuthz + // block is omitted entirely, ext_authz is enabled by default. + Enabled bool +} + // APIGatewayListener represents an individual listener for an APIGateway type APIGatewayListener struct { // Name is the name of the listener in a given gateway. This must be diff --git a/vendor/github.com/hashicorp/consul/api/config_entry_routes.go b/vendor/github.com/hashicorp/consul/api/config_entry_routes.go index e6a1d6a722c..7f6f142f2cd 100644 --- a/vendor/github.com/hashicorp/consul/api/config_entry_routes.go +++ b/vendor/github.com/hashicorp/consul/api/config_entry_routes.go @@ -207,6 +207,52 @@ type HTTPFilters struct { RetryFilter *RetryFilter TimeoutFilter *TimeoutFilter JWT *JWTFilter + ExtProc []ExtProcFilter + // ExtAuthz controls the ext_authz HTTP filter behaviour for routes on an + // API Gateway that has a builtin/ext-authz EnvoyExtension applied. When set, + // it overrides the gateway-wide ExtAuthz toggle for the matched route: + // Enabled=true forces the ext_authz check to run, Enabled=false skips it. + // When nil, the route inherits the gateway-wide default. Exclusions are + // controlled exclusively at the http-route level. + ExtAuthz *HTTPRouteExtAuthzFilter +} + +// ExtProcFilter provides per-route control of a builtin/ext-proc attachment. +type ExtProcFilter struct { + StatPrefix string `json:",omitempty"` + Mode string `json:",omitempty"` + Overrides *ExtProcOverrides `json:",omitempty"` +} + +// ExtProcOverrides carries per-route overrides applied when Mode is "override". +type ExtProcOverrides struct { + Processing *ExtProcProcessing `json:",omitempty"` + // MessageTimeout string `json:",omitempty"` + // FailureModeAllow *bool `json:",omitempty"` +} + +// ExtProcProcessing configures request and response processing modes. +type ExtProcProcessing struct { + Request *ExtProcProcessingDirection `json:",omitempty"` + Response *ExtProcProcessingDirection `json:",omitempty"` +} + +// ExtProcProcessingDirection configures processing modes for one direction. +type ExtProcProcessingDirection struct { + HeadersMode string `json:",omitempty"` + BodyMode string `json:",omitempty"` + TrailersMode string `json:",omitempty"` + MaxBodyBytes int64 `json:",omitempty"` +} + +// HTTPRouteExtAuthzFilter controls ext_authz filter behaviour at the +// individual http-route rule level. +type HTTPRouteExtAuthzFilter struct { + // Enabled controls whether Envoy runs the ext_authz check for requests + // matched by this rule. Enabled=true force-enables the check (overriding a + // disabled gateway toggle); Enabled=false force-skips it. This takes + // precedence over the gateway-wide ExtAuthz toggle. + Enabled bool } // HTTPResponseFilters specifies a list of filters used to modify a diff --git a/vendor/github.com/hashicorp/go-metrics/compat/armon.go b/vendor/github.com/hashicorp/go-metrics/compat/armon.go new file mode 100644 index 00000000000..6a9e1e59661 --- /dev/null +++ b/vendor/github.com/hashicorp/go-metrics/compat/armon.go @@ -0,0 +1,131 @@ +// Copyright IBM Corp. 2013, 2025 +// SPDX-License-Identifier: MIT + +//go:build armonmetrics || ignore || !hashicorpmetrics + +package metrics + +import ( + "io" + "net/url" + "syscall" + "time" + + "github.com/armon/go-metrics" +) + +const ( + // DefaultSignal is used with DefaultInmemSignal + DefaultSignal = metrics.DefaultSignal +) + +func AddSample(key []string, val float32) { + metrics.AddSample(key, val) +} +func AddSampleWithLabels(key []string, val float32, labels []Label) { + metrics.AddSampleWithLabels(key, val, labels) +} +func EmitKey(key []string, val float32) { + metrics.EmitKey(key, val) +} +func IncrCounter(key []string, val float32) { + metrics.IncrCounter(key, val) +} +func IncrCounterWithLabels(key []string, val float32, labels []Label) { + metrics.IncrCounterWithLabels(key, val, labels) +} +func MeasureSince(key []string, start time.Time) { + metrics.MeasureSince(key, start) +} +func MeasureSinceWithLabels(key []string, start time.Time, labels []Label) { + metrics.MeasureSinceWithLabels(key, start, labels) +} +func SetGauge(key []string, val float32) { + metrics.SetGauge(key, val) +} +func SetGaugeWithLabels(key []string, val float32, labels []Label) { + metrics.SetGaugeWithLabels(key, val, labels) +} +func Shutdown() { + metrics.Shutdown() +} +func UpdateFilter(allow, block []string) { + metrics.UpdateFilter(allow, block) +} +func UpdateFilterAndLabels(allow, block, allowedLabels, blockedLabels []string) { + metrics.UpdateFilterAndLabels(allow, block, allowedLabels, blockedLabels) +} + +type AggregateSample = metrics.AggregateSample +type BlackholeSink = metrics.BlackholeSink +type Config = metrics.Config +type Encoder = metrics.Encoder +type FanoutSink = metrics.FanoutSink +type GaugeValue = metrics.GaugeValue +type InmemSignal = metrics.InmemSignal +type InmemSink = metrics.InmemSink +type IntervalMetrics = metrics.IntervalMetrics +type Label = metrics.Label +type MetricSink = metrics.MetricSink +type Metrics = metrics.Metrics +type MetricsSummary = metrics.MetricsSummary +type PointValue = metrics.PointValue +type SampledValue = metrics.SampledValue +type ShutdownSink = metrics.ShutdownSink +type StatsdSink = metrics.StatsdSink +type StatsiteSink = metrics.StatsiteSink + +func DefaultConfig(serviceName string) *Config { + return metrics.DefaultConfig(serviceName) +} + +func DefaultInmemSignal(inmem *InmemSink) *InmemSignal { + return metrics.DefaultInmemSignal(inmem) +} +func NewInmemSignal(inmem *InmemSink, sig syscall.Signal, w io.Writer) *InmemSignal { + return metrics.NewInmemSignal(inmem, sig, w) +} + +func NewInmemSink(interval, retain time.Duration) *InmemSink { + return metrics.NewInmemSink(interval, retain) +} + +func NewIntervalMetrics(intv time.Time) *IntervalMetrics { + return metrics.NewIntervalMetrics(intv) +} + +func NewInmemSinkFromURL(u *url.URL) (MetricSink, error) { + return metrics.NewInmemSinkFromURL(u) +} + +func NewMetricSinkFromURL(urlStr string) (MetricSink, error) { + return metrics.NewMetricSinkFromURL(urlStr) +} + +func NewStatsdSinkFromURL(u *url.URL) (MetricSink, error) { + return metrics.NewStatsdSinkFromURL(u) +} + +func NewStatsiteSinkFromURL(u *url.URL) (MetricSink, error) { + return metrics.NewStatsiteSinkFromURL(u) +} + +func Default() *Metrics { + return metrics.Default() +} + +func New(conf *Config, sink MetricSink) (*Metrics, error) { + return metrics.New(conf, sink) +} + +func NewGlobal(conf *Config, sink MetricSink) (*Metrics, error) { + return metrics.NewGlobal(conf, sink) +} + +func NewStatsdSink(addr string) (*StatsdSink, error) { + return metrics.NewStatsdSink(addr) +} + +func NewStatsiteSink(addr string) (*StatsiteSink, error) { + return metrics.NewStatsiteSink(addr) +} diff --git a/vendor/github.com/hashicorp/go-metrics/compat/hashicorp.go b/vendor/github.com/hashicorp/go-metrics/compat/hashicorp.go new file mode 100644 index 00000000000..b1fdc2ffe63 --- /dev/null +++ b/vendor/github.com/hashicorp/go-metrics/compat/hashicorp.go @@ -0,0 +1,141 @@ +// Copyright IBM Corp. 2013, 2026 +// SPDX-License-Identifier: MIT + +//go:build hashicorpmetrics + +package metrics + +import ( + "io" + "net/url" + "syscall" + "time" + + "github.com/hashicorp/go-metrics" +) + +const ( + // DefaultSignal is used with DefaultInmemSignal + DefaultSignal = metrics.DefaultSignal +) + +func AddSample(key []string, val float32) { + metrics.AddSample(key, val) +} +func AddSampleWithLabels(key []string, val float32, labels []Label) { + metrics.AddSampleWithLabels(key, val, labels) +} +func EmitKey(key []string, val float32) { + metrics.EmitKey(key, val) +} +func IncrCounter(key []string, val float32) { + metrics.IncrCounter(key, val) +} +func IncrCounterWithLabels(key []string, val float32, labels []Label) { + metrics.IncrCounterWithLabels(key, val, labels) +} +func MeasureSince(key []string, start time.Time) { + metrics.MeasureSince(key, start) +} +func MeasureSinceWithLabels(key []string, start time.Time, labels []Label) { + metrics.MeasureSinceWithLabels(key, start, labels) +} +func SetGauge(key []string, val float32) { + metrics.SetGauge(key, val) +} +func SetGaugeWithLabels(key []string, val float32, labels []Label) { + metrics.SetGaugeWithLabels(key, val, labels) +} +func Shutdown() { + metrics.Shutdown() +} +func UpdateFilter(allow, block []string) { + metrics.UpdateFilter(allow, block) +} +func UpdateFilterAndLabels(allow, block, allowedLabels, blockedLabels []string) { + metrics.UpdateFilterAndLabels(allow, block, allowedLabels, blockedLabels) +} + +type AggregateSample = metrics.AggregateSample +type BlackholeSink = metrics.BlackholeSink +type Config = metrics.Config +type Encoder = metrics.Encoder +type FanoutSink = metrics.FanoutSink +type GaugeValue = metrics.GaugeValue +type InmemSignal = metrics.InmemSignal +type InmemSink = metrics.InmemSink +type IntervalMetrics = metrics.IntervalMetrics +type Label = metrics.Label +type MetricSink = metrics.MetricSink +type Metrics = metrics.Metrics +type MetricsSummary = metrics.MetricsSummary +type PointValue = metrics.PointValue +type SampledValue = metrics.SampledValue +type ShutdownSink = metrics.ShutdownSink +type StatsdSink = metrics.StatsdSink +type StatsiteSink = metrics.StatsiteSink + +func DefaultConfig(serviceName string) *Config { + return metrics.DefaultConfig(serviceName) +} + +func DefaultInmemSignal(inmem *InmemSink) *InmemSignal { + return metrics.DefaultInmemSignal(inmem) +} +func NewInmemSignal(inmem *InmemSink, sig syscall.Signal, w io.Writer) *InmemSignal { + return metrics.NewInmemSignal(inmem, sig, w) +} + +func NewInmemSink(interval, retain time.Duration) *InmemSink { + return metrics.NewInmemSink(interval, retain) +} + +func NewIntervalMetrics(intv time.Time) *IntervalMetrics { + return metrics.NewIntervalMetrics(intv) +} + +func NewInmemSinkFromURL(u *url.URL) (MetricSink, error) { + return metrics.NewInmemSinkFromURL(u) +} + +func NewMetricSinkFromURL(urlStr string) (MetricSink, error) { + return metrics.NewMetricSinkFromURL(urlStr) +} + +func NewStatsdSinkFromURL(u *url.URL) (MetricSink, error) { + return metrics.NewStatsdSinkFromURL(u) +} + +func NewStatsiteSinkFromURL(u *url.URL) (MetricSink, error) { + return metrics.NewStatsiteSinkFromURL(u) +} + +func Default() *Metrics { + return metrics.Default() +} + +func New(conf *Config, sink MetricSink) (*Metrics, error) { + return metrics.New(conf, sink) +} + +func NewGlobal(conf *Config, sink MetricSink) (*Metrics, error) { + return metrics.NewGlobal(conf, sink) +} + +type SinkLogger = metrics.SinkLogger + +func NewStatsdSink(addr string) (*StatsdSink, error) { + return metrics.NewStatsdSink(addr) +} + +func NewStatsdSinkWithLogger(addr string, logger SinkLogger) (*StatsdSink, error) { + return metrics.NewStatsdSinkWithLogger(addr, logger) +} + +func NewStatsiteSink(addr string) (*StatsiteSink, error) { + return metrics.NewStatsiteSink(addr) +} + +func NewStatsiteSinkWithLogger(addr string, logger SinkLogger) (*StatsiteSink, error) { + return metrics.NewStatsiteSinkWithLogger(addr, logger) +} diff --git a/vendor/github.com/hashicorp/go-metrics/statsd.go b/vendor/github.com/hashicorp/go-metrics/statsd.go index 8b5f2c6e847..d1a7b3a7738 100644 --- a/vendor/github.com/hashicorp/go-metrics/statsd.go +++ b/vendor/github.com/hashicorp/go-metrics/statsd.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2013, 2025 +// Copyright IBM Corp. 2013, 2026 // SPDX-License-Identifier: MIT package metrics @@ -19,12 +19,22 @@ const ( statsdMaxLen = 1400 ) +// SinkLogger is a minimal structured logging interface that sink implementations +// use to emit operational error messages. It is satisfied by hclog.Logger and +// any other structured logger that provides Warn and Error methods with +// key/value pair arguments. +type SinkLogger interface { + Warn(msg string, args ...any) + Error(msg string, args ...any) +} + // StatsdSink provides a MetricSink that can be used // with a statsite or statsd metrics server. It uses // only UDP packets, while StatsiteSink uses TCP. type StatsdSink struct { addr string metricQueue chan string + logger SinkLogger } // NewStatsdSinkFromURL creates an StatsdSink from a URL. It is used @@ -43,6 +53,47 @@ func NewStatsdSink(addr string) (*StatsdSink, error) { return s, nil } +// NewStatsdSinkWithLogger is used to create a new StatsdSink with a SinkLogger. +// The logger is set before the background flush goroutine starts, ensuring all +// operational errors are routed through it from the first connection attempt. +func NewStatsdSinkWithLogger(addr string, logger SinkLogger) (*StatsdSink, error) { + s := &StatsdSink{ + addr: addr, + metricQueue: make(chan string, 4096), + logger: logger, + } + go s.flushMetrics() + return s, nil +} + +// SetLogger assigns a SinkLogger to the sink. When set, operational errors +// such as connection failures and flush errors are emitted through the provided +// logger instead of the stdlib log package, allowing callers to control the +// log format and destination. +func (s *StatsdSink) SetLogger(logger SinkLogger) { + s.logger = logger +} + +// logWarn emits a warning through the configured SinkLogger when one is set, +// falling back to stdlib log.Printf otherwise. +func (s *StatsdSink) logWarn(msg string, err error) { + if s.logger != nil { + s.logger.Warn(msg, "error", err) + } else { + log.Printf("[WARN] %s Err: %s", msg, err) + } +} + +// logErr emits an error through the configured SinkLogger when one is set, +// falling back to stdlib log.Printf otherwise. +func (s *StatsdSink) logErr(msg string, err error) { + if s.logger != nil { + s.logger.Error(msg, "error", err) + } else { + log.Printf("[ERR] %s Err: %s", msg, err) + } +} + // Close is used to stop flushing to statsd func (s *StatsdSink) Shutdown() { close(s.metricQueue) @@ -139,7 +190,7 @@ CONNECT: // Attempt to connect sock, err = net.Dial("udp", s.addr) if err != nil { - log.Printf("[ERR] Error connecting to statsd! Err: %s", err) + s.logErr("Error connecting to statsd!", err) goto WAIT } @@ -156,7 +207,7 @@ CONNECT: _, err := sock.Write(buf.Bytes()) buf.Reset() if err != nil { - log.Printf("[ERR] Error writing to statsd! Err: %s", err) + s.logErr("Error writing to statsd!", err) goto WAIT } } @@ -172,7 +223,7 @@ CONNECT: _, err := sock.Write(buf.Bytes()) buf.Reset() if err != nil { - log.Printf("[ERR] Error flushing to statsd! Err: %s", err) + s.logErr("Error flushing to statsd!", err) goto WAIT } } diff --git a/vendor/github.com/hashicorp/go-metrics/statsite.go b/vendor/github.com/hashicorp/go-metrics/statsite.go index 1cb4614bad9..ef089344f02 100644 --- a/vendor/github.com/hashicorp/go-metrics/statsite.go +++ b/vendor/github.com/hashicorp/go-metrics/statsite.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2013, 2025 +// Copyright IBM Corp. 2013, 2026 // SPDX-License-Identifier: MIT package metrics @@ -31,6 +31,7 @@ func NewStatsiteSinkFromURL(u *url.URL) (MetricSink, error) { type StatsiteSink struct { addr string metricQueue chan string + logger SinkLogger } // NewStatsiteSink is used to create a new StatsiteSink @@ -43,6 +44,47 @@ func NewStatsiteSink(addr string) (*StatsiteSink, error) { return s, nil } +// NewStatsiteSinkWithLogger is used to create a new StatsiteSink with a SinkLogger. +// The logger is set before the background flush goroutine starts, ensuring all +// operational errors are routed through it from the first connection attempt. +func NewStatsiteSinkWithLogger(addr string, logger SinkLogger) (*StatsiteSink, error) { + s := &StatsiteSink{ + addr: addr, + metricQueue: make(chan string, 4096), + logger: logger, + } + go s.flushMetrics() + return s, nil +} + +// SetLogger assigns a SinkLogger to the sink. When set, operational errors +// such as connection failures and flush errors are emitted through the provided +// logger instead of the stdlib log package, allowing callers to control the +// log format and destination. +func (s *StatsiteSink) SetLogger(logger SinkLogger) { + s.logger = logger +} + +// logWarn emits a warning through the configured SinkLogger when one is set, +// falling back to stdlib log.Printf otherwise. +func (s *StatsiteSink) logWarn(msg string, err error) { + if s.logger != nil { + s.logger.Warn(msg, "error", err) + } else { + log.Printf("[WARN] %s Err: %s", msg, err) + } +} + +// logErr emits an error through the configured SinkLogger when one is set, +// falling back to stdlib log.Printf otherwise. +func (s *StatsiteSink) logErr(msg string, err error) { + if s.logger != nil { + s.logger.Error(msg, "error", err) + } else { + log.Printf("[ERR] %s Err: %s", msg, err) + } +} + // Close is used to stop flushing to statsite func (s *StatsiteSink) Shutdown() { close(s.metricQueue) @@ -137,7 +179,7 @@ CONNECT: // Attempt to connect sock, err = net.Dial("tcp", s.addr) if err != nil { - log.Printf("[ERR] Error connecting to statsite! Err: %s", err) + s.logErr("Error connecting to statsite!", err) goto WAIT } @@ -155,12 +197,12 @@ CONNECT: // Try to send to statsite _, err := buffered.Write([]byte(metric)) if err != nil { - log.Printf("[ERR] Error writing to statsite! Err: %s", err) + s.logErr("Error writing to statsite!", err) goto WAIT } case <-ticker.C: if err := buffered.Flush(); err != nil { - log.Printf("[ERR] Error flushing to statsite! Err: %s", err) + s.logErr("Error flushing to statsite!", err) goto WAIT } } diff --git a/vendor/github.com/hashicorp/serf/LICENSE b/vendor/github.com/hashicorp/serf/LICENSE index c33dcc7c928..bfbd0aa577d 100644 --- a/vendor/github.com/hashicorp/serf/LICENSE +++ b/vendor/github.com/hashicorp/serf/LICENSE @@ -1,3 +1,5 @@ +Copyright IBM Corp. 2013, 2026 + Mozilla Public License, version 2.0 1. Definitions diff --git a/vendor/github.com/hashicorp/serf/coordinate/client.go b/vendor/github.com/hashicorp/serf/coordinate/client.go index 32124a73a20..d940987b2b9 100644 --- a/vendor/github.com/hashicorp/serf/coordinate/client.go +++ b/vendor/github.com/hashicorp/serf/coordinate/client.go @@ -1,3 +1,6 @@ +// Copyright IBM Corp. 2013, 2026 +// SPDX-License-Identifier: MPL-2.0 + package coordinate import ( @@ -7,7 +10,7 @@ import ( "sync" "time" - "github.com/armon/go-metrics" + metrics "github.com/hashicorp/go-metrics/compat" ) // Client manages the estimated network coordinate for a given node, and adjusts @@ -52,7 +55,7 @@ type ClientStats struct { // NewClient creates a new Client and verifies the configuration is valid. func NewClient(config *Config) (*Client, error) { - if !(config.Dimensionality > 0) { + if config.Dimensionality == 0 { return nil, fmt.Errorf("dimensionality must be >0") } diff --git a/vendor/github.com/hashicorp/serf/coordinate/config.go b/vendor/github.com/hashicorp/serf/coordinate/config.go index 09c0cafe830..0adcac24451 100644 --- a/vendor/github.com/hashicorp/serf/coordinate/config.go +++ b/vendor/github.com/hashicorp/serf/coordinate/config.go @@ -1,7 +1,12 @@ +// Copyright IBM Corp. 2013, 2026 +// SPDX-License-Identifier: MPL-2.0 + package coordinate import ( - "github.com/armon/go-metrics" + "math/rand" + + metrics "github.com/hashicorp/go-metrics/compat" ) // Config is used to set the parameters of the Vivaldi-based coordinate mapping @@ -11,12 +16,17 @@ import ( // here: // // [1] Dabek, Frank, et al. "Vivaldi: A decentralized network coordinate system." -// ACM SIGCOMM Computer Communication Review. Vol. 34. No. 4. ACM, 2004. +// +// ACM SIGCOMM Computer Communication Review. Vol. 34. No. 4. ACM, 2004. +// // [2] Ledlie, Jonathan, Paul Gardner, and Margo I. Seltzer. "Network Coordinates -// in the Wild." NSDI. Vol. 7. 2007. +// +// in the Wild." NSDI. Vol. 7. 2007. +// // [3] Lee, Sanghwan, et al. "On suitability of Euclidean embedding for -// host-based network coordinate systems." Networking, IEEE/ACM Transactions -// on 18.1 (2010): 27-40. +// +// host-based network coordinate systems." Networking, IEEE/ACM Transactions +// on 18.1 (2010): 27-40. type Config struct { // The dimensionality of the coordinate system. As discussed in [2], more // dimensions improves the accuracy of the estimates up to a point. Per [2] @@ -59,6 +69,8 @@ type Config struct { // metricLabels is the slice of labels to put on all emitted metrics MetricLabels []metrics.Label + + rand *rand.Rand } // DefaultConfig returns a Config that has some default values suitable for @@ -73,5 +85,6 @@ func DefaultConfig() *Config { HeightMin: 10.0e-6, LatencyFilterSize: 3, GravityRho: 150.0, + rand: nil, } } diff --git a/vendor/github.com/hashicorp/serf/coordinate/coordinate.go b/vendor/github.com/hashicorp/serf/coordinate/coordinate.go index fbe792c90d4..09aae3d111f 100644 --- a/vendor/github.com/hashicorp/serf/coordinate/coordinate.go +++ b/vendor/github.com/hashicorp/serf/coordinate/coordinate.go @@ -1,3 +1,6 @@ +// Copyright IBM Corp. 2013, 2026 +// SPDX-License-Identifier: MPL-2.0 + package coordinate import ( @@ -107,7 +110,7 @@ func (c *Coordinate) ApplyForce(config *Config, force float64, other *Coordinate } ret := c.Clone() - unit, mag := unitVectorAt(c.Vec, other.Vec) + unit, mag := unitVectorAt(config.rand, c.Vec, other.Vec) ret.Vec = add(ret.Vec, mul(unit, force)) if mag > zeroThreshold { ret.Height = (ret.Height+other.Height)*force/mag + ret.Height @@ -179,7 +182,7 @@ func magnitude(vec []float64) float64 { // unitVectorAt returns a unit vector pointing at vec1 from vec2. If the two // positions are the same then a random unit vector is returned. We also return // the distance between the points for use in the later height calculation. -func unitVectorAt(vec1 []float64, vec2 []float64) ([]float64, float64) { +func unitVectorAt(rng *rand.Rand, vec1 []float64, vec2 []float64) ([]float64, float64) { ret := diff(vec1, vec2) // If the coordinates aren't on top of each other we can normalize. @@ -189,7 +192,11 @@ func unitVectorAt(vec1 []float64, vec2 []float64) ([]float64, float64) { // Otherwise, just return a random unit vector. for i := range ret { - ret[i] = rand.Float64() - 0.5 + if rng != nil { + ret[i] = rng.Float64() - 0.5 + } else { + ret[i] = rand.Float64() - 0.5 + } } if mag := magnitude(ret); mag > zeroThreshold { return mul(ret, 1.0/mag), 0.0 diff --git a/vendor/github.com/hashicorp/serf/coordinate/phantom.go b/vendor/github.com/hashicorp/serf/coordinate/phantom.go index 66da4e2e92e..4dcdbb66222 100644 --- a/vendor/github.com/hashicorp/serf/coordinate/phantom.go +++ b/vendor/github.com/hashicorp/serf/coordinate/phantom.go @@ -1,3 +1,6 @@ +// Copyright IBM Corp. 2013, 2026 +// SPDX-License-Identifier: MPL-2.0 + package coordinate import ( @@ -30,7 +33,7 @@ func GenerateLine(nodes int, spacing time.Duration) [][]time.Duration { truth[i] = make([]time.Duration, nodes) } - for i := 0; i < nodes; i++ { + for i := range nodes { for j := i + 1; j < nodes; j++ { rtt := time.Duration(j-i) * spacing truth[i][j], truth[j][i] = rtt, rtt @@ -48,7 +51,7 @@ func GenerateGrid(nodes int, spacing time.Duration) [][]time.Duration { } n := int(math.Sqrt(float64(nodes))) - for i := 0; i < nodes; i++ { + for i := range nodes { for j := i + 1; j < nodes; j++ { x1, y1 := float64(i%n), float64(i/n) x2, y2 := float64(j%n), float64(j/n) @@ -72,7 +75,7 @@ func GenerateSplit(nodes int, lan time.Duration, wan time.Duration) [][]time.Dur } split := nodes / 2 - for i := 0; i < nodes; i++ { + for i := range nodes { for j := i + 1; j < nodes; j++ { rtt := lan if (i <= split && j > split) || (i > split && j <= split) { @@ -94,7 +97,7 @@ func GenerateCircle(nodes int, radius time.Duration) [][]time.Duration { truth[i] = make([]time.Duration, nodes) } - for i := 0; i < nodes; i++ { + for i := range nodes { for j := i + 1; j < nodes; j++ { var rtt time.Duration if i == 0 { @@ -118,16 +121,16 @@ func GenerateCircle(nodes int, radius time.Duration) [][]time.Duration { // distributed delays, with the given mean and deviation. The RNG is re-seeded // so you always get the same matrix for a given size. func GenerateRandom(nodes int, mean time.Duration, deviation time.Duration) [][]time.Duration { - rand.Seed(1) + rng := rand.New(rand.NewSource(1)) truth := make([][]time.Duration, nodes) for i := range truth { truth[i] = make([]time.Duration, nodes) } - for i := 0; i < nodes; i++ { + for i := range nodes { for j := i + 1; j < nodes; j++ { - rttSeconds := rand.NormFloat64()*deviation.Seconds() + mean.Seconds() + rttSeconds := rng.NormFloat64()*deviation.Seconds() + mean.Seconds() rtt := time.Duration(rttSeconds * secondsToNanoseconds) truth[i][j], truth[j][i] = rtt, rtt } @@ -142,16 +145,16 @@ func GenerateRandom(nodes int, mean time.Duration, deviation time.Duration) [][] // underlying algorithm which will use random numbers for position vectors when // starting out with everything at the origin). func Simulate(clients []*Client, truth [][]time.Duration, cycles int) { - rand.Seed(1) + rng := rand.New(rand.NewSource(1)) nodes := len(clients) - for cycle := 0; cycle < cycles; cycle++ { + for range cycles { for i := range clients { - if j := rand.Intn(nodes); j != i { + if j := rng.Intn(nodes); j != i { c := clients[j].GetCoordinate() rtt := truth[i][j] node := fmt.Sprintf("node_%d", j) - clients[i].Update(node, c, rtt) + _, _ = clients[i].Update(node, c, rtt) } } } @@ -168,9 +171,12 @@ type Stats struct { // distances and compares them with the given truth matrix, returning summary // stats. func Evaluate(clients []*Client, truth [][]time.Duration) (stats Stats) { + if len(clients) <= 1 { + return + } nodes := len(clients) count := 0 - for i := 0; i < nodes; i++ { + for i := range nodes { for j := i + 1; j < nodes; j++ { est := clients[i].DistanceTo(clients[j].GetCoordinate()).Seconds() actual := truth[i][j].Seconds() diff --git a/vendor/github.com/klauspost/compress/README.md b/vendor/github.com/klauspost/compress/README.md index fb023f2cf21..0e9f170d012 100644 --- a/vendor/github.com/klauspost/compress/README.md +++ b/vendor/github.com/klauspost/compress/README.md @@ -27,6 +27,18 @@ Use the links above for more information on each. # changelog +* Jul 1st, 2026 [1.19.0](https://github.com/klauspost/compress/releases/tag/v1.19.0) + * zstd: Add true concurrent stream encodingin https://github.com/klauspost/compress/pull/1136 + * zstd: arm64 decoder asm by @lizthegrey in https://github.com/klauspost/compress/pull/1160 + * flate: Add inflate checkpoints in https://github.com/klauspost/compress/pull/1154 + * zstd: avoid unused BuildDict encoder allocation by @snissn in https://github.com/klauspost/compress/pull/1147 + * snappy/s2: Limit length of varint in `decodedLen` by @eustas in https://github.com/klauspost/compress/pull/1148 + * gzhttp: match qvalue parameter case-insensitively (RFC 7231) by @z9z in https://github.com/klauspost/compress/pull/1149 + * zip: add NameDecoder callback for legacy encoding rewrite by @SAY-5 in https://github.com/klauspost/compress/pull/1150 + * huff0: Allow building tables from histogram in https://github.com/klauspost/compress/pull/1155 + * huff0: Allow building table from oversized histogram in https://github.com/klauspost/compress/pull/1156 + * s2sx: Clean symlink targets in https://github.com/klauspost/compress/pull/1163 + * Feb 9th, 2026 [1.18.4](https://github.com/klauspost/compress/releases/tag/v1.18.4) * gzhttp: Add zstandard to server handler wrapper https://github.com/klauspost/compress/pull/1121 * zstd: Add ResetWithOptions to encoder/decoder https://github.com/klauspost/compress/pull/1122 diff --git a/vendor/github.com/klauspost/compress/flate/dict_decoder.go b/vendor/github.com/klauspost/compress/flate/dict_decoder.go index cb855abc4ba..37861cf6afb 100644 --- a/vendor/github.com/klauspost/compress/flate/dict_decoder.go +++ b/vendor/github.com/klauspost/compress/flate/dict_decoder.go @@ -28,9 +28,10 @@ type dictDecoder struct { hist []byte // Sliding window history // Invariant: 0 <= rdPos <= wrPos <= len(hist) - wrPos int // Current output position in buffer - rdPos int // Have emitted hist[:rdPos] already - full bool // Has a full window length been written yet? + wrPos int // Current output position in buffer + rdPos int // Have emitted hist[:rdPos] already + flushed int64 // Total bytes returned by readFlush since init + full bool // Has a full window length been written yet? } // init initializes dictDecoder to have a sliding window dictionary of the given @@ -167,11 +168,22 @@ loop: return dstPos - dstBase } +// appendWindow appends the current sliding window (up to len(hist) most recent +// bytes, oldest first) to dst. +func (dd *dictDecoder) appendWindow(dst []byte) []byte { + if dd.full { + dst = append(dst, dd.hist[dd.wrPos:]...) + return append(dst, dd.hist[:dd.wrPos]...) + } + return append(dst, dd.hist[:dd.wrPos]...) +} + // readFlush returns a slice of the historical buffer that is ready to be // emitted to the user. The data returned by readFlush must be fully consumed // before calling any other dictDecoder methods. func (dd *dictDecoder) readFlush() []byte { toRead := dd.hist[dd.rdPos:dd.wrPos] + dd.flushed += int64(len(toRead)) dd.rdPos = dd.wrPos if dd.wrPos == len(dd.hist) { dd.wrPos, dd.rdPos = 0, 0 @@ -179,3 +191,9 @@ func (dd *dictDecoder) readFlush() []byte { } return toRead } + +// decoded reports the total number of bytes written into the dictionary since +// init (i.e. excluding any preset dict bytes). +func (dd *dictDecoder) decoded() int64 { + return dd.flushed + int64(dd.wrPos-dd.rdPos) +} diff --git a/vendor/github.com/klauspost/compress/flate/inflate.go b/vendor/github.com/klauspost/compress/flate/inflate.go index 6e90126db03..39dd683b2dd 100644 --- a/vendor/github.com/klauspost/compress/flate/inflate.go +++ b/vendor/github.com/klauspost/compress/flate/inflate.go @@ -342,6 +342,11 @@ type decompressor struct { final bool flushMode flushMode + cb func(InflateCheckpoint) + cp InflateCheckpoint + hasCP bool // WithResumeFrom was supplied + uncOffset int64 // baseline uncompressed offset (from a resume checkpoint) + cpBuf []byte } func (f *decompressor) nextBlock() { @@ -676,6 +681,18 @@ func (f *decompressor) finishBlock() { f.toRead = f.dict.readFlush() } + if f.cb != nil { + bitPos := f.roffset*8 - int64(f.nb) + f.cpBuf = f.dict.appendWindow(f.cpBuf[:0]) + f.cb(InflateCheckpoint{ + UncompressedOffset: f.uncOffset + f.dict.decoded(), + CompressedOffset: bitPos / 8, + Final: f.final, + BitOffset: uint8(bitPos & 7), + Window: f.cpBuf, + }) + } + f.step = nextBlock } @@ -806,6 +823,45 @@ func (f *decompressor) Reset(r io.Reader, dict []byte) error { return nil } +// ResetCP will adjust the input to the provided checkpoint. +// It is assumed the input stream is forwarded to cp.CompressedOffset. +func (f *decompressor) ResetCP(r io.Reader, cp InflateCheckpoint) error { + *f = decompressor{ + r: makeReader(r), + bits: f.bits, + codebits: f.codebits, + h1: f.h1, + h2: f.h2, + dict: f.dict, + step: nextBlock, + cpBuf: f.cpBuf, + } + return f.applyCP(cp) +} + +// applyCP seeds the decompressor state from a resume checkpoint: +// loads the sliding window, sets the absolute compressed/uncompressed +// offsets, and skips cp.BitOffset bits into the first input byte so +// the next decode aligns with the start of a deflate block. +func (f *decompressor) applyCP(cp InflateCheckpoint) error { + f.dict.init(maxMatchOffset, cp.Window) + f.roffset = cp.CompressedOffset + f.uncOffset = cp.UncompressedOffset + f.final = cp.Final + f.b = 0 + f.nb = 0 + if cp.BitOffset > 0 { + c, err := f.r.ReadByte() + if err != nil { + return noEOF(err) + } + f.roffset++ + f.b = uint32(c) >> cp.BitOffset + f.nb = 8 - uint(cp.BitOffset) + } + return nil +} + type ReaderOpt func(*decompressor) // WithPartialBlock tells decompressor to return after each block, @@ -823,6 +879,36 @@ func WithDict(dict []byte) ReaderOpt { } } +// InflateCheckpoint provides a resumable checkpoint for inflate. +type InflateCheckpoint struct { + UncompressedOffset int64 // Byte offset in the decompressed stream + CompressedOffset int64 // Byte offset in the compressed stream + Final bool // True if this is the final block + BitOffset uint8 // 0-7 bits + Window []byte // 32KB sliding window dictionary +} + +// WithEobCallback will call the provided function after each block +// with the current gzip checkpoint. +// After returning the provided window can no longer be referenced. +// The callback will not be triggered after a block is marked "final". +// The callback is not retained after Reset. +func WithEobCallback(cb func(InflateCheckpoint)) ReaderOpt { + return func(f *decompressor) { + f.cb = cb + } +} + +// WithResumeFrom will adjust the input to the provided checkpoint. +// It is assumed the input stream is forwarded to the provided offset. +// The checkpoint is removed when Reset is called. +func WithResumeFrom(cp InflateCheckpoint) ReaderOpt { + return func(f *decompressor) { + f.cp = cp + f.hasCP = true + } +} + // NewReaderOpts returns new reader with provided options func NewReaderOpts(r io.Reader, opts ...ReaderOpt) io.ReadCloser { fixedHuffmanDecoderInit() @@ -838,6 +924,12 @@ func NewReaderOpts(r io.Reader, opts ...ReaderOpt) io.ReadCloser { opt(&f) } + if f.hasCP { + if err := f.applyCP(f.cp); err != nil { + f.err = err + } + } + return &f } diff --git a/vendor/github.com/klauspost/compress/flate/inflate_gen.go b/vendor/github.com/klauspost/compress/flate/inflate_gen.go index 2b2f993f753..e80f1965609 100644 --- a/vendor/github.com/klauspost/compress/flate/inflate_gen.go +++ b/vendor/github.com/klauspost/compress/flate/inflate_gen.go @@ -10,6 +10,15 @@ import ( "strings" ) +func peekBufio(fr *bufio.Reader) ([]byte, error) { + if fr.Buffered() == 0 { + if _, err := fr.Peek(1); err != nil && fr.Buffered() == 0 { + return nil, err + } + } + return fr.Peek(fr.Buffered()) +} + // Decode a single Huffman block from f. // hl and hd are the Huffman states for the lit/length values // and the distance values, respectively. If hd == nil, using the @@ -527,6 +536,8 @@ func (f *decompressor) huffmanBufioReader() { // but is smart enough to keep local variables in registers, so use nb and b, // inline call to moreBits and reassign b,nb back to f on return. fnb, fb, dict := f.nb, f.b, &f.dict + pbuf, _ := fr.Peek(fr.Buffered()) + pos := 0 switch f.stepState { case stateInit: @@ -548,12 +559,19 @@ readLiteral: n := uint(f.hl.maxRead) for { for fnb < n { - c, err := fr.ReadByte() - if err != nil { - f.b, f.nb = fb, fnb - f.err = noEOF(err) - return + if pos >= len(pbuf) { + fr.Discard(pos) + var err error + pbuf, err = peekBufio(fr) + pos = 0 + if len(pbuf) == 0 { + f.b, f.nb = fb, fnb + f.err = noEOF(err) + return + } } + c := pbuf[pos] + pos++ f.roffset++ fb |= uint32(c) << (fnb & regSizeMaskUint32) fnb += 8 @@ -566,6 +584,7 @@ readLiteral: } if n <= fnb { if n == 0 { + fr.Discard(pos) f.b, f.nb = fb, fnb if debugDecode { fmt.Println("huffsym: n==0") @@ -586,6 +605,7 @@ readLiteral: case v < 256: dict.writeByte(byte(v)) if dict.availWrite() == 0 { + fr.Discard(pos) f.toRead = dict.readFlush() f.step = huffmanBufioReader f.stepState = stateInit @@ -594,6 +614,7 @@ readLiteral: } goto readLiteral case v == 256: + fr.Discard(pos) f.b, f.nb = fb, fnb f.finishBlock() return @@ -605,15 +626,22 @@ readLiteral: length = int(val.length) + 3 n := uint(val.extra) for fnb < n { - c, err := fr.ReadByte() - if err != nil { - f.b, f.nb = fb, fnb - if debugDecode { - fmt.Println("morebits n>0:", err) + if pos >= len(pbuf) { + fr.Discard(pos) + var err error + pbuf, err = peekBufio(fr) + pos = 0 + if len(pbuf) == 0 { + f.b, f.nb = fb, fnb + if debugDecode { + fmt.Println("morebits n>0:", err) + } + f.err = err + return } - f.err = err - return } + c := pbuf[pos] + pos++ f.roffset++ fb |= uint32(c) << (fnb & regSizeMaskUint32) fnb += 8 @@ -622,6 +650,7 @@ readLiteral: fb >>= n & regSizeMaskUint32 fnb -= n default: + fr.Discard(pos) if debugDecode { fmt.Println(v, ">= maxNumLit") } @@ -633,15 +662,22 @@ readLiteral: var dist uint32 if f.hd == nil { for fnb < 5 { - c, err := fr.ReadByte() - if err != nil { - f.b, f.nb = fb, fnb - if debugDecode { - fmt.Println("morebits f.nb<5:", err) + if pos >= len(pbuf) { + fr.Discard(pos) + var err error + pbuf, err = peekBufio(fr) + pos = 0 + if len(pbuf) == 0 { + f.b, f.nb = fb, fnb + if debugDecode { + fmt.Println("morebits f.nb<5:", err) + } + f.err = err + return } - f.err = err - return } + c := pbuf[pos] + pos++ f.roffset++ fb |= uint32(c) << (fnb & regSizeMaskUint32) fnb += 8 @@ -660,12 +696,19 @@ readLiteral: // inline call to moreBits and reassign b,nb back to f on return. for { for fnb < n { - c, err := fr.ReadByte() - if err != nil { - f.b, f.nb = fb, fnb - f.err = noEOF(err) - return + if pos >= len(pbuf) { + fr.Discard(pos) + var err error + pbuf, err = peekBufio(fr) + pos = 0 + if len(pbuf) == 0 { + f.b, f.nb = fb, fnb + f.err = noEOF(err) + return + } } + c := pbuf[pos] + pos++ f.roffset++ fb |= uint32(c) << (fnb & regSizeMaskUint32) fnb += 8 @@ -678,6 +721,7 @@ readLiteral: } if n <= fnb { if n == 0 { + fr.Discard(pos) f.b, f.nb = fb, fnb if debugDecode { fmt.Println("huffsym: n==0") @@ -701,15 +745,22 @@ readLiteral: // have 1 bit in bottom of dist, need nb more. extra := (dist & 1) << (nb & regSizeMaskUint32) for fnb < nb { - c, err := fr.ReadByte() - if err != nil { - f.b, f.nb = fb, fnb - if debugDecode { - fmt.Println("morebits f.nb= len(pbuf) { + fr.Discard(pos) + var err error + pbuf, err = peekBufio(fr) + pos = 0 + if len(pbuf) == 0 { + f.b, f.nb = fb, fnb + if debugDecode { + fmt.Println("morebits f.nb uint32(dict.histSize()) { + fr.Discard(pos) f.b, f.nb = fb, fnb if debugDecode { fmt.Println("dist > dict.histSize():", dist, dict.histSize()) @@ -752,6 +805,7 @@ copyHistory: f.copyLen -= cnt if dict.availWrite() == 0 || f.copyLen > 0 { + fr.Discard(pos) f.toRead = dict.readFlush() f.step = huffmanBufioReader // We need to continue this work f.stepState = stateDict diff --git a/vendor/github.com/klauspost/compress/gzhttp/compress.go b/vendor/github.com/klauspost/compress/gzhttp/compress.go index 0f84b28ec83..da5048ef240 100644 --- a/vendor/github.com/klauspost/compress/gzhttp/compress.go +++ b/vendor/github.com/klauspost/compress/gzhttp/compress.go @@ -1158,8 +1158,8 @@ func parseCoding(s string) (coding string, qvalue float64, err error) { if n == 0 { coding = strings.ToLower(part) - } else if after, ok := strings.CutPrefix(part, "q="); ok { - qvalue, err = strconv.ParseFloat(after, 64) + } else if len(part) >= 2 && strings.EqualFold(part[:2], "q=") { + qvalue, err = strconv.ParseFloat(part[2:], 64) if qvalue < 0.0 { qvalue = 0.0 diff --git a/vendor/github.com/klauspost/compress/huff0/build_table.go b/vendor/github.com/klauspost/compress/huff0/build_table.go new file mode 100644 index 00000000000..e3757c87e0f --- /dev/null +++ b/vendor/github.com/klauspost/compress/huff0/build_table.go @@ -0,0 +1,168 @@ +package huff0 + +import "errors" + +// BuildCTable builds a Huffman compression table from a precomputed symbol +// histogram and installs it as the previous (reuse) table on s. +// +// After this call: +// - EstimateSize/CanUseTable can probe the table against other histograms. +// - Compress1X/Compress4X with Reuse = ReusePolicyMust will encode without +// emitting a new table header. +// - TransferCTable can hand the table to a sibling Scratch. +// +// count[i] is the number of occurrences of symbol i. The histogram must have +// at least 2 distinct non-zero symbols; ErrUseRLE is returned for a single +// symbol and an error is returned for an empty histogram. +func (s *Scratch) BuildCTable(count *[256]uint32) error { + if s == nil { + return errors.New("huff0: BuildCTable on nil Scratch") + } + if count == nil { + return errors.New("huff0: nil count passed to BuildCTable") + } + var err error + s, err = s.prepare(nil) + if err != nil { + return err + } + s.count = *count + var total, maxCount int + var symLen uint16 + for i, v := range s.count { + total += int(v) + if int(v) > maxCount { + maxCount = int(v) + } + if v != 0 { + symLen = uint16(i) + 1 + } + } + if total == 0 { + return errors.New("huff0: empty histogram") + } + if symLen < 2 || maxCount == total { + return ErrUseRLE + } + // huff0's internal rank table assumes total ≤ BlockSizeMax (it uses + // highBit32(count+1) + 1 as a rank index into a fixed-size array). + // Histograms summed across multiple blocks can exceed that; scale the + // counts down preserving the distribution. Non-zero entries round up so + // rare symbols stay representable. + if total > BlockSizeMax { + shift := uint(0) + for total>>shift > BlockSizeMax { + shift++ + } + round := uint32(1<> shift + if scaled == 0 { + scaled = 1 + } + s.count[i] = scaled + newTotal += int(scaled) + if int(scaled) > newMax { + newMax = int(scaled) + } + } + total = newTotal + maxCount = newMax + if maxCount == total { + return ErrUseRLE + } + } + s.symbolLen = symLen + s.maxCount = maxCount + s.srcLen = total + if err := s.buildCTable(); err != nil { + return err + } + if cap(s.prevTable) < len(s.cTable) { + s.prevTable = make(cTable, 0, maxSymbolValue+1) + } + s.prevTable = s.prevTable[:len(s.cTable)] + copy(s.prevTable, s.cTable) + s.prevTableLog = s.actualTableLog + // Force the next Compress* to recount from real input. + s.clearCount = true + s.maxCount = 0 + return nil +} + +// EstimateSize returns an estimated compressed payload size in bytes for the +// supplied histogram using the table currently stored in prevTable. It returns +// -1 when the table cannot encode every non-zero symbol of hist (i.e. when +// CanUseTable would return false). The estimate excludes the table header. +func (s *Scratch) EstimateSize(hist *[256]uint32) int { + if s == nil || hist == nil || len(s.prevTable) == 0 { + return -1 + } + pt := s.prevTable + nbBits := uint32(7) + for i, v := range hist { + if v == 0 { + continue + } + if i >= len(pt) || pt[i].nBits == 0 { + return -1 + } + nbBits += uint32(pt[i].nBits) * v + } + return int(nbBits >> 3) +} + +// CanUseTable reports whether the table in prevTable can encode every +// non-zero symbol present in hist. +func (s *Scratch) CanUseTable(hist *[256]uint32) bool { + if s == nil || hist == nil || len(s.prevTable) == 0 { + return false + } + pt := s.prevTable + for i, v := range hist { + if v == 0 { + continue + } + if i >= len(pt) || pt[i].nBits == 0 { + return false + } + } + return true +} + +// AppendTable serializes the table currently stored in prevTable (e.g. as +// installed by BuildCTable or carried over from a previous Compress call) +// into a self-delimiting zstd-style header and appends it to dst. The +// returned slice can be parsed back by ReadTable. +func (s *Scratch) AppendTable(dst []byte) ([]byte, error) { + if s == nil || len(s.prevTable) == 0 { + return dst, errors.New("huff0: AppendTable with empty table") + } + // cTable.write reads s.actualTableLog, s.symbolLen, s.huffWeight, s.fse + // and writes into s.Out. Save/restore Out so we don't disturb in-flight + // compression buffers. + saveOut := s.Out + saveTL := s.actualTableLog + saveSL := s.symbolLen + if s.fse == nil { + // Lazily init in case AppendTable is called on a fresh Scratch. + if _, err := s.prepare(nil); err != nil { + return dst, err + } + saveOut = s.Out + } + s.Out = s.Out[:0] + s.actualTableLog = s.prevTableLog + s.symbolLen = uint16(len(s.prevTable)) + if err := s.prevTable.write(s); err != nil { + s.Out, s.actualTableLog, s.symbolLen = saveOut, saveTL, saveSL + return dst, err + } + dst = append(dst, s.Out...) + s.Out, s.actualTableLog, s.symbolLen = saveOut, saveTL, saveSL + return dst, nil +} diff --git a/vendor/github.com/klauspost/compress/huff0/decompress_amd64.go b/vendor/github.com/klauspost/compress/huff0/decompress_amd64.go index 2d6ef64be15..7035d656d99 100644 --- a/vendor/github.com/klauspost/compress/huff0/decompress_amd64.go +++ b/vendor/github.com/klauspost/compress/huff0/decompress_amd64.go @@ -1,222 +1,49 @@ //go:build amd64 && !appengine && !noasm && gc -// This file contains the specialisation of Decoder.Decompress4X -// and Decoder.Decompress1X that use an asm implementation of thir main loops. +// amd64 stubs and dispatch for the asm loops used by decompress_asm.go. package huff0 import ( - "errors" - "fmt" - "github.com/klauspost/compress/internal/cpuinfo" ) -// decompress4x_main_loop_x86 is an x86 assembler implementation +// decompress4x_main_loop_amd64 is an x86 assembler implementation // of Decompress4X when tablelog > 8. // //go:noescape func decompress4x_main_loop_amd64(ctx *decompress4xContext) -// decompress4x_8b_loop_x86 is an x86 assembler implementation +// decompress4x_8b_main_loop_amd64 is an x86 assembler implementation // of Decompress4X when tablelog <= 8 which decodes 4 entries // per loop. // //go:noescape func decompress4x_8b_main_loop_amd64(ctx *decompress4xContext) -// fallback8BitSize is the size where using Go version is faster. -const fallback8BitSize = 800 - -type decompress4xContext struct { - pbr *[4]bitReaderShifted - peekBits uint8 - out *byte - dstEvery int - tbl *dEntrySingle - decoded int - limit *byte -} - -// Decompress4X will decompress a 4X encoded stream. -// The length of the supplied input must match the end of a block exactly. -// The *capacity* of the dst slice must match the destination size of -// the uncompressed data exactly. -func (d *Decoder) Decompress4X(dst, src []byte) ([]byte, error) { - if len(d.dt.single) == 0 { - return nil, errors.New("no table loaded") - } - if len(src) < 6+(4*1) { - return nil, errors.New("input too small") - } - - use8BitTables := d.actualTableLog <= 8 - if cap(dst) < fallback8BitSize && use8BitTables { - return d.decompress4X8bit(dst, src) - } - - var br [4]bitReaderShifted - // Decode "jump table" - start := 6 - for i := range 3 { - length := int(src[i*2]) | (int(src[i*2+1]) << 8) - if start+length >= len(src) { - return nil, errors.New("truncated input (or invalid offset)") - } - err := br[i].init(src[start : start+length]) - if err != nil { - return nil, err - } - start += length - } - err := br[3].init(src[start:]) - if err != nil { - return nil, err - } - - // destination, offset to match first output - dstSize := cap(dst) - dst = dst[:dstSize] - out := dst - dstEvery := (dstSize + 3) / 4 - - const tlSize = 1 << tableLogMax - const tlMask = tlSize - 1 - single := d.dt.single[:tlSize] - - var decoded int - - if len(out) > 4*4 && !(br[0].off < 4 || br[1].off < 4 || br[2].off < 4 || br[3].off < 4) { - ctx := decompress4xContext{ - pbr: &br, - peekBits: uint8((64 - d.actualTableLog) & 63), // see: bitReaderShifted.peekBitsFast() - out: &out[0], - dstEvery: dstEvery, - tbl: &single[0], - limit: &out[dstEvery-4], // Always stop decoding when first buffer gets here to avoid writing OOB on last. - } - if use8BitTables { - decompress4x_8b_main_loop_amd64(&ctx) - } else { - decompress4x_main_loop_amd64(&ctx) - } - - decoded = ctx.decoded - out = out[decoded/4:] - } - - // Decode remaining. - remainBytes := dstEvery - (decoded / 4) - for i := range br { - offset := dstEvery * i - endsAt := min(offset+remainBytes, len(out)) - br := &br[i] - bitsLeft := br.remaining() - for bitsLeft > 0 { - br.fill() - if offset >= endsAt { - return nil, errors.New("corruption detected: stream overrun 4") - } - - // Read value and increment offset. - val := br.peekBitsFast(d.actualTableLog) - v := single[val&tlMask].entry - nBits := uint8(v) - br.advance(nBits) - bitsLeft -= uint(nBits) - out[offset] = uint8(v >> 8) - offset++ - } - if offset != endsAt { - return nil, fmt.Errorf("corruption detected: short output block %d, end %d != %d", i, offset, endsAt) - } - decoded += offset - dstEvery*i - err = br.close() - if err != nil { - return nil, err - } - } - if dstSize != decoded { - return nil, errors.New("corruption detected: short output block") - } - return dst, nil -} - -// decompress4x_main_loop_x86 is an x86 assembler implementation +// decompress1x_main_loop_amd64 is an x86 assembler implementation // of Decompress1X when tablelog > 8. // //go:noescape func decompress1x_main_loop_amd64(ctx *decompress1xContext) -// decompress4x_main_loop_x86 is an x86 with BMI2 assembler implementation +// decompress1x_main_loop_bmi2 is an x86 with BMI2 assembler implementation // of Decompress1X when tablelog > 8. // //go:noescape func decompress1x_main_loop_bmi2(ctx *decompress1xContext) -type decompress1xContext struct { - pbr *bitReaderShifted - peekBits uint8 - out *byte - outCap int - tbl *dEntrySingle - decoded int +func decompress4x_main_loop_asm(ctx *decompress4xContext) { + decompress4x_main_loop_amd64(ctx) } -// Error reported by asm implementations -const error_max_decoded_size_exeeded = -1 - -// Decompress1X will decompress a 1X encoded stream. -// The cap of the output buffer will be the maximum decompressed size. -// The length of the supplied input must match the end of a block exactly. -func (d *Decoder) Decompress1X(dst, src []byte) ([]byte, error) { - if len(d.dt.single) == 0 { - return nil, errors.New("no table loaded") - } - var br bitReaderShifted - err := br.init(src) - if err != nil { - return dst, err - } - maxDecodedSize := cap(dst) - dst = dst[:maxDecodedSize] - - const tlSize = 1 << tableLogMax - const tlMask = tlSize - 1 - - if maxDecodedSize >= 4 { - ctx := decompress1xContext{ - pbr: &br, - out: &dst[0], - outCap: maxDecodedSize, - peekBits: uint8((64 - d.actualTableLog) & 63), // see: bitReaderShifted.peekBitsFast() - tbl: &d.dt.single[0], - } - - if cpuinfo.HasBMI2() { - decompress1x_main_loop_bmi2(&ctx) - } else { - decompress1x_main_loop_amd64(&ctx) - } - if ctx.decoded == error_max_decoded_size_exeeded { - return nil, ErrMaxDecodedSizeExceeded - } - - dst = dst[:ctx.decoded] - } +func decompress4x_8b_main_loop_asm(ctx *decompress4xContext) { + decompress4x_8b_main_loop_amd64(ctx) +} - // br < 8, so uint8 is fine - bitsLeft := uint8(br.off)*8 + 64 - br.bitsRead - for bitsLeft > 0 { - br.fill() - if len(dst) >= maxDecodedSize { - br.close() - return nil, ErrMaxDecodedSizeExceeded - } - v := d.dt.single[br.peekBitsFast(d.actualTableLog)&tlMask] - nBits := uint8(v.entry) - br.advance(nBits) - bitsLeft -= nBits - dst = append(dst, uint8(v.entry>>8)) +func decompress1x_main_loop_asm(ctx *decompress1xContext) { + if cpuinfo.HasBMI2() { + decompress1x_main_loop_bmi2(ctx) + } else { + decompress1x_main_loop_amd64(ctx) } - return dst, br.close() } diff --git a/vendor/github.com/klauspost/compress/huff0/decompress_amd64.s b/vendor/github.com/klauspost/compress/huff0/decompress_amd64.s index c4c7ab2d1fe..c5d4a710a09 100644 --- a/vendor/github.com/klauspost/compress/huff0/decompress_amd64.s +++ b/vendor/github.com/klauspost/compress/huff0/decompress_amd64.s @@ -1,6 +1,6 @@ -// Code generated by command: go run gen.go -out ../decompress_amd64.s -pkg=huff0. DO NOT EDIT. +// Code generated by command: go run gen.go -out ../decompress.s -arch amd64,arm64 -pkg=huff0. DO NOT EDIT. -//go:build amd64 && !appengine && !noasm && gc +//go:build !appengine && !noasm && gc // func decompress4x_main_loop_amd64(ctx *decompress4xContext) TEXT ·decompress4x_main_loop_amd64(SB), $0-8 diff --git a/vendor/github.com/klauspost/compress/huff0/decompress_arm64.go b/vendor/github.com/klauspost/compress/huff0/decompress_arm64.go new file mode 100644 index 00000000000..8ba3c810e60 --- /dev/null +++ b/vendor/github.com/klauspost/compress/huff0/decompress_arm64.go @@ -0,0 +1,37 @@ +//go:build arm64 && !appengine && !noasm && gc + +// arm64 stubs and dispatch for the asm loops used by decompress_asm.go. +// The asm (decompress_arm64.s) is generated by the avo arm64 lowering +// printer from the same source as the amd64 asm; see _generate/gen.go. +package huff0 + +// decompress4x_main_loop_arm64 is an arm64 assembler implementation +// of Decompress4X when tablelog > 8. +// +//go:noescape +func decompress4x_main_loop_arm64(ctx *decompress4xContext) + +// decompress4x_8b_main_loop_arm64 is an arm64 assembler implementation +// of Decompress4X when tablelog <= 8 which decodes 4 entries +// per loop. +// +//go:noescape +func decompress4x_8b_main_loop_arm64(ctx *decompress4xContext) + +// decompress1x_main_loop_arm64 is an arm64 assembler implementation +// of Decompress1X when tablelog > 8. +// +//go:noescape +func decompress1x_main_loop_arm64(ctx *decompress1xContext) + +func decompress4x_main_loop_asm(ctx *decompress4xContext) { + decompress4x_main_loop_arm64(ctx) +} + +func decompress4x_8b_main_loop_asm(ctx *decompress4xContext) { + decompress4x_8b_main_loop_arm64(ctx) +} + +func decompress1x_main_loop_asm(ctx *decompress1xContext) { + decompress1x_main_loop_arm64(ctx) +} diff --git a/vendor/github.com/klauspost/compress/huff0/decompress_arm64.s b/vendor/github.com/klauspost/compress/huff0/decompress_arm64.s new file mode 100644 index 00000000000..e16012721a1 --- /dev/null +++ b/vendor/github.com/klauspost/compress/huff0/decompress_arm64.s @@ -0,0 +1,851 @@ +// Code generated by command: go run gen.go -out ../decompress.s -arch amd64,arm64 -pkg=huff0. DO NOT EDIT. +// EXPERIMENTAL arm64 output lowered from an amd64 avo program. + +//go:build arm64 && !appengine && !noasm && gc + +// func decompress4x_main_loop_amd64(ctx *decompress4xContext) +TEXT ·decompress4x_main_loop_arm64(SB), $0-8 + // Preload values + MOVD ctx+0(FP), R0 + MOVBU 8(R0), R6 + MOVD 16(R0), R3 + MOVD 48(R0), R5 + MOVD 24(R0), R7 + MOVD 32(R0), R8 + MOVD (R0), R9 + + // Main loop +main_loop: + MOVD $0, R2 + CMP R5, R3 + CSET GE, R16 + BFI $0, R16, $8, R2 + + // br0.fillFast32() + MOVD 32(R9), R10 + MOVBU 40(R9), R11 + CMP $0x20, R11 + BLS skip_fill0 + MOVD 24(R9), R0 + SUB $0x20, R11, R11 + SUB $0x04, R0, R0 + MOVD (R9), R12 + + // b.value |= uint64(low) << (b.bitsRead & 63) + ADD R12, R0, R15 + MOVWU (R15), R12 + MOVD R11, R1 + LSL R1, R12, R12 + MOVD R0, 24(R9) + ORR R12, R10, R10 + + // exhausted += (br0.off < 4) + CMP $0x04, R0 + CSINC HS, R2, R2, R16 + BFI $0, R16, $8, R2 + +skip_fill0: + // val0 := br0.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v0 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br0.advance(uint8(v0.entry) + UBFX $8, R1, $8, R16 + BFI $0, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + + // val1 := br0.peekTopBits(peekBits) + MOVD R6, R1 + MOVD R10, R12 + LSR R1, R12, R12 + + // v1 := table[val1&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br0.advance(uint8(v1.entry)) + UBFX $8, R1, $8, R16 + BFI $8, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + + // these two writes get coalesced + // out[id * dstEvery + 0] = uint8(v0.entry >> 8) + // out[id * dstEvery + 1] = uint8(v1.entry >> 8) + MOVH R0, (R3) + + // update the bitreader structure + MOVD R10, 32(R9) + MOVB R11, 40(R9) + + // br1.fillFast32() + MOVD 80(R9), R10 + MOVBU 88(R9), R11 + CMP $0x20, R11 + BLS skip_fill1 + MOVD 72(R9), R0 + SUB $0x20, R11, R11 + SUB $0x04, R0, R0 + MOVD 48(R9), R12 + + // b.value |= uint64(low) << (b.bitsRead & 63) + ADD R12, R0, R15 + MOVWU (R15), R12 + MOVD R11, R1 + LSL R1, R12, R12 + MOVD R0, 72(R9) + ORR R12, R10, R10 + + // exhausted += (br1.off < 4) + CMP $0x04, R0 + CSINC HS, R2, R2, R16 + BFI $0, R16, $8, R2 + +skip_fill1: + // val0 := br1.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v0 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br1.advance(uint8(v0.entry) + UBFX $8, R1, $8, R16 + BFI $0, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + + // val1 := br1.peekTopBits(peekBits) + MOVD R6, R1 + MOVD R10, R12 + LSR R1, R12, R12 + + // v1 := table[val1&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br1.advance(uint8(v1.entry)) + UBFX $8, R1, $8, R16 + BFI $8, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + + // these two writes get coalesced + // out[id * dstEvery + 0] = uint8(v0.entry >> 8) + // out[id * dstEvery + 1] = uint8(v1.entry >> 8) + ADD R7, R3, R15 + MOVH R0, (R15) + + // update the bitreader structure + MOVD R10, 80(R9) + MOVB R11, 88(R9) + + // br2.fillFast32() + MOVD 128(R9), R10 + MOVBU 136(R9), R11 + CMP $0x20, R11 + BLS skip_fill2 + MOVD 120(R9), R0 + SUB $0x20, R11, R11 + SUB $0x04, R0, R0 + MOVD 96(R9), R12 + + // b.value |= uint64(low) << (b.bitsRead & 63) + ADD R12, R0, R15 + MOVWU (R15), R12 + MOVD R11, R1 + LSL R1, R12, R12 + MOVD R0, 120(R9) + ORR R12, R10, R10 + + // exhausted += (br2.off < 4) + CMP $0x04, R0 + CSINC HS, R2, R2, R16 + BFI $0, R16, $8, R2 + +skip_fill2: + // val0 := br2.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v0 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br2.advance(uint8(v0.entry) + UBFX $8, R1, $8, R16 + BFI $0, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + + // val1 := br2.peekTopBits(peekBits) + MOVD R6, R1 + MOVD R10, R12 + LSR R1, R12, R12 + + // v1 := table[val1&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br2.advance(uint8(v1.entry)) + UBFX $8, R1, $8, R16 + BFI $8, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + + // these two writes get coalesced + // out[id * dstEvery + 0] = uint8(v0.entry >> 8) + // out[id * dstEvery + 1] = uint8(v1.entry >> 8) + ADD R7<<1, R3, R15 + MOVH R0, (R15) + + // update the bitreader structure + MOVD R10, 128(R9) + MOVB R11, 136(R9) + + // br3.fillFast32() + MOVD 176(R9), R10 + MOVBU 184(R9), R11 + CMP $0x20, R11 + BLS skip_fill3 + MOVD 168(R9), R0 + SUB $0x20, R11, R11 + SUB $0x04, R0, R0 + MOVD 144(R9), R12 + + // b.value |= uint64(low) << (b.bitsRead & 63) + ADD R12, R0, R15 + MOVWU (R15), R12 + MOVD R11, R1 + LSL R1, R12, R12 + MOVD R0, 168(R9) + ORR R12, R10, R10 + + // exhausted += (br3.off < 4) + CMP $0x04, R0 + CSINC HS, R2, R2, R16 + BFI $0, R16, $8, R2 + +skip_fill3: + // val0 := br3.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v0 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br3.advance(uint8(v0.entry) + UBFX $8, R1, $8, R16 + BFI $0, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + + // val1 := br3.peekTopBits(peekBits) + MOVD R6, R1 + MOVD R10, R12 + LSR R1, R12, R12 + + // v1 := table[val1&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br3.advance(uint8(v1.entry)) + UBFX $8, R1, $8, R16 + BFI $8, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + + // these two writes get coalesced + // out[id * dstEvery + 0] = uint8(v0.entry >> 8) + // out[id * dstEvery + 1] = uint8(v1.entry >> 8) + ADD R7<<1, R7, R1 + ADD R1, R3, R15 + MOVH R0, (R15) + + // update the bitreader structure + MOVD R10, 176(R9) + MOVB R11, 184(R9) + ADD $0x02, R3, R3 + AND $0xff, R2, R15 + AND $0xff, R2, R16 + TST R16, R15 + BEQ main_loop + MOVD ctx+0(FP), R0 + MOVD 16(R0), R16 + SUB R16, R3, R3 + LSL $0x02, R3, R3 + MOVD R3, 40(R0) + RET + +// func decompress4x_8b_main_loop_amd64(ctx *decompress4xContext) +TEXT ·decompress4x_8b_main_loop_arm64(SB), $0-8 + // Preload values + MOVD ctx+0(FP), R1 + MOVBU 8(R1), R6 + MOVD 16(R1), R3 + MOVD 48(R1), R5 + MOVD 24(R1), R7 + MOVD 32(R1), R8 + MOVD (R1), R9 + + // Main loop +main_loop: + MOVD $0, R2 + CMP R5, R3 + CSET GE, R16 + BFI $0, R16, $8, R2 + + // br0.fillFast32() + MOVD 32(R9), R10 + MOVBU 40(R9), R11 + CMP $0x20, R11 + BLS skip_fill0 + MOVD 24(R9), R12 + SUB $0x20, R11, R11 + SUB $0x04, R12, R12 + MOVD (R9), R13 + + // b.value |= uint64(low) << (b.bitsRead & 63) + ADD R13, R12, R15 + MOVWU (R15), R13 + MOVD R11, R1 + LSL R1, R13, R13 + MOVD R12, 24(R9) + ORR R13, R10, R10 + + // exhausted += (br0.off < 4) + CMP $0x04, R12 + CSINC HS, R2, R2, R16 + BFI $0, R16, $8, R2 + +skip_fill0: + // val0 := br0.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v0 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br0.advance(uint8(v0.entry) + UBFX $8, R1, $8, R16 + BFI $0, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + + // val1 := br0.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v1 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br0.advance(uint8(v1.entry) + UBFX $8, R1, $8, R16 + BFI $8, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + REVW R0, R0 + + // val2 := br0.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v2 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br0.advance(uint8(v2.entry) + UBFX $8, R1, $8, R16 + BFI $8, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + + // val3 := br0.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v3 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br0.advance(uint8(v3.entry) + UBFX $8, R1, $8, R16 + BFI $0, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + REVW R0, R0 + + // these four writes get coalesced + // out[id * dstEvery + 0] = uint8(v0.entry >> 8) + // out[id * dstEvery + 1] = uint8(v1.entry >> 8) + // out[id * dstEvery + 3] = uint8(v2.entry >> 8) + // out[id * dstEvery + 4] = uint8(v3.entry >> 8) + MOVW R0, (R3) + + // update the bitreader structure + MOVD R10, 32(R9) + MOVB R11, 40(R9) + + // br1.fillFast32() + MOVD 80(R9), R10 + MOVBU 88(R9), R11 + CMP $0x20, R11 + BLS skip_fill1 + MOVD 72(R9), R12 + SUB $0x20, R11, R11 + SUB $0x04, R12, R12 + MOVD 48(R9), R13 + + // b.value |= uint64(low) << (b.bitsRead & 63) + ADD R13, R12, R15 + MOVWU (R15), R13 + MOVD R11, R1 + LSL R1, R13, R13 + MOVD R12, 72(R9) + ORR R13, R10, R10 + + // exhausted += (br1.off < 4) + CMP $0x04, R12 + CSINC HS, R2, R2, R16 + BFI $0, R16, $8, R2 + +skip_fill1: + // val0 := br1.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v0 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br1.advance(uint8(v0.entry) + UBFX $8, R1, $8, R16 + BFI $0, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + + // val1 := br1.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v1 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br1.advance(uint8(v1.entry) + UBFX $8, R1, $8, R16 + BFI $8, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + REVW R0, R0 + + // val2 := br1.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v2 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br1.advance(uint8(v2.entry) + UBFX $8, R1, $8, R16 + BFI $8, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + + // val3 := br1.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v3 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br1.advance(uint8(v3.entry) + UBFX $8, R1, $8, R16 + BFI $0, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + REVW R0, R0 + + // these four writes get coalesced + // out[id * dstEvery + 0] = uint8(v0.entry >> 8) + // out[id * dstEvery + 1] = uint8(v1.entry >> 8) + // out[id * dstEvery + 3] = uint8(v2.entry >> 8) + // out[id * dstEvery + 4] = uint8(v3.entry >> 8) + ADD R7, R3, R15 + MOVW R0, (R15) + + // update the bitreader structure + MOVD R10, 80(R9) + MOVB R11, 88(R9) + + // br2.fillFast32() + MOVD 128(R9), R10 + MOVBU 136(R9), R11 + CMP $0x20, R11 + BLS skip_fill2 + MOVD 120(R9), R12 + SUB $0x20, R11, R11 + SUB $0x04, R12, R12 + MOVD 96(R9), R13 + + // b.value |= uint64(low) << (b.bitsRead & 63) + ADD R13, R12, R15 + MOVWU (R15), R13 + MOVD R11, R1 + LSL R1, R13, R13 + MOVD R12, 120(R9) + ORR R13, R10, R10 + + // exhausted += (br2.off < 4) + CMP $0x04, R12 + CSINC HS, R2, R2, R16 + BFI $0, R16, $8, R2 + +skip_fill2: + // val0 := br2.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v0 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br2.advance(uint8(v0.entry) + UBFX $8, R1, $8, R16 + BFI $0, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + + // val1 := br2.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v1 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br2.advance(uint8(v1.entry) + UBFX $8, R1, $8, R16 + BFI $8, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + REVW R0, R0 + + // val2 := br2.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v2 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br2.advance(uint8(v2.entry) + UBFX $8, R1, $8, R16 + BFI $8, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + + // val3 := br2.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v3 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br2.advance(uint8(v3.entry) + UBFX $8, R1, $8, R16 + BFI $0, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + REVW R0, R0 + + // these four writes get coalesced + // out[id * dstEvery + 0] = uint8(v0.entry >> 8) + // out[id * dstEvery + 1] = uint8(v1.entry >> 8) + // out[id * dstEvery + 3] = uint8(v2.entry >> 8) + // out[id * dstEvery + 4] = uint8(v3.entry >> 8) + ADD R7<<1, R3, R15 + MOVW R0, (R15) + + // update the bitreader structure + MOVD R10, 128(R9) + MOVB R11, 136(R9) + + // br3.fillFast32() + MOVD 176(R9), R10 + MOVBU 184(R9), R11 + CMP $0x20, R11 + BLS skip_fill3 + MOVD 168(R9), R12 + SUB $0x20, R11, R11 + SUB $0x04, R12, R12 + MOVD 144(R9), R13 + + // b.value |= uint64(low) << (b.bitsRead & 63) + ADD R13, R12, R15 + MOVWU (R15), R13 + MOVD R11, R1 + LSL R1, R13, R13 + MOVD R12, 168(R9) + ORR R13, R10, R10 + + // exhausted += (br3.off < 4) + CMP $0x04, R12 + CSINC HS, R2, R2, R16 + BFI $0, R16, $8, R2 + +skip_fill3: + // val0 := br3.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v0 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br3.advance(uint8(v0.entry) + UBFX $8, R1, $8, R16 + BFI $0, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + + // val1 := br3.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v1 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br3.advance(uint8(v1.entry) + UBFX $8, R1, $8, R16 + BFI $8, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + REVW R0, R0 + + // val2 := br3.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v2 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br3.advance(uint8(v2.entry) + UBFX $8, R1, $8, R16 + BFI $8, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + + // val3 := br3.peekTopBits(peekBits) + MOVD R10, R12 + MOVD R6, R1 + LSR R1, R12, R12 + + // v3 := table[val0&mask] + ADD R12<<1, R8, R15 + MOVHU (R15), R1 + + // br3.advance(uint8(v3.entry) + UBFX $8, R1, $8, R16 + BFI $0, R16, $8, R0 + LSL R1, R10, R10 + ADD R1, R11, R15 + BFI $0, R15, $8, R11 + REVW R0, R0 + + // these four writes get coalesced + // out[id * dstEvery + 0] = uint8(v0.entry >> 8) + // out[id * dstEvery + 1] = uint8(v1.entry >> 8) + // out[id * dstEvery + 3] = uint8(v2.entry >> 8) + // out[id * dstEvery + 4] = uint8(v3.entry >> 8) + ADD R7<<1, R7, R1 + ADD R1, R3, R15 + MOVW R0, (R15) + + // update the bitreader structure + MOVD R10, 176(R9) + MOVB R11, 184(R9) + ADD $0x04, R3, R3 + AND $0xff, R2, R15 + AND $0xff, R2, R16 + TST R16, R15 + BEQ main_loop + MOVD ctx+0(FP), R0 + MOVD 16(R0), R16 + SUB R16, R3, R3 + LSL $0x02, R3, R3 + MOVD R3, 40(R0) + RET + +// func decompress1x_main_loop_amd64(ctx *decompress1xContext) +TEXT ·decompress1x_main_loop_arm64(SB), $0-8 + MOVD ctx+0(FP), R1 + MOVD 16(R1), R2 + MOVD 24(R1), R3 + CMP $0x04, R3 + BLO error_max_decoded_size_exceeded + ADD R3, R2, R3 + MOVD (R1), R5 + MOVD (R5), R7 + MOVD 24(R5), R8 + MOVD 32(R5), R9 + MOVBU 40(R5), R10 + MOVD 32(R1), R5 + MOVBU 8(R1), R6 + JMP loop_condition + +main_loop: + // Check if we have room for 4 bytes in the output buffer + ADD $4, R2, R1 + CMP R3, R1 + BGE error_max_decoded_size_exceeded + + // Decode 4 values + CMP $0x20, R10 + BLT bitReader_fillFast_1_end + SUB $0x20, R10, R10 + SUB $0x04, R8, R8 + ADD R8, R7, R15 + MOVWU (R15), R11 + MOVD R10, R1 + LSL R1, R11, R11 + ORR R11, R9, R9 + +bitReader_fillFast_1_end: + MOVD R6, R1 + MOVD R9, R11 + LSR R1, R11, R11 + ADD R11<<1, R5, R15 + MOVHU (R15), R1 + UBFX $8, R1, $8, R16 + BFI $0, R16, $8, R0 + MOVBU R1, R1 + ADD R1, R10, R10 + LSL R1, R9, R9 + MOVD R6, R1 + MOVD R9, R11 + LSR R1, R11, R11 + ADD R11<<1, R5, R15 + MOVHU (R15), R1 + UBFX $8, R1, $8, R16 + BFI $8, R16, $8, R0 + MOVBU R1, R1 + ADD R1, R10, R10 + LSL R1, R9, R9 + REVW R0, R0 + CMP $0x20, R10 + BLT bitReader_fillFast_2_end + SUB $0x20, R10, R10 + SUB $0x04, R8, R8 + ADD R8, R7, R15 + MOVWU (R15), R11 + MOVD R10, R1 + LSL R1, R11, R11 + ORR R11, R9, R9 + +bitReader_fillFast_2_end: + MOVD R6, R1 + MOVD R9, R11 + LSR R1, R11, R11 + ADD R11<<1, R5, R15 + MOVHU (R15), R1 + UBFX $8, R1, $8, R16 + BFI $8, R16, $8, R0 + MOVBU R1, R1 + ADD R1, R10, R10 + LSL R1, R9, R9 + MOVD R6, R1 + MOVD R9, R11 + LSR R1, R11, R11 + ADD R11<<1, R5, R15 + MOVHU (R15), R1 + UBFX $8, R1, $8, R16 + BFI $0, R16, $8, R0 + MOVBU R1, R1 + ADD R1, R10, R10 + LSL R1, R9, R9 + REVW R0, R0 + + // Store the decoded values + MOVW R0, (R2) + ADD $0x04, R2, R2 + +loop_condition: + CMP $0x08, R8 + BGE main_loop + + // Update ctx structure + MOVD ctx+0(FP), R0 + MOVD 16(R0), R16 + SUB R16, R2, R2 + MOVD R2, 40(R0) + MOVD (R0), R0 + MOVD R8, 24(R0) + MOVD R9, 32(R0) + MOVB R10, 40(R0) + RET + + // Report error +error_max_decoded_size_exceeded: + MOVD ctx+0(FP), R0 + MOVD $-1, R1 + MOVD R1, 40(R0) + RET + +// skipped decompress1x_main_loop_bmi2 (generic twin preferred on arm64) diff --git a/vendor/github.com/klauspost/compress/huff0/decompress_asm.go b/vendor/github.com/klauspost/compress/huff0/decompress_asm.go new file mode 100644 index 00000000000..4854dd43653 --- /dev/null +++ b/vendor/github.com/klauspost/compress/huff0/decompress_asm.go @@ -0,0 +1,193 @@ +//go:build (amd64 || arm64) && !appengine && !noasm && gc + +// This file contains the specialisation of Decoder.Decompress4X +// and Decoder.Decompress1X that use an asm implementation of their main loops. +// The asm function stubs and any per-arch dispatch live in decompress_amd64.go +// and decompress_arm64.go. +package huff0 + +import ( + "errors" + "fmt" +) + +// fallback8BitSize is the size where using Go version is faster. +const fallback8BitSize = 800 + +type decompress4xContext struct { + pbr *[4]bitReaderShifted + peekBits uint8 + out *byte + dstEvery int + tbl *dEntrySingle + decoded int + limit *byte +} + +// Decompress4X will decompress a 4X encoded stream. +// The length of the supplied input must match the end of a block exactly. +// The *capacity* of the dst slice must match the destination size of +// the uncompressed data exactly. +func (d *Decoder) Decompress4X(dst, src []byte) ([]byte, error) { + if len(d.dt.single) == 0 { + return nil, errors.New("no table loaded") + } + if len(src) < 6+(4*1) { + return nil, errors.New("input too small") + } + + use8BitTables := d.actualTableLog <= 8 + if cap(dst) < fallback8BitSize && use8BitTables { + return d.decompress4X8bit(dst, src) + } + + var br [4]bitReaderShifted + // Decode "jump table" + start := 6 + for i := range 3 { + length := int(src[i*2]) | (int(src[i*2+1]) << 8) + if start+length >= len(src) { + return nil, errors.New("truncated input (or invalid offset)") + } + err := br[i].init(src[start : start+length]) + if err != nil { + return nil, err + } + start += length + } + err := br[3].init(src[start:]) + if err != nil { + return nil, err + } + + // destination, offset to match first output + dstSize := cap(dst) + dst = dst[:dstSize] + out := dst + dstEvery := (dstSize + 3) / 4 + + const tlSize = 1 << tableLogMax + const tlMask = tlSize - 1 + single := d.dt.single[:tlSize] + + var decoded int + + if len(out) > 4*4 && !(br[0].off < 4 || br[1].off < 4 || br[2].off < 4 || br[3].off < 4) { + ctx := decompress4xContext{ + pbr: &br, + peekBits: uint8((64 - d.actualTableLog) & 63), // see: bitReaderShifted.peekBitsFast() + out: &out[0], + dstEvery: dstEvery, + tbl: &single[0], + limit: &out[dstEvery-4], // Always stop decoding when first buffer gets here to avoid writing OOB on last. + } + if use8BitTables { + decompress4x_8b_main_loop_asm(&ctx) + } else { + decompress4x_main_loop_asm(&ctx) + } + + decoded = ctx.decoded + out = out[decoded/4:] + } + + // Decode remaining. + remainBytes := dstEvery - (decoded / 4) + for i := range br { + offset := dstEvery * i + endsAt := min(offset+remainBytes, len(out)) + br := &br[i] + bitsLeft := br.remaining() + for bitsLeft > 0 { + br.fill() + if offset >= endsAt { + return nil, errors.New("corruption detected: stream overrun 4") + } + + // Read value and increment offset. + val := br.peekBitsFast(d.actualTableLog) + v := single[val&tlMask].entry + nBits := uint8(v) + br.advance(nBits) + bitsLeft -= uint(nBits) + out[offset] = uint8(v >> 8) + offset++ + } + if offset != endsAt { + return nil, fmt.Errorf("corruption detected: short output block %d, end %d != %d", i, offset, endsAt) + } + decoded += offset - dstEvery*i + err = br.close() + if err != nil { + return nil, err + } + } + if dstSize != decoded { + return nil, errors.New("corruption detected: short output block") + } + return dst, nil +} + +type decompress1xContext struct { + pbr *bitReaderShifted + peekBits uint8 + out *byte + outCap int + tbl *dEntrySingle + decoded int +} + +// Error reported by asm implementations +const error_max_decoded_size_exeeded = -1 + +// Decompress1X will decompress a 1X encoded stream. +// The cap of the output buffer will be the maximum decompressed size. +// The length of the supplied input must match the end of a block exactly. +func (d *Decoder) Decompress1X(dst, src []byte) ([]byte, error) { + if len(d.dt.single) == 0 { + return nil, errors.New("no table loaded") + } + var br bitReaderShifted + err := br.init(src) + if err != nil { + return dst, err + } + maxDecodedSize := cap(dst) + dst = dst[:maxDecodedSize] + + const tlSize = 1 << tableLogMax + const tlMask = tlSize - 1 + + if maxDecodedSize >= 4 { + ctx := decompress1xContext{ + pbr: &br, + out: &dst[0], + outCap: maxDecodedSize, + peekBits: uint8((64 - d.actualTableLog) & 63), // see: bitReaderShifted.peekBitsFast() + tbl: &d.dt.single[0], + } + + decompress1x_main_loop_asm(&ctx) + if ctx.decoded == error_max_decoded_size_exeeded { + return nil, ErrMaxDecodedSizeExceeded + } + + dst = dst[:ctx.decoded] + } + + // br < 8, so uint8 is fine + bitsLeft := uint8(br.off)*8 + 64 - br.bitsRead + for bitsLeft > 0 { + br.fill() + if len(dst) >= maxDecodedSize { + br.close() + return nil, ErrMaxDecodedSizeExceeded + } + v := d.dt.single[br.peekBitsFast(d.actualTableLog)&tlMask] + nBits := uint8(v.entry) + br.advance(nBits) + bitsLeft -= nBits + dst = append(dst, uint8(v.entry>>8)) + } + return dst, br.close() +} diff --git a/vendor/github.com/klauspost/compress/huff0/decompress_generic.go b/vendor/github.com/klauspost/compress/huff0/decompress_generic.go index 61039232224..e1bca5c686e 100644 --- a/vendor/github.com/klauspost/compress/huff0/decompress_generic.go +++ b/vendor/github.com/klauspost/compress/huff0/decompress_generic.go @@ -1,4 +1,4 @@ -//go:build !amd64 || appengine || !gc || noasm +//go:build (!amd64 && !arm64) || appengine || !gc || noasm // This file contains a generic implementation of Decoder.Decompress4X. package huff0 diff --git a/vendor/github.com/klauspost/compress/internal/snapref/decode.go b/vendor/github.com/klauspost/compress/internal/snapref/decode.go index a2c82fcd226..584b7574b20 100644 --- a/vendor/github.com/klauspost/compress/internal/snapref/decode.go +++ b/vendor/github.com/klauspost/compress/internal/snapref/decode.go @@ -31,7 +31,7 @@ func DecodedLen(src []byte) (int, error) { // that the length header occupied. func decodedLen(src []byte) (blockLen, headerLen int, err error) { v, n := binary.Uvarint(src) - if n <= 0 || v > 0xffffffff { + if n <= 0 || n > 5 || v > 0xffffffff { return 0, 0, ErrCorrupt } diff --git a/vendor/github.com/klauspost/compress/s2/decode.go b/vendor/github.com/klauspost/compress/s2/decode.go index 264ffd0a9b4..17abb515a59 100644 --- a/vendor/github.com/klauspost/compress/s2/decode.go +++ b/vendor/github.com/klauspost/compress/s2/decode.go @@ -35,7 +35,7 @@ func DecodedLen(src []byte) (int, error) { // that the length header occupied. func decodedLen(src []byte) (blockLen, headerLen int, err error) { v, n := binary.Uvarint(src) - if n <= 0 || v > 0xffffffff { + if n <= 0 || n > 5 || v > 0xffffffff { return 0, 0, ErrCorrupt } diff --git a/vendor/github.com/klauspost/compress/s2/encode_all.go b/vendor/github.com/klauspost/compress/s2/encode_all.go index 9d12c44f38a..794ec8a6874 100644 --- a/vendor/github.com/klauspost/compress/s2/encode_all.go +++ b/vendor/github.com/klauspost/compress/s2/encode_all.go @@ -981,7 +981,7 @@ searchDict: cv = load64(src, s) continue } - } else if uint32(cv>>(checkRep*8)) == load32(src, s-repeat+checkRep) { + } else if repeat > 0 && uint32(cv>>(checkRep*8)) == load32(src, s-repeat+checkRep) { base := s + checkRep // Extend back for i := base - repeat; base > nextEmit && i > 0 && src[i-1] == src[base-1]; { diff --git a/vendor/github.com/klauspost/compress/s2/hashtable_pool.go b/vendor/github.com/klauspost/compress/s2/hashtable_pool.go index bc7cabd5c5c..ec972132b57 100644 --- a/vendor/github.com/klauspost/compress/s2/hashtable_pool.go +++ b/vendor/github.com/klauspost/compress/s2/hashtable_pool.go @@ -25,7 +25,7 @@ type betterTables struct { sTable [betterShortTableSize]uint32 } -var betterTablePool = sync.Pool{New: func() interface{} { return &betterTables{} }} +var betterTablePool = sync.Pool{New: func() any { return &betterTables{} }} // betterSnappyTables holds better-snappy compression hash tables. type betterSnappyTables struct { @@ -33,7 +33,7 @@ type betterSnappyTables struct { sTable [betterShortTableSize]uint32 } -var betterSnappyTablePool = sync.Pool{New: func() interface{} { return &betterSnappyTables{} }} +var betterSnappyTablePool = sync.Pool{New: func() any { return &betterSnappyTables{} }} // bestTables holds best compression hash tables. type bestTables struct { @@ -41,7 +41,7 @@ type bestTables struct { sTable [bestShortTableSize]uint64 } -var bestTablePool = sync.Pool{New: func() interface{} { return &bestTables{} }} +var bestTablePool = sync.Pool{New: func() any { return &bestTables{} }} // getBetterTables gets a zeroed betterTables from the pool. func getBetterTables() *betterTables { diff --git a/vendor/github.com/klauspost/compress/s2/reader.go b/vendor/github.com/klauspost/compress/s2/reader.go index 4d01c4190cc..17443e2c146 100644 --- a/vendor/github.com/klauspost/compress/s2/reader.go +++ b/vendor/github.com/klauspost/compress/s2/reader.go @@ -216,13 +216,18 @@ func (r *Reader) skippable(tmp []byte, n int, allowEOF bool, id uint8) (ok bool) return r.err == nil } if rs, ok := r.r.(io.ReadSeeker); ok { - _, err := rs.Seek(int64(n), io.SeekCurrent) - if err == nil { - return true - } - if err == io.ErrUnexpectedEOF || (r.err == io.EOF && !allowEOF) { - r.err = ErrCorrupt - return false + if cur, err := rs.Seek(0, io.SeekCurrent); err == nil { + if end, err := rs.Seek(0, io.SeekEnd); err == nil { + if cur+int64(n) <= end { + if _, err := rs.Seek(cur+int64(n), io.SeekStart); err == nil { + return true + } + } + if _, err := rs.Seek(cur, io.SeekStart); err != nil { + r.err = ErrCorrupt + return false + } + } } } for n > 0 { diff --git a/vendor/github.com/klauspost/compress/snappy/decode_strict.go b/vendor/github.com/klauspost/compress/snappy/decode_strict.go new file mode 100644 index 00000000000..6c28bcbbbc9 --- /dev/null +++ b/vendor/github.com/klauspost/compress/snappy/decode_strict.go @@ -0,0 +1,130 @@ +// Copyright 2011 The Snappy-Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package snappy + +import "encoding/binary" + +// DecodeStrict returns the decoded form of src, like Decode. +// +// Unlike Decode, which delegates to the s2 decoder and accepts the s2 +// "repeat last offset" extension (a copy whose encoded offset is 0), +// DecodeStrict uses a strict standard-Snappy block decoder. Offset 0 is not +// valid in the standard Snappy block format, so such a copy is rejected with +// ErrCorrupt. This makes DecodeStrict match github.com/golang/snappy and the +// C++ reference decoder, at the cost of being slower than Decode. +// +// The returned slice may be a sub-slice of dst if dst was large enough to +// hold the entire decoded block. Otherwise, a newly allocated slice will be +// returned. +// +// The dst and src must not overlap. It is valid to pass a nil dst. +// +// DecodeStrict handles the Snappy block format, not the Snappy stream format. +func DecodeStrict(dst, src []byte) ([]byte, error) { + v, n := binary.Uvarint(src) + if n <= 0 || n > 5 || v > 0xffffffff { + return nil, ErrCorrupt + } + const wordSize = 32 << (^uint(0) >> 32 & 1) + if wordSize == 32 && v > 0x7fffffff { + return nil, ErrTooLarge + } + dLen := int(v) + if dLen <= cap(dst) { + dst = dst[:dLen] + } else { + dst = make([]byte, dLen) + } + if decodeStrict(dst, src[n:]) != 0 { + return nil, ErrCorrupt + } + return dst, nil +} + +func decodeStrict(dst, src []byte) int { + var d, s, offset, length int + for s < len(src) { + switch src[s] & 0x03 { + case 0x00: + x := uint32(src[s] >> 2) + switch { + case x < 60: + s++ + case x == 60: + s += 2 + if uint(s) > uint(len(src)) { + return 1 + } + x = uint32(src[s-1]) + case x == 61: + s += 3 + if uint(s) > uint(len(src)) { + return 1 + } + x = uint32(src[s-2]) | uint32(src[s-1])<<8 + case x == 62: + s += 4 + if uint(s) > uint(len(src)) { + return 1 + } + x = uint32(src[s-3]) | uint32(src[s-2])<<8 | uint32(src[s-1])<<16 + case x == 63: + s += 5 + if uint(s) > uint(len(src)) { + return 1 + } + x = uint32(src[s-4]) | uint32(src[s-3])<<8 | uint32(src[s-2])<<16 | uint32(src[s-1])<<24 + } + length = int(x) + 1 + if length <= 0 || length > len(dst)-d || length > len(src)-s { + return 1 + } + copy(dst[d:], src[s:s+length]) + d += length + s += length + continue + case 0x01: + s += 2 + if uint(s) > uint(len(src)) { + return 1 + } + length = 4 + int(src[s-2])>>2&0x7 + offset = int(uint32(src[s-2])&0xe0<<3 | uint32(src[s-1])) + case 0x02: + s += 3 + if uint(s) > uint(len(src)) { + return 1 + } + length = 1 + int(src[s-3])>>2 + offset = int(uint32(src[s-2]) | uint32(src[s-1])<<8) + case 0x03: + s += 5 + if uint(s) > uint(len(src)) { + return 1 + } + length = 1 + int(src[s-5])>>2 + offset = int(uint32(src[s-4]) | uint32(src[s-3])<<8 | uint32(src[s-2])<<16 | uint32(src[s-1])<<24) + } + if offset <= 0 || d < offset || length > len(dst)-d { + return 1 + } + if offset >= length { + copy(dst[d:d+length], dst[d-offset:]) + d += length + continue + } + a := dst[d : d+length] + b := dst[d-offset:] + b = b[:len(a)] + for i := range a { + a[i] = b[i] + } + d += length + } + if d != len(dst) { + return 1 + } + return 0 +} diff --git a/vendor/github.com/klauspost/compress/zstd/README.md b/vendor/github.com/klauspost/compress/zstd/README.md index c11d7fa28e3..a5aeeaed06f 100644 --- a/vendor/github.com/klauspost/compress/zstd/README.md +++ b/vendor/github.com/klauspost/compress/zstd/README.md @@ -75,14 +75,47 @@ The above is fine for big encodes. However, whenever possible try to *reuse* the To reuse the encoder, you can use the `Reset(io.Writer)` function to change to another output. This will allow the encoder to reuse all resources and avoid wasteful allocations. -Currently stream encoding has 'light' concurrency, meaning up to 2 goroutines can be working on part -of a stream. This is independent of the `WithEncoderConcurrency(n)`, but that is likely to change +By default, stream encoding has 'light' concurrency, meaning up to 2 goroutines can be working on part +of a stream. This is independent of the `WithEncoderConcurrency(n)`, but that is likely to change in the future. So if you want to limit concurrency for future updates, specify the concurrency you would like. If you would like stream encoding to be done without spawning async goroutines, use `WithEncoderConcurrency(1)` which will compress input as each block is completed, blocking on writes until each has completed. +#### Parallel Stream Compression + +For maximum throughput on large streams, use `WithConcurrentBlocks(true)` together with +`WithEncoderConcurrency(n)` where n is the number of CPU cores you want to use. +This splits the input into large sections (jobs) that are compressed simultaneously by multiple goroutines, +similar to how the C zstd library does multithreaded compression. + +```Go +enc, err := zstd.NewWriter(out, + zstd.WithEncoderLevel(zstd.SpeedDefault), + zstd.WithEncoderConcurrency(runtime.GOMAXPROCS(0)), + zstd.WithConcurrentBlocks(true), +) +``` + +Each non-first job receives an overlap prefix from the previous job for match context, +so compression ratio is only marginally affected. Output is flushed in order, +producing a valid single-frame zstd stream. + +Benchmark on 1.8GB GOB stream (AMD Ryzen 9 9950X): + +| Level | 1 thread | 4 threads | 16 threads | 1T ratio | 16T ratio | +|---------|:----------:|:------------------:|:-------------------:|:--------:|:---------:| +| fastest | 783 MB/s | 2950 MB/s (3.8×) | 6939 MB/s (8.9×) | 12.24% | 12.26% | +| default | 728 MB/s | 2533 MB/s (3.5×) | 5340 MB/s (7.3×) | 10.67% | 10.68% | +| better | 434 MB/s | 1105 MB/s (2.5×) | 2206 MB/s (5.1×) | 9.14% | 9.21% | +| best | 129 MB/s | 367 MB/s (2.8×) | 884 MB/s (6.8×) | 8.48% | 8.63% | + +Notes: +* Not compatible with dictionary encoding. +* `Flush()` dispatches the current partial job, so latency-sensitive callers can force output. +* `EncodeAll` is unaffected — it uses its own concurrency via the encoder pool. + You can specify your desired compression level using `WithEncoderLevel()` option. Currently only pre-defined compression settings can be specified. diff --git a/vendor/github.com/klauspost/compress/zstd/blockdec.go b/vendor/github.com/klauspost/compress/zstd/blockdec.go index 2329e996f86..51f9da03875 100644 --- a/vendor/github.com/klauspost/compress/zstd/blockdec.go +++ b/vendor/github.com/klauspost/compress/zstd/blockdec.go @@ -400,8 +400,9 @@ func (b *blockDec) decodeLiterals(in []byte, hist *history) (remain []byte, err } } var err error - // Use our out buffer. - huff.MaxDecodedSize = litRegenSize + // Decoder.Decompress* uses cap(dst) for the size limit. Do not write + // MaxDecodedSize on hist.huffTree: with a trained dictionary that + // pointer aliases the shared dict.litEnc and concurrent DecodeAll races. if fourStreams { literals, err = huff.Decoder().Decompress4X(b.literalBuf[:0:litRegenSize], literals) } else { @@ -673,10 +674,6 @@ func (b *blockDec) executeSequences(hist *history) error { hbytes := hist.b if len(hbytes) > hist.windowSize { hbytes = hbytes[len(hbytes)-hist.windowSize:] - // We do not need history anymore. - if hist.dict != nil { - hist.dict.content = nil - } } hist.decoders.windowSize = hist.windowSize hist.decoders.out = b.dst[:0] diff --git a/vendor/github.com/klauspost/compress/zstd/dict.go b/vendor/github.com/klauspost/compress/zstd/dict.go index 2ffbfdf379e..67f40e79149 100644 --- a/vendor/github.com/klauspost/compress/zstd/dict.go +++ b/vendor/github.com/klauspost/compress/zstd/dict.go @@ -230,7 +230,7 @@ func BuildDict(o BuildDictOptions) ([]byte, error) { } block := blockEnc{lowMem: false} block.init() - enc := encoder(&bestFastEncoder{fastBase: fastBase{maxMatchOff: int32(maxMatchLen), bufferReset: math.MaxInt32 - int32(maxMatchLen*2), lowMem: false}}) + var enc encoder if o.Level != 0 { eOpts := encoderOptions{ level: o.Level, @@ -242,6 +242,7 @@ func BuildDict(o BuildDictOptions) ([]byte, error) { enc = eOpts.encoder() } else { o.Level = SpeedBestCompression + enc = encoder(&bestFastEncoder{fastBase: fastBase{maxMatchOff: int32(maxMatchLen), bufferReset: math.MaxInt32 - int32(maxMatchLen*2), lowMem: false}}) } var ( remain [256]int @@ -295,40 +296,81 @@ func BuildDict(o BuildDictOptions) ([]byte, error) { if offset > 3 { newOffsets[offset-3]++ } else { - newOffsets[uint32(o.Offsets[offset-1])]++ + // Repeat codes reference the training Offsets. Skip unset + // (zero) entries so they are not ranked as real offsets. + prev := o.Offsets[offset-1] + if prev > 0 { + newOffsets[uint32(prev)]++ + } } } } // Find most used offsets. var sortedOffsets []uint32 for k := range newOffsets { + if k == 0 { + continue + } sortedOffsets = append(sortedOffsets, k) } sort.Slice(sortedOffsets, func(i, j int) bool { a, b := sortedOffsets[i], sortedOffsets[j] - if a == b { + ca, cb := newOffsets[a], newOffsets[b] + if ca == cb { // Prefer the longer offset - return sortedOffsets[i] > sortedOffsets[j] + return a > b } - return newOffsets[sortedOffsets[i]] > newOffsets[sortedOffsets[j]] + return ca > cb }) - if len(sortedOffsets) > 3 { - if debug { - print("Offsets:") - for i, v := range sortedOffsets { - if i > 20 { - break - } - printf("[%d: %d],", v, newOffsets[v]) + if debug { + print("Offsets:") + for i, v := range sortedOffsets { + if i > 20 { + break } - println("") + printf("[%d: %d],", v, newOffsets[v]) + } + println("") + } + // Dictionary recent-offsets must be three positive values within the + // history. Ranked matches may be fewer (or empty when only unset + // repeat codes were seen), so fill remaining slots with defaults. + used := make(map[int]bool, 3) + var finalOffsets [3]int + nOff := 0 + for _, v := range sortedOffsets { + iv := int(v) + if iv <= 0 || iv > len(hist) || used[iv] { + continue + } + finalOffsets[nOff] = iv + used[iv] = true + nOff++ + if nOff == 3 { + break } - - sortedOffsets = sortedOffsets[:3] } - for i, v := range sortedOffsets { - o.Offsets[i] = int(v) + for _, def := range []int{1, 4, 8} { + if nOff == 3 { + break + } + if def <= len(hist) && !used[def] { + finalOffsets[nOff] = def + used[def] = true + nOff++ + } + } + for def := 1; nOff < 3 && def <= len(hist); def++ { + if !used[def] { + finalOffsets[nOff] = def + used[def] = true + nOff++ + } + } + if nOff < 3 { + return nil, fmt.Errorf("could not determine 3 valid dictionary offsets (history size %d)", len(hist)) } + o.Offsets = finalOffsets if debug { println("New repeat offsets", o.Offsets) } @@ -336,6 +378,9 @@ func BuildDict(o BuildDictOptions) ([]byte, error) { if nUsed == 0 || seqs == 0 { return nil, fmt.Errorf("%d blocks, %d sequences found", nUsed, seqs) } + if litTotal == 0 { + return nil, errors.New("0 literals found") + } if debug { println("Sequences:", seqs, "Blocks:", nUsed, "Literals:", litTotal) } @@ -516,11 +561,10 @@ func BuildDict(o BuildDictOptions) ([]byte, error) { out.Write(binary.LittleEndian.AppendUint32(nil, uint32(o.Offsets[1]))) out.Write(binary.LittleEndian.AppendUint32(nil, uint32(o.Offsets[2]))) out.Write(hist) + if _, err := loadDict(out.Bytes()); err != nil { + return nil, fmt.Errorf("built dictionary failed validation: %w", err) + } if debug { - _, err := loadDict(out.Bytes()) - if err != nil { - panic(err) - } i, err := InspectDictionary(out.Bytes()) if err != nil { panic(err) diff --git a/vendor/github.com/klauspost/compress/zstd/enc_base.go b/vendor/github.com/klauspost/compress/zstd/enc_base.go index c4de134a7a4..c4fea575d6b 100644 --- a/vendor/github.com/klauspost/compress/zstd/enc_base.go +++ b/vendor/github.com/klauspost/compress/zstd/enc_base.go @@ -128,6 +128,34 @@ func (e *fastBase) matchlen(s, t int32, src []byte) int32 { return int32(matchLen(src[s:], src[t:])) } +// resetBasePrefix resets the encoder state and loads prefix as initial history. +// This is used for parallel job encoding where non-first jobs need overlap context. +// Rep offsets are set to defaults [1,4,8] (invalidated, matching C behavior). +func (e *fastBase) resetBasePrefix(prefix []byte) { + if e.blk == nil { + e.blk = &blockEnc{lowMem: e.lowMem} + e.blk.init() + } else { + e.blk.reset(nil) + } + e.blk.initNewEncode() + if e.crc == nil { + e.crc = xxhash.New() + } else { + e.crc.Reset() + } + e.blk.dictLitEnc = nil + e.ensureHist(len(prefix) + maxCompressedBlockSize) + // Bump cur so old table entries fall outside the window. + // When cur >= bufferReset, leave it; the first Encode call + // will shift/clear tables, preserving valid prefix entries. + if e.cur < e.bufferReset { + e.cur += e.maxMatchOff + int32(len(e.hist)) + } + e.hist = e.hist[:0] + e.hist = append(e.hist, prefix...) +} + // Reset the encoding table. func (e *fastBase) resetBase(d *dict, singleBlock bool) { if e.blk == nil { diff --git a/vendor/github.com/klauspost/compress/zstd/enc_best.go b/vendor/github.com/klauspost/compress/zstd/enc_best.go index 851799322bd..c71382dde65 100644 --- a/vendor/github.com/klauspost/compress/zstd/enc_best.go +++ b/vendor/github.com/klauspost/compress/zstd/enc_best.go @@ -551,3 +551,18 @@ func (e *bestFastEncoder) Reset(d *dict, singleBlock bool) { // Reset table to initial state copy(e.table[:], e.dictTable) } + +func (e *bestFastEncoder) ResetPrefix(prefix []byte) { + e.resetBasePrefix(prefix) + if len(prefix) < 8 { + return + } + end := e.cur + int32(len(prefix)) - 8 + for i := e.cur; i < end; i++ { + cv := load6432(prefix, i-e.cur) + h := hashLen(cv, bestLongTableBits, bestLongLen) + e.longTable[h] = prevEntry{offset: i, prev: e.longTable[h].offset} + h0 := hashLen(cv, bestShortTableBits, bestShortLen) + e.table[h0] = prevEntry{offset: i, prev: e.table[h0].offset} + } +} diff --git a/vendor/github.com/klauspost/compress/zstd/enc_better.go b/vendor/github.com/klauspost/compress/zstd/enc_better.go index 3305f09248c..523d57f3ad6 100644 --- a/vendor/github.com/klauspost/compress/zstd/enc_better.go +++ b/vendor/github.com/klauspost/compress/zstd/enc_better.go @@ -1096,6 +1096,20 @@ func (e *betterFastEncoder) Reset(d *dict, singleBlock bool) { } } +func (e *betterFastEncoder) ResetPrefix(prefix []byte) { + e.resetBasePrefix(prefix) + if len(prefix) < 8 { + return + } + end := e.cur + int32(len(prefix)) - 8 + for i := e.cur; i < end; i += 2 { + cv := load6432(prefix, i-e.cur) + h := hashLen(cv, betterLongTableBits, betterLongLen) + e.longTable[h] = prevEntry{offset: i, prev: e.longTable[h].offset} + e.table[hashLen(cv>>8, betterShortTableBits, betterShortLen)] = tableEntry{val: uint32(cv >> 8), offset: i + 1} + } +} + // ResetDict will reset and set a dictionary if not nil func (e *betterFastEncoderDict) Reset(d *dict, singleBlock bool) { e.resetBase(d, singleBlock) @@ -1229,6 +1243,10 @@ func (e *betterFastEncoderDict) Reset(d *dict, singleBlock bool) { e.allDirty = false } +func (e *betterFastEncoderDict) ResetPrefix([]byte) { + panic("ResetPrefix not supported for dict encoders") +} + func (e *betterFastEncoderDict) markLongShardDirty(entryNum uint32) { e.longTableShardDirty[entryNum/betterLongTableShardSize] = true } diff --git a/vendor/github.com/klauspost/compress/zstd/enc_dfast.go b/vendor/github.com/klauspost/compress/zstd/enc_dfast.go index 2fb6da112bc..712ba7ab582 100644 --- a/vendor/github.com/klauspost/compress/zstd/enc_dfast.go +++ b/vendor/github.com/klauspost/compress/zstd/enc_dfast.go @@ -1037,6 +1037,18 @@ func (e *doubleFastEncoder) Reset(d *dict, singleBlock bool) { } } +func (e *doubleFastEncoder) ResetPrefix(prefix []byte) { + e.fastEncoder.ResetPrefix(prefix) + if len(prefix) < 8 { + return + } + end := e.cur + int32(len(prefix)) - 8 + for i := e.cur + 1; i < end; i += 2 { + cv := load6432(prefix, i-e.cur) + e.longTable[hashLen(cv, dFastLongTableBits, dFastLongLen)] = tableEntry{val: uint32(cv), offset: i} + } +} + // ResetDict will reset and set a dictionary if not nil func (e *doubleFastEncoderDict) Reset(d *dict, singleBlock bool) { allDirty := e.allDirty @@ -1102,6 +1114,10 @@ func (e *doubleFastEncoderDict) Reset(d *dict, singleBlock bool) { } } +func (e *doubleFastEncoderDict) ResetPrefix([]byte) { + panic("ResetPrefix not supported for dict encoders") +} + func (e *doubleFastEncoderDict) markLongShardDirty(entryNum uint32) { e.longTableShardDirty[entryNum/dLongTableShardSize] = true } diff --git a/vendor/github.com/klauspost/compress/zstd/enc_fast.go b/vendor/github.com/klauspost/compress/zstd/enc_fast.go index 5e104f1a482..06045e24630 100644 --- a/vendor/github.com/klauspost/compress/zstd/enc_fast.go +++ b/vendor/github.com/klauspost/compress/zstd/enc_fast.go @@ -797,6 +797,19 @@ func (e *fastEncoder) Reset(d *dict, singleBlock bool) { } } +func (e *fastEncoder) ResetPrefix(prefix []byte) { + e.resetBasePrefix(prefix) + if len(prefix) < 8 { + return + } + end := e.cur + int32(len(prefix)) - 8 + // Index every 4th + for i := e.cur + 1; i < end; i += 4 { + cv := load6432(prefix, i-e.cur) + e.table[hashLen(cv, tableBits, tableFastHashLen)] = tableEntry{val: uint32(cv), offset: i} + } +} + // ResetDict will reset and set a dictionary if not nil func (e *fastEncoderDict) Reset(d *dict, singleBlock bool) { e.resetBase(d, singleBlock) @@ -866,6 +879,10 @@ func (e *fastEncoderDict) Reset(d *dict, singleBlock bool) { e.allDirty = false } +func (e *fastEncoderDict) ResetPrefix([]byte) { + panic("ResetPrefix not supported for dict encoders") +} + func (e *fastEncoderDict) markAllShardsDirty() { e.allDirty = true } diff --git a/vendor/github.com/klauspost/compress/zstd/enc_jobs.go b/vendor/github.com/klauspost/compress/zstd/enc_jobs.go new file mode 100644 index 00000000000..95ce67ac05a --- /dev/null +++ b/vendor/github.com/klauspost/compress/zstd/enc_jobs.go @@ -0,0 +1,352 @@ +// Copyright 2019+ Klaus Post. All rights reserved. +// License information can be found in the LICENSE file. +// Based on work by Yann Collet, released under BSD License. + +package zstd + +import ( + "fmt" + rdebug "runtime/debug" + "sync" +) + +type encJob struct { + prefix []byte // overlap from previous job (nil for first) + input []byte // job's own input data (swapped from filling) + last bool // last block of last job gets last=true + output []byte // compressed blocks (filled by worker) + err error // encoding error + done chan struct{} // closed when complete +} + +type jobState struct { + jobSize int + overlapSize int + filling []byte // accumulates input up to jobSize + nextPrefix []byte // overlap prefix prepared for the next dispatched job + + jobSeq int // next job sequence number + + jobCh chan *encJob // dispatch to workers + resultCh chan *encJob // ordered results to flusher + + workerWg sync.WaitGroup + flusherWg sync.WaitGroup + + mu sync.Mutex + flushedSeq int // last flushed sequence number + cond *sync.Cond + + flusherErr error + started bool + + inputPool sync.Pool // *[]byte buffers of jobSize cap + outputPool sync.Pool // *[]byte buffers for compressed output + overlapPool sync.Pool // *[]byte buffers for overlap prefixes +} + +func (e *Encoder) startJobWorkers() { + js := &e.state.jobs + n := e.o.concurrent + js.jobCh = make(chan *encJob, n) + js.resultCh = make(chan *encJob, n) + js.flushedSeq = 0 + js.cond = sync.NewCond(&js.mu) + + // Workers borrow encoders from the shared e.encoders pool per-job. + // Ensure the pool is initialized before any worker tries to borrow. + e.init.Do(e.initialize) + + for range n { + js.workerWg.Add(1) + go e.jobWorker() + } + js.flusherWg.Add(1) + go e.jobFlusher() + js.started = true +} + +func (e *Encoder) jobWorker() { + js := &e.state.jobs + defer js.workerWg.Done() + for job := range js.jobCh { + enc := <-e.encoders + e.compressJob(enc, job) + e.encoders <- enc + close(job.done) + } +} + +func (e *Encoder) compressJob(enc encoder, job *encJob) { + defer func() { + if r := recover(); r != nil { + job.err = fmt.Errorf("panic in parallel job: %v", r) + rdebug.PrintStack() + } + }() + + if len(job.prefix) > 0 { + enc.ResetPrefix(job.prefix) + } else { + enc.Reset(nil, false) + } + + data := job.input + if len(data) == 0 && job.last { + blk := enc.Block() + blk.reset(nil) + blk.last = true + blk.encodeRaw(nil) + job.output = append(job.output, blk.output...) + return + } + + blk := enc.Block() + for len(data) > 0 { + todo := data + if len(todo) > e.o.blockSize { + todo = todo[:e.o.blockSize] + } + data = data[len(todo):] + + blk.pushOffsets() + enc.Encode(blk, todo) + blk.last = len(data) == 0 && job.last + + err := blk.encode(todo, e.o.noEntropy, !e.o.allLitEntropy) + if err != nil { + job.err = err + return + } + job.output = append(job.output, blk.output...) + blk.reset(nil) + } +} + +func (js *jobState) getInputBuf(size int) []byte { + if v := js.inputPool.Get(); v != nil { + bp := v.(*[]byte) + b := *bp + if cap(b) >= size { + return b[:0] + } + } + return make([]byte, 0, size) +} + +func (js *jobState) putInputBuf(b []byte) { + if cap(b) > 0 { + b = b[:0] + js.inputPool.Put(&b) + } +} + +func (js *jobState) getOutputBuf(size int) []byte { + if v := js.outputPool.Get(); v != nil { + bp := v.(*[]byte) + b := *bp + if cap(b) >= size { + return b[:0] + } + } + return make([]byte, 0, size) +} + +func (js *jobState) putOutputBuf(b []byte) { + if cap(b) > 0 { + b = b[:0] + js.outputPool.Put(&b) + } +} + +func (js *jobState) getOverlapBuf(size int) []byte { + if v := js.overlapPool.Get(); v != nil { + bp := v.(*[]byte) + b := *bp + if cap(b) >= size { + return b[:size] + } + } + return make([]byte, size) +} + +func (js *jobState) putOverlapBuf(b []byte) { + if cap(b) > 0 { + b = b[:0] + js.overlapPool.Put(&b) + } +} + +func (e *Encoder) jobFlusher() { + js := &e.state.jobs + defer js.flusherWg.Done() + for job := range js.resultCh { + <-job.done + // Worker has fully exited compressJob, so the prefix is no longer + // in use. Return it to the pool regardless of outcome. + if job.prefix != nil { + js.putOverlapBuf(job.prefix) + job.prefix = nil + } + if job.err != nil { + js.mu.Lock() + js.flusherErr = job.err + js.cond.Broadcast() + js.mu.Unlock() + for range js.resultCh { + } + return + } + if len(job.output) > 0 { + _, err := e.state.w.Write(job.output) + if err != nil { + js.mu.Lock() + js.flusherErr = err + js.cond.Broadcast() + js.mu.Unlock() + for range js.resultCh { + } + return + } + e.state.nWritten += int64(len(job.output)) + } + // Return buffers to pools. + js.putInputBuf(job.input) + js.putOutputBuf(job.output) + job.input = nil + job.output = nil + + js.mu.Lock() + js.flushedSeq++ + js.cond.Broadcast() + js.mu.Unlock() + } +} + +func (e *Encoder) shutdownJobWorkers() { + js := &e.state.jobs + if !js.started { + return + } + close(js.jobCh) + js.workerWg.Wait() + close(js.resultCh) + js.flusherWg.Wait() + js.started = false +} + +// waitAllJobs blocks until all dispatched jobs have been flushed. +func (e *Encoder) waitAllJobs() { + js := &e.state.jobs + if !js.started { + return + } + js.mu.Lock() + for js.flushedSeq < js.jobSeq && js.flusherErr == nil { + js.cond.Wait() + } + js.mu.Unlock() +} + +func (e *Encoder) dispatchJob(final bool) error { + s := &e.state + js := &s.jobs + + js.mu.Lock() + fErr := js.flusherErr + js.mu.Unlock() + if fErr != nil { + return fErr + } + + if !s.headerWritten { + // Single-block optimization: fall through to encodeAll path. + if final && len(js.filling) > 0 && len(js.filling) <= e.o.blockSize { + s.current = e.encodeAll(s.encoder, js.filling, s.current[:0]) + var n2 int + n2, s.err = s.w.Write(s.current) + if s.err != nil { + return s.err + } + s.nWritten += int64(n2) + s.nInput += int64(len(js.filling)) + s.current = s.current[:0] + js.filling = js.filling[:0] + s.headerWritten = true + s.fullFrameWritten = true + s.eofWritten = true + return nil + } + if final && len(js.filling) == 0 && !e.o.fullZero { + s.headerWritten = true + s.fullFrameWritten = true + s.eofWritten = true + return nil + } + + var tmp [maxHeaderSize]byte + fh := frameHeader{ + ContentSize: uint64(s.frameContentSize), + WindowSize: uint32(s.encoder.WindowSize(s.frameContentSize)), + SingleSegment: false, + Checksum: e.o.crc, + DictID: 0, + } + dst := fh.appendTo(tmp[:0]) + var n2 int + n2, s.err = s.w.Write(dst) + if s.err != nil { + return s.err + } + s.nWritten += int64(n2) + s.headerWritten = true + } + + if len(js.filling) == 0 && !final { + return nil + } + + if !js.started { + e.startJobWorkers() + } + + // Estimate output size for pooled buffer. + outputEst := max(len(js.filling)/2, 512) + + job := &encJob{ + last: final, + done: make(chan struct{}), + output: js.getOutputBuf(outputEst), + } + + // Each job owns its prefix slice; the flusher returns it to the pool + // after <-job.done, so workers and dispatch never share a buffer. + if js.nextPrefix != nil { + job.prefix = js.nextPrefix + js.nextPrefix = nil + } + + // Build the next job's prefix from the tail of this job's input. + if !final && len(js.filling) > 0 { + overlapLen := min(js.overlapSize, len(js.filling)) + np := js.getOverlapBuf(overlapLen) + copy(np, js.filling[len(js.filling)-overlapLen:]) + js.nextPrefix = np + } + + // Swap filling buffer into job — zero-copy for the input data. + job.input = js.filling + js.filling = js.getInputBuf(js.jobSize) + + s.nInput += int64(len(job.input)) + js.jobSeq++ + + if final { + s.eofWritten = true + } + + js.resultCh <- job + js.jobCh <- job + + return nil +} diff --git a/vendor/github.com/klauspost/compress/zstd/encoder.go b/vendor/github.com/klauspost/compress/zstd/encoder.go index 0f2a00a0033..6ee96d8730c 100644 --- a/vendor/github.com/klauspost/compress/zstd/encoder.go +++ b/vendor/github.com/klauspost/compress/zstd/encoder.go @@ -38,6 +38,7 @@ type encoder interface { WindowSize(size int64) int32 UseBlock(*blockEnc) Reset(d *dict, singleBlock bool) + ResetPrefix(prefix []byte) } type encoderState struct { @@ -60,6 +61,9 @@ type encoderState struct { wg sync.WaitGroup // This waitgroup indicates we have a block encoding/writing. wWg sync.WaitGroup + + // Parallel job state (used when concurrentBlocks is enabled). + jobs jobState } // NewWriter will create a new Zstandard encoder. @@ -74,6 +78,9 @@ func NewWriter(w io.Writer, opts ...EOption) (*Encoder, error) { return nil, err } } + if e.o.concurrentBlocks && (e.o.dict != nil || e.o.concurrent <= 1) { + e.o.concurrentBlocks = false + } if w != nil { e.Reset(w) } @@ -95,12 +102,31 @@ func (e *Encoder) initialize() { // as a new, independent stream. func (e *Encoder) Reset(w io.Writer) { s := &e.state + + if e.o.concurrentBlocks { + e.shutdownJobWorkers() + js := &s.jobs + js.jobSize = e.o.jobSize() + js.overlapSize = e.o.overlapSize() + // js.filling is allocated lazily on first Write/ReadFrom so callers + // that only use EncodeAll don't pay the (up to ~32 MB) jobSize cost. + js.filling = js.filling[:0] + if js.nextPrefix != nil { + js.putOverlapBuf(js.nextPrefix) + js.nextPrefix = nil + } + js.jobSeq = 0 + js.flushedSeq = 0 + js.flusherErr = nil + js.started = false + } + s.wg.Wait() s.wWg.Wait() if cap(s.filling) == 0 { s.filling = make([]byte, 0, e.o.blockSize) } - if e.o.concurrent > 1 { + if e.o.concurrent > 1 && !e.o.concurrentBlocks { if cap(s.current) == 0 { s.current = make([]byte, 0, e.o.blockSize) } @@ -145,6 +171,9 @@ func (e *Encoder) ResetWithOptions(w io.Writer, opts ...EOption) error { } } hasDict := e.o.dict != nil + if e.o.concurrentBlocks && hasDict { + e.o.concurrentBlocks = false + } if hadDict != hasDict { // Dict presence changed — encoder type must be recreated. e.state.encoder = nil @@ -176,6 +205,49 @@ func (e *Encoder) Write(p []byte) (n int, err error) { if s.eofWritten { return 0, ErrEncoderClosed } + if e.o.concurrentBlocks { + return e.writeJobs(p) + } + return e.writeBlocks(p) +} + +func (e *Encoder) writeJobs(p []byte) (n int, err error) { + s := &e.state + js := &s.jobs + jobSize := js.jobSize + if cap(js.filling) == 0 && len(p) > 0 { + js.filling = make([]byte, 0, jobSize) + } + for len(p) > 0 { + if len(p)+len(js.filling) < jobSize { + if e.o.crc { + _, _ = s.encoder.CRC().Write(p) + } + js.filling = append(js.filling, p...) + return n + len(p), nil + } + add := p + if len(p)+len(js.filling) > jobSize { + add = add[:jobSize-len(js.filling)] + } + if e.o.crc { + _, _ = s.encoder.CRC().Write(add) + } + js.filling = append(js.filling, add...) + p = p[len(add):] + n += len(add) + if len(js.filling) < jobSize { + return n, nil + } + if err := e.dispatchJob(false); err != nil { + return n, err + } + } + return n, nil +} + +func (e *Encoder) writeBlocks(p []byte) (n int, err error) { + s := &e.state for len(p) > 0 { if len(p)+len(s.filling) < e.o.blockSize { if e.o.crc { @@ -374,6 +446,10 @@ func (e *Encoder) ReadFrom(r io.Reader) (n int64, err error) { println("Using ReadFrom") } + if e.o.concurrentBlocks { + return e.readFromJobs(r) + } + // Flush any current writes. if len(e.state.filling) > 0 { if err := e.nextBlock(false); err != nil { @@ -387,7 +463,6 @@ func (e *Encoder) ReadFrom(r io.Reader) (n int64, err error) { if e.o.crc { _, _ = e.state.encoder.CRC().Write(src[:n2]) } - // src is now the unfilled part... src = src[n2:] n += int64(n2) switch err { @@ -420,15 +495,63 @@ func (e *Encoder) ReadFrom(r io.Reader) (n int64, err error) { } } +func (e *Encoder) readFromJobs(r io.Reader) (n int64, err error) { + js := &e.state.jobs + jobSize := js.jobSize + + // Flush any current filling. + if len(js.filling) > 0 { + if err := e.dispatchJob(false); err != nil { + return 0, err + } + } + + if cap(js.filling) < jobSize { + js.filling = make([]byte, 0, jobSize) + } + js.filling = js.filling[:jobSize] + src := js.filling + for { + n2, err := r.Read(src) + if e.o.crc { + _, _ = e.state.encoder.CRC().Write(src[:n2]) + } + src = src[n2:] + n += int64(n2) + switch err { + case io.EOF: + js.filling = js.filling[:len(js.filling)-len(src)] + return n, nil + case nil: + default: + e.state.err = err + return n, err + } + if len(src) > 0 { + continue + } + if err = e.dispatchJob(false); err != nil { + return n, err + } + if cap(js.filling) < jobSize { + js.filling = make([]byte, 0, jobSize) + } + js.filling = js.filling[:jobSize] + src = js.filling + } +} + // Flush will send the currently written data to output // and block until everything has been written. // This should only be used on rare occasions where pushing the currently queued data is critical. func (e *Encoder) Flush() error { s := &e.state + if e.o.concurrentBlocks { + return e.flushJobs() + } if len(s.filling) > 0 { err := e.nextBlock(false) if err != nil { - // Ignore Flush after Close. if errors.Is(s.err, ErrEncoderClosed) { return nil } @@ -438,7 +561,6 @@ func (e *Encoder) Flush() error { s.wg.Wait() s.wWg.Wait() if s.err != nil { - // Ignore Flush after Close. if errors.Is(s.err, ErrEncoderClosed) { return nil } @@ -447,6 +569,20 @@ func (e *Encoder) Flush() error { return s.writeErr } +func (e *Encoder) flushJobs() error { + js := &e.state.jobs + if len(js.filling) > 0 { + if err := e.dispatchJob(false); err != nil { + return err + } + } + e.waitAllJobs() + js.mu.Lock() + fErr := js.flusherErr + js.mu.Unlock() + return fErr +} + // Close will flush the final output and close the stream. // The function will block until everything has been written. // The Encoder can still be re-used after calling this. @@ -455,12 +591,16 @@ func (e *Encoder) Close() error { if s.encoder == nil { return nil } + if e.o.concurrentBlocks { + return e.closeJobs() + } if s.w == nil { if len(s.filling) == 0 && !s.headerWritten && !s.eofWritten && s.nInput == 0 { return nil } return errors.New("zstd: encoder has no writer") } + err := e.nextBlock(true) if err != nil { if errors.Is(s.err, ErrEncoderClosed) { @@ -511,6 +651,68 @@ func (e *Encoder) Close() error { return s.err } +func (e *Encoder) closeJobs() error { + s := &e.state + js := &s.jobs + + if errors.Is(s.err, ErrEncoderClosed) { + return nil + } + + if s.w == nil { + if len(js.filling) == 0 && !s.headerWritten && !s.eofWritten && s.nInput == 0 { + return nil + } + return errors.New("zstd: encoder has no writer") + } + + if err := e.dispatchJob(true); err != nil { + e.shutdownJobWorkers() + if errors.Is(s.err, ErrEncoderClosed) { + return nil + } + return err + } + + if s.frameContentSize > 0 && s.nInput != s.frameContentSize { + e.shutdownJobWorkers() + return fmt.Errorf("frame content size %d given, but %d bytes was written", s.frameContentSize, s.nInput) + } + + if s.fullFrameWritten { + e.shutdownJobWorkers() + s.err = ErrEncoderClosed + return nil + } + + e.shutdownJobWorkers() + if js.flusherErr != nil { + return js.flusherErr + } + + // Write CRC + if e.o.crc { + var tmp [4]byte + _, s.err = s.w.Write(s.encoder.AppendCRC(tmp[:0])) + s.nWritten += 4 + } + + // Add padding + if s.err == nil && e.o.pad > 0 { + add := calcSkippableFrame(s.nWritten, int64(e.o.pad)) + frame, err := skippableFrame(js.filling[:0], add, rand.Reader) + if err != nil { + return err + } + _, s.err = s.w.Write(frame) + } + if s.err == nil { + s.err = ErrEncoderClosed + return nil + } + return s.err +} + // EncodeAll will encode all input in src and append it to dst. // This function can be called concurrently, but each call will only run on a single goroutine. // If empty input is given, nothing is returned, unless WithZeroFrames is specified. diff --git a/vendor/github.com/klauspost/compress/zstd/encoder_options.go b/vendor/github.com/klauspost/compress/zstd/encoder_options.go index e217be0a17a..a8081496739 100644 --- a/vendor/github.com/klauspost/compress/zstd/encoder_options.go +++ b/vendor/github.com/klauspost/compress/zstd/encoder_options.go @@ -14,22 +14,23 @@ type EOption func(*encoderOptions) error // options retains accumulated state of multiple options. type encoderOptions struct { - resetOpt bool - concurrent int - level EncoderLevel - single *bool - pad int - blockSize int - windowSize int - crc bool - fullZero bool - noEntropy bool - allLitEntropy bool - customWindow bool - customALEntropy bool - customBlockSize bool - lowMem bool - dict *dict + resetOpt bool + concurrent int + level EncoderLevel + single *bool + pad int + blockSize int + windowSize int + crc bool + fullZero bool + noEntropy bool + allLitEntropy bool + customWindow bool + customALEntropy bool + customBlockSize bool + lowMem bool + dict *dict + concurrentBlocks bool } func (o *encoderOptions) setDefault() { @@ -333,6 +334,42 @@ func WithLowerEncoderMem(b bool) EOption { } } +// WithConcurrentBlocks enables job-based parallel compression for streams. +// When enabled and concurrent > 1, input is split into large sections (jobs) +// that are compressed simultaneously by multiple goroutines. +// Each non-first job receives an overlap prefix from the previous job for match context. +// Output is flushed in order, producing a valid single-frame zstd stream. +// +// Currently disabled when used with dictionary encoding. +// Cannot be changed with ResetWithOptions. +func WithConcurrentBlocks(b bool) EOption { + return func(o *encoderOptions) error { + if o.resetOpt && b != o.concurrentBlocks { + return errors.New("WithConcurrentBlocks cannot be changed on Reset") + } + o.concurrentBlocks = b + return nil + } +} + +// jobSize returns the input section size per parallel job. +func (o *encoderOptions) jobSize() int { + s := max(o.windowSize*4, 512<<10) + return s +} + +// overlapSize returns the overlap prefix size for parallel jobs. +func (o *encoderOptions) overlapSize() int { + switch o.level { + case SpeedBestCompression: + return o.windowSize / 2 + case SpeedBetterCompression: + return o.windowSize / 4 + default: + return o.windowSize / 8 + } +} + // WithEncoderDict allows to register a dictionary that will be used for the encode. // // The slice dict must be in the [dictionary format] produced by diff --git a/vendor/github.com/klauspost/compress/zstd/fse_decoder_amd64.s b/vendor/github.com/klauspost/compress/zstd/fse_decoder_amd64.s index bcde3986953..deeadc49eb0 100644 --- a/vendor/github.com/klauspost/compress/zstd/fse_decoder_amd64.s +++ b/vendor/github.com/klauspost/compress/zstd/fse_decoder_amd64.s @@ -1,4 +1,4 @@ -// Code generated by command: go run gen_fse.go -out ../fse_decoder_amd64.s -pkg=zstd. DO NOT EDIT. +// Code generated by command: go run gen_fse.go -out ../fse_decoder.s -arch amd64,arm64 -pkg=zstd. DO NOT EDIT. //go:build !appengine && !noasm && gc && !noasm diff --git a/vendor/github.com/klauspost/compress/zstd/fse_decoder_arm64.s b/vendor/github.com/klauspost/compress/zstd/fse_decoder_arm64.s new file mode 100644 index 00000000000..77ee3913f05 --- /dev/null +++ b/vendor/github.com/klauspost/compress/zstd/fse_decoder_arm64.s @@ -0,0 +1,153 @@ +// Code generated by command: go run gen_fse.go -out ../fse_decoder.s -arch amd64,arm64 -pkg=zstd. DO NOT EDIT. +// EXPERIMENTAL arm64 output lowered from an amd64 avo program. + +//go:build arm64 && !appengine && !noasm && gc && !noasm + +// func buildDtable_asm(s *fseDecoder, ctx *buildDtableAsmContext) int +TEXT ·buildDtable_asm(SB), $0-24 + MOVD ctx+8(FP), R1 + MOVD s+0(FP), R6 + + // Load values + MOVBU 4098(R6), R2 + MOVD $0, R0 + MOVD $1, R16 + LSL R2, R16, R16 + ORR R16, R0, R0 + MOVD (R1), R3 + MOVD 16(R1), R5 + SUB $1, R0, R7 + MOVD 8(R1), R1 + MOVHU 4096(R6), R6 + + // End load values + // Init, lay down lowprob symbols + MOVD $0, R8 + JMP init_main_loop_condition + +init_main_loop: + ADD R8<<1, R1, R15 + MOVH (R15), R9 + AND $0xffff, R9, R15 + MOVD $-1, R16 + AND $0xffff, R16, R16 + CMP R16, R15 + BNE do_not_update_high_threshold + ADD R7<<3, R5, R15 + MOVB R8, 1(R15) + SUB $1, R7, R7 + MOVD $0x0000000000000001, R9 + +do_not_update_high_threshold: + ADD R8<<1, R3, R15 + MOVH R9, (R15) + ADD $1, R8, R8 + +init_main_loop_condition: + CMP R6, R8 + BLT init_main_loop + + // Spread symbols + // Calculate table step + MOVD R0, R8 + LSR $0x01, R8, R8 + MOVD R0, R9 + LSR $0x03, R9, R9 + ADD R9, R8, R8 + ADD $3, R8, R8 + + // Fill add bits values + SUB $1, R0, R9 + MOVD $0, R10 + MOVD $0, R11 + JMP spread_main_loop_condition + +spread_main_loop: + MOVD $0, R12 + ADD R11<<1, R1, R15 + MOVH (R15), R13 + JMP spread_inner_loop_condition + +spread_inner_loop: + ADD R10<<3, R5, R15 + MOVB R11, 1(R15) + +adjust_position: + ADD R8, R10, R10 + AND R9, R10, R10 + CMP R7, R10 + BGT adjust_position + ADD $1, R12, R12 + +spread_inner_loop_condition: + CMP R13, R12 + BLT spread_inner_loop + ADD $1, R11, R11 + +spread_main_loop_condition: + CMP R6, R11 + BLT spread_main_loop + TST R10, R10 + BEQ spread_check_ok + MOVD ctx+8(FP), R0 + MOVD R10, 24(R0) + MOVD $+1, R16 + MOVD R16, ret+16(FP) + RET + +spread_check_ok: + // Build Decoding table + MOVD $0, R6 + +build_table_main_table: + ADD R6<<3, R5, R15 + MOVBU 1(R15), R1 + ADD R1<<1, R3, R15 + MOVHU (R15), R7 + ADD $1, R7, R8 + ADD R1<<1, R3, R15 + MOVH R8, (R15) + MOVD R7, R8 + CLZ R8, R16 + MOVD $63, R8 + SUB R16, R8, R8 + MOVD R2, R1 + SUB R8, R1, R1 + LSL R1, R7, R7 + SUB R0, R7, R7 + ADD R6<<3, R5, R15 + MOVB R1, (R15) + ADD R6<<3, R5, R15 + MOVH R7, 2(R15) + CMP R0, R7 + BLE build_table_check1_ok + MOVD ctx+8(FP), R1 + MOVD R7, 24(R1) + MOVD R0, 32(R1) + MOVD $+2, R16 + MOVD R16, ret+16(FP) + RET + +build_table_check1_ok: + AND $0xff, R1, R15 + AND $0xff, R1, R16 + TST R16, R15 + BNE build_table_check2_ok + AND $0xffff, R7, R15 + AND $0xffff, R6, R16 + CMP R16, R15 + BNE build_table_check2_ok + MOVD ctx+8(FP), R0 + MOVD R7, 24(R0) + MOVD R6, 32(R0) + MOVD $+3, R16 + MOVD R16, ret+16(FP) + RET + +build_table_check2_ok: + ADD $1, R6, R6 + CMP R0, R6 + BLT build_table_main_table + MOVD $+0, R16 + MOVD R16, ret+16(FP) + RET diff --git a/vendor/github.com/klauspost/compress/zstd/fse_decoder_amd64.go b/vendor/github.com/klauspost/compress/zstd/fse_decoder_asm.go similarity index 81% rename from vendor/github.com/klauspost/compress/zstd/fse_decoder_amd64.go rename to vendor/github.com/klauspost/compress/zstd/fse_decoder_asm.go index b8c8607b5df..4ffc7e3c9fd 100644 --- a/vendor/github.com/klauspost/compress/zstd/fse_decoder_amd64.go +++ b/vendor/github.com/klauspost/compress/zstd/fse_decoder_asm.go @@ -1,4 +1,4 @@ -//go:build amd64 && !appengine && !noasm && gc +//go:build (amd64 || arm64) && !appengine && !noasm && gc package zstd @@ -6,6 +6,10 @@ import ( "fmt" ) +// buildDtable_asm is generated by _generate/gen_fse.go and lowered to each +// architecture (amd64 by goasm, arm64 by the avo arm64 lowering printer). The +// Go side is identical across architectures, so it lives here. + type buildDtableAsmContext struct { // inputs stateTable *uint16 @@ -18,7 +22,7 @@ type buildDtableAsmContext struct { errParam2 uint64 } -// buildDtable_asm is an x86 assembly implementation of fseDecoder.buildDtable. +// buildDtable_asm is an assembly implementation of fseDecoder.buildDtable. // Function returns non-zero exit code on error. // //go:noescape diff --git a/vendor/github.com/klauspost/compress/zstd/fse_decoder_generic.go b/vendor/github.com/klauspost/compress/zstd/fse_decoder_generic.go index 2138f8091a9..38fd2ccb2a9 100644 --- a/vendor/github.com/klauspost/compress/zstd/fse_decoder_generic.go +++ b/vendor/github.com/klauspost/compress/zstd/fse_decoder_generic.go @@ -1,4 +1,4 @@ -//go:build !amd64 || appengine || !gc || noasm +//go:build (!amd64 && !arm64) || appengine || !gc || noasm package zstd diff --git a/vendor/github.com/klauspost/compress/zstd/seqdec_amd64.go b/vendor/github.com/klauspost/compress/zstd/seqdec_amd64.go index 18c3703ddc9..1281da885c5 100644 --- a/vendor/github.com/klauspost/compress/zstd/seqdec_amd64.go +++ b/vendor/github.com/klauspost/compress/zstd/seqdec_amd64.go @@ -3,321 +3,83 @@ package zstd import ( - "fmt" - "io" - "github.com/klauspost/compress/internal/cpuinfo" ) -type decodeSyncAsmContext struct { - llTable []decSymbol - mlTable []decSymbol - ofTable []decSymbol - llState uint64 - mlState uint64 - ofState uint64 - iteration int - litRemain int - out []byte - outPosition int - literals []byte - litPosition int - history []byte - windowSize int - ll int // set on error (not for all errors, please refer to _generate/gen.go) - ml int // set on error (not for all errors, please refer to _generate/gen.go) - mo int // set on error (not for all errors, please refer to _generate/gen.go) -} +// The shared decode/decodeSync/executeSimple wrappers and context structs live +// in seqdec_asm.go; this file only declares the amd64 asm routines and the +// dispatch helpers that pick the BMI2 / non-BMI2 (and 56-bit / safe) variant. -// sequenceDecs_decodeSync_amd64 implements the main loop of sequenceDecs.decodeSync in x86 asm. +// sequenceDecs_decode implements the main loop of sequenceDecs in x86 asm. // // Please refer to seqdec_generic.go for the reference implementation. // //go:noescape -func sequenceDecs_decodeSync_amd64(s *sequenceDecs, br *bitReader, ctx *decodeSyncAsmContext) int +func sequenceDecs_decode_amd64(s *sequenceDecs, br *bitReader, ctx *decodeAsmContext) int -// sequenceDecs_decodeSync_bmi2 implements the main loop of sequenceDecs.decodeSync in x86 asm with BMI2 extensions. +// sequenceDecs_decode_56_amd64 implements the main loop of sequenceDecs in x86 asm. // //go:noescape -func sequenceDecs_decodeSync_bmi2(s *sequenceDecs, br *bitReader, ctx *decodeSyncAsmContext) int +func sequenceDecs_decode_56_amd64(s *sequenceDecs, br *bitReader, ctx *decodeAsmContext) int -// sequenceDecs_decodeSync_safe_amd64 does the same as above, but does not write more than output buffer. +// sequenceDecs_decode_bmi2 implements the main loop of sequenceDecs in x86 asm with BMI2 extensions. // //go:noescape -func sequenceDecs_decodeSync_safe_amd64(s *sequenceDecs, br *bitReader, ctx *decodeSyncAsmContext) int +func sequenceDecs_decode_bmi2(s *sequenceDecs, br *bitReader, ctx *decodeAsmContext) int -// sequenceDecs_decodeSync_safe_bmi2 does the same as above, but does not write more than output buffer. +// sequenceDecs_decode_56_bmi2 implements the main loop of sequenceDecs in x86 asm with BMI2 extensions. // //go:noescape -func sequenceDecs_decodeSync_safe_bmi2(s *sequenceDecs, br *bitReader, ctx *decodeSyncAsmContext) int - -// decode sequences from the stream with the provided history but without a dictionary. -func (s *sequenceDecs) decodeSyncSimple(hist []byte) (bool, error) { - if len(s.dict) > 0 { - return false, nil - } - if s.maxSyncLen == 0 && cap(s.out)-len(s.out) < maxCompressedBlockSize { - return false, nil - } - - // FIXME: Using unsafe memory copies leads to rare, random crashes - // with fuzz testing. It is therefore disabled for now. - const useSafe = true - /* - useSafe := false - if s.maxSyncLen == 0 && cap(s.out)-len(s.out) < maxCompressedBlockSizeAlloc { - useSafe = true - } - if s.maxSyncLen > 0 && cap(s.out)-len(s.out)-compressedBlockOverAlloc < int(s.maxSyncLen) { - useSafe = true - } - if cap(s.literals) < len(s.literals)+compressedBlockOverAlloc { - useSafe = true - } - */ - - br := s.br - - maxBlockSize := min(s.windowSize, maxCompressedBlockSize) - - ctx := decodeSyncAsmContext{ - llTable: s.litLengths.fse.dt[:maxTablesize], - mlTable: s.matchLengths.fse.dt[:maxTablesize], - ofTable: s.offsets.fse.dt[:maxTablesize], - llState: uint64(s.litLengths.state.state), - mlState: uint64(s.matchLengths.state.state), - ofState: uint64(s.offsets.state.state), - iteration: s.nSeqs - 1, - litRemain: len(s.literals), - out: s.out, - outPosition: len(s.out), - literals: s.literals, - windowSize: s.windowSize, - history: hist, - } - - s.seqSize = 0 - startSize := len(s.out) +func sequenceDecs_decode_56_bmi2(s *sequenceDecs, br *bitReader, ctx *decodeAsmContext) int - var errCode int +// decodeAsm runs the sequenceDecs decode loop, choosing the BMI2 / 56-bit variant. +func decodeAsm(s *sequenceDecs, br *bitReader, ctx *decodeAsmContext, lte56bits bool) int { if cpuinfo.HasBMI2() { - if useSafe { - errCode = sequenceDecs_decodeSync_safe_bmi2(s, br, &ctx) - } else { - errCode = sequenceDecs_decodeSync_bmi2(s, br, &ctx) - } - } else { - if useSafe { - errCode = sequenceDecs_decodeSync_safe_amd64(s, br, &ctx) - } else { - errCode = sequenceDecs_decodeSync_amd64(s, br, &ctx) - } - } - switch errCode { - case noError: - break - - case errorMatchLenOfsMismatch: - return true, fmt.Errorf("zero matchoff and matchlen (%d) > 0", ctx.ml) - - case errorMatchLenTooBig: - return true, fmt.Errorf("match len (%d) bigger than max allowed length", ctx.ml) - - case errorMatchOffTooBig: - return true, fmt.Errorf("match offset (%d) bigger than current history (%d)", - ctx.mo, ctx.outPosition+len(hist)-startSize) - - case errorNotEnoughLiterals: - return true, fmt.Errorf("unexpected literal count, want %d bytes, but only %d is available", - ctx.ll, ctx.litRemain+ctx.ll) - - case errorOverread: - return true, io.ErrUnexpectedEOF - - case errorNotEnoughSpace: - size := ctx.outPosition + ctx.ll + ctx.ml - if debugDecoder { - println("msl:", s.maxSyncLen, "cap", cap(s.out), "bef:", startSize, "sz:", size-startSize, "mbs:", maxBlockSize, "outsz:", cap(s.out)-startSize) + if lte56bits { + return sequenceDecs_decode_56_bmi2(s, br, ctx) } - return true, fmt.Errorf("output bigger than max block size (%d)", maxBlockSize) - - default: - return true, fmt.Errorf("sequenceDecs_decode returned erroneous code %d", errCode) - } - - s.seqSize += ctx.litRemain - if s.seqSize > maxBlockSize { - return true, fmt.Errorf("output bigger than max block size (%d)", maxBlockSize) + return sequenceDecs_decode_bmi2(s, br, ctx) } - err := br.close() - if err != nil { - printf("Closing sequences: %v, %+v\n", err, *br) - return true, err + if lte56bits { + return sequenceDecs_decode_56_amd64(s, br, ctx) } - - s.literals = s.literals[ctx.litPosition:] - t := ctx.outPosition - s.out = s.out[:t] - - // Add final literals - s.out = append(s.out, s.literals...) - if debugDecoder { - t += len(s.literals) - if t != len(s.out) { - panic(fmt.Errorf("length mismatch, want %d, got %d", len(s.out), t)) - } - } - - return true, nil + return sequenceDecs_decode_amd64(s, br, ctx) } -// -------------------------------------------------------------------------------- - -type decodeAsmContext struct { - llTable []decSymbol - mlTable []decSymbol - ofTable []decSymbol - llState uint64 - mlState uint64 - ofState uint64 - iteration int - seqs []seqVals - litRemain int -} - -const noError = 0 - -// error reported when mo == 0 && ml > 0 -const errorMatchLenOfsMismatch = 1 - -// error reported when ml > maxMatchLen -const errorMatchLenTooBig = 2 - -// error reported when mo > available history or mo > s.windowSize -const errorMatchOffTooBig = 3 - -// error reported when the sum of literal lengths exeeceds the literal buffer size -const errorNotEnoughLiterals = 4 - -// error reported when capacity of `out` is too small -const errorNotEnoughSpace = 5 - -// error reported when bits are overread. -const errorOverread = 6 - -// sequenceDecs_decode implements the main loop of sequenceDecs in x86 asm. +// sequenceDecs_decodeSync_amd64 implements the main loop of sequenceDecs.decodeSync in x86 asm. // // Please refer to seqdec_generic.go for the reference implementation. // //go:noescape -func sequenceDecs_decode_amd64(s *sequenceDecs, br *bitReader, ctx *decodeAsmContext) int +func sequenceDecs_decodeSync_amd64(s *sequenceDecs, br *bitReader, ctx *decodeSyncAsmContext) int -// sequenceDecs_decode implements the main loop of sequenceDecs in x86 asm. -// -// Please refer to seqdec_generic.go for the reference implementation. +// sequenceDecs_decodeSync_bmi2 implements the main loop of sequenceDecs.decodeSync in x86 asm with BMI2 extensions. // //go:noescape -func sequenceDecs_decode_56_amd64(s *sequenceDecs, br *bitReader, ctx *decodeAsmContext) int +func sequenceDecs_decodeSync_bmi2(s *sequenceDecs, br *bitReader, ctx *decodeSyncAsmContext) int -// sequenceDecs_decode implements the main loop of sequenceDecs in x86 asm with BMI2 extensions. +// sequenceDecs_decodeSync_safe_amd64 does the same as above, but does not write more than output buffer. // //go:noescape -func sequenceDecs_decode_bmi2(s *sequenceDecs, br *bitReader, ctx *decodeAsmContext) int +func sequenceDecs_decodeSync_safe_amd64(s *sequenceDecs, br *bitReader, ctx *decodeSyncAsmContext) int -// sequenceDecs_decode implements the main loop of sequenceDecs in x86 asm with BMI2 extensions. +// sequenceDecs_decodeSync_safe_bmi2 does the same as above, but does not write more than output buffer. // //go:noescape -func sequenceDecs_decode_56_bmi2(s *sequenceDecs, br *bitReader, ctx *decodeAsmContext) int - -// decode sequences from the stream without the provided history. -func (s *sequenceDecs) decode(seqs []seqVals) error { - br := s.br - - maxBlockSize := min(s.windowSize, maxCompressedBlockSize) - - ctx := decodeAsmContext{ - llTable: s.litLengths.fse.dt[:maxTablesize], - mlTable: s.matchLengths.fse.dt[:maxTablesize], - ofTable: s.offsets.fse.dt[:maxTablesize], - llState: uint64(s.litLengths.state.state), - mlState: uint64(s.matchLengths.state.state), - ofState: uint64(s.offsets.state.state), - seqs: seqs, - iteration: len(seqs) - 1, - litRemain: len(s.literals), - } - - if debugDecoder { - println("decode: decoding", len(seqs), "sequences", br.remain(), "bits remain on stream") - } +func sequenceDecs_decodeSync_safe_bmi2(s *sequenceDecs, br *bitReader, ctx *decodeSyncAsmContext) int - s.seqSize = 0 - lte56bits := s.maxBits+s.offsets.fse.actualTableLog+s.matchLengths.fse.actualTableLog+s.litLengths.fse.actualTableLog <= 56 - var errCode int +// decodeSyncAsm runs the decodeSync loop, choosing the BMI2 / safe variant. +func decodeSyncAsm(s *sequenceDecs, br *bitReader, ctx *decodeSyncAsmContext, safe bool) int { if cpuinfo.HasBMI2() { - if lte56bits { - errCode = sequenceDecs_decode_56_bmi2(s, br, &ctx) - } else { - errCode = sequenceDecs_decode_bmi2(s, br, &ctx) - } - } else { - if lte56bits { - errCode = sequenceDecs_decode_56_amd64(s, br, &ctx) - } else { - errCode = sequenceDecs_decode_amd64(s, br, &ctx) + if safe { + return sequenceDecs_decodeSync_safe_bmi2(s, br, ctx) } + return sequenceDecs_decodeSync_bmi2(s, br, ctx) } - if errCode != 0 { - i := len(seqs) - ctx.iteration - 1 - switch errCode { - case errorMatchLenOfsMismatch: - ml := ctx.seqs[i].ml - return fmt.Errorf("zero matchoff and matchlen (%d) > 0", ml) - - case errorMatchLenTooBig: - ml := ctx.seqs[i].ml - return fmt.Errorf("match len (%d) bigger than max allowed length", ml) - - case errorNotEnoughLiterals: - ll := ctx.seqs[i].ll - return fmt.Errorf("unexpected literal count, want %d bytes, but only %d is available", ll, ctx.litRemain+ll) - case errorOverread: - return io.ErrUnexpectedEOF - } - - return fmt.Errorf("sequenceDecs_decode_amd64 returned erroneous code %d", errCode) + if safe { + return sequenceDecs_decodeSync_safe_amd64(s, br, ctx) } - - if ctx.litRemain < 0 { - return fmt.Errorf("literal count is too big: total available %d, total requested %d", - len(s.literals), len(s.literals)-ctx.litRemain) - } - - s.seqSize += ctx.litRemain - if s.seqSize > maxBlockSize { - return fmt.Errorf("output bigger than max block size (%d)", maxBlockSize) - } - if debugDecoder { - println("decode: ", br.remain(), "bits remain on stream. code:", errCode) - } - err := br.close() - if err != nil { - printf("Closing sequences: %v, %+v\n", err, *br) - } - return err -} - -// -------------------------------------------------------------------------------- - -type executeAsmContext struct { - seqs []seqVals - seqIndex int - out []byte - history []byte - literals []byte - outPosition int - litPosition int - windowSize int + return sequenceDecs_decodeSync_amd64(s, br, ctx) } // sequenceDecs_executeSimple_amd64 implements the main loop of sequenceDecs.executeSimple in x86 asm. @@ -334,54 +96,10 @@ func sequenceDecs_executeSimple_amd64(ctx *executeAsmContext) bool //go:noescape func sequenceDecs_executeSimple_safe_amd64(ctx *executeAsmContext) bool -// executeSimple handles cases when dictionary is not used. -func (s *sequenceDecs) executeSimple(seqs []seqVals, hist []byte) error { - // Ensure we have enough output size... - if len(s.out)+s.seqSize+compressedBlockOverAlloc > cap(s.out) { - addBytes := s.seqSize + len(s.out) + compressedBlockOverAlloc - s.out = append(s.out, make([]byte, addBytes)...) - s.out = s.out[:len(s.out)-addBytes] - } - - if debugDecoder { - printf("Execute %d seqs with literals: %d into %d bytes\n", len(seqs), len(s.literals), s.seqSize) - } - - var t = len(s.out) - out := s.out[:t+s.seqSize] - - ctx := executeAsmContext{ - seqs: seqs, - seqIndex: 0, - out: out, - history: hist, - outPosition: t, - litPosition: 0, - literals: s.literals, - windowSize: s.windowSize, +// executeSimpleAsm runs the executeSimple loop, choosing the safe variant. +func executeSimpleAsm(ctx *executeAsmContext, safe bool) bool { + if safe { + return sequenceDecs_executeSimple_safe_amd64(ctx) } - var ok bool - if cap(s.literals) < len(s.literals)+compressedBlockOverAlloc { - ok = sequenceDecs_executeSimple_safe_amd64(&ctx) - } else { - ok = sequenceDecs_executeSimple_amd64(&ctx) - } - if !ok { - return fmt.Errorf("match offset (%d) bigger than current history (%d)", - seqs[ctx.seqIndex].mo, ctx.outPosition+len(hist)) - } - s.literals = s.literals[ctx.litPosition:] - t = ctx.outPosition - - // Add final literals - copy(out[t:], s.literals) - if debugDecoder { - t += len(s.literals) - if t != len(out) { - panic(fmt.Errorf("length mismatch, want %d, got %d, ss: %d", len(out), t, s.seqSize)) - } - } - s.out = out - - return nil + return sequenceDecs_executeSimple_amd64(ctx) } diff --git a/vendor/github.com/klauspost/compress/zstd/seqdec_amd64.s b/vendor/github.com/klauspost/compress/zstd/seqdec_amd64.s index a708ca6d3d9..4d3188ff49b 100644 --- a/vendor/github.com/klauspost/compress/zstd/seqdec_amd64.s +++ b/vendor/github.com/klauspost/compress/zstd/seqdec_amd64.s @@ -1,4 +1,4 @@ -// Code generated by command: go run gen.go -out ../seqdec_amd64.s -pkg=zstd. DO NOT EDIT. +// Code generated by command: go run gen.go -out ../seqdec.s -arch amd64,arm64 -pkg=zstd. DO NOT EDIT. //go:build !appengine && !noasm && gc && !noasm @@ -2081,7 +2081,7 @@ sequenceDecs_decodeSync_amd64_match_len_ofs_ok: MOVQ 16(SP), R13 // Check if we have enough space in s.out - LEAQ (AX)(R13*1), R14 + LEAQ 16(AX)(R13*1), R14 ADDQ R10, R14 CMPQ R14, 32(SP) JA error_not_enough_space @@ -2601,7 +2601,7 @@ sequenceDecs_decodeSync_bmi2_match_len_ofs_ok: MOVQ 16(SP), R13 // Check if we have enough space in s.out - LEAQ (CX)(R13*1), R14 + LEAQ 16(CX)(R13*1), R14 ADDQ R9, R14 CMPQ R14, 32(SP) JA error_not_enough_space diff --git a/vendor/github.com/klauspost/compress/zstd/seqdec_arm64.go b/vendor/github.com/klauspost/compress/zstd/seqdec_arm64.go new file mode 100644 index 00000000000..5ad262acff0 --- /dev/null +++ b/vendor/github.com/klauspost/compress/zstd/seqdec_arm64.go @@ -0,0 +1,70 @@ +//go:build arm64 && !appengine && !noasm && gc + +package zstd + +// The shared decode/decodeSync/executeSimple wrappers and context structs live +// in seqdec_asm.go; this file only declares the arm64 asm routines (generated +// by the avo arm64 lowering printer) and the dispatch helpers. arm64 has no +// BMI2, so each helper selects only between the 56-bit / safe variants. + +// sequenceDecs_decode_arm64 implements the main loop of sequenceDecs in arm64 asm. +// +// Please refer to seqdec_generic.go for the reference implementation. +// +//go:noescape +func sequenceDecs_decode_arm64(s *sequenceDecs, br *bitReader, ctx *decodeAsmContext) int + +// sequenceDecs_decode_56_arm64 implements the main loop of sequenceDecs in arm64 asm. +// +//go:noescape +func sequenceDecs_decode_56_arm64(s *sequenceDecs, br *bitReader, ctx *decodeAsmContext) int + +// decodeAsm runs the sequenceDecs decode loop, choosing the 56-bit variant. +func decodeAsm(s *sequenceDecs, br *bitReader, ctx *decodeAsmContext, lte56bits bool) int { + if lte56bits { + return sequenceDecs_decode_56_arm64(s, br, ctx) + } + return sequenceDecs_decode_arm64(s, br, ctx) +} + +// sequenceDecs_decodeSync_arm64 implements the main loop of sequenceDecs.decodeSync in arm64 asm. +// +// Please refer to seqdec_generic.go for the reference implementation. +// +//go:noescape +func sequenceDecs_decodeSync_arm64(s *sequenceDecs, br *bitReader, ctx *decodeSyncAsmContext) int + +// sequenceDecs_decodeSync_safe_arm64 does the same as above, but does not write more than output buffer. +// +//go:noescape +func sequenceDecs_decodeSync_safe_arm64(s *sequenceDecs, br *bitReader, ctx *decodeSyncAsmContext) int + +// decodeSyncAsm runs the decodeSync loop, choosing the safe variant. +func decodeSyncAsm(s *sequenceDecs, br *bitReader, ctx *decodeSyncAsmContext, safe bool) int { + if safe { + return sequenceDecs_decodeSync_safe_arm64(s, br, ctx) + } + return sequenceDecs_decodeSync_arm64(s, br, ctx) +} + +// sequenceDecs_executeSimple_arm64 implements the main loop of sequenceDecs.executeSimple in arm64 asm. +// +// Returns false if a match offset is too big. +// +// Please refer to seqdec_generic.go for the reference implementation. +// +//go:noescape +func sequenceDecs_executeSimple_arm64(ctx *executeAsmContext) bool + +// Same as above, but with safe memcopies +// +//go:noescape +func sequenceDecs_executeSimple_safe_arm64(ctx *executeAsmContext) bool + +// executeSimpleAsm runs the executeSimple loop, choosing the safe variant. +func executeSimpleAsm(ctx *executeAsmContext, safe bool) bool { + if safe { + return sequenceDecs_executeSimple_safe_arm64(ctx) + } + return sequenceDecs_executeSimple_arm64(ctx) +} diff --git a/vendor/github.com/klauspost/compress/zstd/seqdec_arm64.s b/vendor/github.com/klauspost/compress/zstd/seqdec_arm64.s new file mode 100644 index 00000000000..6f54ef21ba1 --- /dev/null +++ b/vendor/github.com/klauspost/compress/zstd/seqdec_arm64.s @@ -0,0 +1,2750 @@ +// Code generated by command: go run gen.go -out ../seqdec.s -arch amd64,arm64 -pkg=zstd. DO NOT EDIT. +// EXPERIMENTAL arm64 output lowered from an amd64 avo program. + +//go:build arm64 && !appengine && !noasm && gc && !noasm + +// func sequenceDecs_decode_amd64(s *sequenceDecs, br *bitReader, ctx *decodeAsmContext) int +// Requires: CMOV +TEXT ·sequenceDecs_decode_arm64(SB), $8-32 + MOVD br+8(FP), R1 + MOVD 24(R1), R2 + MOVBU 40(R1), R3 + MOVD (R1), R0 + MOVD 32(R1), R5 + ADD R5, R0, R0 + MOVD R0, 8(RSP) + MOVD ctx+16(FP), R0 + MOVD 72(R0), R6 + MOVD 80(R0), R7 + MOVD 88(R0), R8 + MOVD 104(R0), R9 + MOVD s+0(FP), R0 + MOVD 144(R0), R10 + MOVD 152(R0), R11 + MOVD 160(R0), R12 + +sequenceDecs_decode_amd64_main_loop: + MOVD 8(RSP), R13 + + // Fill bitreader to have enough for the offset and match length. + CMP $0x08, R5 + BLT sequenceDecs_decode_amd64_fill_byte_by_byte + MOVD R3, R0 + LSR $0x03, R0, R0 + SUB R0, R13, R13 + MOVD (R13), R2 + SUB R0, R5, R5 + AND $0x07, R3, R3 + JMP sequenceDecs_decode_amd64_fill_end + +sequenceDecs_decode_amd64_fill_byte_by_byte: + CMP $0x00, R5 + BLE sequenceDecs_decode_amd64_fill_check_overread + CMP $0x07, R3 + BLE sequenceDecs_decode_amd64_fill_end + LSL $0x08, R2, R2 + SUB $0x01, R13, R13 + SUB $0x01, R5, R5 + SUB $0x08, R3, R3 + MOVBU (R13), R0 + ORR R0, R2, R2 + JMP sequenceDecs_decode_amd64_fill_byte_by_byte + +sequenceDecs_decode_amd64_fill_check_overread: + CMP $0x40, R3 + BHI error_overread + +sequenceDecs_decode_amd64_fill_end: + // Update offset + MOVD R8, R0 + MOVD R3, R1 + MOVD R2, R14 + LSL R1, R14, R14 + UBFX $8, R0, $8, R16 + BFI $0, R16, $8, R1 + LSR $0x20, R0, R0 + TST R1, R1 + BEQ sequenceDecs_decode_amd64_of_update_zero + ADD R1, R3, R3 + CMP $0x40, R3 + BHI sequenceDecs_decode_amd64_of_update_zero + CMP $0x40, R1 + BHS sequenceDecs_decode_amd64_of_update_zero + NEG R1, R1 + LSR R1, R14, R14 + ADD R14, R0, R0 + +sequenceDecs_decode_amd64_of_update_zero: + MOVD R0, 16(R9) + + // Update match length + MOVD R7, R0 + MOVD R3, R1 + MOVD R2, R14 + LSL R1, R14, R14 + UBFX $8, R0, $8, R16 + BFI $0, R16, $8, R1 + LSR $0x20, R0, R0 + TST R1, R1 + BEQ sequenceDecs_decode_amd64_ml_update_zero + ADD R1, R3, R3 + CMP $0x40, R3 + BHI sequenceDecs_decode_amd64_ml_update_zero + CMP $0x40, R1 + BHS sequenceDecs_decode_amd64_ml_update_zero + NEG R1, R1 + LSR R1, R14, R14 + ADD R14, R0, R0 + +sequenceDecs_decode_amd64_ml_update_zero: + MOVD R0, 8(R9) + + // Fill bitreader to have enough for the remaining + CMP $0x08, R5 + BLT sequenceDecs_decode_amd64_fill_2_byte_by_byte + MOVD R3, R0 + LSR $0x03, R0, R0 + SUB R0, R13, R13 + MOVD (R13), R2 + SUB R0, R5, R5 + AND $0x07, R3, R3 + JMP sequenceDecs_decode_amd64_fill_2_end + +sequenceDecs_decode_amd64_fill_2_byte_by_byte: + CMP $0x00, R5 + BLE sequenceDecs_decode_amd64_fill_2_check_overread + CMP $0x07, R3 + BLE sequenceDecs_decode_amd64_fill_2_end + LSL $0x08, R2, R2 + SUB $0x01, R13, R13 + SUB $0x01, R5, R5 + SUB $0x08, R3, R3 + MOVBU (R13), R0 + ORR R0, R2, R2 + JMP sequenceDecs_decode_amd64_fill_2_byte_by_byte + +sequenceDecs_decode_amd64_fill_2_check_overread: + CMP $0x40, R3 + BHI error_overread + +sequenceDecs_decode_amd64_fill_2_end: + // Update literal length + MOVD R6, R0 + MOVD R3, R1 + MOVD R2, R14 + LSL R1, R14, R14 + UBFX $8, R0, $8, R16 + BFI $0, R16, $8, R1 + LSR $0x20, R0, R0 + TST R1, R1 + BEQ sequenceDecs_decode_amd64_ll_update_zero + ADD R1, R3, R3 + CMP $0x40, R3 + BHI sequenceDecs_decode_amd64_ll_update_zero + CMP $0x40, R1 + BHS sequenceDecs_decode_amd64_ll_update_zero + NEG R1, R1 + LSR R1, R14, R14 + ADD R14, R0, R0 + +sequenceDecs_decode_amd64_ll_update_zero: + MOVD R0, (R9) + + // Fill bitreader for state updates + MOVD R13, 8(RSP) + MOVD R8, R0 + LSR $0x08, R0, R0 + MOVBU R0, R0 + MOVD ctx+16(FP), R1 + MOVD 96(R1), R16 + CMP $0x00, R16 + BEQ sequenceDecs_decode_amd64_skip_update + + // Update Literal Length State + MOVBU R6, R13 + LSRW $0x10, R6, R6 + ADD R13, R3, R1 + MOVD R2, R14 + MOVD R1, R3 + NEG R1, R16 + ROR R16, R14, R14 + MOVD $0x00000001, R4 + BFI $0, R13, $8, R1 + LSLW R1, R4, R4 + SUBW $1, R4, R4 + AND R4, R14, R14 + ADD R14, R6, R6 + + // Load ctx.llTable + MOVD ctx+16(FP), R1 + MOVD (R1), R1 + ADD R6<<3, R1, R15 + MOVD (R15), R6 + + // Update Match Length State + MOVBU R7, R13 + LSRW $0x10, R7, R7 + ADD R13, R3, R1 + MOVD R2, R14 + MOVD R1, R3 + NEG R1, R16 + ROR R16, R14, R14 + MOVD $0x00000001, R4 + BFI $0, R13, $8, R1 + LSLW R1, R4, R4 + SUBW $1, R4, R4 + AND R4, R14, R14 + ADD R14, R7, R7 + + // Load ctx.mlTable + MOVD ctx+16(FP), R1 + MOVD 24(R1), R1 + ADD R7<<3, R1, R15 + MOVD (R15), R7 + + // Update Offset State + MOVBU R8, R13 + LSRW $0x10, R8, R8 + ADD R13, R3, R1 + MOVD R2, R14 + MOVD R1, R3 + NEG R1, R16 + ROR R16, R14, R14 + MOVD $0x00000001, R4 + BFI $0, R13, $8, R1 + LSLW R1, R4, R4 + SUBW $1, R4, R4 + AND R4, R14, R14 + ADD R14, R8, R8 + + // Load ctx.ofTable + MOVD ctx+16(FP), R1 + MOVD 48(R1), R1 + ADD R8<<3, R1, R15 + MOVD (R15), R8 + +sequenceDecs_decode_amd64_skip_update: + // Adjust offset + MOVD 16(R9), R1 + CMP $0x01, R0 + BLS sequenceDecs_decode_amd64_adjust_offsetB_1_or_0 + MOVD R11, R12 + MOVD R10, R11 + MOVD R1, R10 + JMP sequenceDecs_decode_amd64_after_adjust + +sequenceDecs_decode_amd64_adjust_offsetB_1_or_0: + MOVD (R9), R16 + CMP $0x00000000, R16 + BNE sequenceDecs_decode_amd64_adjust_offset_maybezero + ADD $1, R1, R1 + JMP sequenceDecs_decode_amd64_adjust_offset_nonzero + +sequenceDecs_decode_amd64_adjust_offset_maybezero: + TST R1, R1 + BNE sequenceDecs_decode_amd64_adjust_offset_nonzero + MOVD R10, R1 + JMP sequenceDecs_decode_amd64_after_adjust + +sequenceDecs_decode_amd64_adjust_offset_nonzero: + CMP $0x01, R1 + BLO sequenceDecs_decode_amd64_adjust_zero + BEQ sequenceDecs_decode_amd64_adjust_one + CMP $0x02, R1 + BHI sequenceDecs_decode_amd64_adjust_three + JMP sequenceDecs_decode_amd64_adjust_two + +sequenceDecs_decode_amd64_adjust_zero: + MOVD R10, R0 + JMP sequenceDecs_decode_amd64_adjust_test_temp_valid + +sequenceDecs_decode_amd64_adjust_one: + MOVD R11, R0 + JMP sequenceDecs_decode_amd64_adjust_test_temp_valid + +sequenceDecs_decode_amd64_adjust_two: + MOVD R12, R0 + JMP sequenceDecs_decode_amd64_adjust_test_temp_valid + +sequenceDecs_decode_amd64_adjust_three: + SUB $1, R10, R0 + +sequenceDecs_decode_amd64_adjust_test_temp_valid: + TST R0, R0 + BNE sequenceDecs_decode_amd64_adjust_temp_valid + MOVD $0x00000001, R0 + +sequenceDecs_decode_amd64_adjust_temp_valid: + CMP $0x01, R1 + CSEL NE, R11, R12, R12 + MOVD R10, R11 + MOVD R0, R10 + MOVD R0, R1 + +sequenceDecs_decode_amd64_after_adjust: + MOVD R1, 16(R9) + + // Check values + MOVD 8(R9), R0 + MOVD (R9), R13 + ADD R13, R0, R14 + MOVD s+0(FP), R4 + MOVD 256(R4), R16 + ADD R14, R16, R16 + MOVD R16, 256(R4) + MOVD ctx+16(FP), R14 + MOVD 128(R14), R16 + SUBS R13, R16, R16 + MOVD R16, 128(R14) + BMI error_not_enough_literals + CMP $0x00020002, R0 + BHI sequenceDecs_decode_amd64_error_match_len_too_big + TST R1, R1 + BNE sequenceDecs_decode_amd64_match_len_ofs_ok + TST R0, R0 + BNE sequenceDecs_decode_amd64_error_match_len_ofs_mismatch + +sequenceDecs_decode_amd64_match_len_ofs_ok: + ADD $0x18, R9, R9 + MOVD ctx+16(FP), R0 + MOVD 96(R0), R16 + SUBS $1, R16, R16 + MOVD R16, 96(R0) + BPL sequenceDecs_decode_amd64_main_loop + MOVD s+0(FP), R0 + MOVD R10, 144(R0) + MOVD R11, 152(R0) + MOVD R12, 160(R0) + MOVD br+8(FP), R0 + MOVD R2, 24(R0) + MOVB R3, 40(R0) + MOVD R5, 32(R0) + + // Return success + MOVD $0x00000000, R16 + MOVD R16, ret+24(FP) + RET + + // Return with match length error +sequenceDecs_decode_amd64_error_match_len_ofs_mismatch: + MOVD $0x00000001, R16 + MOVD R16, ret+24(FP) + RET + + // Return with match too long error +sequenceDecs_decode_amd64_error_match_len_too_big: + MOVD $0x00000002, R16 + MOVD R16, ret+24(FP) + RET + + // Return with match offset too long error + MOVD $0x00000003, R16 + MOVD R16, ret+24(FP) + RET + + // Return with not enough literals error +error_not_enough_literals: + MOVD $0x00000004, R16 + MOVD R16, ret+24(FP) + RET + + // Return with overread error +error_overread: + MOVD $0x00000006, R16 + MOVD R16, ret+24(FP) + RET + +// func sequenceDecs_decode_56_amd64(s *sequenceDecs, br *bitReader, ctx *decodeAsmContext) int +// Requires: CMOV +TEXT ·sequenceDecs_decode_56_arm64(SB), $8-32 + MOVD br+8(FP), R1 + MOVD 24(R1), R2 + MOVBU 40(R1), R3 + MOVD (R1), R0 + MOVD 32(R1), R5 + ADD R5, R0, R0 + MOVD R0, 8(RSP) + MOVD ctx+16(FP), R0 + MOVD 72(R0), R6 + MOVD 80(R0), R7 + MOVD 88(R0), R8 + MOVD 104(R0), R9 + MOVD s+0(FP), R0 + MOVD 144(R0), R10 + MOVD 152(R0), R11 + MOVD 160(R0), R12 + +sequenceDecs_decode_56_amd64_main_loop: + MOVD 8(RSP), R13 + + // Fill bitreader to have enough for the offset and match length. + CMP $0x08, R5 + BLT sequenceDecs_decode_56_amd64_fill_byte_by_byte + MOVD R3, R0 + LSR $0x03, R0, R0 + SUB R0, R13, R13 + MOVD (R13), R2 + SUB R0, R5, R5 + AND $0x07, R3, R3 + JMP sequenceDecs_decode_56_amd64_fill_end + +sequenceDecs_decode_56_amd64_fill_byte_by_byte: + CMP $0x00, R5 + BLE sequenceDecs_decode_56_amd64_fill_check_overread + CMP $0x07, R3 + BLE sequenceDecs_decode_56_amd64_fill_end + LSL $0x08, R2, R2 + SUB $0x01, R13, R13 + SUB $0x01, R5, R5 + SUB $0x08, R3, R3 + MOVBU (R13), R0 + ORR R0, R2, R2 + JMP sequenceDecs_decode_56_amd64_fill_byte_by_byte + +sequenceDecs_decode_56_amd64_fill_check_overread: + CMP $0x40, R3 + BHI error_overread + +sequenceDecs_decode_56_amd64_fill_end: + // Update offset + MOVD R8, R0 + MOVD R3, R1 + MOVD R2, R14 + LSL R1, R14, R14 + UBFX $8, R0, $8, R16 + BFI $0, R16, $8, R1 + LSR $0x20, R0, R0 + TST R1, R1 + BEQ sequenceDecs_decode_56_amd64_of_update_zero + ADD R1, R3, R3 + CMP $0x40, R3 + BHI sequenceDecs_decode_56_amd64_of_update_zero + CMP $0x40, R1 + BHS sequenceDecs_decode_56_amd64_of_update_zero + NEG R1, R1 + LSR R1, R14, R14 + ADD R14, R0, R0 + +sequenceDecs_decode_56_amd64_of_update_zero: + MOVD R0, 16(R9) + + // Update match length + MOVD R7, R0 + MOVD R3, R1 + MOVD R2, R14 + LSL R1, R14, R14 + UBFX $8, R0, $8, R16 + BFI $0, R16, $8, R1 + LSR $0x20, R0, R0 + TST R1, R1 + BEQ sequenceDecs_decode_56_amd64_ml_update_zero + ADD R1, R3, R3 + CMP $0x40, R3 + BHI sequenceDecs_decode_56_amd64_ml_update_zero + CMP $0x40, R1 + BHS sequenceDecs_decode_56_amd64_ml_update_zero + NEG R1, R1 + LSR R1, R14, R14 + ADD R14, R0, R0 + +sequenceDecs_decode_56_amd64_ml_update_zero: + MOVD R0, 8(R9) + + // Update literal length + MOVD R6, R0 + MOVD R3, R1 + MOVD R2, R14 + LSL R1, R14, R14 + UBFX $8, R0, $8, R16 + BFI $0, R16, $8, R1 + LSR $0x20, R0, R0 + TST R1, R1 + BEQ sequenceDecs_decode_56_amd64_ll_update_zero + ADD R1, R3, R3 + CMP $0x40, R3 + BHI sequenceDecs_decode_56_amd64_ll_update_zero + CMP $0x40, R1 + BHS sequenceDecs_decode_56_amd64_ll_update_zero + NEG R1, R1 + LSR R1, R14, R14 + ADD R14, R0, R0 + +sequenceDecs_decode_56_amd64_ll_update_zero: + MOVD R0, (R9) + + // Fill bitreader for state updates + MOVD R13, 8(RSP) + MOVD R8, R0 + LSR $0x08, R0, R0 + MOVBU R0, R0 + MOVD ctx+16(FP), R1 + MOVD 96(R1), R16 + CMP $0x00, R16 + BEQ sequenceDecs_decode_56_amd64_skip_update + + // Update Literal Length State + MOVBU R6, R13 + LSRW $0x10, R6, R6 + ADD R13, R3, R1 + MOVD R2, R14 + MOVD R1, R3 + NEG R1, R16 + ROR R16, R14, R14 + MOVD $0x00000001, R4 + BFI $0, R13, $8, R1 + LSLW R1, R4, R4 + SUBW $1, R4, R4 + AND R4, R14, R14 + ADD R14, R6, R6 + + // Load ctx.llTable + MOVD ctx+16(FP), R1 + MOVD (R1), R1 + ADD R6<<3, R1, R15 + MOVD (R15), R6 + + // Update Match Length State + MOVBU R7, R13 + LSRW $0x10, R7, R7 + ADD R13, R3, R1 + MOVD R2, R14 + MOVD R1, R3 + NEG R1, R16 + ROR R16, R14, R14 + MOVD $0x00000001, R4 + BFI $0, R13, $8, R1 + LSLW R1, R4, R4 + SUBW $1, R4, R4 + AND R4, R14, R14 + ADD R14, R7, R7 + + // Load ctx.mlTable + MOVD ctx+16(FP), R1 + MOVD 24(R1), R1 + ADD R7<<3, R1, R15 + MOVD (R15), R7 + + // Update Offset State + MOVBU R8, R13 + LSRW $0x10, R8, R8 + ADD R13, R3, R1 + MOVD R2, R14 + MOVD R1, R3 + NEG R1, R16 + ROR R16, R14, R14 + MOVD $0x00000001, R4 + BFI $0, R13, $8, R1 + LSLW R1, R4, R4 + SUBW $1, R4, R4 + AND R4, R14, R14 + ADD R14, R8, R8 + + // Load ctx.ofTable + MOVD ctx+16(FP), R1 + MOVD 48(R1), R1 + ADD R8<<3, R1, R15 + MOVD (R15), R8 + +sequenceDecs_decode_56_amd64_skip_update: + // Adjust offset + MOVD 16(R9), R1 + CMP $0x01, R0 + BLS sequenceDecs_decode_56_amd64_adjust_offsetB_1_or_0 + MOVD R11, R12 + MOVD R10, R11 + MOVD R1, R10 + JMP sequenceDecs_decode_56_amd64_after_adjust + +sequenceDecs_decode_56_amd64_adjust_offsetB_1_or_0: + MOVD (R9), R16 + CMP $0x00000000, R16 + BNE sequenceDecs_decode_56_amd64_adjust_offset_maybezero + ADD $1, R1, R1 + JMP sequenceDecs_decode_56_amd64_adjust_offset_nonzero + +sequenceDecs_decode_56_amd64_adjust_offset_maybezero: + TST R1, R1 + BNE sequenceDecs_decode_56_amd64_adjust_offset_nonzero + MOVD R10, R1 + JMP sequenceDecs_decode_56_amd64_after_adjust + +sequenceDecs_decode_56_amd64_adjust_offset_nonzero: + CMP $0x01, R1 + BLO sequenceDecs_decode_56_amd64_adjust_zero + BEQ sequenceDecs_decode_56_amd64_adjust_one + CMP $0x02, R1 + BHI sequenceDecs_decode_56_amd64_adjust_three + JMP sequenceDecs_decode_56_amd64_adjust_two + +sequenceDecs_decode_56_amd64_adjust_zero: + MOVD R10, R0 + JMP sequenceDecs_decode_56_amd64_adjust_test_temp_valid + +sequenceDecs_decode_56_amd64_adjust_one: + MOVD R11, R0 + JMP sequenceDecs_decode_56_amd64_adjust_test_temp_valid + +sequenceDecs_decode_56_amd64_adjust_two: + MOVD R12, R0 + JMP sequenceDecs_decode_56_amd64_adjust_test_temp_valid + +sequenceDecs_decode_56_amd64_adjust_three: + SUB $1, R10, R0 + +sequenceDecs_decode_56_amd64_adjust_test_temp_valid: + TST R0, R0 + BNE sequenceDecs_decode_56_amd64_adjust_temp_valid + MOVD $0x00000001, R0 + +sequenceDecs_decode_56_amd64_adjust_temp_valid: + CMP $0x01, R1 + CSEL NE, R11, R12, R12 + MOVD R10, R11 + MOVD R0, R10 + MOVD R0, R1 + +sequenceDecs_decode_56_amd64_after_adjust: + MOVD R1, 16(R9) + + // Check values + MOVD 8(R9), R0 + MOVD (R9), R13 + ADD R13, R0, R14 + MOVD s+0(FP), R4 + MOVD 256(R4), R16 + ADD R14, R16, R16 + MOVD R16, 256(R4) + MOVD ctx+16(FP), R14 + MOVD 128(R14), R16 + SUBS R13, R16, R16 + MOVD R16, 128(R14) + BMI error_not_enough_literals + CMP $0x00020002, R0 + BHI sequenceDecs_decode_56_amd64_error_match_len_too_big + TST R1, R1 + BNE sequenceDecs_decode_56_amd64_match_len_ofs_ok + TST R0, R0 + BNE sequenceDecs_decode_56_amd64_error_match_len_ofs_mismatch + +sequenceDecs_decode_56_amd64_match_len_ofs_ok: + ADD $0x18, R9, R9 + MOVD ctx+16(FP), R0 + MOVD 96(R0), R16 + SUBS $1, R16, R16 + MOVD R16, 96(R0) + BPL sequenceDecs_decode_56_amd64_main_loop + MOVD s+0(FP), R0 + MOVD R10, 144(R0) + MOVD R11, 152(R0) + MOVD R12, 160(R0) + MOVD br+8(FP), R0 + MOVD R2, 24(R0) + MOVB R3, 40(R0) + MOVD R5, 32(R0) + + // Return success + MOVD $0x00000000, R16 + MOVD R16, ret+24(FP) + RET + + // Return with match length error +sequenceDecs_decode_56_amd64_error_match_len_ofs_mismatch: + MOVD $0x00000001, R16 + MOVD R16, ret+24(FP) + RET + + // Return with match too long error +sequenceDecs_decode_56_amd64_error_match_len_too_big: + MOVD $0x00000002, R16 + MOVD R16, ret+24(FP) + RET + + // Return with match offset too long error + MOVD $0x00000003, R16 + MOVD R16, ret+24(FP) + RET + + // Return with not enough literals error +error_not_enough_literals: + MOVD $0x00000004, R16 + MOVD R16, ret+24(FP) + RET + + // Return with overread error +error_overread: + MOVD $0x00000006, R16 + MOVD R16, ret+24(FP) + RET + +// skipped sequenceDecs_decode_bmi2 (generic twin preferred on arm64) + +// skipped sequenceDecs_decode_56_bmi2 (generic twin preferred on arm64) + +// func sequenceDecs_executeSimple_amd64(ctx *executeAsmContext) bool +// Requires: SSE +TEXT ·sequenceDecs_executeSimple_arm64(SB), $8-9 + MOVD ctx+0(FP), R9 + MOVD 8(R9), R1 + TST R1, R1 + BEQ empty_seqs + MOVD (R9), R0 + MOVD 24(R9), R2 + MOVD 32(R9), R3 + MOVD 80(R9), R5 + MOVD 104(R9), R6 + MOVD 120(R9), R7 + MOVD 56(R9), R8 + MOVD 64(R9), R9 + ADD R9, R8, R8 + + // seqsBase += 24 * seqIndex + ADD R2<<1, R2, R10 + LSL $0x03, R10, R10 + ADD R10, R0, R0 + + // outBase += outPosition + ADD R6, R3, R3 + +main_loop: + MOVD (R0), R10 + MOVD 16(R0), R11 + MOVD 8(R0), R12 + + // Copy literals + TST R10, R10 + BEQ check_offset + MOVD $0, R13 + +copy_1: + ADD R13, R5, R15 + VLD1 (R15), [V0.B16] + ADD R13, R3, R15 + VST1 [V0.B16], (R15) + ADD $0x10, R13, R13 + CMP R10, R13 + BLO copy_1 + ADD R10, R5, R5 + ADD R10, R3, R3 + ADD R10, R6, R6 + + // Malformed input if seq.mo > t+len(hist) || seq.mo > s.windowSize) +check_offset: + ADD R9, R6, R10 + CMP R10, R11 + BGT error_match_off_too_big + CMP R7, R11 + BGT error_match_off_too_big + + // Copy match from history + MOVD R11, R10 + SUBS R6, R10, R10 + BLS copy_match + MOVD R8, R13 + SUB R10, R13, R13 + CMP R10, R12 + BGT copy_all_from_history + MOVD R12, R10 + SUBS $0x10, R10, R10 + BLO copy_4_small + +copy_4_loop: + VLD1 (R13), [V0.B16] + VST1 [V0.B16], (R3) + ADD $0x10, R13, R13 + ADD $0x10, R3, R3 + SUBS $0x10, R10, R10 + BHS copy_4_loop + ADD R10, R13, R13 + ADD $16, R13, R13 + ADD R10, R3, R3 + ADD $16, R3, R3 + ADD $-16, R13, R15 + VLD1 (R15), [V0.B16] + ADD $-16, R3, R15 + VST1 [V0.B16], (R15) + JMP copy_4_end + +copy_4_small: + CMP $0x03, R12 + BEQ copy_4_move_3 + CMP $0x08, R12 + BLO copy_4_move_4through7 + JMP copy_4_move_8through16 + +copy_4_move_3: + MOVHU (R13), R10 + MOVBU 2(R13), R16 + BFI $0, R16, $8, R11 + MOVH R10, (R3) + MOVB R11, 2(R3) + ADD R12, R13, R13 + ADD R12, R3, R3 + JMP copy_4_end + +copy_4_move_4through7: + MOVWU (R13), R10 + ADD R12, R13, R15 + MOVWU -4(R15), R11 + MOVW R10, (R3) + ADD R12, R3, R15 + MOVW R11, -4(R15) + ADD R12, R13, R13 + ADD R12, R3, R3 + JMP copy_4_end + +copy_4_move_8through16: + MOVD (R13), R10 + ADD R12, R13, R15 + MOVD -8(R15), R11 + MOVD R10, (R3) + ADD R12, R3, R15 + MOVD R11, -8(R15) + ADD R12, R13, R13 + ADD R12, R3, R3 + +copy_4_end: + ADD R12, R6, R6 + ADD $0x18, R0, R0 + ADD $1, R2, R2 + CMP R1, R2 + BLO main_loop + JMP loop_finished + +copy_all_from_history: + MOVD R10, R14 + SUBS $0x10, R14, R14 + BLO copy_5_small + +copy_5_loop: + VLD1 (R13), [V0.B16] + VST1 [V0.B16], (R3) + ADD $0x10, R13, R13 + ADD $0x10, R3, R3 + SUBS $0x10, R14, R14 + BHS copy_5_loop + ADD R14, R13, R13 + ADD $16, R13, R13 + ADD R14, R3, R3 + ADD $16, R3, R3 + ADD $-16, R13, R15 + VLD1 (R15), [V0.B16] + ADD $-16, R3, R15 + VST1 [V0.B16], (R15) + JMP copy_5_end + +copy_5_small: + CMP $0x03, R10 + BEQ copy_5_move_3 + BLO copy_5_move_1or2 + CMP $0x08, R10 + BLO copy_5_move_4through7 + JMP copy_5_move_8through16 + +copy_5_move_1or2: + MOVBU (R13), R16 + BFI $0, R16, $8, R14 + ADD R10, R13, R15 + MOVBU -1(R15), R16 + BFI $0, R16, $8, R4 + MOVB R14, (R3) + ADD R10, R3, R15 + MOVB R4, -1(R15) + ADD R10, R13, R13 + ADD R10, R3, R3 + JMP copy_5_end + +copy_5_move_3: + MOVHU (R13), R14 + MOVBU 2(R13), R16 + BFI $0, R16, $8, R4 + MOVH R14, (R3) + MOVB R4, 2(R3) + ADD R10, R13, R13 + ADD R10, R3, R3 + JMP copy_5_end + +copy_5_move_4through7: + MOVWU (R13), R14 + ADD R10, R13, R15 + MOVWU -4(R15), R4 + MOVW R14, (R3) + ADD R10, R3, R15 + MOVW R4, -4(R15) + ADD R10, R13, R13 + ADD R10, R3, R3 + JMP copy_5_end + +copy_5_move_8through16: + MOVD (R13), R14 + ADD R10, R13, R15 + MOVD -8(R15), R4 + MOVD R14, (R3) + ADD R10, R3, R15 + MOVD R4, -8(R15) + ADD R10, R13, R13 + ADD R10, R3, R3 + +copy_5_end: + ADD R10, R6, R6 + SUB R10, R12, R12 + + // Copy match from the current buffer +copy_match: + MOVD R3, R10 + SUB R11, R10, R10 + + // ml <= mo + CMP R11, R12 + BHI copy_overlapping_match + + // Copy non-overlapping match + ADD R12, R6, R6 + MOVD R3, R11 + ADD R12, R3, R3 + +copy_2: + VLD1 (R10), [V0.B16] + VST1 [V0.B16], (R11) + ADD $0x10, R10, R10 + ADD $0x10, R11, R11 + SUBS $0x10, R12, R12 + BHI copy_2 + JMP handle_loop + + // Copy overlapping match +copy_overlapping_match: + ADD R12, R6, R6 + +copy_slow_3: + MOVBU (R10), R16 + BFI $0, R16, $8, R11 + MOVB R11, (R3) + ADD $1, R10, R10 + ADD $1, R3, R3 + SUBS $1, R12, R12 + BNE copy_slow_3 + +handle_loop: + ADD $0x18, R0, R0 + ADD $1, R2, R2 + CMP R1, R2 + BLO main_loop + +loop_finished: + // Return value + MOVD $0x01, R16 + MOVB R16, ret+8(FP) + + // Update the context + MOVD ctx+0(FP), R0 + MOVD R2, 24(R0) + MOVD R6, 104(R0) + MOVD 80(R0), R16 + SUB R16, R5, R5 + MOVD R5, 112(R0) + RET + +error_match_off_too_big: + // Return value + MOVD $0x00, R16 + MOVB R16, ret+8(FP) + + // Update the context + MOVD ctx+0(FP), R0 + MOVD R2, 24(R0) + MOVD R6, 104(R0) + MOVD 80(R0), R16 + SUB R16, R5, R5 + MOVD R5, 112(R0) + RET + +empty_seqs: + // Return value + MOVD $0x01, R16 + MOVB R16, ret+8(FP) + RET + +// func sequenceDecs_executeSimple_safe_amd64(ctx *executeAsmContext) bool +// Requires: SSE +TEXT ·sequenceDecs_executeSimple_safe_arm64(SB), $8-9 + MOVD ctx+0(FP), R9 + MOVD 8(R9), R1 + TST R1, R1 + BEQ empty_seqs + MOVD (R9), R0 + MOVD 24(R9), R2 + MOVD 32(R9), R3 + MOVD 80(R9), R5 + MOVD 104(R9), R6 + MOVD 120(R9), R7 + MOVD 56(R9), R8 + MOVD 64(R9), R9 + ADD R9, R8, R8 + + // seqsBase += 24 * seqIndex + ADD R2<<1, R2, R10 + LSL $0x03, R10, R10 + ADD R10, R0, R0 + + // outBase += outPosition + ADD R6, R3, R3 + +main_loop: + MOVD (R0), R10 + MOVD 16(R0), R11 + MOVD 8(R0), R12 + + // Copy literals + TST R10, R10 + BEQ check_offset + MOVD R10, R13 + SUBS $0x10, R13, R13 + BLO copy_1_small + +copy_1_loop: + VLD1 (R5), [V0.B16] + VST1 [V0.B16], (R3) + ADD $0x10, R5, R5 + ADD $0x10, R3, R3 + SUBS $0x10, R13, R13 + BHS copy_1_loop + ADD R13, R5, R5 + ADD $16, R5, R5 + ADD R13, R3, R3 + ADD $16, R3, R3 + ADD $-16, R5, R15 + VLD1 (R15), [V0.B16] + ADD $-16, R3, R15 + VST1 [V0.B16], (R15) + JMP copy_1_end + +copy_1_small: + CMP $0x03, R10 + BEQ copy_1_move_3 + BLO copy_1_move_1or2 + CMP $0x08, R10 + BLO copy_1_move_4through7 + JMP copy_1_move_8through16 + +copy_1_move_1or2: + MOVBU (R5), R16 + BFI $0, R16, $8, R13 + ADD R10, R5, R15 + MOVBU -1(R15), R16 + BFI $0, R16, $8, R14 + MOVB R13, (R3) + ADD R10, R3, R15 + MOVB R14, -1(R15) + ADD R10, R5, R5 + ADD R10, R3, R3 + JMP copy_1_end + +copy_1_move_3: + MOVHU (R5), R13 + MOVBU 2(R5), R16 + BFI $0, R16, $8, R14 + MOVH R13, (R3) + MOVB R14, 2(R3) + ADD R10, R5, R5 + ADD R10, R3, R3 + JMP copy_1_end + +copy_1_move_4through7: + MOVWU (R5), R13 + ADD R10, R5, R15 + MOVWU -4(R15), R14 + MOVW R13, (R3) + ADD R10, R3, R15 + MOVW R14, -4(R15) + ADD R10, R5, R5 + ADD R10, R3, R3 + JMP copy_1_end + +copy_1_move_8through16: + MOVD (R5), R13 + ADD R10, R5, R15 + MOVD -8(R15), R14 + MOVD R13, (R3) + ADD R10, R3, R15 + MOVD R14, -8(R15) + ADD R10, R5, R5 + ADD R10, R3, R3 + +copy_1_end: + ADD R10, R6, R6 + + // Malformed input if seq.mo > t+len(hist) || seq.mo > s.windowSize) +check_offset: + ADD R9, R6, R10 + CMP R10, R11 + BGT error_match_off_too_big + CMP R7, R11 + BGT error_match_off_too_big + + // Copy match from history + MOVD R11, R10 + SUBS R6, R10, R10 + BLS copy_match + MOVD R8, R13 + SUB R10, R13, R13 + CMP R10, R12 + BGT copy_all_from_history + MOVD R12, R10 + SUBS $0x10, R10, R10 + BLO copy_4_small + +copy_4_loop: + VLD1 (R13), [V0.B16] + VST1 [V0.B16], (R3) + ADD $0x10, R13, R13 + ADD $0x10, R3, R3 + SUBS $0x10, R10, R10 + BHS copy_4_loop + ADD R10, R13, R13 + ADD $16, R13, R13 + ADD R10, R3, R3 + ADD $16, R3, R3 + ADD $-16, R13, R15 + VLD1 (R15), [V0.B16] + ADD $-16, R3, R15 + VST1 [V0.B16], (R15) + JMP copy_4_end + +copy_4_small: + CMP $0x03, R12 + BEQ copy_4_move_3 + CMP $0x08, R12 + BLO copy_4_move_4through7 + JMP copy_4_move_8through16 + +copy_4_move_3: + MOVHU (R13), R10 + MOVBU 2(R13), R16 + BFI $0, R16, $8, R11 + MOVH R10, (R3) + MOVB R11, 2(R3) + ADD R12, R13, R13 + ADD R12, R3, R3 + JMP copy_4_end + +copy_4_move_4through7: + MOVWU (R13), R10 + ADD R12, R13, R15 + MOVWU -4(R15), R11 + MOVW R10, (R3) + ADD R12, R3, R15 + MOVW R11, -4(R15) + ADD R12, R13, R13 + ADD R12, R3, R3 + JMP copy_4_end + +copy_4_move_8through16: + MOVD (R13), R10 + ADD R12, R13, R15 + MOVD -8(R15), R11 + MOVD R10, (R3) + ADD R12, R3, R15 + MOVD R11, -8(R15) + ADD R12, R13, R13 + ADD R12, R3, R3 + +copy_4_end: + ADD R12, R6, R6 + ADD $0x18, R0, R0 + ADD $1, R2, R2 + CMP R1, R2 + BLO main_loop + JMP loop_finished + +copy_all_from_history: + MOVD R10, R14 + SUBS $0x10, R14, R14 + BLO copy_5_small + +copy_5_loop: + VLD1 (R13), [V0.B16] + VST1 [V0.B16], (R3) + ADD $0x10, R13, R13 + ADD $0x10, R3, R3 + SUBS $0x10, R14, R14 + BHS copy_5_loop + ADD R14, R13, R13 + ADD $16, R13, R13 + ADD R14, R3, R3 + ADD $16, R3, R3 + ADD $-16, R13, R15 + VLD1 (R15), [V0.B16] + ADD $-16, R3, R15 + VST1 [V0.B16], (R15) + JMP copy_5_end + +copy_5_small: + CMP $0x03, R10 + BEQ copy_5_move_3 + BLO copy_5_move_1or2 + CMP $0x08, R10 + BLO copy_5_move_4through7 + JMP copy_5_move_8through16 + +copy_5_move_1or2: + MOVBU (R13), R16 + BFI $0, R16, $8, R14 + ADD R10, R13, R15 + MOVBU -1(R15), R16 + BFI $0, R16, $8, R4 + MOVB R14, (R3) + ADD R10, R3, R15 + MOVB R4, -1(R15) + ADD R10, R13, R13 + ADD R10, R3, R3 + JMP copy_5_end + +copy_5_move_3: + MOVHU (R13), R14 + MOVBU 2(R13), R16 + BFI $0, R16, $8, R4 + MOVH R14, (R3) + MOVB R4, 2(R3) + ADD R10, R13, R13 + ADD R10, R3, R3 + JMP copy_5_end + +copy_5_move_4through7: + MOVWU (R13), R14 + ADD R10, R13, R15 + MOVWU -4(R15), R4 + MOVW R14, (R3) + ADD R10, R3, R15 + MOVW R4, -4(R15) + ADD R10, R13, R13 + ADD R10, R3, R3 + JMP copy_5_end + +copy_5_move_8through16: + MOVD (R13), R14 + ADD R10, R13, R15 + MOVD -8(R15), R4 + MOVD R14, (R3) + ADD R10, R3, R15 + MOVD R4, -8(R15) + ADD R10, R13, R13 + ADD R10, R3, R3 + +copy_5_end: + ADD R10, R6, R6 + SUB R10, R12, R12 + + // Copy match from the current buffer +copy_match: + MOVD R3, R10 + SUB R11, R10, R10 + + // ml <= mo + CMP R11, R12 + BHI copy_overlapping_match + + // Copy non-overlapping match + ADD R12, R6, R6 + MOVD R12, R11 + SUBS $0x10, R11, R11 + BLO copy_2_small + +copy_2_loop: + VLD1 (R10), [V0.B16] + VST1 [V0.B16], (R3) + ADD $0x10, R10, R10 + ADD $0x10, R3, R3 + SUBS $0x10, R11, R11 + BHS copy_2_loop + ADD R11, R10, R10 + ADD $16, R10, R10 + ADD R11, R3, R3 + ADD $16, R3, R3 + ADD $-16, R10, R15 + VLD1 (R15), [V0.B16] + ADD $-16, R3, R15 + VST1 [V0.B16], (R15) + JMP copy_2_end + +copy_2_small: + CMP $0x03, R12 + BEQ copy_2_move_3 + BLO copy_2_move_1or2 + CMP $0x08, R12 + BLO copy_2_move_4through7 + JMP copy_2_move_8through16 + +copy_2_move_1or2: + MOVBU (R10), R16 + BFI $0, R16, $8, R11 + ADD R12, R10, R15 + MOVBU -1(R15), R16 + BFI $0, R16, $8, R13 + MOVB R11, (R3) + ADD R12, R3, R15 + MOVB R13, -1(R15) + ADD R12, R10, R10 + ADD R12, R3, R3 + JMP copy_2_end + +copy_2_move_3: + MOVHU (R10), R11 + MOVBU 2(R10), R16 + BFI $0, R16, $8, R13 + MOVH R11, (R3) + MOVB R13, 2(R3) + ADD R12, R10, R10 + ADD R12, R3, R3 + JMP copy_2_end + +copy_2_move_4through7: + MOVWU (R10), R11 + ADD R12, R10, R15 + MOVWU -4(R15), R13 + MOVW R11, (R3) + ADD R12, R3, R15 + MOVW R13, -4(R15) + ADD R12, R10, R10 + ADD R12, R3, R3 + JMP copy_2_end + +copy_2_move_8through16: + MOVD (R10), R11 + ADD R12, R10, R15 + MOVD -8(R15), R13 + MOVD R11, (R3) + ADD R12, R3, R15 + MOVD R13, -8(R15) + ADD R12, R10, R10 + ADD R12, R3, R3 + +copy_2_end: + JMP handle_loop + + // Copy overlapping match +copy_overlapping_match: + ADD R12, R6, R6 + +copy_slow_3: + MOVBU (R10), R16 + BFI $0, R16, $8, R11 + MOVB R11, (R3) + ADD $1, R10, R10 + ADD $1, R3, R3 + SUBS $1, R12, R12 + BNE copy_slow_3 + +handle_loop: + ADD $0x18, R0, R0 + ADD $1, R2, R2 + CMP R1, R2 + BLO main_loop + +loop_finished: + // Return value + MOVD $0x01, R16 + MOVB R16, ret+8(FP) + + // Update the context + MOVD ctx+0(FP), R0 + MOVD R2, 24(R0) + MOVD R6, 104(R0) + MOVD 80(R0), R16 + SUB R16, R5, R5 + MOVD R5, 112(R0) + RET + +error_match_off_too_big: + // Return value + MOVD $0x00, R16 + MOVB R16, ret+8(FP) + + // Update the context + MOVD ctx+0(FP), R0 + MOVD R2, 24(R0) + MOVD R6, 104(R0) + MOVD 80(R0), R16 + SUB R16, R5, R5 + MOVD R5, 112(R0) + RET + +empty_seqs: + // Return value + MOVD $0x01, R16 + MOVB R16, ret+8(FP) + RET + +// func sequenceDecs_decodeSync_amd64(s *sequenceDecs, br *bitReader, ctx *decodeSyncAsmContext) int +// Requires: CMOV, SSE +TEXT ·sequenceDecs_decodeSync_arm64(SB), $64-32 + MOVD br+8(FP), R1 + MOVD 24(R1), R2 + MOVBU 40(R1), R3 + MOVD (R1), R0 + MOVD 32(R1), R5 + ADD R5, R0, R0 + MOVD R0, 8(RSP) + MOVD ctx+16(FP), R0 + MOVD 72(R0), R6 + MOVD 80(R0), R7 + MOVD 88(R0), R8 + MOVD $0, R1 + MOVD R1, 16(RSP) + MOVD R1, 24(RSP) + MOVD R1, 32(RSP) + MOVD 112(R0), R9 + MOVD 128(R0), R1 + MOVD R1, 40(RSP) + MOVD 144(R0), R10 + MOVD 136(R0), R11 + MOVD 200(R0), R1 + MOVD R1, 64(RSP) + MOVD 176(R0), R1 + MOVD R1, 56(RSP) + MOVD 184(R0), R0 + MOVD R0, 48(RSP) + MOVD 48(RSP), R0 + MOVD 56(RSP), R16 + ADD R0, R16, R16 + MOVD R16, 56(RSP) + + // Calculate pointer to s.out[cap(s.out)] (a past-end pointer) + MOVD 40(RSP), R16 + ADD R9, R16, R16 + MOVD R16, 40(RSP) + + // outBase += outPosition + ADD R11, R9, R9 + +sequenceDecs_decodeSync_amd64_main_loop: + MOVD 8(RSP), R12 + + // Fill bitreader to have enough for the offset and match length. + CMP $0x08, R5 + BLT sequenceDecs_decodeSync_amd64_fill_byte_by_byte + MOVD R3, R0 + LSR $0x03, R0, R0 + SUB R0, R12, R12 + MOVD (R12), R2 + SUB R0, R5, R5 + AND $0x07, R3, R3 + JMP sequenceDecs_decodeSync_amd64_fill_end + +sequenceDecs_decodeSync_amd64_fill_byte_by_byte: + CMP $0x00, R5 + BLE sequenceDecs_decodeSync_amd64_fill_check_overread + CMP $0x07, R3 + BLE sequenceDecs_decodeSync_amd64_fill_end + LSL $0x08, R2, R2 + SUB $0x01, R12, R12 + SUB $0x01, R5, R5 + SUB $0x08, R3, R3 + MOVBU (R12), R0 + ORR R0, R2, R2 + JMP sequenceDecs_decodeSync_amd64_fill_byte_by_byte + +sequenceDecs_decodeSync_amd64_fill_check_overread: + CMP $0x40, R3 + BHI error_overread + +sequenceDecs_decodeSync_amd64_fill_end: + // Update offset + MOVD R8, R0 + MOVD R3, R1 + MOVD R2, R13 + LSL R1, R13, R13 + UBFX $8, R0, $8, R16 + BFI $0, R16, $8, R1 + LSR $0x20, R0, R0 + TST R1, R1 + BEQ sequenceDecs_decodeSync_amd64_of_update_zero + ADD R1, R3, R3 + CMP $0x40, R3 + BHI sequenceDecs_decodeSync_amd64_of_update_zero + CMP $0x40, R1 + BHS sequenceDecs_decodeSync_amd64_of_update_zero + NEG R1, R1 + LSR R1, R13, R13 + ADD R13, R0, R0 + +sequenceDecs_decodeSync_amd64_of_update_zero: + MOVD R0, 16(RSP) + + // Update match length + MOVD R7, R0 + MOVD R3, R1 + MOVD R2, R13 + LSL R1, R13, R13 + UBFX $8, R0, $8, R16 + BFI $0, R16, $8, R1 + LSR $0x20, R0, R0 + TST R1, R1 + BEQ sequenceDecs_decodeSync_amd64_ml_update_zero + ADD R1, R3, R3 + CMP $0x40, R3 + BHI sequenceDecs_decodeSync_amd64_ml_update_zero + CMP $0x40, R1 + BHS sequenceDecs_decodeSync_amd64_ml_update_zero + NEG R1, R1 + LSR R1, R13, R13 + ADD R13, R0, R0 + +sequenceDecs_decodeSync_amd64_ml_update_zero: + MOVD R0, 24(RSP) + + // Fill bitreader to have enough for the remaining + CMP $0x08, R5 + BLT sequenceDecs_decodeSync_amd64_fill_2_byte_by_byte + MOVD R3, R0 + LSR $0x03, R0, R0 + SUB R0, R12, R12 + MOVD (R12), R2 + SUB R0, R5, R5 + AND $0x07, R3, R3 + JMP sequenceDecs_decodeSync_amd64_fill_2_end + +sequenceDecs_decodeSync_amd64_fill_2_byte_by_byte: + CMP $0x00, R5 + BLE sequenceDecs_decodeSync_amd64_fill_2_check_overread + CMP $0x07, R3 + BLE sequenceDecs_decodeSync_amd64_fill_2_end + LSL $0x08, R2, R2 + SUB $0x01, R12, R12 + SUB $0x01, R5, R5 + SUB $0x08, R3, R3 + MOVBU (R12), R0 + ORR R0, R2, R2 + JMP sequenceDecs_decodeSync_amd64_fill_2_byte_by_byte + +sequenceDecs_decodeSync_amd64_fill_2_check_overread: + CMP $0x40, R3 + BHI error_overread + +sequenceDecs_decodeSync_amd64_fill_2_end: + // Update literal length + MOVD R6, R0 + MOVD R3, R1 + MOVD R2, R13 + LSL R1, R13, R13 + UBFX $8, R0, $8, R16 + BFI $0, R16, $8, R1 + LSR $0x20, R0, R0 + TST R1, R1 + BEQ sequenceDecs_decodeSync_amd64_ll_update_zero + ADD R1, R3, R3 + CMP $0x40, R3 + BHI sequenceDecs_decodeSync_amd64_ll_update_zero + CMP $0x40, R1 + BHS sequenceDecs_decodeSync_amd64_ll_update_zero + NEG R1, R1 + LSR R1, R13, R13 + ADD R13, R0, R0 + +sequenceDecs_decodeSync_amd64_ll_update_zero: + MOVD R0, 32(RSP) + + // Fill bitreader for state updates + MOVD R12, 8(RSP) + MOVD R8, R0 + LSR $0x08, R0, R0 + MOVBU R0, R0 + MOVD ctx+16(FP), R1 + MOVD 96(R1), R16 + CMP $0x00, R16 + BEQ sequenceDecs_decodeSync_amd64_skip_update + + // Update Literal Length State + MOVBU R6, R12 + LSRW $0x10, R6, R6 + ADD R12, R3, R1 + MOVD R2, R13 + MOVD R1, R3 + NEG R1, R16 + ROR R16, R13, R13 + MOVD $0x00000001, R14 + BFI $0, R12, $8, R1 + LSLW R1, R14, R14 + SUBW $1, R14, R14 + AND R14, R13, R13 + ADD R13, R6, R6 + + // Load ctx.llTable + MOVD ctx+16(FP), R1 + MOVD (R1), R1 + ADD R6<<3, R1, R15 + MOVD (R15), R6 + + // Update Match Length State + MOVBU R7, R12 + LSRW $0x10, R7, R7 + ADD R12, R3, R1 + MOVD R2, R13 + MOVD R1, R3 + NEG R1, R16 + ROR R16, R13, R13 + MOVD $0x00000001, R14 + BFI $0, R12, $8, R1 + LSLW R1, R14, R14 + SUBW $1, R14, R14 + AND R14, R13, R13 + ADD R13, R7, R7 + + // Load ctx.mlTable + MOVD ctx+16(FP), R1 + MOVD 24(R1), R1 + ADD R7<<3, R1, R15 + MOVD (R15), R7 + + // Update Offset State + MOVBU R8, R12 + LSRW $0x10, R8, R8 + ADD R12, R3, R1 + MOVD R2, R13 + MOVD R1, R3 + NEG R1, R16 + ROR R16, R13, R13 + MOVD $0x00000001, R14 + BFI $0, R12, $8, R1 + LSLW R1, R14, R14 + SUBW $1, R14, R14 + AND R14, R13, R13 + ADD R13, R8, R8 + + // Load ctx.ofTable + MOVD ctx+16(FP), R1 + MOVD 48(R1), R1 + ADD R8<<3, R1, R15 + MOVD (R15), R8 + +sequenceDecs_decodeSync_amd64_skip_update: + // Adjust offset + MOVD s+0(FP), R1 + MOVD 16(RSP), R12 + CMP $0x01, R0 + BLS sequenceDecs_decodeSync_amd64_adjust_offsetB_1_or_0 + ADD $144, R1, R15 + VLD1 (R15), [V0.B16] + MOVD R12, 144(R1) + ADD $152, R1, R15 + VST1 [V0.B16], (R15) + JMP sequenceDecs_decodeSync_amd64_after_adjust + +sequenceDecs_decodeSync_amd64_adjust_offsetB_1_or_0: + MOVD 32(RSP), R16 + CMP $0x00000000, R16 + BNE sequenceDecs_decodeSync_amd64_adjust_offset_maybezero + ADD $1, R12, R12 + JMP sequenceDecs_decodeSync_amd64_adjust_offset_nonzero + +sequenceDecs_decodeSync_amd64_adjust_offset_maybezero: + TST R12, R12 + BNE sequenceDecs_decodeSync_amd64_adjust_offset_nonzero + MOVD 144(R1), R12 + JMP sequenceDecs_decodeSync_amd64_after_adjust + +sequenceDecs_decodeSync_amd64_adjust_offset_nonzero: + MOVD R12, R0 + MOVD $0, R13 + MOVD $-1, R14 + CMP $0x03, R12 + CSEL EQ, R13, R0, R0 + CSEL EQ, R14, R13, R13 + ADD R0<<3, R1, R15 + MOVD 144(R15), R16 + ADDS R16, R13, R13 + BNE sequenceDecs_decodeSync_amd64_adjust_temp_valid + MOVD $0x00000001, R13 + +sequenceDecs_decodeSync_amd64_adjust_temp_valid: + CMP $0x01, R12 + BEQ sequenceDecs_decodeSync_amd64_adjust_skip + MOVD 152(R1), R0 + MOVD R0, 160(R1) + +sequenceDecs_decodeSync_amd64_adjust_skip: + MOVD 144(R1), R0 + MOVD R0, 152(R1) + MOVD R13, 144(R1) + MOVD R13, R12 + +sequenceDecs_decodeSync_amd64_after_adjust: + MOVD R12, 16(RSP) + + // Check values + MOVD 24(RSP), R0 + MOVD 32(RSP), R1 + ADD R1, R0, R13 + MOVD s+0(FP), R14 + MOVD 256(R14), R16 + ADD R13, R16, R16 + MOVD R16, 256(R14) + MOVD ctx+16(FP), R13 + MOVD 104(R13), R16 + SUBS R1, R16, R16 + MOVD R16, 104(R13) + BMI error_not_enough_literals + CMP $0x00020002, R0 + BHI sequenceDecs_decodeSync_amd64_error_match_len_too_big + TST R12, R12 + BNE sequenceDecs_decodeSync_amd64_match_len_ofs_ok + TST R0, R0 + BNE sequenceDecs_decodeSync_amd64_error_match_len_ofs_mismatch + +sequenceDecs_decodeSync_amd64_match_len_ofs_ok: + MOVD 32(RSP), R0 + MOVD 16(RSP), R1 + MOVD 24(RSP), R12 + + // Check if we have enough space in s.out + ADD R12, R0, R13 + ADD $16, R13, R13 + ADD R9, R13, R13 + MOVD 40(RSP), R16 + CMP R16, R13 + BHI error_not_enough_space + + // Copy literals + TST R0, R0 + BEQ check_offset + MOVD $0, R13 + +copy_1: + ADD R13, R10, R15 + VLD1 (R15), [V0.B16] + ADD R13, R9, R15 + VST1 [V0.B16], (R15) + ADD $0x10, R13, R13 + CMP R0, R13 + BLO copy_1 + ADD R0, R10, R10 + ADD R0, R9, R9 + ADD R0, R11, R11 + + // Malformed input if seq.mo > t+len(hist) || seq.mo > s.windowSize) +check_offset: + MOVD R11, R0 + MOVD 48(RSP), R16 + ADD R16, R0, R0 + CMP R0, R1 + BGT error_match_off_too_big + MOVD 64(RSP), R16 + CMP R16, R1 + BGT error_match_off_too_big + + // Copy match from history + MOVD R1, R0 + SUBS R11, R0, R0 + BLS copy_match + MOVD 56(RSP), R13 + SUB R0, R13, R13 + CMP R0, R12 + BGT copy_all_from_history + MOVD R12, R0 + SUBS $0x10, R0, R0 + BLO copy_4_small + +copy_4_loop: + VLD1 (R13), [V0.B16] + VST1 [V0.B16], (R9) + ADD $0x10, R13, R13 + ADD $0x10, R9, R9 + SUBS $0x10, R0, R0 + BHS copy_4_loop + ADD R0, R13, R13 + ADD $16, R13, R13 + ADD R0, R9, R9 + ADD $16, R9, R9 + ADD $-16, R13, R15 + VLD1 (R15), [V0.B16] + ADD $-16, R9, R15 + VST1 [V0.B16], (R15) + JMP copy_4_end + +copy_4_small: + CMP $0x03, R12 + BEQ copy_4_move_3 + CMP $0x08, R12 + BLO copy_4_move_4through7 + JMP copy_4_move_8through16 + +copy_4_move_3: + MOVHU (R13), R0 + MOVBU 2(R13), R16 + BFI $0, R16, $8, R1 + MOVH R0, (R9) + MOVB R1, 2(R9) + ADD R12, R13, R13 + ADD R12, R9, R9 + JMP copy_4_end + +copy_4_move_4through7: + MOVWU (R13), R0 + ADD R12, R13, R15 + MOVWU -4(R15), R1 + MOVW R0, (R9) + ADD R12, R9, R15 + MOVW R1, -4(R15) + ADD R12, R13, R13 + ADD R12, R9, R9 + JMP copy_4_end + +copy_4_move_8through16: + MOVD (R13), R0 + ADD R12, R13, R15 + MOVD -8(R15), R1 + MOVD R0, (R9) + ADD R12, R9, R15 + MOVD R1, -8(R15) + ADD R12, R13, R13 + ADD R12, R9, R9 + +copy_4_end: + ADD R12, R11, R11 + JMP handle_loop + JMP loop_finished + +copy_all_from_history: + MOVD R0, R14 + SUBS $0x10, R14, R14 + BLO copy_5_small + +copy_5_loop: + VLD1 (R13), [V0.B16] + VST1 [V0.B16], (R9) + ADD $0x10, R13, R13 + ADD $0x10, R9, R9 + SUBS $0x10, R14, R14 + BHS copy_5_loop + ADD R14, R13, R13 + ADD $16, R13, R13 + ADD R14, R9, R9 + ADD $16, R9, R9 + ADD $-16, R13, R15 + VLD1 (R15), [V0.B16] + ADD $-16, R9, R15 + VST1 [V0.B16], (R15) + JMP copy_5_end + +copy_5_small: + CMP $0x03, R0 + BEQ copy_5_move_3 + BLO copy_5_move_1or2 + CMP $0x08, R0 + BLO copy_5_move_4through7 + JMP copy_5_move_8through16 + +copy_5_move_1or2: + MOVBU (R13), R16 + BFI $0, R16, $8, R14 + ADD R0, R13, R15 + MOVBU -1(R15), R16 + BFI $0, R16, $8, R4 + MOVB R14, (R9) + ADD R0, R9, R15 + MOVB R4, -1(R15) + ADD R0, R13, R13 + ADD R0, R9, R9 + JMP copy_5_end + +copy_5_move_3: + MOVHU (R13), R14 + MOVBU 2(R13), R16 + BFI $0, R16, $8, R4 + MOVH R14, (R9) + MOVB R4, 2(R9) + ADD R0, R13, R13 + ADD R0, R9, R9 + JMP copy_5_end + +copy_5_move_4through7: + MOVWU (R13), R14 + ADD R0, R13, R15 + MOVWU -4(R15), R4 + MOVW R14, (R9) + ADD R0, R9, R15 + MOVW R4, -4(R15) + ADD R0, R13, R13 + ADD R0, R9, R9 + JMP copy_5_end + +copy_5_move_8through16: + MOVD (R13), R14 + ADD R0, R13, R15 + MOVD -8(R15), R4 + MOVD R14, (R9) + ADD R0, R9, R15 + MOVD R4, -8(R15) + ADD R0, R13, R13 + ADD R0, R9, R9 + +copy_5_end: + ADD R0, R11, R11 + SUB R0, R12, R12 + + // Copy match from the current buffer +copy_match: + MOVD R9, R0 + SUB R1, R0, R0 + + // ml <= mo + CMP R1, R12 + BHI copy_overlapping_match + + // Copy non-overlapping match + ADD R12, R11, R11 + MOVD R9, R1 + ADD R12, R9, R9 + +copy_2: + VLD1 (R0), [V0.B16] + VST1 [V0.B16], (R1) + ADD $0x10, R0, R0 + ADD $0x10, R1, R1 + SUBS $0x10, R12, R12 + BHI copy_2 + JMP handle_loop + + // Copy overlapping match +copy_overlapping_match: + ADD R12, R11, R11 + +copy_slow_3: + MOVBU (R0), R16 + BFI $0, R16, $8, R1 + MOVB R1, (R9) + ADD $1, R0, R0 + ADD $1, R9, R9 + SUBS $1, R12, R12 + BNE copy_slow_3 + +handle_loop: + MOVD ctx+16(FP), R0 + MOVD 96(R0), R16 + SUBS $1, R16, R16 + MOVD R16, 96(R0) + BPL sequenceDecs_decodeSync_amd64_main_loop + +loop_finished: + MOVD br+8(FP), R0 + MOVD R2, 24(R0) + MOVB R3, 40(R0) + MOVD R5, 32(R0) + + // Update the context + MOVD ctx+16(FP), R0 + MOVD R11, 136(R0) + MOVD 144(R0), R1 + SUB R1, R10, R10 + MOVD R10, 168(R0) + + // Return success + MOVD $0x00000000, R16 + MOVD R16, ret+24(FP) + RET + + // Return with match length error +sequenceDecs_decodeSync_amd64_error_match_len_ofs_mismatch: + MOVD 24(RSP), R0 + MOVD ctx+16(FP), R1 + MOVD R0, 216(R1) + MOVD $0x00000001, R16 + MOVD R16, ret+24(FP) + RET + + // Return with match too long error +sequenceDecs_decodeSync_amd64_error_match_len_too_big: + MOVD ctx+16(FP), R0 + MOVD 24(RSP), R1 + MOVD R1, 216(R0) + MOVD $0x00000002, R16 + MOVD R16, ret+24(FP) + RET + + // Return with match offset too long error +error_match_off_too_big: + MOVD ctx+16(FP), R0 + MOVD 16(RSP), R1 + MOVD R1, 224(R0) + MOVD R11, 136(R0) + MOVD $0x00000003, R16 + MOVD R16, ret+24(FP) + RET + + // Return with not enough literals error +error_not_enough_literals: + MOVD ctx+16(FP), R0 + MOVD 32(RSP), R1 + MOVD R1, 208(R0) + MOVD $0x00000004, R16 + MOVD R16, ret+24(FP) + RET + + // Return with overread error +error_overread: + MOVD $0x00000006, R16 + MOVD R16, ret+24(FP) + RET + + // Return with not enough output space error +error_not_enough_space: + MOVD ctx+16(FP), R0 + MOVD 32(RSP), R1 + MOVD R1, 208(R0) + MOVD 24(RSP), R1 + MOVD R1, 216(R0) + MOVD R11, 136(R0) + MOVD $0x00000005, R16 + MOVD R16, ret+24(FP) + RET + +// skipped sequenceDecs_decodeSync_bmi2 (generic twin preferred on arm64) + +// func sequenceDecs_decodeSync_safe_amd64(s *sequenceDecs, br *bitReader, ctx *decodeSyncAsmContext) int +// Requires: CMOV, SSE +TEXT ·sequenceDecs_decodeSync_safe_arm64(SB), $64-32 + MOVD br+8(FP), R1 + MOVD 24(R1), R2 + MOVBU 40(R1), R3 + MOVD (R1), R0 + MOVD 32(R1), R5 + ADD R5, R0, R0 + MOVD R0, 8(RSP) + MOVD ctx+16(FP), R0 + MOVD 72(R0), R6 + MOVD 80(R0), R7 + MOVD 88(R0), R8 + MOVD $0, R1 + MOVD R1, 16(RSP) + MOVD R1, 24(RSP) + MOVD R1, 32(RSP) + MOVD 112(R0), R9 + MOVD 128(R0), R1 + MOVD R1, 40(RSP) + MOVD 144(R0), R10 + MOVD 136(R0), R11 + MOVD 200(R0), R1 + MOVD R1, 64(RSP) + MOVD 176(R0), R1 + MOVD R1, 56(RSP) + MOVD 184(R0), R0 + MOVD R0, 48(RSP) + MOVD 48(RSP), R0 + MOVD 56(RSP), R16 + ADD R0, R16, R16 + MOVD R16, 56(RSP) + + // Calculate pointer to s.out[cap(s.out)] (a past-end pointer) + MOVD 40(RSP), R16 + ADD R9, R16, R16 + MOVD R16, 40(RSP) + + // outBase += outPosition + ADD R11, R9, R9 + +sequenceDecs_decodeSync_safe_amd64_main_loop: + MOVD 8(RSP), R12 + + // Fill bitreader to have enough for the offset and match length. + CMP $0x08, R5 + BLT sequenceDecs_decodeSync_safe_amd64_fill_byte_by_byte + MOVD R3, R0 + LSR $0x03, R0, R0 + SUB R0, R12, R12 + MOVD (R12), R2 + SUB R0, R5, R5 + AND $0x07, R3, R3 + JMP sequenceDecs_decodeSync_safe_amd64_fill_end + +sequenceDecs_decodeSync_safe_amd64_fill_byte_by_byte: + CMP $0x00, R5 + BLE sequenceDecs_decodeSync_safe_amd64_fill_check_overread + CMP $0x07, R3 + BLE sequenceDecs_decodeSync_safe_amd64_fill_end + LSL $0x08, R2, R2 + SUB $0x01, R12, R12 + SUB $0x01, R5, R5 + SUB $0x08, R3, R3 + MOVBU (R12), R0 + ORR R0, R2, R2 + JMP sequenceDecs_decodeSync_safe_amd64_fill_byte_by_byte + +sequenceDecs_decodeSync_safe_amd64_fill_check_overread: + CMP $0x40, R3 + BHI error_overread + +sequenceDecs_decodeSync_safe_amd64_fill_end: + // Update offset + MOVD R8, R0 + MOVD R3, R1 + MOVD R2, R13 + LSL R1, R13, R13 + UBFX $8, R0, $8, R16 + BFI $0, R16, $8, R1 + LSR $0x20, R0, R0 + TST R1, R1 + BEQ sequenceDecs_decodeSync_safe_amd64_of_update_zero + ADD R1, R3, R3 + CMP $0x40, R3 + BHI sequenceDecs_decodeSync_safe_amd64_of_update_zero + CMP $0x40, R1 + BHS sequenceDecs_decodeSync_safe_amd64_of_update_zero + NEG R1, R1 + LSR R1, R13, R13 + ADD R13, R0, R0 + +sequenceDecs_decodeSync_safe_amd64_of_update_zero: + MOVD R0, 16(RSP) + + // Update match length + MOVD R7, R0 + MOVD R3, R1 + MOVD R2, R13 + LSL R1, R13, R13 + UBFX $8, R0, $8, R16 + BFI $0, R16, $8, R1 + LSR $0x20, R0, R0 + TST R1, R1 + BEQ sequenceDecs_decodeSync_safe_amd64_ml_update_zero + ADD R1, R3, R3 + CMP $0x40, R3 + BHI sequenceDecs_decodeSync_safe_amd64_ml_update_zero + CMP $0x40, R1 + BHS sequenceDecs_decodeSync_safe_amd64_ml_update_zero + NEG R1, R1 + LSR R1, R13, R13 + ADD R13, R0, R0 + +sequenceDecs_decodeSync_safe_amd64_ml_update_zero: + MOVD R0, 24(RSP) + + // Fill bitreader to have enough for the remaining + CMP $0x08, R5 + BLT sequenceDecs_decodeSync_safe_amd64_fill_2_byte_by_byte + MOVD R3, R0 + LSR $0x03, R0, R0 + SUB R0, R12, R12 + MOVD (R12), R2 + SUB R0, R5, R5 + AND $0x07, R3, R3 + JMP sequenceDecs_decodeSync_safe_amd64_fill_2_end + +sequenceDecs_decodeSync_safe_amd64_fill_2_byte_by_byte: + CMP $0x00, R5 + BLE sequenceDecs_decodeSync_safe_amd64_fill_2_check_overread + CMP $0x07, R3 + BLE sequenceDecs_decodeSync_safe_amd64_fill_2_end + LSL $0x08, R2, R2 + SUB $0x01, R12, R12 + SUB $0x01, R5, R5 + SUB $0x08, R3, R3 + MOVBU (R12), R0 + ORR R0, R2, R2 + JMP sequenceDecs_decodeSync_safe_amd64_fill_2_byte_by_byte + +sequenceDecs_decodeSync_safe_amd64_fill_2_check_overread: + CMP $0x40, R3 + BHI error_overread + +sequenceDecs_decodeSync_safe_amd64_fill_2_end: + // Update literal length + MOVD R6, R0 + MOVD R3, R1 + MOVD R2, R13 + LSL R1, R13, R13 + UBFX $8, R0, $8, R16 + BFI $0, R16, $8, R1 + LSR $0x20, R0, R0 + TST R1, R1 + BEQ sequenceDecs_decodeSync_safe_amd64_ll_update_zero + ADD R1, R3, R3 + CMP $0x40, R3 + BHI sequenceDecs_decodeSync_safe_amd64_ll_update_zero + CMP $0x40, R1 + BHS sequenceDecs_decodeSync_safe_amd64_ll_update_zero + NEG R1, R1 + LSR R1, R13, R13 + ADD R13, R0, R0 + +sequenceDecs_decodeSync_safe_amd64_ll_update_zero: + MOVD R0, 32(RSP) + + // Fill bitreader for state updates + MOVD R12, 8(RSP) + MOVD R8, R0 + LSR $0x08, R0, R0 + MOVBU R0, R0 + MOVD ctx+16(FP), R1 + MOVD 96(R1), R16 + CMP $0x00, R16 + BEQ sequenceDecs_decodeSync_safe_amd64_skip_update + + // Update Literal Length State + MOVBU R6, R12 + LSRW $0x10, R6, R6 + ADD R12, R3, R1 + MOVD R2, R13 + MOVD R1, R3 + NEG R1, R16 + ROR R16, R13, R13 + MOVD $0x00000001, R14 + BFI $0, R12, $8, R1 + LSLW R1, R14, R14 + SUBW $1, R14, R14 + AND R14, R13, R13 + ADD R13, R6, R6 + + // Load ctx.llTable + MOVD ctx+16(FP), R1 + MOVD (R1), R1 + ADD R6<<3, R1, R15 + MOVD (R15), R6 + + // Update Match Length State + MOVBU R7, R12 + LSRW $0x10, R7, R7 + ADD R12, R3, R1 + MOVD R2, R13 + MOVD R1, R3 + NEG R1, R16 + ROR R16, R13, R13 + MOVD $0x00000001, R14 + BFI $0, R12, $8, R1 + LSLW R1, R14, R14 + SUBW $1, R14, R14 + AND R14, R13, R13 + ADD R13, R7, R7 + + // Load ctx.mlTable + MOVD ctx+16(FP), R1 + MOVD 24(R1), R1 + ADD R7<<3, R1, R15 + MOVD (R15), R7 + + // Update Offset State + MOVBU R8, R12 + LSRW $0x10, R8, R8 + ADD R12, R3, R1 + MOVD R2, R13 + MOVD R1, R3 + NEG R1, R16 + ROR R16, R13, R13 + MOVD $0x00000001, R14 + BFI $0, R12, $8, R1 + LSLW R1, R14, R14 + SUBW $1, R14, R14 + AND R14, R13, R13 + ADD R13, R8, R8 + + // Load ctx.ofTable + MOVD ctx+16(FP), R1 + MOVD 48(R1), R1 + ADD R8<<3, R1, R15 + MOVD (R15), R8 + +sequenceDecs_decodeSync_safe_amd64_skip_update: + // Adjust offset + MOVD s+0(FP), R1 + MOVD 16(RSP), R12 + CMP $0x01, R0 + BLS sequenceDecs_decodeSync_safe_amd64_adjust_offsetB_1_or_0 + ADD $144, R1, R15 + VLD1 (R15), [V0.B16] + MOVD R12, 144(R1) + ADD $152, R1, R15 + VST1 [V0.B16], (R15) + JMP sequenceDecs_decodeSync_safe_amd64_after_adjust + +sequenceDecs_decodeSync_safe_amd64_adjust_offsetB_1_or_0: + MOVD 32(RSP), R16 + CMP $0x00000000, R16 + BNE sequenceDecs_decodeSync_safe_amd64_adjust_offset_maybezero + ADD $1, R12, R12 + JMP sequenceDecs_decodeSync_safe_amd64_adjust_offset_nonzero + +sequenceDecs_decodeSync_safe_amd64_adjust_offset_maybezero: + TST R12, R12 + BNE sequenceDecs_decodeSync_safe_amd64_adjust_offset_nonzero + MOVD 144(R1), R12 + JMP sequenceDecs_decodeSync_safe_amd64_after_adjust + +sequenceDecs_decodeSync_safe_amd64_adjust_offset_nonzero: + MOVD R12, R0 + MOVD $0, R13 + MOVD $-1, R14 + CMP $0x03, R12 + CSEL EQ, R13, R0, R0 + CSEL EQ, R14, R13, R13 + ADD R0<<3, R1, R15 + MOVD 144(R15), R16 + ADDS R16, R13, R13 + BNE sequenceDecs_decodeSync_safe_amd64_adjust_temp_valid + MOVD $0x00000001, R13 + +sequenceDecs_decodeSync_safe_amd64_adjust_temp_valid: + CMP $0x01, R12 + BEQ sequenceDecs_decodeSync_safe_amd64_adjust_skip + MOVD 152(R1), R0 + MOVD R0, 160(R1) + +sequenceDecs_decodeSync_safe_amd64_adjust_skip: + MOVD 144(R1), R0 + MOVD R0, 152(R1) + MOVD R13, 144(R1) + MOVD R13, R12 + +sequenceDecs_decodeSync_safe_amd64_after_adjust: + MOVD R12, 16(RSP) + + // Check values + MOVD 24(RSP), R0 + MOVD 32(RSP), R1 + ADD R1, R0, R13 + MOVD s+0(FP), R14 + MOVD 256(R14), R16 + ADD R13, R16, R16 + MOVD R16, 256(R14) + MOVD ctx+16(FP), R13 + MOVD 104(R13), R16 + SUBS R1, R16, R16 + MOVD R16, 104(R13) + BMI error_not_enough_literals + CMP $0x00020002, R0 + BHI sequenceDecs_decodeSync_safe_amd64_error_match_len_too_big + TST R12, R12 + BNE sequenceDecs_decodeSync_safe_amd64_match_len_ofs_ok + TST R0, R0 + BNE sequenceDecs_decodeSync_safe_amd64_error_match_len_ofs_mismatch + +sequenceDecs_decodeSync_safe_amd64_match_len_ofs_ok: + MOVD 32(RSP), R0 + MOVD 16(RSP), R1 + MOVD 24(RSP), R12 + + // Check if we have enough space in s.out + ADD R12, R0, R13 + ADD R9, R13, R13 + MOVD 40(RSP), R16 + CMP R16, R13 + BHI error_not_enough_space + + // Copy literals + TST R0, R0 + BEQ check_offset + MOVD R0, R13 + SUBS $0x10, R13, R13 + BLO copy_1_small + +copy_1_loop: + VLD1 (R10), [V0.B16] + VST1 [V0.B16], (R9) + ADD $0x10, R10, R10 + ADD $0x10, R9, R9 + SUBS $0x10, R13, R13 + BHS copy_1_loop + ADD R13, R10, R10 + ADD $16, R10, R10 + ADD R13, R9, R9 + ADD $16, R9, R9 + ADD $-16, R10, R15 + VLD1 (R15), [V0.B16] + ADD $-16, R9, R15 + VST1 [V0.B16], (R15) + JMP copy_1_end + +copy_1_small: + CMP $0x03, R0 + BEQ copy_1_move_3 + BLO copy_1_move_1or2 + CMP $0x08, R0 + BLO copy_1_move_4through7 + JMP copy_1_move_8through16 + +copy_1_move_1or2: + MOVBU (R10), R16 + BFI $0, R16, $8, R13 + ADD R0, R10, R15 + MOVBU -1(R15), R16 + BFI $0, R16, $8, R14 + MOVB R13, (R9) + ADD R0, R9, R15 + MOVB R14, -1(R15) + ADD R0, R10, R10 + ADD R0, R9, R9 + JMP copy_1_end + +copy_1_move_3: + MOVHU (R10), R13 + MOVBU 2(R10), R16 + BFI $0, R16, $8, R14 + MOVH R13, (R9) + MOVB R14, 2(R9) + ADD R0, R10, R10 + ADD R0, R9, R9 + JMP copy_1_end + +copy_1_move_4through7: + MOVWU (R10), R13 + ADD R0, R10, R15 + MOVWU -4(R15), R14 + MOVW R13, (R9) + ADD R0, R9, R15 + MOVW R14, -4(R15) + ADD R0, R10, R10 + ADD R0, R9, R9 + JMP copy_1_end + +copy_1_move_8through16: + MOVD (R10), R13 + ADD R0, R10, R15 + MOVD -8(R15), R14 + MOVD R13, (R9) + ADD R0, R9, R15 + MOVD R14, -8(R15) + ADD R0, R10, R10 + ADD R0, R9, R9 + +copy_1_end: + ADD R0, R11, R11 + + // Malformed input if seq.mo > t+len(hist) || seq.mo > s.windowSize) +check_offset: + MOVD R11, R0 + MOVD 48(RSP), R16 + ADD R16, R0, R0 + CMP R0, R1 + BGT error_match_off_too_big + MOVD 64(RSP), R16 + CMP R16, R1 + BGT error_match_off_too_big + + // Copy match from history + MOVD R1, R0 + SUBS R11, R0, R0 + BLS copy_match + MOVD 56(RSP), R13 + SUB R0, R13, R13 + CMP R0, R12 + BGT copy_all_from_history + MOVD R12, R0 + SUBS $0x10, R0, R0 + BLO copy_4_small + +copy_4_loop: + VLD1 (R13), [V0.B16] + VST1 [V0.B16], (R9) + ADD $0x10, R13, R13 + ADD $0x10, R9, R9 + SUBS $0x10, R0, R0 + BHS copy_4_loop + ADD R0, R13, R13 + ADD $16, R13, R13 + ADD R0, R9, R9 + ADD $16, R9, R9 + ADD $-16, R13, R15 + VLD1 (R15), [V0.B16] + ADD $-16, R9, R15 + VST1 [V0.B16], (R15) + JMP copy_4_end + +copy_4_small: + CMP $0x03, R12 + BEQ copy_4_move_3 + CMP $0x08, R12 + BLO copy_4_move_4through7 + JMP copy_4_move_8through16 + +copy_4_move_3: + MOVHU (R13), R0 + MOVBU 2(R13), R16 + BFI $0, R16, $8, R1 + MOVH R0, (R9) + MOVB R1, 2(R9) + ADD R12, R13, R13 + ADD R12, R9, R9 + JMP copy_4_end + +copy_4_move_4through7: + MOVWU (R13), R0 + ADD R12, R13, R15 + MOVWU -4(R15), R1 + MOVW R0, (R9) + ADD R12, R9, R15 + MOVW R1, -4(R15) + ADD R12, R13, R13 + ADD R12, R9, R9 + JMP copy_4_end + +copy_4_move_8through16: + MOVD (R13), R0 + ADD R12, R13, R15 + MOVD -8(R15), R1 + MOVD R0, (R9) + ADD R12, R9, R15 + MOVD R1, -8(R15) + ADD R12, R13, R13 + ADD R12, R9, R9 + +copy_4_end: + ADD R12, R11, R11 + JMP handle_loop + JMP loop_finished + +copy_all_from_history: + MOVD R0, R14 + SUBS $0x10, R14, R14 + BLO copy_5_small + +copy_5_loop: + VLD1 (R13), [V0.B16] + VST1 [V0.B16], (R9) + ADD $0x10, R13, R13 + ADD $0x10, R9, R9 + SUBS $0x10, R14, R14 + BHS copy_5_loop + ADD R14, R13, R13 + ADD $16, R13, R13 + ADD R14, R9, R9 + ADD $16, R9, R9 + ADD $-16, R13, R15 + VLD1 (R15), [V0.B16] + ADD $-16, R9, R15 + VST1 [V0.B16], (R15) + JMP copy_5_end + +copy_5_small: + CMP $0x03, R0 + BEQ copy_5_move_3 + BLO copy_5_move_1or2 + CMP $0x08, R0 + BLO copy_5_move_4through7 + JMP copy_5_move_8through16 + +copy_5_move_1or2: + MOVBU (R13), R16 + BFI $0, R16, $8, R14 + ADD R0, R13, R15 + MOVBU -1(R15), R16 + BFI $0, R16, $8, R4 + MOVB R14, (R9) + ADD R0, R9, R15 + MOVB R4, -1(R15) + ADD R0, R13, R13 + ADD R0, R9, R9 + JMP copy_5_end + +copy_5_move_3: + MOVHU (R13), R14 + MOVBU 2(R13), R16 + BFI $0, R16, $8, R4 + MOVH R14, (R9) + MOVB R4, 2(R9) + ADD R0, R13, R13 + ADD R0, R9, R9 + JMP copy_5_end + +copy_5_move_4through7: + MOVWU (R13), R14 + ADD R0, R13, R15 + MOVWU -4(R15), R4 + MOVW R14, (R9) + ADD R0, R9, R15 + MOVW R4, -4(R15) + ADD R0, R13, R13 + ADD R0, R9, R9 + JMP copy_5_end + +copy_5_move_8through16: + MOVD (R13), R14 + ADD R0, R13, R15 + MOVD -8(R15), R4 + MOVD R14, (R9) + ADD R0, R9, R15 + MOVD R4, -8(R15) + ADD R0, R13, R13 + ADD R0, R9, R9 + +copy_5_end: + ADD R0, R11, R11 + SUB R0, R12, R12 + + // Copy match from the current buffer +copy_match: + MOVD R9, R0 + SUB R1, R0, R0 + + // ml <= mo + CMP R1, R12 + BHI copy_overlapping_match + + // Copy non-overlapping match + ADD R12, R11, R11 + MOVD R12, R1 + SUBS $0x10, R1, R1 + BLO copy_2_small + +copy_2_loop: + VLD1 (R0), [V0.B16] + VST1 [V0.B16], (R9) + ADD $0x10, R0, R0 + ADD $0x10, R9, R9 + SUBS $0x10, R1, R1 + BHS copy_2_loop + ADD R1, R0, R0 + ADD $16, R0, R0 + ADD R1, R9, R9 + ADD $16, R9, R9 + ADD $-16, R0, R15 + VLD1 (R15), [V0.B16] + ADD $-16, R9, R15 + VST1 [V0.B16], (R15) + JMP copy_2_end + +copy_2_small: + CMP $0x03, R12 + BEQ copy_2_move_3 + BLO copy_2_move_1or2 + CMP $0x08, R12 + BLO copy_2_move_4through7 + JMP copy_2_move_8through16 + +copy_2_move_1or2: + MOVBU (R0), R16 + BFI $0, R16, $8, R1 + ADD R12, R0, R15 + MOVBU -1(R15), R16 + BFI $0, R16, $8, R13 + MOVB R1, (R9) + ADD R12, R9, R15 + MOVB R13, -1(R15) + ADD R12, R0, R0 + ADD R12, R9, R9 + JMP copy_2_end + +copy_2_move_3: + MOVHU (R0), R1 + MOVBU 2(R0), R16 + BFI $0, R16, $8, R13 + MOVH R1, (R9) + MOVB R13, 2(R9) + ADD R12, R0, R0 + ADD R12, R9, R9 + JMP copy_2_end + +copy_2_move_4through7: + MOVWU (R0), R1 + ADD R12, R0, R15 + MOVWU -4(R15), R13 + MOVW R1, (R9) + ADD R12, R9, R15 + MOVW R13, -4(R15) + ADD R12, R0, R0 + ADD R12, R9, R9 + JMP copy_2_end + +copy_2_move_8through16: + MOVD (R0), R1 + ADD R12, R0, R15 + MOVD -8(R15), R13 + MOVD R1, (R9) + ADD R12, R9, R15 + MOVD R13, -8(R15) + ADD R12, R0, R0 + ADD R12, R9, R9 + +copy_2_end: + JMP handle_loop + + // Copy overlapping match +copy_overlapping_match: + ADD R12, R11, R11 + +copy_slow_3: + MOVBU (R0), R16 + BFI $0, R16, $8, R1 + MOVB R1, (R9) + ADD $1, R0, R0 + ADD $1, R9, R9 + SUBS $1, R12, R12 + BNE copy_slow_3 + +handle_loop: + MOVD ctx+16(FP), R0 + MOVD 96(R0), R16 + SUBS $1, R16, R16 + MOVD R16, 96(R0) + BPL sequenceDecs_decodeSync_safe_amd64_main_loop + +loop_finished: + MOVD br+8(FP), R0 + MOVD R2, 24(R0) + MOVB R3, 40(R0) + MOVD R5, 32(R0) + + // Update the context + MOVD ctx+16(FP), R0 + MOVD R11, 136(R0) + MOVD 144(R0), R1 + SUB R1, R10, R10 + MOVD R10, 168(R0) + + // Return success + MOVD $0x00000000, R16 + MOVD R16, ret+24(FP) + RET + + // Return with match length error +sequenceDecs_decodeSync_safe_amd64_error_match_len_ofs_mismatch: + MOVD 24(RSP), R0 + MOVD ctx+16(FP), R1 + MOVD R0, 216(R1) + MOVD $0x00000001, R16 + MOVD R16, ret+24(FP) + RET + + // Return with match too long error +sequenceDecs_decodeSync_safe_amd64_error_match_len_too_big: + MOVD ctx+16(FP), R0 + MOVD 24(RSP), R1 + MOVD R1, 216(R0) + MOVD $0x00000002, R16 + MOVD R16, ret+24(FP) + RET + + // Return with match offset too long error +error_match_off_too_big: + MOVD ctx+16(FP), R0 + MOVD 16(RSP), R1 + MOVD R1, 224(R0) + MOVD R11, 136(R0) + MOVD $0x00000003, R16 + MOVD R16, ret+24(FP) + RET + + // Return with not enough literals error +error_not_enough_literals: + MOVD ctx+16(FP), R0 + MOVD 32(RSP), R1 + MOVD R1, 208(R0) + MOVD $0x00000004, R16 + MOVD R16, ret+24(FP) + RET + + // Return with overread error +error_overread: + MOVD $0x00000006, R16 + MOVD R16, ret+24(FP) + RET + + // Return with not enough output space error +error_not_enough_space: + MOVD ctx+16(FP), R0 + MOVD 32(RSP), R1 + MOVD R1, 208(R0) + MOVD 24(RSP), R1 + MOVD R1, 216(R0) + MOVD R11, 136(R0) + MOVD $0x00000005, R16 + MOVD R16, ret+24(FP) + RET + +// skipped sequenceDecs_decodeSync_safe_bmi2 (generic twin preferred on arm64) diff --git a/vendor/github.com/klauspost/compress/zstd/seqdec_asm.go b/vendor/github.com/klauspost/compress/zstd/seqdec_asm.go new file mode 100644 index 00000000000..42ce5de7163 --- /dev/null +++ b/vendor/github.com/klauspost/compress/zstd/seqdec_asm.go @@ -0,0 +1,316 @@ +//go:build (amd64 || arm64) && !appengine && !noasm && gc + +package zstd + +import ( + "fmt" + "io" +) + +// This file holds the parts of the assembly sequence decoder that are identical +// across architectures: the context structs exchanged with the asm, the error +// codes, and the decode/decodeSync/executeSimple wrappers. Each architecture +// supplies the small dispatch helpers (decodeAsm, decodeSyncAsm, +// executeSimpleAsm) that select the concrete asm routine — amd64 also chooses a +// BMI2 variant, arm64 has a single implementation. + +type decodeSyncAsmContext struct { + llTable []decSymbol + mlTable []decSymbol + ofTable []decSymbol + llState uint64 + mlState uint64 + ofState uint64 + iteration int + litRemain int + out []byte + outPosition int + literals []byte + litPosition int + history []byte + windowSize int + ll int // set on error (not for all errors, please refer to _generate/gen.go) + ml int // set on error (not for all errors, please refer to _generate/gen.go) + mo int // set on error (not for all errors, please refer to _generate/gen.go) +} + +type decodeAsmContext struct { + llTable []decSymbol + mlTable []decSymbol + ofTable []decSymbol + llState uint64 + mlState uint64 + ofState uint64 + iteration int + seqs []seqVals + litRemain int +} + +type executeAsmContext struct { + seqs []seqVals + seqIndex int + out []byte + history []byte + literals []byte + outPosition int + litPosition int + windowSize int +} + +const noError = 0 + +// error reported when mo == 0 && ml > 0 +const errorMatchLenOfsMismatch = 1 + +// error reported when ml > maxMatchLen +const errorMatchLenTooBig = 2 + +// error reported when mo > available history or mo > s.windowSize +const errorMatchOffTooBig = 3 + +// error reported when the sum of literal lengths exeeceds the literal buffer size +const errorNotEnoughLiterals = 4 + +// error reported when capacity of `out` is too small +const errorNotEnoughSpace = 5 + +// error reported when bits are overread. +const errorOverread = 6 + +// useSafeDecodeSync reports whether decodeSyncSimple must use the bounds-exact +// ("safe") copy variants for the current buffer geometry. +// +// When the output and literal buffers have compressedBlockOverAlloc (16) +// bytes of slack past their logical use, the assembly may use extended +// memory copies that read and write in 16-byte blocks, overrunning the end +// of a literal run or match by up to 15 bytes. Otherwise it must use the +// bounds-exact ("safe") copies. This mirrors the analogous, always-dynamic +// selection in executeSimple below. +// +// The unsafe copies were disabled in #644 (2022) as a mitigation for a +// crash, but that crash's root cause — an unguarded bitReader overread that +// produced out-of-range match offsets/lengths — was fixed three days later +// in #645, which also added the fuzz corpus that has guarded this path since. +// See #1168. An asan-instrumented fuzz job (see .github/workflows/go.yml) +// covers the extended-copy path, which -race and plain fuzzing cannot. +func (s *sequenceDecs) useSafeDecodeSync() bool { + if s.maxSyncLen == 0 && cap(s.out)-len(s.out) < maxCompressedBlockSizeAlloc { + return true + } + if s.maxSyncLen > 0 && cap(s.out)-len(s.out)-compressedBlockOverAlloc < int(s.maxSyncLen) { + return true + } + if cap(s.literals) < len(s.literals)+compressedBlockOverAlloc { + return true + } + return false +} + +// decode sequences from the stream with the provided history but without a dictionary. +func (s *sequenceDecs) decodeSyncSimple(hist []byte) (bool, error) { + if len(s.dict) > 0 { + return false, nil + } + if s.maxSyncLen == 0 && cap(s.out)-len(s.out) < maxCompressedBlockSize { + return false, nil + } + + useSafe := s.useSafeDecodeSync() + + br := s.br + + maxBlockSize := min(s.windowSize, maxCompressedBlockSize) + + ctx := decodeSyncAsmContext{ + llTable: s.litLengths.fse.dt[:maxTablesize], + mlTable: s.matchLengths.fse.dt[:maxTablesize], + ofTable: s.offsets.fse.dt[:maxTablesize], + llState: uint64(s.litLengths.state.state), + mlState: uint64(s.matchLengths.state.state), + ofState: uint64(s.offsets.state.state), + iteration: s.nSeqs - 1, + litRemain: len(s.literals), + out: s.out, + outPosition: len(s.out), + literals: s.literals, + windowSize: s.windowSize, + history: hist, + } + + s.seqSize = 0 + startSize := len(s.out) + + errCode := decodeSyncAsm(s, br, &ctx, useSafe) + switch errCode { + case noError: + break + + case errorMatchLenOfsMismatch: + return true, fmt.Errorf("zero matchoff and matchlen (%d) > 0", ctx.ml) + + case errorMatchLenTooBig: + return true, fmt.Errorf("match len (%d) bigger than max allowed length", ctx.ml) + + case errorMatchOffTooBig: + return true, fmt.Errorf("match offset (%d) bigger than current history (%d)", + ctx.mo, ctx.outPosition+len(hist)-startSize) + + case errorNotEnoughLiterals: + return true, fmt.Errorf("unexpected literal count, want %d bytes, but only %d is available", + ctx.ll, ctx.litRemain+ctx.ll) + + case errorOverread: + return true, io.ErrUnexpectedEOF + + case errorNotEnoughSpace: + size := ctx.outPosition + ctx.ll + ctx.ml + if debugDecoder { + println("msl:", s.maxSyncLen, "cap", cap(s.out), "bef:", startSize, "sz:", size-startSize, "mbs:", maxBlockSize, "outsz:", cap(s.out)-startSize) + } + return true, fmt.Errorf("output bigger than max block size (%d)", maxBlockSize) + + default: + return true, fmt.Errorf("sequenceDecs_decode returned erroneous code %d", errCode) + } + + s.seqSize += ctx.litRemain + if s.seqSize > maxBlockSize { + return true, fmt.Errorf("output bigger than max block size (%d)", maxBlockSize) + } + err := br.close() + if err != nil { + printf("Closing sequences: %v, %+v\n", err, *br) + return true, err + } + + s.literals = s.literals[ctx.litPosition:] + t := ctx.outPosition + s.out = s.out[:t] + + // Add final literals + s.out = append(s.out, s.literals...) + if debugDecoder { + t += len(s.literals) + if t != len(s.out) { + panic(fmt.Errorf("length mismatch, want %d, got %d", len(s.out), t)) + } + } + + return true, nil +} + +// decode sequences from the stream without the provided history. +func (s *sequenceDecs) decode(seqs []seqVals) error { + br := s.br + + maxBlockSize := min(s.windowSize, maxCompressedBlockSize) + + ctx := decodeAsmContext{ + llTable: s.litLengths.fse.dt[:maxTablesize], + mlTable: s.matchLengths.fse.dt[:maxTablesize], + ofTable: s.offsets.fse.dt[:maxTablesize], + llState: uint64(s.litLengths.state.state), + mlState: uint64(s.matchLengths.state.state), + ofState: uint64(s.offsets.state.state), + seqs: seqs, + iteration: len(seqs) - 1, + litRemain: len(s.literals), + } + + if debugDecoder { + println("decode: decoding", len(seqs), "sequences", br.remain(), "bits remain on stream") + } + + s.seqSize = 0 + lte56bits := s.maxBits+s.offsets.fse.actualTableLog+s.matchLengths.fse.actualTableLog+s.litLengths.fse.actualTableLog <= 56 + errCode := decodeAsm(s, br, &ctx, lte56bits) + if errCode != 0 { + i := len(seqs) - ctx.iteration - 1 + switch errCode { + case errorMatchLenOfsMismatch: + ml := ctx.seqs[i].ml + return fmt.Errorf("zero matchoff and matchlen (%d) > 0", ml) + + case errorMatchLenTooBig: + ml := ctx.seqs[i].ml + return fmt.Errorf("match len (%d) bigger than max allowed length", ml) + + case errorNotEnoughLiterals: + ll := ctx.seqs[i].ll + return fmt.Errorf("unexpected literal count, want %d bytes, but only %d is available", ll, ctx.litRemain+ll) + case errorOverread: + return io.ErrUnexpectedEOF + } + + return fmt.Errorf("sequenceDecs_decode_amd64 returned erroneous code %d", errCode) + } + + if ctx.litRemain < 0 { + return fmt.Errorf("literal count is too big: total available %d, total requested %d", + len(s.literals), len(s.literals)-ctx.litRemain) + } + + s.seqSize += ctx.litRemain + if s.seqSize > maxBlockSize { + return fmt.Errorf("output bigger than max block size (%d)", maxBlockSize) + } + if debugDecoder { + println("decode: ", br.remain(), "bits remain on stream. code:", errCode) + } + err := br.close() + if err != nil { + printf("Closing sequences: %v, %+v\n", err, *br) + } + return err +} + +// executeSimple handles cases when dictionary is not used. +func (s *sequenceDecs) executeSimple(seqs []seqVals, hist []byte) error { + // Ensure we have enough output size... + if len(s.out)+s.seqSize+compressedBlockOverAlloc > cap(s.out) { + addBytes := s.seqSize + len(s.out) + compressedBlockOverAlloc + s.out = append(s.out, make([]byte, addBytes)...) + s.out = s.out[:len(s.out)-addBytes] + } + + if debugDecoder { + printf("Execute %d seqs with literals: %d into %d bytes\n", len(seqs), len(s.literals), s.seqSize) + } + + var t = len(s.out) + out := s.out[:t+s.seqSize] + + ctx := executeAsmContext{ + seqs: seqs, + seqIndex: 0, + out: out, + history: hist, + outPosition: t, + litPosition: 0, + literals: s.literals, + windowSize: s.windowSize, + } + // useSafe avoids overwriting the output buffer when the literals slice has + // not been allocated with the required over-allocation slack. + useSafe := cap(s.literals) < len(s.literals)+compressedBlockOverAlloc + + ok := executeSimpleAsm(&ctx, useSafe) + if !ok { + return fmt.Errorf("match offset (%d) bigger than current history (%d)", + seqs[ctx.seqIndex].mo, ctx.outPosition+len(hist)) + } + s.literals = s.literals[ctx.litPosition:] + t = ctx.outPosition + + // Add final literals + copy(out[t:], s.literals) + if debugDecoder { + t += len(s.literals) + if t != len(out) { + panic(fmt.Errorf("length mismatch, want %d, got %d, ss: %d", len(out), t, s.seqSize)) + } + } + s.out = out + + return nil +} diff --git a/vendor/github.com/klauspost/compress/zstd/seqdec_generic.go b/vendor/github.com/klauspost/compress/zstd/seqdec_generic.go index 516cd9b0701..8a3db6ba22f 100644 --- a/vendor/github.com/klauspost/compress/zstd/seqdec_generic.go +++ b/vendor/github.com/klauspost/compress/zstd/seqdec_generic.go @@ -1,4 +1,4 @@ -//go:build !amd64 || appengine || !gc || noasm +//go:build (!amd64 && !arm64) || appengine || !gc || noasm package zstd diff --git a/vendor/github.com/klauspost/compress/zstd/snappy.go b/vendor/github.com/klauspost/compress/zstd/snappy.go index 336c2889304..36c56f36d77 100644 --- a/vendor/github.com/klauspost/compress/zstd/snappy.go +++ b/vendor/github.com/klauspost/compress/zstd/snappy.go @@ -334,9 +334,10 @@ func decodeSnappy(blk *blockEnc, src []byte) error { return errUnsupportedLiteralLength } - //if length > snappyMaxBlockSize-d || uint32(length) > len(src)-s { - // return ErrSnappyCorrupt - //} + if length > len(src)-s { + println("length > len(src)-s", length, len(src)-s) + return ErrSnappyCorrupt + } blk.literals = append(blk.literals, src[s:s+length]...) //println(length, "litLen") diff --git a/vendor/github.com/klauspost/cpuid/v2/.goreleaser.yml b/vendor/github.com/klauspost/cpuid/v2/.goreleaser.yml index 1b695b62c35..14712fe0dda 100644 --- a/vendor/github.com/klauspost/cpuid/v2/.goreleaser.yml +++ b/vendor/github.com/klauspost/cpuid/v2/.goreleaser.yml @@ -29,7 +29,7 @@ archives: name_template: "cpuid-{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" format_overrides: - goos: windows - format: zip + formats: [ 'zip' ] files: - LICENSE checksum: diff --git a/vendor/github.com/klauspost/cpuid/v2/README.md b/vendor/github.com/klauspost/cpuid/v2/README.md index 7b1d5992116..a99bbdba361 100644 --- a/vendor/github.com/klauspost/cpuid/v2/README.md +++ b/vendor/github.com/klauspost/cpuid/v2/README.md @@ -2,7 +2,7 @@ Package cpuid provides information about the CPU running the current program. CPU features are detected on startup, and kept for fast access through the life of the application. -Currently x86 / x64 (AMD64/i386) and ARM (ARM64) is supported, and no external C (cgo) code is used, which should make the library very easy to use. +Currently x86 / x64 (AMD64/i386), ARM (ARM64), and RISC-V (RV64) are supported, and no external C (cgo) code is used, which should make the library very easy to use. You can access the CPU information by accessing the shared CPU variable of the cpuid library. @@ -281,7 +281,7 @@ Exit Code 1 | AMXBF16 | Tile computational operations on BFLOAT16 numbers | | AMXINT8 | Tile computational operations on 8-bit integers | | AMXFP16 | Tile computational operations on FP16 numbers | -| AMXFP8 | Tile computational operations on FP8 numbers | +| AMXFP8 | Tile computational operations on FP8 numbers | | AMXCOMPLEX | Tile computational operations on complex numbers | | AMXTILE | Tile architecture | | AMXTF32 | Matrix Multiplication of TF32 Tiles into Packed Single Precision Tile | @@ -418,6 +418,7 @@ Exit Code 1 | SEV_SNP | AMD SEV Secure Nested Paging supported | | SGX | Software Guard Extensions | | SGXLC | Software Guard Extensions Launch Control | +| SGXPQC | Software Guard Extensions 256-bit Encryption | | SHA | Intel SHA Extensions | | SME | AMD Secure Memory Encryption supported | | SME_COHERENT | AMD Hardware cache coherency across encryption domains enforced | @@ -450,6 +451,9 @@ Exit Code 1 | TLB_FLUSH_NESTED | AMD: Flushing includes all the nested translations for guest translations | | TME | Intel Total Memory Encryption. The following MSRs are supported: IA32_TME_CAPABILITY, IA32_TME_ACTIVATE, IA32_TME_EXCLUDE_MASK, and IA32_TME_EXCLUDE_BASE. | | TOPEXT | TopologyExtensions: topology extensions support. Indicates support for CPUID Fn8000_001D_EAX_x[N:0]-CPUID Fn8000_001E_EDX. | +| TSA_L1_NO | AMD only: Not vulnerable to TSA-L1 | +| TSA_SQ_NO | AMD only: Not vulnerable to TSA-SQ | +| TSA_VERW_CLEAR | AMD: If set, the memory form of the VERW instruction may be used to help mitigate TSA | | TSCRATEMSR | MSR based TSC rate control. Indicates support for MSR TSC ratio MSRC000_0104 | | TSXLDTRK | Intel TSX Suspend Load Address Tracking | | VAES | Vector AES. AVX(512) versions requires additional checks. | @@ -502,6 +506,74 @@ Exit Code 1 | SM3 | SM3 instructions | | SM4 | SM4 instructions | | SVE | Scalable Vector Extension | +| SVE2 | Scalable Vector Extension 2 | +| SB | Speculation barrier (SB instruction) | +| SSBS | Speculative Store Bypass Safe (PSTATE.SSBS) | +| BTI | Branch Target Identification | +| FLAGM2 | Condition flag manipulation version 2 (AXFLAG, XAFLAG) | +| FRINTTS | Floating-point to integer rounding (FRINT32Z, FRINT64Z, etc) | +| DCPODP | Data cache clean to Point of Deep Persistence (DC CVADP) | +| BF16 | BFloat16 instructions (BFDOT, BFMMLA, etc) | +| I8MM | Int8 matrix multiplication (SMMLA, UMMLA, USMMLA) | +| WFXT | WFE/WFI with timeout (WFET, WFIT) | +| MOPS | Memory copy and set instructions (CPYF, SETP, etc) | +| HBC | Hinted conditional branches (BC.cond) | +| CSSC | Common short sequence compression (ABS, SMAX, UMAX, etc) | + +## riscv64 feature detection + +On `riscv64/linux`, CPU features are detected using the `riscv_hwprobe` syscall (Linux 6.4+). +For older kernels, detection falls back to parsing `/proc/cpuinfo` for the ISA string. + +Cache line size is detected via `riscv_hwprobe` (Zicbom block size) or sysfs fallback. +Other cache and topology information is not yet available. + +# RISC-V features: + +| Feature Flag | Description | +|----------------|----------------------------------------------------| +| RV_IMA | IMA base (Integer, Multiply, Atomic) | +| RV_C | Compressed instructions | +| RV_F | Single-precision FP | +| RV_D | Double-precision FP | +| RV_V | Vector extension (V) | +| RV_ZBA | Address generation | +| RV_ZBB | Basic bit manipulation | +| RV_ZBC | Carry-less multiplication | +| RV_ZBS | Single-bit manipulation | +| RV_ZICOND | Integer conditional operations | +| RV_ZIHINTPAUSE | Pause hint | +| RV_ZICBOM | Cache block management operations | +| RV_ZICBOZ | Cache block zero | +| RV_ZICBOP | Cache block prefetch | +| RV_ZFA | Additional floating-point | +| RV_ZFH | Half-precision FP | +| RV_ZFHMIN | Minimal half-precision FP | +| RV_ZTSO | Total store ordering | +| RV_ZACAS | Atomic CAS | +| RV_ZBKB | Bit-manipulation for crypto | +| RV_ZBKC | Carry-less multiply for crypto | +| RV_ZBKX | Crossbar permutations | +| RV_ZKND | NIST Suite: AES decrypt | +| RV_ZKNE | NIST Suite: AES encrypt | +| RV_ZKNH | NIST Suite: SHA-2 (SHA-256/SHA-512) | +| RV_ZKSED | ShangMi Suite: SM4 block cipher | +| RV_ZKSH | ShangMi Suite: SM3 hash | +| RV_ZKT | Data-independent execution latency (Crypto) | +| RV_ZKN | NIST Algorithm Suite (combined from individual) | +| RV_ZKS | ShangMi Algorithm Suite (combined from individual) | +| RV_ZVBB | Vector Basic Bit-manipulation | +| RV_ZVBC | Vector Carry-less multiply | +| RV_ZVKB | Vector Bit-manipulation for crypto | +| RV_ZVKG | Vector GCM/GMAC | +| RV_ZVKNED | NIST Suite: Vector AES encrypt+decrypt | +| RV_ZVKNHA | NIST Suite: Vector SHA-2 (SHA-256) | +| RV_ZVKNHB | NIST Suite: Vector SHA-2 (SHA-512) | +| RV_ZVKSED | ShangMi Suite: Vector SM4 | +| RV_ZVKSH | ShangMi Suite: Vector SM3 hash | +| RV_ZVKT | Vector Data-independent execution latency | +| RV_ZVKNG | NIST Suite with GCM (combined from individual) | +| RV_ZVKSG | ShangMi Suite with GCM (combined from individual) | # license diff --git a/vendor/github.com/klauspost/cpuid/v2/cpuid.go b/vendor/github.com/klauspost/cpuid/v2/cpuid.go index 248439a9a57..db903f46a47 100644 --- a/vendor/github.com/klauspost/cpuid/v2/cpuid.go +++ b/vendor/github.com/klauspost/cpuid/v2/cpuid.go @@ -3,7 +3,7 @@ // Package cpuid provides information about the CPU running the current program. // // CPU features are detected on startup, and kept for fast access through the life of the application. -// Currently x86 / x64 (AMD64) as well as arm64 is supported. +// Currently x86 / x64 (AMD64), arm64, and riscv64 are supported. // // You can access the CPU information by accessing the shared CPU variable of the cpuid library. // @@ -17,6 +17,7 @@ import ( "math/bits" "os" "runtime" + "slices" "strings" ) @@ -61,6 +62,13 @@ const ( SRE Apple + // RISC-V vendors + SiFive + StarFive + THead + Andes + SpacemiT + lastVendor ) @@ -95,6 +103,7 @@ const ( AVX2 // AVX2 functions AVX512BF16 // AVX-512 BFLOAT16 Instructions AVX512BITALG // AVX-512 Bit Algorithms + AVX512BMM // AVX-512 Bit Manipulation Instructions AVX512BW // AVX-512 Byte and Word Instructions AVX512CD // AVX-512 Conflict Detection Instructions AVX512DQ // AVX-512 Doubleword and Quadword Instructions @@ -139,6 +148,7 @@ const ( FMA4 // Bulldozer FMA4 functions FP128 // AMD: When set, the internal FP/SIMD execution datapath is no more than 128-bits wide FP256 // AMD: When set, the internal FP/SIMD execution datapath is no more than 256-bits wide + FRED // Flexible Return and Event Delivery FSRM // Fast Short Rep Mov FXSR // FXSAVE, FXRESTOR instructions, CR4 bit 9 FXSROPT // FXSAVE/FXRSTOR optimizations @@ -220,6 +230,7 @@ const ( SEV_SNP // AMD SEV Secure Nested Paging supported SGX // Software Guard Extensions SGXLC // Software Guard Extensions Launch Control + SGXPQC // Software Guard Extensions 256-bit Encryption SHA // Intel SHA Extensions SME // AMD Secure Memory Encryption supported SME_COHERENT // AMD Hardware cache coherency across encryption domains enforced @@ -255,6 +266,9 @@ const ( TLB_FLUSH_NESTED // AMD: Flushing includes all the nested translations for guest translations TME // Intel Total Memory Encryption. The following MSRs are supported: IA32_TME_CAPABILITY, IA32_TME_ACTIVATE, IA32_TME_EXCLUDE_MASK, and IA32_TME_EXCLUDE_BASE. TOPEXT // TopologyExtensions: topology extensions support. Indicates support for CPUID Fn8000_001D_EAX_x[N:0]-CPUID Fn8000_001E_EDX. + TSA_L1_NO // AMD only: Not vulnerable to TSA-L1 + TSA_SQ_NO // AM onlyD: Not vulnerable to TSA-SQ + TSA_VERW_CLEAR // If set, the memory form of the VERW instruction may be used to help mitigate TSA TSCRATEMSR // MSR based TSC rate control. Indicates support for MSR TSC ratio MSRC000_0104 TSXLDTRK // Intel TSX Suspend Load Address Tracking VAES // Vector AES. AVX(512) versions requires additional checks. @@ -304,6 +318,77 @@ const ( SM3 // SM3 instructions SM4 // SM4 instructions SVE // Scalable Vector Extension + SVE2 // Scalable Vector Extension 2 + SB // Speculation barrier (SB instruction) + SSBS // Speculative Store Bypass Safe (PSTATE.SSBS) + BTI // Branch Target Identification + FLAGM2 // Condition flag manipulation version 2 (AXFLAG, XAFLAG) + FRINTTS // Floating-point to integer rounding (FRINT32Z, FRINT64Z, etc) + DCPODP // Data cache clean to Point of Deep Persistence (DC CVADP) + BF16 // BFloat16 instructions (BFDOT, BFMMLA, etc) + I8MM // Int8 matrix multiplication (SMMLA, UMMLA, USMMLA) + WFXT // WFE/WFI with timeout (WFET, WFIT) + MOPS // Memory copy and set instructions (CPYF, SETP, etc) + HBC // Hinted conditional branches (BC.cond) + CSSC // Common short sequence compression (ABS, SMAX, UMAX, etc) + + // PMU + PMU_FIXEDCOUNTER_CYCLES + PMU_FIXEDCOUNTER_REFCYCLES + PMU_FIXEDCOUNTER_INSTRUCTIONS + PMU_FIXEDCOUNTER_TOPDOWN_SLOTS + + // RISC-V features + RV_IMA // IMA base (Integer, Multiply, Atomic) + RV_C // Compressed instructions + RV_F // Single-precision FP + RV_D // Double-precision FP + RV_V // Vector extension (V) + RV_ZBA // Address generation + RV_ZBB // Basic bit manipulation + RV_ZBC // Carry-less multiplication + RV_ZBS // Single-bit manipulation + RV_ZICOND // Integer conditional operations + RV_ZIHINTPAUSE // Pause hint + RV_ZICBOM // Cache block management operations + RV_ZICBOZ // Cache block zero + RV_ZICBOP // Cache block prefetch + RV_ZFA // Additional floating-point + RV_ZFH // Half-precision FP + RV_ZFHMIN // Minimal half-precision FP + RV_ZTSO // Total store ordering + RV_ZACAS // Atomic CAS + // Scalar cryptography + RV_ZBKB // Bit-manipulation for crypto + RV_ZBKC // Carry-less multiply for crypto + RV_ZBKX // Crossbar permutations + RV_ZKND // NIST Suite: AES decrypt + RV_ZKNE // NIST Suite: AES encrypt + RV_ZKNH // NIST Suite: SHA-2 (SHA-256/SHA-512) + RV_ZKSED // ShangMi Suite: SM4 block cipher + RV_ZKSH // ShangMi Suite: SM3 hash + RV_ZKT // Data-independent execution latency (Crypto) + + // Scalar crypto suites (combined from individual extensions) + RV_ZKN // NIST Algorithm Suite (Zknd+Zkne+Zknh+Zbkb+Zbkc+Zbkx+Zkt) + RV_ZKS // ShangMi Algorithm Suite (Zksed+Zksh+Zbkb+Zbkc+Zbkx+Zkt) + + // Vector cryptography + RV_ZVBB // Vector Basic Bit-manipulation + RV_ZVBC // Vector Carry-less multiply + RV_ZVKB // Vector Bit-manipulation for crypto + RV_ZVKG // Vector GCM/GMAC + RV_ZVKNED // NIST Suite: Vector AES encrypt+decrypt + RV_ZVKNHA // NIST Suite: Vector SHA-2 (SHA-256) + RV_ZVKNHB // NIST Suite: Vector SHA-2 (SHA-512) + RV_ZVKSED // ShangMi Suite: Vector SM4 + RV_ZVKSH // ShangMi Suite: Vector SM3 hash + RV_ZVKT // Vector Data-independent execution latency + + // Vector crypto suites (combined from individual extensions) + RV_ZVKNG // NIST Suite with GCM (Zvkned+Zvknhb+Zvkg+Zvkb+Zvkt) + RV_ZVKSG // ShangMi Suite with GCM (Zvksed+Zvksh+Zvkg+Zvkb+Zvkt) + // Keep it last. It automatically defines the size of []flagSet lastID @@ -336,11 +421,36 @@ type CPUInfo struct { SGX SGXSupport AMDMemEncryption AMDMemEncryptionSupport AVX10Level uint8 + PMU PerformanceMonitoringInfo // holds information about the PMU maxFunc uint32 maxExFunc uint32 } +// PerformanceMonitoringInfo holds information about CPU performance monitoring capabilities. +// This is primarily populated from CPUID leaf 0xAh on x86 +type PerformanceMonitoringInfo struct { + // VersionID (x86 only): Version ID of architectural performance monitoring. + // A value of 0 means architectural performance monitoring is not supported or information is unavailable. + VersionID uint8 + // NumGPPMC: Number of General-Purpose Performance Monitoring Counters per logical processor. + // On ARM, this is derived from PMCR_EL0.N (number of event counters). + NumGPCounters uint8 + // GPPMCWidth: Bit width of General-Purpose Performance Monitoring Counters. + // On ARM, typically 64 for PMU event counters. + GPPMCWidth uint8 + // NumFixedPMC: Number of Fixed-Function Performance Counters. + // Valid on x86 if VersionID > 1. On ARM, this typically includes at least the cycle counter (PMCCNTR_EL0). + NumFixedPMC uint8 + // FixedPMCWidth: Bit width of Fixed-Function Performance Counters. + // Valid on x86 if VersionID > 1. On ARM, the cycle counter (PMCCNTR_EL0) is 64-bit. + FixedPMCWidth uint8 + // Raw register output from CPUID leaf 0xAh. + RawEBX uint32 + RawEAX uint32 + RawEDX uint32 +} + var cpuid func(op uint32) (eax, ebx, ecx, edx uint32) var cpuidex func(op, op2 uint32) (eax, ebx, ecx, edx uint32) var xgetbv func(index uint32) (eax, edx uint32) @@ -383,8 +493,8 @@ func Detect() { os.Exit(1) } if disableFlag != nil { - s := strings.Split(*disableFlag, ",") - for _, feat := range s { + s := strings.SplitSeq(*disableFlag, ",") + for feat := range s { feat := ParseFeature(strings.TrimSpace(feat)) if feat != UNKNOWN { CPU.featureSet.unset(feat) @@ -435,12 +545,7 @@ func (c *CPUInfo) Has(id FeatureID) bool { // AnyOf returns whether the CPU supports one or more of the requested features. func (c CPUInfo) AnyOf(ids ...FeatureID) bool { - for _, id := range ids { - if c.featureSet.inSet(id) { - return true - } - } - return false + return slices.ContainsFunc(ids, c.featureSet.inSet) } // Features contains several features combined for a fast check using @@ -460,6 +565,11 @@ func (c *CPUInfo) HasAll(f Features) bool { return c.featureSet.hasSetP(f) } +// HasOneOf returns whether the CPU supports one or more of the requested features. +func (c *CPUInfo) HasOneOf(f Features) bool { + return c.featureSet.hasOneOf(f) +} + // https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels var oneOfLevel = CombineFeatures(SYSEE, SYSCALL) var level1Features = CombineFeatures(CMOV, CMPXCHG8, X87, FXSR, MMX, SSE, SSE2) @@ -467,6 +577,56 @@ var level2Features = CombineFeatures(CMOV, CMPXCHG8, X87, FXSR, MMX, SSE, SSE2, var level3Features = CombineFeatures(CMOV, CMPXCHG8, X87, FXSR, MMX, SSE, SSE2, CX16, LAHF, POPCNT, SSE3, SSE4, SSE42, SSSE3, AVX, AVX2, BMI1, BMI2, F16C, FMA3, LZCNT, MOVBE, OSXSAVE) var level4Features = CombineFeatures(CMOV, CMPXCHG8, X87, FXSR, MMX, SSE, SSE2, CX16, LAHF, POPCNT, SSE3, SSE4, SSE42, SSSE3, AVX, AVX2, BMI1, BMI2, F16C, FMA3, LZCNT, MOVBE, OSXSAVE, AVX512F, AVX512BW, AVX512CD, AVX512DQ, AVX512VL) +// RV_CRYPTO_FEATS contains all RISC-V scalar cryptography instruction extensions (excludes Zkt since it is a timing guarantee, not a computational instruction). +var RV_CRYPTO_FEATS = CombineFeatures(RV_ZBKB, RV_ZBKC, RV_ZBKX, RV_ZKND, RV_ZKNE, RV_ZKNH, RV_ZKSED, RV_ZKSH) + +// RV_VECTOR_CRYPTO_FEATS contains all RISC-V vector cryptography extensions. +var RV_VECTOR_CRYPTO_FEATS = CombineFeatures(RV_ZVBB, RV_ZVBC, RV_ZVKB, RV_ZVKG, RV_ZVKNED, RV_ZVKNHA, RV_ZVKNHB, RV_ZVKSED, RV_ZVKSH) + +// RISC-V application profile feature sets. +// https://github.com/riscv/riscv-profiles +var rvProfile20Features = CombineFeatures(RV_IMA, RV_C, RV_F, RV_D) +var rvProfile22Features = CombineFeatures(RV_IMA, RV_C, RV_F, RV_D, RV_ZBA, RV_ZBB, RV_ZBS, RV_ZFHMIN, RV_ZICBOM, RV_ZICBOP, RV_ZICBOZ, RV_ZIHINTPAUSE) +var rvProfile23Features = CombineFeatures(RV_IMA, RV_C, RV_F, RV_D, RV_ZBA, RV_ZBB, RV_ZBS, RV_ZFHMIN, RV_ZICBOM, RV_ZICBOP, RV_ZICBOZ, RV_ZIHINTPAUSE, RV_V, RV_ZFA, RV_ZICOND, RV_ZVBB, RV_ZVKB) + +// RISC-V crypto suites — combined from individual extensions. +var rvZKNFeatures = CombineFeatures(RV_ZKND, RV_ZKNE, RV_ZKNH, RV_ZBKB, RV_ZBKC, RV_ZBKX, RV_ZKT) +var rvZKSFeatures = CombineFeatures(RV_ZKSED, RV_ZKSH, RV_ZBKB, RV_ZBKC, RV_ZBKX, RV_ZKT) +var rvZVKNFeatures = CombineFeatures(RV_ZVKNED, RV_ZVKNHB, RV_ZVKG, RV_ZVKB, RV_ZVKT) +var rvZVKSFeatures = CombineFeatures(RV_ZVKSED, RV_ZVKSH, RV_ZVKG, RV_ZVKB, RV_ZVKT) + +// ARM64 architecture levels. armV8Levels[m] is the cumulative set of mandatory +// user-space instruction features added up to and including ARMv8.m that this +// package can detect. EL1/system-only features (PAN, VHE, CSV2/CSV3, ECV, ...) +// are excluded since they are irrelevant to user-space code generation, exactly +// as X64Level ignores non-instruction features. +// +// FEAT_SSBS and FEAT_BTI, although mandatory from ARMv8.5, are intentionally NOT +// required. Both are OS-policy-gated security features (speculative store bypass +// safety and branch-target identification) that Go code generation never depends +// on: their HWCAP/sysctl bits are set only when the OS or hypervisor enables the +// protection, not purely from CPU capability, so they are routinely hidden even +// on capable silicon (neither a Neoverse N2 Linux guest nor Apple Silicon reports +// them). Requiring them would cap such CPUs at v8.4. Both are still detected and +// reported through FeatureSet when present. +// https://go.dev/wiki/MinimumRequirements#arm64 +var armV8Levels = [...]Features{ + CombineFeatures(FP, ASIMD), // v8.0 + CombineFeatures(FP, ASIMD, ATOMICS, CRC32, ASIMDRDM), // v8.1 + CombineFeatures(FP, ASIMD, ATOMICS, CRC32, ASIMDRDM, DCPOP), // v8.2 + CombineFeatures(FP, ASIMD, ATOMICS, CRC32, ASIMDRDM, DCPOP, JSCVT, FCMA, LRCPC), // v8.3 + CombineFeatures(FP, ASIMD, ATOMICS, CRC32, ASIMDRDM, DCPOP, JSCVT, FCMA, LRCPC, TS), // v8.4 + CombineFeatures(FP, ASIMD, ATOMICS, CRC32, ASIMDRDM, DCPOP, JSCVT, FCMA, LRCPC, TS, SB, FRINTTS, FLAGM2, DCPODP), // v8.5 + CombineFeatures(FP, ASIMD, ATOMICS, CRC32, ASIMDRDM, DCPOP, JSCVT, FCMA, LRCPC, TS, SB, FRINTTS, FLAGM2, DCPODP, BF16, I8MM), // v8.6 + CombineFeatures(FP, ASIMD, ATOMICS, CRC32, ASIMDRDM, DCPOP, JSCVT, FCMA, LRCPC, TS, SB, FRINTTS, FLAGM2, DCPODP, BF16, I8MM, WFXT), // v8.7 + CombineFeatures(FP, ASIMD, ATOMICS, CRC32, ASIMDRDM, DCPOP, JSCVT, FCMA, LRCPC, TS, SB, FRINTTS, FLAGM2, DCPODP, BF16, I8MM, WFXT, MOPS, HBC), // v8.8 + CombineFeatures(FP, ASIMD, ATOMICS, CRC32, ASIMDRDM, DCPOP, JSCVT, FCMA, LRCPC, TS, SB, FRINTTS, FLAGM2, DCPODP, BF16, I8MM, WFXT, MOPS, HBC, CSSC), // v8.9 +} + +// armCrypto matches the GOARM64 ",crypto" option: FEAT_AES, FEAT_PMULL, +// FEAT_SHA1 and FEAT_SHA256. +var armCrypto = CombineFeatures(AESARM, PMULL, SHA1, SHA2) + // X64Level returns the microarchitecture level detected on the CPU. // If features are lacking or non x64 mode, 0 is returned. // See https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels @@ -489,6 +649,67 @@ func (c CPUInfo) X64Level() int { return 0 } +// RVProfile returns the RISC-V application profile level. +// 0 = unknown / base ISA only, 20 = RVA20, 22 = RVA22, 23 = RVA23. +// Returns 0 on non-RISC-V architectures or if not detected. +// https://github.com/riscv/riscv-profiles +func (c CPUInfo) RVProfile() int { + switch { + case c.featureSet.hasSetP(rvProfile23Features): + return 23 + case c.featureSet.hasSetP(rvProfile22Features): + return 22 + case c.featureSet.hasSetP(rvProfile20Features): + return 20 + default: + return 0 + } +} + +// ARM64Level returns the ARMv8/ARMv9 architecture version supported by the CPU +// as (major, minor), e.g. 8, 4 for ARMv8.4-A or 9, 0 for ARMv9.0-A. +// Only mandatory user-space instruction features are considered, so the result +// is the highest level whose required instructions are all present. +// Returns 0, 0 on non-arm64 CPUs or when feature detection was unavailable. +func (c CPUInfo) ARM64Level() (major, minor int) { + if !c.featureSet.hasSetP(armV8Levels[0]) { + return 0, 0 + } + m8 := 0 + for m := len(armV8Levels) - 1; m >= 1; m-- { + if c.featureSet.hasSetP(armV8Levels[m]) { + m8 = m + break + } + } + // ARMv9.x mandates everything in ARMv8.(x+5) plus SVE2. + if m8 >= 5 && c.featureSet.inSet(SVE2) { + return 9, m8 - 5 + } + return 8, m8 +} + +// GOARM64 returns a value usable as the GOARM64 build setting for the detected +// CPU, e.g. "v8.4" or "v9.0,crypto". The ",crypto" suffix is appended when AES, +// PMULL, SHA1 and SHA256 are all present; the ",lse" suffix is appended in the +// rare case LSE is present without the rest of the ARMv8.1 feature set. +// Returns "" on non-arm64 CPUs or when feature detection was unavailable. +// See https://go.dev/wiki/MinimumRequirements#arm64 +func (c CPUInfo) GOARM64() string { + major, minor := c.ARM64Level() + if major == 0 { + return "" + } + v := fmt.Sprintf("v%d.%d", major, minor) + if major == 8 && minor == 0 && c.featureSet.inSet(ATOMICS) { + v += ",lse" + } + if c.featureSet.hasSetP(armCrypto) { + v += ",crypto" + } + return v +} + // Disable will disable one or several features. func (c *CPUInfo) Disable(ids ...FeatureID) bool { for _, id := range ids { @@ -735,7 +956,7 @@ func flagSetWith(feat ...FeatureID) flagSet { // Will return UNKNOWN if not found. func ParseFeature(s string) FeatureID { s = strings.ToUpper(s) - for i := firstID; i < lastID; i++ { + for i := range lastID { if i.String() == s { return i } @@ -749,7 +970,7 @@ func (s flagSet) Strings() []string { return []string{""} } r := make([]string, 0) - for i := firstID; i < lastID; i++ { + for i := range lastID { if s.inSet(i) { r = append(r, i.String()) } @@ -770,7 +991,7 @@ func maxFunctionID() uint32 { func brandName() string { if maxExtendedFunction() >= 0x80000004 { v := make([]uint32, 0, 48) - for i := uint32(0); i < 3; i++ { + for i := range uint32(3) { a, b, c, d := cpuid(0x80000002 + i) v = append(v, a, b, c, d) } @@ -1039,7 +1260,7 @@ func (c *CPUInfo) cacheSize() { // Hack: When we encounter the same entry 100 times we break. nSame := 0 var last uint32 - for i := uint32(0); i < math.MaxUint32; i++ { + for i := range uint32(math.MaxUint32) { eax, ebx, ecx, _ := cpuidex(0x8000001D, i) level := (eax >> 5) & 7 @@ -1293,6 +1514,7 @@ func support() flagSet { fs.setIf(eax1&(1<<10) != 0, MOVSB_ZL) fs.setIf(eax1&(1<<11) != 0, STOSB_SHORT) fs.setIf(eax1&(1<<12) != 0, CMPSB_SCADBS_SHORT) + fs.setIf(eax1&(1<<17) != 0, FRED) fs.setIf(eax1&(1<<22) != 0, HRESET) fs.setIf(eax1&(1<<23) != 0, AVXIFMA) fs.setIf(eax1&(1<<26) != 0, LAM) @@ -1358,6 +1580,11 @@ func support() flagSet { fs.setIf(edx&(1<<4) != 0, BHI_CTRL) fs.setIf(edx&(1<<5) != 0, MCDT_NO) + if fs.inSet(SGX) { + eax, _, _, _ := cpuidex(0x12, 0) + fs.setIf(eax&(1<<12) != 0, SGXPQC) + } + // Add keylocker features. if fs.inSet(KEYLOCKER) && mfi >= 0x19 { _, ebx, _, _ := cpuidex(0x19, 0) @@ -1371,6 +1598,7 @@ func support() flagSet { fs.setIf(ebx&(1<<17) != 0, AVX10_256) fs.setIf(ebx&(1<<18) != 0, AVX10_512) } + } // Processor Extended State Enumeration Sub-leaf (EAX = 0DH, ECX = 1) @@ -1514,12 +1742,29 @@ func support() flagSet { } if maxExtendedFunction() >= 0x80000021 && vend == AMD { - a, _, _, _ := cpuid(0x80000021) + a, _, c, _ := cpuid(0x80000021) fs.setIf((a>>31)&1 == 1, SRSO_MSR_FIX) fs.setIf((a>>30)&1 == 1, SRSO_USER_KERNEL_NO) fs.setIf((a>>29)&1 == 1, SRSO_NO) fs.setIf((a>>28)&1 == 1, IBPB_BRTYPE) fs.setIf((a>>27)&1 == 1, SBPB) + fs.setIf((a>>23)&1 == 1, AVX512BMM) + fs.setIf((c>>1)&1 == 1, TSA_L1_NO) + fs.setIf((c>>2)&1 == 1, TSA_SQ_NO) + fs.setIf((a>>5)&1 == 1, TSA_VERW_CLEAR) + } + if vend == AMD { + if family < 0x19 { + // AMD CPUs that are older than Family 19h are not vulnerable to TSA but do not set TSA_L1_NO or TSA_SQ_NO. + // Source: https://www.amd.com/content/dam/amd/en/documents/resources/bulletin/technical-guidance-for-mitigating-transient-scheduler-attacks.pdf + fs.set(TSA_L1_NO) + fs.set(TSA_SQ_NO) + } else if family == 0x1a { + // AMD Family 1Ah models 00h-4Fh and 60h-7Fh are also not vulnerable to TSA but do not set TSA_L1_NO or TSA_SQ_NO. + // Future AMD CPUs will set these CPUID bits if appropriate. CPUs will be designed to set these CPUID bits if appropriate. + notVuln := model <= 0x4f || (model >= 0x60 && model <= 0x7f) + fs.setIf(notVuln, TSA_L1_NO, TSA_SQ_NO) + } } if mfi >= 0x20 { @@ -1575,3 +1820,47 @@ func valAsString(values ...uint32) []byte { } return r } + +func parseLeaf0AH(c *CPUInfo, eax, ebx, edx uint32) (info PerformanceMonitoringInfo) { + info.VersionID = uint8(eax & 0xFF) + info.NumGPCounters = uint8((eax >> 8) & 0xFF) + info.GPPMCWidth = uint8((eax >> 16) & 0xFF) + + info.RawEBX = ebx + info.RawEAX = eax + info.RawEDX = edx + + if info.VersionID > 1 { // This information is only valid if VersionID > 1 + info.NumFixedPMC = uint8(edx & 0x1F) // Bits 4:0 + info.FixedPMCWidth = uint8((edx >> 5) & 0xFF) // Bits 12:5 + } + if info.VersionID > 0 { + // first 4 fixed events are always instructions retired, cycles, ref cycles and topdown slots + if ebx == 0x0 && info.NumFixedPMC == 3 { + c.featureSet.set(PMU_FIXEDCOUNTER_INSTRUCTIONS) + c.featureSet.set(PMU_FIXEDCOUNTER_CYCLES) + c.featureSet.set(PMU_FIXEDCOUNTER_REFCYCLES) + } + if ebx == 0x0 && info.NumFixedPMC == 4 { + c.featureSet.set(PMU_FIXEDCOUNTER_INSTRUCTIONS) + c.featureSet.set(PMU_FIXEDCOUNTER_CYCLES) + c.featureSet.set(PMU_FIXEDCOUNTER_REFCYCLES) + c.featureSet.set(PMU_FIXEDCOUNTER_TOPDOWN_SLOTS) + } + if ebx != 0x0 { + if ((ebx >> 0) & 1) == 0 { + c.featureSet.set(PMU_FIXEDCOUNTER_INSTRUCTIONS) + } + if ((ebx >> 1) & 1) == 0 { + c.featureSet.set(PMU_FIXEDCOUNTER_CYCLES) + } + if ((ebx >> 2) & 1) == 0 { + c.featureSet.set(PMU_FIXEDCOUNTER_REFCYCLES) + } + if ((ebx >> 3) & 1) == 0 { + c.featureSet.set(PMU_FIXEDCOUNTER_TOPDOWN_SLOTS) + } + } + } + return info +} diff --git a/vendor/github.com/klauspost/cpuid/v2/detect_arm64.go b/vendor/github.com/klauspost/cpuid/v2/detect_arm64.go index 9ae32d607dc..e615b10be7d 100644 --- a/vendor/github.com/klauspost/cpuid/v2/detect_arm64.go +++ b/vendor/github.com/klauspost/cpuid/v2/detect_arm64.go @@ -1,7 +1,6 @@ // Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file. //go:build arm64 && !gccgo && !noasm && !appengine -// +build arm64,!gccgo,!noasm,!appengine package cpuid @@ -189,6 +188,7 @@ func addInfo(c *CPUInfo, safe bool) { f.setIf(instAttrReg0&(0xf<<60) != 0, RNDR) f.setIf(instAttrReg0&(0xf<<56) != 0, TLB) f.setIf(instAttrReg0&(0xf<<52) != 0, TS) + f.setIf(instAttrReg0&(0xf<<52) == 2<<52, FLAGM2) // TS == 0b0010 (FEAT_FlagM2) f.setIf(instAttrReg0&(0xf<<48) != 0, FHM) f.setIf(instAttrReg0&(0xf<<44) != 0, ASIMDDP) f.setIf(instAttrReg0&(0xf<<40) != 0, SM4) @@ -244,6 +244,13 @@ func addInfo(c *CPUInfo, safe bool) { // fmt.Println("APA") // } f.setIf(instAttrReg1&(0xf<<0) != 0, DCPOP) + f.setIf(instAttrReg1&(0xf<<0) == 2<<0, DCPODP) // DPB == 0b0010 (FEAT_DPB2) + + // Upper ID_AA64ISAR1_EL1 fields, not in the table above. + f.setIf(instAttrReg1&(0xf<<32) != 0, FRINTTS) // bits [35:32] + f.setIf(instAttrReg1&(0xf<<36) != 0, SB) // bits [39:36] + f.setIf(instAttrReg1&(0xf<<44) != 0, BF16) // bits [47:44] + f.setIf(instAttrReg1&(0xf<<52) != 0, I8MM) // bits [55:52] // Store c.featureSet.or(f) diff --git a/vendor/github.com/klauspost/cpuid/v2/detect_ref.go b/vendor/github.com/klauspost/cpuid/v2/detect_ref.go index 574f9389c07..38699f4d78a 100644 --- a/vendor/github.com/klauspost/cpuid/v2/detect_ref.go +++ b/vendor/github.com/klauspost/cpuid/v2/detect_ref.go @@ -1,7 +1,6 @@ // Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file. -//go:build (!amd64 && !386 && !arm64) || gccgo || noasm || appengine -// +build !amd64,!386,!arm64 gccgo noasm appengine +//go:build (!amd64 && !386 && !arm64 && !riscv64) || ((amd64 || 386) && (gccgo || noasm || appengine)) package cpuid diff --git a/vendor/github.com/klauspost/cpuid/v2/detect_ref_arm64.go b/vendor/github.com/klauspost/cpuid/v2/detect_ref_arm64.go new file mode 100644 index 00000000000..d2ea76ba823 --- /dev/null +++ b/vendor/github.com/klauspost/cpuid/v2/detect_ref_arm64.go @@ -0,0 +1,19 @@ +// Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file. + +//go:build arm64 && (gccgo || noasm || appengine) + +package cpuid + +func initCPU() { + cpuid = func(uint32) (a, b, c, d uint32) { return 0, 0, 0, 0 } + cpuidex = func(x, y uint32) (a, b, c, d uint32) { return 0, 0, 0, 0 } + xgetbv = func(uint32) (a, b uint32) { return 0, 0 } + rdtscpAsm = func() (a, b, c, d uint32) { return 0, 0, 0, 0 } +} + +func addInfo(c *CPUInfo, safe bool) { + c.CacheLine = 64 + detectOS(c) +} + +func getVectorLength() (vl, pl uint64) { return 0, 0 } diff --git a/vendor/github.com/klauspost/cpuid/v2/detect_riscv64.go b/vendor/github.com/klauspost/cpuid/v2/detect_riscv64.go new file mode 100644 index 00000000000..25381f08982 --- /dev/null +++ b/vendor/github.com/klauspost/cpuid/v2/detect_riscv64.go @@ -0,0 +1,16 @@ +// Copyright (c) 2026 Klaus Post, released under MIT License. See LICENSE file. + +package cpuid + +func getVectorLength() (vl, pl uint64) { return 0, 0 } + +func initCPU() { + cpuid = func(uint32) (a, b, c, d uint32) { return 0, 0, 0, 0 } + cpuidex = func(x, y uint32) (a, b, c, d uint32) { return 0, 0, 0, 0 } + xgetbv = func(uint32) (a, b uint32) { return 0, 0 } + rdtscpAsm = func() (a, b, c, d uint32) { return 0, 0, 0, 0 } +} + +func addInfo(c *CPUInfo, safe bool) { + detectOS(c) +} diff --git a/vendor/github.com/klauspost/cpuid/v2/detect_x86.go b/vendor/github.com/klauspost/cpuid/v2/detect_x86.go index f924c9d8399..22819ce4a91 100644 --- a/vendor/github.com/klauspost/cpuid/v2/detect_x86.go +++ b/vendor/github.com/klauspost/cpuid/v2/detect_x86.go @@ -1,7 +1,6 @@ // Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file. //go:build (386 && !gccgo && !noasm && !appengine) || (amd64 && !gccgo && !noasm && !appengine) -// +build 386,!gccgo,!noasm,!appengine amd64,!gccgo,!noasm,!appengine package cpuid @@ -36,6 +35,10 @@ func addInfo(c *CPUInfo, safe bool) { c.AVX10Level = c.supportAVX10() c.cacheSize() c.frequencies() + if c.maxFunc >= 0x0A { + eax, ebx, _, edx := cpuid(0x0A) + c.PMU = parseLeaf0AH(c, eax, ebx, edx) + } } func getVectorLength() (vl, pl uint64) { return 0, 0 } diff --git a/vendor/github.com/klauspost/cpuid/v2/featureid_string.go b/vendor/github.com/klauspost/cpuid/v2/featureid_string.go index 07704351faf..f88ead13080 100644 --- a/vendor/github.com/klauspost/cpuid/v2/featureid_string.go +++ b/vendor/github.com/klauspost/cpuid/v2/featureid_string.go @@ -29,226 +29,292 @@ func _() { _ = x[AVX2-19] _ = x[AVX512BF16-20] _ = x[AVX512BITALG-21] - _ = x[AVX512BW-22] - _ = x[AVX512CD-23] - _ = x[AVX512DQ-24] - _ = x[AVX512ER-25] - _ = x[AVX512F-26] - _ = x[AVX512FP16-27] - _ = x[AVX512IFMA-28] - _ = x[AVX512PF-29] - _ = x[AVX512VBMI-30] - _ = x[AVX512VBMI2-31] - _ = x[AVX512VL-32] - _ = x[AVX512VNNI-33] - _ = x[AVX512VP2INTERSECT-34] - _ = x[AVX512VPOPCNTDQ-35] - _ = x[AVXIFMA-36] - _ = x[AVXNECONVERT-37] - _ = x[AVXSLOW-38] - _ = x[AVXVNNI-39] - _ = x[AVXVNNIINT8-40] - _ = x[AVXVNNIINT16-41] - _ = x[BHI_CTRL-42] - _ = x[BMI1-43] - _ = x[BMI2-44] - _ = x[CETIBT-45] - _ = x[CETSS-46] - _ = x[CLDEMOTE-47] - _ = x[CLMUL-48] - _ = x[CLZERO-49] - _ = x[CMOV-50] - _ = x[CMPCCXADD-51] - _ = x[CMPSB_SCADBS_SHORT-52] - _ = x[CMPXCHG8-53] - _ = x[CPBOOST-54] - _ = x[CPPC-55] - _ = x[CX16-56] - _ = x[EFER_LMSLE_UNS-57] - _ = x[ENQCMD-58] - _ = x[ERMS-59] - _ = x[F16C-60] - _ = x[FLUSH_L1D-61] - _ = x[FMA3-62] - _ = x[FMA4-63] - _ = x[FP128-64] - _ = x[FP256-65] - _ = x[FSRM-66] - _ = x[FXSR-67] - _ = x[FXSROPT-68] - _ = x[GFNI-69] - _ = x[HLE-70] - _ = x[HRESET-71] - _ = x[HTT-72] - _ = x[HWA-73] - _ = x[HYBRID_CPU-74] - _ = x[HYPERVISOR-75] - _ = x[IA32_ARCH_CAP-76] - _ = x[IA32_CORE_CAP-77] - _ = x[IBPB-78] - _ = x[IBPB_BRTYPE-79] - _ = x[IBRS-80] - _ = x[IBRS_PREFERRED-81] - _ = x[IBRS_PROVIDES_SMP-82] - _ = x[IBS-83] - _ = x[IBSBRNTRGT-84] - _ = x[IBSFETCHSAM-85] - _ = x[IBSFFV-86] - _ = x[IBSOPCNT-87] - _ = x[IBSOPCNTEXT-88] - _ = x[IBSOPSAM-89] - _ = x[IBSRDWROPCNT-90] - _ = x[IBSRIPINVALIDCHK-91] - _ = x[IBS_FETCH_CTLX-92] - _ = x[IBS_OPDATA4-93] - _ = x[IBS_OPFUSE-94] - _ = x[IBS_PREVENTHOST-95] - _ = x[IBS_ZEN4-96] - _ = x[IDPRED_CTRL-97] - _ = x[INT_WBINVD-98] - _ = x[INVLPGB-99] - _ = x[KEYLOCKER-100] - _ = x[KEYLOCKERW-101] - _ = x[LAHF-102] - _ = x[LAM-103] - _ = x[LBRVIRT-104] - _ = x[LZCNT-105] - _ = x[MCAOVERFLOW-106] - _ = x[MCDT_NO-107] - _ = x[MCOMMIT-108] - _ = x[MD_CLEAR-109] - _ = x[MMX-110] - _ = x[MMXEXT-111] - _ = x[MOVBE-112] - _ = x[MOVDIR64B-113] - _ = x[MOVDIRI-114] - _ = x[MOVSB_ZL-115] - _ = x[MOVU-116] - _ = x[MPX-117] - _ = x[MSRIRC-118] - _ = x[MSRLIST-119] - _ = x[MSR_PAGEFLUSH-120] - _ = x[NRIPS-121] - _ = x[NX-122] - _ = x[OSXSAVE-123] - _ = x[PCONFIG-124] - _ = x[POPCNT-125] - _ = x[PPIN-126] - _ = x[PREFETCHI-127] - _ = x[PSFD-128] - _ = x[RDPRU-129] - _ = x[RDRAND-130] - _ = x[RDSEED-131] - _ = x[RDTSCP-132] - _ = x[RRSBA_CTRL-133] - _ = x[RTM-134] - _ = x[RTM_ALWAYS_ABORT-135] - _ = x[SBPB-136] - _ = x[SERIALIZE-137] - _ = x[SEV-138] - _ = x[SEV_64BIT-139] - _ = x[SEV_ALTERNATIVE-140] - _ = x[SEV_DEBUGSWAP-141] - _ = x[SEV_ES-142] - _ = x[SEV_RESTRICTED-143] - _ = x[SEV_SNP-144] - _ = x[SGX-145] - _ = x[SGXLC-146] - _ = x[SHA-147] - _ = x[SME-148] - _ = x[SME_COHERENT-149] - _ = x[SM3_X86-150] - _ = x[SM4_X86-151] - _ = x[SPEC_CTRL_SSBD-152] - _ = x[SRBDS_CTRL-153] - _ = x[SRSO_MSR_FIX-154] - _ = x[SRSO_NO-155] - _ = x[SRSO_USER_KERNEL_NO-156] - _ = x[SSE-157] - _ = x[SSE2-158] - _ = x[SSE3-159] - _ = x[SSE4-160] - _ = x[SSE42-161] - _ = x[SSE4A-162] - _ = x[SSSE3-163] - _ = x[STIBP-164] - _ = x[STIBP_ALWAYSON-165] - _ = x[STOSB_SHORT-166] - _ = x[SUCCOR-167] - _ = x[SVM-168] - _ = x[SVMDA-169] - _ = x[SVMFBASID-170] - _ = x[SVML-171] - _ = x[SVMNP-172] - _ = x[SVMPF-173] - _ = x[SVMPFT-174] - _ = x[SYSCALL-175] - _ = x[SYSEE-176] - _ = x[TBM-177] - _ = x[TDX_GUEST-178] - _ = x[TLB_FLUSH_NESTED-179] - _ = x[TME-180] - _ = x[TOPEXT-181] - _ = x[TSCRATEMSR-182] - _ = x[TSXLDTRK-183] - _ = x[VAES-184] - _ = x[VMCBCLEAN-185] - _ = x[VMPL-186] - _ = x[VMSA_REGPROT-187] - _ = x[VMX-188] - _ = x[VPCLMULQDQ-189] - _ = x[VTE-190] - _ = x[WAITPKG-191] - _ = x[WBNOINVD-192] - _ = x[WRMSRNS-193] - _ = x[X87-194] - _ = x[XGETBV1-195] - _ = x[XOP-196] - _ = x[XSAVE-197] - _ = x[XSAVEC-198] - _ = x[XSAVEOPT-199] - _ = x[XSAVES-200] - _ = x[AESARM-201] - _ = x[ARMCPUID-202] - _ = x[ASIMD-203] - _ = x[ASIMDDP-204] - _ = x[ASIMDHP-205] - _ = x[ASIMDRDM-206] - _ = x[ATOMICS-207] - _ = x[CRC32-208] - _ = x[DCPOP-209] - _ = x[EVTSTRM-210] - _ = x[FCMA-211] - _ = x[FHM-212] - _ = x[FP-213] - _ = x[FPHP-214] - _ = x[GPA-215] - _ = x[JSCVT-216] - _ = x[LRCPC-217] - _ = x[PMULL-218] - _ = x[RNDR-219] - _ = x[TLB-220] - _ = x[TS-221] - _ = x[SHA1-222] - _ = x[SHA2-223] - _ = x[SHA3-224] - _ = x[SHA512-225] - _ = x[SM3-226] - _ = x[SM4-227] - _ = x[SVE-228] - _ = x[lastID-229] + _ = x[AVX512BMM-22] + _ = x[AVX512BW-23] + _ = x[AVX512CD-24] + _ = x[AVX512DQ-25] + _ = x[AVX512ER-26] + _ = x[AVX512F-27] + _ = x[AVX512FP16-28] + _ = x[AVX512IFMA-29] + _ = x[AVX512PF-30] + _ = x[AVX512VBMI-31] + _ = x[AVX512VBMI2-32] + _ = x[AVX512VL-33] + _ = x[AVX512VNNI-34] + _ = x[AVX512VP2INTERSECT-35] + _ = x[AVX512VPOPCNTDQ-36] + _ = x[AVXIFMA-37] + _ = x[AVXNECONVERT-38] + _ = x[AVXSLOW-39] + _ = x[AVXVNNI-40] + _ = x[AVXVNNIINT8-41] + _ = x[AVXVNNIINT16-42] + _ = x[BHI_CTRL-43] + _ = x[BMI1-44] + _ = x[BMI2-45] + _ = x[CETIBT-46] + _ = x[CETSS-47] + _ = x[CLDEMOTE-48] + _ = x[CLMUL-49] + _ = x[CLZERO-50] + _ = x[CMOV-51] + _ = x[CMPCCXADD-52] + _ = x[CMPSB_SCADBS_SHORT-53] + _ = x[CMPXCHG8-54] + _ = x[CPBOOST-55] + _ = x[CPPC-56] + _ = x[CX16-57] + _ = x[EFER_LMSLE_UNS-58] + _ = x[ENQCMD-59] + _ = x[ERMS-60] + _ = x[F16C-61] + _ = x[FLUSH_L1D-62] + _ = x[FMA3-63] + _ = x[FMA4-64] + _ = x[FP128-65] + _ = x[FP256-66] + _ = x[FRED-67] + _ = x[FSRM-68] + _ = x[FXSR-69] + _ = x[FXSROPT-70] + _ = x[GFNI-71] + _ = x[HLE-72] + _ = x[HRESET-73] + _ = x[HTT-74] + _ = x[HWA-75] + _ = x[HYBRID_CPU-76] + _ = x[HYPERVISOR-77] + _ = x[IA32_ARCH_CAP-78] + _ = x[IA32_CORE_CAP-79] + _ = x[IBPB-80] + _ = x[IBPB_BRTYPE-81] + _ = x[IBRS-82] + _ = x[IBRS_PREFERRED-83] + _ = x[IBRS_PROVIDES_SMP-84] + _ = x[IBS-85] + _ = x[IBSBRNTRGT-86] + _ = x[IBSFETCHSAM-87] + _ = x[IBSFFV-88] + _ = x[IBSOPCNT-89] + _ = x[IBSOPCNTEXT-90] + _ = x[IBSOPSAM-91] + _ = x[IBSRDWROPCNT-92] + _ = x[IBSRIPINVALIDCHK-93] + _ = x[IBS_FETCH_CTLX-94] + _ = x[IBS_OPDATA4-95] + _ = x[IBS_OPFUSE-96] + _ = x[IBS_PREVENTHOST-97] + _ = x[IBS_ZEN4-98] + _ = x[IDPRED_CTRL-99] + _ = x[INT_WBINVD-100] + _ = x[INVLPGB-101] + _ = x[KEYLOCKER-102] + _ = x[KEYLOCKERW-103] + _ = x[LAHF-104] + _ = x[LAM-105] + _ = x[LBRVIRT-106] + _ = x[LZCNT-107] + _ = x[MCAOVERFLOW-108] + _ = x[MCDT_NO-109] + _ = x[MCOMMIT-110] + _ = x[MD_CLEAR-111] + _ = x[MMX-112] + _ = x[MMXEXT-113] + _ = x[MOVBE-114] + _ = x[MOVDIR64B-115] + _ = x[MOVDIRI-116] + _ = x[MOVSB_ZL-117] + _ = x[MOVU-118] + _ = x[MPX-119] + _ = x[MSRIRC-120] + _ = x[MSRLIST-121] + _ = x[MSR_PAGEFLUSH-122] + _ = x[NRIPS-123] + _ = x[NX-124] + _ = x[OSXSAVE-125] + _ = x[PCONFIG-126] + _ = x[POPCNT-127] + _ = x[PPIN-128] + _ = x[PREFETCHI-129] + _ = x[PSFD-130] + _ = x[RDPRU-131] + _ = x[RDRAND-132] + _ = x[RDSEED-133] + _ = x[RDTSCP-134] + _ = x[RRSBA_CTRL-135] + _ = x[RTM-136] + _ = x[RTM_ALWAYS_ABORT-137] + _ = x[SBPB-138] + _ = x[SERIALIZE-139] + _ = x[SEV-140] + _ = x[SEV_64BIT-141] + _ = x[SEV_ALTERNATIVE-142] + _ = x[SEV_DEBUGSWAP-143] + _ = x[SEV_ES-144] + _ = x[SEV_RESTRICTED-145] + _ = x[SEV_SNP-146] + _ = x[SGX-147] + _ = x[SGXLC-148] + _ = x[SGXPQC-149] + _ = x[SHA-150] + _ = x[SME-151] + _ = x[SME_COHERENT-152] + _ = x[SM3_X86-153] + _ = x[SM4_X86-154] + _ = x[SPEC_CTRL_SSBD-155] + _ = x[SRBDS_CTRL-156] + _ = x[SRSO_MSR_FIX-157] + _ = x[SRSO_NO-158] + _ = x[SRSO_USER_KERNEL_NO-159] + _ = x[SSE-160] + _ = x[SSE2-161] + _ = x[SSE3-162] + _ = x[SSE4-163] + _ = x[SSE42-164] + _ = x[SSE4A-165] + _ = x[SSSE3-166] + _ = x[STIBP-167] + _ = x[STIBP_ALWAYSON-168] + _ = x[STOSB_SHORT-169] + _ = x[SUCCOR-170] + _ = x[SVM-171] + _ = x[SVMDA-172] + _ = x[SVMFBASID-173] + _ = x[SVML-174] + _ = x[SVMNP-175] + _ = x[SVMPF-176] + _ = x[SVMPFT-177] + _ = x[SYSCALL-178] + _ = x[SYSEE-179] + _ = x[TBM-180] + _ = x[TDX_GUEST-181] + _ = x[TLB_FLUSH_NESTED-182] + _ = x[TME-183] + _ = x[TOPEXT-184] + _ = x[TSA_L1_NO-185] + _ = x[TSA_SQ_NO-186] + _ = x[TSA_VERW_CLEAR-187] + _ = x[TSCRATEMSR-188] + _ = x[TSXLDTRK-189] + _ = x[VAES-190] + _ = x[VMCBCLEAN-191] + _ = x[VMPL-192] + _ = x[VMSA_REGPROT-193] + _ = x[VMX-194] + _ = x[VPCLMULQDQ-195] + _ = x[VTE-196] + _ = x[WAITPKG-197] + _ = x[WBNOINVD-198] + _ = x[WRMSRNS-199] + _ = x[X87-200] + _ = x[XGETBV1-201] + _ = x[XOP-202] + _ = x[XSAVE-203] + _ = x[XSAVEC-204] + _ = x[XSAVEOPT-205] + _ = x[XSAVES-206] + _ = x[AESARM-207] + _ = x[ARMCPUID-208] + _ = x[ASIMD-209] + _ = x[ASIMDDP-210] + _ = x[ASIMDHP-211] + _ = x[ASIMDRDM-212] + _ = x[ATOMICS-213] + _ = x[CRC32-214] + _ = x[DCPOP-215] + _ = x[EVTSTRM-216] + _ = x[FCMA-217] + _ = x[FHM-218] + _ = x[FP-219] + _ = x[FPHP-220] + _ = x[GPA-221] + _ = x[JSCVT-222] + _ = x[LRCPC-223] + _ = x[PMULL-224] + _ = x[RNDR-225] + _ = x[TLB-226] + _ = x[TS-227] + _ = x[SHA1-228] + _ = x[SHA2-229] + _ = x[SHA3-230] + _ = x[SHA512-231] + _ = x[SM3-232] + _ = x[SM4-233] + _ = x[SVE-234] + _ = x[SVE2-235] + _ = x[SB-236] + _ = x[SSBS-237] + _ = x[BTI-238] + _ = x[FLAGM2-239] + _ = x[FRINTTS-240] + _ = x[DCPODP-241] + _ = x[BF16-242] + _ = x[I8MM-243] + _ = x[WFXT-244] + _ = x[MOPS-245] + _ = x[HBC-246] + _ = x[CSSC-247] + _ = x[PMU_FIXEDCOUNTER_CYCLES-248] + _ = x[PMU_FIXEDCOUNTER_REFCYCLES-249] + _ = x[PMU_FIXEDCOUNTER_INSTRUCTIONS-250] + _ = x[PMU_FIXEDCOUNTER_TOPDOWN_SLOTS-251] + _ = x[RV_IMA-252] + _ = x[RV_C-253] + _ = x[RV_F-254] + _ = x[RV_D-255] + _ = x[RV_V-256] + _ = x[RV_ZBA-257] + _ = x[RV_ZBB-258] + _ = x[RV_ZBC-259] + _ = x[RV_ZBS-260] + _ = x[RV_ZICOND-261] + _ = x[RV_ZIHINTPAUSE-262] + _ = x[RV_ZICBOM-263] + _ = x[RV_ZICBOZ-264] + _ = x[RV_ZICBOP-265] + _ = x[RV_ZFA-266] + _ = x[RV_ZFH-267] + _ = x[RV_ZFHMIN-268] + _ = x[RV_ZTSO-269] + _ = x[RV_ZACAS-270] + _ = x[RV_ZBKB-271] + _ = x[RV_ZBKC-272] + _ = x[RV_ZBKX-273] + _ = x[RV_ZKND-274] + _ = x[RV_ZKNE-275] + _ = x[RV_ZKNH-276] + _ = x[RV_ZKSED-277] + _ = x[RV_ZKSH-278] + _ = x[RV_ZKT-279] + _ = x[RV_ZKN-280] + _ = x[RV_ZKS-281] + _ = x[RV_ZVBB-282] + _ = x[RV_ZVBC-283] + _ = x[RV_ZVKB-284] + _ = x[RV_ZVKG-285] + _ = x[RV_ZVKNED-286] + _ = x[RV_ZVKNHA-287] + _ = x[RV_ZVKNHB-288] + _ = x[RV_ZVKSED-289] + _ = x[RV_ZVKSH-290] + _ = x[RV_ZVKT-291] + _ = x[RV_ZVKNG-292] + _ = x[RV_ZVKSG-293] + _ = x[lastID-294] _ = x[firstID-0] } -const _FeatureID_name = "firstIDADXAESNIAMD3DNOWAMD3DNOWEXTAMXBF16AMXFP16AMXINT8AMXFP8AMXTILEAMXTF32AMXCOMPLEXAMXTRANSPOSEAPX_FAVXAVX10AVX10_128AVX10_256AVX10_512AVX2AVX512BF16AVX512BITALGAVX512BWAVX512CDAVX512DQAVX512ERAVX512FAVX512FP16AVX512IFMAAVX512PFAVX512VBMIAVX512VBMI2AVX512VLAVX512VNNIAVX512VP2INTERSECTAVX512VPOPCNTDQAVXIFMAAVXNECONVERTAVXSLOWAVXVNNIAVXVNNIINT8AVXVNNIINT16BHI_CTRLBMI1BMI2CETIBTCETSSCLDEMOTECLMULCLZEROCMOVCMPCCXADDCMPSB_SCADBS_SHORTCMPXCHG8CPBOOSTCPPCCX16EFER_LMSLE_UNSENQCMDERMSF16CFLUSH_L1DFMA3FMA4FP128FP256FSRMFXSRFXSROPTGFNIHLEHRESETHTTHWAHYBRID_CPUHYPERVISORIA32_ARCH_CAPIA32_CORE_CAPIBPBIBPB_BRTYPEIBRSIBRS_PREFERREDIBRS_PROVIDES_SMPIBSIBSBRNTRGTIBSFETCHSAMIBSFFVIBSOPCNTIBSOPCNTEXTIBSOPSAMIBSRDWROPCNTIBSRIPINVALIDCHKIBS_FETCH_CTLXIBS_OPDATA4IBS_OPFUSEIBS_PREVENTHOSTIBS_ZEN4IDPRED_CTRLINT_WBINVDINVLPGBKEYLOCKERKEYLOCKERWLAHFLAMLBRVIRTLZCNTMCAOVERFLOWMCDT_NOMCOMMITMD_CLEARMMXMMXEXTMOVBEMOVDIR64BMOVDIRIMOVSB_ZLMOVUMPXMSRIRCMSRLISTMSR_PAGEFLUSHNRIPSNXOSXSAVEPCONFIGPOPCNTPPINPREFETCHIPSFDRDPRURDRANDRDSEEDRDTSCPRRSBA_CTRLRTMRTM_ALWAYS_ABORTSBPBSERIALIZESEVSEV_64BITSEV_ALTERNATIVESEV_DEBUGSWAPSEV_ESSEV_RESTRICTEDSEV_SNPSGXSGXLCSHASMESME_COHERENTSM3_X86SM4_X86SPEC_CTRL_SSBDSRBDS_CTRLSRSO_MSR_FIXSRSO_NOSRSO_USER_KERNEL_NOSSESSE2SSE3SSE4SSE42SSE4ASSSE3STIBPSTIBP_ALWAYSONSTOSB_SHORTSUCCORSVMSVMDASVMFBASIDSVMLSVMNPSVMPFSVMPFTSYSCALLSYSEETBMTDX_GUESTTLB_FLUSH_NESTEDTMETOPEXTTSCRATEMSRTSXLDTRKVAESVMCBCLEANVMPLVMSA_REGPROTVMXVPCLMULQDQVTEWAITPKGWBNOINVDWRMSRNSX87XGETBV1XOPXSAVEXSAVECXSAVEOPTXSAVESAESARMARMCPUIDASIMDASIMDDPASIMDHPASIMDRDMATOMICSCRC32DCPOPEVTSTRMFCMAFHMFPFPHPGPAJSCVTLRCPCPMULLRNDRTLBTSSHA1SHA2SHA3SHA512SM3SM4SVElastID" +const _FeatureID_name = "firstIDADXAESNIAMD3DNOWAMD3DNOWEXTAMXBF16AMXFP16AMXINT8AMXFP8AMXTILEAMXTF32AMXCOMPLEXAMXTRANSPOSEAPX_FAVXAVX10AVX10_128AVX10_256AVX10_512AVX2AVX512BF16AVX512BITALGAVX512BMMAVX512BWAVX512CDAVX512DQAVX512ERAVX512FAVX512FP16AVX512IFMAAVX512PFAVX512VBMIAVX512VBMI2AVX512VLAVX512VNNIAVX512VP2INTERSECTAVX512VPOPCNTDQAVXIFMAAVXNECONVERTAVXSLOWAVXVNNIAVXVNNIINT8AVXVNNIINT16BHI_CTRLBMI1BMI2CETIBTCETSSCLDEMOTECLMULCLZEROCMOVCMPCCXADDCMPSB_SCADBS_SHORTCMPXCHG8CPBOOSTCPPCCX16EFER_LMSLE_UNSENQCMDERMSF16CFLUSH_L1DFMA3FMA4FP128FP256FREDFSRMFXSRFXSROPTGFNIHLEHRESETHTTHWAHYBRID_CPUHYPERVISORIA32_ARCH_CAPIA32_CORE_CAPIBPBIBPB_BRTYPEIBRSIBRS_PREFERREDIBRS_PROVIDES_SMPIBSIBSBRNTRGTIBSFETCHSAMIBSFFVIBSOPCNTIBSOPCNTEXTIBSOPSAMIBSRDWROPCNTIBSRIPINVALIDCHKIBS_FETCH_CTLXIBS_OPDATA4IBS_OPFUSEIBS_PREVENTHOSTIBS_ZEN4IDPRED_CTRLINT_WBINVDINVLPGBKEYLOCKERKEYLOCKERWLAHFLAMLBRVIRTLZCNTMCAOVERFLOWMCDT_NOMCOMMITMD_CLEARMMXMMXEXTMOVBEMOVDIR64BMOVDIRIMOVSB_ZLMOVUMPXMSRIRCMSRLISTMSR_PAGEFLUSHNRIPSNXOSXSAVEPCONFIGPOPCNTPPINPREFETCHIPSFDRDPRURDRANDRDSEEDRDTSCPRRSBA_CTRLRTMRTM_ALWAYS_ABORTSBPBSERIALIZESEVSEV_64BITSEV_ALTERNATIVESEV_DEBUGSWAPSEV_ESSEV_RESTRICTEDSEV_SNPSGXSGXLCSGXPQCSHASMESME_COHERENTSM3_X86SM4_X86SPEC_CTRL_SSBDSRBDS_CTRLSRSO_MSR_FIXSRSO_NOSRSO_USER_KERNEL_NOSSESSE2SSE3SSE4SSE42SSE4ASSSE3STIBPSTIBP_ALWAYSONSTOSB_SHORTSUCCORSVMSVMDASVMFBASIDSVMLSVMNPSVMPFSVMPFTSYSCALLSYSEETBMTDX_GUESTTLB_FLUSH_NESTEDTMETOPEXTTSA_L1_NOTSA_SQ_NOTSA_VERW_CLEARTSCRATEMSRTSXLDTRKVAESVMCBCLEANVMPLVMSA_REGPROTVMXVPCLMULQDQVTEWAITPKGWBNOINVDWRMSRNSX87XGETBV1XOPXSAVEXSAVECXSAVEOPTXSAVESAESARMARMCPUIDASIMDASIMDDPASIMDHPASIMDRDMATOMICSCRC32DCPOPEVTSTRMFCMAFHMFPFPHPGPAJSCVTLRCPCPMULLRNDRTLBTSSHA1SHA2SHA3SHA512SM3SM4SVESVE2SBSSBSBTIFLAGM2FRINTTSDCPODPBF16I8MMWFXTMOPSHBCCSSCPMU_FIXEDCOUNTER_CYCLESPMU_FIXEDCOUNTER_REFCYCLESPMU_FIXEDCOUNTER_INSTRUCTIONSPMU_FIXEDCOUNTER_TOPDOWN_SLOTSRV_IMARV_CRV_FRV_DRV_VRV_ZBARV_ZBBRV_ZBCRV_ZBSRV_ZICONDRV_ZIHINTPAUSERV_ZICBOMRV_ZICBOZRV_ZICBOPRV_ZFARV_ZFHRV_ZFHMINRV_ZTSORV_ZACASRV_ZBKBRV_ZBKCRV_ZBKXRV_ZKNDRV_ZKNERV_ZKNHRV_ZKSEDRV_ZKSHRV_ZKTRV_ZKNRV_ZKSRV_ZVBBRV_ZVBCRV_ZVKBRV_ZVKGRV_ZVKNEDRV_ZVKNHARV_ZVKNHBRV_ZVKSEDRV_ZVKSHRV_ZVKTRV_ZVKNGRV_ZVKSGlastID" -var _FeatureID_index = [...]uint16{0, 7, 10, 15, 23, 34, 41, 48, 55, 61, 68, 75, 85, 97, 102, 105, 110, 119, 128, 137, 141, 151, 163, 171, 179, 187, 195, 202, 212, 222, 230, 240, 251, 259, 269, 287, 302, 309, 321, 328, 335, 346, 358, 366, 370, 374, 380, 385, 393, 398, 404, 408, 417, 435, 443, 450, 454, 458, 472, 478, 482, 486, 495, 499, 503, 508, 513, 517, 521, 528, 532, 535, 541, 544, 547, 557, 567, 580, 593, 597, 608, 612, 626, 643, 646, 656, 667, 673, 681, 692, 700, 712, 728, 742, 753, 763, 778, 786, 797, 807, 814, 823, 833, 837, 840, 847, 852, 863, 870, 877, 885, 888, 894, 899, 908, 915, 923, 927, 930, 936, 943, 956, 961, 963, 970, 977, 983, 987, 996, 1000, 1005, 1011, 1017, 1023, 1033, 1036, 1052, 1056, 1065, 1068, 1077, 1092, 1105, 1111, 1125, 1132, 1135, 1140, 1143, 1146, 1158, 1165, 1172, 1186, 1196, 1208, 1215, 1234, 1237, 1241, 1245, 1249, 1254, 1259, 1264, 1269, 1283, 1294, 1300, 1303, 1308, 1317, 1321, 1326, 1331, 1337, 1344, 1349, 1352, 1361, 1377, 1380, 1386, 1396, 1404, 1408, 1417, 1421, 1433, 1436, 1446, 1449, 1456, 1464, 1471, 1474, 1481, 1484, 1489, 1495, 1503, 1509, 1515, 1523, 1528, 1535, 1542, 1550, 1557, 1562, 1567, 1574, 1578, 1581, 1583, 1587, 1590, 1595, 1600, 1605, 1609, 1612, 1614, 1618, 1622, 1626, 1632, 1635, 1638, 1641, 1647} +var _FeatureID_index = [...]uint16{0, 7, 10, 15, 23, 34, 41, 48, 55, 61, 68, 75, 85, 97, 102, 105, 110, 119, 128, 137, 141, 151, 163, 172, 180, 188, 196, 204, 211, 221, 231, 239, 249, 260, 268, 278, 296, 311, 318, 330, 337, 344, 355, 367, 375, 379, 383, 389, 394, 402, 407, 413, 417, 426, 444, 452, 459, 463, 467, 481, 487, 491, 495, 504, 508, 512, 517, 522, 526, 530, 534, 541, 545, 548, 554, 557, 560, 570, 580, 593, 606, 610, 621, 625, 639, 656, 659, 669, 680, 686, 694, 705, 713, 725, 741, 755, 766, 776, 791, 799, 810, 820, 827, 836, 846, 850, 853, 860, 865, 876, 883, 890, 898, 901, 907, 912, 921, 928, 936, 940, 943, 949, 956, 969, 974, 976, 983, 990, 996, 1000, 1009, 1013, 1018, 1024, 1030, 1036, 1046, 1049, 1065, 1069, 1078, 1081, 1090, 1105, 1118, 1124, 1138, 1145, 1148, 1153, 1159, 1162, 1165, 1177, 1184, 1191, 1205, 1215, 1227, 1234, 1253, 1256, 1260, 1264, 1268, 1273, 1278, 1283, 1288, 1302, 1313, 1319, 1322, 1327, 1336, 1340, 1345, 1350, 1356, 1363, 1368, 1371, 1380, 1396, 1399, 1405, 1414, 1423, 1437, 1447, 1455, 1459, 1468, 1472, 1484, 1487, 1497, 1500, 1507, 1515, 1522, 1525, 1532, 1535, 1540, 1546, 1554, 1560, 1566, 1574, 1579, 1586, 1593, 1601, 1608, 1613, 1618, 1625, 1629, 1632, 1634, 1638, 1641, 1646, 1651, 1656, 1660, 1663, 1665, 1669, 1673, 1677, 1683, 1686, 1689, 1692, 1696, 1698, 1702, 1705, 1711, 1718, 1724, 1728, 1732, 1736, 1740, 1743, 1747, 1770, 1796, 1825, 1855, 1861, 1865, 1869, 1873, 1877, 1883, 1889, 1895, 1901, 1910, 1924, 1933, 1942, 1951, 1957, 1963, 1972, 1979, 1987, 1994, 2001, 2008, 2015, 2022, 2029, 2037, 2044, 2050, 2056, 2062, 2069, 2076, 2083, 2090, 2099, 2108, 2117, 2126, 2134, 2141, 2149, 2157, 2163} func (i FeatureID) String() string { - if i < 0 || i >= FeatureID(len(_FeatureID_index)-1) { + idx := int(i) - 0 + if i < 0 || idx >= len(_FeatureID_index)-1 { return "FeatureID(" + strconv.FormatInt(int64(i), 10) + ")" } - return _FeatureID_name[_FeatureID_index[i]:_FeatureID_index[i+1]] + return _FeatureID_name[_FeatureID_index[idx]:_FeatureID_index[idx+1]] } func _() { // An "invalid array index" compiler error signifies that the constant values have changed. @@ -285,16 +351,22 @@ func _() { _ = x[ACRN-28] _ = x[SRE-29] _ = x[Apple-30] - _ = x[lastVendor-31] + _ = x[SiFive-31] + _ = x[StarFive-32] + _ = x[THead-33] + _ = x[Andes-34] + _ = x[SpacemiT-35] + _ = x[lastVendor-36] } -const _Vendor_name = "VendorUnknownIntelAMDVIATransmetaNSCKVMMSVMVMwareXenHVMBhyveHygonSiSRDCAmpereARMBroadcomCaviumDECFujitsuInfineonMotorolaNVIDIAAMCCQualcommMarvellQEMUQNXACRNSREApplelastVendor" +const _Vendor_name = "VendorUnknownIntelAMDVIATransmetaNSCKVMMSVMVMwareXenHVMBhyveHygonSiSRDCAmpereARMBroadcomCaviumDECFujitsuInfineonMotorolaNVIDIAAMCCQualcommMarvellQEMUQNXACRNSREAppleSiFiveStarFiveTHeadAndesSpacemiTlastVendor" -var _Vendor_index = [...]uint8{0, 13, 18, 21, 24, 33, 36, 39, 43, 49, 55, 60, 65, 68, 71, 77, 80, 88, 94, 97, 104, 112, 120, 126, 130, 138, 145, 149, 152, 156, 159, 164, 174} +var _Vendor_index = [...]uint8{0, 13, 18, 21, 24, 33, 36, 39, 43, 49, 55, 60, 65, 68, 71, 77, 80, 88, 94, 97, 104, 112, 120, 126, 130, 138, 145, 149, 152, 156, 159, 164, 170, 178, 183, 188, 196, 206} func (i Vendor) String() string { - if i < 0 || i >= Vendor(len(_Vendor_index)-1) { + idx := int(i) - 0 + if i < 0 || idx >= len(_Vendor_index)-1 { return "Vendor(" + strconv.FormatInt(int64(i), 10) + ")" } - return _Vendor_name[_Vendor_index[i]:_Vendor_index[i+1]] + return _Vendor_name[_Vendor_index[idx]:_Vendor_index[idx+1]] } diff --git a/vendor/github.com/klauspost/cpuid/v2/os_darwin_arm64.go b/vendor/github.com/klauspost/cpuid/v2/os_darwin_arm64.go index da07522e7cb..addbfc67b8e 100644 --- a/vendor/github.com/klauspost/cpuid/v2/os_darwin_arm64.go +++ b/vendor/github.com/klauspost/cpuid/v2/os_darwin_arm64.go @@ -126,4 +126,17 @@ func tryToFillCPUInfoFomSysctl(c *CPUInfo) { setFeature(c, SM3, "hw.optional.arm.FEAT_SM3") // SM3 instructions setFeature(c, SM4, "hw.optional.arm.FEAT_SM4") // SM4 instructions setFeature(c, SVE, "hw.optional.arm.FEAT_SVE") // Scalable Vector Extension + setFeature(c, SVE2, "hw.optional.arm.FEAT_SVE2") // Scalable Vector Extension 2 + setFeature(c, SB, "hw.optional.arm.FEAT_SB") // Speculation barrier + setFeature(c, SSBS, "hw.optional.arm.FEAT_SSBS") // Speculative Store Bypass Safe + setFeature(c, BTI, "hw.optional.arm.FEAT_BTI") // Branch Target Identification + setFeature(c, FLAGM2, "hw.optional.arm.FEAT_FlagM2") // Condition flag manipulation version 2 + setFeature(c, FRINTTS, "hw.optional.arm.FEAT_FRINTTS") // Floating-point to integer rounding + setFeature(c, DCPODP, "hw.optional.arm.FEAT_DPB2") // Data cache clean to Point of Deep Persistence + setFeature(c, BF16, "hw.optional.arm.FEAT_BF16") // BFloat16 instructions + setFeature(c, I8MM, "hw.optional.arm.FEAT_I8MM") // Int8 matrix multiplication + setFeature(c, WFXT, "hw.optional.arm.FEAT_WFxT") // WFE/WFI with timeout + setFeature(c, MOPS, "hw.optional.arm.FEAT_MOPS") // Memory copy and set instructions + setFeature(c, HBC, "hw.optional.arm.FEAT_HBC") // Hinted conditional branches + setFeature(c, CSSC, "hw.optional.arm.FEAT_CSSC") // Common short sequence compression } diff --git a/vendor/github.com/klauspost/cpuid/v2/os_linux_arm64.go b/vendor/github.com/klauspost/cpuid/v2/os_linux_arm64.go index d96d24438b3..ea9da404c67 100644 --- a/vendor/github.com/klauspost/cpuid/v2/os_linux_arm64.go +++ b/vendor/github.com/klauspost/cpuid/v2/os_linux_arm64.go @@ -115,15 +115,19 @@ const ( hwcap2_POE = 1 << 63 ) +// hwcap2 holds AT_HWCAP2. Unlike hwcap, the arm64 runtime does not expose it +// through internal/cpu, so detectOS reads it from the auxiliary vector. +var hwcap2 uint + func detectOS(c *CPUInfo) bool { // For now assuming no hyperthreading is reasonable. c.LogicalCores = runtime.NumCPU() c.PhysicalCores = c.LogicalCores c.ThreadsPerCore = 1 - if hwcap == 0 { - // We did not get values from the runtime. - // Try reading /proc/self/auxv - + // hwcap is provided by the runtime through the internal/cpu.HWCap linkname, + // but the runtime does not expose HWCAP2 on arm64. Read the auxiliary vector + // directly to obtain hwcap2 (and hwcap when the linkname is unavailable). + if hwcap == 0 || hwcap2 == 0 { // From https://github.com/golang/sys const ( _AT_HWCAP = 16 @@ -132,37 +136,34 @@ func detectOS(c *CPUInfo) bool { uintSize = int(32 << (^uint(0) >> 63)) ) - buf, err := ioutil.ReadFile("/proc/self/auxv") - if err != nil { - // e.g. on android /proc/self/auxv is not accessible, so silently - // ignore the error and leave Initialized = false. On some - // architectures (e.g. arm64) doinit() implements a fallback - // readout and will set Initialized = true again. - return false - } - bo := binary.LittleEndian - for len(buf) >= 2*(uintSize/8) { - var tag, val uint - switch uintSize { - case 32: - tag = uint(bo.Uint32(buf[0:])) - val = uint(bo.Uint32(buf[4:])) - buf = buf[8:] - case 64: - tag = uint(bo.Uint64(buf[0:])) - val = uint(bo.Uint64(buf[8:])) - buf = buf[16:] - } - switch tag { - case _AT_HWCAP: - hwcap = val - case _AT_HWCAP2: - // Not used + // e.g. on android /proc/self/auxv is not accessible, so silently ignore + // the error and fall back to whatever the runtime provided. + if buf, err := ioutil.ReadFile("/proc/self/auxv"); err == nil { + bo := binary.LittleEndian + for len(buf) >= 2*(uintSize/8) { + var tag, val uint + switch uintSize { + case 32: + tag = uint(bo.Uint32(buf[0:])) + val = uint(bo.Uint32(buf[4:])) + buf = buf[8:] + case 64: + tag = uint(bo.Uint64(buf[0:])) + val = uint(bo.Uint64(buf[8:])) + buf = buf[16:] + } + switch tag { + case _AT_HWCAP: + hwcap = val + case _AT_HWCAP2: + hwcap2 = val + } } } - if hwcap == 0 { - return false - } + } + if hwcap == 0 { + // Nothing detected, e.g. on android or a restricted environment. + return false } // HWCap was populated by the runtime from the auxiliary vector. @@ -184,9 +185,9 @@ func detectOS(c *CPUInfo) bool { c.featureSet.setIf(isSet(hwcap, hwcap_JSCVT), JSCVT) c.featureSet.setIf(isSet(hwcap, hwcap_LRCPC), LRCPC) c.featureSet.setIf(isSet(hwcap, hwcap_PMULL), PMULL) - c.featureSet.setIf(isSet(hwcap, hwcap2_RNG), RNDR) - // c.featureSet.setIf(isSet(hwcap, hwcap_), TLB) - // c.featureSet.setIf(isSet(hwcap, hwcap_), TS) + c.featureSet.setIf(isSet(hwcap2, hwcap2_RNG), RNDR) + // TLB (FEAT_TLBIOS/TLBIRANGE) has no HWCAP bit; only detectable via ID registers. + c.featureSet.setIf(isSet(hwcap, hwcap_FLAGM), TS) c.featureSet.setIf(isSet(hwcap, hwcap_SHA1), SHA1) c.featureSet.setIf(isSet(hwcap, hwcap_SHA2), SHA2) c.featureSet.setIf(isSet(hwcap, hwcap_SHA3), SHA3) @@ -194,6 +195,21 @@ func detectOS(c *CPUInfo) bool { c.featureSet.setIf(isSet(hwcap, hwcap_SM3), SM3) c.featureSet.setIf(isSet(hwcap, hwcap_SM4), SM4) c.featureSet.setIf(isSet(hwcap, hwcap_SVE), SVE) + c.featureSet.setIf(isSet(hwcap, hwcap_SB), SB) + c.featureSet.setIf(isSet(hwcap, hwcap_SSBS), SSBS) + + // Features reported through the second hardware capability word (HWCAP2). + c.featureSet.setIf(isSet(hwcap2, hwcap2_SVE2), SVE2) + c.featureSet.setIf(isSet(hwcap2, hwcap2_BTI), BTI) + c.featureSet.setIf(isSet(hwcap2, hwcap2_FLAGM2), FLAGM2) + c.featureSet.setIf(isSet(hwcap2, hwcap2_FRINT), FRINTTS) + c.featureSet.setIf(isSet(hwcap2, hwcap2_DCPODP), DCPODP) + c.featureSet.setIf(isSet(hwcap2, hwcap2_BF16), BF16) + c.featureSet.setIf(isSet(hwcap2, hwcap2_I8MM), I8MM) + c.featureSet.setIf(isSet(hwcap2, hwcap2_WFXT), WFXT) + c.featureSet.setIf(isSet(hwcap2, hwcap2_MOPS), MOPS) + c.featureSet.setIf(isSet(hwcap2, hwcap2_HBC), HBC) + c.featureSet.setIf(isSet(hwcap2, hwcap2_CSSC), CSSC) // The Samsung S9+ kernel reports support for atomics, but not all cores // actually support them, resulting in SIGILL. See issue #28431. diff --git a/vendor/github.com/klauspost/cpuid/v2/os_linux_riscv64.go b/vendor/github.com/klauspost/cpuid/v2/os_linux_riscv64.go new file mode 100644 index 00000000000..71919a49bd6 --- /dev/null +++ b/vendor/github.com/klauspost/cpuid/v2/os_linux_riscv64.go @@ -0,0 +1,225 @@ +// Copyright (c) 2026 Klaus Post, released under MIT License. See LICENSE file. + +package cpuid + +import ( + "bufio" + "os" + "runtime" + "strconv" + "strings" + "unsafe" + + "golang.org/x/sys/unix" +) + +const __NR_riscv_hwprobe = 258 + +type riscvHWProbePair struct { + key int64 + value uint64 +} + +// Keys from linux/include/uapi/asm/hwprobe.h +const ( + riscv_hwprobe_key_mvendorid = 0 + riscv_hwprobe_key_marchid = 1 + riscv_hwprobe_key_mimpid = 2 + riscv_hwprobe_key_base_behavior = 3 + riscv_hwprobe_key_ima_ext_0 = 4 + riscv_hwprobe_key_cpuperf_0 = 5 + riscv_hwprobe_key_zicbom_block_size = 12 +) + +// Bits from linux/arch/riscv/include/uapi/asm/hwprobe.h +const ( + riscv_hwprobe_ima_fd = 1 << 0 + riscv_hwprobe_ima_c = 1 << 1 + riscv_hwprobe_ima_v = 1 << 2 + riscv_hwprobe_ext_zba = 1 << 3 + riscv_hwprobe_ext_zbb = 1 << 4 + riscv_hwprobe_ext_zbs = 1 << 5 + riscv_hwprobe_ext_zicboz = 1 << 6 + riscv_hwprobe_ext_zbc = 1 << 7 + riscv_hwprobe_ext_zbkb = 1 << 8 + riscv_hwprobe_ext_zbkc = 1 << 9 + riscv_hwprobe_ext_zbkx = 1 << 10 + riscv_hwprobe_ext_zknd = 1 << 11 + riscv_hwprobe_ext_zkne = 1 << 12 + riscv_hwprobe_ext_zknh = 1 << 13 + riscv_hwprobe_ext_zksed = 1 << 14 + riscv_hwprobe_ext_zksh = 1 << 15 + riscv_hwprobe_ext_zkt = 1 << 16 + riscv_hwprobe_ext_zvbb = 1 << 17 + riscv_hwprobe_ext_zvbc = 1 << 18 + riscv_hwprobe_ext_zvkb = 1 << 19 + riscv_hwprobe_ext_zvkg = 1 << 20 + riscv_hwprobe_ext_zvkned = 1 << 21 + riscv_hwprobe_ext_zvknha = 1 << 22 + riscv_hwprobe_ext_zvknhb = 1 << 23 + riscv_hwprobe_ext_zvksed = 1 << 24 + riscv_hwprobe_ext_zvksh = 1 << 25 + riscv_hwprobe_ext_zvkt = 1 << 26 + riscv_hwprobe_ext_zfh = 1 << 27 + riscv_hwprobe_ext_zfhmin = 1 << 28 + riscv_hwprobe_ext_zihintntl = 1 << 29 + riscv_hwprobe_ext_zvfh = 1 << 30 + riscv_hwprobe_ext_zvfhmin = 1 << 31 + riscv_hwprobe_ext_zfa = 1 << 32 + riscv_hwprobe_ext_ztso = 1 << 33 + riscv_hwprobe_ext_zacas = 1 << 34 + riscv_hwprobe_ext_zicond = 1 << 35 + riscv_hwprobe_ext_zihintpause = 1 << 36 + riscv_hwprobe_ext_zicbom = 1 << 55 + riscv_hwprobe_ext_zicbop = 1 << 60 +) + +func riscvHWProbe(pairs []riscvHWProbePair) int64 { + if len(pairs) == 0 { + return -1 + } + ret, _, _ := unix.Syscall6(__NR_riscv_hwprobe, + uintptr(unsafe.Pointer(&pairs[0])), + uintptr(len(pairs)), + 0, 0, 0, 0) + return int64(ret) +} + +func detectOS(c *CPUInfo) bool { + c.LogicalCores = runtime.NumCPU() + c.PhysicalCores = c.LogicalCores + c.ThreadsPerCore = 1 + + pairs := []riscvHWProbePair{ + {key: riscv_hwprobe_key_mvendorid}, + {key: riscv_hwprobe_key_marchid}, + {key: riscv_hwprobe_key_mimpid}, + {key: riscv_hwprobe_key_ima_ext_0}, + {key: riscv_hwprobe_key_zicbom_block_size}, + } + ret := riscvHWProbe(pairs) + if ret == 0 && pairs[3].value != ^uint64(0) { + detectFromHWProbe(c, pairs) + if pairs[4].value != ^uint64(0) && pairs[4].value > 0 { + c.CacheLine = int(pairs[4].value) + } + return true + } + + c.CacheLine = detectCacheLine() + return detectFromCPUInfo(c) +} + +func detectFromHWProbe(c *CPUInfo, pairs []riscvHWProbePair) { + if pairs[0].value != ^uint64(0) { + c.VendorID = riscvVendorID(pairs[0].value) + c.VendorString = c.VendorID.String() + } + if pairs[1].value != ^uint64(0) { + c.Model = int(pairs[1].value) + } + if pairs[2].value != ^uint64(0) { + c.Family = int(pairs[2].value) + } + + imaExt := pairs[3].value + + if imaExt&riscv_hwprobe_ima_fd != 0 { + c.featureSet.set(RV_D) + c.featureSet.set(RV_F) + } + c.featureSet.setIf(imaExt&riscv_hwprobe_ima_c != 0, RV_C) + c.featureSet.setIf(imaExt&riscv_hwprobe_ima_v != 0, RV_V) + + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zba != 0, RV_ZBA) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zbb != 0, RV_ZBB) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zbc != 0, RV_ZBC) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zbs != 0, RV_ZBS) + + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zicbom != 0, RV_ZICBOM) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zicboz != 0, RV_ZICBOZ) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zicbop != 0, RV_ZICBOP) + + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zicond != 0, RV_ZICOND) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zihintpause != 0, RV_ZIHINTPAUSE) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zfa != 0, RV_ZFA) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zfh != 0, RV_ZFH) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zfhmin != 0, RV_ZFHMIN) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_ztso != 0, RV_ZTSO) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zacas != 0, RV_ZACAS) + + // Scalar cryptography + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zbkb != 0, RV_ZBKB) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zbkc != 0, RV_ZBKC) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zbkx != 0, RV_ZBKX) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zknd != 0, RV_ZKND) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zkne != 0, RV_ZKNE) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zknh != 0, RV_ZKNH) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zksed != 0, RV_ZKSED) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zksh != 0, RV_ZKSH) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zkt != 0, RV_ZKT) + + // Vector cryptography + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvbb != 0, RV_ZVBB) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvbc != 0, RV_ZVBC) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvkb != 0, RV_ZVKB) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvkg != 0, RV_ZVKG) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvkned != 0, RV_ZVKNED) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvknha != 0, RV_ZVKNHA) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvknhb != 0, RV_ZVKNHB) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvksed != 0, RV_ZVKSED) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvksh != 0, RV_ZVKSH) + c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvkt != 0, RV_ZVKT) + + // Crypto suites (combined from individual features) + c.featureSet.setIf(c.featureSet.hasSetP(rvZKNFeatures), RV_ZKN) + c.featureSet.setIf(c.featureSet.hasSetP(rvZKSFeatures), RV_ZKS) + c.featureSet.setIf(c.featureSet.hasSetP(rvZVKNFeatures), RV_ZVKNG) + c.featureSet.setIf(c.featureSet.hasSetP(rvZVKSFeatures), RV_ZVKSG) + + // Every Linux-capable riscv64 core has I, M, A base. + c.featureSet.set(RV_IMA) +} + +func detectFromCPUInfo(c *CPUInfo) bool { + f, err := os.Open("/proc/cpuinfo") + if err != nil { + return false + } + defer f.Close() + + scanner := bufio.NewScanner(f) + for scanner.Scan() { + line := scanner.Text() + fields := strings.SplitN(line, ":", 2) + if len(fields) < 2 { + continue + } + key := strings.TrimSpace(fields[0]) + value := strings.TrimSpace(fields[1]) + + switch key { + case "isa": + parseISAString(c, value) + case "mvendorid": + if vid, err := strconv.ParseUint(value, 0, 64); err == nil { + c.VendorID = riscvVendorID(vid) + c.VendorString = c.VendorID.String() + } + case "uarch": + c.BrandName = value + } + } + return scanner.Err() == nil +} + +func detectCacheLine() int { + data, err := os.ReadFile("/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size") + if err != nil { + return 0 + } + if n, err := strconv.Atoi(strings.TrimSpace(string(data))); err == nil && n > 0 { + return n + } + return 0 +} diff --git a/vendor/github.com/klauspost/cpuid/v2/os_other_arm64.go b/vendor/github.com/klauspost/cpuid/v2/os_other_arm64.go index 8733ba34363..debc123922e 100644 --- a/vendor/github.com/klauspost/cpuid/v2/os_other_arm64.go +++ b/vendor/github.com/klauspost/cpuid/v2/os_other_arm64.go @@ -1,7 +1,6 @@ // Copyright (c) 2020 Klaus Post, released under MIT License. See LICENSE file. //go:build arm64 && !linux && !darwin -// +build arm64,!linux,!darwin package cpuid diff --git a/vendor/github.com/klauspost/cpuid/v2/os_other_riscv64.go b/vendor/github.com/klauspost/cpuid/v2/os_other_riscv64.go new file mode 100644 index 00000000000..fd86f7d0562 --- /dev/null +++ b/vendor/github.com/klauspost/cpuid/v2/os_other_riscv64.go @@ -0,0 +1,14 @@ +// Copyright (c) 2026 Klaus Post, released under MIT License. See LICENSE file. + +//go:build riscv64 && !linux + +package cpuid + +import "runtime" + +func detectOS(c *CPUInfo) bool { + c.PhysicalCores = runtime.NumCPU() + c.ThreadsPerCore = 1 + c.LogicalCores = c.PhysicalCores + return false +} diff --git a/vendor/github.com/klauspost/cpuid/v2/os_safe_linux_arm64.go b/vendor/github.com/klauspost/cpuid/v2/os_safe_linux_arm64.go index f8f201b5f7b..5b4e8a1b3e0 100644 --- a/vendor/github.com/klauspost/cpuid/v2/os_safe_linux_arm64.go +++ b/vendor/github.com/klauspost/cpuid/v2/os_safe_linux_arm64.go @@ -1,7 +1,6 @@ // Copyright (c) 2021 Klaus Post, released under MIT License. See LICENSE file. //go:build nounsafe -// +build nounsafe package cpuid diff --git a/vendor/github.com/klauspost/cpuid/v2/os_unsafe_linux_arm64.go b/vendor/github.com/klauspost/cpuid/v2/os_unsafe_linux_arm64.go index 92af622eb8c..00158c21c39 100644 --- a/vendor/github.com/klauspost/cpuid/v2/os_unsafe_linux_arm64.go +++ b/vendor/github.com/klauspost/cpuid/v2/os_unsafe_linux_arm64.go @@ -1,7 +1,6 @@ // Copyright (c) 2021 Klaus Post, released under MIT License. See LICENSE file. //go:build !nounsafe -// +build !nounsafe package cpuid diff --git a/vendor/github.com/klauspost/cpuid/v2/riscv_isa.go b/vendor/github.com/klauspost/cpuid/v2/riscv_isa.go new file mode 100644 index 00000000000..5a87679bdbd --- /dev/null +++ b/vendor/github.com/klauspost/cpuid/v2/riscv_isa.go @@ -0,0 +1,93 @@ +// Copyright (c) 2026 Klaus Post, released under MIT License. See LICENSE file. + +package cpuid + +import "strings" + +func parseISAString(c *CPUInfo, isa string) { + isa = strings.ToLower(isa) + extMap := make(map[string]bool) + for ext := range strings.SplitSeq(isa, "_") { + ext = strings.TrimSpace(ext) + if strings.HasPrefix(ext, "rv64") { + extMap["i"] = true + for _, ch := range ext[4:] { + extMap[string(ch)] = true + } + } else if ext != "" { + extMap[ext] = true + } + } + + if extMap["g"] { + extMap["i"] = true + extMap["m"] = true + extMap["a"] = true + extMap["f"] = true + extMap["d"] = true + } + + c.featureSet.setIf(extMap["i"] && extMap["m"] && extMap["a"], RV_IMA) + c.featureSet.setIf(extMap["c"], RV_C) + c.featureSet.setIf(extMap["f"], RV_F) + c.featureSet.setIf(extMap["d"], RV_D) + c.featureSet.setIf(extMap["v"], RV_V) + c.featureSet.setIf(extMap["zihintpause"], RV_ZIHINTPAUSE) + c.featureSet.setIf(extMap["zba"], RV_ZBA) + c.featureSet.setIf(extMap["zbb"], RV_ZBB) + c.featureSet.setIf(extMap["zbc"], RV_ZBC) + c.featureSet.setIf(extMap["zbs"], RV_ZBS) + c.featureSet.setIf(extMap["zicond"], RV_ZICOND) + c.featureSet.setIf(extMap["zicbom"], RV_ZICBOM) + c.featureSet.setIf(extMap["zicboz"], RV_ZICBOZ) + c.featureSet.setIf(extMap["zicbop"], RV_ZICBOP) + c.featureSet.setIf(extMap["zfa"], RV_ZFA) + c.featureSet.setIf(extMap["zfh"], RV_ZFH) + c.featureSet.setIf(extMap["zfhmin"], RV_ZFHMIN) + c.featureSet.setIf(extMap["ztso"], RV_ZTSO) + c.featureSet.setIf(extMap["zacas"], RV_ZACAS) + + // Scalar cryptography + c.featureSet.setIf(extMap["zbkb"], RV_ZBKB) + c.featureSet.setIf(extMap["zbkc"], RV_ZBKC) + c.featureSet.setIf(extMap["zbkx"], RV_ZBKX) + c.featureSet.setIf(extMap["zknd"], RV_ZKND) + c.featureSet.setIf(extMap["zkne"], RV_ZKNE) + c.featureSet.setIf(extMap["zknh"], RV_ZKNH) + c.featureSet.setIf(extMap["zksed"], RV_ZKSED) + c.featureSet.setIf(extMap["zksh"], RV_ZKSH) + c.featureSet.setIf(extMap["zkt"], RV_ZKT) + + // Vector cryptography + c.featureSet.setIf(extMap["zvbb"], RV_ZVBB) + c.featureSet.setIf(extMap["zvbc"], RV_ZVBC) + c.featureSet.setIf(extMap["zvkb"], RV_ZVKB) + c.featureSet.setIf(extMap["zvkg"], RV_ZVKG) + c.featureSet.setIf(extMap["zvkned"], RV_ZVKNED) + c.featureSet.setIf(extMap["zvknha"], RV_ZVKNHA) + c.featureSet.setIf(extMap["zvknhb"], RV_ZVKNHB) + c.featureSet.setIf(extMap["zvksed"], RV_ZVKSED) + c.featureSet.setIf(extMap["zvksh"], RV_ZVKSH) + c.featureSet.setIf(extMap["zvkt"], RV_ZVKT) + + // Crypto suites (combined from individual features or bundle tokens) + c.featureSet.setIf(extMap["zkn"] || c.featureSet.hasSetP(rvZKNFeatures), RV_ZKN) + c.featureSet.setIf(extMap["zks"] || c.featureSet.hasSetP(rvZKSFeatures), RV_ZKS) + c.featureSet.setIf(extMap["zvkng"] || c.featureSet.hasSetP(rvZVKNFeatures), RV_ZVKNG) + c.featureSet.setIf(extMap["zvksg"] || c.featureSet.hasSetP(rvZVKSFeatures), RV_ZVKSG) +} + +var riscvVendorMap = map[uint64]Vendor{ + 0x489: SiFive, + 0x5b7: StarFive, + 0x5b1: THead, + 0x31e: Andes, + 0x710: SpacemiT, +} + +func riscvVendorID(mvendorid uint64) Vendor { + if v, ok := riscvVendorMap[mvendorid]; ok { + return v + } + return VendorUnknown +} diff --git a/vendor/github.com/mattn/go-colorable/colorable_windows.go b/vendor/github.com/mattn/go-colorable/colorable_windows.go index 2df7b8598a1..426a409ca41 100644 --- a/vendor/github.com/mattn/go-colorable/colorable_windows.go +++ b/vendor/github.com/mattn/go-colorable/colorable_windows.go @@ -5,13 +5,13 @@ package colorable import ( "bytes" + syscall "golang.org/x/sys/windows" "io" "math" "os" "strconv" "strings" "sync" - syscall "golang.org/x/sys/windows" "unsafe" "github.com/mattn/go-isatty" @@ -93,6 +93,7 @@ type writer struct { handle syscall.Handle althandle syscall.Handle oldattr word + curattr word oldpos coord rest bytes.Buffer mutex sync.Mutex @@ -112,7 +113,7 @@ func NewColorable(file *os.File) io.Writer { var csbi consoleScreenBufferInfo handle := syscall.Handle(file.Fd()) procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) - return &writer{out: file, handle: handle, oldattr: csbi.attributes, oldpos: coord{0, 0}} + return &writer{out: file, handle: handle, oldattr: csbi.attributes, curattr: csbi.attributes, oldpos: coord{0, 0}} } return file } @@ -438,7 +439,11 @@ func (w *writer) Write(data []byte) (n int, err error) { w.mutex.Lock() defer w.mutex.Unlock() var csbi consoleScreenBufferInfo - procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi))) + + if w.rest.Len() == 0 && bytes.IndexByte(data, 0x1b) == -1 { + w.out.Write(data) + return len(data), nil + } handle := w.handle @@ -517,7 +522,7 @@ loop: w.rest.Reset() break } - buf.Write([]byte(string(c))) + buf.WriteByte(c) } if m == 0 { break loop @@ -678,11 +683,11 @@ loop: procFillConsoleOutputCharacter.Call(uintptr(handle), uintptr(' '), uintptr(n), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) procFillConsoleOutputAttribute.Call(uintptr(handle), uintptr(csbi.attributes), uintptr(n), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) case 'm': - procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) - attr := csbi.attributes + attr := w.curattr cs := buf.String() if cs == "" { procSetConsoleTextAttribute.Call(uintptr(handle), uintptr(w.oldattr)) + w.curattr = w.oldattr continue } token := strings.Split(cs, ";") @@ -814,9 +819,12 @@ loop: attr |= backgroundBlue } } - procSetConsoleTextAttribute.Call(uintptr(handle), uintptr(attr)) } } + if attr != w.curattr { + procSetConsoleTextAttribute.Call(uintptr(handle), uintptr(attr)) + w.curattr = attr + } case 'h': var ci consoleCursorInfo cs := buf.String() @@ -834,6 +842,8 @@ loop: w.althandle = syscall.Handle(h) if w.althandle != 0 { handle = w.althandle + procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) + w.curattr = csbi.attributes } } } @@ -853,6 +863,8 @@ loop: syscall.CloseHandle(w.althandle) w.althandle = 0 handle = w.handle + procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) + w.curattr = csbi.attributes } } case 's': diff --git a/vendor/github.com/mattn/go-isatty/isatty_others.go b/vendor/github.com/mattn/go-isatty/isatty_others.go index 7402e0618aa..b24a2fadc9c 100644 --- a/vendor/github.com/mattn/go-isatty/isatty_others.go +++ b/vendor/github.com/mattn/go-isatty/isatty_others.go @@ -1,5 +1,5 @@ -//go:build (appengine || js || nacl || tinygo || wasm) && !windows -// +build appengine js nacl tinygo wasm +//go:build (appengine || js || nacl || tinygo || wasm || wasip1 || wasip2) && !windows +// +build appengine js nacl tinygo wasm wasip1 wasip2 // +build !windows package isatty diff --git a/vendor/github.com/mattn/go-isatty/isatty_windows.go b/vendor/github.com/mattn/go-isatty/isatty_windows.go index 8e3c99171bf..5f29c11dd25 100644 --- a/vendor/github.com/mattn/go-isatty/isatty_windows.go +++ b/vendor/github.com/mattn/go-isatty/isatty_windows.go @@ -31,6 +31,10 @@ func init() { if procGetFileInformationByHandleEx.Find() != nil { procGetFileInformationByHandleEx = nil } + // Check if NtQueryObject is available. + if procNtQueryObject.Find() != nil { + procNtQueryObject = nil + } } // IsTerminal return true if the file descriptor is terminal. @@ -43,6 +47,7 @@ func IsTerminal(fd uintptr) bool { // Check pipe name is used for cygwin/msys2 pty. // Cygwin/MSYS2 PTY has a name like: // \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master +// On Windows 7 a trailing suffix (e.g. "-nat") may be appended. func isCygwinPipeName(name string) bool { token := strings.Split(name, "-") if len(token) < 5 { @@ -72,13 +77,19 @@ func isCygwinPipeName(name string) bool { return false } + for _, t := range token[5:] { + if t == "" { + return false + } + } + return true } -// getFileNameByHandle use the undocomented ntdll NtQueryObject to get file full name from file handler +// getFileNameByHandle use the undocumented ntdll NtQueryObject to get file full name from file handler // since GetFileInformationByHandleEx is not available under windows Vista and still some old fashion // guys are using Windows XP, this is a workaround for those guys, it will also work on system from -// Windows vista to 10 +// Windows Vista to 10 // see https://stackoverflow.com/a/18792477 for details func getFileNameByHandle(fd uintptr) (string, error) { if procNtQueryObject == nil { diff --git a/vendor/github.com/miekg/dns/README.md b/vendor/github.com/miekg/dns/README.md index 2a7d8c265bf..8dc2472360b 100644 --- a/vendor/github.com/miekg/dns/README.md +++ b/vendor/github.com/miekg/dns/README.md @@ -6,7 +6,12 @@ DNS version 2 is now available at , check it out if you want to help shape the next 15 years of the Go DNS package. -The version here will see no new features and less and less development. +The version here will see no new features and less and less development, and my time (if any) will be fully +devoted towards v2. + +**December 2025**: v2 should be (already) a good replacement, the coming months would be a good time to +migrate, see [this file describing the +differences](https://codeberg.org/miekg/dns/src/branch/main/README-diff-with-v1.md), to help you get started. # Alternative (more granular) approach to a DNS library @@ -62,7 +67,7 @@ A not-so-up-to-date-list-that-may-be-actually-current: - https://www.dnsperf.com/ - https://dnssectest.net/ - https://github.com/oif/apex -- https://github.com/jedisct1/dnscrypt-proxy +- https://github.com/jedisct1/dnscrypt-proxy (migrated to v2) - https://github.com/jedisct1/rpdns - https://github.com/xor-gate/sshfp - https://github.com/rs/dnstrace diff --git a/vendor/github.com/miekg/dns/client.go b/vendor/github.com/miekg/dns/client.go index 9549fa9232b..a0f96187b41 100644 --- a/vendor/github.com/miekg/dns/client.go +++ b/vendor/github.com/miekg/dns/client.go @@ -57,8 +57,8 @@ type Client struct { // Client.Dialer) or context.Context.Deadline (see ExchangeContext) Timeout time.Duration DialTimeout time.Duration // net.DialTimeout, defaults to 2 seconds, or net.Dialer.Timeout if expiring earlier - overridden by Timeout when that value is non-zero - ReadTimeout time.Duration // net.Conn.SetReadTimeout value for connections, defaults to 2 seconds - overridden by Timeout when that value is non-zero - WriteTimeout time.Duration // net.Conn.SetWriteTimeout value for connections, defaults to 2 seconds - overridden by Timeout when that value is non-zero + ReadTimeout time.Duration // net.Conn.SetReadDeadline value for connections, defaults to 2 seconds - overridden by Timeout when that value is non-zero + WriteTimeout time.Duration // net.Conn.SetWriteDeadline value for connections, defaults to 2 seconds - overridden by Timeout when that value is non-zero TsigSecret map[string]string // secret(s) for Tsig map[], zonename must be in canonical form (lowercase, fqdn, see RFC 4034 Section 6.2) TsigProvider TsigProvider // An implementation of the TsigProvider interface. If defined it replaces TsigSecret and is used for all TSIG operations. @@ -92,6 +92,9 @@ func (c *Client) dialTimeout() time.Duration { } func (c *Client) readTimeout() time.Duration { + if c.Timeout != 0 { + return c.Timeout + } if c.ReadTimeout != 0 { return c.ReadTimeout } @@ -99,6 +102,9 @@ func (c *Client) readTimeout() time.Duration { } func (c *Client) writeTimeout() time.Duration { + if c.Timeout != 0 { + return c.Timeout + } if c.WriteTimeout != 0 { return c.WriteTimeout } diff --git a/vendor/github.com/miekg/dns/msg.go b/vendor/github.com/miekg/dns/msg.go index edf18596199..382a8083875 100644 --- a/vendor/github.com/miekg/dns/msg.go +++ b/vendor/github.com/miekg/dns/msg.go @@ -338,11 +338,13 @@ loop: return off + 2, nil } + // Trailing root label if off < len(msg) { msg[off] = 0 + return off + 1, nil } - return off + 1, nil + return off, ErrBuf } // isRootLabel returns whether s or bs, from off to end, is the root diff --git a/vendor/github.com/miekg/dns/scan.go b/vendor/github.com/miekg/dns/scan.go index 31957b2ea0d..f7c6525dd0f 100644 --- a/vendor/github.com/miekg/dns/scan.go +++ b/vendor/github.com/miekg/dns/scan.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "io/fs" + "math" "os" "path" "path/filepath" @@ -1231,7 +1232,7 @@ func typeToInt(token string) (uint16, bool) { // stringToTTL parses things like 2w, 2m, etc, and returns the time in seconds. func stringToTTL(token string) (uint32, bool) { - var s, i uint32 + var s, i uint for _, c := range token { switch c { case 's', 'S': @@ -1251,12 +1252,15 @@ func stringToTTL(token string) (uint32, bool) { i = 0 case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': i *= 10 - i += uint32(c) - '0' + i += uint(c) - '0' default: return 0, false } } - return s + i, true + if s+i > math.MaxUint32 { + return 0, false + } + return uint32(s + i), true } // Parse LOC records' [.][mM] into a diff --git a/vendor/github.com/miekg/dns/version.go b/vendor/github.com/miekg/dns/version.go index c53a63d7c8b..33cb83e5ac8 100644 --- a/vendor/github.com/miekg/dns/version.go +++ b/vendor/github.com/miekg/dns/version.go @@ -3,7 +3,7 @@ package dns import "fmt" // Version is current version of this library. -var Version = v{1, 1, 69} +var Version = v{1, 1, 72} // v holds the version of this library. type v struct { diff --git a/vendor/github.com/minio/minio-go/v7/.gitignore b/vendor/github.com/minio/minio-go/v7/.gitignore index 5bb12e74afb..39f4bee7a61 100644 --- a/vendor/github.com/minio/minio-go/v7/.gitignore +++ b/vendor/github.com/minio/minio-go/v7/.gitignore @@ -5,3 +5,4 @@ golangci-lint functional_tests .idea vendor/ +.branch-validate/ diff --git a/vendor/github.com/minio/minio-go/v7/api-bucket-policy.go b/vendor/github.com/minio/minio-go/v7/api-bucket-policy.go index 0e561bdfab2..c4b768cec9f 100644 --- a/vendor/github.com/minio/minio-go/v7/api-bucket-policy.go +++ b/vendor/github.com/minio/minio-go/v7/api-bucket-policy.go @@ -1,6 +1,6 @@ /* * MinIO Go Library for Amazon S3 Compatible Cloud Storage - * Copyright 2020 MinIO, Inc. + * Copyright 2026 MinIO, Inc. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -18,14 +18,44 @@ package minio import ( "context" + "encoding/json" + "fmt" "io" "net/http" "net/url" "strings" + "github.com/minio/minio-go/v7/pkg/policy" "github.com/minio/minio-go/v7/pkg/s3utils" ) +// SetCannedBucketPolicy sets a canned (predefined) access policy on a bucket. +// This is a convenience method that translates predefined access levels +// (readonly, writeonly, readwrite) into the corresponding bucket policy. +// If access is empty or results in no policy statements, the existing bucket policy will be removed. +// +// Parameters: +// - ctx: Context for request cancellation and timeout +// - bucketName: Name of the bucket +// - access: Canned access level (policy.BucketPolicyNone, policy.BucketPolicyReadOnly, policy.BucketPolicyWriteOnly, policy.BucketPolicyReadWrite) +// +// Returns an error if the operation fails. +func (c *Client) SetCannedBucketPolicy(ctx context.Context, bucketName string, bucketPolicy policy.BucketPolicy) error { + if !bucketPolicy.IsValidBucketPolicy() { + return fmt.Errorf("invalid bucket policy %q", bucketPolicy) + } + p := policy.BucketAccessPolicy{Version: "2012-10-17"} + p.Statements = policy.SetPolicy(p.Statements, bucketPolicy, bucketName, "") + if len(p.Statements) == 0 { + return c.SetBucketPolicy(ctx, bucketName, "") + } + policyB, e := json.Marshal(p) + if e != nil { + return e + } + return c.SetBucketPolicy(ctx, bucketName, string(policyB)) +} + // SetBucketPolicy sets the access permissions policy on an existing bucket. // The policy should be a valid JSON string that conforms to the IAM policy format. // If policy is an empty string, the existing bucket policy will be removed. diff --git a/vendor/github.com/minio/minio-go/v7/api-compose-object.go b/vendor/github.com/minio/minio-go/v7/api-compose-object.go index 6d91bed433f..2ea833b731d 100644 --- a/vendor/github.com/minio/minio-go/v7/api-compose-object.go +++ b/vendor/github.com/minio/minio-go/v7/api-compose-object.go @@ -386,6 +386,7 @@ func (c *Client) copyObjectPartDo(ctx context.Context, srcBucket, srcObject, des return p, err } p.PartNumber, p.ETag = partID, cpObjRes.ETag + cpObjRes.setChecksums(&p) return p, nil } @@ -424,6 +425,7 @@ func (c *Client) uploadPartCopy(ctx context.Context, bucket, object, uploadID st return p, err } p.PartNumber, p.ETag = partNumber, cpObjRes.ETag + cpObjRes.setChecksums(&p) return p, nil } @@ -531,6 +533,19 @@ func (c *Client) ComposeObject(ctx context.Context, dst CopyDestOptions, srcs .. userTags = srcObjectInfos[0].UserTags } + // Set the requested checksum algorithm on the multipart upload. + if dst.ChecksumType.IsSet() { + meta := make(map[string]string, len(userMeta)+2) + for k, v := range userMeta { + meta[k] = v + } + meta[amzChecksumAlgo] = dst.ChecksumType.String() + if dst.ChecksumType.FullObjectRequested() { + meta[amzChecksumMode] = ChecksumFullObjectMode.String() + } + userMeta = meta + } + uploadID, err := c.newUploadID(ctx, dst.Bucket, dst.Object, PutObjectOptions{ ServerSideEncryption: dst.Encryption, UserMetadata: userMeta, diff --git a/vendor/github.com/minio/minio-go/v7/api-datatypes.go b/vendor/github.com/minio/minio-go/v7/api-datatypes.go index f359f29a763..2391c6e5a2f 100644 --- a/vendor/github.com/minio/minio-go/v7/api-datatypes.go +++ b/vendor/github.com/minio/minio-go/v7/api-datatypes.go @@ -184,10 +184,30 @@ type ObjectInfo struct { // eg: x-amz-meta-*, content-encoding etc. Metadata http.Header `json:"metadata" xml:"-"` - // x-amz-meta-* headers stripped "x-amz-meta-" prefix containing the first value. + // Headers is the unfiltered set of response headers from the + // HEAD or GET request that produced this ObjectInfo, e.g. + // Content-Range for ranged requests. RFC 2047-encoded + // x-amz-meta-*/x-minio-meta-* values appear MIME-decoded, matching + // Metadata. Set only when the object info is parsed from an HTTP + // object response (StatObject, GetObject); nil elsewhere, e.g. in + // ListObjects results, on error paths, or for RDMA-backed GetObject. + // It aliases the response headers and must be treated as read-only. + Headers http.Header `json:"rawHeaders,omitempty" xml:"-"` + + // UserMetadata contains x-amz-meta-* user metadata. + // StatObject and GetObject return it with the "X-Amz-Meta-" prefix + // stripped; list results with WithMetadata keep the exact values stored + // on the object (prefixed keys plus system entries such as content-type). // Only returned by MinIO servers. UserMetadata StringMap `json:"userMetadata,omitempty"` + // UserMetadataStripped is the user metadata from list results in the + // keyed form StatObject and GetObject return in UserMetadata: + // x-amz-meta-* entries with the "X-Amz-Meta-" prefix stripped and + // values passed through verbatim. + // Only populated by MinIO servers when listing with WithMetadata. + UserMetadataStripped StringMap `json:"userMetadataStripped,omitempty" xml:"-"` + // x-amz-tagging values in their k/v values. // Only returned by MinIO servers. UserTags URLMap `json:"userTags,omitempty" xml:"UserTags"` diff --git a/vendor/github.com/minio/minio-go/v7/api-get-object-file.go b/vendor/github.com/minio/minio-go/v7/api-get-object-file.go index 6ef9c9330ee..dd62b3f7c86 100644 --- a/vendor/github.com/minio/minio-go/v7/api-get-object-file.go +++ b/vendor/github.com/minio/minio-go/v7/api-get-object-file.go @@ -72,7 +72,7 @@ func (c *Client) FGetObject(ctx context.Context, bucketName, objectName, filePat filePartPath := filepath.Join(filepath.Dir(filePath), sum256Hex([]byte(filepath.Base(filePath)+objectStat.ETag))+".part.minio") // If exists, open in append mode. If not create it as a part file. - filePart, err := os.OpenFile(filePartPath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o600) + filePart, err := os.OpenFile(filePartPath, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0o600) if err != nil { return err } @@ -98,19 +98,41 @@ func (c *Client) FGetObject(ctx context.Context, bucketName, objectName, filePat // appropriate range offsets to read from. if st.Size() > 0 { opts.SetRange(st.Size(), 0) + if opts.Checksum && objectStat.ChecksumMode == ChecksumFullObjectMode.String() { + if hasherReader := c.newChecksumVerifyingReader(objectStat); hasherReader != nil { + // Read existing file data into hash. + if _, err = io.CopyN(hasherReader.Hash, filePart, st.Size()); err != nil { + _ = hasherReader.Close() + return err + } + opts.checkSumReader = hasherReader + } + } } // Seek to current position for incoming reader. objectReader, objectStat, _, err := c.getObject(ctx, bucketName, objectName, opts) if err != nil { + if opts.checkSumReader != nil { + _ = opts.checkSumReader.Close() + } return err } + defer objectReader.Close() + // Write to the part file. if _, err = io.CopyN(filePart, objectReader, objectStat.Size); err != nil { return err } + // Verify the checksum of the downloaded object before committing the file. + if cr, ok := objectReader.(*checksumVerifyingReader); ok { + if err = cr.VerifyChecksum(); err != nil { + return err + } + } + // Close the file before rename, this is specifically needed for Windows users. closeAndRemove = false if err = filePart.Close(); err != nil { diff --git a/vendor/github.com/minio/minio-go/v7/api-get-object.go b/vendor/github.com/minio/minio-go/v7/api-get-object.go index ab783551520..d41d516a540 100644 --- a/vendor/github.com/minio/minio-go/v7/api-get-object.go +++ b/vendor/github.com/minio/minio-go/v7/api-get-object.go @@ -81,6 +81,8 @@ func (c *Client) GetObject(ctx context.Context, bucketName, objectName string, o reqCh := make(chan getRequest) // Create response channel. resCh := make(chan getResponse) + // record original range header for stat operation. + originalRangeHeader := opts.Header().Get("Range") // This routine feeds partial object data as and when the caller reads. go func() { @@ -115,6 +117,12 @@ func (c *Client) GetObject(ctx context.Context, bucketName, objectName string, o httpReader, objectInfo, _, err = c.getObject(gctx, bucketName, objectName, opts) if err != nil { resCh <- getResponse{Error: err} + // An unsatisfiable range is recoverable: the caller + // may Seek or ReadAt within bounds next, so keep + // serving requests instead of ending the stream. + if ToErrorResponse(err).Code == InvalidRange { + continue + } return } etag = objectInfo.ETag @@ -141,19 +149,35 @@ func (c *Client) GetObject(ctx context.Context, bucketName, objectName string, o // it to io.EOF - return unexpected EOF. err = io.ErrUnexpectedEOF } + // when doing a readAt, we can't reuse the httpReader for next read action. + if req.isReadAt { + httpReader.Close() + httpReader = nil + } + + objectSize := int64(0) + // case for ReadFull with range request + if !req.isReadAt && req.Offset == 0 { + objectSize = objectInfo.Size + } // Send back the first response. resCh <- getResponse{ + ObjectSize: objectSize, objectInfo: objectInfo, Size: size, Error: err, didRead: true, } } else { - // First request is a Stat or Seek call. - // Only need to run a StatObject until an actual Read or ReadAt request comes through. + if originalRangeHeader == "" { + // First request is a Seek call. + // Only need to run a StatObject until an actual Read request comes through. - // Remove range header if already set, for stat Operations to get original file size. - delete(opts.headers, "Range") + // Remove range header if already set, for stat Operations to get original file size. + delete(opts.headers, "Range") + } else { + opts.headers["Range"] = originalRangeHeader + } objectInfo, err = c.StatObject(gctx, bucketName, objectName, StatObjectOptions(opts)) if err != nil { resCh <- getResponse{ @@ -165,12 +189,17 @@ func (c *Client) GetObject(ctx context.Context, bucketName, objectName string, o etag = objectInfo.ETag // Send back the first response. resCh <- getResponse{ + ObjectSize: objectInfo.Size, objectInfo: objectInfo, } } } else if req.settingObjectInfo { // Request is just to get objectInfo. // Remove range header if already set, for stat Operations to get original file size. - delete(opts.headers, "Range") + if originalRangeHeader == "" { + delete(opts.headers, "Range") + } else { + opts.headers["Range"] = originalRangeHeader + } // Check whether this is snowball // if yes do not use If-Match feature // it doesn't work. @@ -187,16 +216,22 @@ func (c *Client) GetObject(ctx context.Context, bucketName, objectName string, o } // Send back the objectInfo. resCh <- getResponse{ + ObjectSize: objectInfo.Size, objectInfo: objectInfo, } } else { + objectSize := int64(0) + renewReader := false // Offset changes fetch the new object at an Offset. // Because the httpReader may not be set by the first // request if it was a stat or seek it must be checked // if the object has been read or not to only initialize // new ones when they haven't been already. // All readAt requests are new requests. - if req.DidOffsetChange || !req.beenRead { + // A nil httpReader means the previous fetch failed and + // left no stream, so a new one must be established + // regardless of the offset bookkeeping. + if req.DidOffsetChange || !req.beenRead || httpReader == nil { // Check whether this is snowball // if yes do not use If-Match feature // it doesn't work. @@ -214,16 +249,30 @@ func (c *Client) GetObject(ctx context.Context, bucketName, objectName string, o } else if req.Offset > 0 { // Range is set with respect to the offset. opts.SetRange(req.Offset, 0) } else { - // Remove range header if already set - delete(opts.headers, "Range") + if originalRangeHeader == "" { + delete(opts.headers, "Range") + } else { + opts.headers["Range"] = originalRangeHeader + } } httpReader, objectInfo, _, err = c.getObject(gctx, bucketName, objectName, opts) if err != nil { resCh <- getResponse{ Error: err, } + // An unsatisfiable range is recoverable: the caller + // may Seek or ReadAt within bounds next, so keep + // serving requests instead of ending the stream. + if ToErrorResponse(err).Code == InvalidRange { + continue + } return } + // case for ReadFull with range request + if !req.isReadAt && req.Offset == 0 { + objectSize = objectInfo.Size + } + renewReader = true totalRead = 0 } @@ -250,9 +299,13 @@ func (c *Client) GetObject(ctx context.Context, bucketName, objectName string, o // it to io.EOF - return unexpected EOF. err = io.ErrUnexpectedEOF } - + if renewReader && req.isReadAt { + httpReader.Close() + httpReader = nil + } // Reply back how much was read. resCh <- getResponse{ + ObjectSize: objectSize, Size: size, Error: err, didRead: true, @@ -281,6 +334,7 @@ type getRequest struct { // get response message container to reply back for the request. type getResponse struct { + ObjectSize int64 Size int Error error didRead bool // Lets subsequent calls know whether or not httpReader has been initiated. @@ -299,6 +353,7 @@ type Object struct { ctx context.Context cancel context.CancelFunc currOffset int64 + totalSize int64 objectInfo ObjectInfo // Ask lower level to initiate data fetching based on currOffset @@ -356,6 +411,10 @@ func (o *Object) doGetRequest(request getRequest) (getResponse, error) { // Data are ready on the wire, no need to reinitiate connection in lower level o.seekData = false + if response.ObjectSize != 0 { + o.totalSize = response.ObjectSize + } + return response, response.Error } @@ -365,7 +424,7 @@ func (o *Object) setOffset(bytesRead int64) error { // Update the currentOffset. o.currOffset += bytesRead - if o.objectInfo.Size > -1 && o.currOffset >= o.objectInfo.Size { + if o.totalSize > -1 && o.currOffset >= o.totalSize { return io.EOF } return nil @@ -387,6 +446,13 @@ func (o *Object) Read(b []byte) (n int, err error) { if o.prevErr != nil || o.isClosed { return 0, o.prevErr } + // If the current offset is at or beyond the known object size, there is + // nothing more to read. Return io.EOF directly instead of issuing a range + // request from EOF (which the server rejects as an unsatisfiable range). + if o.objectInfoSet && o.objectInfo.Size > -1 && o.currOffset >= o.objectInfo.Size { + o.prevErr = io.EOF + return 0, io.EOF + } // Create a new request. readReq := getRequest{ @@ -407,6 +473,14 @@ func (o *Object) Read(b []byte) (n int, err error) { // Send and receive from the first request. response, err := o.doGetRequest(readReq) if err != nil && err != io.EOF { + // An InvalidRange response to a range generated from a non-zero + // read offset means the position is at or past EOF for the object + // as it currently exists. Offset zero sends only a caller-supplied + // range, whose InvalidRange must surface untranslated. + if o.currOffset > 0 && ToErrorResponse(err).Code == InvalidRange { + o.prevErr = io.EOF + return 0, io.EOF + } // Save the error for future calls. o.prevErr = err return response.Size, err @@ -428,6 +502,8 @@ func (o *Object) Read(b []byte) (n int, err error) { } // Stat returns the ObjectInfo structure describing Object. +// When requesting a partial object or reading has started, +// the size returned will reflect the remaining size. func (o *Object) Stat() (ObjectInfo, error) { if o == nil { return ObjectInfo{}, errInvalidArgument("Object is nil") @@ -436,7 +512,24 @@ func (o *Object) Stat() (ObjectInfo, error) { o.mutex.Lock() defer o.mutex.Unlock() - if o.prevErr != nil && o.prevErr != io.EOF || o.isClosed { + if o.prevErr != nil && o.prevErr != io.EOF { + return ObjectInfo{}, o.prevErr + } + + // When the object info is already known (e.g. the RDMA GET path, whose + // payload is delivered out-of-band so the object is created closed, or a + // previously completed request) report it, even for a closed object. + if o.objectInfoSet { + if o.currOffset > o.totalSize { + return ObjectInfo{}, io.EOF + } + if o.currOffset <= o.totalSize { + o.objectInfo.Size = o.totalSize - o.currOffset + } + return o.objectInfo, nil + } + + if o.isClosed { return ObjectInfo{}, o.prevErr } @@ -452,7 +545,12 @@ func (o *Object) Stat() (ObjectInfo, error) { return ObjectInfo{}, err } } - + if o.currOffset > o.totalSize { + return ObjectInfo{}, io.EOF + } + if o.currOffset <= o.totalSize { + o.objectInfo.Size = o.totalSize - o.currOffset + } return o.objectInfo, nil } @@ -488,7 +586,7 @@ func (o *Object) ReadAt(b []byte, offset int64) (n int, err error) { if o.objectInfoSet { // If offset is negative than we return io.EOF. // If offset is greater than or equal to object size we return io.EOF. - if (o.objectInfo.Size > -1 && offset >= o.objectInfo.Size) || offset < 0 { + if (o.totalSize > -1 && offset >= o.totalSize) || offset < 0 { return 0, io.EOF } } @@ -511,6 +609,12 @@ func (o *Object) ReadAt(b []byte, offset int64) (n int, err error) { // Send and receive from the first request. response, err := o.doGetRequest(readAtReq) if err != nil && err != io.EOF { + // Reading at an offset at or beyond the object size yields + // InvalidRange from the server: report io.EOF, matching the + // io.ReaderAt contract for reads past the end. + if ToErrorResponse(err).Code == InvalidRange { + return 0, io.EOF + } // Save the error. o.prevErr = err return response.Size, err @@ -541,9 +645,10 @@ func (o *Object) ReadAt(b []byte, offset int64) (n int, err error) { // and 2 means relative to the end. // Seek returns the new offset and an error, if any. // -// Seeking to a negative offset is an error. Seeking to any positive -// offset is legal, subsequent io operations succeed until the -// underlying object is not closed. +// Seeking to a position before the start of the object is an error. +// Seeking to the end of the object is legal; the subsequent Read reports +// io.EOF. When the object size is known, seeking past the end returns +// io.EOF from Seek itself and leaves the offset unchanged. func (o *Object) Seek(offset int64, whence int) (n int64, err error) { if o == nil { return 0, errInvalidArgument("Object is nil") @@ -558,9 +663,11 @@ func (o *Object) Seek(offset int64, whence int) (n int64, err error) { return 0, o.prevErr } - // Negative offset is valid for whence of '2'. - if offset < 0 && whence != 2 { - return 0, errInvalidArgument(fmt.Sprintf("Negative position not allowed for %d", whence)) + // Negative absolute offsets are invalid for SeekStart. Negative offsets + // for SeekCurrent/SeekEnd are valid as long as the computed position is + // not before the start of the object (checked after applying whence). + if offset < 0 && whence == 0 { + return 0, errInvalidArgument("Negative position not allowed for 0") } // This is the first request. So before anything else @@ -588,31 +695,26 @@ func (o *Object) Seek(offset int64, whence int) (n int64, err error) { default: return 0, errInvalidArgument(fmt.Sprintf("Invalid whence %d", whence)) case 0: - if o.objectInfo.Size > -1 && offset > o.objectInfo.Size { - return 0, io.EOF - } newOffset = offset case 1: - if o.objectInfo.Size > -1 && o.currOffset+offset > o.objectInfo.Size { - return 0, io.EOF - } newOffset += offset case 2: // If we don't know the object size return an error for io.SeekEnd - if o.objectInfo.Size < 0 { + if o.totalSize < 0 { return 0, errInvalidArgument("Whence END is not supported when the object size is unknown") } - // Seeking to positive offset is valid for whence '2', but - // since we are backing a Reader we have reached 'EOF' if - // offset is positive. - if offset > 0 { - return 0, io.EOF - } - // Seeking to negative position not allowed for whence. - if o.objectInfo.Size+offset < 0 { - return 0, errInvalidArgument(fmt.Sprintf("Seeking at negative offset not allowed for %d", whence)) - } - newOffset = o.objectInfo.Size + offset + newOffset = o.totalSize + offset + } + // Seeking to a position before the start of the object is not allowed for + // any whence. + if newOffset < 0 { + return 0, errInvalidArgument(fmt.Sprintf("Seeking at negative offset not allowed for %d", whence)) + } + // Seeking past the end of the object is rejected with io.EOF, preserving + // long-standing behavior. Seeking to exactly the end is legal and the + // subsequent Read reports io.EOF. + if o.objectInfo.Size > -1 && newOffset > o.objectInfo.Size { + return 0, io.EOF } // Reset the saved error since we successfully seeked, let the Read // and ReadAt decide. @@ -717,6 +819,19 @@ func (c *Client) getObject(ctx context.Context, bucketName, objectName string, o return nil, ObjectInfo{}, nil, err } + body := resp.Body + if opts.Checksum { + if opts.checkSumReader != nil { + opts.checkSumReader.SetReader(resp.Body) + body = opts.checkSumReader + } else if objectStat.ChecksumMode == ChecksumFullObjectMode.String() && opts.headers["Range"] == "" { + if hasherReader := c.newChecksumVerifyingReader(objectStat); hasherReader != nil { + hasherReader.SetReader(resp.Body) + body = hasherReader + } + } + } + // do not close body here, caller will close - return resp.Body, objectStat, resp.Header, nil + return body, objectStat, resp.Header, nil } diff --git a/vendor/github.com/minio/minio-go/v7/api-get-options.go b/vendor/github.com/minio/minio-go/v7/api-get-options.go index dd82f97a132..e78235b15ad 100644 --- a/vendor/github.com/minio/minio-go/v7/api-get-options.go +++ b/vendor/github.com/minio/minio-go/v7/api-get-options.go @@ -44,10 +44,15 @@ type GetObjectOptions struct { VersionID string PartNumber int - // Include any checksums, if object was uploaded with checksum. // For multipart objects this is a checksum of part checksums. // https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html + // When the response advertises a full-object checksum, un-ranged + // downloads are verified against it: reads through *Object fail with a + // checksum mismatch error at EOF, and FGetObject fails before renaming + // the file into place. Reads that stop before EOF are not verified. Checksum bool + // If not nil, continue checksum hash verification on the existing data. + checkSumReader *checksumVerifyingReader // RDMABuffer, when non-nil and Options.EnableRDMA=true, downloads directly // into a contiguous buffer via libminiocpp.so. The returned *Object's diff --git a/vendor/github.com/minio/minio-go/v7/api-list.go b/vendor/github.com/minio/minio-go/v7/api-list.go index 5e4a381790d..3e13d36ae43 100644 --- a/vendor/github.com/minio/minio-go/v7/api-list.go +++ b/vendor/github.com/minio/minio-go/v7/api-list.go @@ -127,6 +127,9 @@ func (c *Client) listObjectsV2(ctx context.Context, bucketName string, opts List // Return object owner information by default fetchOwner := true + if opts.FetchOwner != nil { + fetchOwner = *opts.FetchOwner + } return func(yield func(ObjectInfo) bool) { if contextCanceled(ctx) { @@ -296,6 +299,7 @@ func (c *Client) listObjectsV2Query(ctx context.Context, bucketName, objectPrefi return listBucketResult, err } listBucketResult.Contents[i].LastModified = listBucketResult.Contents[i].LastModified.Truncate(time.Millisecond) + listBucketResult.Contents[i].UserMetadataStripped = stripUserMetadata(obj.UserMetadata) } for i, obj := range listBucketResult.CommonPrefixes { @@ -419,31 +423,32 @@ func (c *Client) listObjectVersions(ctx context.Context, bucketName string, opts } for _, version := range vers { info := ObjectInfo{ - ETag: trimEtag(version.ETag), - Key: version.Key, - LastModified: version.LastModified.Truncate(time.Millisecond), - Size: version.Size, - Owner: version.Owner, - StorageClass: version.StorageClass, - IsLatest: version.IsLatest, - VersionID: version.VersionID, - IsDeleteMarker: version.isDeleteMarker, - UserTags: version.UserTags, - UserMetadata: version.UserMetadata, - Internal: version.Internal, - NumVersions: numVersions, - ChecksumAlgorithm: version.ChecksumAlgorithm, - ChecksumMode: version.ChecksumType, - ChecksumCRC32: version.ChecksumCRC32, - ChecksumCRC32C: version.ChecksumCRC32C, - ChecksumSHA1: version.ChecksumSHA1, - ChecksumSHA256: version.ChecksumSHA256, - ChecksumCRC64NVME: version.ChecksumCRC64NVME, - ChecksumMD5: version.ChecksumMD5, - ChecksumSHA512: version.ChecksumSHA512, - ChecksumXXHash64: version.ChecksumXXHash64, - ChecksumXXHash3: version.ChecksumXXHash3, - ChecksumXXHash128: version.ChecksumXXHash128, + ETag: trimEtag(version.ETag), + Key: version.Key, + LastModified: version.LastModified.Truncate(time.Millisecond), + Size: version.Size, + Owner: version.Owner, + StorageClass: version.StorageClass, + IsLatest: version.IsLatest, + VersionID: version.VersionID, + IsDeleteMarker: version.isDeleteMarker, + UserTags: version.UserTags, + UserMetadata: version.UserMetadata, + UserMetadataStripped: version.UserMetadataStripped, + Internal: version.Internal, + NumVersions: numVersions, + ChecksumAlgorithm: version.ChecksumAlgorithm, + ChecksumMode: version.ChecksumType, + ChecksumCRC32: version.ChecksumCRC32, + ChecksumCRC32C: version.ChecksumCRC32C, + ChecksumSHA1: version.ChecksumSHA1, + ChecksumSHA256: version.ChecksumSHA256, + ChecksumCRC64NVME: version.ChecksumCRC64NVME, + ChecksumMD5: version.ChecksumMD5, + ChecksumSHA512: version.ChecksumSHA512, + ChecksumXXHash64: version.ChecksumXXHash64, + ChecksumXXHash3: version.ChecksumXXHash3, + ChecksumXXHash128: version.ChecksumXXHash128, } if !yield(info) { return false @@ -606,6 +611,7 @@ func (c *Client) listObjectVersionsQuery(ctx context.Context, bucketName string, if err != nil { return listObjectVersionsOutput, err } + listObjectVersionsOutput.Versions[i].UserMetadataStripped = stripUserMetadata(obj.UserMetadata) } for i, obj := range listObjectVersionsOutput.CommonPrefixes { @@ -738,6 +744,10 @@ type ListObjectsOptions struct { // Use the deprecated list objects V1 API UseV1 bool + // FetchOwner indicates whether to return object owner information. + // It defaults to true when unset. + FetchOwner *bool + headers http.Header } diff --git a/vendor/github.com/minio/minio-go/v7/api-presigned.go b/vendor/github.com/minio/minio-go/v7/api-presigned.go index 29642200ee1..1591fab32b0 100644 --- a/vendor/github.com/minio/minio-go/v7/api-presigned.go +++ b/vendor/github.com/minio/minio-go/v7/api-presigned.go @@ -140,7 +140,7 @@ func (c *Client) PresignedPostPolicy(ctx context.Context, p *PostPolicy) (u *url } // Get credentials from the configured credentials provider. - credValues, err := c.credsProvider.GetWithContext(c.CredContext()) + credValues, err := c.credsProvider.GetWithContext(c.credContext(ctx)) if err != nil { return nil, nil, err } diff --git a/vendor/github.com/minio/minio-go/v7/api-put-object-fan-out.go b/vendor/github.com/minio/minio-go/v7/api-put-object-fan-out.go index 3023b949cd4..cba0c069ba0 100644 --- a/vendor/github.com/minio/minio-go/v7/api-put-object-fan-out.go +++ b/vendor/github.com/minio/minio-go/v7/api-put-object-fan-out.go @@ -69,6 +69,8 @@ type PutObjectFanOutResponse struct { // stream multiple objects are written, defined via a list of PutObjectFanOutRequests. Each entry // in PutObjectFanOutRequest carries an object keyname and its relevant metadata if any. `Key` is // mandatory, rest of the other options in PutObjectFanOutRequest are optional. +// +// Deprecated: Use PutObject instead. func (c *Client) PutObjectFanOut(ctx context.Context, bucket string, fanOutData io.Reader, fanOutReq PutObjectFanOutRequest) ([]PutObjectFanOutResponse, error) { if len(fanOutReq.Entries) == 0 { return nil, errInvalidArgument("fan out requests cannot be empty") diff --git a/vendor/github.com/minio/minio-go/v7/api-s3-datatypes.go b/vendor/github.com/minio/minio-go/v7/api-s3-datatypes.go index fe503fb667d..402319cbff2 100644 --- a/vendor/github.com/minio/minio-go/v7/api-s3-datatypes.go +++ b/vendor/github.com/minio/minio-go/v7/api-s3-datatypes.go @@ -94,10 +94,16 @@ type Version struct { StorageClass string VersionID string `xml:"VersionId"` - // x-amz-meta-* headers stripped "x-amz-meta-" prefix containing the first value. - // Only returned by MinIO servers. + // UserMetadata contains the exact stored object metadata: x-amz-meta-* + // entries with their prefixed keys plus system entries such as + // content-type. Only returned by MinIO servers. UserMetadata StringMap `json:"userMetadata,omitempty"` + // UserMetadataStripped is UserMetadata in the keyed form StatObject and + // GetObject return in ObjectInfo.UserMetadata. See + // ObjectInfo.UserMetadataStripped. + UserMetadataStripped StringMap `json:"userMetadataStripped,omitempty" xml:"-"` + // x-amz-tagging values in their k/v values. // Only returned by MinIO servers. UserTags URLMap `json:"userTags,omitempty" xml:"UserTags"` @@ -280,6 +286,32 @@ type initiator struct { type copyObjectResult struct { ETag string LastModified time.Time // time string format "2006-01-02T15:04:05.000Z" + + // Checksum values returned in CopyObjectResult / CopyPartResult. + ChecksumCRC32 string `xml:"ChecksumCRC32,omitempty"` + ChecksumCRC32C string `xml:"ChecksumCRC32C,omitempty"` + ChecksumSHA1 string `xml:"ChecksumSHA1,omitempty"` + ChecksumSHA256 string `xml:"ChecksumSHA256,omitempty"` + ChecksumCRC64NVME string `xml:",omitempty"` + ChecksumMD5 string `xml:",omitempty"` + ChecksumSHA512 string `xml:",omitempty"` + ChecksumXXHash64 string `xml:"ChecksumXXHASH64,omitempty"` + ChecksumXXHash3 string `xml:"ChecksumXXHASH3,omitempty"` + ChecksumXXHash128 string `xml:"ChecksumXXHASH128,omitempty"` +} + +// setChecksums copies the copied part's checksums onto a CompletePart. +func (r *copyObjectResult) setChecksums(p *CompletePart) { + p.ChecksumCRC32 = r.ChecksumCRC32 + p.ChecksumCRC32C = r.ChecksumCRC32C + p.ChecksumSHA1 = r.ChecksumSHA1 + p.ChecksumSHA256 = r.ChecksumSHA256 + p.ChecksumCRC64NVME = r.ChecksumCRC64NVME + p.ChecksumMD5 = r.ChecksumMD5 + p.ChecksumSHA512 = r.ChecksumSHA512 + p.ChecksumXXHash64 = r.ChecksumXXHash64 + p.ChecksumXXHash3 = r.ChecksumXXHash3 + p.ChecksumXXHash128 = r.ChecksumXXHash128 } // ObjectPart container for particular part of an object. diff --git a/vendor/github.com/minio/minio-go/v7/api-stat.go b/vendor/github.com/minio/minio-go/v7/api-stat.go index a4b2af7aefc..ba9afa75c8d 100644 --- a/vendor/github.com/minio/minio-go/v7/api-stat.go +++ b/vendor/github.com/minio/minio-go/v7/api-stat.go @@ -57,7 +57,12 @@ func (c *Client) BucketExists(ctx context.Context, bucketName string) (bool, err } // StatObject verifies if object exists, you have permission to access it -// and returns information about the object. +// and returns information about the object. When the returned error is +// non-nil but a response was received, the ObjectInfo still carries the +// VersionID and IsDeleteMarker values parsed from the response headers, +// plus ReplicationReady on every error path except the versioned +// delete-marker 405 (an asymmetry preserved from the pre-v7.0.93 +// behavior, which populated ReplicationReady on the generic branch only). func (c *Client) StatObject(ctx context.Context, bucketName, objectName string, opts StatObjectOptions) (ObjectInfo, error) { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { @@ -92,32 +97,32 @@ func (c *Client) StatObject(ctx context.Context, bucketName, objectName string, }) defer closeResponse(resp) if err != nil { - return ObjectInfo{}, err - } - - if resp != nil { + // executeMethod returns a non-nil error for every non-success + // status. When a response exists, its headers still carry the + // version and delete-marker fields — surface them with the error. + if resp == nil { + return ObjectInfo{}, err + } deleteMarker := resp.Header.Get(amzDeleteMarker) == "true" replicationReady := resp.Header.Get(minioTgtReplicationReady) == "true" - if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusPartialContent { - if resp.StatusCode == http.StatusMethodNotAllowed && opts.VersionID != "" && deleteMarker { - errResp := ErrorResponse{ - StatusCode: resp.StatusCode, - Code: MethodNotAllowed, - Message: s3ErrorResponseMap[MethodNotAllowed], - BucketName: bucketName, - Key: objectName, - } - return ObjectInfo{ - VersionID: resp.Header.Get(amzVersionID), - IsDeleteMarker: deleteMarker, - }, errResp + if resp.StatusCode == http.StatusMethodNotAllowed && opts.VersionID != "" && deleteMarker { + errResp := ErrorResponse{ + StatusCode: resp.StatusCode, + Code: MethodNotAllowed, + Message: s3ErrorResponseMap[MethodNotAllowed], + BucketName: bucketName, + Key: objectName, } return ObjectInfo{ - VersionID: resp.Header.Get(amzVersionID), - IsDeleteMarker: deleteMarker, - ReplicationReady: replicationReady, // whether delete marker can be replicated - }, httpRespToErrorResponse(resp, bucketName, objectName) + VersionID: resp.Header.Get(amzVersionID), + IsDeleteMarker: deleteMarker, + }, errResp } + return ObjectInfo{ + VersionID: resp.Header.Get(amzVersionID), + IsDeleteMarker: deleteMarker, + ReplicationReady: replicationReady, // whether delete marker can be replicated + }, err } return ToObjectInfo(bucketName, objectName, resp.Header) diff --git a/vendor/github.com/minio/minio-go/v7/api.go b/vendor/github.com/minio/minio-go/v7/api.go index dbf639ab1d0..f7241af77fa 100644 --- a/vendor/github.com/minio/minio-go/v7/api.go +++ b/vendor/github.com/minio/minio-go/v7/api.go @@ -175,7 +175,7 @@ type Options struct { // Global constants. const ( libraryName = "minio-go" - libraryVersion = "v7.0.98" + libraryVersion = "v7.3.0" ) // User Agent should always following the below style. @@ -403,7 +403,7 @@ func (c *Client) TraceOff() { // SetS3TransferAccelerate - turns s3 accelerated endpoint on or off for all your // requests. This feature is only specific to S3 for all other endpoints this // function does nothing. To read further details on s3 transfer acceleration -// please vist - +// please visit - // http://docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html func (c *Client) SetS3TransferAccelerate(accelerateEndpoint string) { if s3utils.IsAmazonEndpoint(*c.endpointURL) { @@ -554,7 +554,7 @@ type requestMetadata struct { } // dumpHTTP - dump HTTP request and response. -func (c *Client) dumpHTTP(req *http.Request, resp *http.Response) error { +func (c *Client) dumpHTTP(req *http.Request, resp *http.Response, doErr error) error { // Starts http dump. _, err := fmt.Fprintln(c.traceOutput, "---------START-HTTP---------") if err != nil { @@ -568,6 +568,9 @@ func (c *Client) dumpHTTP(req *http.Request, resp *http.Response) error { } // Only display request header. + if req.Body != nil { + req.Body = http.NoBody + } reqTrace, err := httputil.DumpRequestOut(req, false) if err != nil { return err @@ -579,28 +582,36 @@ func (c *Client) dumpHTTP(req *http.Request, resp *http.Response) error { return err } - // Only display response header. - var respTrace []byte + if resp != nil { + // Only display response header. + var respTrace []byte - // For errors we make sure to dump response body as well. - if resp.StatusCode != http.StatusOK && - resp.StatusCode != http.StatusPartialContent && - resp.StatusCode != http.StatusNoContent { - respTrace, err = httputil.DumpResponse(resp, true) - if err != nil { - return err + // For errors we make sure to dump response body as well. + if !successStatus.Contains(resp.StatusCode) { + respTrace, err = httputil.DumpResponse(resp, true) + if err != nil { + return err + } + } else { + respTrace, err = httputil.DumpResponse(resp, false) + if err != nil { + return err + } } - } else { - respTrace, err = httputil.DumpResponse(resp, false) + + // Write response to trace output. + _, err = fmt.Fprint(c.traceOutput, strings.TrimSuffix(string(respTrace), "\r\n")) if err != nil { return err } } - // Write response to trace output. - _, err = fmt.Fprint(c.traceOutput, strings.TrimSuffix(string(respTrace), "\r\n")) - if err != nil { - return err + if doErr != nil { + // Write error to trace output. + _, err = fmt.Fprintln(c.traceOutput, strings.TrimSuffix(string(doErr.Error()), "\r\n")) + if err != nil { + return err + } } // Ends the http dump. @@ -623,6 +634,9 @@ func (c *Client) do(req *http.Request) (resp *http.Response, err error) { resp, err = c.httpClient.Do(req) if err != nil { + if c.isTraceEnabled { + _ = c.dumpHTTP(req, nil, err) + } // Handle this specifically for now until future Golang versions fix this issue properly. if urlErr, ok := err.(*url.Error); ok { if strings.Contains(urlErr.Err.Error(), "EOF") { @@ -643,9 +657,9 @@ func (c *Client) do(req *http.Request) (resp *http.Response, err error) { } // If trace is enabled, dump http request and response, - // except when the traceErrorsOnly enabled and the response's status code is ok - if c.isTraceEnabled && (!c.traceErrorsOnly || resp.StatusCode != http.StatusOK) { - err = c.dumpHTTP(req, resp) + // except when traceErrorsOnly is enabled and the response has a success status code + if c.isTraceEnabled && (!c.traceErrorsOnly || !successStatus.Contains(resp.StatusCode)) { + err = c.dumpHTTP(req, resp, nil) if err != nil { return nil, err } @@ -657,6 +671,7 @@ func (c *Client) do(req *http.Request) (resp *http.Response, err error) { // List of success status. var successStatus = set.CreateIntSet( http.StatusOK, + http.StatusAccepted, http.StatusNoContent, http.StatusPartialContent, ) @@ -833,8 +848,24 @@ func (c *Client) executeMethod(ctx context.Context, method string, metadata requ return res, err } +// credsRetrievalPanic carries a panic value out of the de-duplicated +// credential retrieval goroutine so newRequest can resume it on each +// caller's goroutine. The value is re-raised verbatim, as if the provider +// had panicked on the caller's goroutine; the retrieval goroutine's stack +// is not carried along. +type credsRetrievalPanic struct{ value any } + +func (p credsRetrievalPanic) Error() string { + return fmt.Sprintf("credentials retrieval panicked: %v", p.value) +} + // newRequest - instantiate a new HTTP request for a given method. func (c *Client) newRequest(ctx context.Context, method string, metadata requestMetadata) (req *http.Request, err error) { + if ctx == nil { + // A nil context would be dereferenced below — by the bucket + // location lookup, the waiter select, and context.WithoutCancel. + return nil, errInvalidArgument("context cannot be nil") + } // If no method is supplied default to 'POST'. if method == "" { method = http.MethodPost @@ -867,23 +898,88 @@ func (c *Client) newRequest(ctx context.Context, method string, metadata request return nil, err } - if c.httpTrace != nil { - ctx = httptrace.WithClientTrace(ctx, c.httpTrace) - } - - // make sure to de-dup calls to credential services, this reduces - // the overall load to the endpoint generating credential service. - value, err, _ := c.credsGroup.Do(metadata.bucketName, func() (credentials.Value, error) { - if s3utils.IsS3ExpressBucket(metadata.bucketName) && s3utils.IsAmazonEndpoint(*c.endpointURL) { - return c.CreateSession(ctx, metadata.bucketName, SessionReadWrite) + // Cached, unexpired credentials (or an absent provider — anonymous + // access) are served inline; a retrieval that races expiry runs + // inline too, with the caller's live context, serialized by the + // Credentials mutex. A still-fresh cached S3 Express session is + // served inline as well; actual retrievals go through the de-dup + // group. + express := s3utils.IsS3ExpressBucket(metadata.bucketName) && s3utils.IsAmazonEndpoint(*c.endpointURL) + var value credentials.Value + var served bool + if express { + value, served = c.sessionFromCache(metadata.bucketName) + } else if c.credsProvider == nil || !c.credsProvider.IsExpired() { + value, err = c.credsProvider.GetWithContext(c.credContext(ctx)) + served = true + } + if !served { + // The provider retrieval is detached (context.WithoutCancel) so + // one caller's cancellation cannot fail concurrent waiters; each + // waiter stops waiting when its own context ends, though a + // caller arriving mid-retrieval blocks in IsExpired on the + // Credentials mutex until the retrieval completes. Detachment + // strips the caller's deadline along with its cancellation: on + // this path the caller context governs only the wait, and reaches + // the credential request itself only outside the group — on the + // inline not-expired path above and the direct call sites + // (presign, bucket location, express CreateSession). The S3 + // Express session request keeps the caller context: a full S3 + // operation's retries must stay cancellable, so its waiters + // share the winner's fate, and its trace for the same reason: + // the round trip was traced before this change. + // A retrieval panic resumes on each waiting caller's goroutine + // (credsRetrievalPanic); a runtime.Goexit reaches waiters as a + // terminal error from the de-dup group, since the retrieval + // goroutine cannot return one itself. + retrieveCtx := ctx + if express { + if c.httpTrace != nil { + retrieveCtx = httptrace.WithClientTrace(retrieveCtx, c.httpTrace) + } + } else { + retrieveCtx = context.WithoutCancel(ctx) + } + resCh := c.credsGroup.DoChan(metadata.bucketName, func() (v credentials.Value, rerr error) { + defer func() { + if r := recover(); r != nil { + rerr = credsRetrievalPanic{value: r} + } + }() + if express { + return c.CreateSession(retrieveCtx, metadata.bucketName, SessionReadWrite) + } + // Get credentials from the configured credentials provider. + return c.credsProvider.GetWithContext(c.credContext(retrieveCtx)) + }) + var res singleflight.Result[credentials.Value] + select { + case res = <-resCh: + case <-ctx.Done(): + // A result already delivered when the cancellation fires is + // preferred over the caller's context error. + select { + case res = <-resCh: + default: + return nil, ctx.Err() + } + } + var cp credsRetrievalPanic + if errors.As(res.Err, &cp) { + panic(cp.value) } - // Get credentials from the configured credentials provider. - return c.credsProvider.GetWithContext(c.CredContext()) - }) + value, err = res.Val, res.Err + } if err != nil { return nil, err } + // Attach the trace after retrieval: provider credential requests were + // never traced. The express session request is traced above. + if c.httpTrace != nil { + ctx = httptrace.WithClientTrace(ctx, c.httpTrace) + } + // Initialize a new HTTP request for the method. req, err = http.NewRequestWithContext(ctx, method, targetURL.String(), nil) if err != nil { @@ -1157,6 +1253,14 @@ func (c *Client) CredContext() *credentials.CredContext { } } +// credContext returns the client's CredContext with ctx attached as the +// caller context for credential retrieval. +func (c *Client) credContext(ctx context.Context) *credentials.CredContext { + cc := c.CredContext() + cc.Context = ctx + return cc +} + // GetCreds returns the access creds for the client func (c *Client) GetCreds() (credentials.Value, error) { if c.credsProvider == nil { diff --git a/vendor/github.com/minio/minio-go/v7/bucket-cache.go b/vendor/github.com/minio/minio-go/v7/bucket-cache.go index 7c64972842c..50b20c4dc64 100644 --- a/vendor/github.com/minio/minio-go/v7/bucket-cache.go +++ b/vendor/github.com/minio/minio-go/v7/bucket-cache.go @@ -76,33 +76,35 @@ func (c *Client) getBucketLocation(ctx context.Context, bucketName string) (stri // processes the getBucketLocation http response from the server. func processBucketLocationResponse(resp *http.Response, bucketName string) (bucketLocation string, err error) { - if resp != nil { - if resp.StatusCode != http.StatusOK { - err = httpRespToErrorResponse(resp, bucketName, "") - errResp := ToErrorResponse(err) - // For access denied error, it could be an anonymous - // request. Move forward and let the top level callers - // succeed if possible based on their policy. - switch errResp.Code { - case NotImplemented: - switch errResp.Server { - case "AmazonSnowball": - return "snowball", nil - case "cloudflare": - return "us-east-1", nil - } - case AuthorizationHeaderMalformed: - fallthrough - case InvalidRegion: - fallthrough - case AccessDenied: - if errResp.Region == "" { - return "us-east-1", nil - } - return errResp.Region, nil + if resp == nil { + return "", errInvalidArgument("Empty http response. " + reportIssue) + } + + if resp.StatusCode != http.StatusOK { + err = httpRespToErrorResponse(resp, bucketName, "") + errResp := ToErrorResponse(err) + // For access denied error, it could be an anonymous + // request. Move forward and let the top level callers + // succeed if possible based on their policy. + switch errResp.Code { + case NotImplemented: + switch errResp.Server { + case "AmazonSnowball": + return "snowball", nil + case "cloudflare": + return "us-east-1", nil } - return "", err + case AuthorizationHeaderMalformed: + fallthrough + case InvalidRegion: + fallthrough + case AccessDenied: + if errResp.Region == "" { + return "us-east-1", nil + } + return errResp.Region, nil } + return "", err } // Extract location. @@ -170,7 +172,7 @@ func (c *Client) getBucketLocationRequest(ctx context.Context, bucketName string c.setUserAgent(req) // Get credentials from the configured credentials provider. - value, err := c.credsProvider.GetWithContext(c.CredContext()) + value, err := c.credsProvider.GetWithContext(c.credContext(ctx)) if err != nil { return nil, err } diff --git a/vendor/github.com/minio/minio-go/v7/checksum.go b/vendor/github.com/minio/minio-go/v7/checksum.go index bb3ce27b185..d6324b1c05a 100644 --- a/vendor/github.com/minio/minio-go/v7/checksum.go +++ b/vendor/github.com/minio/minio-go/v7/checksum.go @@ -25,6 +25,7 @@ import ( "encoding/base64" "encoding/binary" "errors" + "fmt" "hash" "io" "math/bits" @@ -316,6 +317,86 @@ func (c ChecksumType) String() string { return "" } +// checksumVerifyingReader verifies the checksum of data as it is read. +type checksumVerifyingReader struct { + io.ReadCloser + hash.Hash + expectChecksum string +} + +// newChecksumVerifyingReader returns a checksum-verifying reader for obj, +// wrapping the given response body, or nil if obj carries no usable checksum. +func (c *Client) newChecksumVerifyingReader(obj ObjectInfo) *checksumVerifyingReader { + switch { + case obj.ChecksumCRC32 != "": + return &checksumVerifyingReader{Hash: ChecksumCRC32.Hasher(), expectChecksum: obj.ChecksumCRC32} + case obj.ChecksumCRC32C != "": + return &checksumVerifyingReader{Hash: ChecksumCRC32C.Hasher(), expectChecksum: obj.ChecksumCRC32C} + case obj.ChecksumSHA1 != "": + return &checksumVerifyingReader{Hash: ChecksumSHA1.Hasher(), expectChecksum: obj.ChecksumSHA1} + case obj.ChecksumSHA256 != "": + return &checksumVerifyingReader{Hash: c.sha256Hasher(), expectChecksum: obj.ChecksumSHA256} + case obj.ChecksumCRC64NVME != "": + return &checksumVerifyingReader{Hash: ChecksumCRC64NVME.Hasher(), expectChecksum: obj.ChecksumCRC64NVME} + case obj.ChecksumMD5 != "": + return &checksumVerifyingReader{Hash: c.md5Hasher(), expectChecksum: obj.ChecksumMD5} + case obj.ChecksumSHA512 != "": + return &checksumVerifyingReader{Hash: ChecksumSHA512.Hasher(), expectChecksum: obj.ChecksumSHA512} + case obj.ChecksumXXHash64 != "": + return &checksumVerifyingReader{Hash: ChecksumXXHash64.Hasher(), expectChecksum: obj.ChecksumXXHash64} + case obj.ChecksumXXHash3 != "": + return &checksumVerifyingReader{Hash: ChecksumXXHash3.Hasher(), expectChecksum: obj.ChecksumXXHash3} + case obj.ChecksumXXHash128 != "": + return &checksumVerifyingReader{Hash: ChecksumXXHash128.Hasher(), expectChecksum: obj.ChecksumXXHash128} + default: + return nil + } +} + +func (c *checksumVerifyingReader) SetReader(r io.ReadCloser) { + c.ReadCloser = r +} + +// Close returns any pooled hasher and closes the underlying reader if one is set. +func (c *checksumVerifyingReader) Close() error { + if closer, ok := c.Hash.(interface{ Close() }); ok { + closer.Close() + } + if c.ReadCloser == nil { + return nil + } + return c.ReadCloser.Close() +} + +// Read reads data and hashes it. At EOF the checksum is verified; on +// mismatch the mismatch error is returned in place of io.EOF. +func (c *checksumVerifyingReader) Read(p []byte) (int, error) { + n, err := c.ReadCloser.Read(p) + if n > 0 { + n2, werr := c.Write(p[:n]) + if werr != nil { + return n, werr + } + if n2 != n { + return n, io.ErrShortWrite + } + } + if err == io.EOF { + if verr := c.VerifyChecksum(); verr != nil { + return n, verr + } + } + return n, err +} + +// VerifyChecksum returns an error if the computed checksum does not match. +func (c *checksumVerifyingReader) VerifyChecksum() error { + if got := base64.StdEncoding.EncodeToString(c.Sum(nil)); got != c.expectChecksum { + return fmt.Errorf("checksum mismatch, expected %s, got %s", c.expectChecksum, got) + } + return nil +} + // ChecksumReader reads all of r and returns a checksum of type c. // Returns any error that may have occurred while reading. func (c ChecksumType) ChecksumReader(r io.Reader) (Checksum, error) { diff --git a/vendor/github.com/minio/minio-go/v7/create-session.go b/vendor/github.com/minio/minio-go/v7/create-session.go index d85e79d4b1e..3f1b3175c9e 100644 --- a/vendor/github.com/minio/minio-go/v7/create-session.go +++ b/vendor/github.com/minio/minio-go/v7/create-session.go @@ -51,19 +51,30 @@ type createSessionResult struct { } `xml:",omitempty"` } +// expressSessionRenewalLeeway is how long before its expiration a cached +// S3 Express session stops being served, leaving room for renewal. +const expressSessionRenewalLeeway = 10 * time.Second + +// sessionFromCache returns the cached S3 Express session credentials for +// bucketName while they remain outside the renewal leeway. +func (c *Client) sessionFromCache(bucketName string) (credentials.Value, bool) { + v, ok := c.bucketSessionCache.Get(bucketName) + if !ok || !v.Expiration.After(time.Now().Add(expressSessionRenewalLeeway)) { + return credentials.Value{}, false + } + return v, true +} + // CreateSession - https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateSession.html // the returning credentials may be cached depending on the expiration of the original -// credential, credentials will get renewed 10 secs earlier than when its gonna expire -// allowing for some leeway in the renewal process. +// credential; a cached session stops being served expressSessionRenewalLeeway before +// it expires, allowing for some leeway in the renewal process. func (c *Client) CreateSession(ctx context.Context, bucketName string, sessionMode SessionMode) (cred credentials.Value, err error) { if err := s3utils.CheckValidBucketNameS3Express(bucketName); err != nil { return credentials.Value{}, err } - v, ok := c.bucketSessionCache.Get(bucketName) - if ok && v.Expiration.After(time.Now().Add(10*time.Second)) { - // Verify if the credentials will not expire - // in another 10 seconds, if not we renew it again. + if v, ok := c.sessionFromCache(bucketName); ok { return v, nil } @@ -143,7 +154,7 @@ func (c *Client) createSessionRequest(ctx context.Context, bucketName string, se c.setUserAgent(req) // Get credentials from the configured credentials provider. - value, err := c.credsProvider.GetWithContext(c.CredContext()) + value, err := c.credsProvider.GetWithContext(c.credContext(ctx)) if err != nil { return nil, err } diff --git a/vendor/github.com/minio/minio-go/v7/functional_tests.go b/vendor/github.com/minio/minio-go/v7/functional_tests.go index ef5f2377f1d..80d98955a2f 100644 --- a/vendor/github.com/minio/minio-go/v7/functional_tests.go +++ b/vendor/github.com/minio/minio-go/v7/functional_tests.go @@ -172,9 +172,12 @@ func logError(testName, function string, args map[string]interface{}, startTime // If server returns NotImplemented we assume it is gateway mode and hence log it as info and move on to next tests // Special case for ComposeObject API as it is implemented on client side and adds specific error details like `Error in upload-part-copy` in // addition to NotImplemented error returned from server - if isErrNotImplemented(err) { + switch { + case isErrNotImplemented(err): logIgnored(testName, function, args, startTime, message) - } else { + case isErrFreeTierLicense(err): + logNotAvailable(testName, function, args, startTime, message) + default: logFailure(testName, function, args, startTime, alert, message, err) if !isRunOnFail() { panic(fmt.Sprintf("Test failed with message: %s, err: %v", message, err)) @@ -206,6 +209,15 @@ func logIgnored(testName, function string, args map[string]interface{}, startTim ).Info("") } +// log not applicable test runs for license-gated features +func logNotAvailable(testName, function string, args map[string]interface{}, startTime time.Time, alert string) { + baseLogger(testName, function, args, startTime). + With( + "status", "NA", + "alert", strings.Split(alert, " ")[0]+" requires a paid-tier license", + ).Info("") +} + // Delete objects in given bucket, recursively func cleanupBucket(bucketName string, c *minio.Client) error { // Create a done channel to control 'ListObjectsV2' go routine. @@ -279,6 +291,11 @@ func isErrNotImplemented(err error) bool { return minio.ToErrorResponse(err).Code == minio.NotImplemented } +// isErrFreeTierLicense reports whether the server rejected the request because it requires a paid-tier license. +func isErrFreeTierLicense(err error) bool { + return minio.ToErrorResponse(err).Code == minio.XMinioPaidTierLicenseRequired +} + func isRunOnFail() bool { return os.Getenv("RUN_ON_FAIL") == "1" } @@ -795,6 +812,125 @@ func testListObjectVersions() { logSuccess(testName, function, args, startTime) } +func testStatObjectResponseHeaders() { + // initialize logging params + startTime := time.Now() + testName := getFuncName() + function := "StatObject(bucketName, objectName, opts)" + args := map[string]interface{}{} + + c, err := NewClient(ClientConfig{}) + if err != nil { + logError(testName, function, args, startTime, "", "MinIO client object creation failed", err) + return + } + + // Generate a new random bucket name. + bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test-") + args["bucketName"] = bucketName + + // Make a new bucket. + err = c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1"}) + if err != nil { + logError(testName, function, args, startTime, "", "MakeBucket failed", err) + return + } + + defer cleanupBucket(bucketName, c) + + bufSize := dataFileMap["datafile-33-kB"] + reader := getDataReader("datafile-33-kB") + defer reader.Close() + + objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "") + args["objectName"] = objectName + + _, err = c.PutObject(context.Background(), bucketName, objectName, reader, int64(bufSize), minio.PutObjectOptions{ContentType: "binary/octet-stream"}) + if err != nil { + logError(testName, function, args, startTime, "", "PutObject failed", err) + return + } + + opts := minio.StatObjectOptions{} + err = opts.SetRange(0, 99) + if err != nil { + logError(testName, function, args, startTime, "", "SetRange failed", err) + return + } + args["range"] = "0-99" + + st, err := c.StatObject(context.Background(), bucketName, objectName, opts) + if err != nil { + logError(testName, function, args, startTime, "", "StatObject failed", err) + return + } + + if st.Size != 100 { + logError(testName, function, args, startTime, "", "StatObject ranged size mismatch", fmt.Errorf("got %d, want 100", st.Size)) + return + } + wantContentRange := fmt.Sprintf("bytes 0-99/%d", bufSize) + gotContentRange := st.Headers.Get("Content-Range") + if gotContentRange != wantContentRange { + logError(testName, function, args, startTime, "", "StatObject response headers Content-Range mismatch", fmt.Errorf("got %q, want %q", gotContentRange, wantContentRange)) + return + } + if st.Headers.Get("ETag") == "" { + logError(testName, function, args, startTime, "", "StatObject response headers missing ETag", errors.New("empty ETag header")) + return + } + + gopts := minio.GetObjectOptions{} + err = gopts.SetRange(0, 99) + if err != nil { + logError(testName, function, args, startTime, "", "SetRange failed", err) + return + } + obj, err := c.GetObject(context.Background(), bucketName, objectName, gopts) + if err != nil { + logError(testName, function, args, startTime, "", "GetObject failed", err) + return + } + defer obj.Close() + // Read first: a first-op Stat issues an un-ranged StatObject by design, + // so the ranged GET response headers are observable only after a read. + buf := make([]byte, 100) + if _, err = io.ReadFull(obj, buf); err != nil { + logError(testName, function, args, startTime, "", "GetObject ranged read failed", err) + return + } + gst, err := obj.Stat() + if err != nil { + logError(testName, function, args, startTime, "", "GetObject Stat failed", err) + return + } + if got := gst.Headers.Get("Content-Range"); got != wantContentRange { + logError(testName, function, args, startTime, "", "GetObject response headers Content-Range mismatch", fmt.Errorf("got %q, want %q", got, wantContentRange)) + return + } + + sawObject := false + for listInfo := range c.ListObjects(context.Background(), bucketName, minio.ListObjectsOptions{}) { + if listInfo.Err != nil { + logError(testName, function, args, startTime, "", "ListObjects failed", listInfo.Err) + return + } + if listInfo.Key == objectName { + sawObject = true + } + if listInfo.Headers != nil { + logError(testName, function, args, startTime, "", "ListObjects ObjectInfo.Headers expected nil", fmt.Errorf("got %v", listInfo.Headers)) + return + } + } + if !sawObject { + logError(testName, function, args, startTime, "", "ListObjects did not list the uploaded object", errors.New("uploaded object missing from listing")) + return + } + + logSuccess(testName, function, args, startTime) +} + func testStatObjectWithVersioning() { // initialize logging params startTime := time.Now() @@ -5379,7 +5515,7 @@ func testGetObjectReadSeekFunctional() { } if st.Size != int64(bufSize) { - logError(testName, function, args, startTime, "", "Number of bytes does not match, expected "+string(int64(bufSize))+", got "+string(st.Size), err) + logError(testName, function, args, startTime, "", "Number of bytes does not match, expected "+strconv.Itoa(bufSize)+", got "+strconv.FormatInt(st.Size, 10), err) return } @@ -5418,50 +5554,77 @@ func testGetObjectReadSeekFunctional() { {0, 0, 0, nil, true, 0, 0}, // Start from offset 2048, fetch data and compare {2048, 0, 2048, nil, true, 2048, bufSize}, - // Start from offset larger than possible - {int64(bufSize) + 1024, 0, 0, seekErr, false, 0, 0}, + // Start from offset larger than possible: Seek rejects it with io.EOF + // and keeps the offset unchanged. + {int64(bufSize) + 1024, 0, 0, io.EOF, false, 0, 0}, // Move to offset 0 without comparing {0, 0, 0, nil, false, 0, 0}, // Move one step forward and compare {1, 1, 1, nil, true, 1, bufSize}, - // Move larger than possible - {int64(bufSize), 1, 0, seekErr, false, 0, 0}, - // Provide negative offset with CUR_SEEK - {int64(-1), 1, 0, seekErr, false, 0, 0}, - // Test with whence SEEK_END and with positive offset - {1024, 2, int64(bufSize) - 1024, io.EOF, true, 0, 0}, + // Move larger than possible: Seek returns io.EOF. + {int64(bufSize), 1, 0, io.EOF, false, 0, 0}, + // Provide negative offset with CUR_SEEK: valid since the resulting + // absolute position is within the object. + {int64(-1), 1, int64(bufSize) - 1, nil, false, 0, 0}, + // Test with whence SEEK_END and with positive offset: Seek returns + // io.EOF. + {1024, 2, 0, io.EOF, false, 0, 0}, // Test with whence SEEK_END and with negative offset {-1024, 2, int64(bufSize) - 1024, nil, true, bufSize - 1024, bufSize}, // Test with whence SEEK_END and with large negative offset {-int64(bufSize) * 2, 2, 0, seekErr, true, 0, 0}, + // Seek to exactly the object end; the subsequent read reports io.EOF. + {0, 2, int64(bufSize), nil, false, 0, 0}, } for i, testCase := range testCases { + // Snapshot the cursor so rejected seeks can be asserted side-effect + // free. + prevPos, err := r.Seek(0, io.SeekCurrent) + if err != nil { + logError(testName, function, args, startTime, "", fmt.Sprintf("Test %d, reading the current position failed", i+1), err) + return + } // Perform seek operation n, err := r.Seek(testCase.offset, testCase.whence) // We expect an error if testCase.err == seekErr && err == nil { - logError(testName, function, args, startTime, "", "Test "+string(i+1)+", unexpected err value: expected: "+testCase.err.Error()+", found: "+err.Error(), err) + logError(testName, function, args, startTime, "", fmt.Sprintf("Test %d, unexpected err value: expected: %v, found: %v", i+1, testCase.err, err), err) return } // We expect a specific error if testCase.err != seekErr && testCase.err != err { - logError(testName, function, args, startTime, "", "Test "+string(i+1)+", unexpected err value: expected: "+testCase.err.Error()+", found: "+err.Error(), err) + logError(testName, function, args, startTime, "", fmt.Sprintf("Test %d, unexpected err value: expected: %v, found: %v", i+1, testCase.err, err), err) return } // If we expect an error go to the next loop if testCase.err != nil { + // A rejected seek must leave the cursor unchanged. + curPos, cerr := r.Seek(0, io.SeekCurrent) + if cerr != nil || curPos != prevPos { + logError(testName, function, args, startTime, "", fmt.Sprintf("Test %d, cursor after rejected seek: expected %d, got %d", i+1, prevPos, curPos), cerr) + return + } continue } // Check the returned seek pos if n != testCase.pos { - logError(testName, function, args, startTime, "", "Test "+string(i+1)+", number of bytes seeked does not match, expected "+string(testCase.pos)+", got "+string(n), err) + logError(testName, function, args, startTime, "", fmt.Sprintf("Test %d, number of bytes seeked does not match, expected %d, got %d", i+1, testCase.pos, n), err) return } // Compare only if shouldCmp is activated if testCase.shouldCmp { cmpData(r, testCase.start, testCase.end) } + // A successful seek to the object end must defer io.EOF to the + // subsequent read. + if !testCase.shouldCmp && testCase.err == nil && testCase.pos >= int64(bufSize) { + readN, readErr := r.Read(make([]byte, 1)) + if readN != 0 || readErr != io.EOF { + logError(testName, function, args, startTime, "", fmt.Sprintf("Test %d, read after seek to object end expected zero bytes and io.EOF, got %d bytes and %v", i+1, readN, readErr), readErr) + return + } + } } logSuccess(testName, function, args, startTime) } @@ -5569,8 +5732,8 @@ func testGetObjectReadAtFunctional() { return } - if st.Size != int64(bufSize) { - logError(testName, function, args, startTime, "", "Number of bytes in stat does not match, expected "+string(int64(bufSize))+", got "+string(st.Size), err) + if st.Size != (int64(bufSize) - int64(len(bufRead))) { + logError(testName, function, args, startTime, "", "Number of bytes in stat does not match, expected "+strconv.Itoa(bufSize)+", got "+strconv.Itoa(bufSize-len(bufRead)), err) return } @@ -5665,6 +5828,228 @@ func testGetObjectReadAtFunctional() { logSuccess(testName, function, args, startTime) } +// testGetObjectWithRange - get object with range +func testGetObjectWithRange() { + // initialize logging params + startTime := time.Now() + testName := getFuncName() + function := "GetObject(bucketName, objectName)" + args := map[string]interface{}{} + + c, err := NewClient(ClientConfig{}) + if err != nil { + logError(testName, function, args, startTime, "", "MinIO client object creation failed", err) + return + } + + // Generate a new random bucket name. + bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test-") + args["bucketName"] = bucketName + + // Make a new bucket. + err = c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1"}) + if err != nil { + logError(testName, function, args, startTime, "", "MakeBucket failed", err) + return + } + + defer cleanupBucket(bucketName, c) + + // Generate 33K of data. + bufSize := dataFileMap["datafile-33-kB"] + reader := getDataReader("datafile-33-kB") + defer reader.Close() + + objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "") + args["objectName"] = objectName + + buf, err := io.ReadAll(reader) + if err != nil { + logError(testName, function, args, startTime, "", "ReadAll failed", err) + return + } + + // Save the data + _, err = c.PutObject(context.Background(), bucketName, objectName, bytes.NewReader(buf), int64(len(buf)), minio.PutObjectOptions{ContentType: "binary/octet-stream"}) + if err != nil { + logError(testName, function, args, startTime, "", "PutObject failed", err) + return + } + + var r *minio.Object + testIndex := 0 + baseSize := 0 + New := func() { + opts := minio.GetObjectOptions{} + switch testIndex { + case 0: + baseSize = bufSize + case 1: + opts.SetRange(100, 1000) + baseSize = 1000 - 100 + 1 + case 2: + opts.SetRange(100, 0) + baseSize = bufSize - 100 + case 3: + opts.SetRange(0, 1000) + baseSize = 1000 + 1 + } + r, err = c.GetObject(context.Background(), bucketName, objectName, opts) + if err != nil { + logError(testName, function, args, startTime, "", "Failed to create MinIO client object", err) + } + } + + Size := func(size int) { + st, err := r.Stat() + if err != nil { + logError(testName, function, args, startTime, "", "Failed to get object stat", err) + } + if int(st.Size) != size { + logError(testName, function, args, startTime, "", "Incorrect size returned", fmt.Errorf("Test index %d Expected size %d, got %d", testIndex, size, int(st.Size))) + } + } + Read := func(size int) { + b := make([]byte, size) + _, err := r.Read(b) + if err != nil { + logError(testName, function, args, startTime, "", "Failed to read from object", err) + } + } + + ReadFull := func(size int) { + b := make([]byte, size) + _, err := r.Read(b) + if err != nil { + logError(testName, function, args, startTime, "", "Failed to read from object", err) + } + } + + ReadAll := func() { + _, err := io.ReadAll(r) + if err != nil { + logError(testName, function, args, startTime, "", "Failed to read from object", err) + } + } + + Seek := func(offset int64, whence int) { + _, err := r.Seek(offset, whence) + if err != nil { + logError(testName, function, args, startTime, "", "Failed to seek in object", err) + } + } + ReadAt := func(offset int64, size int64) { + b := make([]byte, size) + _, err := r.ReadAt(b, offset) + if err != nil { + logError(testName, function, args, startTime, "", "Failed to read from object", err) + } + } + for index := range 4 { + testIndex = index + // case 1: stat first and then read 100 bytes for per read + { + New() + Size(baseSize) + Read(100) + Size(baseSize - 100) + Read(100) + Size(baseSize - 200) + Read(100) + Size(baseSize - 300) + ReadFull(100) + Size(baseSize - 400) + } + // case 2: read 100 bytes for per read + { + New() + Read(100) + Size(baseSize - 100) + Read(100) + Size(baseSize - 200) + Read(100) + Size(baseSize - 300) + ReadFull(100) + Size(baseSize - 400) + } + // case 3: Stat -> Read -> ReadAt -> Read + { + New() + Size(baseSize) + Read(100) + Size(baseSize - 100) + // should not move the offset, so next stat is not changed + ReadAt(100, 100) + Size(baseSize - 100) + Read(100) + Size(baseSize - 200) + } + // case 4: Read -> ReadAt -> Read + { + New() + Read(100) + Size(baseSize - 100) + // should not move the offset, so next stat is not changed + ReadAt(100, 100) + Size(baseSize - 100) + Read(100) + Size(baseSize - 200) + } + // case 5: Stat -> Read -> ReadAt -> Read -> Seek -> Read + { + New() + Size(baseSize) + Read(100) + Size(baseSize - 100) + // should not move the offset, so next stat is not changed + ReadAt(100, 100) + Size(baseSize - 100) + Read(100) + Size(baseSize - 200) + Seek(100, io.SeekCurrent) + Size(baseSize - 300) + Read(100) + Size(baseSize - 400) + } + // case 6: Read -> ReadAt -> Read -> Seek -> Read + { + New() + Read(100) + Size(baseSize - 100) + // should not move the offset, so next stat is not changed + ReadAt(100, 100) + Size(baseSize - 100) + Read(100) + Size(baseSize - 200) + Seek(100, io.SeekCurrent) + Size(baseSize - 300) + Read(100) + Size(baseSize - 400) + } + // case 7: Stat -> ReadAll -> ReadAt + { + New() + Size(baseSize) + ReadAll() + ReadAt(100, 100) + } + // case 8: ReadAll -> ReadAt + { + New() + ReadAll() + ReadAt(100, 100) + } + // case9: Seek first + { + New() + Seek(100, io.SeekCurrent) + Size(baseSize - 100) + Read(100) + Size(baseSize - 200) + } + } +} + // Reproduces issue https://github.com/minio/minio-go/issues/1137 func testGetObjectReadAtWhenEOFWasReached() { // initialize logging params @@ -5746,7 +6131,7 @@ func testGetObjectReadAtWhenEOFWasReached() { return } - if st.Size != int64(bufSize) { + if st.Size != (int64(bufSize) - int64(len(buf1))) { logError(testName, function, args, startTime, "", "Number of bytes in stat does not match, expected "+string(int64(bufSize))+", got "+string(st.Size), err) return } @@ -6527,7 +6912,7 @@ func testSSECEncryptedGetObjectReadSeekFunctional() { } if st.Size != int64(bufSize) { - logError(testName, function, args, startTime, "", "Number of bytes does not match, expected "+string(int64(bufSize))+", got "+string(st.Size), err) + logError(testName, function, args, startTime, "", "Number of bytes does not match, expected "+strconv.Itoa(bufSize)+", got "+strconv.FormatInt(st.Size, 10), err) return } @@ -6563,17 +6948,20 @@ func testSSECEncryptedGetObjectReadSeekFunctional() { {0, 0, 0, nil, true, 0, 0}, // Start from offset 2048, fetch data and compare {2048, 0, 2048, nil, true, 2048, bufSize}, - // Start from offset larger than possible + // Start from offset larger than possible: Seek rejects it with io.EOF + // and keeps the offset unchanged. {int64(bufSize) + 1024, 0, 0, io.EOF, false, 0, 0}, // Move to offset 0 without comparing {0, 0, 0, nil, false, 0, 0}, // Move one step forward and compare {1, 1, 1, nil, true, 1, bufSize}, - // Move larger than possible + // Move larger than possible: Seek returns io.EOF. {int64(bufSize), 1, 0, io.EOF, false, 0, 0}, - // Provide negative offset with CUR_SEEK - {int64(-1), 1, 0, fmt.Errorf("Negative position not allowed for 1"), false, 0, 0}, - // Test with whence SEEK_END and with positive offset + // Provide negative offset with CUR_SEEK: valid since the resulting + // absolute position is within the object. + {int64(-1), 1, int64(bufSize) - 1, nil, false, 0, 0}, + // Test with whence SEEK_END and with positive offset: Seek returns + // io.EOF. {1024, 2, 0, io.EOF, false, 0, 0}, // Test with whence SEEK_END and with negative offset {-1024, 2, int64(bufSize) - 1024, nil, true, bufSize - 1024, bufSize}, @@ -6581,9 +6969,18 @@ func testSSECEncryptedGetObjectReadSeekFunctional() { {-int64(bufSize) * 2, 2, 0, fmt.Errorf("Seeking at negative offset not allowed for 2"), false, 0, 0}, // Test with invalid whence {0, 3, 0, fmt.Errorf("Invalid whence 3"), false, 0, 0}, + // Seek to exactly the object end; the subsequent read reports io.EOF. + {0, 2, int64(bufSize), nil, false, 0, 0}, } for i, testCase := range testCases { + // Snapshot the cursor so rejected seeks can be asserted side-effect + // free. + prevPos, err := r.Seek(0, io.SeekCurrent) + if err != nil { + logError(testName, function, args, startTime, "", fmt.Sprintf("Test %d, reading the current position failed", i+1), err) + return + } // Perform seek operation n, err := r.Seek(testCase.offset, testCase.whence) if err != nil && testCase.err == nil { @@ -6605,6 +7002,12 @@ func testSSECEncryptedGetObjectReadSeekFunctional() { fmt.Sprintf("Test %d, unexpected err value: expected: %s, found: %s", i+1, testCase.err, err), err) return } + // A rejected seek must leave the cursor unchanged. + curPos, cerr := r.Seek(0, io.SeekCurrent) + if cerr != nil || curPos != prevPos { + logError(testName, function, args, startTime, "", fmt.Sprintf("Test %d, cursor after rejected seek: expected %d, got %d", i+1, prevPos, curPos), cerr) + return + } } // Check the returned seek pos if n != testCase.pos { @@ -6616,6 +7019,15 @@ func testSSECEncryptedGetObjectReadSeekFunctional() { if testCase.shouldCmp { cmpData(r, testCase.start, testCase.end) } + // A successful seek to the object end must defer io.EOF to the + // subsequent read. + if !testCase.shouldCmp && testCase.err == nil && testCase.pos >= int64(bufSize) { + readN, readErr := r.Read(make([]byte, 1)) + if readN != 0 || readErr != io.EOF { + logError(testName, function, args, startTime, "", fmt.Sprintf("Test %d, read after seek to object end expected zero bytes and io.EOF, got %d bytes and %v", i+1, readN, readErr), readErr) + return + } + } } logSuccess(testName, function, args, startTime) @@ -6693,7 +7105,7 @@ func testSSES3EncryptedGetObjectReadSeekFunctional() { } if st.Size != int64(bufSize) { - logError(testName, function, args, startTime, "", "Number of bytes does not match, expected "+string(int64(bufSize))+", got "+string(st.Size), err) + logError(testName, function, args, startTime, "", "Number of bytes does not match, expected "+strconv.Itoa(bufSize)+", got "+strconv.FormatInt(st.Size, 10), err) return } @@ -6729,17 +7141,20 @@ func testSSES3EncryptedGetObjectReadSeekFunctional() { {0, 0, 0, nil, true, 0, 0}, // Start from offset 2048, fetch data and compare {2048, 0, 2048, nil, true, 2048, bufSize}, - // Start from offset larger than possible + // Start from offset larger than possible: Seek rejects it with io.EOF + // and keeps the offset unchanged. {int64(bufSize) + 1024, 0, 0, io.EOF, false, 0, 0}, // Move to offset 0 without comparing {0, 0, 0, nil, false, 0, 0}, // Move one step forward and compare {1, 1, 1, nil, true, 1, bufSize}, - // Move larger than possible + // Move larger than possible: Seek returns io.EOF. {int64(bufSize), 1, 0, io.EOF, false, 0, 0}, - // Provide negative offset with CUR_SEEK - {int64(-1), 1, 0, fmt.Errorf("Negative position not allowed for 1"), false, 0, 0}, - // Test with whence SEEK_END and with positive offset + // Provide negative offset with CUR_SEEK: valid since the resulting + // absolute position is within the object. + {int64(-1), 1, int64(bufSize) - 1, nil, false, 0, 0}, + // Test with whence SEEK_END and with positive offset: Seek returns + // io.EOF. {1024, 2, 0, io.EOF, false, 0, 0}, // Test with whence SEEK_END and with negative offset {-1024, 2, int64(bufSize) - 1024, nil, true, bufSize - 1024, bufSize}, @@ -6747,9 +7162,18 @@ func testSSES3EncryptedGetObjectReadSeekFunctional() { {-int64(bufSize) * 2, 2, 0, fmt.Errorf("Seeking at negative offset not allowed for 2"), false, 0, 0}, // Test with invalid whence {0, 3, 0, fmt.Errorf("Invalid whence 3"), false, 0, 0}, + // Seek to exactly the object end; the subsequent read reports io.EOF. + {0, 2, int64(bufSize), nil, false, 0, 0}, } for i, testCase := range testCases { + // Snapshot the cursor so rejected seeks can be asserted side-effect + // free. + prevPos, err := r.Seek(0, io.SeekCurrent) + if err != nil { + logError(testName, function, args, startTime, "", fmt.Sprintf("Test %d, reading the current position failed", i+1), err) + return + } // Perform seek operation n, err := r.Seek(testCase.offset, testCase.whence) if err != nil && testCase.err == nil { @@ -6771,6 +7195,12 @@ func testSSES3EncryptedGetObjectReadSeekFunctional() { fmt.Sprintf("Test %d, unexpected err value: expected: %s, found: %s", i+1, testCase.err, err), err) return } + // A rejected seek must leave the cursor unchanged. + curPos, cerr := r.Seek(0, io.SeekCurrent) + if cerr != nil || curPos != prevPos { + logError(testName, function, args, startTime, "", fmt.Sprintf("Test %d, cursor after rejected seek: expected %d, got %d", i+1, prevPos, curPos), cerr) + return + } } // Check the returned seek pos if n != testCase.pos { @@ -6782,6 +7212,15 @@ func testSSES3EncryptedGetObjectReadSeekFunctional() { if testCase.shouldCmp { cmpData(r, testCase.start, testCase.end) } + // A successful seek to the object end must defer io.EOF to the + // subsequent read. + if !testCase.shouldCmp && testCase.err == nil && testCase.pos >= int64(bufSize) { + readN, readErr := r.Read(make([]byte, 1)) + if readN != 0 || readErr != io.EOF { + logError(testName, function, args, startTime, "", fmt.Sprintf("Test %d, read after seek to object end expected zero bytes and io.EOF, got %d bytes and %v", i+1, readN, readErr), readErr) + return + } + } } logSuccess(testName, function, args, startTime) @@ -6879,7 +7318,7 @@ func testSSECEncryptedGetObjectReadAtFunctional() { } if st.Size != int64(bufSize) { - logError(testName, function, args, startTime, "", "Number of bytes in stat does not match, expected "+string(int64(bufSize))+", got "+string(st.Size), err) + logError(testName, function, args, startTime, "", "Number of bytes in stat does not match, expected "+strconv.Itoa(bufSize)+", got "+strconv.Itoa(int(st.Size)), err) return } @@ -8856,7 +9295,7 @@ func testGetObjectReadSeekFunctionalV2() { } if st.Size != int64(bufSize) { - logError(testName, function, args, startTime, "", "Number of bytes in stat does not match, expected "+string(int64(bufSize))+" got "+string(st.Size), err) + logError(testName, function, args, startTime, "", "Number of bytes in stat does not match, expected "+strconv.Itoa(bufSize)+" got "+strconv.FormatInt(st.Size, 10), err) return } @@ -8867,7 +9306,7 @@ func testGetObjectReadSeekFunctionalV2() { return } if n != offset { - logError(testName, function, args, startTime, "", "Number of seeked bytes does not match, expected "+string(offset)+" got "+string(n), err) + logError(testName, function, args, startTime, "", "Number of seeked bytes does not match, expected "+strconv.FormatInt(offset, 10)+" got "+strconv.FormatInt(n, 10), err) return } n, err = r.Seek(0, 1) @@ -8876,12 +9315,44 @@ func testGetObjectReadSeekFunctionalV2() { return } if n != offset { - logError(testName, function, args, startTime, "", "Number of seeked bytes does not match, expected "+string(offset)+" got "+string(n), err) + logError(testName, function, args, startTime, "", "Number of seeked bytes does not match, expected "+strconv.FormatInt(offset, 10)+" got "+strconv.FormatInt(n, 10), err) return } - _, err = r.Seek(offset, 2) - if err == nil { - logError(testName, function, args, startTime, "", "Seek on positive offset for whence '2' should error out", err) + // Seeking past the object end with SEEK_END is rejected with io.EOF and + // leaves the offset unchanged. + n, err = r.Seek(offset, 2) + if err != io.EOF { + logError(testName, function, args, startTime, "", "Seek past object end should return io.EOF", err) + return + } + if n != 0 { + logError(testName, function, args, startTime, "", "Seek past object end should return offset 0, got "+strconv.FormatInt(n, 10), err) + return + } + // A rejected seek must leave the cursor unchanged. + n, err = r.Seek(0, 1) + if err != nil { + logError(testName, function, args, startTime, "", "Seek failed", err) + return + } + if n != offset { + logError(testName, function, args, startTime, "", "Cursor moved after rejected seek, expected "+strconv.FormatInt(offset, 10)+" got "+strconv.FormatInt(n, 10), err) + return + } + // Seeking to exactly the object end succeeds; the subsequent read reports + // io.EOF. + n, err = r.Seek(0, 2) + if err != nil { + logError(testName, function, args, startTime, "", "Seek failed", err) + return + } + if n != st.Size { + logError(testName, function, args, startTime, "", "Number of seeked bytes does not match, expected "+strconv.FormatInt(st.Size, 10)+" got "+strconv.FormatInt(n, 10), err) + return + } + readN, readErr := r.Read(make([]byte, 1)) + if readN != 0 || readErr != io.EOF { + logError(testName, function, args, startTime, "", "Read after seeking to object end should return zero bytes and EOF", readErr) return } n, err = r.Seek(-offset, 2) @@ -8890,7 +9361,7 @@ func testGetObjectReadSeekFunctionalV2() { return } if n != st.Size-offset { - logError(testName, function, args, startTime, "", "Number of seeked bytes does not match, expected "+string(st.Size-offset)+" got "+string(n), err) + logError(testName, function, args, startTime, "", "Number of seeked bytes does not match, expected "+strconv.FormatInt(st.Size-offset, 10)+" got "+strconv.FormatInt(n, 10), err) return } @@ -8913,7 +9384,7 @@ func testGetObjectReadSeekFunctionalV2() { return } if n != (offset - 1) { - logError(testName, function, args, startTime, "", "Number of seeked bytes does not match, expected "+string(offset-1)+" got "+string(n), err) + logError(testName, function, args, startTime, "", "Number of seeked bytes does not match, expected "+strconv.FormatInt(offset-1, 10)+" got "+strconv.FormatInt(n, 10), err) return } @@ -15084,6 +15555,7 @@ func main() { testMakeBucketError() testMakeBucketRegions() testPutObjectWithMetadata() + testGetObjectWithRange() testPutObjectReadAt() testPutObjectStreaming() testPutObjectPreconditionOnNonExistent() @@ -15122,6 +15594,7 @@ func main() { testRemoveObjects() testRemoveObjectsIter() testListObjectVersions() + testStatObjectResponseHeaders() testStatObjectWithVersioning() testGetObjectWithVersioning() testCopyObjectWithVersioning() diff --git a/vendor/github.com/minio/minio-go/v7/hook-reader.go b/vendor/github.com/minio/minio-go/v7/hook-reader.go index 06dbbb74d70..0d78e9afff4 100644 --- a/vendor/github.com/minio/minio-go/v7/hook-reader.go +++ b/vendor/github.com/minio/minio-go/v7/hook-reader.go @@ -25,22 +25,31 @@ import ( // hookReader hooks additional reader in the source stream. It is // useful for making progress bars. Second reader is appropriately // notified about the exact number of bytes read from the primary -// source on each Read operation. +// source on each Read operation. It deliberately implements neither +// io.Seeker nor io.Closer: retry logic treats a seekable body as +// rewindable, and executeMethod closes request bodies that implement +// io.Closer — a caller-supplied reader must be shielded from both. type hookReader struct { source io.Reader hook io.Reader } +// hookReadSeeker extends hookReader with seeking support. It is +// constructed only when the source implements io.Seeker, so a wrapped +// reader exposes Seek if and only if it can actually rewind. This lets +// retry logic disable retries for non-seekable bodies instead of +// retrying over a drained reader. +type hookReadSeeker struct { + hookReader + seeker io.Seeker +} + // Seek implements io.Seeker. Seeks source first, and if necessary // seeks hook if Seek method is appropriately found. -func (hr *hookReader) Seek(offset int64, whence int) (n int64, err error) { - // Verify for source has embedded Seeker, use it. - sourceSeeker, ok := hr.source.(io.Seeker) - if ok { - n, err = sourceSeeker.Seek(offset, whence) - if err != nil { - return 0, err - } +func (hr *hookReadSeeker) Seek(offset int64, whence int) (n int64, err error) { + n, err = hr.seeker.Seek(offset, whence) + if err != nil { + return 0, err } if hr.hook != nil { @@ -53,7 +62,7 @@ func (hr *hookReader) Seek(offset int64, whence int) (n int64, err error) { return 0, err } if n != m { - return 0, fmt.Errorf("hook seeker seeked %d bytes, expected source %d bytes", m, n) + return 0, fmt.Errorf("hook seeker sought to offset %d, expected source offset %d", m, n) } } } @@ -80,14 +89,13 @@ func (hr *hookReader) Read(b []byte) (n int, err error) { return n, err } -// newHook returns a io.ReadSeeker which implements hookReader that -// reports the data read from the source to the hook. +// newHook returns an io.Reader that reports the data read from the +// source to the hook. The returned reader implements io.Seeker only +// when the source does. func newHook(source, hook io.Reader) io.Reader { - if hook == nil { - return &hookReader{source: source} - } - return &hookReader{ - source: source, - hook: hook, + hr := hookReader{source: source, hook: hook} + if seeker, ok := source.(io.Seeker); ok { + return &hookReadSeeker{hookReader: hr, seeker: seeker} } + return &hr } diff --git a/vendor/github.com/minio/minio-go/v7/pkg/credentials/assume_role.go b/vendor/github.com/minio/minio-go/v7/pkg/credentials/assume_role.go index 415b0709520..41225e4cf2f 100644 --- a/vendor/github.com/minio/minio-go/v7/pkg/credentials/assume_role.go +++ b/vendor/github.com/minio/minio-go/v7/pkg/credentials/assume_role.go @@ -19,6 +19,7 @@ package credentials import ( "bytes" + "context" "crypto/sha256" "encoding/hex" "encoding/xml" @@ -142,7 +143,7 @@ func closeResponse(resp *http.Response) { } } -func getAssumeRoleCredentials(clnt *http.Client, endpoint string, opts STSAssumeRoleOptions) (AssumeRoleResponse, error) { +func getAssumeRoleCredentials(ctx context.Context, clnt *http.Client, endpoint string, opts STSAssumeRoleOptions) (AssumeRoleResponse, error) { v := url.Values{} v.Set("Action", "AssumeRole") v.Set("Version", STSVersion) @@ -180,7 +181,7 @@ func getAssumeRoleCredentials(clnt *http.Client, endpoint string, opts STSAssume } postBody.Seek(0, 0) - req, err := http.NewRequest(http.MethodPost, u.String(), postBody) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, u.String(), postBody) if err != nil { return AssumeRoleResponse{}, err } @@ -245,7 +246,7 @@ func (m *STSAssumeRole) RetrieveWithCredContext(cc *CredContext) (Value, error) return Value{}, errors.New("STS endpoint unknown") } - a, err := getAssumeRoleCredentials(client, stsEndpoint, m.Options) + a, err := getAssumeRoleCredentials(cc.requestContext(), client, stsEndpoint, m.Options) if err != nil { return Value{}, err } diff --git a/vendor/github.com/minio/minio-go/v7/pkg/credentials/credentials-sso.sample b/vendor/github.com/minio/minio-go/v7/pkg/credentials/credentials-sso.sample new file mode 100644 index 00000000000..46af924b30a --- /dev/null +++ b/vendor/github.com/minio/minio-go/v7/pkg/credentials/credentials-sso.sample @@ -0,0 +1,57 @@ +[profile p1] +sso_session = main +sso_account_id = 123456789 +sso_role_name = myrole + +[sso-session main] +sso_region = us-test-2 +sso_start_url = https://testacct.awsapps.com/start + +[profile p2-legacy] +sso_start_url = https://legacy.awsapps.com/start +sso_region = us-test-1 +sso_account_id = 987654321 +sso_role_name = legacyrole + +[profile p3-broken] +sso_account_id = 111111111 +sso_role_name = brokenrole + +[profile p4-noregion] +sso_start_url = https://noregion.awsapps.com/start +sso_account_id = 222222222 +sso_role_name = noregionrole + +[profile p5-ghost-session] +sso_session = ghost +sso_account_id = 333333333 +sso_role_name = ghostrole + +[profile p6-norole] +sso_start_url = https://norole.awsapps.com/start +sso_region = us-test-1 +sso_account_id = 444444444 + +[profile p7-noaccount] +sso_session = main +sso_role_name = noaccountrole + +[profile p8-mixed] +sso_start_url = https://mixed.awsapps.com/start +aws_access_key_id = mixedAccessKey +aws_secret_access_key = mixedSecret + +[profile p9-mixed-complete] +sso_session = main +sso_account_id = 555555555 +sso_role_name = mixedcompleterole +aws_access_key_id = completeAccessKey +aws_secret_access_key = completeSecret + +[profile p10-partial-key] +sso_start_url = https://partial.awsapps.com/start +aws_access_key_id = partialAccessKey + +[profile p11-partial-secret] +sso_session = main +aws_secret_access_key = partialSecret diff --git a/vendor/github.com/minio/minio-go/v7/pkg/credentials/credentials.go b/vendor/github.com/minio/minio-go/v7/pkg/credentials/credentials.go index 52aff9a57f6..dfc25c072a3 100644 --- a/vendor/github.com/minio/minio-go/v7/pkg/credentials/credentials.go +++ b/vendor/github.com/minio/minio-go/v7/pkg/credentials/credentials.go @@ -18,6 +18,7 @@ package credentials import ( + "context" "net/http" "sync" "time" @@ -85,6 +86,21 @@ type CredContext struct { // Endpoint specifies the MinIO endpoint that will be used if no // explicit endpoint is provided. Endpoint string + + // Context is the optional caller context. Cancellation and deadlines + // on it propagate to the HTTP requests the built-in providers make + // to fetch credentials, in addition to any provider-level timeout + // bound. A nil Context means no caller cancellation applies. + Context context.Context +} + +// requestContext returns the caller context carried by cc, or +// context.Background() when no Context is set. +func (cc *CredContext) requestContext() context.Context { + if cc.Context == nil { + return context.Background() + } + return cc.Context } // A Expiry provides shared expiration logic to be used by credentials diff --git a/vendor/github.com/minio/minio-go/v7/pkg/credentials/file_aws_credentials.go b/vendor/github.com/minio/minio-go/v7/pkg/credentials/file_aws_credentials.go index 2d0336f92ec..204bcfa2b1a 100644 --- a/vendor/github.com/minio/minio-go/v7/pkg/credentials/file_aws_credentials.go +++ b/vendor/github.com/minio/minio-go/v7/pkg/credentials/file_aws_credentials.go @@ -18,8 +18,15 @@ package credentials import ( + "context" + "crypto/sha1" + "encoding/hex" "encoding/json" "errors" + "fmt" + "io" + "io/fs" + "net/http" "os" "os/exec" "path/filepath" @@ -29,7 +36,10 @@ import ( "gopkg.in/ini.v1" ) -// A externalProcessCredentials stores the output of a credential_process +// ssoPortalRequestTimeout bounds the AWS SSO portal role-credentials request. +const ssoPortalRequestTimeout = time.Minute + +// An externalProcessCredentials stores the output of a credential_process type externalProcessCredentials struct { Version int SessionToken string @@ -38,6 +48,34 @@ type externalProcessCredentials struct { Expiration time.Time } +// An ssoCredentials stores the response of fetching role credentials for +// an AWS SSO role from the SSO portal. +type ssoCredentials struct { + RoleCredentials ssoRoleCredentials `json:"roleCredentials"` +} + +// An ssoRoleCredentials stores the role-specific credentials portion of +// an SSO role credentials response. Expiration is milliseconds since +// the Unix epoch. +type ssoRoleCredentials struct { + AccessKeyID string `json:"accessKeyId"` + Expiration int64 `json:"expiration"` + SecretAccessKey string `json:"secretAccessKey"` + SessionToken string `json:"sessionToken"` +} + +func (s ssoRoleCredentials) expirationTime() time.Time { + return time.Unix(0, s.Expiration*int64(time.Millisecond)) +} + +// ssoCachedToken is the subset of the cached token file written by +// `aws sso login` under ~/.aws/sso/cache/ that we need. +type ssoCachedToken struct { + AccessToken string `json:"accessToken"` + ExpiresAt time.Time `json:"expiresAt"` + Region string `json:"region"` +} + // A FileAWSCredentials retrieves credentials from the current user's home // directory, and keeps track if those credentials are expired. // @@ -47,10 +85,15 @@ type FileAWSCredentials struct { // Path to the shared credentials file. // - // If empty will look for "AWS_SHARED_CREDENTIALS_FILE" env variable. If the - // env value is empty will default to current user's home directory. - // Linux/OSX: "$HOME/.aws/credentials" - // Windows: "%USERPROFILE%\.aws\credentials" + // If empty, the default AWS files are merged instead: the AWS config + // file ("AWS_CONFIG_FILE" env variable or "$HOME/.aws/config") loaded + // first, then the shared credentials file + // ("AWS_SHARED_CREDENTIALS_FILE" env variable or + // "$HOME/.aws/credentials") overriding matching keys, the same + // resolution the AWS SDK uses. Profiles written by `aws configure sso` + // live in the config file and are discovered this way. + // + // If set, only this one file is read. Filename string // AWS Profile to extract credentials from the shared credentials file. If empty @@ -60,6 +103,14 @@ type FileAWSCredentials struct { // retrieved states if the credentials have been successfully retrieved. retrieved bool + + // overrideSSOCacheDir overrides, for tests, the directory holding the + // cached SSO tokens (defaults to ~/.aws/sso/cache). + overrideSSOCacheDir string + + // overrideSSOPortalURL overrides, for tests, the AWS SSO portal URL + // serving role credentials. + overrideSSOPortalURL string } // NewFileAWSCredentials returns a pointer to a new Credentials object @@ -71,27 +122,27 @@ func NewFileAWSCredentials(filename, profile string) *Credentials { }) } -func (p *FileAWSCredentials) retrieve() (Value, error) { - if p.Filename == "" { - p.Filename = os.Getenv("AWS_SHARED_CREDENTIALS_FILE") - if p.Filename == "" { - homeDir, err := os.UserHomeDir() - if err != nil { - return Value{}, err - } - p.Filename = filepath.Join(homeDir, ".aws", "credentials") - } - } - if p.Profile == "" { - p.Profile = os.Getenv("AWS_PROFILE") - if p.Profile == "" { - p.Profile = "default" +func (p *FileAWSCredentials) retrieve(cc *CredContext) (Value, error) { + profile := p.Profile + if profile == "" { + profile = os.Getenv("AWS_PROFILE") + if profile == "" { + profile = "default" } } p.retrieved = false - iniProfile, err := loadProfile(p.Filename, p.Profile) + var ( + iniConfig *ini.File + iniProfile *ini.Section + err error + ) + if p.Filename != "" { + iniConfig, iniProfile, err = loadProfile(p.Filename, profile) + } else { + iniConfig, iniProfile, err = loadDefaultProfiles(profile) + } if err != nil { return Value{}, err } @@ -103,10 +154,53 @@ func (p *FileAWSCredentials) retrieve() (Value, error) { // Default to empty string if not found. token := iniProfile.Key("aws_session_token") - // If credential_process is defined, obtain credentials by executing - // the external process + // A complete static key pair takes precedence over SSO configuration + // and credential_process in the same profile, matching aws-sdk-go-v2's + // resolution order: static credentials, then SSO, then + // credential_process. + hasStaticKeys := id.String() != "" && secret.String() != "" + + // Exactly one half of a static key pair is never usable and poisons + // downstream consumers — Chain accepts a Value when either field is + // set — so it is rejected before any resolution, matching + // aws-sdk-go-v2's partial-credentials validation. + if !hasStaticKeys && (id.String() != "" || secret.String() != "") { + return Value{}, errors.New("profile has partial static credentials: aws_access_key_id and aws_secret_access_key must both be set") + } + + // If the profile is configured for AWS SSO, obtain credentials from the + // token cached by `aws sso login`. + if !hasStaticKeys && iniProfile.Key("sso_role_name").String() != "" { + ssoCreds, err := p.getSSOCredentials(cc, iniConfig, iniProfile) + if err != nil { + return Value{}, err + } + expiration := ssoCreds.RoleCredentials.expirationTime() + p.retrieved = true + p.SetExpiration(expiration, DefaultExpiryWindow) + return Value{ + AccessKeyID: ssoCreds.RoleCredentials.AccessKeyID, + SecretAccessKey: ssoCreds.RoleCredentials.SecretAccessKey, + SessionToken: ssoCreds.RoleCredentials.SessionToken, + Expiration: expiration, + SignerType: SignatureV4, + }, nil + } + + // A profile carrying SSO configuration without sso_role_name cannot + // engage the SSO flow above; without a complete static key pair the + // values below would be anonymous. + if !hasStaticKeys && + (iniProfile.Key("sso_session").String() != "" || iniProfile.Key("sso_start_url").String() != "" || + iniProfile.Key("sso_account_id").String() != "" || iniProfile.Key("sso_region").String() != "") { + return Value{}, errors.New("profile has SSO configuration but no sso_role_name, and no complete static credentials") + } + + // If credential_process is defined, obtain credentials by executing the + // external process. Static credentials and SSO in the same profile both + // take precedence over it, matching aws-sdk-go-v2. credentialProcess := strings.TrimSpace(iniProfile.Key("credential_process").String()) - if credentialProcess != "" { + if !hasStaticKeys && credentialProcess != "" { args := strings.Fields(credentialProcess) if len(args) <= 1 { return Value{}, errors.New("invalid credential process args") @@ -131,6 +225,7 @@ func (p *FileAWSCredentials) retrieve() (Value, error) { SignerType: SignatureV4, }, nil } + p.retrieved = true return Value{ AccessKeyID: id.String(), @@ -140,28 +235,319 @@ func (p *FileAWSCredentials) retrieve() (Value, error) { }, nil } +// getSSOCredentials fetches role credentials for an SSO-configured profile +// from the AWS SSO portal, using the access token cached by `aws sso login`. +func (p *FileAWSCredentials) getSSOCredentials(cc *CredContext, iniConfig *ini.File, iniProfile *ini.Section) (ssoCredentials, error) { + ssoAccountID := iniProfile.Key("sso_account_id").String() + ssoRoleName := iniProfile.Key("sso_role_name").String() + if ssoAccountID == "" { + return ssoCredentials{}, errors.New("profile defines sso_role_name but no sso_account_id") + } + + // Modern config: the profile references an [sso-session ] section + // and the cached token file is named after the SHA1 of the session name. + // Legacy config: sso_start_url/sso_region live directly on the profile + // and the cached token file is named after the SHA1 of the start URL. + ssoSessionName := iniProfile.Key("sso_session").String() + cacheKey := ssoSessionName + ssoRegion := iniProfile.Key("sso_region").String() + if ssoSessionName != "" { + if sessionSection, err := iniConfig.GetSection("sso-session " + ssoSessionName); err == nil { + // aws-sdk-go-v2 rejects profile sso_region/sso_start_url + // values that contradict the sso-session; guessing between + // the two could silently query the wrong portal. + if region := sessionSection.Key("sso_region").String(); region != "" { + if ssoRegion != "" && ssoRegion != region { + return ssoCredentials{}, fmt.Errorf("sso_region %q in profile must match sso_region %q in sso-session %q", ssoRegion, region, ssoSessionName) + } + ssoRegion = region + } + if sessionStartURL := sessionSection.Key("sso_start_url").String(); sessionStartURL != "" { + if profileStartURL := iniProfile.Key("sso_start_url").String(); profileStartURL != "" && profileStartURL != sessionStartURL { + return ssoCredentials{}, fmt.Errorf("sso_start_url %q in profile must match sso_start_url %q in sso-session %q", profileStartURL, sessionStartURL, ssoSessionName) + } + } + } + } else { + startURL := iniProfile.Key("sso_start_url").String() + if startURL == "" { + return ssoCredentials{}, errors.New("profile defines sso_role_name but neither sso_session nor sso_start_url") + } + cacheKey = startURL + } + + hash := sha1.Sum([]byte(cacheKey)) + cachedTokenFilename := hex.EncodeToString(hash[:]) + ".json" + + cacheDir := p.overrideSSOCacheDir + if cacheDir == "" { + homeDir, err := os.UserHomeDir() + if err != nil { + return ssoCredentials{}, fmt.Errorf("getting home dir: %w", err) + } + cacheDir = filepath.Join(homeDir, ".aws", "sso", "cache") + } + cachedTokenPath := filepath.Join(cacheDir, cachedTokenFilename) + cachedTokenRaw, err := os.ReadFile(cachedTokenPath) + if err != nil { + return ssoCredentials{}, fmt.Errorf("reading cached SSO token %q (try `aws sso login`): %w", cachedTokenPath, err) + } + + var cachedToken ssoCachedToken + if err := json.Unmarshal(cachedTokenRaw, &cachedToken); err != nil { + return ssoCredentials{}, fmt.Errorf("parsing cached SSO token %q: %w", cachedTokenPath, err) + } + now := time.Now + if p.CurrentTime != nil { + now = p.CurrentTime + } + if cachedToken.ExpiresAt.Before(now()) { + return ssoCredentials{}, errors.New("cached SSO token is expired, refresh it with `aws sso login`") + } + + if ssoRegion == "" { + ssoRegion = cachedToken.Region + } + if ssoRegion == "" { + return ssoCredentials{}, errors.New("unable to determine AWS SSO region from profile, sso-session or cached token") + } + + portalURL := p.overrideSSOPortalURL + if portalURL == "" { + portalURL = ssoPortalBaseURL(ssoRegion) + } + if cc == nil { + cc = defaultCredContext + } + ctx, cancel := context.WithTimeout(cc.requestContext(), ssoPortalRequestTimeout) + defer cancel() + req, err := http.NewRequestWithContext(ctx, http.MethodGet, portalURL+"/federation/credentials", nil) + if err != nil { + return ssoCredentials{}, fmt.Errorf("creating SSO role credentials request: %w", err) + } + req.Header.Set("x-amz-sso_bearer_token", cachedToken.AccessToken) + query := req.URL.Query() + query.Add("account_id", ssoAccountID) + query.Add("role_name", ssoRoleName) + req.URL.RawQuery = query.Encode() + + client := cc.Client + if client == nil { + client = defaultCredContext.Client + } + resp, err := client.Do(req) + if err != nil { + return ssoCredentials{}, fmt.Errorf("fetching SSO role credentials: %w", err) + } + defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + body, _ := io.ReadAll(io.LimitReader(resp.Body, 4<<10)) + return ssoCredentials{}, fmt.Errorf("fetching SSO role credentials: %s: %s", resp.Status, strings.TrimSpace(string(body))) + } + + var ssoCreds ssoCredentials + if err := json.NewDecoder(io.LimitReader(resp.Body, 1<<20)).Decode(&ssoCreds); err != nil { + return ssoCredentials{}, fmt.Errorf("parsing SSO role credentials response: %w", err) + } + if ssoCreds.RoleCredentials.AccessKeyID == "" || ssoCreds.RoleCredentials.SecretAccessKey == "" { + return ssoCredentials{}, errors.New("SSO portal returned empty role credentials") + } + return ssoCreds, nil +} + +// ssoPortalBaseURL returns the AWS SSO portal endpoint for region. The DNS +// suffix follows the region's AWS partition per aws-sdk-go-v2 endpoint +// metadata; regions of unlisted partitions, including aws-us-gov, use the +// standard amazonaws.com suffix. +func ssoPortalBaseURL(region string) string { + suffix := "amazonaws.com" + switch { + case strings.HasPrefix(region, "cn-"): + suffix = "amazonaws.com.cn" + case strings.HasPrefix(region, "us-iso-"): + suffix = "c2s.ic.gov" + case strings.HasPrefix(region, "us-isob-"): + suffix = "sc2s.sgov.gov" + case strings.HasPrefix(region, "eu-isoe-"): + suffix = "cloud.adc-e.uk" + case strings.HasPrefix(region, "us-isof-"): + suffix = "csp.hci.ic.gov" + case strings.HasPrefix(region, "eusc-"): + suffix = "amazonaws.eu" + } + return fmt.Sprintf("https://portal.sso.%s.%s", region, suffix) +} + // Retrieve reads and extracts the shared credentials from the current // users home directory. +// +// Deprecated: Retrieve() exists for historical compatibility and should not +// be used. To get new credentials use the RetrieveWithCredContext function. func (p *FileAWSCredentials) Retrieve() (Value, error) { - return p.retrieve() + return p.retrieve(nil) } -// RetrieveWithCredContext is like Retrieve(), cred context is no-op for File credentials -func (p *FileAWSCredentials) RetrieveWithCredContext(_ *CredContext) (Value, error) { - return p.retrieve() +// RetrieveWithCredContext retrieves credentials from the file like Retrieve, +// using the context's HTTP client for any SSO portal call. +func (p *FileAWSCredentials) RetrieveWithCredContext(cc *CredContext) (Value, error) { + return p.retrieve(cc) } -// loadProfiles loads from the file pointed to by shared credentials filename for profile. +// loadProfile loads from the file pointed to by shared credentials filename for profile. // The credentials retrieved from the profile will be returned or error. Error will be // returned if it fails to read from the file, or the data is invalid. -func loadProfile(filename, profile string) (*ini.Section, error) { +func loadProfile(filename, profile string) (*ini.File, *ini.Section, error) { config, err := ini.Load(filename) if err != nil { - return nil, err + return nil, nil, err } iniProfile, err := config.GetSection(profile) if err != nil { - return nil, err + // AWS config files (~/.aws/config) name non-default profile + // sections "profile ". + var sectionErr error + iniProfile, sectionErr = config.GetSection("profile " + profile) + if sectionErr != nil { + return nil, nil, err + } + } + return config, iniProfile, nil +} + +// loadDefaultProfiles loads profile from the default AWS files, mirroring +// the AWS SDK's shared-config resolution: the config file (AWS_CONFIG_FILE +// or ~/.aws/config) is loaded first and the shared credentials file +// (AWS_SHARED_CREDENTIALS_FILE or ~/.aws/credentials) overrides matching +// keys. A missing file is tolerated as long as the other one loads; a file +// that exists but fails to parse aborts resolution, like aws-sdk-go-v2, +// because silently skipping it could resolve credentials from the wrong +// (lower-precedence) source. +func loadDefaultProfiles(profile string) (*ini.File, *ini.Section, error) { + configFilename := os.Getenv("AWS_CONFIG_FILE") + credsFilename := os.Getenv("AWS_SHARED_CREDENTIALS_FILE") + var loadErrs []error + if configFilename == "" || credsFilename == "" { + // A home-dir failure only rules out the files defaulted under it; + // a file named via env var must still load. + homeDir, err := os.UserHomeDir() + if err != nil { + loadErrs = append(loadErrs, err) + } else { + if configFilename == "" { + configFilename = filepath.Join(homeDir, ".aws", "config") + } + if credsFilename == "" { + credsFilename = filepath.Join(homeDir, ".aws", "credentials") + } + } + } + + merged := ini.Empty() + loaded := false + if configFilename != "" { + config, err := ini.Load(configFilename) + switch { + case err == nil: + loaded = true + mergeAWSConfigSections(merged, config) + case errors.Is(err, fs.ErrNotExist): + loadErrs = append(loadErrs, err) + default: + return nil, nil, err + } + } + if credsFilename != "" { + config, err := ini.Load(credsFilename) + switch { + case err == nil: + loaded = true + mergeAWSCredentialsSections(merged, config) + case errors.Is(err, fs.ErrNotExist): + loadErrs = append(loadErrs, err) + default: + return nil, nil, err + } + } + if !loaded { + // Prefer the home-dir error when there is one (the informative + // failure); otherwise return the last not-exist error bare so the + // legacy os.IsNotExist probe on a missing-files result keeps working. + err := loadErrs[len(loadErrs)-1] + for _, e := range loadErrs { + if !errors.Is(e, fs.ErrNotExist) { + err = e + break + } + } + return nil, nil, err + } + iniProfile, err := merged.GetSection(profile) + if err != nil { + return nil, nil, err + } + return merged, iniProfile, nil +} + +// mergeAWSConfigSections copies the AWS config file's sections into dst +// under the SDK's config-file rules: bare sections other than "default" and +// "sso-session " are invalid profile names and ignored, and a +// "profile " section is renamed to , replacing a bare +// same-named section wholesale rather than merging with it. +func mergeAWSConfigSections(dst, src *ini.File) { + for _, section := range src.Sections() { + name := section.Name() + if name == ini.DefaultSection || strings.HasPrefix(name, "profile ") || + (!strings.EqualFold(name, "default") && !strings.HasPrefix(name, "sso-session ")) { + continue + } + copySectionKeys(dst.Section(name), section) + } + for _, section := range src.Sections() { + name := section.Name() + if !strings.HasPrefix(name, "profile ") { + continue + } + dstSection := dst.Section(strings.TrimPrefix(name, "profile ")) + for _, key := range dstSection.Keys() { + dstSection.DeleteKey(key.Name()) + } + copySectionKeys(dstSection, section) + } +} + +// mergeAWSCredentialsSections copies the shared credentials file's sections +// into dst, overriding matching keys; "profile "-prefixed section names are +// invalid in the credentials file and ignored. When a section overrides an +// existing profile, the static credentials move atomically: +// aws_access_key_id, aws_secret_access_key and aws_session_token are only +// taken from an overriding section carrying the complete key pair, so a +// partial pair cannot clobber half of an existing one. A section new to +// the merge is copied as-is; a partial pair it carries is rejected at +// resolution time, matching aws-sdk-go-v2's partial-credentials error. +func mergeAWSCredentialsSections(dst, src *ini.File) { + for _, section := range src.Sections() { + name := section.Name() + if name == ini.DefaultSection || strings.HasPrefix(name, "profile ") { + continue + } + _, err := dst.GetSection(name) + newSection := err != nil + hasPair := section.HasKey("aws_access_key_id") && section.HasKey("aws_secret_access_key") + dstSection := dst.Section(name) + for _, key := range section.Keys() { + switch key.Name() { + case "aws_access_key_id", "aws_secret_access_key", "aws_session_token": + if !newSection && !hasPair { + continue + } + } + dstSection.Key(key.Name()).SetValue(key.Value()) + } + } +} + +func copySectionKeys(dst, src *ini.Section) { + for _, key := range src.Keys() { + dst.Key(key.Name()).SetValue(key.Value()) } - return iniProfile, nil } diff --git a/vendor/github.com/minio/minio-go/v7/pkg/credentials/iam_aws.go b/vendor/github.com/minio/minio-go/v7/pkg/credentials/iam_aws.go index f4f7c8f7e29..f35d9d6598a 100644 --- a/vendor/github.com/minio/minio-go/v7/pkg/credentials/iam_aws.go +++ b/vendor/github.com/minio/minio-go/v7/pkg/credentials/iam_aws.go @@ -58,6 +58,17 @@ type IAM struct { // Region configurable custom region for STS Region string + // ExpiryWindow configures how long before the actual credential + // expiration the credentials are considered expired and refreshed. + // The zero value keeps the default behavior of refreshing once 80% + // of the credential lifetime has elapsed. A positive value refreshes + // that long before the actual expiration; a value that meets or + // exceeds the credential lifetime places the effective expiration at + // or before the moment of retrieval, so the credentials are refreshed + // on every subsequent retrieval. A negative value behaves like the + // default. + ExpiryWindow time.Duration + // Support for container authorization token https://docs.aws.amazon.com/sdkref/latest/guide/feature-container-credentials.html Container struct { AuthorizationToken string @@ -94,6 +105,15 @@ func NewIAM(endpoint string) *Credentials { }) } +// expiryWindow returns the configured ExpiryWindow, falling back to +// DefaultExpiryWindow when unset or negative. +func (m *IAM) expiryWindow() time.Duration { + if m.ExpiryWindow <= 0 { + return DefaultExpiryWindow + } + return m.ExpiryWindow +} + // RetrieveWithCredContext is like Retrieve with Cred Context func (m *IAM) RetrieveWithCredContext(cc *CredContext) (Value, error) { if cc == nil { @@ -151,6 +171,8 @@ func (m *IAM) RetrieveWithCredContext(cc *CredContext) (Value, error) { client = defaultCredContext.Client } + ctx := cc.requestContext() + endpoint := m.Endpoint switch { @@ -184,7 +206,11 @@ func (m *IAM) RetrieveWithCredContext(cc *CredContext) (Value, error) { stsWebIdentityCreds, err := creds.RetrieveWithCredContext(cc) if err == nil { - m.SetExpiration(creds.Expiration(), DefaultExpiryWindow) + // Use the raw credential expiration, not creds.Expiration(): + // the inner provider has already reduced its own expiration by + // DefaultExpiryWindow, and applying a window to the reduced + // value would compound the two. + m.SetExpiration(stsWebIdentityCreds.Expiration, m.expiryWindow()) } return stsWebIdentityCreds, err @@ -193,11 +219,11 @@ func (m *IAM) RetrieveWithCredContext(cc *CredContext) (Value, error) { endpoint = fmt.Sprintf("%s%s", DefaultECSRoleEndpoint, relativeURI) } - roleCreds, err = getEcsTaskCredentials(client, endpoint, token) + roleCreds, err = getEcsTaskCredentials(ctx, client, endpoint, token) case tokenFile != "" && fullURI != "": endpoint = fullURI - roleCreds, err = getEKSPodIdentityCredentials(client, endpoint, tokenFile) + roleCreds, err = getEKSPodIdentityCredentials(ctx, client, endpoint, tokenFile) case fullURI != "": if len(endpoint) == 0 { @@ -211,17 +237,16 @@ func (m *IAM) RetrieveWithCredContext(cc *CredContext) (Value, error) { } } - roleCreds, err = getEcsTaskCredentials(client, endpoint, token) + roleCreds, err = getEcsTaskCredentials(ctx, client, endpoint, token) default: - roleCreds, err = getCredentials(client, endpoint) + roleCreds, err = getCredentials(ctx, client, endpoint) } if err != nil { return Value{}, err } - // Expiry window is set to 10secs. - m.SetExpiration(roleCreds.Expiration, DefaultExpiryWindow) + m.SetExpiration(roleCreds.Expiration, m.expiryWindow()) return Value{ AccessKeyID: roleCreds.AccessKeyID, @@ -273,8 +298,8 @@ func getIAMRoleURL(endpoint string) (*url.URL, error) { // with the current EC2 service. If there are no credentials, // or there is an error making or receiving the request. // http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html -func listRoleNames(client *http.Client, u *url.URL, token string) ([]string, error) { - req, err := http.NewRequest(http.MethodGet, u.String(), nil) +func listRoleNames(ctx context.Context, client *http.Client, u *url.URL, token string) ([]string, error) { + req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil) if err != nil { return nil, err } @@ -303,8 +328,8 @@ func listRoleNames(client *http.Client, u *url.URL, token string) ([]string, err return credsList, nil } -func getEcsTaskCredentials(client *http.Client, endpoint, token string) (ec2RoleCredRespBody, error) { - req, err := http.NewRequest(http.MethodGet, endpoint, nil) +func getEcsTaskCredentials(ctx context.Context, client *http.Client, endpoint, token string) (ec2RoleCredRespBody, error) { + req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil) if err != nil { return ec2RoleCredRespBody{}, err } @@ -330,20 +355,20 @@ func getEcsTaskCredentials(client *http.Client, endpoint, token string) (ec2Role return respCreds, nil } -func getEKSPodIdentityCredentials(client *http.Client, endpoint string, tokenFile string) (ec2RoleCredRespBody, error) { +func getEKSPodIdentityCredentials(ctx context.Context, client *http.Client, endpoint string, tokenFile string) (ec2RoleCredRespBody, error) { if tokenFile != "" { bytes, err := os.ReadFile(tokenFile) if err != nil { return ec2RoleCredRespBody{}, fmt.Errorf("getEKSPodIdentityCredentials: failed to read token file:%s", err) } token := string(bytes) - return getEcsTaskCredentials(client, endpoint, token) + return getEcsTaskCredentials(ctx, client, endpoint, token) } return ec2RoleCredRespBody{}, fmt.Errorf("getEKSPodIdentityCredentials: no tokenFile found") } -func fetchIMDSToken(client *http.Client, endpoint string) (string, error) { - ctx, cancel := context.WithTimeout(context.Background(), time.Second) +func fetchIMDSToken(ctx context.Context, client *http.Client, endpoint string) (string, error) { + ctx, cancel := context.WithTimeout(ctx, time.Second) defer cancel() req, err := http.NewRequestWithContext(ctx, http.MethodPut, endpoint+TokenPath, nil) @@ -371,14 +396,18 @@ func fetchIMDSToken(client *http.Client, endpoint string) (string, error) { // // If the credentials cannot be found, or there is an error // reading the response an error will be returned. -func getCredentials(client *http.Client, endpoint string) (ec2RoleCredRespBody, error) { +func getCredentials(ctx context.Context, client *http.Client, endpoint string) (ec2RoleCredRespBody, error) { if endpoint == "" { endpoint = DefaultIAMRoleEndpoint } // https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html - token, err := fetchIMDSToken(client, endpoint) + token, err := fetchIMDSToken(ctx, client, endpoint) if err != nil { + // A dead caller context is not an IMDSv2 availability signal. + if cerr := ctx.Err(); cerr != nil { + return ec2RoleCredRespBody{}, fmt.Errorf("%w (imds token fetch: %v)", cerr, err) + } // Return only errors for valid situations, if the IMDSv2 is not enabled // we will not be able to get the token, in such a situation we have // to rely on IMDSv1 behavior as a fallback, this check ensures that. @@ -395,7 +424,7 @@ func getCredentials(client *http.Client, endpoint string) (ec2RoleCredRespBody, } // http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html - roleNames, err := listRoleNames(client, u, token) + roleNames, err := listRoleNames(ctx, client, u, token) if err != nil { return ec2RoleCredRespBody{}, err } @@ -415,7 +444,7 @@ func getCredentials(client *http.Client, endpoint string) (ec2RoleCredRespBody, // $ curl http://169.254.169.254/latest/meta-data/iam/security-credentials/s3access // u.Path = path.Join(u.Path, roleName) - req, err := http.NewRequest(http.MethodGet, u.String(), nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil) if err != nil { return ec2RoleCredRespBody{}, err } diff --git a/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_client_grants.go b/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_client_grants.go index ef6f436b84b..7ab7d68ef94 100644 --- a/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_client_grants.go +++ b/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_client_grants.go @@ -19,6 +19,7 @@ package credentials import ( "bytes" + "context" "encoding/xml" "errors" "fmt" @@ -100,7 +101,7 @@ func NewSTSClientGrants(stsEndpoint string, getClientGrantsTokenExpiry func() (* }), nil } -func getClientGrantsCredentials(clnt *http.Client, endpoint string, +func getClientGrantsCredentials(ctx context.Context, clnt *http.Client, endpoint string, getClientGrantsTokenExpiry func() (*ClientGrantsToken, error), ) (AssumeRoleWithClientGrantsResponse, error) { accessToken, err := getClientGrantsTokenExpiry() @@ -119,7 +120,7 @@ func getClientGrantsCredentials(clnt *http.Client, endpoint string, return AssumeRoleWithClientGrantsResponse{}, err } - req, err := http.NewRequest(http.MethodPost, u.String(), strings.NewReader(v.Encode())) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, u.String(), strings.NewReader(v.Encode())) if err != nil { return AssumeRoleWithClientGrantsResponse{}, err } @@ -179,7 +180,7 @@ func (m *STSClientGrants) RetrieveWithCredContext(cc *CredContext) (Value, error return Value{}, errors.New("STS endpoint unknown") } - a, err := getClientGrantsCredentials(client, stsEndpoint, m.GetClientGrantsTokenExpiry) + a, err := getClientGrantsCredentials(cc.requestContext(), client, stsEndpoint, m.GetClientGrantsTokenExpiry) if err != nil { return Value{}, err } diff --git a/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_custom_identity.go b/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_custom_identity.go index e9e7a1151f1..b986c175f7e 100644 --- a/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_custom_identity.go +++ b/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_custom_identity.go @@ -107,7 +107,7 @@ func (c *CustomTokenIdentity) RetrieveWithCredContext(cc *CredContext) (value Va u.RawQuery = v.Encode() - req, err := http.NewRequest(http.MethodPost, u.String(), nil) + req, err := http.NewRequestWithContext(cc.requestContext(), http.MethodPost, u.String(), nil) if err != nil { return value, err } diff --git a/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_ldap_identity.go b/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_ldap_identity.go index 7e80cd6a2ac..648c95d273a 100644 --- a/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_ldap_identity.go +++ b/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_ldap_identity.go @@ -172,7 +172,7 @@ func (k *LDAPIdentity) RetrieveWithCredContext(cc *CredContext) (value Value, er v.Set("ConfigName", k.ConfigName) } - req, err := http.NewRequest(http.MethodPost, u.String(), strings.NewReader(v.Encode())) + req, err := http.NewRequestWithContext(cc.requestContext(), http.MethodPost, u.String(), strings.NewReader(v.Encode())) if err != nil { return value, err } diff --git a/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_tls_identity.go b/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_tls_identity.go index beab4a6a648..ebaae128066 100644 --- a/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_tls_identity.go +++ b/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_tls_identity.go @@ -131,7 +131,7 @@ func (i *STSCertificateIdentity) RetrieveWithCredContext(cc *CredContext) (Value } endpointURL.RawQuery = queryValues.Encode() - req, err := http.NewRequest(http.MethodPost, endpointURL.String(), nil) + req, err := http.NewRequestWithContext(cc.requestContext(), http.MethodPost, endpointURL.String(), nil) if err != nil { return Value{}, err } diff --git a/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_web_identity.go b/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_web_identity.go index a9987255ec7..c3afdc6299d 100644 --- a/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_web_identity.go +++ b/vendor/github.com/minio/minio-go/v7/pkg/credentials/sts_web_identity.go @@ -19,6 +19,7 @@ package credentials import ( "bytes" + "context" "encoding/xml" "errors" "fmt" @@ -137,7 +138,7 @@ func WithPolicy(policy string) func(*STSWebIdentity) { } } -func getWebIdentityCredentials(clnt *http.Client, endpoint, roleARN, roleSessionName string, policy string, +func getWebIdentityCredentials(ctx context.Context, clnt *http.Client, endpoint, roleARN, roleSessionName string, policy string, getWebIDTokenExpiry func() (*WebIdentityToken, error), tokenRevokeType string, ) (AssumeRoleWithWebIdentityResponse, error) { idToken, err := getWebIDTokenExpiry() @@ -180,7 +181,7 @@ func getWebIdentityCredentials(clnt *http.Client, endpoint, roleARN, roleSession return AssumeRoleWithWebIdentityResponse{}, err } - req, err := http.NewRequest(http.MethodPost, u.String(), strings.NewReader(v.Encode())) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, u.String(), strings.NewReader(v.Encode())) if err != nil { return AssumeRoleWithWebIdentityResponse{}, err } @@ -242,7 +243,7 @@ func (m *STSWebIdentity) RetrieveWithCredContext(cc *CredContext) (Value, error) return Value{}, errors.New("STS endpoint unknown") } - a, err := getWebIdentityCredentials(client, stsEndpoint, m.RoleARN, m.roleSessionName, m.Policy, m.GetWebIDTokenExpiry, m.TokenRevokeType) + a, err := getWebIdentityCredentials(cc.requestContext(), client, stsEndpoint, m.RoleARN, m.roleSessionName, m.Policy, m.GetWebIDTokenExpiry, m.TokenRevokeType) if err != nil { return Value{}, err } diff --git a/vendor/github.com/minio/minio-go/v7/pkg/lifecycle/lifecycle.go b/vendor/github.com/minio/minio-go/v7/pkg/lifecycle/lifecycle.go index 01d4e6aa798..2ae38b85a7e 100644 --- a/vendor/github.com/minio/minio-go/v7/pkg/lifecycle/lifecycle.go +++ b/vendor/github.com/minio/minio-go/v7/pkg/lifecycle/lifecycle.go @@ -209,6 +209,58 @@ func (t Transition) MarshalXML(en *xml.Encoder, startElement xml.StartElement) e return en.EncodeElement(transitionWrapper(t), startElement) } +// Compression is a MinIO AIStor extension with no S3 equivalent: it compresses +// matching current object versions in place. Presence of the element enables the +// action, so Rule carries it as a pointer — unlike Transition, there is no +// StorageClass to key presence off and Days: 0 legitimately means "immediately". +// +// HighCompression selects the strongest level the server offers; without it the +// rule writes the level ingest uses and only compresses objects stored +// uncompressed. +// +// Unlike Transition and Expiration there is no absolute Date trigger — a one-off +// sweep is what the compress batch job is for. That also means no custom +// MarshalJSON: with no embedded time.Time to suppress, every field honors +// omitempty, and a zero element still marshals as {} because Rule holds it as a +// pointer and its presence alone enables the action. +type Compression struct { + XMLName xml.Name `xml:"Compression" json:"-"` + Days ExpirationDays `xml:"Days,omitempty" json:"Days,omitempty"` + HighCompression bool `xml:"HighCompression,omitempty" json:"HighCompression,omitempty"` + SkipCompressed bool `xml:"SkipCompressed,omitempty" json:"SkipCompressed,omitempty"` + IncludeEncrypted bool `xml:"IncludeEncrypted,omitempty" json:"IncludeEncrypted,omitempty"` +} + +// IsDaysNull returns true if days field is null +func (c *Compression) IsDaysNull() bool { + return c == nil || c.Days == ExpirationDays(0) +} + +// IsNull returns true if the element is absent. +func (c *Compression) IsNull() bool { + return c == nil +} + +// NoncurrentVersionCompression is the Compression counterpart for noncurrent +// object versions. See Compression for why Rule holds it as a pointer. +type NoncurrentVersionCompression struct { + XMLName xml.Name `xml:"NoncurrentVersionCompression" json:"-"` + NoncurrentDays ExpirationDays `xml:"NoncurrentDays,omitempty" json:"NoncurrentDays,omitempty"` + HighCompression bool `xml:"HighCompression,omitempty" json:"HighCompression,omitempty"` + SkipCompressed bool `xml:"SkipCompressed,omitempty" json:"SkipCompressed,omitempty"` + IncludeEncrypted bool `xml:"IncludeEncrypted,omitempty" json:"IncludeEncrypted,omitempty"` +} + +// IsDaysNull returns true if noncurrent days field is null +func (n *NoncurrentVersionCompression) IsDaysNull() bool { + return n == nil || n.NoncurrentDays == ExpirationDays(0) +} + +// IsNull returns true if the element is absent. +func (n *NoncurrentVersionCompression) IsNull() bool { + return n == nil +} + // And And Rule for LifecycleTag, to be used in LifecycleRuleFilter type And struct { XMLName xml.Name `xml:"And" json:"-"` @@ -265,12 +317,11 @@ func (f Filter) MarshalJSON() ([]byte, error) { } // MarshalXML - produces the xml representation of the Filter struct -// only one of Prefix, And and Tag should be present in the output. +// at most one of Prefix, And, Tag, ObjectSizeGreaterThan and +// ObjectSizeLessThan is present in the output. +// A zero-value Filter marshals as ; +// suppressing the element entirely is the caller's responsibility. func (f Filter) MarshalXML(e *xml.Encoder, start xml.StartElement) error { - if f.IsNull() { - return nil - } - if err := e.EncodeToken(start); err != nil { return err } @@ -473,6 +524,8 @@ func (r Rule) MarshalJSON() ([]byte, error) { Prefix string `json:"Prefix,omitempty"` Status string `json:"Status"` Transition *Transition `json:"Transition,omitempty"` + Compression *Compression `json:"Compression,omitempty"` + NoncurrentVersionCompression *NoncurrentVersionCompression `json:"NoncurrentVersionCompression,omitempty"` } newr := rule{ Prefix: r.Prefix, @@ -504,10 +557,45 @@ func (r Rule) MarshalJSON() ([]byte, error) { if !r.AllVersionsExpiration.IsNull() { newr.AllVersionsExpiration = &r.AllVersionsExpiration } + newr.Compression = r.Compression + newr.NoncurrentVersionCompression = r.NoncurrentVersionCompression return json.Marshal(newr) } +// ruleAlias drops Rule's methods so EncodeElement falls back to the default +// struct-tag encoding. +type ruleAlias Rule + +// ruleWrapper embeds ruleAlias, so it needs no updating when Rule gains a +// field. Its RuleFilter is shallower than the embedded one, and encoding/xml's +// depth-based field shadowing suppresses the deeper field, so is +// emitted only through this pointer: nil omits the element, a set pointer +// emits it (empty) as the last child of . +type ruleWrapper struct { + ruleAlias + RuleFilter *Filter `xml:"Filter,omitempty"` +} + +// MarshalXML customizes XML encoding of Rule: a rule with neither Filter nor +// Prefix set emits an empty as the last +// child of — S3 requires a Filter when no Prefix element is present; +// the empty child is this library's representation of an empty +// filter. A rule with only a top-level Prefix omits the Filter element; a +// non-null Filter marshals through the default encoding in its declared +// field position. MarshalJSON is unaffected and still omits a null Filter. +func (r Rule) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + if !r.RuleFilter.IsNull() { + return e.EncodeElement(ruleAlias(r), start) + } + + w := ruleWrapper{ruleAlias: ruleAlias(r)} + if r.Prefix == "" { + w.RuleFilter = &w.ruleAlias.RuleFilter + } + return e.EncodeElement(w, start) +} + // Rule represents a single rule in lifecycle configuration type Rule struct { XMLName xml.Name `xml:"Rule,omitempty" json:"-"` @@ -522,6 +610,8 @@ type Rule struct { Prefix string `xml:"Prefix,omitempty" json:"Prefix,omitempty"` Status string `xml:"Status" json:"Status"` Transition Transition `xml:"Transition,omitempty" json:"Transition,omitempty"` + Compression *Compression `xml:"Compression,omitempty" json:"Compression,omitempty"` + NoncurrentVersionCompression *NoncurrentVersionCompression `xml:"NoncurrentVersionCompression,omitempty" json:"NoncurrentVersionCompression,omitempty"` } // Configuration is a collection of Rule objects. diff --git a/vendor/github.com/minio/minio-go/v7/pkg/policy/bucket-policy-condition.go b/vendor/github.com/minio/minio-go/v7/pkg/policy/bucket-policy-condition.go new file mode 100644 index 00000000000..4d6d85cbc10 --- /dev/null +++ b/vendor/github.com/minio/minio-go/v7/pkg/policy/bucket-policy-condition.go @@ -0,0 +1,114 @@ +/* + * MinIO Go Library for Amazon S3 Compatible Cloud Storage + * Copyright 2015-2017 MinIO, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package policy + +import ( + "github.com/minio/minio-go/v7/pkg/set" +) + +// ConditionKeyMap - map of policy condition key and value. +type ConditionKeyMap map[string]set.StringSet + +// Add - adds key and value. The value is appended If key already exists. +func (ckm ConditionKeyMap) Add(key string, value set.StringSet) { + if v, ok := ckm[key]; ok { + ckm[key] = v.Union(value) + } else { + ckm[key] = set.CopyStringSet(value) + } +} + +// Remove - removes value of given key. If key has empty after removal, the key is also removed. +func (ckm ConditionKeyMap) Remove(key string, value set.StringSet) { + if v, ok := ckm[key]; ok { + if value != nil { + ckm[key] = v.Difference(value) + } + + if ckm[key].IsEmpty() { + delete(ckm, key) + } + } +} + +// RemoveKey - removes key and its value. +func (ckm ConditionKeyMap) RemoveKey(key string) { + delete(ckm, key) +} + +// CopyConditionKeyMap - returns new copy of given ConditionKeyMap. +func CopyConditionKeyMap(condKeyMap ConditionKeyMap) ConditionKeyMap { + out := make(ConditionKeyMap) + + for k, v := range condKeyMap { + out[k] = set.CopyStringSet(v) + } + + return out +} + +// mergeConditionKeyMap - returns a new ConditionKeyMap which contains merged key/value of given two ConditionKeyMap. +func mergeConditionKeyMap(condKeyMap1, condKeyMap2 ConditionKeyMap) ConditionKeyMap { + out := CopyConditionKeyMap(condKeyMap1) + + for k, v := range condKeyMap2 { + if ev, ok := out[k]; ok { + out[k] = ev.Union(v) + } else { + out[k] = set.CopyStringSet(v) + } + } + + return out +} + +// ConditionMap - map of condition and conditional values. +type ConditionMap map[string]ConditionKeyMap + +// Add - adds condition key and condition value. The value is appended if key already exists. +func (cond ConditionMap) Add(condKey string, condKeyMap ConditionKeyMap) { + if v, ok := cond[condKey]; ok { + cond[condKey] = mergeConditionKeyMap(v, condKeyMap) + } else { + cond[condKey] = CopyConditionKeyMap(condKeyMap) + } +} + +// Remove - removes condition key and its value. +func (cond ConditionMap) Remove(condKey string) { + delete(cond, condKey) +} + +// mergeConditionMap - returns new ConditionMap which contains merged key/value of two ConditionMap. +func mergeConditionMap(condMap1, condMap2 ConditionMap) ConditionMap { + out := make(ConditionMap) + + for k, v := range condMap1 { + out[k] = CopyConditionKeyMap(v) + } + + for k, v := range condMap2 { + if ev, ok := out[k]; ok { + out[k] = mergeConditionKeyMap(ev, v) + } else { + out[k] = CopyConditionKeyMap(v) + } + } + + return out +} diff --git a/vendor/github.com/minio/minio-go/v7/pkg/policy/bucket-policy.go b/vendor/github.com/minio/minio-go/v7/pkg/policy/bucket-policy.go new file mode 100644 index 00000000000..762c9015622 --- /dev/null +++ b/vendor/github.com/minio/minio-go/v7/pkg/policy/bucket-policy.go @@ -0,0 +1,680 @@ +/* + * MinIO Go Library for Amazon S3 Compatible Cloud Storage + * Copyright 2015-2017 MinIO, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package policy + +import ( + "encoding/json" + "errors" + "reflect" + "strings" + + "github.com/minio/minio-go/v7/pkg/set" +) + +// BucketPolicy - Bucket level policy. +type BucketPolicy string + +// Different types of Policies currently supported for buckets. +const ( + BucketPolicyNone BucketPolicy = "none" + BucketPolicyReadOnly BucketPolicy = "readonly" + BucketPolicyReadWrite BucketPolicy = "readwrite" + BucketPolicyWriteOnly BucketPolicy = "writeonly" +) + +// IsValidBucketPolicy - returns true if policy is valid and supported, false otherwise. +func (p BucketPolicy) IsValidBucketPolicy() bool { + switch p { + case BucketPolicyNone, BucketPolicyReadOnly, BucketPolicyReadWrite, BucketPolicyWriteOnly: + return true + } + return false +} + +// Resource prefix for all aws resources. +const awsResourcePrefix = "arn:aws:s3:::" + +// Common bucket actions for both read and write policies. +var commonBucketActions = set.CreateStringSet("s3:GetBucketLocation") + +// Read only bucket actions. +var readOnlyBucketActions = set.CreateStringSet("s3:ListBucket") + +// Write only bucket actions. +var writeOnlyBucketActions = set.CreateStringSet("s3:ListBucketMultipartUploads") + +// Read only object actions. +var readOnlyObjectActions = set.CreateStringSet("s3:GetObject") + +// Write only object actions. +var writeOnlyObjectActions = set.CreateStringSet("s3:AbortMultipartUpload", "s3:DeleteObject", "s3:ListMultipartUploadParts", "s3:PutObject") + +// Read and write object actions. +var readWriteObjectActions = readOnlyObjectActions.Union(writeOnlyObjectActions) + +// All valid bucket and object actions. +var validActions = commonBucketActions. + Union(readOnlyBucketActions). + Union(writeOnlyBucketActions). + Union(readOnlyObjectActions). + Union(writeOnlyObjectActions) + +var startsWithFunc = func(resource, resourcePrefix string) bool { + return strings.HasPrefix(resource, resourcePrefix) +} + +// User - canonical users list. +type User struct { + AWS set.StringSet `json:"AWS,omitempty"` + CanonicalUser set.StringSet `json:"CanonicalUser,omitempty"` +} + +// UnmarshalJSON is a custom json unmarshaler for Principal field, +// the reason is that Principal can take a json struct represented by +// User string but it can also take a string. +func (u *User) UnmarshalJSON(data []byte) error { + // Try to unmarshal data in a struct equal to User, + // to avoid infinite recursive call of this function + type AliasUser User + var au AliasUser + err := json.Unmarshal(data, &au) + if err == nil { + *u = User(au) + return nil + } + // Data type is not known, check if it is a json string + // which contains a star, which is permitted in the spec + var str string + err = json.Unmarshal(data, &str) + if err == nil { + if str != "*" { + return errors.New("unrecognized Principal field") + } + *u = User{AWS: set.CreateStringSet("*")} + return nil + } + return err +} + +// Statement - minio policy statement +type Statement struct { + Actions set.StringSet `json:"Action"` + Conditions ConditionMap `json:"Condition,omitempty"` + Effect string + Principal User `json:"Principal"` + Resources set.StringSet `json:"Resource"` + Sid string +} + +// BucketAccessPolicy - minio policy collection +type BucketAccessPolicy struct { + Version string // date in YYYY-MM-DD format + Statements []Statement `json:"Statement"` +} + +// isValidStatement - returns whether given statement is valid to process for given bucket name. +func isValidStatement(statement Statement, bucketName string) bool { + if statement.Actions.Intersection(validActions).IsEmpty() { + return false + } + + if statement.Effect != "Allow" { + return false + } + + if statement.Principal.AWS == nil || !statement.Principal.AWS.Contains("*") { + return false + } + + bucketResource := awsResourcePrefix + bucketName + if statement.Resources.Contains(bucketResource) { + return true + } + + if statement.Resources.FuncMatch(startsWithFunc, bucketResource+"/").IsEmpty() { + return false + } + + return true +} + +// Returns new statements with bucket actions for given policy. +func newBucketStatement(policy BucketPolicy, bucketName, prefix string) (statements []Statement) { + statements = []Statement{} + if policy == BucketPolicyNone || bucketName == "" { + return statements + } + + bucketResource := set.CreateStringSet(awsResourcePrefix + bucketName) + + statement := Statement{ + Actions: commonBucketActions, + Effect: "Allow", + Principal: User{AWS: set.CreateStringSet("*")}, + Resources: bucketResource, + Sid: "", + } + statements = append(statements, statement) + + if policy == BucketPolicyReadOnly || policy == BucketPolicyReadWrite { + statement = Statement{ + Actions: readOnlyBucketActions, + Effect: "Allow", + Principal: User{AWS: set.CreateStringSet("*")}, + Resources: bucketResource, + Sid: "", + } + if prefix != "" { + condKeyMap := make(ConditionKeyMap) + condKeyMap.Add("s3:prefix", set.CreateStringSet(prefix+"*")) + condMap := make(ConditionMap) + condMap.Add("StringLike", condKeyMap) + statement.Conditions = condMap + } + statements = append(statements, statement) + } + + if policy == BucketPolicyWriteOnly || policy == BucketPolicyReadWrite { + statement = Statement{ + Actions: writeOnlyBucketActions, + Effect: "Allow", + Principal: User{AWS: set.CreateStringSet("*")}, + Resources: bucketResource, + Sid: "", + } + statements = append(statements, statement) + } + + return statements +} + +// Returns new statements contains object actions for given policy. +func newObjectStatement(policy BucketPolicy, bucketName, prefix string) (statements []Statement) { + statements = []Statement{} + if policy == BucketPolicyNone || bucketName == "" { + return statements + } + + statement := Statement{ + Effect: "Allow", + Principal: User{AWS: set.CreateStringSet("*")}, + Resources: set.CreateStringSet(awsResourcePrefix + bucketName + "/" + prefix + "*"), + Sid: "", + } + + switch policy { + case BucketPolicyReadOnly: + statement.Actions = readOnlyObjectActions + case BucketPolicyWriteOnly: + statement.Actions = writeOnlyObjectActions + case BucketPolicyReadWrite: + statement.Actions = readWriteObjectActions + } + + statements = append(statements, statement) + return statements +} + +// Returns new statements for given policy, bucket and prefix. +func newStatements(policy BucketPolicy, bucketName, prefix string) (statements []Statement) { + statements = []Statement{} + ns := newBucketStatement(policy, bucketName, prefix) + statements = append(statements, ns...) + + ns = newObjectStatement(policy, bucketName, prefix) + statements = append(statements, ns...) + + return statements +} + +// Returns whether given bucket statements are used by other than given prefix statements. +func getInUsePolicy(statements []Statement, bucketName, prefix string) (readOnlyInUse, writeOnlyInUse bool) { + resourcePrefix := awsResourcePrefix + bucketName + "/" + objectResource := awsResourcePrefix + bucketName + "/" + prefix + "*" + + for _, s := range statements { + if !s.Resources.Contains(objectResource) && !s.Resources.FuncMatch(startsWithFunc, resourcePrefix).IsEmpty() { + if s.Actions.Intersection(readOnlyObjectActions).Equals(readOnlyObjectActions) { + readOnlyInUse = true + } + + if s.Actions.Intersection(writeOnlyObjectActions).Equals(writeOnlyObjectActions) { + writeOnlyInUse = true + } + } + if readOnlyInUse && writeOnlyInUse { + break + } + } + + return readOnlyInUse, writeOnlyInUse +} + +// Removes object actions in given statement. +func removeObjectActions(statement Statement, objectResource string) Statement { + if statement.Conditions == nil { + if len(statement.Resources) > 1 { + statement.Resources.Remove(objectResource) + } else { + statement.Actions = statement.Actions.Difference(readOnlyObjectActions) + statement.Actions = statement.Actions.Difference(writeOnlyObjectActions) + } + } + + return statement +} + +// Removes bucket actions for given policy in given statement. +func removeBucketActions(statement Statement, prefix, bucketResource string, readOnlyInUse, writeOnlyInUse bool) Statement { + removeReadOnly := func() { + if !statement.Actions.Intersection(readOnlyBucketActions).Equals(readOnlyBucketActions) { + return + } + + if statement.Conditions == nil { + statement.Actions = statement.Actions.Difference(readOnlyBucketActions) + return + } + + if prefix != "" { + stringEqualsValue := statement.Conditions["StringEquals"] + values := set.NewStringSet() + if stringEqualsValue != nil { + values = stringEqualsValue["s3:prefix"] + if values == nil { + values = set.NewStringSet() + } + } + + values.Remove(prefix) + + if stringEqualsValue != nil { + if values.IsEmpty() { + delete(stringEqualsValue, "s3:prefix") + } + if len(stringEqualsValue) == 0 { + delete(statement.Conditions, "StringEquals") + } + } + + if len(statement.Conditions) == 0 { + statement.Conditions = nil + statement.Actions = statement.Actions.Difference(readOnlyBucketActions) + } + } + } + + removeWriteOnly := func() { + if statement.Conditions == nil { + statement.Actions = statement.Actions.Difference(writeOnlyBucketActions) + } + } + + if len(statement.Resources) > 1 { + statement.Resources.Remove(bucketResource) + } else { + if !readOnlyInUse { + removeReadOnly() + } + + if !writeOnlyInUse { + removeWriteOnly() + } + } + + return statement +} + +// Returns statements containing removed actions/statements for given +// policy, bucket name and prefix. +func removeStatements(statements []Statement, bucketName, prefix string) []Statement { + bucketResource := awsResourcePrefix + bucketName + objectResource := awsResourcePrefix + bucketName + "/" + prefix + "*" + readOnlyInUse, writeOnlyInUse := getInUsePolicy(statements, bucketName, prefix) + + out := []Statement{} + readOnlyBucketStatements := []Statement{} + s3PrefixValues := set.NewStringSet() + + for _, statement := range statements { + if !isValidStatement(statement, bucketName) { + out = append(out, statement) + continue + } + + if statement.Resources.Contains(bucketResource) { + if statement.Conditions != nil { + statement = removeBucketActions(statement, prefix, bucketResource, false, false) + } else { + statement = removeBucketActions(statement, prefix, bucketResource, readOnlyInUse, writeOnlyInUse) + } + } else if statement.Resources.Contains(objectResource) { + statement = removeObjectActions(statement, objectResource) + } + + if !statement.Actions.IsEmpty() { + if statement.Resources.Contains(bucketResource) && + statement.Actions.Intersection(readOnlyBucketActions).Equals(readOnlyBucketActions) && + statement.Effect == "Allow" && + statement.Principal.AWS.Contains("*") { + if statement.Conditions != nil { + stringEqualsValue := statement.Conditions["StringEquals"] + values := set.NewStringSet() + if stringEqualsValue != nil { + values = stringEqualsValue["s3:prefix"] + if values == nil { + values = set.NewStringSet() + } + } + s3PrefixValues = s3PrefixValues.Union(values.ApplyFunc(func(v string) string { + return bucketResource + "/" + v + "*" + })) + } else if !s3PrefixValues.IsEmpty() { + readOnlyBucketStatements = append(readOnlyBucketStatements, statement) + continue + } + } + out = append(out, statement) + } + } + + skipBucketStatement := true + resourcePrefix := awsResourcePrefix + bucketName + "/" + for _, statement := range out { + if !statement.Resources.FuncMatch(startsWithFunc, resourcePrefix).IsEmpty() && + s3PrefixValues.Intersection(statement.Resources).IsEmpty() { + skipBucketStatement = false + break + } + } + + for _, statement := range readOnlyBucketStatements { + if skipBucketStatement && + statement.Resources.Contains(bucketResource) && + statement.Effect == "Allow" && + statement.Principal.AWS.Contains("*") && + statement.Conditions == nil { + continue + } + + out = append(out, statement) + } + + if len(out) == 1 { + statement := out[0] + if statement.Resources.Contains(bucketResource) && + statement.Actions.Intersection(commonBucketActions).Equals(commonBucketActions) && + statement.Effect == "Allow" && + statement.Principal.AWS.Contains("*") && + statement.Conditions == nil { + out = []Statement{} + } + } + + return out +} + +// Appends given statement into statement list to have unique statements. +// - If statement already exists in statement list, it ignores. +// - If statement exists with different conditions, they are merged. +// - Else the statement is appended to statement list. +func appendStatement(statements []Statement, statement Statement) []Statement { + for i, s := range statements { + if s.Actions.Equals(statement.Actions) && + s.Effect == statement.Effect && + s.Principal.AWS.Equals(statement.Principal.AWS) && + reflect.DeepEqual(s.Conditions, statement.Conditions) { + statements[i].Resources = s.Resources.Union(statement.Resources) + return statements + } else if s.Resources.Equals(statement.Resources) && + s.Effect == statement.Effect && + s.Principal.AWS.Equals(statement.Principal.AWS) && + reflect.DeepEqual(s.Conditions, statement.Conditions) { + statements[i].Actions = s.Actions.Union(statement.Actions) + return statements + } + + if s.Resources.Intersection(statement.Resources).Equals(statement.Resources) && + s.Actions.Intersection(statement.Actions).Equals(statement.Actions) && + s.Effect == statement.Effect && + s.Principal.AWS.Intersection(statement.Principal.AWS).Equals(statement.Principal.AWS) { + if reflect.DeepEqual(s.Conditions, statement.Conditions) { + return statements + } + if s.Conditions != nil && statement.Conditions != nil { + if s.Resources.Equals(statement.Resources) { + statements[i].Conditions = mergeConditionMap(s.Conditions, statement.Conditions) + return statements + } + } + } + } + + if !statement.Actions.IsEmpty() || !statement.Resources.IsEmpty() { + return append(statements, statement) + } + + return statements +} + +// Appends two statement lists. +func appendStatements(statements, appendStatements []Statement) []Statement { + for _, s := range appendStatements { + statements = appendStatement(statements, s) + } + + return statements +} + +// Returns policy of given bucket statement. +func getBucketPolicy(statement Statement, prefix string) (commonFound, readOnly, writeOnly bool) { + if statement.Effect != "Allow" || !statement.Principal.AWS.Contains("*") { + return commonFound, readOnly, writeOnly + } + + if statement.Actions.Intersection(commonBucketActions).Equals(commonBucketActions) && + statement.Conditions == nil { + commonFound = true + } + + if statement.Actions.Intersection(writeOnlyBucketActions).Equals(writeOnlyBucketActions) && + statement.Conditions == nil { + writeOnly = true + } + + if statement.Actions.Intersection(readOnlyBucketActions).Equals(readOnlyBucketActions) { + if prefix != "" && statement.Conditions != nil { + if stringEqualsValue, ok := statement.Conditions["StringEquals"]; ok { + if s3PrefixValues, ok := stringEqualsValue["s3:prefix"]; ok { + if s3PrefixValues.Contains(prefix) { + readOnly = true + } + } + } else if stringNotEqualsValue, ok := statement.Conditions["StringNotEquals"]; ok { + if s3PrefixValues, ok := stringNotEqualsValue["s3:prefix"]; ok { + if !s3PrefixValues.Contains(prefix) { + readOnly = true + } + } + } else if stringLikeValue, ok := statement.Conditions["StringLike"]; ok { + if s3PrefixValues, ok := stringLikeValue["s3:prefix"]; ok { + if s3PrefixValues.Contains(prefix + "*") { + readOnly = true + } + } + } else if stringNotLikeValue, ok := statement.Conditions["StringNotLike"]; ok { + if s3PrefixValues, ok := stringNotLikeValue["s3:prefix"]; ok { + if !s3PrefixValues.Contains(prefix + "*") { + readOnly = true + } + } + } + } else if prefix == "" && statement.Conditions == nil { + readOnly = true + } else if prefix != "" && statement.Conditions == nil { + readOnly = true + } + } + + return commonFound, readOnly, writeOnly +} + +// Returns policy of given object statement. +func getObjectPolicy(statement Statement) (readOnly, writeOnly bool) { + if statement.Effect == "Allow" && + statement.Principal.AWS.Contains("*") && + statement.Conditions == nil { + if statement.Actions.Intersection(readOnlyObjectActions).Equals(readOnlyObjectActions) { + readOnly = true + } + if statement.Actions.Intersection(writeOnlyObjectActions).Equals(writeOnlyObjectActions) { + writeOnly = true + } + } + + return readOnly, writeOnly +} + +// GetPolicy - Returns policy of given bucket name, prefix in given statements. +func GetPolicy(statements []Statement, bucketName, prefix string) BucketPolicy { + bucketResource := awsResourcePrefix + bucketName + objectResource := awsResourcePrefix + bucketName + "/" + prefix + "*" + + bucketCommonFound := false + bucketReadOnly := false + bucketWriteOnly := false + matchedResource := "" + objReadOnly := false + objWriteOnly := false + + for _, s := range statements { + matchedObjResources := set.NewStringSet() + if s.Resources.Contains(objectResource) { + matchedObjResources.Add(objectResource) + } else { + matchedObjResources = s.Resources.FuncMatch(resourceMatch, objectResource) + } + if !matchedObjResources.IsEmpty() { + readOnly, writeOnly := getObjectPolicy(s) + for resource := range matchedObjResources { + if len(matchedResource) < len(resource) { + objReadOnly = readOnly + objWriteOnly = writeOnly + matchedResource = resource + } else if len(matchedResource) == len(resource) { + objReadOnly = objReadOnly || readOnly + objWriteOnly = objWriteOnly || writeOnly + matchedResource = resource + } + } + } + if s.Resources.Contains(bucketResource) { + commonFound, readOnly, writeOnly := getBucketPolicy(s, prefix) + bucketCommonFound = bucketCommonFound || commonFound + bucketReadOnly = bucketReadOnly || readOnly + bucketWriteOnly = bucketWriteOnly || writeOnly + } + } + + policy := BucketPolicyNone + if bucketCommonFound { + if bucketReadOnly && bucketWriteOnly && objReadOnly && objWriteOnly { + policy = BucketPolicyReadWrite + } else if bucketReadOnly && objReadOnly { + policy = BucketPolicyReadOnly + } else if bucketWriteOnly && objWriteOnly { + policy = BucketPolicyWriteOnly + } + } + + return policy +} + +// GetPolicies - returns a map of policies of given bucket name, prefix in given statements. +func GetPolicies(statements []Statement, bucketName, prefix string) map[string]BucketPolicy { + policyRules := map[string]BucketPolicy{} + objResources := set.NewStringSet() + // Search all resources related to objects policy + for _, s := range statements { + for r := range s.Resources { + if strings.HasPrefix(r, awsResourcePrefix+bucketName+"/"+prefix) { + objResources.Add(r) + } + } + } + + // Pretend that policy resource as an actual object and fetch its policy + for r := range objResources { + // Put trailing * if exists in asterisk + asterisk := "" + if strings.HasSuffix(r, "*") { + r = r[:len(r)-1] + asterisk = "*" + } + var objectPath string + if len(r) >= len(awsResourcePrefix+bucketName)+1 { + objectPath = r[len(awsResourcePrefix+bucketName)+1:] + } + p := GetPolicy(statements, bucketName, objectPath) + policyRules[bucketName+"/"+objectPath+asterisk] = p + } + return policyRules +} + +// SetPolicy - Returns new statements containing policy of given bucket name and prefix are appended. +func SetPolicy(statements []Statement, policy BucketPolicy, bucketName, prefix string) []Statement { + out := removeStatements(statements, bucketName, prefix) + // fmt.Println("out = ") + // printstatement(out) + ns := newStatements(policy, bucketName, prefix) + // fmt.Println("ns = ") + // printstatement(ns) + + rv := appendStatements(out, ns) + // fmt.Println("rv = ") + // printstatement(rv) + + return rv +} + +// Match function matches wild cards in 'pattern' for resource. +func resourceMatch(pattern, resource string) bool { + if pattern == "" { + return resource == pattern + } + if pattern == "*" { + return true + } + parts := strings.Split(pattern, "*") + if len(parts) == 1 { + return resource == pattern + } + tGlob := strings.HasSuffix(pattern, "*") + end := len(parts) - 1 + if !strings.HasPrefix(resource, parts[0]) { + return false + } + for i := 1; i < end; i++ { + if !strings.Contains(resource, parts[i]) { + return false + } + idx := strings.Index(resource, parts[i]) + len(parts[i]) + resource = resource[idx:] + } + return tGlob || strings.HasSuffix(resource, parts[end]) +} diff --git a/vendor/github.com/minio/minio-go/v7/pkg/signer/request-signature-streaming-unsigned-trailer.go b/vendor/github.com/minio/minio-go/v7/pkg/signer/request-signature-streaming-unsigned-trailer.go index e18002b8d53..35c50b0c4d3 100644 --- a/vendor/github.com/minio/minio-go/v7/pkg/signer/request-signature-streaming-unsigned-trailer.go +++ b/vendor/github.com/minio/minio-go/v7/pkg/signer/request-signature-streaming-unsigned-trailer.go @@ -61,10 +61,10 @@ func getUSStreamLength(dataLen, chunkSize int64, trailers http.Header) int64 { return streamLen } -// prepareStreamingRequest - prepares a request with appropriate -// headers before computing the seed signature. +// prepareUSStreamingRequest - prepares a request with the headers +// required for an unsigned aws-chunked streaming upload. func prepareUSStreamingRequest(req *http.Request, sessionToken string, dataLen int64, timestamp time.Time) { - req.TransferEncoding = []string{"aws-chunked"} + setAwsChunkedContentEncoding(req) if sessionToken != "" { req.Header.Set("X-Amz-Security-Token", sessionToken) } diff --git a/vendor/github.com/minio/minio-go/v7/pkg/signer/request-signature-streaming.go b/vendor/github.com/minio/minio-go/v7/pkg/signer/request-signature-streaming.go index 4fe0debf5cb..8d86d4f15e2 100644 --- a/vendor/github.com/minio/minio-go/v7/pkg/signer/request-signature-streaming.go +++ b/vendor/github.com/minio/minio-go/v7/pkg/signer/request-signature-streaming.go @@ -132,8 +132,8 @@ func prepareStreamingRequest(req *http.Request, sessionToken string, dataLen int for k := range req.Trailer { req.Header.Add("X-Amz-Trailer", strings.ToLower(k)) } - req.TransferEncoding = []string{"aws-chunked"} } + setAwsChunkedContentEncoding(req) if sessionToken != "" { req.Header.Set("X-Amz-Security-Token", sessionToken) diff --git a/vendor/github.com/minio/minio-go/v7/pkg/signer/request-signature-v4.go b/vendor/github.com/minio/minio-go/v7/pkg/signer/request-signature-v4.go index 2a060c6e792..0ae2256d306 100644 --- a/vendor/github.com/minio/minio-go/v7/pkg/signer/request-signature-v4.go +++ b/vendor/github.com/minio/minio-go/v7/pkg/signer/request-signature-v4.go @@ -331,7 +331,7 @@ func signV4(req http.Request, accessKeyID, secretAccessKey, sessionToken, locati req.Header.Add("X-Amz-Trailer", strings.ToLower(k)) } - req.Header.Set("Content-Encoding", "aws-chunked") + setAwsChunkedContentEncoding(&req) req.Header.Set("x-amz-decoded-content-length", strconv.FormatInt(req.ContentLength, 10)) } @@ -395,7 +395,7 @@ func UnsignedTrailer(req http.Request, trailer http.Header) *http.Request { req.Header.Add("X-Amz-Trailer", strings.ToLower(k)) } - req.Header.Set("Content-Encoding", "aws-chunked") + setAwsChunkedContentEncoding(&req) req.Header.Set("x-amz-decoded-content-length", strconv.FormatInt(req.ContentLength, 10)) // Use custom chunked encoding. diff --git a/vendor/github.com/minio/minio-go/v7/pkg/signer/utils.go b/vendor/github.com/minio/minio-go/v7/pkg/signer/utils.go index 87c99398913..20172c2fb64 100644 --- a/vendor/github.com/minio/minio-go/v7/pkg/signer/utils.go +++ b/vendor/github.com/minio/minio-go/v7/pkg/signer/utils.go @@ -22,6 +22,8 @@ import ( "crypto/sha256" "net/http" "strings" + + "golang.org/x/net/http/httpguts" ) // unsignedPayload - value to be set to X-Amz-Content-Sha256 header when @@ -60,3 +62,26 @@ func signV4TrimAll(input string) string { // unicode.IsSpace() internally here) to one space and return return strings.Join(strings.Fields(input), " ") } + +// awsChunkedEncoding is the content coding AWS SigV4 streaming uploads +// declare on the Content-Encoding header. +const awsChunkedEncoding = "aws-chunked" + +// setAwsChunkedContentEncoding marks the request payload as aws-chunked +// encoded, keeping any content encoding the caller already set, for example +// "aws-chunked,gzip". AWS SigV4 streaming uploads require this header. +// Assigning "aws-chunked" to http.Request.TransferEncoding never reaches +// the wire — net/http silently drops assigned values other than "chunked" — +// so this header is the only signal that declares the aws-chunked framing. +func setAwsChunkedContentEncoding(req *http.Request) { + encodings := req.Header.Values("Content-Encoding") + if httpguts.HeaderValuesContainsToken(encodings, awsChunkedEncoding) { + return + } + existing := strings.TrimSpace(strings.Join(encodings, ",")) + if existing == "" { + req.Header.Set("Content-Encoding", awsChunkedEncoding) + return + } + req.Header.Set("Content-Encoding", awsChunkedEncoding+","+existing) +} diff --git a/vendor/github.com/minio/minio-go/v7/pkg/singleflight/singleflight.go b/vendor/github.com/minio/minio-go/v7/pkg/singleflight/singleflight.go index 49260327f28..ece42b9e66e 100644 --- a/vendor/github.com/minio/minio-go/v7/pkg/singleflight/singleflight.go +++ b/vendor/github.com/minio/minio-go/v7/pkg/singleflight/singleflight.go @@ -172,10 +172,12 @@ func (g *Group[K, V]) doCall(c *call[V], key K, fn func() (V, error)) { } else { panic(e) } - } else if c.err == errGoexit { - // Already in the process of goexit, no need to call again } else { - // Normal return + // Normal return, and runtime.Goexit, which reaches here with + // c.err set to errGoexit. This goroutine is already being torn + // down and must not call runtime.Goexit again: Do callers + // re-Goexit themselves once they see c.err, but DoChan callers + // hold a channel and have nothing else to wake them. for _, ch := range c.chans { ch <- Result[V]{c.val, c.err, c.dups > 0} } diff --git a/vendor/github.com/minio/minio-go/v7/rdma.go b/vendor/github.com/minio/minio-go/v7/rdma.go index 450c9620e5d..48d2c87fab8 100644 --- a/vendor/github.com/minio/minio-go/v7/rdma.go +++ b/vendor/github.com/minio/minio-go/v7/rdma.go @@ -26,6 +26,25 @@ import ( var ErrRDMANotConnected = errors.New("RDMA infrastructure not connected") +// maxRDMABufferSize is the largest transfer a single RDMA descriptor can +// describe: the x-amz-rdma-token carries the window size in a 32-bit field. +// libminiocpp itself does not fail on a larger buffer: it skips RDMA and +// transfers it over one ordinary HTTP request. The guards below reject it +// instead, so an oversize buffer does not silently become a much slower HTTP +// transfer on a path the caller explicitly opted into for RDMA. Keep this in +// step with kRDMAMaxMemoryRegSize in minio-cpp -- a value even one byte larger +// lets a buffer through here that libminiocpp then declines. The lower bound +// also stops a negative size from wrapping to a huge C.size_t. +const maxRDMABufferSize int64 = 1<<32 - 1 // 4 GiB - 1 + +// rdmaBufferSizeInRange reports whether a descriptor can name this many bytes. +// Both entry points gate on it before converting to C.size_t, so it is the one +// place the bound is expressed -- and the only part of the guard that can be +// exercised without an RDMA device. +func rdmaBufferSizeInRange(size int) bool { + return size >= 0 && int64(size) <= maxRDMABufferSize +} + type rdmaClientHandle struct { cptr *C.miniocpp_client } @@ -63,6 +82,12 @@ func newRDMAClient(c *Client) (*rdmaClientHandle, error) { func (c *Client) putObjectRDMA(_ context.Context, bucketName, objectName string, opts PutObjectOptions, ) (UploadInfo, error) { + if !rdmaBufferSizeInRange(opts.RDMABufferSize) { + return UploadInfo{}, fmt.Errorf( + "RDMA put: buffer size %d must be between 0 and the %d bytes an RDMA descriptor can describe", + opts.RDMABufferSize, maxRDMABufferSize) + } + h, err := c.rdma() if err != nil { return UploadInfo{}, err @@ -93,6 +118,12 @@ func (c *Client) putObjectRDMA(_ context.Context, bucketName, objectName string, func (c *Client) getObjectRDMA(_ context.Context, bucketName, objectName string, opts GetObjectOptions, ) (int64, error) { + if !rdmaBufferSizeInRange(opts.RDMABufferSize) { + return 0, fmt.Errorf( + "RDMA get: buffer size %d must be between 0 and the %d bytes an RDMA descriptor can describe", + opts.RDMABufferSize, maxRDMABufferSize) + } + h, err := c.rdma() if err != nil { return 0, err @@ -136,5 +167,7 @@ func AlignedBuffer(n int) unsafe.Pointer { // FreeAlignedBuffer releases a buffer from AlignedBuffer. func FreeAlignedBuffer(p unsafe.Pointer) { C.miniocpp_free_aligned(p) } -// IsRDMAAvailable reports whether cuObj is connected to a cuObjServer. +// IsRDMAAvailable reports whether this host has a usable RDMA device, so an +// RDMA transfer is worth attempting. Whether the server serves RDMA for a +// given object is answered per request, by x-amz-rdma-reply. func IsRDMAAvailable() bool { return C.miniocpp_rdma_available() != 0 } diff --git a/vendor/github.com/minio/minio-go/v7/s3-error.go b/vendor/github.com/minio/minio-go/v7/s3-error.go index 4bcc47d80a0..4ff34156d61 100644 --- a/vendor/github.com/minio/minio-go/v7/s3-error.go +++ b/vendor/github.com/minio/minio-go/v7/s3-error.go @@ -62,6 +62,7 @@ const ( InvalidDuration = "InvalidDuration" XAmzContentSHA256Mismatch = "XAmzContentSHA256Mismatch" XMinioInvalidObjectName = "XMinioInvalidObjectName" + XMinioPaidTierLicenseRequired = "XMinioPaidTierLicenseRequired" NoSuchCORSConfiguration = "NoSuchCORSConfiguration" BucketAlreadyExists = "BucketAlreadyExists" NoSuchVersion = "NoSuchVersion" diff --git a/vendor/github.com/minio/minio-go/v7/utils.go b/vendor/github.com/minio/minio-go/v7/utils.go index 3361464c5dc..48e4a47b618 100644 --- a/vendor/github.com/minio/minio-go/v7/utils.go +++ b/vendor/github.com/minio/minio-go/v7/utils.go @@ -33,6 +33,7 @@ import ( "mime" "net" "net/http" + "net/textproto" "net/url" "regexp" "strconv" @@ -63,7 +64,7 @@ func amzExpirationToExpiryDateRuleID(expiration string) (time.Time, string) { return time.Time{}, "" } -var restoreRegex = regexp.MustCompile(`ongoing-request="(.*?)"(, expiry-date="(.*?)")?`) +var restoreRegex = regexp.MustCompile(`ongoing-request="(.*?)"(, ?expiry-date="(.*?)")?`) func amzRestoreToStruct(restore string) (ongoing bool, expTime time.Time, err error) { matches := restoreRegex.FindStringSubmatch(restore) @@ -105,8 +106,32 @@ func sumMD5Base64(data []byte) string { return base64.StdEncoding.EncodeToString(hash.Sum(nil)) } -// getEndpointURL - construct a new endpoint. +// getEndpointURL - construct a new endpoint from a host[:port] endpoint +// or an http(s):// URL whose scheme agrees with the secure option. func getEndpointURL(endpoint string, secure bool) (*url.URL, error) { + // An endpoint that already carries a scheme is parsed directly instead + // of prefixing another scheme. It must agree with the secure option + // since signing and transport behavior are derived from that option. + // A "://" preceded by a path, query, or fragment delimiter is endpoint + // data rather than a scheme, so such endpoints keep the scheme-less path. + if i := strings.Index(endpoint, "://"); i == 0 || (i > 0 && !strings.ContainsAny(endpoint[:i], "/?#")) { + scheme := strings.ToLower(endpoint[:i]) + if scheme != "http" && scheme != "https" { + return nil, errInvalidArgument("Endpoint url scheme \"" + scheme + "\" is unsupported; use http or https or omit the scheme.") + } + endpointURL, err := url.Parse(endpoint) + if err != nil { + return nil, err + } + if secure != (endpointURL.Scheme == "https") { + return nil, errInvalidArgument("Endpoint url scheme \"" + endpointURL.Scheme + "\" conflicts with the secure option; remove the scheme from the endpoint or align the secure option.") + } + if err := isValidEndpointURL(*endpointURL); err != nil { + return nil, err + } + return endpointURL, nil + } + // If secure is false, use 'http' scheme. scheme := "https" if !secure { @@ -199,6 +224,9 @@ func isValidExpiry(expires time.Duration) error { return nil } +// amzMetaPrefix is the canonical prefix of S3 user metadata headers. +const amzMetaPrefix = "X-Amz-Meta-" + // Extract only necessary metadata header key/values by // filtering them out with a list of custom header keys. func extractObjMetadata(header http.Header) http.Header { @@ -215,7 +243,7 @@ func extractObjMetadata(header http.Header) http.Header { "X-Amz-Website-Redirect-Location", "X-Amz-Server-Side-Encryption", "X-Amz-Tagging-Count", - "X-Amz-Meta-", + amzMetaPrefix, "X-Minio-Meta-", // Add new headers to be preserved. // if you add new headers here, please extend @@ -230,7 +258,7 @@ func extractObjMetadata(header http.Header) http.Header { continue } found = true - if prefix == "X-Amz-Meta-" || prefix == "X-Minio-Meta-" { + if prefix == amzMetaPrefix || prefix == "X-Minio-Meta-" { for index, val := range v { if strings.HasPrefix(val, "=?") { decoder := mime.WordDecoder{} @@ -249,8 +277,29 @@ func extractObjMetadata(header http.Header) http.Header { return filteredHeader } +// stripUserMetadata converts the raw element of MinIO list +// responses into the keyed form StatObject and GetObject return in +// ObjectInfo.UserMetadata: only "X-Amz-Meta-*" entries are kept, with the +// prefix stripped and values passed through verbatim (list responses carry +// the stored values, so no decoding applies). Returns nil if raw contains +// no user metadata. +func stripUserMetadata(raw StringMap) StringMap { + var stripped StringMap + for k, v := range raw { + k = textproto.CanonicalMIMEHeaderKey(k) + if !strings.HasPrefix(k, amzMetaPrefix) { + continue + } + if stripped == nil { + stripped = make(StringMap, len(raw)) + } + stripped[strings.TrimPrefix(k, amzMetaPrefix)] = v + } + return stripped +} + const ( - // RFC 7231#section-7.1.1.1 timetamp format. e.g Tue, 29 Apr 2014 18:30:38 GMT + // RFC 7231#section-7.1.1.1 timestamp format. e.g Tue, 29 Apr 2014 18:30:38 GMT rfc822TimeFormat = "Mon, 2 Jan 2006 15:04:05 GMT" rfc822TimeFormatSingleDigitDay = "Mon, _2 Jan 2006 15:04:05 GMT" rfc822TimeFormatSingleDigitDayTwoDigitYear = "Mon, _2 Jan 06 15:04:05 GMT" @@ -351,8 +400,8 @@ func ToObjectInfo(bucketName, objectName string, h http.Header) (ObjectInfo, err metadata := extractObjMetadata(h) userMetadata := make(map[string]string) for k, v := range metadata { - if strings.HasPrefix(k, "X-Amz-Meta-") { - userMetadata[strings.TrimPrefix(k, "X-Amz-Meta-")] = v[0] + if strings.HasPrefix(k, amzMetaPrefix) { + userMetadata[strings.TrimPrefix(k, amzMetaPrefix)] = v[0] } } @@ -412,6 +461,7 @@ func ToObjectInfo(bucketName, objectName string, h http.Header) (ObjectInfo, err // following function filters out a list of standard set of keys // which are not part of object metadata. Metadata: metadata, + Headers: h, UserMetadata: userMetadata, UserTags: userTags.ToMap(), UserTagCount: tagCount, diff --git a/vendor/github.com/oklog/ulid/v2/ulid.go b/vendor/github.com/oklog/ulid/v2/ulid.go index 77e9ddd6349..e07e1a68183 100644 --- a/vendor/github.com/oklog/ulid/v2/ulid.go +++ b/vendor/github.com/oklog/ulid/v2/ulid.go @@ -505,7 +505,16 @@ func (id *ULID) Scan(src interface{}) error { case string: return id.UnmarshalText([]byte(x)) case []byte: - return id.UnmarshalBinary(x) + // Drivers often return text/varchar columns as []byte. Accept both + // the 16-byte binary form and the 26-character text encoding. + switch len(x) { + case len(*id): + return id.UnmarshalBinary(x) + case EncodedSize: + return id.UnmarshalText(x) + default: + return ErrDataSize + } } return ErrScanValue diff --git a/vendor/github.com/parquet-go/parquet-go/bloom.go b/vendor/github.com/parquet-go/parquet-go/bloom.go index 75dbaee4053..735d411ebbe 100644 --- a/vendor/github.com/parquet-go/parquet-go/bloom.go +++ b/vendor/github.com/parquet-go/parquet-go/bloom.go @@ -64,18 +64,30 @@ func (v Value) hash(h bloom.Hash) uint64 { } } +// The bloom filter spec only defines one algorithm and one hash function; a +// header carrying anything else comes from a writer we do not understand. +func isSplitBlockAlgorithm(header *format.BloomFilterHeader) bool { + _, ok := header.Algorithm.Value.(*format.SplitBlockAlgorithm) + return ok +} + +func isXxHash(header *format.BloomFilterHeader) bool { + _, ok := header.Hash.Value.(*format.XxHash) + return ok +} + func newBloomFilter(file io.ReaderAt, offset int64, header *format.BloomFilterHeader) (*FileBloomFilter, error) { - if header.Algorithm.Block == nil || header.Hash.XxHash == nil { + if !isSplitBlockAlgorithm(header) || !isXxHash(header) { return nil, nil } - switch { - case header.Compression.Uncompressed != nil: + switch header.Compression.Value.(type) { + case *format.BloomFilterUncompressed: return &FileBloomFilter{ SectionReader: *io.NewSectionReader(file, offset, int64(header.NumBytes)), hash: bloom.XXH64{}, check: bloom.CheckSplitBlock, }, nil - case header.Compression.GZip != nil: + case *format.BloomFilterGzip: // Decompress lazily on the first Check call so that opening a file with // PrefetchBloomFilters(false) does not perform any extra I/O at open time. compressedSize := int64(header.NumBytes) @@ -120,18 +132,18 @@ func newBloomFilter(file io.ReaderAt, offset int64, header *format.BloomFilterHe // fails, we return nil so the read silently skips the filter rather than // failing the whole file open. func newBloomFilterFromBytes(header *format.BloomFilterHeader, bits []byte) *FileBloomFilter { - if header.Algorithm.Block == nil || header.Hash.XxHash == nil { + if !isSplitBlockAlgorithm(header) || !isXxHash(header) { return nil } - switch { - case header.Compression.Uncompressed != nil: + switch header.Compression.Value.(type) { + case *format.BloomFilterUncompressed: r := bytes.NewReader(bits) return &FileBloomFilter{ SectionReader: *io.NewSectionReader(r, 0, int64(len(bits))), hash: bloom.XXH64{}, check: bloom.CheckSplitBlock, } - case header.Compression.GZip != nil: + case *format.BloomFilterGzip: decompressed, err := LookupCompressionCodec(format.Gzip).Decode(nil, bits) if err != nil { return nil @@ -202,16 +214,16 @@ func (f splitBlockFilter) Size(numValues int64) int { func bloomFilterHeader(filter BloomFilterColumn, codec compress.Codec) (header format.BloomFilterHeader) { switch filter.(type) { case splitBlockFilter: - header.Algorithm.Block = &format.SplitBlockAlgorithm{} + header.Algorithm.Value = &format.SplitBlockAlgorithm{} } switch filter.Hash().(type) { case bloom.XXH64: - header.Hash.XxHash = &format.XxHash{} + header.Hash.Value = &format.XxHash{} } if codec != nil && codec.CompressionCodec() == format.Gzip { - header.Compression.GZip = &format.BloomFilterGzip{} + header.Compression.Value = &format.BloomFilterGzip{} } else { - header.Compression.Uncompressed = &format.BloomFilterUncompressed{} + header.Compression.Value = &format.BloomFilterUncompressed{} } return header } diff --git a/vendor/github.com/parquet-go/parquet-go/buffer.go b/vendor/github.com/parquet-go/parquet-go/buffer.go index 2bb2dea7449..28ae8b5cd58 100644 --- a/vendor/github.com/parquet-go/parquet-go/buffer.go +++ b/vendor/github.com/parquet-go/parquet-go/buffer.go @@ -144,6 +144,10 @@ func (buf *GenericBuffer[T]) Rows() Rows { return buf.base.Rows() } +// chunkTransparentRowGroup marks GenericBuffer as safe for the chunk-level +// write fast paths, for the same reasons as Buffer. +func (buf *GenericBuffer[T]) chunkTransparentRowGroup() {} + func (buf *GenericBuffer[T]) Schema() *Schema { return buf.base.Schema() } @@ -437,6 +441,11 @@ func (buf *Buffer) WriteRowGroup(rowGroup RowGroup) (int64, error) { // concurrently to reading rows may result in non-deterministic behavior. func (buf *Buffer) Rows() Rows { return NewRowGroupRowReader(buf) } +// chunkTransparentRowGroup marks Buffer as safe for the chunk-level write fast +// paths: its Rows() reads the column buffers in order, and sorting reorders all +// columns together, so column-wise reads preserve row order. +func (buf *Buffer) chunkTransparentRowGroup() {} + // bufferWriter is an adapter for Buffer which implements both RowWriter and // PageWriter to enable optimizations in CopyRows for types that support writing // rows by copying whole pages instead of calling WriteRow repeatedly. diff --git a/vendor/github.com/parquet-go/parquet-go/buffer_pool.go b/vendor/github.com/parquet-go/parquet-go/buffer_pool.go index d2260a652d1..171fc6a6a19 100644 --- a/vendor/github.com/parquet-go/parquet-go/buffer_pool.go +++ b/vendor/github.com/parquet-go/parquet-go/buffer_pool.go @@ -1,6 +1,7 @@ package parquet import ( + "errors" "io" "os" "path/filepath" @@ -133,8 +134,11 @@ func (r *readerAt) ReadAt(b []byte, off int64) (int, error) { } r.offset = off } - n, err := r.reader.Read(b) + n, err := io.ReadFull(r.reader, b) r.offset += int64(n) + if errors.Is(err, io.ErrUnexpectedEOF) { + err = io.EOF + } return n, err } diff --git a/vendor/github.com/parquet-go/parquet-go/column.go b/vendor/github.com/parquet-go/parquet-go/column.go index e3ae1714f1c..6df3fcbf6d4 100644 --- a/vendor/github.com/parquet-go/parquet-go/column.go +++ b/vendor/github.com/parquet-go/parquet-go/column.go @@ -210,6 +210,7 @@ func (c *Column) forEachLeaf(do func(*Column)) { func openColumns(file *File, metadata *format.FileMetaData, columnIndexes []format.ColumnIndex, offsetIndexes []format.OffsetIndex) (*Column, error) { cl := columnLoader{} + cl.reserve(metadata, columnIndexes, offsetIndexes) c, err := cl.open(file, metadata, columnIndexes, offsetIndexes, nil) if err != nil { @@ -282,14 +283,104 @@ type columnLoader struct { schemaIndex int columnOrderIndex int rowGroupColumnIndex int + + // The shape of the column tree is fully determined by the schema, so its + // parts are allocated once here and handed out in slices as the tree is + // built. A file with C schema elements, L of them leaves, and R row groups + // used to cost C + 2*(C-1) + 3*L allocations; it now costs six. + columns []Column + children []*Column + fields []Field + chunks []*format.ColumnChunk + columnIndex []*format.ColumnIndex + offsetIndex []*format.OffsetIndex + // paths backs every column's path. A column's path is its parent's path + // plus its own name, so the segments across the whole tree sum to a size + // the schema determines up front. + paths []string +} + +func (cl *columnLoader) reserve(metadata *format.FileMetaData, columnIndexes []format.ColumnIndex, offsetIndexes []format.OffsetIndex) { + numColumns := len(metadata.Schema) + if numColumns == 0 { + return + } + // Walk the schema in its depth-first order to count leaves and to sum the + // path lengths: a node at depth d has a path of d+1 names, and remaining + // tracks how many children are still open at each ancestor level, so its + // length is the current depth. + numLeaves := 0 + pathSegments := 0 + // remaining tracks the open-children counts per ancestor level; its cap + // keeps the common shallow schema on the stack, a deeper one grows to heap. + remaining := make([]int32, 0, 16) + for i := range metadata.Schema { + pathSegments += len(remaining) + 1 + if isLeafSchemaElement(&metadata.Schema[i]) { + numLeaves++ + } + if n := metadata.Schema[i].NumChildren; n.Valid && n.V > 0 { + remaining = append(remaining, n.V) + } else { + // A leaf closes itself and any ancestors whose last child it was. + for len(remaining) > 0 { + remaining[len(remaining)-1]-- + if remaining[len(remaining)-1] > 0 { + break + } + remaining = remaining[:len(remaining)-1] + } + } + } + numRowGroups := len(metadata.RowGroups) + + cl.columns = make([]Column, numColumns) + // Every column but the root is a child of exactly one group, and appears + // once in that group's fields. + cl.children = make([]*Column, numColumns-1) + cl.fields = make([]Field, numColumns-1) + cl.paths = make([]string, pathSegments) + + if n := numLeaves * numRowGroups; n > 0 { + cl.chunks = make([]*format.ColumnChunk, n) + if len(columnIndexes) > 0 { + cl.columnIndex = make([]*format.ColumnIndex, n) + } + if len(offsetIndexes) > 0 { + cl.offsetIndex = make([]*format.OffsetIndex, n) + } + } +} + +// allocate cuts the first n elements off the front of the slab and returns them +// with their capacity clamped, so that appending to the result cannot reach into +// the rest of the slab. +// +// The caller must have reserved room for n; a slab shorter than that is a +// programming error and panics. Every slab is sized from the schema, and the +// only value the schema does not bound is a group's NumChildren, which open +// checks against the children slab before allocating from it. +func allocate[T any](slab *[]T, n int) []T { + taken := (*slab)[:n:n] + *slab = (*slab)[n:] + return taken } func (cl *columnLoader) open(file *File, metadata *format.FileMetaData, columnIndexes []format.ColumnIndex, offsetIndexes []format.OffsetIndex, path []string) (*Column, error) { - c := &Column{ - file: file, - schema: &metadata.Schema[cl.schemaIndex], + if cl.schemaIndex >= len(cl.columns) { + return nil, fmt.Errorf("column schema index %d is out of range: %d >= %d", + cl.schemaIndex, cl.schemaIndex, len(cl.columns)) } - c.path = columnPath(path).append(c.schema.Name) + c := &cl.columns[cl.schemaIndex] + c.file = file + c.schema = &metadata.Schema[cl.schemaIndex] + + // A column's path is its parent's path plus its own name, cut from the + // shared slab rather than concatenated into a fresh slice per column. + p := allocate(&cl.paths, len(path)+1) + copy(p, path) + p[len(path)] = c.schema.Name + c.path = columnPath(p) cl.schemaIndex++ numChildren := 0 @@ -309,32 +400,32 @@ func (cl *columnLoader) open(file *File, metadata *format.FileMetaData, columnIn rowGroupColumnIndex := cl.rowGroupColumnIndex cl.rowGroupColumnIndex++ - c.chunks = make([]*format.ColumnChunk, 0, len(rowGroups)) - c.columnIndex = make([]*format.ColumnIndex, 0, len(rowGroups)) - c.offsetIndex = make([]*format.OffsetIndex, 0, len(rowGroups)) + c.chunks = allocate(&cl.chunks, len(rowGroups)) for i, rowGroup := range rowGroups { if rowGroupColumnIndex >= len(rowGroup.Columns) { return nil, fmt.Errorf("row group at index %d does not have enough columns", i) } - c.chunks = append(c.chunks, &rowGroup.Columns[rowGroupColumnIndex]) + c.chunks[i] = &rowGroup.Columns[rowGroupColumnIndex] } if len(columnIndexes) > 0 { + c.columnIndex = allocate(&cl.columnIndex, len(rowGroups)) for i := range rowGroups { if rowGroupColumnIndex >= len(columnIndexes) { return nil, fmt.Errorf("row group at index %d does not have enough column index pages", i) } - c.columnIndex = append(c.columnIndex, &columnIndexes[rowGroupColumnIndex]) + c.columnIndex[i] = &columnIndexes[rowGroupColumnIndex] } } if len(offsetIndexes) > 0 { + c.offsetIndex = allocate(&cl.offsetIndex, len(rowGroups)) for i := range rowGroups { if rowGroupColumnIndex >= len(offsetIndexes) { return nil, fmt.Errorf("row group at index %d does not have enough offset index pages", i) } - c.offsetIndex = append(c.offsetIndex, &offsetIndexes[rowGroupColumnIndex]) + c.offsetIndex[i] = &offsetIndexes[rowGroupColumnIndex] } } @@ -351,6 +442,17 @@ func (cl *columnLoader) open(file *File, metadata *format.FileMetaData, columnIn // the page headers to determine which compression and encodings are // applied. for _, encoding := range c.chunks[0].MetaData.Encoding { + // BIT_PACKED appears in the encodings list when the + // deprecated bit-packed encoding was used for repetition + // or definition levels. Encodings.md: "Note that the + // BIT_PACKED encoding method is only supported for + // encoding repetition and definition levels." It is never + // a data page encoding, so it must not be reported as the + // column encoding (it would make schemas derived from + // this file unwritable). + if encoding == format.BitPacked { + continue + } if c.encoding == nil { c.encoding = LookupEncoding(encoding) } @@ -366,21 +468,37 @@ func (cl *columnLoader) open(file *File, metadata *format.FileMetaData, columnIn } c.typ = &groupType{} - if lt := c.schema.LogicalType; lt.Valid && lt.V.Map != nil { + switch c.schema.LogicalType.Value.(type) { + case *format.MapType: c.typ = &mapType{} - } else if lt.Valid && lt.V.List != nil { + case *format.ListType: c.typ = &listType{} - } else if lt.Valid && lt.V.Variant != nil { + case *format.VariantType: c.typ = &variantType{} - } else if ct := c.schema.ConvertedType; ct.Valid { - switch ct.V { - case deprecated.Map: - c.typ = &mapType{} - case deprecated.List: - c.typ = &listType{} + default: + // Fall back on the deprecated converted type when the schema element + // carries no logical type annotation we recognize. + if ct := c.schema.ConvertedType; ct.Valid { + switch ct.V { + case deprecated.Map: + c.typ = &mapType{} + case deprecated.List: + c.typ = &listType{} + } } } - c.columns = make([]*Column, numChildren) + // Bound NumChildren by what the children slab has left rather than by the + // schema elements that remain. Only the slab bounds the total across every + // group: a schema where each group's claim fits the elements after it can + // still claim more children in total than the schema has to give. + if numChildren > len(cl.children) { + return nil, fmt.Errorf("column %q declares %d children but only %d schema elements are left to be children", + c.schema.Name, numChildren, len(cl.children)) + } + + // Reserve this group's children before recursing, so that a child's own + // children are cut from the slab after ours rather than overlapping them. + c.columns = allocate(&cl.children, numChildren) for i := range c.columns { if cl.schemaIndex >= len(metadata.Schema) { @@ -395,7 +513,7 @@ func (cl *columnLoader) open(file *File, metadata *format.FileMetaData, columnIn } } - c.fields = make([]Field, len(c.columns)) + c.fields = allocate(&cl.fields, len(c.columns)) for i, column := range c.columns { c.fields[i] = column } @@ -414,66 +532,63 @@ func isLeafSchemaElement(element *format.SchemaElement) bool { } func schemaElementTypeOf(s *format.SchemaElement) Type { - if s.LogicalType.Valid { - lt := &s.LogicalType.V - // A logical type exists, the Type interface implementations in this - // package are all based on the logical parquet types declared in the - // format sub-package so we can return them directly via a pointer type - // conversion. - switch { - case lt.UTF8 != nil: - return (*stringType)(lt.UTF8) - case lt.Map != nil: - return (*mapType)(lt.Map) - case lt.List != nil: - return (*listType)(lt.List) - case lt.Enum != nil: - return (*enumType)(lt.Enum) - case lt.Decimal != nil: - // A parquet decimal can be one of several different physical types. - if s.Type.Valid { - var typ Type - switch kind := Kind(s.Type.V); kind { - case Int32: - typ = Int32Type - case Int64: - typ = Int64Type - case ByteArray: - typ = ByteArrayType - case FixedLenByteArray: - if !s.TypeLength.Valid { - panic("DECIMAL using FIXED_LEN_BYTE_ARRAY must specify a length") - } - typ = FixedLenByteArrayType(int(s.TypeLength.V)) - default: - panic("DECIMAL must be of type INT32, INT64, BYTE_ARRAY or FIXED_LEN_BYTE_ARRAY but got " + kind.String()) - } - return &decimalType{ - decimal: *lt.Decimal, - Type: typ, + // A logical type exists, the Type interface implementations in this + // package are all based on the logical parquet types declared in the + // format sub-package so we can return them directly via a pointer type + // conversion. + switch lt := s.LogicalType.Value.(type) { + case *format.StringType: + return (*stringType)(lt) + case *format.MapType: + return (*mapType)(lt) + case *format.ListType: + return (*listType)(lt) + case *format.EnumType: + return (*enumType)(lt) + case *format.DecimalType: + // A parquet decimal can be one of several different physical types. + if s.Type.Valid { + var typ Type + switch kind := Kind(s.Type.V); kind { + case Int32: + typ = Int32Type + case Int64: + typ = Int64Type + case ByteArray: + typ = ByteArrayType + case FixedLenByteArray: + if !s.TypeLength.Valid { + panic("DECIMAL using FIXED_LEN_BYTE_ARRAY must specify a length") } + typ = FixedLenByteArrayType(int(s.TypeLength.V)) + default: + panic("DECIMAL must be of type INT32, INT64, BYTE_ARRAY or FIXED_LEN_BYTE_ARRAY but got " + kind.String()) + } + return &decimalType{ + decimal: *lt, + Type: typ, } - case lt.Date != nil: - return (*dateType)(lt.Date) - case lt.Time != nil: - return (*timeType)(lt.Time) - case lt.Timestamp != nil: - return (*timestampType)(lt.Timestamp) - case lt.Integer != nil: - return (*intType)(lt.Integer) - case lt.Unknown != nil: - return (*nullType)(lt.Unknown) - case lt.Json != nil: - return (*jsonType)(lt.Json) - case lt.Bson != nil: - return (*bsonType)(lt.Bson) - case lt.UUID != nil: - return (*uuidType)(lt.UUID) - case lt.Geometry != nil: - return (*geometryType)(lt.Geometry) - case lt.Geography != nil: - return (*geographyType)(lt.Geography) } + case *format.DateType: + return (*dateType)(lt) + case *format.TimeType: + return canonicalTimeType(lt) + case *format.TimestampType: + return canonicalTimestampType(lt) + case *format.IntType: + return canonicalIntType(lt) + case *format.NullType: + return (*nullType)(lt) + case *format.JsonType: + return (*jsonType)(lt) + case *format.BsonType: + return (*bsonType)(lt) + case *format.UUIDType: + return (*uuidType)(lt) + case *format.GeometryType: + return (*geometryType)(lt) + case *format.GeographyType: + return (*geographyType)(lt) } if s.ConvertedType.Valid { @@ -768,6 +883,12 @@ func (c *Column) decodeDataPage(header DataPageHeader, numValues int, repetition return nil, err } + if !isDictionaryEncoding(pageEncoding) { + if err := checkPageDataCapacity(pageKind, c.Type().Length(), numValues, values); err != nil { + return nil, err + } + } + newPage := pageType.NewPage(c.Index(), numValues, values) switch { case c.maxRepetitionLevel > 0: @@ -865,7 +986,35 @@ func (c *Column) decodeDictionary(header DictionaryPageHeader, page *buffer[byte if err != nil { return nil, err } + if err := checkPageDataCapacity(pageType.Kind(), pageType.Length(), numValues, values); err != nil { + return nil, err + } return pageType.NewDictionary(int(c.index), numValues, values), nil } +// check data buffer has enough capacity for the nubmer of values & value type +func checkPageDataCapacity(kind Kind, typeLength, numValues int, values encoding.Values) error { + n := int64(numValues) + var need int64 + switch kind { + case Boolean: // bit packed + need = (n + 7) / 8 + case Int32, Float: + need = 4 * n + case Int64, Double: + need = 8 * n + case Int96: + need = 12 * n + case FixedLenByteArray: + need = int64(typeLength) * n + default: + return nil + } + data, _ := values.Data() + if int64(cap(data)) < need { + return fmt.Errorf("page header declares %d values requiring %d bytes but decoded buffer holds only %d: %w", numValues, need, cap(data), ErrCorrupted) + } + return nil +} + var _ Node = (*Column)(nil) diff --git a/vendor/github.com/parquet-go/parquet-go/column_buffer_geometry.go b/vendor/github.com/parquet-go/parquet-go/column_buffer_geometry.go index 50d83cd00b9..b86757610f4 100644 --- a/vendor/github.com/parquet-go/parquet-go/column_buffer_geometry.go +++ b/vendor/github.com/parquet-go/parquet-go/column_buffer_geometry.go @@ -3,6 +3,7 @@ package parquet import ( "fmt" + "github.com/parquet-go/parquet-go/format" "github.com/twpayne/go-geom" "github.com/twpayne/go-geom/encoding/wkb" ) @@ -14,9 +15,8 @@ func writeGeometry(col ColumnBuffer, levels columnLevels, value geom.T, node Nod } if logicalType := node.Type().LogicalType(); logicalType != nil { - switch { - case logicalType.Geometry != nil: - case logicalType.Geography != nil: + switch logicalType.Value.(type) { + case *format.GeometryType, *format.GeographyType: // valid default: panic("invalid logical type for value of type geom.T, must be Geometry or Geography") diff --git a/vendor/github.com/parquet-go/parquet-go/column_buffer_json.go b/vendor/github.com/parquet-go/parquet-go/column_buffer_json.go index efea249d312..4f444be3c3d 100644 --- a/vendor/github.com/parquet-go/parquet-go/column_buffer_json.go +++ b/vendor/github.com/parquet-go/parquet-go/column_buffer_json.go @@ -10,6 +10,7 @@ import ( "github.com/parquet-go/bitpack/unsafecast" "github.com/parquet-go/jsonlite" + "github.com/parquet-go/parquet-go/format" ) var jsonNull jsonlite.Value @@ -29,7 +30,7 @@ func jsonParse(data []byte) (*jsonlite.Value, error) { func writeJSONToLeaf(col ColumnBuffer, levels columnLevels, val *jsonlite.Value, node Node) { typ := node.Type() if typ.Kind() == ByteArray { - if logicalType := typ.LogicalType(); logicalType != nil && logicalType.Json != nil { + if logicalType := typ.LogicalType(); logicalTypeIs[*format.JsonType](logicalType) { writeJSONToByteArray(col, levels, val, node) return } @@ -103,8 +104,8 @@ func writeJSONString(col ColumnBuffer, levels columnLevels, str string, node Nod typ := node.Type() if logicalType := typ.LogicalType(); logicalType != nil { - switch { - case logicalType.Timestamp != nil: + switch logicalType.Value.(type) { + case *format.TimestampType: t, err := time.Parse(time.RFC3339, str) if err != nil { panic(fmt.Errorf("cannot parse JSON string %q as timestamp: %w", str, err)) @@ -112,7 +113,7 @@ func writeJSONString(col ColumnBuffer, levels columnLevels, str string, node Nod writeTime(col, levels, t, node) return - case logicalType.Date != nil: + case *format.DateType: t, err := time.Parse("2006-01-02", str) if err != nil { panic(fmt.Errorf("cannot parse JSON string %q as date: %w", str, err)) @@ -120,7 +121,7 @@ func writeJSONString(col ColumnBuffer, levels columnLevels, str string, node Nod writeTime(col, levels, t, node) return - case logicalType.Time != nil: + case *format.TimeType: t, err := time.Parse("15:04:05.000000000", str) if err != nil { panic(fmt.Errorf("cannot parse JSON string %q as time: %w", str, err)) @@ -132,7 +133,7 @@ func writeJSONString(col ColumnBuffer, levels columnLevels, str string, node Nod writeDuration(col, levels, d, node) return - case logicalType.UUID != nil: + case *format.UUIDType: // Only parse UUID strings when writing to binary UUID columns // (FIXED_LEN_BYTE_ARRAY with 16 bytes). If writing to a STRING // column with UUID logical type, write the string as-is. @@ -149,8 +150,8 @@ func writeJSONNumber(col ColumnBuffer, levels columnLevels, num json.Number, nod str := num.String() if logicalType := typ.LogicalType(); logicalType != nil { - switch { - case logicalType.Timestamp != nil: + switch logicalType.Value.(type) { + case *format.TimestampType: // Interpret number as seconds since Unix epoch (with sub-second precision) f, err := num.Float64() if err != nil { @@ -161,7 +162,7 @@ func writeJSONNumber(col ColumnBuffer, levels columnLevels, num json.Number, nod writeTime(col, levels, t, node) return - case logicalType.Date != nil: + case *format.DateType: // Interpret number as seconds since Unix epoch i, err := num.Int64() if err != nil { @@ -171,7 +172,7 @@ func writeJSONNumber(col ColumnBuffer, levels columnLevels, num json.Number, nod writeTime(col, levels, t, node) return - case logicalType.Time != nil: + case *format.TimeType: // Interpret number as seconds since midnight f, err := num.Float64() if err != nil { diff --git a/vendor/github.com/parquet-go/parquet-go/column_buffer_proto.go b/vendor/github.com/parquet-go/parquet-go/column_buffer_proto.go index 31bb7f1147c..abcd5338960 100644 --- a/vendor/github.com/parquet-go/parquet-go/column_buffer_proto.go +++ b/vendor/github.com/parquet-go/parquet-go/column_buffer_proto.go @@ -24,17 +24,17 @@ func writeProtoTimestamp(col ColumnBuffer, levels columnLevels, ts *timestamppb. } var typ = node.Type() var unit format.TimeUnit - if lt := typ.LogicalType(); lt != nil && lt.Timestamp != nil { - unit = lt.Timestamp.Unit + if timestamp, ok := logicalTypeOf[*format.TimestampType](typ.LogicalType()); ok { + unit = timestamp.Unit } else { unit = Nanosecond.TimeUnit() } var t = ts.AsTime() var value int64 - switch { - case unit.Millis != nil: + switch unit.Value.(type) { + case *format.MilliSeconds: value = t.UnixMilli() - case unit.Micros != nil: + case *format.MicroSeconds: value = t.UnixMicro() default: value = t.UnixNano() diff --git a/vendor/github.com/parquet-go/parquet-go/column_buffer_reflect.go b/vendor/github.com/parquet-go/parquet-go/column_buffer_reflect.go index c472f533cba..0eedcda062c 100644 --- a/vendor/github.com/parquet-go/parquet-go/column_buffer_reflect.go +++ b/vendor/github.com/parquet-go/parquet-go/column_buffer_reflect.go @@ -20,6 +20,7 @@ import ( "github.com/google/uuid" "github.com/parquet-go/jsonlite" "github.com/parquet-go/parquet-go/deprecated" + "github.com/parquet-go/parquet-go/format" "github.com/parquet-go/parquet-go/internal/memory" "github.com/parquet-go/parquet-go/sparse" "github.com/twpayne/go-geom" @@ -218,15 +219,15 @@ func writeTime(col ColumnBuffer, levels columnLevels, t time.Time, node Node) { typ := node.Type() if logicalType := typ.LogicalType(); logicalType != nil { - switch { - case logicalType.Timestamp != nil: + switch lt := logicalType.Value.(type) { + case *format.TimestampType: // TIMESTAMP logical type -> write to int64 - unit := logicalType.Timestamp.Unit + unit := lt.Unit var val int64 - switch { - case unit.Millis != nil: + switch unit.Value.(type) { + case *format.MilliSeconds: val = t.UnixMilli() - case unit.Micros != nil: + case *format.MicroSeconds: val = t.UnixMicro() default: val = t.UnixNano() @@ -234,19 +235,19 @@ func writeTime(col ColumnBuffer, levels columnLevels, t time.Time, node Node) { col.writeInt64(levels, val) return - case logicalType.Date != nil: + case *format.DateType: // DATE logical type -> write to int32 col.writeInt32(levels, int32(daysSinceUnixEpoch(t))) return - case logicalType.Time != nil: + case *format.TimeType: // TIME logical type -> write time of day - unit := logicalType.Time.Unit + unit := lt.Unit nanos := timeOfDayNanos(t) - switch { - case unit.Millis != nil: + switch unit.Value.(type) { + case *format.MilliSeconds: col.writeInt32(levels, int32(nanos/1e6)) - case unit.Micros != nil: + case *format.MicroSeconds: col.writeInt64(levels, nanos/1e3) default: col.writeInt64(levels, nanos) @@ -281,13 +282,13 @@ func writeTime(col ColumnBuffer, levels columnLevels, t time.Time, node Node) { func writeDuration(col ColumnBuffer, levels columnLevels, d time.Duration, node Node) { typ := node.Type() - if logicalType := typ.LogicalType(); logicalType != nil && logicalType.Time != nil { + if lt, ok := logicalTypeOf[*format.TimeType](typ.LogicalType()); ok { // TIME logical type - unit := logicalType.Time.Unit - switch { - case unit.Millis != nil: + unit := lt.Unit + switch unit.Value.(type) { + case *format.MilliSeconds: col.writeInt32(levels, int32(d.Milliseconds())) - case unit.Micros != nil: + case *format.MicroSeconds: col.writeInt64(levels, d.Microseconds()) default: col.writeInt64(levels, d.Nanoseconds()) @@ -808,9 +809,8 @@ func writeValueFuncOfLeaf(columnIndex uint16, node Node) (uint16, writeValueFunc case reflect.Float32: typ := node.Type() - logicalType := typ.LogicalType() - if logicalType != nil && logicalType.Decimal != nil { - decimalValue(col, levels, typ, value, logicalType.Decimal.Scale) + if decimal, ok := logicalTypeOf[*format.DecimalType](typ.LogicalType()); ok { + decimalValue(col, levels, typ, value, decimal.Scale) return } col.writeFloat(levels, float32(value.Float())) @@ -818,9 +818,8 @@ func writeValueFuncOfLeaf(columnIndex uint16, node Node) (uint16, writeValueFunc case reflect.Float64: typ := node.Type() - logicalType := typ.LogicalType() - if logicalType != nil && logicalType.Decimal != nil { - decimalValue(col, levels, typ, value, logicalType.Decimal.Scale) + if decimal, ok := logicalTypeOf[*format.DecimalType](typ.LogicalType()); ok { + decimalValue(col, levels, typ, value, decimal.Scale) return } @@ -834,8 +833,7 @@ func writeValueFuncOfLeaf(columnIndex uint16, node Node) (uint16, writeValueFunc writeJSONNumber(col, levels, json.Number(v), node) default: typ := node.Type() - logicalType := typ.LogicalType() - if logicalType != nil && logicalType.UUID != nil { + if logicalTypeIs[*format.UUIDType](typ.LogicalType()) { writeUUID(col, levels, v, typ) return } @@ -972,15 +970,15 @@ func numberToByteArray(data any) []byte { func writeBigFloat(col ColumnBuffer, levels columnLevels, f *big.Float, node Node) { typ := node.Type() - logicalType := typ.LogicalType() - if logicalType == nil || logicalType.Decimal == nil { + decimal, ok := logicalTypeOf[*format.DecimalType](typ.LogicalType()) + if !ok { panic("writeBigFloat requires a decimal logical type") } - scale := int(logicalType.Decimal.Scale) + scale := int(decimal.Scale) // Compute minimum precision needed: decimal precision * log2(10) ≈ precision * 3.32 // We use precision * 4 + 64 for safety margin - minPrec := uint(logicalType.Decimal.Precision)*4 + 64 + minPrec := uint(decimal.Precision)*4 + 64 prec := max(f.Prec(), minPrec) scaleFactor := new(big.Float).SetPrec(prec) scaleFactor.SetInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(scale)), nil)) diff --git a/vendor/github.com/parquet-go/parquet-go/column_buffer_variant.go b/vendor/github.com/parquet-go/parquet-go/column_buffer_variant.go index 2c1b982835e..d611755b952 100644 --- a/vendor/github.com/parquet-go/parquet-go/column_buffer_variant.go +++ b/vendor/github.com/parquet-go/parquet-go/column_buffer_variant.go @@ -7,8 +7,6 @@ import ( "github.com/parquet-go/parquet-go/variant" ) -// writeValueFuncOfVariant handles writing Go values to variant column buffers. -// Dispatches to unshredded or shredded variant handling. func writeValueFuncOfVariant(columnIndex uint16, node Node) (uint16, writeValueFunc) { if isUnshreddedVariant(node) { return writeValueFuncOfUnshreddedVariant(columnIndex, node) @@ -16,7 +14,6 @@ func writeValueFuncOfVariant(columnIndex uint16, node Node) (uint16, writeValueF return writeValueFuncOfShreddedVariant(columnIndex, node) } -// writeValueFuncOfUnshreddedVariant handles the simple 2-column variant. func writeValueFuncOfUnshreddedVariant(columnIndex uint16, node Node) (uint16, writeValueFunc) { metadataColumnIndex := columnIndex valueColumnIndex := columnIndex + 1 @@ -29,127 +26,102 @@ func writeValueFuncOfUnshreddedVariant(columnIndex uint16, node Node) (uint16, w } } -// writeValueFuncOfShreddedVariant handles the 3-field shredded variant. +// writeValueFuncOfShreddedVariant writes Go values into a shredded variant +// group per the Variant Shredding specification. It shares the shredding +// logic with the row-based write path (variant_shredded_write.go) by +// shredding into a scratch column buffer and flushing the resulting values +// with their levels to the column buffers. func writeValueFuncOfShreddedVariant(columnIndex uint16, node Node) (uint16, writeValueFunc) { - // Fields are sorted alphabetically: metadata, typed_value, value - var metadataColumnIndex, valueColumnIndex, typedValueStartColumn uint16 - var typedValueLeafCount uint16 - var typedValueNode Node - - col := columnIndex - for _, f := range node.Fields() { - n := numLeafColumnsOf(f) - switch f.Name() { - case "metadata": - metadataColumnIndex = col - col += n - case "typed_value": - typedValueStartColumn = col - typedValueNode = f - typedValueLeafCount = n - col += n - case "value": - valueColumnIndex = col - col += n + // Schemas that cannot be written to (e.g. missing the metadata column) + // may still be read from; fail when a row is written, not at build time. + group, err := buildShreddedVariantGroup(node, 0, 0, 0) + if err == nil && group.metadataCol < 0 { + err = fmt.Errorf("variant: shredded variant group has no metadata field") + } + if err != nil { + numCols := numLeafColumnsOf(node) + return columnIndex + numCols, func([]ColumnBuffer, columnLevels, reflect.Value) { + panic(fmt.Sprintf("invalid shredded variant schema: %v", err)) } } - nextColumnIndex := col - - typedInner := Required(typedValueNode) - matcher := buildShreddedMatcher(typedInner) + nextColumnIndex := columnIndex + uint16(group.numCols) return nextColumnIndex, func(columns []ColumnBuffer, levels columnLevels, value reflect.Value) { - metadata, val := variantMarshalOrNull(value) - columns[metadataColumnIndex].writeByteArray(levels, metadata) + // An invalid value means an enclosing optional/repeated wrapper is + // null for this row: the whole variant group is null. + if !value.IsValid() { + for col := range group.numCols { + columns[columnIndex+uint16(col)].writeNull(levels) + } + return + } - goVal := extractGoValue(value) - if goVal != nil && matcher.canShred(goVal) { - // Write null to value column - columns[valueColumnIndex].writeNull(levels) - // Write typed value (increment def level for optional wrapper) - typedLevels := levels - typedLevels.definitionLevel++ - writeShredded(columns, typedLevels, typedValueStartColumn, &matcher, goVal) + var v variant.Value + if metaBytes, valBytes, ok := extractRawVariantStruct(value); ok { + m, err := variant.DecodeMetadata(metaBytes) + if err != nil { + panic(fmt.Sprintf("variant metadata: %v", err)) + } + if v, err = variant.Decode(m, valBytes); err != nil { + panic(fmt.Sprintf("variant decode: %v", err)) + } } else { - // Write variant bytes to value column - valueLevels := levels - valueLevels.definitionLevel++ - columns[valueColumnIndex].writeByteArray(valueLevels, val) - // Write null to all typed_value columns - for col := typedValueStartColumn; col < typedValueStartColumn+typedValueLeafCount; col++ { - columns[col].writeNull(levels) + var err error + if v, err = variant.ValueOf(extractGoValue(value)); err != nil { + panic(fmt.Sprintf("variant marshal: %v", err)) } } - } -} -// writeShredded writes a shredded value to the column buffers. -func writeShredded(columns []ColumnBuffer, levels columnLevels, startColumn uint16, m *shreddedMatcher, v any) { - if m.isPrimitive() { - pv := goValueToParquetValue(v, m.kind()) - col := columns[startColumn] - switch m.kind() { - case Boolean: - col.writeBoolean(levels, pv.Boolean()) - case Int32: - col.writeInt32(levels, pv.Int32()) - case Int64: - col.writeInt64(levels, pv.Int64()) - case Float: - col.writeFloat(levels, pv.Float()) - case Double: - col.writeDouble(levels, pv.Double()) - case ByteArray: - col.writeByteArray(levels, pv.ByteArray()) - default: - col.writeByteArray(levels, pv.ByteArray()) - } - return - } - if m.isGroup() { - writeShreddedObject(columns, levels, startColumn, m, v) - } -} + var b variant.MetadataBuilder + addVariantFieldNames(&b, v) -func writeShreddedObject(columns []ColumnBuffer, levels columnLevels, startColumn uint16, m *shreddedMatcher, v any) { - obj, ok := v.(map[string]any) - if !ok { - return - } + // One backing slab gives every scratch column capacity for the + // common one-value-per-column case without a per-column allocation; + // only columns under a repeated list can grow past it. + scratch := make([][]Value, group.numCols) + slab := make([]Value, len(scratch)) + for i := range scratch { + scratch[i] = slab[i : i : i+1] + } + group.write(scratch, 0, &b, v, true, shredLevels{ + baseDef: int(levels.definitionLevel), + baseRep: int(levels.repetitionDepth), + rep: levels.repetitionLevel, + }) - col := startColumn - for _, f := range m.fields { - // Within each field's sub-group, fields are sorted alphabetically: - // typed_value comes before value. - typedValueCol := col - typedCount := f.matcher.leafCount - valueCol := col + typedCount - nextFieldCol := valueCol + 1 + _, metadata := b.Build() + columns[columnIndex+uint16(group.metadataCol)].writeByteArray(levels, metadata) - fieldVal, exists := obj[f.name] - if exists && fieldVal != nil && f.matcher.canShred(fieldVal) { - columns[valueCol].writeNull(levels) - typedLevels := levels - typedLevels.definitionLevel++ - writeShredded(columns, typedLevels, typedValueCol, &f.matcher, fieldVal) - } else if exists && fieldVal != nil { - valueLevels := levels - valueLevels.definitionLevel++ - metadata, val, err := variant.Marshal(fieldVal) - if err != nil { - panic(fmt.Sprintf("variant marshal field %q: %v", f.name, err)) + for col, values := range scratch { + if col == group.metadataCol { + continue } - combined := encodeFieldVariant(metadata, val) - columns[valueCol].writeByteArray(valueLevels, combined) - for c := typedValueCol; c < typedValueCol+typedCount; c++ { - columns[c].writeNull(levels) - } - } else { - for c := typedValueCol; c < nextFieldCol; c++ { - columns[c].writeNull(levels) + buffer := columns[columnIndex+uint16(col)] + for _, val := range values { + valueLevels := columnLevels{ + repetitionDepth: levels.repetitionDepth, + repetitionLevel: val.repetitionLevel, + definitionLevel: val.definitionLevel, + } + if val.IsNull() { + buffer.writeNull(valueLevels) + continue + } + switch val.Kind() { + case Boolean: + buffer.writeBoolean(valueLevels, val.Boolean()) + case Int32: + buffer.writeInt32(valueLevels, val.Int32()) + case Int64: + buffer.writeInt64(valueLevels, val.Int64()) + case Float: + buffer.writeFloat(valueLevels, val.Float()) + case Double: + buffer.writeDouble(valueLevels, val.Double()) + default: + buffer.writeByteArray(valueLevels, val.ByteArray()) + } } } - - col = nextFieldCol } } diff --git a/vendor/github.com/parquet-go/parquet-go/column_buffer_write.go b/vendor/github.com/parquet-go/parquet-go/column_buffer_write.go index dbe1413b458..fcdce3883b8 100644 --- a/vendor/github.com/parquet-go/parquet-go/column_buffer_write.go +++ b/vendor/github.com/parquet-go/parquet-go/column_buffer_write.go @@ -12,6 +12,7 @@ import ( "github.com/parquet-go/jsonlite" "github.com/parquet-go/parquet-go/deprecated" + "github.com/parquet-go/parquet-go/format" "github.com/parquet-go/parquet-go/internal/memory" "github.com/parquet-go/parquet-go/sparse" "google.golang.org/protobuf/types/known/structpb" @@ -34,7 +35,7 @@ type writeRowsFunc func(columns []ColumnBuffer, levels columnLevels, rows sparse func writeRowsFuncOf(t reflect.Type, schema *Schema, path columnPath, tagReplacements []StructTagOption) writeRowsFunc { if leaf, exists := schema.Lookup(path...); exists { logicalType := leaf.Node.Type().LogicalType() - if logicalType != nil && logicalType.Json != nil { + if logicalTypeIs[*format.JsonType](logicalType) { return writeRowsFuncOfJSON(t, schema, path) } } @@ -918,21 +919,21 @@ func writeRowsFuncOfJSON(t reflect.Type, schema *Schema, path columnPath) writeR func writeRowsFuncOfTime(_ reflect.Type, schema *Schema, path columnPath, tagReplacements []StructTagOption) writeRowsFunc { t := reflect.TypeFor[int64]() - elemSize := uintptr(t.Size()) writeRows := writeRowsFuncOf(t, schema, path, tagReplacements) col, _ := schema.Lookup(path...) unit := Nanosecond.TimeUnit() lt := col.Node.Type().LogicalType() - if lt != nil && lt.Timestamp != nil { - unit = lt.Timestamp.Unit + if ts, ok := logicalTypeOf[*format.TimestampType](lt); ok { + unit = ts.Unit } // Check if the column is optional isOptional := col.Node.Optional() return func(columns []ColumnBuffer, levels columnLevels, rows sparse.Array) { - if rows.Len() == 0 { + n := rows.Len() + if n == 0 { writeRows(columns, levels, rows) return } @@ -945,38 +946,53 @@ func writeRowsFuncOfTime(_ reflect.Type, schema *Schema, path columnPath, tagRep // definitionLevel starts at 0. alreadyHandled := isOptional && levels.definitionLevel > 0 - times := rows.TimeArray() - for i := range times.Len() { - t := times.Index(i) + buf := wideIntBufPool.Get( + func() *wideIntBuf { return new(wideIntBuf) }, + func(b *wideIntBuf) { b.values = b.values[:0] }, + ) + buf.values = slices.Grow(buf.values, n)[:n] + defer wideIntBufPool.Put(buf) - // For optional fields, check if the value is zero - // (unless already handled by pointer wrapper). - elemLevels := levels - if isOptional && !alreadyHandled && t.IsZero() { - // Write as NULL (don't increment definition level). - empty := sparse.Array{} - writeRows(columns, elemLevels, empty) - continue + times := rows.TimeArray() + switch unit.Value.(type) { + case *format.MilliSeconds: + for i := range n { + buf.values[i] = times.Index(i).UnixMilli() } - - // For optional non-zero values, increment definition level - // (unless already handled). - if isOptional && !alreadyHandled { - elemLevels.definitionLevel++ + case *format.MicroSeconds: + for i := range n { + buf.values[i] = times.Index(i).UnixMicro() } + default: + for i := range n { + buf.values[i] = times.Index(i).UnixNano() + } + } - var val int64 - switch { - case unit.Millis != nil: - val = t.UnixMilli() - case unit.Micros != nil: - val = t.UnixMicro() - default: - val = t.UnixNano() + if !isOptional || alreadyHandled { + writeRows(columns, levels, sparse.MakeInt64Array(buf.values).UnsafeArray()) + return + } + + i := 0 + empty := sparse.Array{} + for i < n { + j := i + isNull := times.Index(i).IsZero() + for j < n && times.Index(j).IsZero() == isNull { + j++ } - a := makeArray(reflectValueData(reflect.ValueOf(val)), 1, elemSize) - writeRows(columns, elemLevels, a) + if isNull { + for k := i; k < j; k++ { + writeRows(columns, levels, empty) + } + } else { + elemLevels := levels + elemLevels.definitionLevel++ + writeRows(columns, elemLevels, sparse.MakeInt64Array(buf.values[i:j]).UnsafeArray()) + } + i = j } } } diff --git a/vendor/github.com/parquet-go/parquet-go/compare.go b/vendor/github.com/parquet-go/parquet-go/compare.go index c37f2f7e066..49817afbce8 100644 --- a/vendor/github.com/parquet-go/parquet-go/compare.go +++ b/vendor/github.com/parquet-go/parquet-go/compare.go @@ -1,6 +1,7 @@ package parquet import ( + "bytes" "encoding/binary" "github.com/parquet-go/parquet-go/deprecated" @@ -226,12 +227,170 @@ func compareRowsFuncOfIndexColumns(compareFuncs []func(Row, Row) int) func(Row, //go:noinline func compareRowsFuncOfIndexAscending(columnIndex uint16, typ Type) func(Row, Row) int { - return func(row1, row2 Row) int { return typ.Compare(row1[columnIndex], row2[columnIndex]) } + switch t := typ.(type) { + case int32Type: + return func(row1, row2 Row) int { + return compareInt32(row1[columnIndex].int32(), row2[columnIndex].int32()) + } + case uint32Type: + return func(row1, row2 Row) int { + return compareUint32(row1[columnIndex].uint32(), row2[columnIndex].uint32()) + } + case int64Type: + return func(row1, row2 Row) int { + return compareInt64(row1[columnIndex].int64(), row2[columnIndex].int64()) + } + case uint64Type: + return func(row1, row2 Row) int { + return compareUint64(row1[columnIndex].uint64(), row2[columnIndex].uint64()) + } + case floatType: + return func(row1, row2 Row) int { + return compareFloat32(row1[columnIndex].float(), row2[columnIndex].float()) + } + case doubleType: + return func(row1, row2 Row) int { + return compareFloat64(row1[columnIndex].double(), row2[columnIndex].double()) + } + case booleanType: + return func(row1, row2 Row) int { + return compareBool(row1[columnIndex].boolean(), row2[columnIndex].boolean()) + } + case byteArrayType, *stringType, fixedLenByteArrayType, *enumType, *geographyType, *bsonType, *geometryType, *jsonType: + return func(row1, row2 Row) int { + return bytes.Compare(row1[columnIndex].byteArray(), row2[columnIndex].byteArray()) + } + case be128Type, *uuidType: + return func(row1, row2 Row) int { + return compareBE128(row1[columnIndex].be128(), row2[columnIndex].be128()) + } + case *dateType: + return func(row1, row2 Row) int { + return compareInt32(row1[columnIndex].int32(), row2[columnIndex].int32()) + } + case *timestampType: + return func(row1, row2 Row) int { + return compareInt64(row1[columnIndex].int64(), row2[columnIndex].int64()) + } + case *timeType: + if t.useInt32() { + return func(row1, row2 Row) int { + return compareInt32(row1[columnIndex].int32(), row2[columnIndex].int32()) + } + } else { + return func(row1, row2 Row) int { + return compareInt64(row1[columnIndex].int64(), row2[columnIndex].int64()) + } + } + case *intType: + if t.BitWidth == 64 { + if t.IsSigned { + return func(row1, row2 Row) int { + return compareInt64(row1[columnIndex].int64(), row2[columnIndex].int64()) + } + } else { + return func(row1, row2 Row) int { + return compareUint64(row1[columnIndex].uint64(), row2[columnIndex].uint64()) + } + } + } else { + if t.IsSigned { + return func(row1, row2 Row) int { + return compareInt32(row1[columnIndex].int32(), row2[columnIndex].int32()) + } + } else { + return func(row1, row2 Row) int { + return compareUint32(row1[columnIndex].uint32(), row2[columnIndex].uint32()) + } + } + } + default: + return func(row1, row2 Row) int { return typ.Compare(row1[columnIndex], row2[columnIndex]) } + } } //go:noinline func compareRowsFuncOfIndexDescending(columnIndex uint16, typ Type) func(Row, Row) int { - return func(row1, row2 Row) int { return -typ.Compare(row1[columnIndex], row2[columnIndex]) } + switch t := typ.(type) { + case int32Type: + return func(row1, row2 Row) int { + return -compareInt32(row1[columnIndex].int32(), row2[columnIndex].int32()) + } + case uint32Type: + return func(row1, row2 Row) int { + return -compareUint32(row1[columnIndex].uint32(), row2[columnIndex].uint32()) + } + case int64Type: + return func(row1, row2 Row) int { + return -compareInt64(row1[columnIndex].int64(), row2[columnIndex].int64()) + } + case uint64Type: + return func(row1, row2 Row) int { + return -compareUint64(row1[columnIndex].uint64(), row2[columnIndex].uint64()) + } + case floatType: + return func(row1, row2 Row) int { + return -compareFloat32(row1[columnIndex].float(), row2[columnIndex].float()) + } + case doubleType: + return func(row1, row2 Row) int { + return -compareFloat64(row1[columnIndex].double(), row2[columnIndex].double()) + } + case booleanType: + return func(row1, row2 Row) int { + return -compareBool(row1[columnIndex].boolean(), row2[columnIndex].boolean()) + } + case byteArrayType, *stringType, fixedLenByteArrayType, *enumType, *geographyType, *bsonType, *geometryType, *jsonType: + return func(row1, row2 Row) int { + return -bytes.Compare(row1[columnIndex].byteArray(), row2[columnIndex].byteArray()) + } + case be128Type, *uuidType: + return func(row1, row2 Row) int { + return -compareBE128(row1[columnIndex].be128(), row2[columnIndex].be128()) + } + case *dateType: + return func(row1, row2 Row) int { + return -compareInt32(row1[columnIndex].int32(), row2[columnIndex].int32()) + } + case *timestampType: + return func(row1, row2 Row) int { + return -compareInt64(row1[columnIndex].int64(), row2[columnIndex].int64()) + } + case *timeType: + if t.useInt32() { + return func(row1, row2 Row) int { + return -compareInt32(row1[columnIndex].int32(), row2[columnIndex].int32()) + } + } else { + return func(row1, row2 Row) int { + return -compareInt64(row1[columnIndex].int64(), row2[columnIndex].int64()) + } + } + case *intType: + if t.BitWidth == 64 { + if t.IsSigned { + return func(row1, row2 Row) int { + return -compareInt64(row1[columnIndex].int64(), row2[columnIndex].int64()) + } + } else { + return func(row1, row2 Row) int { + return -compareUint64(row1[columnIndex].uint64(), row2[columnIndex].uint64()) + } + } + } else { + if t.IsSigned { + return func(row1, row2 Row) int { + return -compareInt32(row1[columnIndex].int32(), row2[columnIndex].int32()) + } + } else { + return func(row1, row2 Row) int { + return -compareUint32(row1[columnIndex].uint32(), row2[columnIndex].uint32()) + } + } + } + default: + return func(row1, row2 Row) int { return -typ.Compare(row1[columnIndex], row2[columnIndex]) } + } } //go:noinline diff --git a/vendor/github.com/parquet-go/parquet-go/config.go b/vendor/github.com/parquet-go/parquet-go/config.go index 6492d07c798..a21f3ed2fac 100644 --- a/vendor/github.com/parquet-go/parquet-go/config.go +++ b/vendor/github.com/parquet-go/parquet-go/config.go @@ -319,6 +319,7 @@ func (c *WriterConfig) ConfigureWriter(config *WriterConfig) { SkipPageBounds: coalesceSlices(c.SkipPageBounds, config.SkipPageBounds), SkipPageStatistics: coalesceSlices(c.SkipPageStatistics, config.SkipPageStatistics), Encodings: encodings, + DictionaryMaxBytes: cmp.Or(c.DictionaryMaxBytes, config.DictionaryMaxBytes), SchemaConfig: cmp.Or(c.SchemaConfig, config.SchemaConfig), Encryption: cmp.Or(c.Encryption, config.Encryption), } diff --git a/vendor/github.com/parquet-go/parquet-go/convert.go b/vendor/github.com/parquet-go/parquet-go/convert.go index a1d0439945b..93195d04a49 100644 --- a/vendor/github.com/parquet-go/parquet-go/convert.go +++ b/vendor/github.com/parquet-go/parquet-go/convert.go @@ -62,8 +62,11 @@ type Conversion interface { type conversion struct { columns []conversionColumn - schema *Schema - buffers memory.Pool[conversionBuffer] + // Shredded variant columns of the source being reconstructed to + // unshredded variant columns of the target (see convert_variant.go). + variants []variantConversion + schema *Schema + buffers memory.Pool[conversionBuffer] // This field is used to size the column buffers held in the memory.Pool since // they are intended to store the source rows being converted from. numberOfSourceColumns int @@ -71,6 +74,9 @@ type conversion struct { type conversionBuffer struct { columns [][]Value + // Per-variant-conversion scratch space, reused across rows (see + // convert_variant.go). + variants []variantScratch } type conversionColumn struct { @@ -78,6 +84,11 @@ type conversionColumn struct { convertValues conversionFunc targetKind Kind // Target column kind for creating proper null values isOptional bool // Whether the target column is optional (for null handling) + // Index in conversion.variants of the variant conversion producing this + // column, or -1; variantOutput selects its metadata (0) or value (1) + // output column. + variantIndex int + variantOutput int } type conversionFunc func([]Value) error @@ -189,6 +200,17 @@ func convertToLevels(repetitionLevels, definitionLevels []byte) conversionFunc { for i := range column { r := column[i].repetitionLevel d := column[i].definitionLevel + // Source levels that exceed the lookup-table size can be produced + // when maskMissingRowGroupColumns or sibling-fallback synthesizes + // values for schemas where source and target disagree on optionality + // or nesting depth. Without this guard, the convertedRows reader + // panics with "index out of range" inside this hot loop. Treat the + // value as null so downstream Reconstruct skips it instead of + // dereferencing a placeholder's nil byte-array pointer. + if int(r) >= len(repetitionLevels) || int(d) >= len(definitionLevels) { + column[i] = Value{} + continue + } column[i].repetitionLevel = repetitionLevels[r] column[i].definitionLevel = definitionLevels[d] } @@ -218,7 +240,8 @@ func (c *conversion) getBuffer() *conversionBuffer { return c.buffers.Get( func() *conversionBuffer { b := &conversionBuffer{ - columns: make([][]Value, c.numberOfSourceColumns), + columns: make([][]Value, c.numberOfSourceColumns), + variants: make([]variantScratch, len(c.variants)), } values := make([]Value, c.numberOfSourceColumns) for i := range b.columns { @@ -250,7 +273,26 @@ func (c *conversion) Convert(rows []Row) (int, error) { }) row = row[:0] + // Reconstruct shredded variant columns once per row; the column + // loop below picks up the metadata and value outputs. + for k := range c.variants { + if err := c.variants[k].convert(source.columns, &source.variants[k]); err != nil { + return n, err + } + } + for columnIndex, conv := range c.columns { + if conv.variantIndex >= 0 { + // Values already carry final levels and column indexes. + scratch := &source.variants[conv.variantIndex] + if conv.variantOutput == 0 { + row = append(row, scratch.metas...) + } else { + row = append(row, scratch.values...) + } + continue + } + columnOffset := len(row) // Get source values if available @@ -318,6 +360,11 @@ func (id identity) Schema() *Schema { return id.schema } // stripped out of the rows. Extra columns in the target schema will be set to // null or zero values. // +// Variant columns that the target declares unshredded but the source stores +// shredded are reconstructed with the construct_variant algorithm of the +// Variant Shredding specification instead of being mapped column-by-column +// (see convert_variant.go). +// // The returned function is intended to be used to append the converted source // row to the destination buffer. func Convert(to, from Node) (conv Conversion, err error) { @@ -330,6 +377,34 @@ func Convert(to, from Node) (conv Conversion, err error) { return identity{schema}, nil } + // Variant columns that the target declares unshredded but the source + // stores shredded are reconstructed, not mapped column-by-column (see + // convert_variant.go). + variants := findVariantConversions(to, from) + variantColumns := make(map[int]conversionColumn, 2*len(variants)) + for k := range variants { + vc := &variants[k] + metaSource, valueSource := 0, 0 + if vc.group != nil { + metaSource = vc.group.metadataCol + // Shredded groups without a value column are legal; any column + // of the group keeps the source chunk mapping meaningful. + valueSource = max(vc.group.valueCol, 0) + } + variantColumns[vc.targetMetaCol] = conversionColumn{ + sourceIndex: vc.sourceStart + metaSource, + targetKind: ByteArray, + variantIndex: k, + variantOutput: 0, + } + variantColumns[vc.targetValueCol] = conversionColumn{ + sourceIndex: vc.sourceStart + valueSource, + targetKind: ByteArray, + variantIndex: k, + variantOutput: 1, + } + } + targetMapping, targetColumns := columnMappingOf(to) sourceMapping, sourceColumns := columnMappingOf(from) columns := make([]conversionColumn, len(targetColumns)) @@ -352,6 +427,11 @@ func Convert(to, from Node) (conv Conversion, err error) { } for i, path := range targetColumns { + if cc, ok := variantColumns[i]; ok { + columns[i] = cc + continue + } + targetColumn := targetMapping.lookup(path) sourceColumn := sourceMapping.lookup(path) @@ -455,11 +535,13 @@ func Convert(to, from Node) (conv Conversion, err error) { convertValues: multiConversionFunc(conversions), targetKind: targetType.Kind(), // Store target kind for null value creation isOptional: isOptional, + variantIndex: -1, } } c := &conversion{ columns: columns, + variants: variants, schema: schema, numberOfSourceColumns: len(sourceColumns), } @@ -648,6 +730,17 @@ func maskMissingRowGroupColumns(r RowGroup, numColumns int, conv Conversion) Row } } + // Shredded variant reconstruction reads every leaf column of the + // variant group, not just the ones mapped to target columns. + if c, ok := conv.(*conversion); ok { + for k := range c.variants { + vc := &c.variants[k] + for j := vc.sourceStart; j < vc.sourceStart+vc.numCols && j < len(columns); j++ { + columns[j] = rowGroupColumns[j] + } + } + } + return &rowGroup{ schema: r.Schema(), numRows: numRows, @@ -1570,15 +1663,13 @@ func timestamp(v Value, u format.TimeUnit, tz *time.Location) time.Time { return unixEpoch.In(tz).Add(time.Duration(v.int64()) * timeUnitDuration(u)) } +// timeUnitDuration returns the precision of unit, defaulting to nanoseconds +// when the unit is unset (an unknown unit written by a newer implementation). func timeUnitDuration(unit format.TimeUnit) time.Duration { - switch { - case unit.Millis != nil: - return time.Millisecond - case unit.Micros != nil: - return time.Microsecond - default: + if unit.Value == nil { return time.Nanosecond } + return unit.Value.Duration() } func invalidConversion(value Value, from, to string) error { diff --git a/vendor/github.com/parquet-go/parquet-go/convert_variant.go b/vendor/github.com/parquet-go/parquet-go/convert_variant.go new file mode 100644 index 00000000000..48b53afadea --- /dev/null +++ b/vendor/github.com/parquet-go/parquet-go/convert_variant.go @@ -0,0 +1,235 @@ +package parquet + +import ( + "fmt" + + "github.com/parquet-go/parquet-go/variant" +) + +// This file teaches schema conversion to read shredded variant columns. +// When the target schema declares an unshredded variant group (metadata, +// value) and the source schema stores the column shredded (metadata, value, +// typed_value), the conversion reconstructs each value with the +// construct_variant algorithm (see variant_shredded_read.go) and emits the +// re-encoded variant binary. Without this, the generic column mapping would +// silently drop the typed_value columns, losing every shredded value. +// +// Because every read path funnels through Convert when the reader and file +// schemas differ, this single integration point makes shredded files +// readable by any reader that declares a plain variant column. + +// variantConversion reconstructs one shredded variant column during row +// conversion. +type variantConversion struct { + group *shreddedVariantGroup + // A source group that cannot be reconstructed (e.g. an unsupported + // shredded type) fails when rows are read, not when the conversion is + // constructed, matching how readers report other malformed files. + err error + numCols int // leaf columns of the source variant group + sourceStart int // first source leaf column of the variant group + + targetMetaCol int + targetValueCol int + targetDef byte // definition level of the target leaves when present + + sourceGroupDef int // definition level at which the source group is present + sourceGroupRep int // repetition level of the source group + + // Source-to-target level mappings for the path down to the variant + // group, used for occurrences where the group is null because of a + // null enclosing level. + defLevels []byte + repLevels []byte +} + +// findVariantConversions walks the target and source schemas in parallel +// and returns a conversion for every variant column that the target +// declares unshredded and the source stores shredded. +func findVariantConversions(to, from Node) []variantConversion { + var conversions []variantConversion + walkVariantConversions(to, from, 0, 0, 0, 0, 0, 0, []byte{0}, []byte{0}, &conversions) + return conversions +} + +func walkVariantConversions(t, s Node, tCol, sCol int, tRep, tDef, sRep, sDef byte, repLevels, defLevels []byte, conversions *[]variantConversion) { + if isVariant(t) && isVariant(s) && isUnshreddedVariant(t) && !isUnshreddedVariant(s) { + if vc := makeVariantConversion(t, s, tCol, sCol, tDef, sDef, sRep, repLevels, defLevels); vc != nil { + *conversions = append(*conversions, *vc) + } + return + } + if t.Leaf() || s.Leaf() { + return + } + sColOf := make(map[string]int, len(s.Fields())) + sFieldOf := make(map[string]Field, len(s.Fields())) + col := sCol + for _, sf := range s.Fields() { + sColOf[sf.Name()] = col + sFieldOf[sf.Name()] = sf + col += int(numLeafColumnsOf(sf)) + } + for _, tf := range t.Fields() { + if sf, ok := sFieldOf[tf.Name()]; ok { + tr, td := applyFieldRepetitionType(fieldRepetitionTypeOf(tf), tRep, tDef) + sr, sd := applyFieldRepetitionType(fieldRepetitionTypeOf(sf), sRep, sDef) + walkVariantConversions( + tf, sf, + tCol, sColOf[tf.Name()], + tr, td, sr, sd, + setLevelMapping(repLevels, sr, tr), + setLevelMapping(defLevels, sd, td), + conversions, + ) + } + tCol += int(numLeafColumnsOf(tf)) + } +} + +// makeVariantConversion builds the conversion for one variant column. The +// level arguments are those of the variant group nodes themselves. A nil +// result means the target group does not have the expected metadata and +// value leaves and the generic column mapping applies. +func makeVariantConversion(t, s Node, tCol, sCol int, tDef, sDef, sRep byte, repLevels, defLevels []byte) *variantConversion { + vc := &variantConversion{ + numCols: int(numLeafColumnsOf(s)), + sourceStart: sCol, + targetMetaCol: -1, + targetValueCol: -1, + targetDef: tDef, + sourceGroupDef: int(sDef), + sourceGroupRep: int(sRep), + defLevels: defLevels, + repLevels: repLevels, + } + col := tCol + for _, tf := range t.Fields() { + if !tf.Leaf() || tf.Type().Kind() != ByteArray || tf.Optional() { + return nil + } + switch tf.Name() { + case "metadata": + vc.targetMetaCol = col + case "value": + vc.targetValueCol = col + } + col++ + } + if vc.targetMetaCol < 0 || vc.targetValueCol < 0 { + return nil + } + + vc.group, vc.err = buildShreddedVariantGroup(s, 0, 0, 0) + if vc.err == nil && vc.group.metadataCol < 0 { + vc.group, vc.err = nil, fmt.Errorf("variant: shredded variant group has no metadata field") + } + return vc +} + +// setLevelMapping returns a copy of the source-to-target level mapping with +// the entry for the source level set, extending the table when the source +// level is new (each schema step adds at most one level). +func setLevelMapping(levels []byte, source, target byte) []byte { + mapping := make([]byte, max(len(levels), int(source)+1)) + copy(mapping, levels) + mapping[source] = target + return mapping +} + +// variantScratch is the per-row state of one variant conversion, pooled in +// conversionBuffer so converting a row does not allocate it anew. +type variantScratch struct { + pos []int + metas []Value + values []Value +} + +// convert reconstructs every occurrence of the variant column in the +// current row from the source columns, leaving the values of the target +// metadata and value columns in the scratch space. +func (vc *variantConversion) convert(source [][]Value, scratch *variantScratch) error { + if vc.err != nil { + return vc.err + } + columns := source[vc.sourceStart : vc.sourceStart+vc.numCols] + if cap(scratch.pos) < len(columns) { + scratch.pos = make([]int, len(columns)) + } + scratch.pos = scratch.pos[:len(columns)] + clear(scratch.pos) + scratch.metas = scratch.metas[:0] + scratch.values = scratch.values[:0] + reader := variantColumnReader{columns: columns, pos: scratch.pos} + metaIdx := ^uint16(vc.targetMetaCol) + valueIdx := ^uint16(vc.targetValueCol) + + for { + metaVal, ok := reader.peek(vc.group.metadataCol) + if !ok { + break + } + + // The level mapping tables cover the levels the schema can + // produce; corrupt files can carry level bytes beyond them, which + // must surface as a decode error rather than a panic. + if int(metaVal.repetitionLevel) >= len(vc.repLevels) || int(metaVal.definitionLevel) >= len(vc.defLevels) { + return fmt.Errorf("variant: metadata column has levels (r=%d, d=%d) outside the schema's levels", + metaVal.repetitionLevel, metaVal.definitionLevel) + } + + if int(metaVal.definitionLevel) < vc.sourceGroupDef { + // The variant group is null at this occurrence; every leaf + // column of the group carries exactly one value at the + // enclosing level to consume. + rep := vc.repLevels[metaVal.repetitionLevel] + def := vc.defLevels[metaVal.definitionLevel] + scratch.metas = append(scratch.metas, Value{repetitionLevel: rep, definitionLevel: def, columnIndex: metaIdx}) + scratch.values = append(scratch.values, Value{repetitionLevel: rep, definitionLevel: def, columnIndex: valueIdx}) + for col := range columns { + reader.next(col) + } + continue + } + + reader.next(vc.group.metadataCol) + m, err := variant.DecodeMetadata(metaVal.ByteArray()) + if err != nil { + return fmt.Errorf("variant metadata: %w", err) + } + v, present, err := vc.group.read(&reader, m, vc.sourceGroupDef, vc.sourceGroupRep) + if err != nil { + return err + } + if !present { + // value and typed_value both null at the top level is invalid + // per the spec; read it as variant null (matching parquet-java). + v = variant.Null() + } + + var b variant.MetadataBuilder + encoded := variant.Encode(&b, v) + _, metadata := b.Build() + rep := vc.repLevels[metaVal.repetitionLevel] + + metaValue := ByteArrayValue(metadata) + metaValue.repetitionLevel = rep + metaValue.definitionLevel = vc.targetDef + metaValue.columnIndex = metaIdx + + valueValue := ByteArrayValue(encoded) + valueValue.repetitionLevel = rep + valueValue.definitionLevel = vc.targetDef + valueValue.columnIndex = valueIdx + + scratch.metas = append(scratch.metas, metaValue) + scratch.values = append(scratch.values, valueValue) + } + if len(scratch.metas) == 0 { + // No values in the source columns for this row; emit a null pair + // to maintain the one-value-per-column invariant. + scratch.metas = append(scratch.metas, Value{columnIndex: metaIdx}) + scratch.values = append(scratch.values, Value{columnIndex: valueIdx}) + } + return nil +} diff --git a/vendor/github.com/parquet-go/parquet-go/encoding/rle/rle.go b/vendor/github.com/parquet-go/parquet-go/encoding/rle/rle.go index 6aef0ae3286..6d7bda6f694 100644 --- a/vendor/github.com/parquet-go/parquet-go/encoding/rle/rle.go +++ b/vendor/github.com/parquet-go/parquet-go/encoding/rle/rle.go @@ -260,6 +260,9 @@ func decodeBits(dst, src []byte) ([]byte, error) { i += n count, bitpacked := uint(u>>1), (u&1) != 0 + if count == 0 { + continue + } if count > maxSupportedValueCount { return dst, fmt.Errorf("decoded run-length block cannot have more than %d values", maxSupportedValueCount) } @@ -305,6 +308,9 @@ func decodeBytes(dst, src []byte, bitWidth uint) ([]byte, error) { i += n count, bitpacked := uint(u>>1), (u&1) != 0 + if count == 0 { + continue + } if count > maxSupportedValueCount { return dst, fmt.Errorf("decoded run-length block cannot have more than %d values", maxSupportedValueCount) } @@ -361,6 +367,9 @@ func decodeInt32(dst, src []byte, bitWidth uint) ([]byte, error) { i += n count, bitpacked := uint(u>>1), (u&1) != 0 + if count == 0 { + continue + } if count > maxSupportedValueCount { return dst, fmt.Errorf("decoded run-length block cannot have more than %d values", maxSupportedValueCount) } diff --git a/vendor/github.com/parquet-go/parquet-go/encoding/thrift/binary.go b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/binary.go index f9798be5a93..6f96bc0473e 100644 --- a/vendor/github.com/parquet-go/parquet-go/encoding/thrift/binary.go +++ b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/binary.go @@ -18,7 +18,7 @@ type BinaryProtocol struct { NonStrict bool } -func (p *BinaryProtocol) NewReaderFromBytes(b []byte) Reader { +func (p *BinaryProtocol) NewReaderFromBytes(b []byte) BytesReader { return &binaryBytesReader{p: p, data: b} } @@ -400,6 +400,11 @@ type binaryBytesReader struct { offset int } +func (r *binaryBytesReader) ResetBytes(b []byte) { + r.data = b + r.offset = 0 +} + func (r *binaryBytesReader) Protocol() Protocol { return r.p } @@ -408,6 +413,18 @@ func (r *binaryBytesReader) Reader() io.Reader { return bytes.NewReader(r.data[r.offset:]) } +// Discard advances the reader past the next n bytes, reporting how many +// bytes were discarded. Unlike reading through Reader(), it moves the +// reader's own offset, which skip operations rely on. +func (r *binaryBytesReader) Discard(n int) (int, error) { + if remain := len(r.data) - r.offset; remain < n { + r.offset = len(r.data) + return remain, io.ErrUnexpectedEOF + } + r.offset += n + return n, nil +} + func (r *binaryBytesReader) ReadBool() (bool, error) { b, err := r.ReadByte() // Thrift protocol treats both 0 and 2 as false. diff --git a/vendor/github.com/parquet-go/parquet-go/encoding/thrift/compact.go b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/compact.go index 249b3d8b9e8..b17b789c58b 100644 --- a/vendor/github.com/parquet-go/parquet-go/encoding/thrift/compact.go +++ b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/compact.go @@ -16,7 +16,7 @@ import ( // https://github.com/apache/thrift/blob/master/doc/specs/thrift-compact-protocol.md#integer-encoding type CompactProtocol struct{} -func (p *CompactProtocol) NewReaderFromBytes(b []byte) Reader { +func (p *CompactProtocol) NewReaderFromBytes(b []byte) BytesReader { return &compactBytesReader{protocol: p, data: b} } @@ -372,6 +372,11 @@ type compactBytesReader struct { offset int } +func (r *compactBytesReader) ResetBytes(b []byte) { + r.data = b + r.offset = 0 +} + func (r *compactBytesReader) Protocol() Protocol { return r.protocol } @@ -380,6 +385,18 @@ func (r *compactBytesReader) Reader() io.Reader { return bytes.NewReader(r.data[r.offset:]) } +// Discard advances the reader past the next n bytes, reporting how many +// bytes were discarded. Unlike reading through Reader(), it moves the +// reader's own offset, which skip operations rely on. +func (r *compactBytesReader) Discard(n int) (int, error) { + if remain := len(r.data) - r.offset; remain < n { + r.offset = len(r.data) + return remain, io.ErrUnexpectedEOF + } + r.offset += n + return n, nil +} + func (r *compactBytesReader) ReadBool() (bool, error) { b, err := r.ReadByte() // Thrift protocol treats both 0 and 2 as false. diff --git a/vendor/github.com/parquet-go/parquet-go/encoding/thrift/debug.go b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/debug.go index e8bf5763bf7..f3aa32533f1 100644 --- a/vendor/github.com/parquet-go/parquet-go/encoding/thrift/debug.go +++ b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/debug.go @@ -128,6 +128,16 @@ func (d *debugReader) BytesRead() int { return d.r.BytesRead() } +// Discard forwards discards to the wrapped reader. Without it, a +// debug-wrapped bytes-backed reader would fall through to a throwaway +// Reader() view and the discard would not advance the wrapped reader's +// offset, silently desynchronizing the stream. +func (d *debugReader) Discard(n int) (int, error) { + v, err := discard(d.r, n) + d.log("Discard", v, err) + return v, err +} + type debugWriter struct { w Writer l *log.Logger diff --git a/vendor/github.com/parquet-go/parquet-go/encoding/thrift/decode.go b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/decode.go index b1e3189297a..2145b768a15 100644 --- a/vendor/github.com/parquet-go/parquet-go/encoding/thrift/decode.go +++ b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/decode.go @@ -1,7 +1,6 @@ package thrift import ( - "bufio" "fmt" "io" "maps" @@ -18,8 +17,11 @@ import ( // // As an optimization, the value passed in v may be reused across multiple calls // to Unmarshal, allowing the function to reuse objects referenced by pointer -// fields of struct values. When reusing objects, the application is responsible -// for resetting the state of v before calling Unmarshal again. +// fields of struct values: non-nil pointer fields present in the input have +// their pointed-to value zeroed and decoded in place, and pointer fields +// absent from the input are set to nil. When reusing objects, the application +// remains responsible for resetting non-pointer state of v (scalars, strings, +// and slice lengths) before calling Unmarshal again. func Unmarshal(p Protocol, b []byte, v any) error { pr := p.NewReaderFromBytes(slices.Clone(b)) @@ -108,6 +110,10 @@ func DecodeFuncOf(t reflect.Type, seen DecodeFuncCache) DecodeFunc { return f } + if isUnion(t) { + return decodeFuncUnionOf(t, seen) + } + // Check if type implements Value interface first if t.Implements(valueType) { zv := reflect.Zero(t).Interface().(Value) @@ -247,7 +253,7 @@ func decodeFuncSliceOf(t reflect.Type, seen DecodeFuncCache) DecodeFunc { if flags.Have(Strict) { return &TypeMismatch{item: "list item", Expect: typ, Found: l.Type} } - return nil + return skipListItems(r, l) } size := int(l.Size) @@ -302,14 +308,14 @@ func decodeFuncMapOf(t reflect.Type, seen DecodeFuncCache) DecodeFunc { if flags.Have(Strict) { return &TypeMismatch{item: "map key", Expect: keyType, Found: m.Key} } - return nil + return skipMapItems(r, m) } if elemType != m.Value { if flags.Have(Strict) { return &TypeMismatch{item: "map value", Expect: elemType, Found: m.Value} } - return nil + return skipMapItems(r, m) } tmpKey := reflect.New(key).Elem() @@ -363,7 +369,7 @@ func decodeFuncMapAsSetOf(t reflect.Type, seen DecodeFuncCache) DecodeFunc { if flags.Have(Strict) { return &TypeMismatch{item: "list item", Expect: typ, Found: s.Type} } - return nil + return skipSetItems(r, s) } tmp := reflect.New(key).Elem() @@ -383,21 +389,29 @@ func decodeFuncMapAsSetOf(t reflect.Type, seen DecodeFuncCache) DecodeFunc { type structDecoder struct { fields []structDecoderField - union []int minID int16 - zero reflect.Value required []uint64 + // clears contains the indices (into fields) of pointer-typed and + // union-typed fields. Such fields absent from the input are zeroed + // after decoding, so that reusing a previously decoded value as the + // decode target produces the same result as decoding into a fresh + // value. Without this, stale pointers (or stale union members) from a + // previous decode would survive, which is invisible for regular + // optional fields but corrupts values where "which member is non-nil" + // carries meaning. + clears []int } func (dec *structDecoder) decode(r Reader, v reflect.Value, flags Flags) error { flags = flags.Only(decodeFlags) coalesceBool := flags.Have(coalesceBoolFields) - lastField := reflect.Value{} - union := len(dec.union) > 0 - seen := make([]uint64, 1) - if len(dec.required) > len(seen) { - seen = make([]uint64, len(dec.required)) + // seen tracks which of the (sparse, id-indexed) fields were observed + // in the input; required is sized to the same word count. + var seenBuf [4]uint64 + seen := seenBuf[:] + if n := len(dec.required); n > len(seenBuf) { + seen = make([]uint64, n) } // Inlined readStruct loop to avoid closure overhead @@ -424,7 +438,19 @@ decodeFields: } i := int(f.ID) - int(dec.minID) - if i < 0 || i >= len(dec.fields) || dec.fields[i].decode == nil { + var field *structDecoderField + if i >= 0 && i < len(dec.fields) && dec.fields[i].decode != nil { + field = &dec.fields[i] + } + // Unknown fields and (in non-strict mode) type-mismatched fields + // are consumed so the stream stays aligned, and left unseen: they + // were not decoded, so they must not satisfy the required check nor + // protect a stale pointer from the clearUnseen pass below. + // TODO: implement type conversions? + if field == nil || (f.Type != field.typ && !(f.Type == TRUE && field.typ == BOOL)) { + if field != nil && flags.Have(Strict) { + return &TypeMismatch{item: "field value", Expect: field.typ, Found: f.Type} + } if err := skip(r, f.Type); err != nil { return with(dontExpectEOF(err), &decodeErrorField{cause: f}) } @@ -432,19 +458,8 @@ decodeFields: numFields++ continue decodeFields } - field := &dec.fields[i] seen[i/64] |= 1 << (i % 64) - // TODO: implement type conversions? - if f.Type != field.typ && !(f.Type == TRUE && field.typ == BOOL) { - if flags.Have(Strict) { - return &TypeMismatch{item: "field value", Expect: field.typ, Found: f.Type} - } - lastFieldID = f.ID - numFields++ - continue decodeFields - } - x := v for _, i := range field.index { if x.Kind() == reflect.Ptr { @@ -457,12 +472,6 @@ decodeFields: } } - if union { - v.Set(dec.zero) - } - - lastField = x - if coalesceBool && (f.Type == TRUE || f.Type == FALSE) { for x.Kind() == reflect.Ptr { if x.IsNil() { @@ -503,8 +512,26 @@ decodeFields: } } - if union && lastField.IsValid() { - v.FieldByIndex(dec.union).Set(lastField.Addr()) +clearUnseen: + for _, i := range dec.clears { + if seen[i/64]&(1<<(i%64)) != 0 { + continue + } + x := v + for _, j := range dec.fields[i].index { + if x.Kind() == reflect.Ptr { + if x.IsNil() { + continue clearUnseen + } + x = x.Elem() + } + x = x.Field(j) + } + // x is either a pointer field or a union struct; zeroing a union + // nils its member interface, marking the union unset. + if x.Kind() != reflect.Ptr || !x.IsNil() { + x.SetZero() + } } return nil @@ -515,29 +542,25 @@ type structDecoderField struct { id int16 flags Flags typ Type + isPtr bool decode DecodeFunc } func decodeFuncStructOf(t reflect.Type, seen DecodeFuncCache) DecodeFunc { - dec := &structDecoder{ - zero: reflect.Zero(t), - } + dec := &structDecoder{} decode := dec.decode seen[t] = decode fields := make([]structDecoderField, 0, t.NumField()) forEachStructField(t, nil, func(f structField) { - if f.flags.Have(Union) { - dec.union = f.index - } else { - fields = append(fields, structDecoderField{ - index: f.index, - id: f.id, - flags: f.flags, - typ: TypeOf(f.typ), - decode: decodeFuncStructFieldOf(f, seen), - }) - } + fields = append(fields, structDecoderField{ + index: f.index, + id: f.id, + flags: f.flags, + typ: TypeOf(f.typ), + isPtr: f.typ.Kind() == reflect.Ptr, + decode: decodeFuncStructFieldOf(f, seen), + }) }) minID := int16(0) @@ -554,7 +577,7 @@ func decodeFuncStructOf(t reflect.Type, seen DecodeFuncCache) DecodeFunc { dec.fields = make([]structDecoderField, (maxID-minID)+1) dec.minID = minID - dec.required = make([]uint64, len(fields)/64+1) + dec.required = make([]uint64, (len(dec.fields)+63)/64) for _, f := range fields { i := f.id - minID @@ -566,6 +589,9 @@ func decodeFuncStructOf(t reflect.Type, seen DecodeFuncCache) DecodeFunc { if f.flags.Have(Required) { dec.required[i/64] |= 1 << (i % 64) } + if f.isPtr || f.flags.Have(UnionType) { + dec.clears = append(dec.clears, int(i)) + } } return decode @@ -587,6 +613,11 @@ func decodeFuncPtrOf(t reflect.Type, seen DecodeFuncCache) DecodeFunc { return func(r Reader, v reflect.Value, f Flags) error { if v.IsNil() { v.Set(reflect.New(elem)) + } else { + // Reuse the allocation but not the contents: optional fields + // of the pointed-to value that are absent from the input must + // not survive from a previous decode. + v.Elem().SetZero() } return decode(r, v.Elem(), f) } @@ -654,26 +685,34 @@ func skipBinary(r Reader) error { if n == 0 { return nil } - switch x := r.Reader().(type) { - case *bufio.Reader: - _, err = x.Discard(int(n)) - default: - _, err = io.CopyN(io.Discard, x, int64(n)) - } + _, err = discard(r, int(n)) return dontExpectEOF(err) } +type discarder interface{ Discard(int) (int, error) } + +// discard advances r past n bytes. The bytes-backed readers implement +// Discard themselves; their Reader() method returns a throwaway view that +// does not advance the read offset, so discarding through it would silently +// desynchronize the stream. Streaming readers discard through the +// underlying io.Reader when it supports it (*bufio.Reader does). +func discard(r Reader, n int) (int, error) { + if d, ok := r.(discarder); ok { + return d.Discard(n) + } + if d, ok := r.Reader().(discarder); ok { + return d.Discard(n) + } + c, err := io.CopyN(io.Discard, r.Reader(), int64(n)) + return int(c), err +} + func skipList(r Reader) error { l, err := r.ReadList() if err != nil { return err } - for i := range int(l.Size) { - if err := skip(r, l.Type); err != nil { - return with(dontExpectEOF(err), &decodeErrorList{cause: l, index: i}) - } - } - return nil + return skipListItems(r, l) } func skipSet(r Reader) error { @@ -681,12 +720,7 @@ func skipSet(r Reader) error { if err != nil { return err } - for i := range int(s.Size) { - if err := skip(r, s.Type); err != nil { - return with(dontExpectEOF(err), &decodeErrorSet{cause: s, index: i}) - } - } - return nil + return skipSetItems(r, s) } func skipMap(r Reader) error { @@ -694,11 +728,52 @@ func skipMap(r Reader) error { if err != nil { return err } + return skipMapItems(r, m) +} + +// skipItem consumes one container element of the given type. Unlike bool +// fields, whose value compact-protocol encoders coalesce into the field +// type, bool container elements always occupy one byte. +func skipItem(r Reader, t Type) error { + switch t { + case TRUE, FALSE: + _, err := r.ReadBool() + return err + default: + return skip(r, t) + } +} + +// skipListItems, skipSetItems, and skipMapItems consume the elements of a +// container whose header has already been read. They are used both by the +// skip functions above and by the decoders when the elements cannot be +// decoded into the target type: the payload must still be consumed, or the +// reader would desynchronize from the stream. + +func skipListItems(r Reader, l List) error { + for i := range int(l.Size) { + if err := skipItem(r, l.Type); err != nil { + return with(dontExpectEOF(err), &decodeErrorList{cause: l, index: i}) + } + } + return nil +} + +func skipSetItems(r Reader, s Set) error { + for i := range int(s.Size) { + if err := skipItem(r, s.Type); err != nil { + return with(dontExpectEOF(err), &decodeErrorSet{cause: s, index: i}) + } + } + return nil +} + +func skipMapItems(r Reader, m Map) error { for i := range int(m.Size) { - if err := skip(r, m.Key); err != nil { + if err := skipItem(r, m.Key); err != nil { return with(dontExpectEOF(err), &decodeErrorMap{cause: m, index: i}) } - if err := skip(r, m.Value); err != nil { + if err := skipItem(r, m.Value); err != nil { return with(dontExpectEOF(err), &decodeErrorMap{cause: m, index: i}) } } diff --git a/vendor/github.com/parquet-go/parquet-go/encoding/thrift/encode.go b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/encode.go index f9899312b37..b8f4391dc46 100644 --- a/vendor/github.com/parquet-go/parquet-go/encoding/thrift/encode.go +++ b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/encode.go @@ -79,6 +79,10 @@ func EncodeFuncOf(t reflect.Type, seen EncodeFuncCache) EncodeFunc { return f } + if isUnion(t) { + return encodeFuncUnionOf(t, seen) + } + // Check if type implements Value interface first if t.Implements(valueType) { zv := reflect.Zero(t).Interface().(Value) @@ -258,7 +262,6 @@ func encodeFuncMapAsSetOf(t reflect.Type, seen EncodeFuncCache) EncodeFunc { type structEncoder struct { fields []structEncoderField - union bool } func dereference(v reflect.Value) reflect.Value { @@ -347,20 +350,9 @@ encodeFields: return err } - if numFields > 1 && enc.union { - return fmt.Errorf("thrift union had more than one field with a non-zero value (%d)", numFields) - } - return nil } -func (enc *structEncoder) String() string { - if enc.union { - return "union" - } - return "struct" -} - type structEncoderField struct { index []int id int16 @@ -378,18 +370,14 @@ func encodeFuncStructOf(t reflect.Type, seen EncodeFuncCache) EncodeFunc { seen[t] = encode forEachStructField(t, nil, func(f structField) { - if f.flags.Have(Union) { - enc.union = true - } else { - enc.fields = append(enc.fields, structEncoderField{ - index: f.index, - id: f.id, - flags: f.flags, - typ: TypeOf(f.typ), - encode: encodeFuncStructFieldOf(f, seen), - null: nullFuncOf(f), - }) - } + enc.fields = append(enc.fields, structEncoderField{ + index: f.index, + id: f.id, + flags: f.flags, + typ: TypeOf(f.typ), + encode: encodeFuncStructFieldOf(f, seen), + null: nullFuncOf(f), + }) }) slices.SortStableFunc(enc.fields, func(a, b structEncoderField) int { @@ -423,6 +411,10 @@ func nullFuncOf(f structField) NullFunc { if f.flags.Have(Required) { return neverNull } + // Union structs are unset when their member field is nil. + if f.flags.Have(UnionType) { + return unionLayoutOf(f.typ).nullFunc() + } // Value types: use their NullFunc if f.flags.Have(ValueType) { zv := reflect.Zero(f.typ).Interface().(Value) diff --git a/vendor/github.com/parquet-go/parquet-go/encoding/thrift/list.go b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/list.go index 0fb66c02383..1d743d5a3cd 100644 --- a/vendor/github.com/parquet-go/parquet-go/encoding/thrift/list.go +++ b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/list.go @@ -69,7 +69,7 @@ func (l Slice[T]) DecodeFunc(cache DecodeFuncCache) DecodeFunc { if flags.Have(Strict) { return &TypeMismatch{item: "list item", Expect: elemType, Found: listHeader.Type} } - return nil + return skipListItems(r, listHeader) } size := int(listHeader.Size) diff --git a/vendor/github.com/parquet-go/parquet-go/encoding/thrift/protocol.go b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/protocol.go index 1640398a833..99242e74842 100644 --- a/vendor/github.com/parquet-go/parquet-go/encoding/thrift/protocol.go +++ b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/protocol.go @@ -25,7 +25,10 @@ const ( // However, the readers and writer that they instantiates are intended to be // used by a single goroutine. type Protocol interface { - NewReaderFromBytes(b []byte) Reader + // NewReaderFromBytes returns a reader over b. Every reader constructed from + // a byte slice can be repointed at another one, so the concrete BytesReader + // is returned rather than the wider Reader. + NewReaderFromBytes(b []byte) BytesReader NewReader(r io.Reader) Reader NewWriter(w io.Writer) Writer Features() Features @@ -53,6 +56,21 @@ type Reader interface { BytesRead() int } +// BytesReader is a Reader positioned over a fixed byte slice. +// +// ResetBytes repoints the reader at b and rewinds it, so a caller decoding many +// values from a byte buffer can reuse one reader instead of allocating one per +// value. +// +// Values decoded through a BytesReader may alias b: ReadBytes and ReadString +// return sub-slices of it rather than copies. Callers must keep b alive and +// unmodified for as long as the decoded values are used. This is why Unmarshal, +// which makes no such demand of its caller, clones its input. +type BytesReader interface { + Reader + ResetBytes(b []byte) +} + // Writer represents a low-level writer of values encoded according to one of // the thrift protocols. type Writer interface { diff --git a/vendor/github.com/parquet-go/parquet-go/encoding/thrift/struct.go b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/struct.go index 81f0fb2e69e..6b5ec7763d8 100644 --- a/vendor/github.com/parquet-go/parquet-go/encoding/thrift/struct.go +++ b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/struct.go @@ -13,7 +13,7 @@ type Flags int16 // Flag constants for struct field handling. const ( Enum Flags = 1 << 0 - Union Flags = 1 << 1 + UnionType Flags = 1 << 1 // indicates field implements Union interface Required Flags = 1 << 2 Optional Flags = 1 << 3 Strict Flags = 1 << 4 @@ -91,8 +91,6 @@ func forEachStructField(t reflect.Type, index []int, do func(structField)) { switch opt { case "enum": flags = flags.With(Enum) - case "union": - flags = flags.With(Union) case "required": flags = flags.With(Required) case "optional": @@ -108,21 +106,7 @@ func forEachStructField(t reflect.Type, index []int, do func(structField)) { panic(fmt.Errorf("thrift struct field cannot be both optional and required in `thrift:\"%s\"`", tag)) } - if flags.Have(Union) { - if f.Type.Kind() != reflect.Interface { - panic(fmt.Errorf("thrift union tag found on a field which is not an interface type `thrift:\"%s\"`", tag)) - } - - if tags[0] != "" { - panic(fmt.Errorf("invalid thrift field id on union field `thrift:\"%s\"`", tag)) - } - - do(structField{ - typ: f.Type, - index: fieldIndex, - flags: flags, - }) - } else { + { if flags.Have(Enum) { switch f.Type.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: @@ -132,8 +116,10 @@ func forEachStructField(t reflect.Type, index []int, do func(structField)) { } } - // Detect types implementing Value interface - if f.Type.Implements(valueType) { + // Detect union structs, then types implementing Value interface. + if isUnion(f.Type) { + flags = flags.With(UnionType) + } else if f.Type.Implements(valueType) { flags = flags.With(ValueType) } diff --git a/vendor/github.com/parquet-go/parquet-go/encoding/thrift/thrift.go b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/thrift.go index 861329efdc6..142d0e79aea 100644 --- a/vendor/github.com/parquet-go/parquet-go/encoding/thrift/thrift.go +++ b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/thrift.go @@ -130,6 +130,10 @@ func (m Map) String() string { } func TypeOf(t reflect.Type) Type { + if isUnion(t) { + return STRUCT + } + // Check if type implements Value interface first if t.Implements(valueType) { zv := reflect.Zero(t).Interface().(Value) diff --git a/vendor/github.com/parquet-go/parquet-go/encoding/thrift/union.go b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/union.go new file mode 100644 index 00000000000..14e29cded6c --- /dev/null +++ b/vendor/github.com/parquet-go/parquet-go/encoding/thrift/union.go @@ -0,0 +1,322 @@ +package thrift + +import ( + "fmt" + "reflect" +) + +// UnionMember is implemented by the concrete member types of a thrift union. +// +// FieldID returns the thrift field id that the member is encoded under. The id +// is intrinsic to the member type, which makes it impossible for a union to +// register the same member under two different ids. +// +// Implementations must declare FieldID on a pointer receiver and must not +// dereference it: unions register their members as typed nil pointers, and the +// codec calls FieldID on those values to build its dispatch table. +type UnionMember interface { + FieldID() int16 +} + +// Union is implemented by structs that encode as a thrift union. +// +// A union struct has exactly one field, of an interface type, holding at most +// one member. A nil field means the union is not set, and the struct is skipped +// when it appears as an optional field of another struct. +// +// UnionMembers returns the members the union may hold, as typed nil pointers: +// +// var logicalTypeMembers = []thrift.UnionMember{ +// (*StringType)(nil), +// (*MapType)(nil), +// } +// +// func (*LogicalType) UnionMembers() []thrift.UnionMember { return logicalTypeMembers } +// +// The returned slice is read once, when the codec for the union is built, so +// implementations should return a package-level value rather than construct it +// on each call. +type Union interface { + UnionMembers() []UnionMember +} + +var unionType = reflect.TypeFor[Union]() + +// isUnion reports whether t is a union struct. +// +// Unlike Value, which is probed on the value type because its implementations +// (Null, Slice) are value wrappers with value receivers, Union is probed on the +// pointer type. Union structs live in packages that declare their methods on +// pointer receivers, and a union only ever appears as an addressable struct +// field, so requiring the value method set would buy nothing and would force +// those packages into a mixed receiver set. +func isUnion(t reflect.Type) bool { + return t.Kind() == reflect.Struct && reflect.PointerTo(t).Implements(unionType) +} + +// unionMember describes one member of a union after validation. +type unionMember struct { + id int16 + // typ is the member struct type, i.e. the element of the registered *T. + typ reflect.Type + // interned holds a shared *T for zero-sized members, which carry no state + // and so can be handed out from every decode without allocating. + interned reflect.Value +} + +// unionLayout is the validated shape of a union struct, independent of whether +// it is being encoded or decoded. +type unionLayout struct { + typ reflect.Type + // field is the index of the interface field holding the member. + field int + members []unionMember + minID int16 + maxID int16 +} + +// unionLayoutOf validates t and describes its shape, panicking on any structural +// problem. Union codecs are built once per type, at the first encode or decode, +// so these panics surface at startup rather than on a hot path. +func unionLayoutOf(t reflect.Type) *unionLayout { + if t.Kind() != reflect.Struct { + panic(fmt.Errorf("thrift union %s is not a struct", t)) + } + if t.NumField() != 1 { + panic(fmt.Errorf("thrift union %s must have exactly one field, found %d", t, t.NumField())) + } + field := t.Field(0) + if field.Type.Kind() != reflect.Interface { + panic(fmt.Errorf("thrift union %s field %s must be an interface, found %s", t, field.Name, field.Type)) + } + + members := reflect.New(t).Interface().(Union).UnionMembers() + if len(members) == 0 { + panic(fmt.Errorf("thrift union %s declares no members", t)) + } + + layout := &unionLayout{typ: t, field: 0} + seen := make(map[int16]reflect.Type, len(members)) + + for _, m := range members { + if m == nil { + panic(fmt.Errorf("thrift union %s declares a nil member", t)) + } + mt := reflect.TypeOf(m) + if mt.Kind() != reflect.Ptr || mt.Elem().Kind() != reflect.Struct { + panic(fmt.Errorf("thrift union %s member %s must be a pointer to a struct", t, mt)) + } + if !mt.AssignableTo(field.Type) { + panic(fmt.Errorf("thrift union %s member %s is not assignable to %s", t, mt, field.Type)) + } + id := m.FieldID() + if id <= 0 { + panic(fmt.Errorf("thrift union %s member %s has an invalid field id %d", t, mt, id)) + } + if prev, ok := seen[id]; ok { + panic(fmt.Errorf("thrift union %s field id %d is present multiple times with types %s and %s", t, id, prev, mt)) + } + seen[id] = mt + + member := unionMember{id: id, typ: mt.Elem()} + if member.typ.Size() == 0 { + member.interned = reflect.New(member.typ) + } + layout.members = append(layout.members, member) + + if layout.minID == 0 || id < layout.minID { + layout.minID = id + } + if id > layout.maxID { + layout.maxID = id + } + } + + return layout +} + +// nullFunc reports the union as unset when its member field is nil. +func (layout *unionLayout) nullFunc() NullFunc { + field := layout.field + return func(v reflect.Value) bool { return v.Field(field).IsNil() } +} + +type unionEncoderMember struct { + id int16 + encode EncodeFunc +} + +type unionEncoder struct { + typ reflect.Type + field int + byType map[reflect.Type]unionEncoderMember +} + +func (enc *unionEncoder) encode(w Writer, v reflect.Value, flags Flags) error { + x := v.Field(enc.field) + + if !x.IsNil() { + p := x.Elem() + + m, ok := enc.byType[p.Type()] + if !ok { + return fmt.Errorf("thrift: %s is not a member of union %s", p.Type(), enc.typ) + } + + field := Field{ID: m.id, Type: STRUCT} + // A union writes a single field, so the previous field id is always + // zero and the delta is the id itself. This mirrors structEncoder so + // that unions and structs produce identical bytes for the same field. + if flags.Have(useDeltaEncoding) && field.ID <= 15 { + field.Delta = true + } + if err := w.WriteField(field); err != nil { + return err + } + + // A typed nil member encodes as an empty struct, matching the way + // encodeFuncPtrOf substitutes the zero value for a nil pointer. + if p.IsNil() { + p = reflect.New(p.Type().Elem()) + } + if err := m.encode(w, p.Elem(), flags); err != nil { + return err + } + } + + return w.WriteField(Field{Type: STOP}) +} + +func encodeFuncUnionOf(t reflect.Type, seen EncodeFuncCache) EncodeFunc { + layout := unionLayoutOf(t) + + enc := &unionEncoder{ + typ: t, + field: layout.field, + byType: make(map[reflect.Type]unionEncoderMember, len(layout.members)), + } + encode := enc.encode + seen[t] = encode + + for _, m := range layout.members { + enc.byType[reflect.PointerTo(m.typ)] = unionEncoderMember{ + id: m.id, + encode: EncodeFuncOf(m.typ, seen), + } + } + + return encode +} + +type unionDecoderMember struct { + // interned is a shared *T for zero-sized members, invalid otherwise. + interned reflect.Value + typ reflect.Type + // ptrTyp is *typ, kept to test whether a previously decoded member can + // be reused as the decode target without allocating. + ptrTyp reflect.Type + decode DecodeFunc +} + +type unionDecoder struct { + field int + minID int16 + members []unionDecoderMember +} + +func (dec *unionDecoder) decode(r Reader, v reflect.Value, flags Flags) error { + flags = flags.Only(decodeFlags) + + // Reset so that decoding into a reused value cannot retain a stale + // member, but remember the previous member: when the input holds a + // member of the same type, its allocation is reused instead of + // allocating a fresh value. + x := v.Field(dec.field) + prev := x.Elem() // invalid when the union was unset + x.SetZero() + + lastFieldID := int16(0) + numFields := 0 + + for { + f, err := r.ReadField() + if err != nil { + if numFields > 0 { + err = dontExpectEOF(err) + } + return err + } + + if f.Type == STOP { + return nil + } + + if f.Delta { + f.ID += lastFieldID + f.Delta = false + } + + i := int(f.ID) - int(dec.minID) + known := i >= 0 && i < len(dec.members) && dec.members[i].decode != nil + + switch { + case !known: + // An id we do not know: a member added by a newer writer. Skip it + // and leave the union unset rather than failing the whole decode. + if err := skip(r, f.Type); err != nil { + return with(dontExpectEOF(err), &decodeErrorField{cause: f}) + } + + case f.Type != STRUCT: + if flags.Have(Strict) { + return &TypeMismatch{item: "union member", Expect: STRUCT, Found: f.Type} + } + if err := skip(r, f.Type); err != nil { + return with(dontExpectEOF(err), &decodeErrorField{cause: f}) + } + + default: + m := &dec.members[i] + + p := m.interned + if !p.IsValid() { + if prev.IsValid() && prev.Type() == m.ptrTyp && !prev.IsNil() { + p = prev + p.Elem().SetZero() + } else { + p = reflect.New(m.typ) + } + } + if err := m.decode(r, p.Elem(), flags); err != nil { + return with(dontExpectEOF(err), &decodeErrorField{cause: f}) + } + x.Set(p) + } + + lastFieldID = f.ID + numFields++ + } +} + +func decodeFuncUnionOf(t reflect.Type, seen DecodeFuncCache) DecodeFunc { + layout := unionLayoutOf(t) + + dec := &unionDecoder{ + field: layout.field, + minID: layout.minID, + members: make([]unionDecoderMember, (layout.maxID-layout.minID)+1), + } + decode := dec.decode + seen[t] = decode + + for _, m := range layout.members { + dec.members[m.id-layout.minID] = unionDecoderMember{ + interned: m.interned, + typ: m.typ, + ptrTyp: reflect.PointerTo(m.typ), + decode: DecodeFuncOf(m.typ, seen), + } + } + + return decode +} diff --git a/vendor/github.com/parquet-go/parquet-go/errors.go b/vendor/github.com/parquet-go/parquet-go/errors.go index 651fe740c88..1d00774673a 100644 --- a/vendor/github.com/parquet-go/parquet-go/errors.go +++ b/vendor/github.com/parquet-go/parquet-go/errors.go @@ -9,7 +9,7 @@ var ( // ErrCorrupted is an error returned by the Err method of ColumnPages // instances when they encountered a mismatch between the CRC checksum // recorded in a page header and the one computed while reading the page - // data. + // data. Also returned on invalid headers / footer decoding. ErrCorrupted = errors.New("corrupted parquet page") // ErrMissingRootColumn is an error returned when opening an invalid parquet diff --git a/vendor/github.com/parquet-go/parquet-go/file.go b/vendor/github.com/parquet-go/parquet-go/file.go index 11c697b0464..d9fab37ff9c 100644 --- a/vendor/github.com/parquet-go/parquet-go/file.go +++ b/vendor/github.com/parquet-go/parquet-go/file.go @@ -142,13 +142,13 @@ func OpenFile(r io.ReaderAt, size int64, options ...FileOption) (*File, error) { // Extract AAD parameters from the encryption algorithm. var fileUnique, aadPrefix []byte - switch { - case cryptoMeta.EncryptionAlgorithm.AesGcmV1 != nil: - fileUnique = cryptoMeta.EncryptionAlgorithm.AesGcmV1.AadFileUnique - aadPrefix = cryptoMeta.EncryptionAlgorithm.AesGcmV1.AadPrefix - case cryptoMeta.EncryptionAlgorithm.AesGcmCtrV1 != nil: - fileUnique = cryptoMeta.EncryptionAlgorithm.AesGcmCtrV1.AadFileUnique - aadPrefix = cryptoMeta.EncryptionAlgorithm.AesGcmCtrV1.AadPrefix + switch algo := cryptoMeta.EncryptionAlgorithm.Value.(type) { + case *format.AesGcmV1: + fileUnique = algo.AadFileUnique + aadPrefix = algo.AadPrefix + case *format.AesGcmCtrV1: + fileUnique = algo.AadFileUnique + aadPrefix = algo.AadPrefix } footerKey, err := c.Decryption.Keys.FooterKey(cryptoMeta.KeyMetadata) @@ -184,15 +184,14 @@ func OpenFile(r io.ReaderAt, size int64, options ...FileOption) (*File, error) { if c.Decryption == nil { return nil, fmt.Errorf("parquet file has a signed footer but no DecryptionConfig was provided") } - algo := &f.metadata.EncryptionAlgorithm var fileUnique, aadPrefix []byte - switch { - case algo.AesGcmV1 != nil: - fileUnique = algo.AesGcmV1.AadFileUnique - aadPrefix = algo.AesGcmV1.AadPrefix - case algo.AesGcmCtrV1 != nil: - fileUnique = algo.AesGcmCtrV1.AadFileUnique - aadPrefix = algo.AesGcmCtrV1.AadPrefix + switch algo := f.metadata.EncryptionAlgorithm.Value.(type) { + case *format.AesGcmV1: + fileUnique = algo.AadFileUnique + aadPrefix = algo.AadPrefix + case *format.AesGcmCtrV1: + fileUnique = algo.AadFileUnique + aadPrefix = algo.AadPrefix } plainFooterBytes := footerData[:pr.BytesRead()] sig := footerData[pr.BytesRead():] @@ -382,7 +381,36 @@ func (f *File) ReadPageIndex() ([]format.ColumnIndex, []format.OffsetIndex, erro columnIndexes := make([]format.ColumnIndex, numColumnChunks) offsetIndexes := make([]format.OffsetIndex, numColumnChunks) - indexBuffer := make([]byte, max(int(columnIndexLength), int(offsetIndexLength))) + + // The column index and the offset index get separate buffers because the + // values decoded below alias them: ColumnIndex.MinValues and MaxValues are + // sub-slices of the bytes they were decoded from. A single shared buffer + // would be overwritten by the offset index read, corrupting the min/max + // statistics of every column. + var columnIndexBuffer, offsetIndexBuffer []byte + if columnIndexOffset > 0 { + columnIndexBuffer = make([]byte, columnIndexLength) + } + if offsetIndexOffset > 0 { + offsetIndexBuffer = make([]byte, offsetIndexLength) + } + + // One reader and one decoder are reused across every column chunk. Decoding + // each chunk with thrift.Unmarshal instead would clone the chunk's bytes and + // allocate a reader for it, twice per column chunk. + reader := f.protocol.NewReaderFromBytes(nil) + decoder := thrift.NewDecoder(reader) + + decode := func(b []byte, v any) error { + reader.ResetBytes(b) + if err := decoder.Decode(v); err != nil { + return err + } + if n := len(b) - reader.BytesRead(); n != 0 { + return fmt.Errorf("unexpected trailing bytes at the end of thrift input: %d", n) + } + return nil + } // pageIndexKey returns the AES key used to decrypt this column's // page-index modules, or nil for plaintext columns. We resolve keys here @@ -392,19 +420,18 @@ func (f *File) ReadPageIndex() ([]format.ColumnIndex, []format.OffsetIndex, erro if f.decryption == nil { return nil, nil } - switch { - case c.CryptoMetadata.EncryptionWithFooterKey != nil: + switch crypto := c.CryptoMetadata.Value.(type) { + case *format.EncryptionWithFooterKey: return f.decryption.Keys.FooterKey(nil) - case c.CryptoMetadata.EncryptionWithColumnKey != nil: - colKey := c.CryptoMetadata.EncryptionWithColumnKey - return f.decryption.Keys.ColumnKey(colKey.PathInSchema, colKey.KeyMetadata) + case *format.EncryptionWithColumnKey: + return f.decryption.Keys.ColumnKey(crypto.PathInSchema, crypto.KeyMetadata) default: return nil, nil } } if columnIndexOffset > 0 { - columnIndexData := indexBuffer[:columnIndexLength] + columnIndexData := columnIndexBuffer if cast, ok := f.reader.(interface{ SetColumnIndexSection(offset, length int64) }); ok { cast.SetColumnIndexSection(columnIndexOffset, columnIndexLength) @@ -437,7 +464,7 @@ func (f *File) ReadPageIndex() ([]format.ColumnIndex, []format.OffsetIndex, erro } buffer = plain } - if err := thrift.Unmarshal(&f.protocol, buffer, &columnIndexes[(i*numColumns)+j]); err != nil { + if err := decode(buffer, &columnIndexes[(i*numColumns)+j]); err != nil { return fmt.Errorf("decoding column index: rowGroup=%d columnChunk=%d/%d: %w", i, j, numColumns, err) } } @@ -449,7 +476,7 @@ func (f *File) ReadPageIndex() ([]format.ColumnIndex, []format.OffsetIndex, erro } if offsetIndexOffset > 0 { - offsetIndexData := indexBuffer[:offsetIndexLength] + offsetIndexData := offsetIndexBuffer if cast, ok := f.reader.(interface{ SetOffsetIndexSection(offset, length int64) }); ok { cast.SetOffsetIndexSection(offsetIndexOffset, offsetIndexLength) @@ -478,7 +505,7 @@ func (f *File) ReadPageIndex() ([]format.ColumnIndex, []format.OffsetIndex, erro } buffer = plain } - if err := thrift.Unmarshal(&f.protocol, buffer, &offsetIndexes[(i*numColumns)+j]); err != nil { + if err := decode(buffer, &offsetIndexes[(i*numColumns)+j]); err != nil { return fmt.Errorf("decoding offset index: rowGroup=%d columnChunk=%d/%d: %w", i, j, numColumns, err) } } @@ -513,17 +540,16 @@ func (f *File) decryptAllColumnMetadata() error { continue } var key []byte - switch { - case chunk.CryptoMetadata.EncryptionWithFooterKey != nil: + switch crypto := chunk.CryptoMetadata.Value.(type) { + case *format.EncryptionWithFooterKey: var err error key, err = f.decryption.Keys.FooterKey(nil) if err != nil { return fmt.Errorf("resolving footer key for column metadata: %w", err) } - case chunk.CryptoMetadata.EncryptionWithColumnKey != nil: - colKey := chunk.CryptoMetadata.EncryptionWithColumnKey + case *format.EncryptionWithColumnKey: var err error - key, err = f.decryption.Keys.ColumnKey(colKey.PathInSchema, colKey.KeyMetadata) + key, err = f.decryption.Keys.ColumnKey(crypto.PathInSchema, crypto.KeyMetadata) if err != nil { // Only treat an explicit ErrKeyNotFound as non-fatal: the // caller intentionally omitted this column's key. Any other @@ -664,16 +690,15 @@ func (g *FileRowGroup) init(file *File, columns []*Column, rowGroup *format.RowG } if file.decryption != nil { chunk := &rowGroup.Columns[i] - switch { - case chunk.CryptoMetadata.EncryptionWithFooterKey != nil: + switch crypto := chunk.CryptoMetadata.Value.(type) { + case *format.EncryptionWithFooterKey: key, err := file.decryption.Keys.FooterKey(nil) if err != nil { return fmt.Errorf("resolving footer key for column %q: %w", columnPathString(columns[i].Path()), err) } fileColumnChunks[i].decryptionKey = key - case chunk.CryptoMetadata.EncryptionWithColumnKey != nil: - colKey := chunk.CryptoMetadata.EncryptionWithColumnKey - key, err := file.decryption.Keys.ColumnKey(colKey.PathInSchema, colKey.KeyMetadata) + case *format.EncryptionWithColumnKey: + key, err := file.decryption.Keys.ColumnKey(crypto.PathInSchema, crypto.KeyMetadata) switch { case err == nil: fileColumnChunks[i].decryptionKey = key @@ -685,7 +710,7 @@ func (g *FileRowGroup) init(file *File, columns []*Column, rowGroup *format.RowG // Real error (KMS failure, bad metadata, …) must surface so // the caller learns the cause instead of seeing later // "decode page header" errors masking the missing key. - return fmt.Errorf("resolving column key for %q: %w", columnPathString(colKey.PathInSchema), err) + return fmt.Errorf("resolving column key for %q: %w", columnPathString(crypto.PathInSchema), err) } } } @@ -739,6 +764,11 @@ func (g *FileRowGroup) Rows() Rows { return NewRowGroupRowReader(rowGroup) } +// chunkTransparentRowGroup marks FileRowGroup as safe for the chunk-level write +// fast paths: its Rows() reads the file column chunks in order with no +// additional semantics. +func (g *FileRowGroup) chunkTransparentRowGroup() {} + type fileSortingColumn struct { column *Column descending bool @@ -1030,9 +1060,10 @@ func (c *FileColumnChunk) readBloomFilter(reader io.ReaderAt) (*FileBloomFilter, if err := decoder.Decode(&header); err != nil { return nil, fmt.Errorf("decoding bloom filter header: %w", err) } - offset, _ = section.Seek(0, io.SeekCurrent) + sectionPos, _ := section.Seek(0, io.SeekCurrent) + dataOffset := offset + sectionPos - int64(rbuf.Buffered()) var err error - filter, err = newBloomFilter(reader, offset, &header) + filter, err = newBloomFilter(reader, dataOffset, &header) if err != nil { return nil, fmt.Errorf("reading bloom filter: %w", err) } @@ -1193,6 +1224,9 @@ func (f *FilePages) ReadPage() (Page, error) { if err = f.decoder.Decode(header); err != nil { return nil, err } + if err = validatePageHeader(header); err != nil { + return nil, err + } // if this is a dictionary page and we've already read and decoded the dictionary we can skip past it. // call f.rbuf.Discard to skip the page data and realign f.rbuf with the next page header @@ -1305,6 +1339,9 @@ func (f *FilePages) readDictionary() error { if err := thrift.NewDecoder(pr).Decode(header); err != nil { return fmt.Errorf("parquet decryption: decoding dict page header: %w", err) } + if err := validatePageHeader(header); err != nil { + return err + } bodyAAD := makeAAD(d.aadPrefix, d.fileUnique, dictPageBodyModule, d.rowGroupOrdinal, d.columnOrdinal, 0) bodyPlain, err := readDecryptedEnvelopeFrom(rbuf, d.key, bodyAAD) if err != nil { @@ -1318,6 +1355,9 @@ func (f *FilePages) readDictionary() error { if err := decoder.Decode(header); err != nil { return err } + if err := validatePageHeader(header); err != nil { + return err + } page = buffers.get(int(header.CompressedPageSize)) page.ref() if _, err := io.ReadFull(rbuf, page.data.Slice()); err != nil { @@ -1368,6 +1408,42 @@ func (f *FilePages) readDataPageV2(header *format.PageHeader, page *buffer[byte] return f.chunk.column.decodeDataPageV2(DataPageHeaderV2{&header.DataPageHeaderV2.V}, page, f.dictionary, header.UncompressedPageSize) } +// validatePageHeader rejects page headers whose size or count fields decoded to +// negative values. Those values end up being trusted by the code later on +// which results in panics if they're off +func validatePageHeader(header *format.PageHeader) error { + reject := func(field string, value int32) error { + return fmt.Errorf("invalid page header: %s=%d: %w", field, value, ErrCorrupted) + } + if header.CompressedPageSize < 0 { + return reject("compressed_page_size", header.CompressedPageSize) + } + if header.UncompressedPageSize < 0 { + return reject("uncompressed_page_size", header.UncompressedPageSize) + } + if h := header.DataPageHeader; h.Valid && h.V.NumValues < 0 { + return reject("data_page_header.num_values", h.V.NumValues) + } + if h := header.DictionaryPageHeader; h.Valid && h.V.NumValues < 0 { + return reject("dictionary_page_header.num_values", h.V.NumValues) + } + if h := header.DataPageHeaderV2; h.Valid { + switch { + case h.V.NumValues < 0: + return reject("data_page_header_v2.num_values", h.V.NumValues) + case h.V.NumNulls < 0: + return reject("data_page_header_v2.num_nulls", h.V.NumNulls) + case h.V.NumRows < 0: + return reject("data_page_header_v2.num_rows", h.V.NumRows) + case h.V.RepetitionLevelsByteLength < 0: + return reject("data_page_header_v2.repetition_levels_byte_length", h.V.RepetitionLevelsByteLength) + case h.V.DefinitionLevelsByteLength < 0: + return reject("data_page_header_v2.definition_levels_byte_length", h.V.DefinitionLevelsByteLength) + } + } + return nil +} + func (f *FilePages) readPage(header *format.PageHeader, reader *bufio.Reader) (*buffer[byte], error) { page := buffers.get(int(header.CompressedPageSize)) defer page.unref() @@ -1448,6 +1524,9 @@ func (f *FilePages) readEncryptedPage() (*format.PageHeader, *buffer[byte], erro if err := thrift.NewDecoder(pr).Decode(header); err != nil { return nil, nil, fmt.Errorf("parquet decryption: decoding page header: %w", err) } + if err := validatePageHeader(header); err != nil { + return nil, nil, err + } bodyAAD := makeAAD(d.aadPrefix, d.fileUnique, bodyModuleType, d.rowGroupOrdinal, d.columnOrdinal, pageOrd) bodyPlain, err := readDecryptedEnvelopeFrom(f.rbuf, d.key, bodyAAD) diff --git a/vendor/github.com/parquet-go/parquet-go/format/footer.go b/vendor/github.com/parquet-go/parquet-go/format/footer.go new file mode 100644 index 00000000000..df439cefe89 --- /dev/null +++ b/vendor/github.com/parquet-go/parquet-go/format/footer.go @@ -0,0 +1,63 @@ +package format + +import ( + "fmt" + + "github.com/parquet-go/parquet-go/encoding/thrift" +) + +// FooterDecoder decodes Parquet file footers (thrift compact protocol) with +// zero steady-state allocations by retaining its input buffer and decoded +// metadata across calls to Decode. +// +// The zero value is ready to use. FooterDecoder values must not be copied +// after first use and are not safe for concurrent use; to amortize +// allocations across goroutines, keep decoders in a sync.Pool. +// +// A decoder never allocates for inputs whose shape fits the capacity +// retained from previous decodes; larger or differently-shaped inputs grow +// the retained state as needed. The retained state never shrinks: one +// unusually large footer sizes the decoder's buffer and metadata tree for +// its remaining lifetime, so long-lived decoders dedicated to a single file +// may prefer to be discarded after use instead of pooled. +type FooterDecoder struct { + buf []byte + meta FileMetaData + reader thrift.BytesReader + decoder *thrift.Decoder +} + +// protocol is stateless and shared by all decoders. +var footerProtocol thrift.CompactProtocol + +// Decode parses the thrift-encoded footer in data and returns the decoded +// metadata along with the number of bytes consumed. Trailing bytes after the +// thrift payload (such as the 28-byte AES-GCM footer signature written by +// encrypted-footer-signing writers) are not an error; callers can detect +// them by comparing the consumed byte count to len(data). +// +// The returned metadata, and all strings and byte slices it references, are +// owned by the decoder and remain valid only until the next call to Decode. +// Callers that need the metadata to outlive the decoder must deep-copy it. +// +// Decode makes a private copy of data; the caller retains ownership of the +// slice and may reuse it immediately. +func (d *FooterDecoder) Decode(data []byte) (*FileMetaData, int, error) { + // The decoded metadata aliases the retained buffer, so the copy below + // would corrupt previously returned values in place. Resetting first + // keeps the "valid until next Decode" contract honest instead of + // leaving values that are subtly wrong. + d.meta.Reset() + d.buf = append(d.buf[:0], data...) + + if d.reader == nil { + d.reader = footerProtocol.NewReaderFromBytes(nil) + d.decoder = thrift.NewDecoder(d.reader) + } + d.reader.ResetBytes(d.buf) + + if err := d.decoder.Decode(&d.meta); err != nil { + return nil, 0, fmt.Errorf("decoding parquet footer: %w", err) + } + return &d.meta, d.reader.BytesRead(), nil +} diff --git a/vendor/github.com/parquet-go/parquet-go/format/parquet.go b/vendor/github.com/parquet-go/parquet-go/format/parquet.go index 26a5de5d2cb..d27f3aa1a50 100644 --- a/vendor/github.com/parquet-go/parquet-go/format/parquet.go +++ b/vendor/github.com/parquet-go/parquet-go/format/parquet.go @@ -3,6 +3,7 @@ package format import ( "fmt" "strings" + "time" "github.com/parquet-go/parquet-go/deprecated" "github.com/parquet-go/parquet-go/encoding/thrift" @@ -103,13 +104,13 @@ type SizeStatistics struct { // // This field may be omitted if max_repetition_level is 0 without loss // of information. - RepetitionLevelHistogram []int64 `thrift:"2,optional"` + RepetitionLevelHistogram thrift.Slice[int64] `thrift:"2,optional"` // Same as repetition_level_histogram except for definition levels. // // This field may be omitted if max_definition_level is 0 or 1 without // loss of information. - DefinitionLevelHistogram []int64 `thrift:"3,optional"` + DefinitionLevelHistogram thrift.Slice[int64] `thrift:"3,optional"` } // Bounding box for GEOMETRY or GEOGRAPHY type in the representation of min/max @@ -130,7 +131,7 @@ type GeospatialStatistics struct { // A bounding box of geospatial instances BBox BoundingBox `thrift:"1,optional"` // Geospatial type codes of all instances, or an empty list if not known - GeoSpatialTypes []int32 `thrift:"2,optional"` + GeoSpatialTypes thrift.Slice[int32] `thrift:"2,optional"` } // Statistics per row group and per page. @@ -181,6 +182,14 @@ func (*EnumType) String() string { return "ENUM" } func (*DateType) String() string { return "DATE" } func (*Float16Type) String() string { return "FLOAT16" } +func (*StringType) FieldID() int16 { return 1 } +func (*MapType) FieldID() int16 { return 2 } +func (*ListType) FieldID() int16 { return 3 } +func (*EnumType) FieldID() int16 { return 4 } +func (*DateType) FieldID() int16 { return 6 } +func (*UUIDType) FieldID() int16 { return 14 } +func (*Float16Type) FieldID() int16 { return 15 } + // Logical type to annotate a column that is always null. // // Sometimes when discovering the schema of existing data, values are always @@ -189,6 +198,7 @@ func (*Float16Type) String() string { return "FLOAT16" } type NullType struct{} func (*NullType) String() string { return "NULL" } +func (*NullType) FieldID() int16 { return 11 } // Decimal logical type annotation // @@ -206,6 +216,8 @@ func (t *DecimalType) String() string { return fmt.Sprintf("DECIMAL(%d,%d)", t.Precision, t.Scale) } +func (*DecimalType) FieldID() int16 { return 5 } + // Time units for logical types. type MilliSeconds struct{} type MicroSeconds struct{} @@ -215,23 +227,44 @@ func (*MilliSeconds) String() string { return "MILLIS" } func (*MicroSeconds) String() string { return "MICROS" } func (*NanoSeconds) String() string { return "NANOS" } +func (*MilliSeconds) FieldID() int16 { return 1 } +func (*MicroSeconds) FieldID() int16 { return 2 } +func (*NanoSeconds) FieldID() int16 { return 3 } + +// Duration returns the precision of the time unit. It is the length of one +// step, so a value stored in this unit is that many of these durations since +// the epoch or midnight. +func (*MilliSeconds) Duration() time.Duration { return time.Millisecond } +func (*MicroSeconds) Duration() time.Duration { return time.Microsecond } +func (*NanoSeconds) Duration() time.Duration { return time.Nanosecond } + +// TimeUnitValue is the set of time units a TimeUnit union may hold. Duration is +// intrinsic to a unit (like its name) and closes the interface: types that are +// not time units, though they satisfy thrift.UnionMember and String, do not +// have a Duration and so cannot be mistaken for a member here. +type TimeUnitValue interface { + thrift.UnionMember + String() string + Duration() time.Duration +} + +var timeUnitMembers = []thrift.UnionMember{ + (*MilliSeconds)(nil), + (*MicroSeconds)(nil), + (*NanoSeconds)(nil), +} + type TimeUnit struct { // union - Millis *MilliSeconds `thrift:"1"` - Micros *MicroSeconds `thrift:"2"` - Nanos *NanoSeconds `thrift:"3"` + Value TimeUnitValue } +func (*TimeUnit) UnionMembers() []thrift.UnionMember { return timeUnitMembers } + func (u *TimeUnit) String() string { - switch { - case u.Millis != nil: - return u.Millis.String() - case u.Micros != nil: - return u.Micros.String() - case u.Nanos != nil: - return u.Nanos.String() - default: + if u.Value == nil { return "" } + return u.Value.String() } // Timestamp logical type annotation @@ -246,6 +279,8 @@ func (t *TimestampType) String() string { return fmt.Sprintf("TIMESTAMP(isAdjustedToUTC=%t,unit=%s)", t.IsAdjustedToUTC, &t.Unit) } +func (*TimestampType) FieldID() int16 { return 8 } + // Time logical type annotation // // Allowed for physical types: INT32 (millis), INT64 (micros, nanos) @@ -258,6 +293,8 @@ func (t *TimeType) String() string { return fmt.Sprintf("TIME(isAdjustedToUTC=%t,unit=%s)", t.IsAdjustedToUTC, &t.Unit) } +func (*TimeType) FieldID() int16 { return 7 } + // Integer logical type annotation // // bitWidth must be 8, 16, 32, or 64. @@ -272,6 +309,8 @@ func (t *IntType) String() string { return fmt.Sprintf("INT(%d,%t)", t.BitWidth, t.IsSigned) } +func (*IntType) FieldID() int16 { return 10 } + // Embedded JSON logical type annotation // // Allowed for physical types: BINARY @@ -279,6 +318,8 @@ type JsonType struct{} func (t *JsonType) String() string { return "JSON" } +func (*JsonType) FieldID() int16 { return 12 } + // Embedded BSON logical type annotation // // Allowed for physical types: BINARY @@ -286,6 +327,8 @@ type BsonType struct{} func (t *BsonType) String() string { return "BSON" } +func (*BsonType) FieldID() int16 { return 13 } + // Embedded Variant logical type annotation // // Allowed for physical types: BYTE_ARRAY (with embedded Variant binary). @@ -306,6 +349,8 @@ type VariantType struct { func (*VariantType) String() string { return "VARIANT" } +func (*VariantType) FieldID() int16 { return 16 } + // Edge interpolation algorithm for Geography logical type type EdgeInterpolationAlgorithm int32 @@ -389,6 +434,8 @@ func (t *GeometryType) String() string { return fmt.Sprintf("GEOMETRY(%q)", crs) } +func (*GeometryType) FieldID() int16 { return 17 } + const GeographyDefaultCRS = defaultCRS // Embedded Geography logical type annotation @@ -419,78 +466,53 @@ func (t *GeographyType) String() string { return fmt.Sprintf("GEOGRAPHY(%q, %s)", crs, t.Algorithm) } +func (*GeographyType) FieldID() int16 { return 18 } + // LogicalType annotations to replace ConvertedType. // // To maintain compatibility, implementations using LogicalType for a // SchemaElement must also set the corresponding ConvertedType (if any) // from the following table. -type LogicalType struct { // union - UTF8 *StringType `thrift:"1"` // use ConvertedType UTF8 - Map *MapType `thrift:"2"` // use ConvertedType Map - List *ListType `thrift:"3"` // use ConvertedType List - Enum *EnumType `thrift:"4"` // use ConvertedType Enum - Decimal *DecimalType `thrift:"5"` // use ConvertedType Decimal + SchemaElement.{Scale, Precision} - Date *DateType `thrift:"6"` // use ConvertedType Date - - // use ConvertedType TimeMicros for Time{IsAdjustedToUTC: *, Unit: Micros} - // use ConvertedType TimeMillis for Time{IsAdjustedToUTC: *, Unit: Millis} - Time *TimeType `thrift:"7"` - - // use ConvertedType TimestampMicros for Timestamp{IsAdjustedToUTC: *, Unit: Micros} - // use ConvertedType TimestampMillis for Timestamp{IsAdjustedToUTC: *, Unit: Millis} - Timestamp *TimestampType `thrift:"8"` +// LogicalTypeValue is the set of annotations a LogicalType union may hold. The +// FieldID method carries each member's thrift field id; see the member list in +// logicalTypeMembers for the full id mapping. +type LogicalTypeValue interface { + thrift.UnionMember + String() string +} +var logicalTypeMembers = []thrift.UnionMember{ + (*StringType)(nil), // 1: use ConvertedType UTF8 + (*MapType)(nil), // 2: use ConvertedType Map + (*ListType)(nil), // 3: use ConvertedType List + (*EnumType)(nil), // 4: use ConvertedType Enum + (*DecimalType)(nil), // 5: use ConvertedType Decimal + SchemaElement.{Scale, Precision} + (*DateType)(nil), // 6: use ConvertedType Date + (*TimeType)(nil), // 7: use ConvertedType TimeMicros or TimeMillis + (*TimestampType)(nil), // 8: use ConvertedType TimestampMicros or TimestampMillis // 9: reserved for Interval - Integer *IntType `thrift:"10"` // use ConvertedType Int* or Uint* - Unknown *NullType `thrift:"11"` // no compatible ConvertedType - Json *JsonType `thrift:"12"` // use ConvertedType JSON - Bson *BsonType `thrift:"13"` // use ConvertedType BSON - UUID *UUIDType `thrift:"14"` // no compatible ConvertedType - Float16 *Float16Type `thrift:"15"` // no compatible ConvertedType - Variant *VariantType `thrift:"16"` // no compatible ConvertedType - Geometry *GeometryType `thrift:"17"` // no compatible ConvertedType - Geography *GeographyType `thrift:"18"` // no compatible ConvertedType + (*IntType)(nil), // 10: use ConvertedType Int* or Uint* + (*NullType)(nil), // 11: no compatible ConvertedType + (*JsonType)(nil), // 12: use ConvertedType JSON + (*BsonType)(nil), // 13: use ConvertedType BSON + (*UUIDType)(nil), // 14: no compatible ConvertedType + (*Float16Type)(nil), // 15: no compatible ConvertedType + (*VariantType)(nil), // 16: no compatible ConvertedType + (*GeometryType)(nil), // 17: no compatible ConvertedType + (*GeographyType)(nil), // 18: no compatible ConvertedType } +type LogicalType struct { // union + Value LogicalTypeValue +} + +func (*LogicalType) UnionMembers() []thrift.UnionMember { return logicalTypeMembers } + func (t *LogicalType) String() string { - switch { - case t.UTF8 != nil: - return t.UTF8.String() - case t.Map != nil: - return t.Map.String() - case t.List != nil: - return t.List.String() - case t.Enum != nil: - return t.Enum.String() - case t.Decimal != nil: - return t.Decimal.String() - case t.Date != nil: - return t.Date.String() - case t.Time != nil: - return t.Time.String() - case t.Timestamp != nil: - return t.Timestamp.String() - case t.Integer != nil: - return t.Integer.String() - case t.Unknown != nil: - return t.Unknown.String() - case t.Json != nil: - return t.Json.String() - case t.Bson != nil: - return t.Bson.String() - case t.UUID != nil: - return t.UUID.String() - case t.Float16 != nil: - return t.Float16.String() - case t.Variant != nil: - return t.Variant.String() - case t.Geometry != nil: - return t.Geometry.String() - case t.Geography != nil: - return t.Geography.String() - default: + if t.Value == nil { return "" } + return t.Value.String() } // Represents a element inside a schema definition. @@ -546,7 +568,7 @@ type SchemaElement struct { // // LogicalType replaces ConvertedType, but ConvertedType is still required // for some logical types to ensure forward-compatibility in format v1. - LogicalType thrift.Null[LogicalType] `thrift:"10,optional"` + LogicalType LogicalType `thrift:"10,optional"` } // Encodings supported by Parquet. Not all encodings are valid for all types. @@ -801,27 +823,75 @@ type DataPageHeaderV2 struct { // Block-based algorithm type annotation. type SplitBlockAlgorithm struct{} +func (*SplitBlockAlgorithm) FieldID() int16 { return 1 } + +// BloomFilterAlgorithmValue is the set of algorithms a BloomFilterAlgorithm +// union may hold. +type BloomFilterAlgorithmValue interface { + thrift.UnionMember +} + +var bloomFilterAlgorithmMembers = []thrift.UnionMember{ + (*SplitBlockAlgorithm)(nil), // 1 +} + // The algorithm used in Bloom filter. type BloomFilterAlgorithm struct { // union - Block *SplitBlockAlgorithm `thrift:"1"` + Value BloomFilterAlgorithmValue +} + +func (*BloomFilterAlgorithm) UnionMembers() []thrift.UnionMember { + return bloomFilterAlgorithmMembers } // Hash strategy type annotation. xxHash is an extremely fast non-cryptographic // hash algorithm. It uses 64 bits version of xxHash. type XxHash struct{} +func (*XxHash) FieldID() int16 { return 1 } + +// BloomFilterHashValue is the set of hash functions a BloomFilterHash union may +// hold. +type BloomFilterHashValue interface { + thrift.UnionMember +} + +var bloomFilterHashMembers = []thrift.UnionMember{ + (*XxHash)(nil), // 1 +} + // The hash function used in Bloom filter. This function takes the hash of a // column value using plain encoding. type BloomFilterHash struct { // union - XxHash *XxHash `thrift:"1"` + Value BloomFilterHashValue } +func (*BloomFilterHash) UnionMembers() []thrift.UnionMember { return bloomFilterHashMembers } + // The compression used in the Bloom filter. type BloomFilterUncompressed struct{} type BloomFilterGzip struct{} + +func (*BloomFilterUncompressed) FieldID() int16 { return 1 } +func (*BloomFilterGzip) FieldID() int16 { return 2 } + +// BloomFilterCompressionValue is the set of compressions a +// BloomFilterCompression union may hold. +type BloomFilterCompressionValue interface { + thrift.UnionMember +} + +var bloomFilterCompressionMembers = []thrift.UnionMember{ + (*BloomFilterUncompressed)(nil), // 1 + (*BloomFilterGzip)(nil), // 2 +} + type BloomFilterCompression struct { // union - Uncompressed *BloomFilterUncompressed `thrift:"1"` - GZip *BloomFilterGzip `thrift:"2"` + Value BloomFilterCompressionValue +} + +func (*BloomFilterCompression) UnionMembers() []thrift.UnionMember { + return bloomFilterCompressionMembers } // Bloom filter header is stored at beginning of Bloom filter data of each column @@ -939,7 +1009,7 @@ type ColumnMetaData struct { TotalCompressedSize int64 `thrift:"7,required"` // Optional key/value metadata. - KeyValueMetadata []KeyValue `thrift:"8,optional"` + KeyValueMetadata thrift.Slice[KeyValue] `thrift:"8,optional"` // Byte offset from beginning of file to first data page. DataPageOffset int64 `thrift:"9,required"` @@ -957,7 +1027,7 @@ type ColumnMetaData struct { // Set of all encodings used for pages in this column chunk. // This information can be used to determine if all data pages are // dictionary encoded for example. - EncodingStats []PageEncodingStats `thrift:"13,optional"` + EncodingStats thrift.Slice[PageEncodingStats] `thrift:"13,optional"` // Byte offset from beginning of file to Bloom filter data. BloomFilterOffset int64 `thrift:"14,optional"` @@ -983,15 +1053,32 @@ type EncryptionWithFooterKey struct{} type EncryptionWithColumnKey struct { // Column path in schema. - PathInSchema []string `thrift:"1,required"` + PathInSchema thrift.Slice[string] `thrift:"1,required"` // Retrieval metadata of column encryption key. KeyMetadata []byte `thrift:"2,optional"` } -type ColumnCryptoMetaData struct { - EncryptionWithFooterKey *EncryptionWithFooterKey `thrift:"1"` - EncryptionWithColumnKey *EncryptionWithColumnKey `thrift:"2"` +func (*EncryptionWithFooterKey) FieldID() int16 { return 1 } +func (*EncryptionWithColumnKey) FieldID() int16 { return 2 } + +// ColumnCryptoMetaDataValue is the set of key references a +// ColumnCryptoMetaData union may hold. +type ColumnCryptoMetaDataValue interface { + thrift.UnionMember +} + +var columnCryptoMetaDataMembers = []thrift.UnionMember{ + (*EncryptionWithFooterKey)(nil), // 1 + (*EncryptionWithColumnKey)(nil), // 2 +} + +type ColumnCryptoMetaData struct { // union + Value ColumnCryptoMetaDataValue +} + +func (*ColumnCryptoMetaData) UnionMembers() []thrift.UnionMember { + return columnCryptoMetaDataMembers } type ColumnChunk struct { @@ -1039,7 +1126,7 @@ type RowGroup struct { // If set, specifies a sort ordering of the rows in this RowGroup. // The sorting columns can be a subset of all the columns. - SortingColumns []SortingColumn `thrift:"4,optional"` + SortingColumns thrift.Slice[SortingColumn] `thrift:"4,optional"` // Byte offset from beginning of file to first page (data or dictionary) // in this row group @@ -1056,20 +1143,38 @@ type RowGroup struct { Ordinal int16 `thrift:"7,optional,writezero"` } +// Reset clears r in place, retaining allocated capacity for reuse. Elements +// of the retained slices are recursively cleared so that values from a +// previous thrift decode cannot leak into the next one (the decoder only +// writes fields present in its input). func (r *RowGroup) Reset() { - r.FileOffset = 0 - r.NumRows = 0 - r.TotalByteSize = 0 - r.SortingColumns = r.SortingColumns[:0] + for i := range r.Columns { + r.Columns[i].Reset() + } r.Columns = r.Columns[:0] - r.Ordinal = 0 r.TotalByteSize = 0 + r.NumRows = 0 + clear(r.SortingColumns) + r.SortingColumns = r.SortingColumns[:0] + r.FileOffset = 0 r.TotalCompressedSize = 0 + r.Ordinal = 0 } // Empty struct to signal the order defined by the physical or logical type. type TypeDefinedOrder struct{} +func (*TypeDefinedOrder) FieldID() int16 { return 1 } + +// ColumnOrderValue is the set of orderings a ColumnOrder union may hold. +type ColumnOrderValue interface { + thrift.UnionMember +} + +var columnOrderMembers = []thrift.UnionMember{ + (*TypeDefinedOrder)(nil), // 1 +} + // Union to specify the order used for the min_value and max_value fields for a // column. This union takes the role of an enhanced enum that allows rich // elements (which will be needed for a collation-based ordering in the future). @@ -1126,9 +1231,11 @@ type ColumnOrder struct { // union // - If the min is +0, the row group may contain -0 values as well. // - If the max is -0, the row group may contain +0 values as well. // - When looking for NaN values, min and max should be ignored. - TypeOrder *TypeDefinedOrder `thrift:"1"` + Value ColumnOrderValue } +func (*ColumnOrder) UnionMembers() []thrift.UnionMember { return columnOrderMembers } + type PageLocation struct { // Offset of the page in the file. Offset int64 `thrift:"1,required"` @@ -1145,13 +1252,13 @@ type PageLocation struct { type OffsetIndex struct { // PageLocations, ordered by increasing PageLocation.offset. It is required // that page_locations[i].first_row_index < page_locations[i+1].first_row_index. - PageLocations []PageLocation `thrift:"1,required"` + PageLocations thrift.Slice[PageLocation] `thrift:"1,required"` // Unencoded/uncompressed size for BYTE_ARRAY types. // // See documention for unencoded_byte_array_data_bytes in SizeStatistics for // more details on this field. - UnencodedByteArrayDataBytes []int64 `thrift:"2,optional"` + UnencodedByteArrayDataBytes thrift.Slice[int64] `thrift:"2,optional"` } func (o *OffsetIndex) Reset() { @@ -1172,7 +1279,7 @@ type ColumnIndex struct { // have to set the corresponding entries in min_values and max_values to // byte[0], so that all lists have the same length. If false, the // corresponding entries in min_values and max_values must be valid. - NullPages []bool `thrift:"1,required"` + NullPages thrift.Slice[bool] `thrift:"1,required"` // Two lists containing lower and upper bounds for the values of each page // determined by the ColumnOrder of the column. These may be the actual @@ -1182,8 +1289,8 @@ type ColumnIndex struct { // Such more compact values must still be valid values within the column's // logical type. Readers must make sure that list entries are populated before // using them by inspecting null_pages. - MinValues [][]byte `thrift:"2,required"` - MaxValues [][]byte `thrift:"3,required"` + MinValues thrift.Slice[[]byte] `thrift:"2,required"` + MaxValues thrift.Slice[[]byte] `thrift:"3,required"` // Stores whether both min_values and max_values are ordered and if so, in // which direction. This allows readers to perform binary searches in both @@ -1195,7 +1302,7 @@ type ColumnIndex struct { // The writezero tag satisfies spec: // "Writers SHOULD always write this field even if no null values are present or the column is not nullable." // https://github.com/apache/parquet-format/blob/apache-parquet-format-2.12.0/src/main/thrift/parquet.thrift#L1197-L1198 - NullCounts []int64 `thrift:"5,optional,writezero"` + NullCounts thrift.Slice[int64] `thrift:"5,optional,writezero"` // Contains repetition level histograms for each page // concatenated together. The repetition_level_histogram field on @@ -1207,10 +1314,10 @@ type ColumnIndex struct { // Element 0 is the first element of the histogram for the first page. // Element (max_repetition_level + 1) is the first element of the histogram // for the second page. - RepetitionLevelHistogram []int64 `thrift:"6,optional"` + RepetitionLevelHistogram thrift.Slice[int64] `thrift:"6,optional"` // Same as repetition_level_histograms except for definitions levels. - DefinitionLevelHistogram []int64 `thrift:"7,optional"` + DefinitionLevelHistogram thrift.Slice[int64] `thrift:"7,optional"` } func (c *ColumnIndex) Reset() { @@ -1253,9 +1360,26 @@ type AesGcmCtrV1 struct { SupplyAadPrefix bool `thrift:"3,optional"` } +func (*AesGcmV1) FieldID() int16 { return 1 } +func (*AesGcmCtrV1) FieldID() int16 { return 2 } + +// EncryptionAlgorithmValue is the set of algorithms an EncryptionAlgorithm +// union may hold. +type EncryptionAlgorithmValue interface { + thrift.UnionMember +} + +var encryptionAlgorithmMembers = []thrift.UnionMember{ + (*AesGcmV1)(nil), // 1 + (*AesGcmCtrV1)(nil), // 2 +} + type EncryptionAlgorithm struct { // union - AesGcmV1 *AesGcmV1 `thrift:"1"` - AesGcmCtrV1 *AesGcmCtrV1 `thrift:"2"` + Value EncryptionAlgorithmValue +} + +func (*EncryptionAlgorithm) UnionMembers() []thrift.UnionMember { + return encryptionAlgorithmMembers } // Description for file metadata. @@ -1278,7 +1402,7 @@ type FileMetaData struct { RowGroups thrift.Slice[RowGroup] `thrift:"4,required"` // Optional key/value metadata. - KeyValueMetadata []KeyValue `thrift:"5,optional"` + KeyValueMetadata thrift.Slice[KeyValue] `thrift:"5,optional"` // String for application that wrote this file. This should be in the format // version (build ). @@ -1299,7 +1423,7 @@ type FileMetaData struct { // // The obsolete min and max fields in the Statistics object are always sorted // by signed comparison regardless of column_orders. - ColumnOrders []ColumnOrder `thrift:"7,optional"` + ColumnOrders thrift.Slice[ColumnOrder] `thrift:"7,optional"` // Encryption algorithm. This field is set only in encrypted files // with plaintext footer. Files with encrypted footer store algorithm id diff --git a/vendor/github.com/parquet-go/parquet-go/format/reset.go b/vendor/github.com/parquet-go/parquet-go/format/reset.go new file mode 100644 index 00000000000..10bbcd4dcfa --- /dev/null +++ b/vendor/github.com/parquet-go/parquet-go/format/reset.go @@ -0,0 +1,124 @@ +package format + +// The Reset methods in this file clear values in place while retaining +// allocated slice capacity, so that a value can be reused as the decode +// target of multiple thrift deserializations without allocating on each +// decode (see FooterDecoder). +// +// Because the thrift decoder only writes fields that are present in the +// input, Reset must recursively clear the elements of retained slices; +// otherwise fields decoded from a previous input would leak into the next +// decoded value. Union fields are the exception: the decoder itself clears +// unions absent from the input and zeroes reused members, so Reset retains +// their member allocations for the next decode to reuse. +// +// Byte slice and string fields decoded from footers alias the input buffer +// (they are replaced, never reused, by the decoder), so Reset sets them to +// nil or empty instead of truncating, releasing references to the previous +// input buffer. This includes the contents of retained union members whose +// fields alias the buffer: the member allocation is kept for the next +// decode to reuse, but its contents are zeroed so no retained member holds +// a reference into a buffer with unrelated data. + +// Reset clears m in place, retaining allocated capacity for reuse in +// subsequent thrift decodes. +// +// Note that after reuse, optional list fields that are absent from the +// decoded input are left empty but non-nil, whereas decoding into a fresh +// FileMetaData leaves them nil. Both states are semantically equivalent +// (zero-length), but programs distinguishing nil from empty slices, or +// re-encoding the value, can observe the difference. +func (m *FileMetaData) Reset() { + m.Version = 0 + for i := range m.Schema { + m.Schema[i].Reset() + } + m.Schema = m.Schema[:0] + m.NumRows = 0 + for i := range m.RowGroups { + m.RowGroups[i].Reset() + } + m.RowGroups = m.RowGroups[:0] + clear(m.KeyValueMetadata) + m.KeyValueMetadata = m.KeyValueMetadata[:0] + m.CreatedBy = "" + m.ColumnOrders = m.ColumnOrders[:0] + // Retained union member; scrub buffer-aliasing contents (see file header). + switch v := m.EncryptionAlgorithm.Value.(type) { + case *AesGcmV1: + *v = AesGcmV1{} + case *AesGcmCtrV1: + *v = AesGcmCtrV1{} + } + m.FooterSigningKeyMetadata = nil +} + +// Reset clears s in place, retaining allocated capacity for reuse in +// subsequent thrift decodes. +func (s *SchemaElement) Reset() { + s.Type.Reset() + s.TypeLength.Reset() + s.RepetitionType.Reset() + s.Name = "" + s.NumChildren.Reset() + s.ConvertedType.Reset() + s.Scale.Reset() + s.Precision.Reset() + s.FieldID = 0 + // Retained union member; scrub the buffer-aliasing CRS strings of the + // Geometry and Geography members (see file header). + switch m := s.LogicalType.Value.(type) { + case *GeometryType: + *m = GeometryType{} + case *GeographyType: + *m = GeographyType{} + } +} + +// Reset clears c in place, retaining allocated capacity for reuse in +// subsequent thrift decodes. +func (c *ColumnChunk) Reset() { + c.FilePath = "" + c.FileOffset = 0 + c.MetaData.Reset() + c.OffsetIndexOffset = 0 + c.OffsetIndexLength = 0 + c.ColumnIndexOffset = 0 + c.ColumnIndexLength = 0 + // Retained union member; scrub buffer-aliasing contents (see file header). + if v, ok := c.CryptoMetadata.Value.(*EncryptionWithColumnKey); ok { + *v = EncryptionWithColumnKey{} + } + c.EncryptedColumnMetadata = nil +} + +// Reset clears c in place, retaining allocated capacity for reuse in +// subsequent thrift decodes. +func (c *ColumnMetaData) Reset() { + c.Type = 0 + c.Encoding = c.Encoding[:0] + clear(c.PathInSchema) + c.PathInSchema = c.PathInSchema[:0] + c.Codec = 0 + c.NumValues = 0 + c.TotalUncompressedSize = 0 + c.TotalCompressedSize = 0 + clear(c.KeyValueMetadata) + c.KeyValueMetadata = c.KeyValueMetadata[:0] + c.DataPageOffset = 0 + c.IndexPageOffset = 0 + c.DictionaryPageOffset = 0 + // Statistics byte slices alias the input buffer (replaced, never + // appended to), so zero the whole struct instead of truncating. + c.Statistics = Statistics{} + clear(c.EncodingStats) + c.EncodingStats = c.EncodingStats[:0] + c.BloomFilterOffset = 0 + c.BloomFilterLength = 0 + // The histograms and geospatial types retain capacity. + c.SizeStatistics.UnencodedByteArrayDataBytes = 0 + c.SizeStatistics.RepetitionLevelHistogram = c.SizeStatistics.RepetitionLevelHistogram[:0] + c.SizeStatistics.DefinitionLevelHistogram = c.SizeStatistics.DefinitionLevelHistogram[:0] + c.GeospatialStatistics.BBox = BoundingBox{} + c.GeospatialStatistics.GeoSpatialTypes = c.GeospatialStatistics.GeoSpatialTypes[:0] +} diff --git a/vendor/github.com/parquet-go/parquet-go/limits.go b/vendor/github.com/parquet-go/parquet-go/limits.go index be1a08ff7d3..9c3104427ba 100644 --- a/vendor/github.com/parquet-go/parquet-go/limits.go +++ b/vendor/github.com/parquet-go/parquet-go/limits.go @@ -33,30 +33,75 @@ const ( estimatedSizeOfByteArrayValues = 20 ) +// The make* functions below use a single unsigned comparison to bounds-check the +// index (uint(i) > max catches both i < 0 and i > max), and delegate the failure +// to a dedicated out-of-line panic helper. This keeps their inline cost low: the +// previous implementation inlined fmt.Errorf on the failure path, which inflated +// every caller (Value.Level cost 192) and prevented inlining. Keeping the error +// construction out of line lets these helpers inline and lets small callers such +// as Value.WithRepetitionLevel dead-code-eliminate the check when the argument is +// provably in range. + func makeRepetitionLevel(i int) byte { - checkIndexRange("repetition level", i, 0, MaxRepetitionLevel) + if uint(i) > MaxRepetitionLevel { + panicRepetitionLevelOutOfRange(i) + } return byte(i) } func makeDefinitionLevel(i int) byte { - checkIndexRange("definition level", i, 0, MaxDefinitionLevel) + if uint(i) > MaxDefinitionLevel { + panicDefinitionLevelOutOfRange(i) + } return byte(i) } func makeColumnIndex(i int) uint16 { - checkIndexRange("column index", i, 0, MaxColumnIndex) + if uint(i) > MaxColumnIndex { + panicColumnIndexOutOfRange(i) + } return uint16(i) } func makeNumValues(i int) int32 { - checkIndexRange("number of values", i, 0, math.MaxInt32) + if uint(i) > math.MaxInt32 { + panicNumValuesOutOfRange(i) + } return int32(i) } -func checkIndexRange(typ string, i, min, max int) { - if i < min || i > max { - panic(errIndexOutOfRange(typ, i, min, max)) +// The panic helpers are kept out of line (along with the error construction) so +// the make* functions above stay cheap to inline. + +func panicRepetitionLevelOutOfRange(i int) { + panic(errIndexOutOfRange("repetition level", i, 0, MaxRepetitionLevel)) +} + +func panicDefinitionLevelOutOfRange(i int) { + panic(errIndexOutOfRange("definition level", i, 0, MaxDefinitionLevel)) +} + +func panicColumnIndexOutOfRange(i int) { + panic(errIndexOutOfRange("column index", i, 0, MaxColumnIndex)) +} + +func panicNumValuesOutOfRange(i int) { + panic(errIndexOutOfRange("number of values", i, 0, math.MaxInt32)) +} + +// panicLevelOutOfRange performs the fine-grained range check for Value.Level's +// combined fast-path test. It is only called when at least one of the three +// arguments is out of range, so it can afford to recompute which one to produce +// a precise error message. Keeping it out of line lets Value.Level reduce its +// hot path to a single combined comparison and stay cheap enough to inline. +func panicLevelOutOfRange(repetitionLevel, definitionLevel, columnIndex int) { + if uint(repetitionLevel) > MaxRepetitionLevel { + panicRepetitionLevelOutOfRange(repetitionLevel) + } + if uint(definitionLevel) > MaxDefinitionLevel { + panicDefinitionLevelOutOfRange(definitionLevel) } + panicColumnIndexOutOfRange(columnIndex) } func errIndexOutOfRange(typ string, i, min, max int) error { diff --git a/vendor/github.com/parquet-go/parquet-go/merge.go b/vendor/github.com/parquet-go/parquet-go/merge.go index 0c47386b35b..ab3d5d19312 100644 --- a/vendor/github.com/parquet-go/parquet-go/merge.go +++ b/vendor/github.com/parquet-go/parquet-go/merge.go @@ -84,18 +84,38 @@ func MergeRowGroups(rowGroups []RowGroup, options ...RowGroupOption) (RowGroup, dropDuplicatedRows := config.Sorting.DropDuplicatedRows // Optimization: detect non-overlapping row groups and create segments + makeMerged := func(rowGroups []RowGroup) RowGroup { + merged := &mergedRowGroup{ + compare: mergedCompare, + dropDuplicatedRows: dropDuplicatedRows, + } + merged.init(schema, mergedSortingColumns, rowGroups) + return merged + } + rowGroupSegments := make([]RowGroup, 0) for segment := range overlappingRowGroups(mergedRowGroups, schema, mergedSortingColumns, mergedCompare) { if len(segment) == 1 { - rowGroupSegments = append(rowGroupSegments, segment[0]) - } else { - merged := &mergedRowGroup{ - compare: mergedCompare, - dropDuplicatedRows: dropDuplicatedRows, + rowGroupSegments = append(rowGroupSegments, segment[0].rowGroup) + continue + } + // Refine partially overlapping segments: stretches of key space + // covered by a single row group are sliced off as row-range views, + // leaving only the truly overlapping stretches for the merge. Not + // applied when dropping duplicated rows: which physical row of an + // equal-key run survives depends on the interleaving of ties across + // row groups, which refinement does not preserve. + if !dropDuplicatedRows && !disableMergeRefinement { + if refined := refineSegment(newRefineTargets(segment, schema, mergedSortingColumns), mergedCompare, makeMerged); refined != nil { + rowGroupSegments = append(rowGroupSegments, refined...) + continue } - merged.init(schema, mergedSortingColumns, segment) - rowGroupSegments = append(rowGroupSegments, merged) } + rowGroups := make([]RowGroup, len(segment)) + for i := range segment { + rowGroups[i] = segment[i].rowGroup + } + rowGroupSegments = append(rowGroupSegments, makeMerged(rowGroups)) } if len(rowGroupSegments) == 1 { @@ -120,18 +140,20 @@ func MergeRowGroups(rowGroups []RowGroup, options ...RowGroupOption) (RowGroup, }, nil } +// rowGroupRange associates a row group with the bounds of its sorting columns +// (nil when the bounds could not be determined). +type rowGroupRange struct { + rowGroup RowGroup + minRow Row + maxRow Row +} + // overlappingRowGroups analyzes row groups to find non-overlapping segments // Returns groups of row groups where each group either: // 1. Contains a single non-overlapping row group (can be concatenated) // 2. Contains multiple overlapping row groups (need to be merged) -func overlappingRowGroups(rowGroups []RowGroup, schema *Schema, sorting []SortingColumn, compare func(Row, Row) int) iter.Seq[[]RowGroup] { - return func(yield func([]RowGroup) bool) { - type rowGroupRange struct { - rowGroup RowGroup - minRow Row - maxRow Row - } - +func overlappingRowGroups(rowGroups []RowGroup, schema *Schema, sorting []SortingColumn, compare func(Row, Row) int) iter.Seq[[]rowGroupRange] { + return func(yield func([]rowGroupRange) bool) { rowGroupRanges := make([]rowGroupRange, 0, len(rowGroups)) for _, rg := range rowGroups { if rg.NumRows() == 0 { @@ -139,7 +161,13 @@ func overlappingRowGroups(rowGroups []RowGroup, schema *Schema, sorting []Sortin } minRow, maxRow, err := rowGroupRangeOfSortedColumns(rg, schema, sorting) if err != nil { - yield(rowGroups) + // Bounds unavailable: yield all row groups as a single segment + // with nil bounds, which the caller merges without refinement. + all := make([]rowGroupRange, len(rowGroups)) + for i, rg := range rowGroups { + all[i] = rowGroupRange{rowGroup: rg} + } + yield(all) return } rowGroupRanges = append(rowGroupRanges, rowGroupRange{ @@ -152,7 +180,7 @@ func overlappingRowGroups(rowGroups []RowGroup, schema *Schema, sorting []Sortin return } if len(rowGroupRanges) == 1 { - yield([]RowGroup{rowGroupRanges[0].rowGroup}) + yield(rowGroupRanges[:1]) return } @@ -162,29 +190,26 @@ func overlappingRowGroups(rowGroups []RowGroup, schema *Schema, sorting []Sortin }) // Detect overlapping segments - currentSegment := []RowGroup{rowGroupRanges[0].rowGroup} + segmentStart := 0 currentMax := rowGroupRanges[0].maxRow - for _, rr := range rowGroupRanges[1:] { + for i, rr := range rowGroupRanges[1:] { if compare(rr.minRow, currentMax) <= 0 { - // Overlapping - add to current segment and extend max if necessary - currentSegment = append(currentSegment, rr.rowGroup) + // Overlapping - extend max if necessary if compare(rr.maxRow, currentMax) > 0 { currentMax = rr.maxRow } } else { // Non-overlapping - yield current segment - if !yield(currentSegment) { + if !yield(rowGroupRanges[segmentStart : i+1]) { return } - currentSegment = []RowGroup{rr.rowGroup} + segmentStart = i + 1 currentMax = rr.maxRow } } - if len(currentSegment) > 0 { - yield(currentSegment) - } + yield(rowGroupRanges[segmentStart:]) } } @@ -222,18 +247,26 @@ func rowGroupRangeOfSortedColumns(rg RowGroup, schema *Schema, sorting []Sorting return nil, nil, fmt.Errorf("column index not available for sorting column %s", sortingColumnPath) } - // Since data is sorted by sorting columns, we can efficiently get min/max: - // - Min value = min of first non-null page - // - Max value = max of last non-null page + // Since data is sorted by sorting columns, we can bound the first and + // last rows of the row group from the first and last non-null pages of + // the column index. The bounds are expressed in sort order: when the + // column is sorted in descending order, the first row holds the + // largest value and the last row holds the smallest one, so the page + // statistics to read are inverted. numPages := columnIndex.NumPages() + descending := sortingColumn.Descending() - // Find first non-null page for min value - var globalMin Value + // Bound the first row in sort order from the first non-null page + var firstValue Value var found bool for pageIdx := range numPages { if !columnIndex.NullPage(pageIdx) { - if minValue := columnIndex.MinValue(pageIdx); !minValue.IsNull() { - globalMin, found = minValue, true + value := columnIndex.MinValue(pageIdx) + if descending { + value = columnIndex.MaxValue(pageIdx) + } + if !value.IsNull() { + firstValue, found = value, true break } } @@ -242,20 +275,24 @@ func rowGroupRangeOfSortedColumns(rg RowGroup, schema *Schema, sorting []Sorting return nil, nil, fmt.Errorf("no valid pages found in column index for column %s", sortingColumnPath) } - // Find last non-null page for max value - var globalMax Value + // Bound the last row in sort order from the last non-null page + var lastValue Value for pageIdx := numPages - 1; pageIdx >= 0; pageIdx-- { if !columnIndex.NullPage(pageIdx) { - if maxValue := columnIndex.MaxValue(pageIdx); !maxValue.IsNull() { - globalMax = maxValue + value := columnIndex.MaxValue(pageIdx) + if descending { + value = columnIndex.MinValue(pageIdx) + } + if !value.IsNull() { + lastValue = value break } } } // Set the min/max values with proper levels - minValues[sortingColumnIndex] = globalMin.Level(0, 1, sortingColumnIndex) - maxValues[sortingColumnIndex] = globalMax.Level(0, 1, sortingColumnIndex) + minValues[sortingColumnIndex] = firstValue.Level(0, 1, sortingColumnIndex) + maxValues[sortingColumnIndex] = lastValue.Level(0, 1, sortingColumnIndex) } minRow = Row(minValues) @@ -278,6 +315,12 @@ type mergedRowGroup struct { dropDuplicatedRows bool } +// rowGroupSegments opts out of segment splitting: a mergedRowGroup interleaves +// rows from overlapping row groups via a heap merge, so its row groups cannot be +// written independently without losing the merged ordering. It overrides the +// method promoted from the embedded multiRowGroup. +func (m *mergedRowGroup) rowGroupSegments() []RowGroup { return nil } + func (m *mergedRowGroup) Rows() Rows { // The row group needs to respect a sorting order; the merged row reader // uses a heap to merge rows from the row groups. @@ -307,6 +350,18 @@ type sortedSegmentRowGroup struct { dropDuplicatedRows bool } +// rowGroupSegments implements orderedRowGroupSegments: the segments are already +// in sorted order and each segment's own Rows() preserves its internal ordering, +// so writing them in sequence preserves the global order. It returns nil when +// dropping duplicates, because deduplication spans segment boundaries and would +// be lost if segments were written independently. +func (s *sortedSegmentRowGroup) rowGroupSegments() []RowGroup { + if s.dropDuplicatedRows { + return nil + } + return s.segments +} + func (s *sortedSegmentRowGroup) Rows() Rows { readers := make([]Rows, len(s.segments)) for i, seg := range s.segments { @@ -489,14 +544,12 @@ func mergeRowReaders[T RowReader](rows []T, compare func(Row, Row) int) RowReade } default: buffers := make([]bufferedRowReader, len(rows)) - readers := make([]*bufferedRowReader, len(rows)) for i, r := range rows { buffers[i].rows = r - readers[i] = &buffers[i] } return &mergedRowReader{ compare: compare, - readers: readers, + buffers: buffers, } } } @@ -507,6 +560,8 @@ type mergedRowReader2 struct { compare func(Row, Row) int readers [2]*bufferedRowReader buffers [2]bufferedRowReader + prev int // <0 if r0 won the previous game, >0 if r1 won, 0 otherwise + streak int32 // consecutive games won by the same reader initialized bool } @@ -584,15 +639,42 @@ func (m *mergedRowReader2) ReadRows(rows []Row) (n int, err error) { for n < len(rows) { switch cmp := m.compare(r0.head(), r1.head()); { case cmp < 0: - rows[n] = append(rows[n][:0], r0.head()...) - n++ - hasNext0 = r0.next() - hasNext1 = true + if m.prev < 0 { + m.streak++ + } else { + m.streak = 0 + } + m.prev = -1 + if m.streak >= runDetectionStreak { + // r0 has been winning: gallop through its buffered rows + // for the run that sorts strictly before r1's head (ties + // are emitted pairwise by the case below) and emit it in + // bulk. Interleaved inputs rarely reach the streak + // threshold and pay only the cost of the counter. + n, hasNext0 = m.emitRun(rows, n, r0, r1.head()) + hasNext1 = true + } else { + rows[n] = append(rows[n][:0], r0.head()...) + n++ + hasNext0 = r0.next() + hasNext1 = true + } case cmp > 0: - rows[n] = append(rows[n][:0], r1.head()...) - n++ - hasNext0 = true - hasNext1 = r1.next() + if m.prev > 0 { + m.streak++ + } else { + m.streak = 0 + } + m.prev = 1 + if m.streak >= runDetectionStreak { + n, hasNext1 = m.emitRun(rows, n, r1, r0.head()) + hasNext0 = true + } else { + rows[n] = append(rows[n][:0], r1.head()...) + n++ + hasNext0 = true + hasNext1 = r1.next() + } default: rows[n] = append(rows[n][:0], r0.head()...) n++ @@ -602,6 +684,8 @@ func (m *mergedRowReader2) ReadRows(rows []Row) (n int, err error) { n++ hasNext1 = r1.next() } + m.prev = 0 + m.streak = 0 } if !hasNext0 || !hasNext1 { break @@ -612,39 +696,83 @@ func (m *mergedRowReader2) ReadRows(rows []Row) (n int, err error) { return n, nil } +// emitRun bulk-emits the run of buffered rows of r that sort strictly before +// bound; the head of r must already be known to. It returns the new number of +// rows produced and whether r has more rows buffered. +func (m *mergedRowReader2) emitRun(rows []Row, n int, r *bufferedRowReader, bound Row) (int, bool) { + window := r.window() + if max := len(rows) - n; len(window) > max { + window = window[:max] + } + run := 1 + if len(window) > 1 { + run += runLength(window[1:], bound, m.compare, -1) + } + for _, row := range window[:run] { + rows[n] = append(rows[n][:0], row...) + n++ + } + return n, r.advance(int32(run)) +} + +// mergedRowReader merges k buffered row readers using a tournament tree of +// losers, which performs ~log2(k) comparisons per row instead of the ~2*log2(k) +// required to sift down a binary min-heap. +// +// The tree is laid out as the first k positions of a 2k binary heap: internal +// node i stores the loser of the game played at that position, identified by +// the index of its buffer, and the leaf for buffer i sits at implicit position +// k+i. The overall winner is kept out of the tree in the winner field, and its +// leaf position in winnerLeaf. Advancing the merge replays the games on the +// path from the winner's leaf to the root, comparing the new head of the +// winner against the losers stored along the way. Exhausted readers are +// represented by a negative value which loses every game it plays. type mergedRowReader struct { compare func(Row, Row) int - readers []*bufferedRowReader + buffers []bufferedRowReader + losers []int32 + count int + winner int32 + winnerLeaf int32 + streak int32 // consecutive games won by the current winner initialized bool } +// runDetectionStreak is the number of consecutive games the same reader must +// win before the merge switches to run mode. When the merged inputs are mostly +// disjoint (e.g. sorted row groups overlapping only at their boundaries), the +// same reader wins long streaks and replaying ~log2(k) games per row is wasted +// work; run mode computes the second-smallest head once and then emits rows +// with a single comparison each. Interleaved inputs never reach the threshold +// and pay only the cost of maintaining the streak counter. +const runDetectionStreak = 3 + func (m *mergedRowReader) initialize() error { - for i, r := range m.readers { - switch err := r.read(); err { + k := len(m.buffers) + m.losers = make([]int32, k) + m.count = k + + leaves := make([]int32, k) + for i := range leaves { + leaves[i] = int32(i) + } + + for i := range m.buffers { + switch err := m.buffers[i].read(); err { case nil: case io.EOF: - m.readers[i] = nil + leaves[i] = -1 + m.count-- default: - m.readers = nil + m.count = 0 return err } } - n := 0 - for _, r := range m.readers { - if r != nil { - m.readers[n] = r - n++ - } + if m.count > 0 { + m.winner = m.playInitialGames(0, leaves) + m.winnerLeaf = int32(k) + m.winner } - - clear := m.readers[n:] - for i := range clear { - clear[i] = nil - } - - m.readers = m.readers[:n] - m.heapInit() return nil } @@ -657,95 +785,182 @@ func (m *mergedRowReader) ReadRows(rows []Row) (n int, err error) { } } - for n < len(rows) && len(m.readers) != 0 { - r := m.readers[0] - if r.empty() { // This readers buffer has been exhausted, repopulate it. - if err := r.read(); err != nil { - if err == io.EOF { - m.heapPop() - continue + for n < len(rows) && m.count != 0 { + c := &m.buffers[m.winner] + + if c.empty() { // This reader's buffer has been exhausted, repopulate it. + switch err := c.read(); err { + case nil: + case io.EOF: + m.winner = -1 + m.count-- + if m.count == 0 { + break } + default: return n, err - } else { - if !m.heapDown(0, len(m.readers)) { // heap.Fix - m.heapUp(0) - } - continue } + // The winner's head changed (or the winner was exhausted), replay + // the games on the path from its leaf to the root to determine the + // new winner. + prev := m.winner + m.replayGames() + if m.winner != prev { + m.streak = 0 + } + continue } - rows[n] = append(rows[n][:0], r.head()...) + rows[n] = append(rows[n][:0], c.head()...) n++ - if !r.next() { + if !c.next() { return n, nil } - if !m.heapDown(0, len(m.readers)) { // heap.Fix - m.heapUp(0) + + if m.streak >= runDetectionStreak { + // The same reader has been winning; emit its run in bulk. The run + // bound is the second-smallest head across all readers, so the + // winner keeps winning as long as its head does not exceed it + // (ties favor the incumbent, matching the strict comparison in + // replayGames). Other readers are not consumed during the run, so + // the bound remains valid until it is crossed. The length of the + // run within the buffered window is found with O(log n) + // comparisons: a single comparison of the last buffered row + // settles the common case where the whole window is part of the + // run. + bound := m.runBound() + for n < len(rows) { + window := c.window() + if max := len(rows) - n; len(window) > max { + window = window[:max] + } + run := len(window) + if bound != nil { + run = runLength(window, bound, m.compare, 0) + } + for _, row := range window[:run] { + rows[n] = append(rows[n][:0], row...) + n++ + } + if !c.advance(int32(run)) { + return n, nil + } + if run < len(window) { + break // the run bound was crossed + } + } + m.streak = 0 + m.replayGames() + continue + } + + prev := m.winner + m.replayGames() + if m.winner == prev { + m.streak++ + } else { + m.streak = 0 } } - if len(m.readers) == 0 { + if m.count == 0 { err = io.EOF } return n, err } -func (m *mergedRowReader) heapInit() { - n := len(m.readers) - for i := n/2 - 1; i >= 0; i-- { - m.heapDown(i, n) +// runBound returns the second-smallest head among the merged readers, i.e. the +// row that the current winner's head must not exceed for the winner to keep +// winning. In a tournament tree of losers the runner-up necessarily lost its +// game directly against the overall winner, so it is stored at one of the +// nodes on the winner's path from leaf to root; the minimum over those players +// is the runner-up. Returns nil when the winner is the only reader left. +func (m *mergedRowReader) runBound() (bound Row) { + for offset := (m.winnerLeaf - 1) / 2; ; offset = (offset - 1) / 2 { + if player := m.losers[offset]; player >= 0 { + if head := m.buffers[player].head(); bound == nil || m.compare(head, bound) < 0 { + bound = head + } + } + if offset == 0 { + return bound + } } } -func (m *mergedRowReader) heapPop() { - n := len(m.readers) - 1 - m.heapSwap(0, n) - m.heapDown(0, n) - m.readers = m.readers[:n] +// playInitialGames recursively plays the tournament rooted at position i, +// storing the loser of each game at the internal node where it was played, +// and returns the winner of the subtree. +func (m *mergedRowReader) playInitialGames(i int32, leaves []int32) int32 { + k := int32(len(m.buffers)) + if i >= k { // leaf or out of bounds + if i -= k; int(i) < len(leaves) { + return leaves[i] + } + return -1 + } + n1 := m.playInitialGames(2*i+1, leaves) + n2 := m.playInitialGames(2*i+2, leaves) + loser, winner := m.playGame(n1, n2) + m.losers[i] = loser + return winner } -func (m *mergedRowReader) heapUp(j int) { - for { - i := (j - 1) / 2 // parent - if i == j || !(m.compare(m.readers[j].head(), m.readers[i].head()) < 0) { - break - } - m.heapSwap(i, j) - j = i +func (m *mergedRowReader) playGame(n1, n2 int32) (loser, winner int32) { + if n1 < 0 { + return n1, n2 + } + if n2 < 0 { + return n2, n1 } + if m.compare(m.buffers[n1].head(), m.buffers[n2].head()) < 0 { + return n2, n1 + } + return n1, n2 } -func (m *mergedRowReader) heapDown(i0, n int) bool { - i := i0 - for { - j1 := 2*i + 1 - if j1 >= n || j1 < 0 { // j1 < 0 after int overflow - break - } - j := j1 // left child - if j2 := j1 + 1; j2 < n && m.compare(m.readers[j2].head(), m.readers[j1].head()) < 0 { - j = j2 // = 2*i + 2 // right child +// replayGames walks the path from the current winner's leaf to the root, +// playing the winner against the losers stored along the way and exchanging +// them when they win, then records the new overall winner. +func (m *mergedRowReader) replayGames() { + winner := m.winner + for offset := (m.winnerLeaf - 1) / 2; ; offset = (offset - 1) / 2 { + player := m.losers[offset] + + if player >= 0 { + if winner < 0 || m.compare(m.buffers[player].head(), m.buffers[winner].head()) < 0 { + m.losers[offset] = winner + winner = player + } } - if !(m.compare(m.readers[j].head(), m.readers[i].head()) < 0) { + + if offset == 0 { break } - m.heapSwap(i, j) - i = j } - return i > i0 + m.winner = winner + m.winnerLeaf = int32(len(m.buffers)) + winner } -func (m *mergedRowReader) heapSwap(i, j int) { - m.readers[i], m.readers[j] = m.readers[j], m.readers[i] -} +// minRowBufferSize is the initial buffer size of a bufferedRowReader, and +// maxRowBufferSize the size it can grow to. Buffers grow exponentially as +// long as the underlying reader keeps filling them completely, so merges of +// small row groups do not pay for full-size buffers while sustained merges +// amortize refills and extend the reach of the bulk run emission paths, +// which are bounded by the buffered window. +const ( + minRowBufferSize = 24 + maxRowBufferSize = 192 +) type bufferedRowReader struct { rows RowReader off int32 end int32 - buf [24]Row + full bool // the last read filled the buffer completely + buf []Row } func (r *bufferedRowReader) empty() bool { @@ -757,7 +972,17 @@ func (r *bufferedRowReader) head() Row { } func (r *bufferedRowReader) next() bool { - r.off++ + return r.advance(1) +} + +// window returns the buffered rows that have not been consumed yet. +func (r *bufferedRowReader) window() []Row { + return r.buf[r.off:r.end] +} + +// advance consumes n buffered rows and reports whether more remain buffered. +func (r *bufferedRowReader) advance(n int32) bool { + r.off += n hasNext := r.off < r.end if !hasNext { // We need to read more rows, however it is unsafe to do so here because we haven't @@ -769,14 +994,55 @@ func (r *bufferedRowReader) next() bool { } func (r *bufferedRowReader) read() error { + if r.buf == nil { + r.buf = make([]Row, minRowBufferSize) + } else if r.full && r.off == 0 && r.end == 0 && len(r.buf) < maxRowBufferSize { + // The reader keeps filling the buffer completely: grow it to amortize + // refills and extend the bulk run emission paths. The previous rows + // are carried over so their backing arrays keep being reused. + buf := make([]Row, min(2*len(r.buf), maxRowBufferSize)) + copy(buf, r.buf) + r.buf = buf + } n, err := r.rows.ReadRows(r.buf[r.end:]) if err != nil && n == 0 { return err } r.end += int32(n) + r.full = r.end == int32(len(r.buf)) return nil } +// runLength returns the number of leading rows of window whose comparison +// against bound is at most max (0 to include ties, -1 to exclude them). The +// window must be sorted by the same comparison function, so the qualifying +// rows form a prefix; the function checks the first and last rows to settle +// empty and complete runs with a single comparison, then gallops with a +// binary search refinement, costing O(log n) comparisons instead of the O(n) +// of a linear scan. +func runLength(window []Row, bound Row, compare func(Row, Row) int, max int) int { + if len(window) == 0 || compare(window[0], bound) > max { + return 0 + } + if compare(window[len(window)-1], bound) <= max { + return len(window) + } + lo, hi := 0, 1 + for hi < len(window) && compare(window[hi], bound) <= max { + lo = hi + hi *= 2 + } + hi = min(hi, len(window)) + for lo+1 < hi { + if mid := int(uint(lo+hi) >> 1); compare(window[mid], bound) <= max { + lo = mid + } else { + hi = mid + } + } + return hi +} + var ( _ RowReaderWithSchema = (*mergedRowGroupRows)(nil) ) @@ -878,12 +1144,12 @@ func mergeTwoNodes(a, b Node) Node { merged = group if logicalType := b.Type().LogicalType(); logicalType != nil { - switch { - case logicalType.List != nil: + switch logicalType.Value.(type) { + case *format.ListType: merged = &listNode{group} - case logicalType.Map != nil: + case *format.MapType: merged = &mapNode{group} - case logicalType.Variant != nil: + case *format.VariantType: merged = &variantNode{group} } } diff --git a/vendor/github.com/parquet-go/parquet-go/merge_refine.go b/vendor/github.com/parquet-go/parquet-go/merge_refine.go new file mode 100644 index 00000000000..9bb1a1b7959 --- /dev/null +++ b/vendor/github.com/parquet-go/parquet-go/merge_refine.go @@ -0,0 +1,365 @@ +package parquet + +import ( + "slices" + "sort" +) + +// This file refines overlapping merge segments: when sorted row groups overlap +// only in part of their key ranges (e.g. time-ordered files overlapping around +// their boundaries), the stretches of key space covered by a single row group +// do not need to be merged row by row — they can be sliced off as row-range +// views (see row_range.go) and read or written through the column-oriented +// paths, leaving only the truly overlapping stretches for the loser-tree merge. +// +// Cuts are only ever applied to the row group that is alone in a stretch of +// key space (a "lone stretch"), and are validated against the exact +// row-group-level min/max keys of the other row groups. This avoids a subtle +// hazard: page-granular cuts of different row groups at a common boundary key +// land at different actual keys, which could reorder rows across regions. +// Cutting only the lone row group — with the rows of its boundary pages pushed +// into the adjacent merged region — guarantees that every row of a region +// compares at most equal to every row of the following regions, so +// concatenating the regions preserves sorted order. Ties across row groups +// always land in merged regions, whose loser-tree resolves them. +// +// The refined plan is equivalent to the full merge as a sorted sequence: the +// same multiset of rows, with each input row group's rows in their original +// relative order. The interleaving of rows with equal sort keys across row +// groups may differ from the unrefined merge (as it already does between merge +// arities), which is why refinement is not applied when dropping duplicated +// rows: which physical row of an equal-key run survives deduplication depends +// on that interleaving. + +// disableMergeRefinement forces overlapping segments through the unrefined +// merge. It exists only so tests and benchmarks can compare refined plans +// against the reference behavior. +var disableMergeRefinement bool + +// minStreamedRegionRows is the minimum number of rows a lone stretch must span +// to be worth slicing out of the merge. Below this, the overhead of an extra +// segment (a seek per column, a row group boundary when writing) outweighs the +// merge work saved, so the stretch stays in the adjacent merged region. +const minStreamedRegionRows = 1024 + +// refineTarget describes one row group of an overlapping segment for the +// planner. minRow and maxRow are the exact bounds of the sorting columns, as +// computed by rowGroupRangeOfSortedColumns. cutAbove and cutBelow are +// conservative page-granular row lookups on the first sorting column; either +// may be nil when the row group does not support them, in which case the row +// group is never sliced. +type refineTarget struct { + rowGroup RowGroup + minRow Row + maxRow Row + numRows int64 + + // cutAbove returns the smallest row index such that every row at or after + // it has a sort key strictly greater than key, rounded down to a page + // boundary of the first sorting column (the rows of the page containing + // key stay below the cut). + cutAbove func(key Row) int64 + + // cutBelow returns the largest row index such that every row before it + // has a sort key strictly less than key, rounded down to a page boundary + // of the first sorting column (the rows of the page containing key stay + // at or above the cut). + cutBelow func(key Row) int64 +} + +// newRefineTargets builds the planner inputs for one overlapping segment. It +// returns nil when the segment cannot be refined at all (bounds unavailable). +// Individual row groups whose page index does not support cut lookups get nil +// cut functions and are never sliced, but still participate in the plan. +func newRefineTargets(segment []rowGroupRange, schema *Schema, sorting []SortingColumn) []refineTarget { + if len(sorting) == 0 { + return nil + } + + // Locate the leaf column of the first sorting column; cuts are computed on + // its page bounds only. (Strict inequality on the first sort column implies + // strict inequality on the full sorting tuple, so cuts remain conservative + // for multi-column sorts.) + sortingColumnIndex := -1 + sortingColumnPath := columnPath(sorting[0].Path()) + for columnIndex, path := range schema.Columns() { + if slices.Equal(path, sortingColumnPath) { + sortingColumnIndex = columnIndex + break + } + } + if sortingColumnIndex < 0 { + return nil + } + descending := sorting[0].Descending() + + targets := make([]refineTarget, len(segment)) + for i, rr := range segment { + if rr.minRow == nil || rr.maxRow == nil { + return nil + } + targets[i] = refineTarget{ + rowGroup: rr.rowGroup, + minRow: rr.minRow, + maxRow: rr.maxRow, + numRows: rr.rowGroup.NumRows(), + } + targets[i].cutAbove, targets[i].cutBelow = newCutLookups(rr.rowGroup, sortingColumnIndex, descending) + } + return targets +} + +// newCutLookups builds the page-granular row cut lookups for the sorting leaf +// column of a row group, or (nil, nil) when the page index does not support +// them (missing column or offset index, or null pages in the sorting column, +// whose position in the sort order is not knowable from the index). +func newCutLookups(rg RowGroup, columnIndex int, descending bool) (cutAbove, cutBelow func(Row) int64) { + chunks := rg.ColumnChunks() + if columnIndex >= len(chunks) { + return nil, nil + } + chunk := chunks[columnIndex] + columnType := chunk.Type() + + ci, err := chunk.ColumnIndex() + if err != nil || ci == nil || ci.NumPages() == 0 { + return nil, nil + } + oi, err := chunk.OffsetIndex() + if err != nil || oi == nil || oi.NumPages() != ci.NumPages() { + return nil, nil + } + numPages := ci.NumPages() + for p := range numPages { + if ci.NullPage(p) { + return nil, nil + } + } + numRows := rg.NumRows() + + // In-order page bounds: the first value of a page in sort order is its + // minimum for ascending sorts and its maximum for descending sorts. + earliest := ci.MinValue + latest := ci.MaxValue + if descending { + earliest, latest = latest, earliest + } + // orderCompare orders values by the sort direction. + orderCompare := func(a, b Value) int { + return compareValues(a, b, columnType, descending) + } + pageEnd := func(p int) int64 { + if p+1 < numPages { + return oi.FirstRowIndex(p + 1) + } + return numRows + } + + // cutAbove: end of the last page whose earliest value is at or before key + // (every row from the cut on belongs to a later page, whose values are all + // strictly after key). + cutAbove = func(key Row) int64 { + kv := key[columnIndex] + if kv.IsNull() { + return numRows // no safe cut: the slice comes out empty + } + p := sort.Search(numPages, func(p int) bool { + return orderCompare(earliest(p), kv) > 0 + }) + if p == 0 { + return 0 + } + return pageEnd(p - 1) + } + + // cutBelow: start of the first page whose latest value is at or after key + // (every row before the cut belongs to an earlier page, whose values are + // all strictly before key). + cutBelow = func(key Row) int64 { + kv := key[columnIndex] + if kv.IsNull() { + return 0 // no safe cut: the slice comes out empty + } + p := sort.Search(numPages, func(p int) bool { + return orderCompare(latest(p), kv) >= 0 + }) + if p == numPages { + return numRows + } + return oi.FirstRowIndex(p) + } + + return cutAbove, cutBelow +} + +// refineSegment plans the refinement of one overlapping segment, returning the +// refined sub-segments: an alternation of merged regions (built with +// makeMerged from two or more participants) and single-source row groups or +// range views. It returns nil when no refinement applies, in which case the +// caller merges the whole segment as usual. +func refineSegment(targets []refineTarget, compare func(Row, Row) int, makeMerged func([]RowGroup) RowGroup) []RowGroup { + if len(targets) < 2 { + return nil + } + + type event struct { + key Row + start bool + index int + } + + events := make([]event, 0, 2*len(targets)) + for i := range targets { + events = append(events, + event{key: targets[i].minRow, start: true, index: i}, + event{key: targets[i].maxRow, start: false, index: i}, + ) + } + slices.SortStableFunc(events, func(a, b event) int { + if c := compare(a.key, b.key); c != 0 { + return c + } + // Starts sort before ends so that touching ranges (a max equal to + // another's min) produce a merged region for the shared key instead + // of being falsely torn apart. + switch { + case a.start && !b.start: + return -1 + case !a.start && b.start: + return +1 + default: + return 0 + } + }) + + // regionPart tracks the target index of each participant so merged + // regions can list participants deterministically in minRow order. + type regionPart struct { + index int + part RowGroup + } + + var ( + plan []RowGroup + region []regionPart // participants of the merged region being built + cursors map[int]int64 // rows of each target consumed by earlier regions + active map[int]struct{} // targets whose key interval covers the sweep position + sliced bool // whether any lone slice was emitted + + // pendingLone is set while the sweep is inside a stretch of key space + // covered by a single target; leftK is the exclusive lower bound of + // the stretch (nil at the start of the segment). + pendingLone = -1 + pendingLeftK Row + ) + cursors = make(map[int]int64, len(targets)) + active = make(map[int]struct{}, len(targets)) + + remainder := func(i int) (RowGroup, bool) { + t := &targets[i] + off := cursors[i] + if off >= t.numRows { + return nil, false + } + cursors[i] = t.numRows + if off == 0 { + return t.rowGroup, true + } + return newRowRangeRowGroup(t.rowGroup, off, t.numRows-off), true + } + + closeRegion := func() { + switch len(region) { + case 0: + case 1: + plan = append(plan, region[0].part) + default: + slices.SortStableFunc(region, func(a, b regionPart) int { return a.index - b.index }) + parts := make([]RowGroup, len(region)) + for i, p := range region { + parts[i] = p.part + } + plan = append(plan, makeMerged(parts)) + } + region = nil + } + + // resolveLone ends the pending lone stretch, bounded above by rightK (nil + // at the end of the segment). When the stretch is sliceable and large + // enough, the region below it is closed and the slice emitted; otherwise + // the stretch simply remains part of the current region. + resolveLone := func(rightK Row) { + i := pendingLone + pendingLone = -1 + t := &targets[i] + if t.cutAbove == nil || t.cutBelow == nil { + return + } + off := int64(0) + if pendingLeftK != nil { + off = t.cutAbove(pendingLeftK) + } + end := t.numRows + if rightK != nil { + end = t.cutBelow(rightK) + } + off = max(off, cursors[i]) + end = min(end, t.numRows) + if end-off < minStreamedRegionRows { + return + } + + // Close the region below the slice: every participant contributes its + // remaining rows (their key intervals ended inside the region), and + // the lone target contributes its rows before the slice. + if off > cursors[i] { + region = append(region, regionPart{index: i, part: newRowRangeRowGroup(t.rowGroup, cursors[i], off-cursors[i])}) + } + closeRegion() + + if off == 0 && end == t.numRows { + plan = append(plan, t.rowGroup) + } else { + plan = append(plan, newRowRangeRowGroup(t.rowGroup, off, end-off)) + } + cursors[i] = end + sliced = true + } + + for _, ev := range events { + if ev.start { + if pendingLone >= 0 { + resolveLone(ev.key) + } + active[ev.index] = struct{}{} + if len(active) == 1 { + // First target of the segment: it is alone until the next + // start event. + pendingLone = ev.index + pendingLeftK = nil + } + } else { + // If the ending target is the pending lone one, its stretch runs + // to the end of its rows: resolve before consuming the remainder. + if ev.index == pendingLone { + resolveLone(nil) + } + delete(active, ev.index) + if r, ok := remainder(ev.index); ok { + region = append(region, regionPart{index: ev.index, part: r}) + } + if len(active) == 1 && pendingLone < 0 { + for lone := range active { + pendingLone = lone + } + pendingLeftK = ev.key + } + } + } + closeRegion() + + if !sliced { + return nil + } + return plan +} diff --git a/vendor/github.com/parquet-go/parquet-go/multi_row_group.go b/vendor/github.com/parquet-go/parquet-go/multi_row_group.go index 65bf920d0dd..084b3d4d160 100644 --- a/vendor/github.com/parquet-go/parquet-go/multi_row_group.go +++ b/vendor/github.com/parquet-go/parquet-go/multi_row_group.go @@ -126,6 +126,11 @@ func (m *multiRowGroup) Schema() *Schema { return m.schema } func (m *multiRowGroup) Rows() Rows { return NewRowGroupRowReader(m) } +// rowGroupSegments implements orderedRowGroupSegments: a multiRowGroup is the +// in-order concatenation of its row groups, so each may be written independently +// while preserving row order. +func (m *multiRowGroup) rowGroupSegments() []RowGroup { return m.rowGroups } + type multiColumnChunk struct { rowGroup *multiRowGroup column int @@ -213,10 +218,20 @@ func (c *multiColumnChunk) OffsetIndex() (OffsetIndex, error) { offsets[i+1] = offsets[i] + index.NumPages() } - // Build cumulative row offsets for each chunk + // Build cumulative row offsets for each chunk. Use rowCounts when + // available (flattened chunks), otherwise fall back to rowGroups; the + // chunk count can exceed len(rowGroups) when merging already-merged + // row groups. + rowCounts := c.rowCounts rowOffsets := make([]int64, len(c.chunks)+1) for i := range c.chunks { - rowOffsets[i+1] = rowOffsets[i] + c.rowGroup.rowGroups[i].NumRows() + var numRows int64 + if i < len(rowCounts) { + numRows = rowCounts[i] + } else { + numRows = c.rowGroup.rowGroups[i].NumRows() + } + rowOffsets[i+1] = rowOffsets[i] + numRows } return &multiOffsetIndex{ diff --git a/vendor/github.com/parquet-go/parquet-go/node.go b/vendor/github.com/parquet-go/parquet-go/node.go index e92489f3e8e..cf2cc79a595 100644 --- a/vendor/github.com/parquet-go/parquet-go/node.go +++ b/vendor/github.com/parquet-go/parquet-go/node.go @@ -475,17 +475,17 @@ func isValidInGoIdent(r rune) bool { func isList(node Node) bool { logicalType := node.Type().LogicalType() - return logicalType != nil && logicalType.List != nil + return logicalTypeIs[*format.ListType](logicalType) } func isMap(node Node) bool { logicalType := node.Type().LogicalType() - return logicalType != nil && logicalType.Map != nil + return logicalTypeIs[*format.MapType](logicalType) } func isVariant(node Node) bool { logicalType := node.Type().LogicalType() - return logicalType != nil && logicalType.Variant != nil + return logicalTypeIs[*format.VariantType](logicalType) } func numLeafColumnsOf(node Node) uint16 { diff --git a/vendor/github.com/parquet-go/parquet-go/page_be128.go b/vendor/github.com/parquet-go/parquet-go/page_be128.go index 30f62d0f924..d5d6ac6470c 100644 --- a/vendor/github.com/parquet-go/parquet-go/page_be128.go +++ b/vendor/github.com/parquet-go/parquet-go/page_be128.go @@ -3,7 +3,9 @@ package parquet import ( "io" + "github.com/google/uuid" "github.com/parquet-go/parquet-go/encoding" + "github.com/parquet-go/parquet-go/internal/unsafecast" ) type be128Page struct { @@ -97,3 +99,32 @@ func (r *be128PageValues) ReadValues(values []Value) (n int, err error) { } return n, err } + +func (r *be128PageValues) ReadBE128s(values [][16]byte) (n int, err error) { + n = copy(values, r.page.values[r.offset:]) + r.offset += n + if r.offset == len(r.page.values) { + err = io.EOF + } + return n, err +} + +func (col *be128ColumnBuffer) WriteBE128s(values [][16]byte) (int, error) { + col.values = append(col.values, values...) + return len(values), nil +} + +func (r *be128PageValues) ReadUUIDs(values []uuid.UUID) (n int, err error) { + pageValues := unsafecast.Slice[uuid.UUID](r.page.values) + n = copy(values, pageValues[r.offset:]) + r.offset += n + if r.offset == len(pageValues) { + err = io.EOF + } + return n, err +} + +func (col *be128ColumnBuffer) WriteUUIDs(values []uuid.UUID) (int, error) { + col.values = append(col.values, unsafecast.Slice[[16]byte](values)...) + return len(values), nil +} diff --git a/vendor/github.com/parquet-go/parquet-go/page_bounds_amd64.go b/vendor/github.com/parquet-go/parquet-go/page_bounds_amd64.go index 9cb513b407c..95d250cc414 100644 --- a/vendor/github.com/parquet-go/parquet-go/page_bounds_amd64.go +++ b/vendor/github.com/parquet-go/parquet-go/page_bounds_amd64.go @@ -38,7 +38,12 @@ package parquet // to running less instructions per loop. The performance starts to equalize // around 256KiB, and degrade beyond 1MiB, so we use this threshold to determine // which approach to prefer. -const combinedBoundsThreshold = 1 * 1024 * 1024 +const ( + combinedBoundsThreshold = 1 * 1024 * 1024 + // ColumnWriter fills pages to 98% of DefaultPageBufferSize. This is the + // first whole INT64 value count that reaches that default page target. + combinedBoundsInt64Threshold = (DefaultPageBufferSize*98/100 + 7) / 8 +) //go:noescape func combinedBoundsBool(data []bool) (min, max bool) @@ -49,6 +54,9 @@ func combinedBoundsInt32(data []int32) (min, max int32) //go:noescape func combinedBoundsInt64(data []int64) (min, max int64) +//go:noescape +func combinedBoundsInt64AVX512(data []int64) (min, max int64) + //go:noescape func combinedBoundsUint32(data []uint32) (min, max uint32) @@ -74,8 +82,13 @@ func boundsInt32(data []int32) (min, max int32) { } func boundsInt64(data []int64) (min, max int64) { - if 8*len(data) >= combinedBoundsThreshold { - return combinedBoundsInt64(data) + if len(data) >= combinedBoundsInt64Threshold { + if hasAVX512VL && 8*len(data) < combinedBoundsThreshold { + return combinedBoundsInt64AVX512(data) + } + if 8*len(data) >= combinedBoundsThreshold { + return combinedBoundsInt64(data) + } } min = minInt64(data) max = maxInt64(data) diff --git a/vendor/github.com/parquet-go/parquet-go/page_bounds_amd64.s b/vendor/github.com/parquet-go/parquet-go/page_bounds_amd64.s index c6d172a5e1a..bdadc5a26bc 100644 --- a/vendor/github.com/parquet-go/parquet-go/page_bounds_amd64.s +++ b/vendor/github.com/parquet-go/parquet-go/page_bounds_amd64.s @@ -212,6 +212,79 @@ done: MOVQ R9, max+32(FP) RET +// func combinedBoundsInt64AVX512(data []int64) (min, max int64) +TEXT ·combinedBoundsInt64AVX512(SB), NOSPLIT, $-40 + MOVQ data_base+0(FP), AX + MOVQ data_len+8(FP), CX + XORQ SI, SI + + MOVQ CX, DI + SHRQ $5, DI + SHLQ $5, DI + VPBROADCASTQ (AX), Z0 + VPBROADCASTQ (AX), Z1 + VPBROADCASTQ (AX), Z2 + VPBROADCASTQ (AX), Z3 +loop32: + VMOVDQU64 (AX)(SI*8), Z4 + VMOVDQU64 64(AX)(SI*8), Z5 + VMOVDQU64 128(AX)(SI*8), Z6 + VMOVDQU64 192(AX)(SI*8), Z7 + VPMINSQ Z4, Z0, Z0 + VPMAXSQ Z4, Z1, Z1 + VPMINSQ Z5, Z2, Z2 + VPMAXSQ Z5, Z3, Z3 + VPMINSQ Z6, Z0, Z0 + VPMAXSQ Z6, Z1, Z1 + VPMINSQ Z7, Z2, Z2 + VPMAXSQ Z7, Z3, Z3 + ADDQ $32, SI + CMPQ SI, DI + JNE loop32 + + VPMINSQ Z2, Z0, Z0 + VPMAXSQ Z3, Z1, Z1 + + VMOVDQU32 swap32+0(SB), Z2 + VMOVDQU32 swap32+0(SB), Z3 + VPERMI2D Z0, Z0, Z2 + VPERMI2D Z1, Z1, Z3 + VPMINSQ Y2, Y0, Y0 + VPMAXSQ Y3, Y1, Y1 + + VMOVDQU32 swap32+32(SB), Y2 + VMOVDQU32 swap32+32(SB), Y3 + VPERMI2D Y0, Y0, Y2 + VPERMI2D Y1, Y1, Y3 + VPMINSQ X2, X0, X0 + VPMAXSQ X3, X1, X1 + + VMOVDQU32 swap32+48(SB), X2 + VMOVDQU32 swap32+48(SB), X3 + VPERMI2D X0, X0, X2 + VPERMI2D X1, X1, X3 + VPMINSQ X2, X0, X0 + VPMAXSQ X3, X1, X1 + VZEROUPPER + + MOVQ X0, R8 + MOVQ X1, R9 + CMPQ SI, CX + JE done +loop: + MOVQ (AX)(SI*8), DX + CMPQ DX, R8 + CMOVQLT DX, R8 + CMPQ DX, R9 + CMOVQGT DX, R9 + INCQ SI + CMPQ SI, CX + JNE loop +done: + MOVQ R8, min+24(FP) + MOVQ R9, max+32(FP) + RET + // func combinedBoundsUint32(data []uint32) (min, max uint32) TEXT ·combinedBoundsUint32(SB), NOSPLIT, $-32 MOVQ data_base+0(FP), AX diff --git a/vendor/github.com/parquet-go/parquet-go/reader.go b/vendor/github.com/parquet-go/parquet-go/reader.go index 29c020892f4..21d54965816 100644 --- a/vendor/github.com/parquet-go/parquet-go/reader.go +++ b/vendor/github.com/parquet-go/parquet-go/reader.go @@ -662,6 +662,9 @@ func makeFileRowGroups(file *File, columns []*Column) ([]FileRowGroup, error) { if err := validateRowGroupOrdinals(rowGroups); err != nil { return nil, err } + if err := validateRowCounts(file.metadata.NumRows, rowGroups); err != nil { + return nil, err + } fileRowGroups := make([]FileRowGroup, len(rowGroups)) for i := range fileRowGroups { @@ -712,3 +715,17 @@ func validateRowGroupOrdinals(rowGroups []format.RowGroup) error { } return nil } + +// validateRowCounts rejects negative row counts in the file footer and row groups +// prevent panics later on that would reach for an invalid slice index +func validateRowCounts(fileNumRows int64, rowGroups []format.RowGroup) error { + if fileNumRows < 0 { + return fmt.Errorf("invalid file metadata: num_rows=%d is negative", fileNumRows) + } + for i := range rowGroups { + if n := rowGroups[i].NumRows; n < 0 { + return fmt.Errorf("invalid file metadata: row group %d num_rows=%d is negative", i, n) + } + } + return nil +} diff --git a/vendor/github.com/parquet-go/parquet-go/row.go b/vendor/github.com/parquet-go/parquet-go/row.go index 190480832c4..c1010525433 100644 --- a/vendor/github.com/parquet-go/parquet-go/row.go +++ b/vendor/github.com/parquet-go/parquet-go/row.go @@ -666,7 +666,8 @@ func reconstructFuncOfRepeated(columnIndex uint16, node Node) (uint16, reconstru return nil } - values := make([][]Value, len(columns)) + b := acquireValuesSliceBuffer() + values := b.reserve(len(columns)) column := columns[0] n := 0 @@ -701,6 +702,7 @@ func reconstructFuncOfRepeated(columnIndex uint16, node Node) (uint16, reconstru } if err := reconstruct(value.Index(i), levels, values); err != nil { + b.release() return err } @@ -711,6 +713,7 @@ func reconstructFuncOfRepeated(columnIndex uint16, node Node) (uint16, reconstru levels.repetitionLevel = levels.repetitionDepth } + b.release() return nil } } @@ -761,7 +764,8 @@ func reconstructFuncOfMap(columnIndex uint16, node Node) (uint16, reconstructFun return nil } - values := make([][]Value, len(columns)) + b := acquireValuesSliceBuffer() + values := b.reserve(len(columns)) column := columns[0] t := value.Type() if t.Kind() == reflect.Interface { @@ -808,6 +812,7 @@ func reconstructFuncOfMap(columnIndex uint16, node Node) (uint16, reconstructFun } if err := reconstruct(elem, levels, values); err != nil { + b.release() return err } @@ -832,6 +837,7 @@ func reconstructFuncOfMap(columnIndex uint16, node Node) (uint16, reconstructFun levels.repetitionLevel = levels.repetitionDepth } + b.release() return nil } } diff --git a/vendor/github.com/parquet-go/parquet-go/row_range.go b/vendor/github.com/parquet-go/parquet-go/row_range.go new file mode 100644 index 00000000000..e70fa490cb8 --- /dev/null +++ b/vendor/github.com/parquet-go/parquet-go/row_range.go @@ -0,0 +1,176 @@ +package parquet + +import ( + "fmt" + "io" +) + +// This file implements row-range views of row groups: a rowRangeRowGroup +// presents rows [off, off+length) of a base row group, with column chunks that +// seek to the range start and stop after the range's row count. Range views are +// produced by the merge planner (see merge_refine.go) to slice partially +// overlapping row groups into disjoint stretches — which stream through the +// writer's column-oriented fast paths — and truly overlapping stretches, which +// go through the loser-tree merge. + +// rowRangeRowGroup is a view of rows [off, off+length) of a base row group. +type rowRangeRowGroup struct { + base RowGroup + off int64 + length int64 + chunks []ColumnChunk +} + +// newRowRangeRowGroup returns a view of rows [off, off+length) of base. The +// caller is responsible for bounds: 0 <= off, off+length <= base.NumRows(), +// length > 0, and for not constructing views that span the whole base row +// group (use the base row group directly instead, which preserves its +// eligibility for the verbatim copy fast path). +func newRowRangeRowGroup(base RowGroup, off, length int64) *rowRangeRowGroup { + baseChunks := base.ColumnChunks() + rg := &rowRangeRowGroup{ + base: base, + off: off, + length: length, + chunks: make([]ColumnChunk, len(baseChunks)), + } + + // The value count of a row range is only knowable from metadata when each + // row holds exactly one value, i.e. for non-repeated columns. + repeated := make([]bool, len(baseChunks)) + if schema := base.Schema(); schema != nil { + forEachLeafColumnOf(schema, func(leaf leafColumn) { + if int(leaf.columnIndex) < len(repeated) { + repeated[leaf.columnIndex] = leaf.maxRepetitionLevel > 0 + } + }) + } + + for i, chunk := range baseChunks { + rg.chunks[i] = &rangeColumnChunk{ + base: chunk, + off: off, + length: length, + exact: !repeated[i], + } + } + return rg +} + +func (rg *rowRangeRowGroup) NumRows() int64 { return rg.length } +func (rg *rowRangeRowGroup) ColumnChunks() []ColumnChunk { return rg.chunks } +func (rg *rowRangeRowGroup) Schema() *Schema { return rg.base.Schema() } +func (rg *rowRangeRowGroup) SortingColumns() []SortingColumn { return rg.base.SortingColumns() } +func (rg *rowRangeRowGroup) Rows() Rows { return NewRowGroupRowReader(rg) } + +// chunkTransparentRowGroup marks range views as safe for the chunk-level write +// fast paths: Rows() is NewRowGroupRowReader over the range chunks, so reading +// the chunks in order is the definition of its row semantics. +func (rg *rowRangeRowGroup) chunkTransparentRowGroup() {} + +// rangeColumnChunk presents rows [off, off+length) of a base column chunk. +type rangeColumnChunk struct { + base ColumnChunk + off int64 + length int64 + exact bool // NumValues is exact (non-repeated column) +} + +func (c *rangeColumnChunk) Type() Type { return c.base.Type() } +func (c *rangeColumnChunk) Column() int { return c.base.Column() } + +func (c *rangeColumnChunk) Pages() Pages { + pages := c.base.Pages() + if err := pages.SeekToRow(c.off); err != nil { + pages.Close() + return &errorPages{err: fmt.Errorf("seeking to start of row range at %d: %w", c.off, err)} + } + return &rangePages{base: pages, off: c.off, length: c.length, remaining: c.length} +} + +// The page index and bloom filter of the base chunk describe all of its rows; +// exposing them for a sub-range would let consumers draw wrong conclusions +// (e.g. bounds that rows in the range never reach), so range views report them +// as absent. +func (c *rangeColumnChunk) ColumnIndex() (ColumnIndex, error) { return nil, ErrMissingColumnIndex } +func (c *rangeColumnChunk) OffsetIndex() (OffsetIndex, error) { return nil, ErrMissingOffsetIndex } +func (c *rangeColumnChunk) BloomFilter() BloomFilter { return nil } + +// NumValues returns the number of values in the row range. For non-repeated +// columns this is exactly the row count; for repeated columns the count is not +// knowable from metadata and the base chunk's total is returned as an upper +// bound (see exactNumValues). +func (c *rangeColumnChunk) NumValues() int64 { + if c.exact { + return c.length + } + return c.base.NumValues() +} + +// exactNumValues reports whether NumValues is exact rather than an upper +// bound. Consumers that size resources from NumValues (bloom filters) must +// check this and fall back when the count is inexact. +func (c *rangeColumnChunk) exactNumValues() bool { return c.exact } + +// rangePages limits a Pages stream positioned inside its base column chunk to +// the rows [off, off+length) of the base, slicing the final page when the +// range ends mid-page. +type rangePages struct { + base Pages + off int64 // start of the range, in base row indexes + length int64 + remaining int64 +} + +func (p *rangePages) ReadPage() (Page, error) { + if p.remaining <= 0 { + return nil, io.EOF + } + page, err := p.base.ReadPage() + if err != nil { + return nil, err + } + numRows := page.NumRows() + if numRows <= p.remaining { + p.remaining -= numRows + return page, nil + } + // The range ends inside this page. The slice shares the page's underlying + // buffers without incrementing their reference counts, so ownership of the + // page transfers to the caller through the slice: the caller's Release of + // the slice releases the shared buffers. + tail := page.Slice(0, p.remaining) + p.remaining = 0 + return tail, nil +} + +// SeekToRow positions the stream on the row at index rowIndex within the +// range (i.e. relative to the start of the range, not of the base chunk). +func (p *rangePages) SeekToRow(rowIndex int64) error { + if rowIndex < 0 || rowIndex > p.length { + return fmt.Errorf("SeekToRow: row index %d out of range of row range view of %d rows", rowIndex, p.length) + } + if err := p.base.SeekToRow(p.off + rowIndex); err != nil { + return err + } + p.remaining = p.length - rowIndex + return nil +} + +func (p *rangePages) Close() error { + p.remaining = 0 + return p.base.Close() +} + +// errorPages is a Pages implementation which returns an error on every read. +type errorPages struct{ err error } + +func (p *errorPages) ReadPage() (Page, error) { return nil, p.err } +func (p *errorPages) SeekToRow(int64) error { return p.err } +func (p *errorPages) Close() error { return nil } + +var ( + _ RowGroup = (*rowRangeRowGroup)(nil) + _ ColumnChunk = (*rangeColumnChunk)(nil) + _ Pages = (*rangePages)(nil) +) diff --git a/vendor/github.com/parquet-go/parquet-go/row_variant.go b/vendor/github.com/parquet-go/parquet-go/row_variant.go index 3fea8b3548f..9914963edf5 100644 --- a/vendor/github.com/parquet-go/parquet-go/row_variant.go +++ b/vendor/github.com/parquet-go/parquet-go/row_variant.go @@ -1,13 +1,10 @@ package parquet import ( - "encoding/binary" "fmt" - "maps" "reflect" "unsafe" - "github.com/google/uuid" "github.com/parquet-go/parquet-go/variant" ) @@ -122,82 +119,76 @@ func deconstructFuncOfUnshreddedVariant(columnIndex uint16, node Node) (uint16, } } -// deconstructFuncOfShreddedVariant handles the 3-field shredded variant: -// metadata (required), value (optional), typed_value (optional). -// -// When the Go value matches the typed_value schema, the value is written to the -// typed_value columns and the value column is set to null. Otherwise, the variant- -// encoded bytes are written to the value column and typed_value columns are null. +// deconstructFuncOfShreddedVariant writes Go values into a shredded variant +// group per the Variant Shredding specification (see +// variant_shredded_write.go): values matching the typed_value schema are +// shredded into typed columns; everything else is encoded as plain variant +// values into the appropriate value column, sharing the row's metadata +// dictionary. // //go:noinline func deconstructFuncOfShreddedVariant(columnIndex uint16, node Node) (uint16, deconstructFunc) { - // Fields are sorted alphabetically: metadata, typed_value, value - var metadataColumnIndex, valueColumnIndex, typedValueStartColumn uint16 - var typedValueLeafCount uint16 - var typedValueNode Node - - col := columnIndex - for _, f := range node.Fields() { - n := numLeafColumnsOf(f) - switch f.Name() { - case "metadata": - metadataColumnIndex = col - col += n - case "typed_value": - typedValueStartColumn = col - typedValueNode = f - typedValueLeafCount = n - col += n - case "value": - valueColumnIndex = col - col += n + // Schemas that cannot be written to (e.g. missing the metadata column) + // may still be read from; fail when a row is written, not at build time. + group, err := buildShreddedVariantGroup(node, 0, 0, 0) + if err == nil && group.metadataCol < 0 { + err = fmt.Errorf("variant: shredded variant group has no metadata field") + } + if err != nil { + numCols := numLeafColumnsOf(node) + return columnIndex + numCols, func([][]Value, columnLevels, reflect.Value) { + panic(fmt.Sprintf("invalid shredded variant schema: %v", err)) } } - nextColumnIndex := col - - // Determine the shredded type structure - typedInner := Required(typedValueNode) - matcher := buildShreddedMatcher(typedInner) + nextColumnIndex := columnIndex + uint16(group.numCols) return nextColumnIndex, func(columns [][]Value, levels columnLevels, value reflect.Value) { - metaIdx := ^metadataColumnIndex - valIdx := ^valueColumnIndex + // An invalid value means an enclosing optional/repeated wrapper is + // null for this row: the whole variant group is null. + if !value.IsValid() { + appendShreddedNulls(columns, columnIndex, 0, group.numCols, levels.definitionLevel, levels.repetitionLevel) + return + } + + // Convert the Go value to a variant value tree. Raw variant structs + // (Metadata/Value []byte fields) are decoded so their contents can + // be shredded like any other value. + var v variant.Value + if metaBytes, valBytes, ok := extractRawVariantStruct(value); ok { + m, err := variant.DecodeMetadata(metaBytes) + if err != nil { + panic(fmt.Sprintf("variant metadata: %v", err)) + } + if v, err = variant.Decode(m, valBytes); err != nil { + panic(fmt.Sprintf("variant decode: %v", err)) + } + } else { + var err error + if v, err = variant.ValueOf(extractGoValue(value)); err != nil { + panic(fmt.Sprintf("variant marshal: %v", err)) + } + } - metadata, val := variantMarshalOrNull(value) + // The row's metadata dictionary contains every object field name of + // the value, shredded or not. + var b variant.MetadataBuilder + addVariantFieldNames(&b, v) + + group.write(columns, columnIndex, &b, v, true, shredLevels{ + baseDef: int(levels.definitionLevel), + baseRep: int(levels.repetitionDepth), + rep: levels.repetitionLevel, + }) - // Always write metadata + // The metadata column is written last so the dictionary includes + // the field IDs assigned while encoding residual values. + _, metadata := b.Build() + metaCol := columnIndex + uint16(group.metadataCol) metaValue := makeValueByteArray(ByteArray, unsafe.SliceData(metadata), len(metadata)) metaValue.repetitionLevel = levels.repetitionLevel metaValue.definitionLevel = levels.definitionLevel - metaValue.columnIndex = metaIdx - columns[metadataColumnIndex] = append(columns[metadataColumnIndex], metaValue) - - // Try to shred the value - goVal := extractGoValue(value) - if goVal != nil && matcher.canShred(goVal) { - // Write null to value column (optional, def level not incremented) - columns[valueColumnIndex] = append(columns[valueColumnIndex], Value{ - repetitionLevel: levels.repetitionLevel, - definitionLevel: levels.definitionLevel, - columnIndex: valIdx, - }) - // Write typed value (increment def level for optional typed_value wrapper) - typedLevels := levels - typedLevels.definitionLevel++ - matcher.shred(columns, typedLevels, typedValueStartColumn, goVal) - } else { - // Write variant bytes to value column (increment def level for optional wrapper) - valueLevels := levels - valueLevels.definitionLevel++ - valValue := makeValueByteArray(ByteArray, unsafe.SliceData(val), len(val)) - valValue.repetitionLevel = valueLevels.repetitionLevel - valValue.definitionLevel = valueLevels.definitionLevel - valValue.columnIndex = valIdx - columns[valueColumnIndex] = append(columns[valueColumnIndex], valValue) - - // Write null to all typed_value columns - writeNullLeaves(columns, typedValueStartColumn, typedValueStartColumn+typedValueLeafCount, levels) - } + metaValue.columnIndex = ^metaCol + columns[metaCol] = append(columns[metaCol], metaValue) } } @@ -217,366 +208,6 @@ func extractGoValue(value reflect.Value) any { return v.Interface() } -// writeNullLeaves writes null values to all leaf columns in the range [start, end). -func writeNullLeaves(columns [][]Value, start, end uint16, levels columnLevels) { - for col := start; col < end; col++ { - columns[col] = append(columns[col], Value{ - repetitionLevel: levels.repetitionLevel, - definitionLevel: levels.definitionLevel, - columnIndex: ^col, - }) - } -} - -// shreddedMatcher determines if a Go value can be shredded into a typed_value -// column and performs the shredding. -// -// A matcher is one of three kinds: -// - primitive: typ is set (leaf column) -// - group: fields is set (object with per-field matchers) -// - unsupported: neither (e.g., LIST — values go to the fallback column) -// -// leafCount is always set to the number of leaf columns occupied. -type shreddedMatcher struct { - typ Type // non-nil for primitive typed_value (leaf node) - fields []shreddedFieldMatcher // non-nil for group typed_value (object node) - leafCount uint16 -} - -func (m *shreddedMatcher) isPrimitive() bool { return m.typ != nil } -func (m *shreddedMatcher) isGroup() bool { return len(m.fields) > 0 } -func (m *shreddedMatcher) kind() Kind { return m.typ.Kind() } -func (m *shreddedMatcher) isString() bool { - lt := m.typ.LogicalType() - return lt != nil && lt.UTF8 != nil -} -func (m *shreddedMatcher) isUUID() bool { - lt := m.typ.LogicalType() - return lt != nil && lt.UUID != nil -} - -type shreddedFieldMatcher struct { - name string - matcher shreddedMatcher -} - -func buildShreddedMatcher(node Node) shreddedMatcher { - if node.Leaf() { - return shreddedMatcher{ - typ: node.Type(), - leafCount: 1, - } - } - - // Check if this is a group with (value, typed_value) pairs for each field - fields := node.Fields() - matchers := make([]shreddedFieldMatcher, 0, len(fields)) - for _, f := range fields { - subFields := f.Fields() - if len(subFields) == 2 { - // This is a (value, typed_value) pair for a named field - valueNode := fieldByName(f, "value") - typedNode := fieldByName(f, "typed_value") - if valueNode != nil && typedNode != nil { - matchers = append(matchers, shreddedFieldMatcher{ - name: f.Name(), - matcher: buildShreddedMatcher(Required(typedNode)), - }) - } - } - } - - if len(matchers) > 0 { - return shreddedMatcher{ - fields: matchers, - leafCount: countMatcherLeaves(matchers), - } - } - - // Unsupported typed_value structure (e.g., LIST). Return a matcher - // that never shreds so values always go to the value column. - // Still compute leaf count so column offsets are correct. - return shreddedMatcher{ - leafCount: numLeafColumnsOf(node), - } -} - -func (m *shreddedMatcher) canShred(v any) bool { - if v == nil { - return false - } - if m.isPrimitive() { - return canShredPrimitive(v, m) - } - if m.isGroup() { - return canShredObject(v, m.fields) - } - return false -} - -func canShredPrimitive(v any, m *shreddedMatcher) bool { - switch m.kind() { - case ByteArray: - if m.isString() { - switch v.(type) { - case string: - return true - } - } else { - switch v.(type) { - case []byte: - return true - } - } - case Int32: - switch v.(type) { - case int8, int16, int32, uint8, uint16: - return true - } - case Int64: - switch v.(type) { - case int8, int16, int32, int64, int, uint8, uint16, uint32: - return true - } - case Float: - switch v.(type) { - case float32: - return true - } - case Double: - switch v.(type) { - case float32, float64: - return true - } - case Boolean: - switch v.(type) { - case bool: - return true - } - case FixedLenByteArray: - if m.isUUID() { - switch v.(type) { - case uuid.UUID, [16]byte: - return true - } - } else { - switch v.(type) { - case [16]byte: - return true - } - } - } - return false -} - -func canShredObject(v any, fields []shreddedFieldMatcher) bool { - m, ok := v.(map[string]any) - if !ok { - return false - } - // An object can be shredded if ALL its fields exist in the shredded schema - for key := range m { - found := false - for _, f := range fields { - if f.name == key { - found = true - break - } - } - if !found { - return false - } - } - return true -} - -func (m *shreddedMatcher) shred(columns [][]Value, levels columnLevels, startColumn uint16, v any) { - if m.isPrimitive() { - col := startColumn - pv := goValueToParquetValue(v, m.kind()) - pv.repetitionLevel = levels.repetitionLevel - pv.definitionLevel = levels.definitionLevel - pv.columnIndex = ^col - columns[col] = append(columns[col], pv) - return - } - if m.isGroup() { - m.shredObject(columns, levels, startColumn, v) - } -} - -func (m *shreddedMatcher) shredObject(columns [][]Value, levels columnLevels, startColumn uint16, v any) { - obj, ok := v.(map[string]any) - if !ok { - // Should not happen if canShred returned true - return - } - - col := startColumn - for _, f := range m.fields { - // Within each field's sub-group, fields are sorted alphabetically: - // typed_value comes before value. - typedValueCol := col - typedCount := f.matcher.leafCount - valueCol := col + typedCount - nextFieldCol := valueCol + 1 - - fieldVal, exists := obj[f.name] - if exists && fieldVal != nil && f.matcher.canShred(fieldVal) { - // Write null to field's value column - columns[valueCol] = append(columns[valueCol], Value{ - repetitionLevel: levels.repetitionLevel, - definitionLevel: levels.definitionLevel, - columnIndex: ^valueCol, - }) - // Write typed value (increment def for optional typed_value) - typedLevels := levels - typedLevels.definitionLevel++ - f.matcher.shred(columns, typedLevels, typedValueCol, fieldVal) - } else if exists && fieldVal != nil { - // Value doesn't match typed schema: write variant to field's value. - // Encode metadata+value together so nested objects can be decoded later. - valueLevels := levels - valueLevels.definitionLevel++ - metadata, val, err := variant.Marshal(fieldVal) - if err != nil { - panic(fmt.Sprintf("variant marshal field %q: %v", f.name, err)) - } - combined := encodeFieldVariant(metadata, val) - valValue := makeValueByteArray(ByteArray, unsafe.SliceData(combined), len(combined)) - valValue.repetitionLevel = valueLevels.repetitionLevel - valValue.definitionLevel = valueLevels.definitionLevel - valValue.columnIndex = ^valueCol - columns[valueCol] = append(columns[valueCol], valValue) - // Write null to typed_value columns - writeNullLeaves(columns, typedValueCol, typedValueCol+typedCount, levels) - } else { - // Field not present or null: write null to both - writeNullLeaves(columns, typedValueCol, nextFieldCol, levels) - } - - col = nextFieldCol - } -} - -// encodeFieldVariant encodes metadata and value bytes together for per-field -// fallback storage. Format: 4-byte LE metadata length + metadata + value. -// This ensures nested objects retain their metadata dictionary for decoding. -func encodeFieldVariant(metadata, value []byte) []byte { - mLen := len(metadata) - buf := make([]byte, 4+mLen+len(value)) - binary.LittleEndian.PutUint32(buf, uint32(mLen)) - copy(buf[4:], metadata) - copy(buf[4+mLen:], value) - return buf -} - -// decodeFieldVariant splits per-field variant bytes back into metadata and value. -func decodeFieldVariant(data []byte) (metadata, value []byte, ok bool) { - if len(data) < 4 { - return nil, data, false - } - mLen := int(binary.LittleEndian.Uint32(data)) - if 4+mLen > len(data) { - return nil, data, false - } - return data[4 : 4+mLen], data[4+mLen:], true -} - -// countMatcherColumns returns the total number of leaf columns for a matcher, -// including the value column for each field in a group. -func countMatcherColumns(m *shreddedMatcher) uint16 { - if m.isGroup() { - return countMatcherLeaves(m.fields) - } - return m.leafCount -} - -// countMatcherLeaves sums the leaf columns for a list of field matchers. -// Each field contributes its typed_value leaf count plus one value column. -func countMatcherLeaves(fields []shreddedFieldMatcher) uint16 { - var count uint16 - for _, f := range fields { - count += f.matcher.leafCount + 1 // typed_value leaves + value column - } - return count -} - -func goValueToParquetValue(v any, kind Kind) Value { - switch kind { - case Boolean: - return BooleanValue(v.(bool)) - case Int32: - switch val := v.(type) { - case int8: - return Int32Value(int32(val)) - case int16: - return Int32Value(int32(val)) - case int32: - return Int32Value(val) - case uint8: - return Int32Value(int32(val)) - case uint16: - return Int32Value(int32(val)) - default: - return Int32Value(0) - } - case Int64: - switch val := v.(type) { - case int8: - return Int64Value(int64(val)) - case int16: - return Int64Value(int64(val)) - case int32: - return Int64Value(int64(val)) - case int64: - return Int64Value(val) - case int: - return Int64Value(int64(val)) - case uint8: - return Int64Value(int64(val)) - case uint16: - return Int64Value(int64(val)) - case uint32: - return Int64Value(int64(val)) - default: - return Int64Value(0) - } - case Float: - return FloatValue(v.(float32)) - case Double: - switch val := v.(type) { - case float32: - return DoubleValue(float64(val)) - case float64: - return DoubleValue(val) - default: - return DoubleValue(0) - } - case ByteArray: - switch val := v.(type) { - case string: - return ByteArrayValue([]byte(val)) - case []byte: - return ByteArrayValue(val) - default: - return ByteArrayValue(nil) - } - case FixedLenByteArray: - switch val := v.(type) { - case uuid.UUID: - b := [16]byte(val) - return FixedLenByteArrayValue(b[:]) - case [16]byte: - return FixedLenByteArrayValue(val[:]) - default: - return FixedLenByteArrayValue(nil) - } - default: - return Value{} - } -} - // reconstructFuncOfVariant handles reconstruction of variant columns back into // Go values. Dispatches to unshredded or shredded variant handling. // @@ -641,110 +272,70 @@ func reconstructFuncOfUnshreddedVariant(columnIndex uint16, node Node) (uint16, } } -// reconstructFuncOfShreddedVariant handles the 3-field shredded variant. +// reconstructFuncOfShreddedVariant reconstructs Go values from a shredded +// variant group using the construct_variant algorithm of the Variant +// Shredding specification (see variant_shredded_read.go). // //go:noinline func reconstructFuncOfShreddedVariant(columnIndex uint16, node Node) (uint16, reconstructFunc) { - // Fields are sorted alphabetically: metadata, typed_value, value - var metadataOffset, valueOffset, typedValueOffset uint16 - var typedValueLeafCount uint16 - var typedValueNode Node - - col := uint16(0) - for _, f := range node.Fields() { - n := numLeafColumnsOf(f) - switch f.Name() { - case "metadata": - metadataOffset = col - col += n - case "typed_value": - typedValueOffset = col - typedValueNode = f - typedValueLeafCount = n - col += n - case "value": - valueOffset = col - col += n + group, err := buildShreddedVariantGroup(node, 0, 0, 0) + if err != nil { + numCols := numLeafColumnsOf(node) + return columnIndex + numCols, func(reflect.Value, columnLevels, [][]Value) error { + return err } } - totalCols := int(col) - nextColumnIndex := columnIndex + col - - typedInner := Required(typedValueNode) - extractor := buildShreddedExtractor(typedInner) + nextColumnIndex := columnIndex + uint16(group.numCols) return nextColumnIndex, func(value reflect.Value, levels columnLevels, columns [][]Value) error { - if len(columns) < totalCols { - return fmt.Errorf("shredded variant reconstruction: expected %d columns, got %d", totalCols, len(columns)) + if len(columns) < group.numCols { + return fmt.Errorf("shredded variant reconstruction: expected %d columns, got %d", group.numCols, len(columns)) } - - metaCol := columns[metadataOffset] - valCol := columns[valueOffset] - typedColumns := columns[typedValueOffset : typedValueOffset+typedValueLeafCount] - - if len(metaCol) == 0 { - return fmt.Errorf("variant reconstruction: no values in metadata column %d", columnIndex) + if group.metadataCol < 0 { + return fmt.Errorf("shredded variant reconstruction: missing metadata column") } - metaVal := metaCol[0] - hasValue := len(valCol) > 0 && !valCol[0].IsNull() - hasTypedValue := hasNonNullInColumns(typedColumns) + reader := &variantColumnReader{ + columns: columns, + pos: make([]int, len(columns)), + } - if metaVal.IsNull() && !hasValue && !hasTypedValue { - // All null: missing/null + metaVal, ok := reader.next(group.metadataCol) + if !ok || metaVal.IsNull() || int(metaVal.definitionLevel) < int(levels.definitionLevel) { + // The variant group itself is null for this row. value.Set(reflect.Zero(value.Type())) return nil } - - if hasValue && !hasTypedValue { - // Unshredded value - valBytes := valCol[0].ByteArray() - if len(valBytes) == 0 { - value.Set(reflect.Zero(value.Type())) - return nil - } - metaBytes := metaVal.ByteArray() - if setRawVariantStruct(value, metaBytes, valBytes) { - return nil - } - goVal, err := variant.Unmarshal(metaBytes, valBytes) - if err != nil { - return fmt.Errorf("variant unmarshal: %w", err) - } - return setVariantGoValue(value, goVal) - } - - if !hasValue && hasTypedValue { - // Shredded value: extract from typed columns - goVal := extractor.extract(typedColumns) - return setVariantGoValue(value, goVal) + metaBytes := metaVal.ByteArray() + m, err := variant.DecodeMetadata(metaBytes) + if err != nil { + return fmt.Errorf("variant metadata: %w", err) } - if hasValue && hasTypedValue { - // Partially shredded: typed_value has some fields, value has the rest - typedVal := extractor.extract(typedColumns) - valBytes := valCol[0].ByteArray() - metaBytes := metaVal.ByteArray() - unshreddedVal, err := variant.Unmarshal(metaBytes, valBytes) - if err != nil { - return fmt.Errorf("variant unmarshal: %w", err) + v, present, err := group.read(reader, m, int(levels.definitionLevel), int(levels.repetitionDepth)) + if err != nil { + return err + } + if !present { + // value and typed_value both null at the top level is invalid + // per the spec; read it as variant null (matching + // parquet-java's behavior). + v = variant.Null() + } + + // If the target is a raw variant struct (Metadata/Value []byte + // fields), re-encode the reconstructed value. + if isRawVariantStructTarget(value) { + var b variant.MetadataBuilder + encoded := variant.Encode(&b, v) + _, metadata := b.Build() + if setRawVariantStruct(value, metadata, encoded) { + return nil } - merged := mergeVariantObjects(typedVal, unshreddedVal) - return setVariantGoValue(value, merged) } - value.Set(reflect.Zero(value.Type())) - return nil - } -} - -func hasNonNullInColumns(columns [][]Value) bool { - for _, col := range columns { - if len(col) > 0 && !col[0].IsNull() { - return true - } + return setVariantGoValue(value, v.GoValue()) } - return false } // setRawVariantStruct checks if the target value is a struct with Metadata and @@ -794,186 +385,19 @@ func setVariantGoValue(value reflect.Value, goVal any) error { return nil } -// shreddedExtractor reconstructs Go values from typed_value columns. -// Same three-kind structure as shreddedMatcher: primitive (typ set), -// group (fields set), or unsupported (neither). -type shreddedExtractor struct { - typ Type // non-nil for primitive (leaf column) - fields []shreddedFieldExtractor // non-nil for group (object) - leafCount int -} - -func (e *shreddedExtractor) isPrimitive() bool { return e.typ != nil } -func (e *shreddedExtractor) isGroup() bool { return len(e.fields) > 0 } -func (e *shreddedExtractor) kind() Kind { return e.typ.Kind() } -func (e *shreddedExtractor) isString() bool { - lt := e.typ.LogicalType() - return lt != nil && lt.UTF8 != nil -} -func (e *shreddedExtractor) isUUID() bool { - lt := e.typ.LogicalType() - return lt != nil && lt.UUID != nil -} - -type shreddedFieldExtractor struct { - name string - extractor shreddedExtractor -} - -func buildShreddedExtractor(node Node) shreddedExtractor { - if node.Leaf() { - return shreddedExtractor{ - typ: node.Type(), - leafCount: 1, - } - } - - fields := node.Fields() - extractors := make([]shreddedFieldExtractor, 0, len(fields)) - for _, f := range fields { - subFields := f.Fields() - if len(subFields) == 2 { - typedNode := fieldByName(f, "typed_value") - if typedNode != nil { - extractors = append(extractors, shreddedFieldExtractor{ - name: f.Name(), - extractor: buildShreddedExtractor(Required(typedNode)), - }) - } - } - } - - if len(extractors) > 0 { - leaves := 0 - for _, f := range extractors { - leaves += f.extractor.leafCount + 1 // typed_value leaves + value column - } - return shreddedExtractor{ - fields: extractors, - leafCount: leaves, - } - } - - // Unsupported typed_value structure (e.g., LIST). Return an extractor - // that always returns nil so values are read from the value column. - return shreddedExtractor{ - leafCount: int(numLeafColumnsOf(node)), +// isRawVariantStructTarget reports whether the reconstruction target is a +// struct with Metadata and Value []byte fields (raw variant passthrough). +func isRawVariantStructTarget(value reflect.Value) bool { + t := value.Type() + for t.Kind() == reflect.Ptr { + t = t.Elem() } -} - -func (e *shreddedExtractor) extract(columns [][]Value) any { - if e.isPrimitive() { - if len(columns) == 0 || len(columns[0]) == 0 || columns[0][0].IsNull() { - return nil - } - return parquetValueToGo(columns[0][0], e) - } - if e.isGroup() { - return e.extractObject(columns) - } - return nil -} - -func (e *shreddedExtractor) extractObject(columns [][]Value) any { - result := make(map[string]any) - col := 0 - for _, f := range e.fields { - // Within each field's sub-group, fields are sorted alphabetically: - // typed_value comes before value. - typedStart := col - typedCount := f.extractor.leafCount - valueCol := col + typedCount - nextFieldCol := valueCol + 1 - - hasValue := valueCol < len(columns) && len(columns[valueCol]) > 0 && !columns[valueCol][0].IsNull() - hasTyped := hasNonNullInRange(columns, typedStart, typedStart+typedCount) - - if hasTyped { - val := f.extractor.extract(columns[typedStart : typedStart+typedCount]) - if val != nil { - result[f.name] = val - } - } else if hasValue { - // Field stored as unshredded variant with metadata+value encoded together. - data := columns[valueCol][0].ByteArray() - metaBytes, valBytes, ok := decodeFieldVariant(data) - if ok { - goVal, err := variant.Unmarshal(metaBytes, valBytes) - if err == nil && goVal != nil { - result[f.name] = goVal - } - } - } - - col = nextFieldCol - } - - if len(result) == 0 { - return nil - } - return result -} - -func hasNonNullInRange(columns [][]Value, start, end int) bool { - for i := start; i < end && i < len(columns); i++ { - if len(columns[i]) > 0 && !columns[i][0].IsNull() { - return true - } - } - return false -} - -func parquetValueToGo(v Value, e *shreddedExtractor) any { - switch e.kind() { - case Boolean: - return v.Boolean() - case Int32: - return v.Int32() - case Int64: - return v.Int64() - case Float: - return v.Float() - case Double: - return v.Double() - case ByteArray: - b := v.ByteArray() - if e.isString() { - return string(b) - } - dst := make([]byte, len(b)) - copy(dst, b) - return dst - case FixedLenByteArray: - b := v.ByteArray() - if e.isUUID() && len(b) == 16 { - return uuid.UUID(b) - } - if len(b) == 16 { - var u [16]byte - copy(u[:], b) - return u - } - dst := make([]byte, len(b)) - copy(dst, b) - return dst - default: - return nil - } -} - -// mergeVariantObjects merges two values, preferring typed (shredded) values -// over unshredded ones. Used for partially shredded objects. -func mergeVariantObjects(typed, unshredded any) any { - typedMap, tOk := typed.(map[string]any) - unshreddedMap, uOk := unshredded.(map[string]any) - if tOk && uOk { - result := make(map[string]any, len(typedMap)+len(unshreddedMap)) - maps.Copy(result, unshreddedMap) - maps.Copy(result, typedMap) - return result - } - if tOk { - return typed + if t.Kind() != reflect.Struct { + return false } - return unshredded + byteSliceType := reflect.TypeOf([]byte(nil)) + metaField, hasMetadata := t.FieldByName("Metadata") + valField, hasValue := t.FieldByName("Value") + return hasMetadata && hasValue && + metaField.Type == byteSliceType && valField.Type == byteSliceType } diff --git a/vendor/github.com/parquet-go/parquet-go/schema.go b/vendor/github.com/parquet-go/parquet-go/schema.go index c4d8a8addac..c233cdb8734 100644 --- a/vendor/github.com/parquet-go/parquet-go/schema.go +++ b/vendor/github.com/parquet-go/parquet-go/schema.go @@ -385,14 +385,7 @@ func (s *Schema) Reconstruct(value any, row Row) error { v = v.Elem() } - b := valuesSliceBufferPool.Get( - func() *valuesSliceBuffer { - return &valuesSliceBuffer{ - values: make([][]Value, 0, 64), - } - }, - func(v *valuesSliceBuffer) { v.values = v.values[:0] }, - ) + b := acquireValuesSliceBuffer() state := s.lazyLoadState() funcs := s.lazyLoadFuncs() @@ -432,6 +425,17 @@ func (v *valuesSliceBuffer) release() { var valuesSliceBufferPool memory.Pool[valuesSliceBuffer] +func acquireValuesSliceBuffer() *valuesSliceBuffer { + return valuesSliceBufferPool.Get( + func() *valuesSliceBuffer { + return &valuesSliceBuffer{ + values: make([][]Value, 0, 64), + } + }, + func(v *valuesSliceBuffer) { v.values = v.values[:0] }, + ) +} + // Lookup returns the leaf column at the given path. // // The path is the sequence of column names identifying a leaf column (not @@ -750,7 +754,7 @@ func nodeOf(path []string, t reflect.Type, tags parquetTags, tagReplacements []S } n = FieldID(n, id) default: - throwUnknownTag(t, "map", option) + throwUnknownTag(t, "map", joinOptionArgs(option, args)) } }) @@ -788,6 +792,17 @@ func splitOptionArgs(s string) (option, args string) { return } +// joinOptionArgs is the inverse of splitOptionArgs for the purpose of +// rendering a tag back to the user. splitOptionArgs returns args="()" as +// a sentinel meaning "no parens in the source"; we drop it here so plain +// options don't render as "foo()" in panic messages. +func joinOptionArgs(option, args string) string { + if args == "()" { + return option + } + return option + args +} + func parseDecimalArgs(args string) (scale, precision int, err error) { if !strings.HasPrefix(args, "(") || !strings.HasSuffix(args, ")") { return 0, 0, fmt.Errorf("malformed decimal args: %s", args) @@ -1069,7 +1084,15 @@ func makeNodeOf(path []string, t reflect.Type, name string, tags parquetTags, ta if t == reflect.TypeFor[json.RawMessage]() { throwInvalidTag(t, name, option) } - element := makeNodeOf(append(path, "list", "element"), t.Elem(), t.Name(), tags.getListElementNodeTags(), tagReplacements) + elementTags := tags.getListElementNodeTags() + if elem := t.Elem(); elem.Kind() == reflect.Slice && elem.Elem().Kind() != reflect.Uint8 && !strings.Contains(elementTags.parquet, "list") { + // A nested slice under a list is itself a list: recurse the + // list option implicitly so any nesting depth is expressible + // with a single `list` tag on the field. An explicit + // parquet-element tag still takes precedence. + elementTags.parquet += ",list" + } + element := makeNodeOf(append(path, "list", "element"), t.Elem(), t.Name(), elementTags, tagReplacements) setNode(element) setList() default: @@ -1327,6 +1350,8 @@ func makeNodeOf(path []string, t reflect.Type, name string, tags parquetTags, ta throwInvalidTag(t, name, option+args) } setNode(Geography(crs, alg)) + default: + throwUnknownTag(t, name, joinOptionArgs(option, args)) } }) } @@ -1390,6 +1415,7 @@ func forEachTagOption(tags []string, do func(option, args string)) { option, tag = split(tag) var args string option, args = splitOptionArgs(option) + option = strings.TrimSpace(option) do(option, args) } } diff --git a/vendor/github.com/parquet-go/parquet-go/sorting.go b/vendor/github.com/parquet-go/parquet-go/sorting.go index cdb5974cc99..c39b02f8e8f 100644 --- a/vendor/github.com/parquet-go/parquet-go/sorting.go +++ b/vendor/github.com/parquet-go/parquet-go/sorting.go @@ -110,15 +110,12 @@ func (w *SortingWriter[T]) Close() error { return err } - rows := m.Rows() - defer rows.Close() - - reader := RowReader(rows) - if w.sorting.DropDuplicatedRows { - reader = DedupeRowReader(rows, w.rowbuf.compare) - } - - if _, err := CopyRows(w.output, reader); err != nil { + // Writing the merged row group (rather than copying its rows) lets the + // writer use its chunk-level fast paths when the sorted chunks do not + // overlap: verbatim column chunk copies and column-oriented packing toward + // MaxRowsPerRowGroup. Overlapping chunks fall back to the row-oriented heap + // merge, and the merge itself applies DropDuplicatedRows when configured. + if _, err := w.output.WriteRowGroup(m); err != nil { return err } diff --git a/vendor/github.com/parquet-go/parquet-go/type.go b/vendor/github.com/parquet-go/parquet-go/type.go index c8e27ec64e5..15158022fd6 100644 --- a/vendor/github.com/parquet-go/parquet-go/type.go +++ b/vendor/github.com/parquet-go/parquet-go/type.go @@ -242,10 +242,36 @@ var ( NullType Type = &nullType{} ) +// logicalTypeOf returns the annotation carried by lt if it is of type T. A nil +// lt, or one carrying a different annotation, yields ok=false. +func logicalTypeOf[T format.LogicalTypeValue](lt *format.LogicalType) (T, bool) { + if lt == nil { + var zero T + return zero, false + } + v, ok := lt.Value.(T) + return v, ok +} + +// logicalTypeIs reports whether lt carries a T annotation. +func logicalTypeIs[T format.LogicalTypeValue](lt *format.LogicalType) bool { + _, ok := logicalTypeOf[T](lt) + return ok +} + +// logicalTypeValueOf returns the annotation carried by lt, or nil when lt is +// nil. It is the nil-safe way to reach lt.Value for a type switch. +func logicalTypeValueOf(lt *format.LogicalType) format.LogicalTypeValue { + if lt == nil { + return nil + } + return lt.Value +} + // In the current parquet version supported by this library, only type-defined // orders are supported. var typeDefinedColumnOrder = format.ColumnOrder{ - TypeOrder: new(format.TypeDefinedOrder), + Value: new(format.TypeDefinedOrder), } var physicalTypes = [...]format.Type{ diff --git a/vendor/github.com/parquet-go/parquet-go/type_bson.go b/vendor/github.com/parquet-go/parquet-go/type_bson.go index 687e5d1f7d0..5303f0af7c7 100644 --- a/vendor/github.com/parquet-go/parquet-go/type_bson.go +++ b/vendor/github.com/parquet-go/parquet-go/type_bson.go @@ -14,7 +14,7 @@ import ( func BSON() Node { return Leaf(&bsonType{}) } var bsonLogicalType = format.LogicalType{ - Bson: new(format.BsonType), + Value: new(format.BsonType), } type bsonType format.BsonType diff --git a/vendor/github.com/parquet-go/parquet-go/type_date.go b/vendor/github.com/parquet-go/parquet-go/type_date.go index e408be207db..42b7862ede9 100644 --- a/vendor/github.com/parquet-go/parquet-go/type_date.go +++ b/vendor/github.com/parquet-go/parquet-go/type_date.go @@ -15,7 +15,7 @@ import ( func Date() Node { return Leaf(&dateType{}) } var dateLogicalType = format.LogicalType{ - Date: new(format.DateType), + Value: new(format.DateType), } type dateType format.DateType diff --git a/vendor/github.com/parquet-go/parquet-go/type_decimal.go b/vendor/github.com/parquet-go/parquet-go/type_decimal.go index a3b71ac7bbc..b7882537a16 100644 --- a/vendor/github.com/parquet-go/parquet-go/type_decimal.go +++ b/vendor/github.com/parquet-go/parquet-go/type_decimal.go @@ -49,7 +49,7 @@ type decimalType struct { func (t *decimalType) String() string { return t.decimal.String() } func (t *decimalType) LogicalType() *format.LogicalType { - return &format.LogicalType{Decimal: &t.decimal} + return &format.LogicalType{Value: &t.decimal} } func (t *decimalType) ConvertedType() *deprecated.ConvertedType { @@ -77,6 +77,14 @@ func (t *decimalType) AssignValue(dst reflect.Value, src Value) error { if t.Type.Kind() != ByteArray && t.Type.Kind() != FixedLenByteArray { return nil } + switch dst.Kind() { + case reflect.Slice, reflect.Array, reflect.String: + // Destinations like []byte, [N]byte, or string receive the raw + // big-endian two's-complement representation of the decimal + // value, as they did when decimalType inherited AssignValue + // from its underlying byte array type. + return t.Type.AssignValue(dst, src) + } data := src.ByteArray() val := new(big.Int) if len(data) > 0 && data[0]&0x80 != 0 { @@ -98,7 +106,13 @@ func (t *decimalType) AssignValue(dst reflect.Value, src Value) error { scaleFactor := new(big.Float).SetPrec(prec) scaleFactor.SetInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(t.decimal.Scale)), nil)) f.Quo(f, scaleFactor) - dst.Set(reflect.ValueOf(f)) + switch dst.Kind() { + case reflect.Float32, reflect.Float64: + v, _ := f.Float64() + dst.SetFloat(v) + default: + dst.Set(reflect.ValueOf(f)) + } } return nil } diff --git a/vendor/github.com/parquet-go/parquet-go/type_enum.go b/vendor/github.com/parquet-go/parquet-go/type_enum.go index d47c7bbb2fe..e2c4eedc7c7 100644 --- a/vendor/github.com/parquet-go/parquet-go/type_enum.go +++ b/vendor/github.com/parquet-go/parquet-go/type_enum.go @@ -14,7 +14,7 @@ import ( func Enum() Node { return Leaf(&enumType{}) } var enumLogicalType = format.LogicalType{ - Enum: new(format.EnumType), + Value: new(format.EnumType), } type enumType format.EnumType diff --git a/vendor/github.com/parquet-go/parquet-go/type_geography.go b/vendor/github.com/parquet-go/parquet-go/type_geography.go index f39b0418e91..74f6a29ada3 100644 --- a/vendor/github.com/parquet-go/parquet-go/type_geography.go +++ b/vendor/github.com/parquet-go/parquet-go/type_geography.go @@ -34,18 +34,18 @@ func (t *geographyType) ColumnOrder() *format.ColumnOrder { return byteArrayType func (t *geographyType) PhysicalType() *format.Type { return byteArrayType{}.PhysicalType() } func (t *geographyType) LogicalType() *format.LogicalType { - f := &format.LogicalType{Geography: &format.GeographyType{ + g := format.GeographyType{ CRS: t.CRS, Algorithm: t.Algorithm, - }} - if t.CRS == "" { - f.Geography.CRS = format.GeometryDefaultCRS + } + if g.CRS == "" { + g.CRS = format.GeometryDefaultCRS } if t.Algorithm != 0 { - f.Geography.Algorithm = t.Algorithm + g.Algorithm = t.Algorithm } - return f + return &format.LogicalType{Value: &g} } func (t *geographyType) ConvertedType() *deprecated.ConvertedType { @@ -120,15 +120,18 @@ func (t *geographyType) AssignValue(dst reflect.Value, src Value) error { func (t *geographyType) ConvertValue(val Value, typ Type) (Value, error) { switch src := typ.(type) { case *geographyType: - if src.LogicalType().Geography.CRS != t.CRS { + srcGeography, _ := logicalTypeOf[*format.GeographyType](src.LogicalType()) + dstGeography, _ := logicalTypeOf[*format.GeographyType](t.LogicalType()) + if srcGeography.CRS != t.CRS { return Value{}, errors.New("cannot convert between geography types with different CRS") } - if src.LogicalType().Geography.Algorithm != t.LogicalType().Geography.Algorithm { + if srcGeography.Algorithm != dstGeography.Algorithm { return Value{}, errors.New("cannot convert between geography types with different Algorithm") } return val, nil case *geometryType: - if src.LogicalType().Geometry.CRS != t.CRS { + srcGeometry, _ := logicalTypeOf[*format.GeometryType](src.LogicalType()) + if srcGeometry.CRS != t.CRS { return Value{}, errors.New("cannot convert between geography and geometry types with different CRS") } return val, nil diff --git a/vendor/github.com/parquet-go/parquet-go/type_geometry.go b/vendor/github.com/parquet-go/parquet-go/type_geometry.go index 54f53ef4fcb..57bf2528612 100644 --- a/vendor/github.com/parquet-go/parquet-go/type_geometry.go +++ b/vendor/github.com/parquet-go/parquet-go/type_geometry.go @@ -37,9 +37,9 @@ func (t *geometryType) PhysicalType() *format.Type { return byteArrayType{}.Phys func (t *geometryType) LogicalType() *format.LogicalType { if t.CRS == "" { - return &format.LogicalType{Geometry: &geometryDefaultCRSLogicType} + return &format.LogicalType{Value: &geometryDefaultCRSLogicType} } - return &format.LogicalType{Geometry: (*format.GeometryType)(t)} + return &format.LogicalType{Value: (*format.GeometryType)(t)} } func (t *geometryType) ConvertedType() *deprecated.ConvertedType { @@ -114,12 +114,14 @@ func (t *geometryType) AssignValue(dst reflect.Value, src Value) error { func (t *geometryType) ConvertValue(val Value, typ Type) (Value, error) { switch src := typ.(type) { case *geometryType: - if src.LogicalType().Geometry.CRS != t.CRS { + srcGeometry, _ := logicalTypeOf[*format.GeometryType](src.LogicalType()) + if srcGeometry.CRS != t.CRS { return Value{}, errors.New("cannot convert between geometry types with different CRS") } return val, nil case *geographyType: - if src.LogicalType().Geography.CRS != t.CRS { + srcGeography, _ := logicalTypeOf[*format.GeographyType](src.LogicalType()) + if srcGeography.CRS != t.CRS { return Value{}, errors.New("cannot convert between geography and geometry types with different CRS") } return val, nil diff --git a/vendor/github.com/parquet-go/parquet-go/type_int32.go b/vendor/github.com/parquet-go/parquet-go/type_int32.go index bf9200b3622..c7a138127e3 100644 --- a/vendor/github.com/parquet-go/parquet-go/type_int32.go +++ b/vendor/github.com/parquet-go/parquet-go/type_int32.go @@ -10,7 +10,7 @@ import ( type int32Type struct{} -var int32LogicalType = format.LogicalType{Integer: &format.IntType{ +var int32LogicalType = format.LogicalType{Value: &format.IntType{ BitWidth: 32, IsSigned: true, }} diff --git a/vendor/github.com/parquet-go/parquet-go/type_int64.go b/vendor/github.com/parquet-go/parquet-go/type_int64.go index db1287b6945..21c4fa7d3b3 100644 --- a/vendor/github.com/parquet-go/parquet-go/type_int64.go +++ b/vendor/github.com/parquet-go/parquet-go/type_int64.go @@ -10,7 +10,7 @@ import ( type int64Type struct{} -var int64LogicalType = format.LogicalType{Integer: &format.IntType{ +var int64LogicalType = format.LogicalType{Value: &format.IntType{ BitWidth: 64, IsSigned: true, }} diff --git a/vendor/github.com/parquet-go/parquet-go/type_int_logical.go b/vendor/github.com/parquet-go/parquet-go/type_int_logical.go index 8a2f7ed7618..94627fb717b 100644 --- a/vendor/github.com/parquet-go/parquet-go/type_int_logical.go +++ b/vendor/github.com/parquet-go/parquet-go/type_int_logical.go @@ -56,17 +56,41 @@ var unsignedIntTypes = [...]intType{ } var signedLogicalIntTypes = [...]format.LogicalType{ - {Integer: (*format.IntType)(&signedIntTypes[0])}, - {Integer: (*format.IntType)(&signedIntTypes[1])}, - {Integer: (*format.IntType)(&signedIntTypes[2])}, - {Integer: (*format.IntType)(&signedIntTypes[3])}, + {Value: (*format.IntType)(&signedIntTypes[0])}, + {Value: (*format.IntType)(&signedIntTypes[1])}, + {Value: (*format.IntType)(&signedIntTypes[2])}, + {Value: (*format.IntType)(&signedIntTypes[3])}, } var unsignedLogicalIntTypes = [...]format.LogicalType{ - {Integer: (*format.IntType)(&unsignedIntTypes[0])}, - {Integer: (*format.IntType)(&unsignedIntTypes[1])}, - {Integer: (*format.IntType)(&unsignedIntTypes[2])}, - {Integer: (*format.IntType)(&unsignedIntTypes[3])}, + {Value: (*format.IntType)(&unsignedIntTypes[0])}, + {Value: (*format.IntType)(&unsignedIntTypes[1])}, + {Value: (*format.IntType)(&unsignedIntTypes[2])}, + {Value: (*format.IntType)(&unsignedIntTypes[3])}, +} + +// canonicalIntType maps a decoded IntType onto the instance this package +// already declares for it. Returning the shared instance rather than a pointer +// into the file metadata lets LogicalType find it by identity, instead of +// allocating a new format.LogicalType on every call. +func canonicalIntType(t *format.IntType) *intType { + table := &unsignedIntTypes + if t.IsSigned { + table = &signedIntTypes + } + switch t.BitWidth { + case 8: + return &table[0] + case 16: + return &table[1] + case 32: + return &table[2] + case 64: + return &table[3] + default: + // Not a bit width the spec allows; keep the value the file carried. + return (*intType)(t) + } } type intType format.IntType @@ -143,7 +167,7 @@ func (t *intType) LogicalType() *format.LogicalType { case &unsignedIntTypes[3]: return &unsignedLogicalIntTypes[3] default: - return &format.LogicalType{Integer: (*format.IntType)(t)} + return &format.LogicalType{Value: (*format.IntType)(t)} } } diff --git a/vendor/github.com/parquet-go/parquet-go/type_json.go b/vendor/github.com/parquet-go/parquet-go/type_json.go index abf452f7fb9..d6d41630801 100644 --- a/vendor/github.com/parquet-go/parquet-go/type_json.go +++ b/vendor/github.com/parquet-go/parquet-go/type_json.go @@ -15,7 +15,7 @@ import ( func JSON() Node { return Leaf(&jsonType{}) } var jsonLogicalType = format.LogicalType{ - Json: new(format.JsonType), + Value: new(format.JsonType), } type jsonType format.JsonType diff --git a/vendor/github.com/parquet-go/parquet-go/type_list.go b/vendor/github.com/parquet-go/parquet-go/type_list.go index 3f17fde4922..ccfd413df95 100644 --- a/vendor/github.com/parquet-go/parquet-go/type_list.go +++ b/vendor/github.com/parquet-go/parquet-go/type_list.go @@ -21,7 +21,7 @@ func (listNode) Type() Type { return &listType{} } type listType format.ListType -var listLogicalType = format.LogicalType{List: new(format.ListType)} +var listLogicalType = format.LogicalType{Value: new(format.ListType)} func (t *listType) String() string { return (*format.ListType)(t).String() } diff --git a/vendor/github.com/parquet-go/parquet-go/type_map.go b/vendor/github.com/parquet-go/parquet-go/type_map.go index 66835cda12f..f1d96d3e09e 100644 --- a/vendor/github.com/parquet-go/parquet-go/type_map.go +++ b/vendor/github.com/parquet-go/parquet-go/type_map.go @@ -26,7 +26,7 @@ func (mapNode) Type() Type { return &mapType{} } type mapType format.MapType -var mapLogicalType = format.LogicalType{Map: new(format.MapType)} +var mapLogicalType = format.LogicalType{Value: new(format.MapType)} func (t *mapType) String() string { return (*format.MapType)(t).String() } diff --git a/vendor/github.com/parquet-go/parquet-go/type_null.go b/vendor/github.com/parquet-go/parquet-go/type_null.go index 3a3318226bc..aa9b66950f5 100644 --- a/vendor/github.com/parquet-go/parquet-go/type_null.go +++ b/vendor/github.com/parquet-go/parquet-go/type_null.go @@ -10,7 +10,7 @@ import ( type nullType format.NullType -var nullLogicalType = format.LogicalType{Unknown: new(format.NullType)} +var nullLogicalType = format.LogicalType{Value: new(format.NullType)} func (t *nullType) String() string { return (*format.NullType)(t).String() } diff --git a/vendor/github.com/parquet-go/parquet-go/type_string.go b/vendor/github.com/parquet-go/parquet-go/type_string.go index cdd9afb7873..89bc6ad82d5 100644 --- a/vendor/github.com/parquet-go/parquet-go/type_string.go +++ b/vendor/github.com/parquet-go/parquet-go/type_string.go @@ -15,7 +15,7 @@ import ( func String() Node { return Leaf(&stringType{}) } var stringLogicalType = format.LogicalType{ - UTF8: new(format.StringType), + Value: new(format.StringType), } type stringType format.StringType @@ -92,7 +92,7 @@ func (t *stringType) ConvertValue(val Value, typ Type) (Value, error) { return convertDateToString(val) case *timeType: tz := t2.tz() - if t2.Unit.Micros != nil { + if isMicros(t2.Unit) { return convertTimeMicrosToString(val, tz) } else { return convertTimeMillisToString(val, tz) diff --git a/vendor/github.com/parquet-go/parquet-go/type_time.go b/vendor/github.com/parquet-go/parquet-go/type_time.go index 327ba8bf0ef..3eb5f8b13c1 100644 --- a/vendor/github.com/parquet-go/parquet-go/type_time.go +++ b/vendor/github.com/parquet-go/parquet-go/type_time.go @@ -24,25 +24,31 @@ var ( Nanosecond TimeUnit = &nanosecond{} ) +// The TimeUnit union holds exactly one of these; testing which one is common +// enough in this package to be worth naming. +func isMillis(u format.TimeUnit) bool { _, ok := u.Value.(*format.MilliSeconds); return ok } +func isMicros(u format.TimeUnit) bool { _, ok := u.Value.(*format.MicroSeconds); return ok } +func isNanos(u format.TimeUnit) bool { _, ok := u.Value.(*format.NanoSeconds); return ok } + type millisecond format.MilliSeconds func (u *millisecond) Duration() time.Duration { return time.Millisecond } func (u *millisecond) TimeUnit() format.TimeUnit { - return format.TimeUnit{Millis: (*format.MilliSeconds)(u)} + return format.TimeUnit{Value: (*format.MilliSeconds)(u)} } type microsecond format.MicroSeconds func (u *microsecond) Duration() time.Duration { return time.Microsecond } func (u *microsecond) TimeUnit() format.TimeUnit { - return format.TimeUnit{Micros: (*format.MicroSeconds)(u)} + return format.TimeUnit{Value: (*format.MicroSeconds)(u)} } type nanosecond format.NanoSeconds func (u *nanosecond) Duration() time.Duration { return time.Nanosecond } func (u *nanosecond) TimeUnit() format.TimeUnit { - return format.TimeUnit{Nanos: (*format.NanoSeconds)(u)} + return format.TimeUnit{Value: (*format.NanoSeconds)(u)} } // Time constructs a leaf node of TIME logical type. @@ -61,21 +67,21 @@ func TimeAdjusted(unit TimeUnit, isAdjustedToUTC bool) Node { // Use pre-allocated instances for common cases timeUnit := unit.TimeUnit() if isAdjustedToUTC { - switch { - case timeUnit.Millis != nil: + switch timeUnit.Value.(type) { + case *format.MilliSeconds: return Leaf(&timeMilliAdjustedToUTC) - case timeUnit.Micros != nil: + case *format.MicroSeconds: return Leaf(&timeMicroAdjustedToUTC) - case timeUnit.Nanos != nil: + case *format.NanoSeconds: return Leaf(&timeNanoAdjustedToUTC) } } else { - switch { - case timeUnit.Millis != nil: + switch timeUnit.Value.(type) { + case *format.MilliSeconds: return Leaf(&timeMilliNotAdjustedToUTC) - case timeUnit.Micros != nil: + case *format.MicroSeconds: return Leaf(&timeMicroNotAdjustedToUTC) - case timeUnit.Nanos != nil: + case *format.NanoSeconds: return Leaf(&timeNanoNotAdjustedToUTC) } } @@ -85,56 +91,82 @@ func TimeAdjusted(unit TimeUnit, isAdjustedToUTC bool) Node { var timeMilliAdjustedToUTC = timeType{ IsAdjustedToUTC: true, - Unit: format.TimeUnit{Millis: new(format.MilliSeconds)}, + Unit: format.TimeUnit{Value: new(format.MilliSeconds)}, } var timeMicroAdjustedToUTC = timeType{ IsAdjustedToUTC: true, - Unit: format.TimeUnit{Micros: new(format.MicroSeconds)}, + Unit: format.TimeUnit{Value: new(format.MicroSeconds)}, } var timeNanoAdjustedToUTC = timeType{ IsAdjustedToUTC: true, - Unit: format.TimeUnit{Nanos: new(format.NanoSeconds)}, + Unit: format.TimeUnit{Value: new(format.NanoSeconds)}, } var timeMilliNotAdjustedToUTC = timeType{ IsAdjustedToUTC: false, - Unit: format.TimeUnit{Millis: new(format.MilliSeconds)}, + Unit: format.TimeUnit{Value: new(format.MilliSeconds)}, } var timeMicroNotAdjustedToUTC = timeType{ IsAdjustedToUTC: false, - Unit: format.TimeUnit{Micros: new(format.MicroSeconds)}, + Unit: format.TimeUnit{Value: new(format.MicroSeconds)}, } var timeNanoNotAdjustedToUTC = timeType{ IsAdjustedToUTC: false, - Unit: format.TimeUnit{Nanos: new(format.NanoSeconds)}, + Unit: format.TimeUnit{Value: new(format.NanoSeconds)}, } var timeMilliAdjustedToUTCLogicalType = format.LogicalType{ - Time: (*format.TimeType)(&timeMilliAdjustedToUTC), + Value: (*format.TimeType)(&timeMilliAdjustedToUTC), } var timeMicroAdjustedToUTCLogicalType = format.LogicalType{ - Time: (*format.TimeType)(&timeMicroAdjustedToUTC), + Value: (*format.TimeType)(&timeMicroAdjustedToUTC), } var timeNanoAdjustedToUTCLogicalType = format.LogicalType{ - Time: (*format.TimeType)(&timeNanoAdjustedToUTC), + Value: (*format.TimeType)(&timeNanoAdjustedToUTC), } var timeMilliNotAdjustedToUTCLogicalType = format.LogicalType{ - Time: (*format.TimeType)(&timeMilliNotAdjustedToUTC), + Value: (*format.TimeType)(&timeMilliNotAdjustedToUTC), } var timeMicroNotAdjustedToUTCLogicalType = format.LogicalType{ - Time: (*format.TimeType)(&timeMicroNotAdjustedToUTC), + Value: (*format.TimeType)(&timeMicroNotAdjustedToUTC), } var timeNanoNotAdjustedToUTCLogicalType = format.LogicalType{ - Time: (*format.TimeType)(&timeNanoNotAdjustedToUTC), + Value: (*format.TimeType)(&timeNanoNotAdjustedToUTC), +} + +// canonicalTimeType maps a decoded TimeType onto the instance this package +// already declares for it. See canonicalIntType. +func canonicalTimeType(t *format.TimeType) *timeType { + if t.IsAdjustedToUTC { + switch t.Unit.Value.(type) { + case *format.MilliSeconds: + return &timeMilliAdjustedToUTC + case *format.MicroSeconds: + return &timeMicroAdjustedToUTC + case *format.NanoSeconds: + return &timeNanoAdjustedToUTC + } + } else { + switch t.Unit.Value.(type) { + case *format.MilliSeconds: + return &timeMilliNotAdjustedToUTC + case *format.MicroSeconds: + return &timeMicroNotAdjustedToUTC + case *format.NanoSeconds: + return &timeNanoNotAdjustedToUTC + } + } + // No unit, or one we do not know; keep the value the file carried. + return (*timeType)(t) } type timeType format.TimeType @@ -155,9 +187,9 @@ func (t *timeType) baseType() Type { } } -func (t *timeType) useInt32() bool { return t.Unit.Millis != nil } +func (t *timeType) useInt32() bool { return isMillis(t.Unit) } -func (t *timeType) useInt64() bool { return t.Unit.Micros != nil } +func (t *timeType) useInt64() bool { return isMicros(t.Unit) } func (t *timeType) String() string { return (*format.TimeType)(t).String() } @@ -190,7 +222,7 @@ func (t *timeType) LogicalType() *format.LogicalType { case &timeNanoNotAdjustedToUTC: return &timeNanoNotAdjustedToUTCLogicalType default: - return &format.LogicalType{Time: (*format.TimeType)(t)} + return &format.LogicalType{Value: (*format.TimeType)(t)} } } @@ -241,17 +273,7 @@ func (t *timeType) AssignValue(dst reflect.Value, src Value) error { // Handle time.Duration specially to convert from the stored time unit to nanoseconds if dst.Type() == reflect.TypeFor[time.Duration]() { v := src.int64() - var nanos int64 - switch { - case t.Unit.Millis != nil: - nanos = v * int64(time.Millisecond) - case t.Unit.Micros != nil: - nanos = v * int64(time.Microsecond) - case t.Unit.Nanos != nil: - nanos = v - default: - nanos = v - } + nanos := v * int64(timeUnitDuration(t.Unit)) dst.SetInt(nanos) return nil } @@ -262,14 +284,14 @@ func (t *timeType) ConvertValue(val Value, typ Type) (Value, error) { switch src := typ.(type) { case *stringType: tz := t.tz() - if t.Unit.Micros != nil { + if isMicros(t.Unit) { return convertStringToTimeMicros(val, tz) } else { return convertStringToTimeMillis(val, tz) } case *timestampType: tz := t.tz() - if t.Unit.Micros != nil { + if isMicros(t.Unit) { return convertTimestampToTimeMicros(val, src.Unit, src.tz(), tz) } else { return convertTimestampToTimeMillis(val, src.Unit, src.tz(), tz) diff --git a/vendor/github.com/parquet-go/parquet-go/type_timestamp.go b/vendor/github.com/parquet-go/parquet-go/type_timestamp.go index 08d58633a1f..04fa6265285 100644 --- a/vendor/github.com/parquet-go/parquet-go/type_timestamp.go +++ b/vendor/github.com/parquet-go/parquet-go/type_timestamp.go @@ -25,21 +25,21 @@ func TimestampAdjusted(unit TimeUnit, isAdjustedToUTC bool) Node { // Use pre-allocated instances for common cases timeUnit := unit.TimeUnit() if isAdjustedToUTC { - switch { - case timeUnit.Millis != nil: + switch timeUnit.Value.(type) { + case *format.MilliSeconds: return Leaf(×tampMilliAdjustedToUTC) - case timeUnit.Micros != nil: + case *format.MicroSeconds: return Leaf(×tampMicroAdjustedToUTC) - case timeUnit.Nanos != nil: + case *format.NanoSeconds: return Leaf(×tampNanoAdjustedToUTC) } } else { - switch { - case timeUnit.Millis != nil: + switch timeUnit.Value.(type) { + case *format.MilliSeconds: return Leaf(×tampMilliNotAdjustedToUTC) - case timeUnit.Micros != nil: + case *format.MicroSeconds: return Leaf(×tampMicroNotAdjustedToUTC) - case timeUnit.Nanos != nil: + case *format.NanoSeconds: return Leaf(×tampNanoNotAdjustedToUTC) } } @@ -49,56 +49,82 @@ func TimestampAdjusted(unit TimeUnit, isAdjustedToUTC bool) Node { var timestampMilliAdjustedToUTC = timestampType{ IsAdjustedToUTC: true, - Unit: format.TimeUnit{Millis: new(format.MilliSeconds)}, + Unit: format.TimeUnit{Value: new(format.MilliSeconds)}, } var timestampMicroAdjustedToUTC = timestampType{ IsAdjustedToUTC: true, - Unit: format.TimeUnit{Micros: new(format.MicroSeconds)}, + Unit: format.TimeUnit{Value: new(format.MicroSeconds)}, } var timestampNanoAdjustedToUTC = timestampType{ IsAdjustedToUTC: true, - Unit: format.TimeUnit{Nanos: new(format.NanoSeconds)}, + Unit: format.TimeUnit{Value: new(format.NanoSeconds)}, } var timestampMilliNotAdjustedToUTC = timestampType{ IsAdjustedToUTC: false, - Unit: format.TimeUnit{Millis: new(format.MilliSeconds)}, + Unit: format.TimeUnit{Value: new(format.MilliSeconds)}, } var timestampMicroNotAdjustedToUTC = timestampType{ IsAdjustedToUTC: false, - Unit: format.TimeUnit{Micros: new(format.MicroSeconds)}, + Unit: format.TimeUnit{Value: new(format.MicroSeconds)}, } var timestampNanoNotAdjustedToUTC = timestampType{ IsAdjustedToUTC: false, - Unit: format.TimeUnit{Nanos: new(format.NanoSeconds)}, + Unit: format.TimeUnit{Value: new(format.NanoSeconds)}, } var timestampMilliAdjustedToUTCLogicalType = format.LogicalType{ - Timestamp: (*format.TimestampType)(×tampMilliAdjustedToUTC), + Value: (*format.TimestampType)(×tampMilliAdjustedToUTC), } var timestampMicroAdjustedToUTCLogicalType = format.LogicalType{ - Timestamp: (*format.TimestampType)(×tampMicroAdjustedToUTC), + Value: (*format.TimestampType)(×tampMicroAdjustedToUTC), } var timestampNanoAdjustedToUTCLogicalType = format.LogicalType{ - Timestamp: (*format.TimestampType)(×tampNanoAdjustedToUTC), + Value: (*format.TimestampType)(×tampNanoAdjustedToUTC), } var timestampMilliNotAdjustedToUTCLogicalType = format.LogicalType{ - Timestamp: (*format.TimestampType)(×tampMilliNotAdjustedToUTC), + Value: (*format.TimestampType)(×tampMilliNotAdjustedToUTC), } var timestampMicroNotAdjustedToUTCLogicalType = format.LogicalType{ - Timestamp: (*format.TimestampType)(×tampMicroNotAdjustedToUTC), + Value: (*format.TimestampType)(×tampMicroNotAdjustedToUTC), } var timestampNanoNotAdjustedToUTCLogicalType = format.LogicalType{ - Timestamp: (*format.TimestampType)(×tampNanoNotAdjustedToUTC), + Value: (*format.TimestampType)(×tampNanoNotAdjustedToUTC), +} + +// canonicalTimestampType maps a decoded TimestampType onto the instance this +// package already declares for it. See canonicalIntType. +func canonicalTimestampType(t *format.TimestampType) *timestampType { + if t.IsAdjustedToUTC { + switch t.Unit.Value.(type) { + case *format.MilliSeconds: + return ×tampMilliAdjustedToUTC + case *format.MicroSeconds: + return ×tampMicroAdjustedToUTC + case *format.NanoSeconds: + return ×tampNanoAdjustedToUTC + } + } else { + switch t.Unit.Value.(type) { + case *format.MilliSeconds: + return ×tampMilliNotAdjustedToUTC + case *format.MicroSeconds: + return ×tampMicroNotAdjustedToUTC + case *format.NanoSeconds: + return ×tampNanoNotAdjustedToUTC + } + } + // No unit, or one we do not know; keep the value the file carried. + return (*timestampType)(t) } type timestampType format.TimestampType @@ -142,15 +168,15 @@ func (t *timestampType) LogicalType() *format.LogicalType { case ×tampNanoNotAdjustedToUTC: return ×tampNanoNotAdjustedToUTCLogicalType default: - return &format.LogicalType{Timestamp: (*format.TimestampType)(t)} + return &format.LogicalType{Value: (*format.TimestampType)(t)} } } func (t *timestampType) ConvertedType() *deprecated.ConvertedType { - switch { - case t.Unit.Millis != nil: + switch t.Unit.Value.(type) { + case *format.MilliSeconds: return &convertedTypes[deprecated.TimestampMillis] - case t.Unit.Micros != nil: + case *format.MicroSeconds: return &convertedTypes[deprecated.TimestampMicros] default: return nil @@ -200,17 +226,11 @@ func (t *timestampType) AssignValue(dst reflect.Value, src Value) error { unit := Nanosecond.TimeUnit() lt := t.LogicalType() - if lt != nil && lt.Timestamp != nil { - unit = lt.Timestamp.Unit + if ts, ok := logicalTypeOf[*format.TimestampType](lt); ok { + unit = ts.Unit } - nanos := src.int64() - switch { - case unit.Millis != nil: - nanos = nanos * 1e6 - case unit.Micros != nil: - nanos = nanos * 1e3 - } + nanos := src.int64() * int64(timeUnitDuration(unit)) val := time.Unix(0, nanos).UTC() dst.Set(reflect.ValueOf(val)) @@ -225,17 +245,11 @@ func (t *timestampType) AssignValue(dst reflect.Value, src Value) error { unit := Nanosecond.TimeUnit() lt := t.LogicalType() - if lt != nil && lt.Timestamp != nil { - unit = lt.Timestamp.Unit + if ts, ok := logicalTypeOf[*format.TimestampType](lt); ok { + unit = ts.Unit } - nanos := src.int64() - switch { - case unit.Millis != nil: - nanos = nanos * 1e6 - case unit.Micros != nil: - nanos = nanos * 1e3 - } + nanos := src.int64() * int64(timeUnitDuration(unit)) val := time.Unix(0, nanos).UTC() ptr := &val diff --git a/vendor/github.com/parquet-go/parquet-go/type_uuid.go b/vendor/github.com/parquet-go/parquet-go/type_uuid.go index 1cf2a4f94fc..c480e63bf7f 100644 --- a/vendor/github.com/parquet-go/parquet-go/type_uuid.go +++ b/vendor/github.com/parquet-go/parquet-go/type_uuid.go @@ -14,7 +14,7 @@ import ( func UUID() Node { return Leaf(&uuidType{}) } var uuidLogicaType = format.LogicalType{ - UUID: new(format.UUIDType), + Value: new(format.UUIDType), } type uuidType format.UUIDType diff --git a/vendor/github.com/parquet-go/parquet-go/type_variant.go b/vendor/github.com/parquet-go/parquet-go/type_variant.go index 8d692e0e0c5..ecd93ad1df5 100644 --- a/vendor/github.com/parquet-go/parquet-go/type_variant.go +++ b/vendor/github.com/parquet-go/parquet-go/type_variant.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "reflect" + "slices" "strings" "github.com/parquet-go/parquet-go/deprecated" @@ -17,13 +18,51 @@ import ( // *Experimental*: Support for the VARIANT type is still being developed and subject to // change. // -// Initial support does not attempt to process the variant data. So reading and writing -// data of this type behaves as if it were just a group with two byte array fields, as -// if the logical type annotation were absent. This may change in the future. +// Go values written to a variant column with the "variant" struct tag are encoded +// with the variant binary encoding (see the variant subpackage); structs with +// Metadata and Value []byte fields pass the raw encoding through unchanged. When +// reading, files that store the column shredded are reconstructed automatically. // // [VARIANT logical type]: https://github.com/apache/parquet-format/blob/master/LogicalTypes.md#variant func Variant() Node { - return variantNode{Group{"metadata": Required(Leaf(ByteArrayType)), "value": Required(Leaf(ByteArrayType))}} + return variantNode{variantOrderedGroup(Group{ + "metadata": Required(Leaf(ByteArrayType)), + "value": Required(Leaf(ByteArrayType)), + })} +} + +// variantOrderedGroup wraps a group so its fields are returned in the +// canonical variant order (metadata, value, typed_value; value before +// typed_value in nested groups) instead of alphabetically. Other engines +// (e.g. DuckDB) require the metadata and value columns to come first in +// the variant group. +func variantOrderedGroup(g Group) Node { + return orderedGroup{Group: g, order: []string{"metadata", "value", "typed_value"}} +} + +// orderedGroup is a Group whose fields are returned in an explicit order. +// Fields not listed in order come last, in alphabetical order. +type orderedGroup struct { + Group + order []string +} + +func (g orderedGroup) Fields() []Field { + fields := g.Group.Fields() + rank := func(name string) int { + for i, n := range g.order { + if n == name { + return i + } + } + return len(g.order) + } + sortedFields := make([]Field, len(fields)) + copy(sortedFields, fields) + slices.SortStableFunc(sortedFields, func(a, b Field) int { + return rank(a.Name()) - rank(b.Name()) + }) + return sortedFields } // ShreddedVariant constructs a node of shredded [VARIANT logical type]. It is a group @@ -48,9 +87,10 @@ func Variant() Node { // *Experimental*: Support for the VARIANT type is still being developed and subject to // change. // -// Initial support does not attempt to process the variant data. So reading and writing -// data of this type behaves as if it were just a group with the three described fields, -// as if the logical type annotation were absent. This may change in the future. +// Go values written to a shredded variant column with the "variant" struct tag are +// shredded per the [Parquet documentation]: values matching the shredded type are +// stored in the typed_value columns, and everything else is encoded into the +// appropriate value column. Reading reconstructs the variant from all columns. // // [VARIANT logical type]: https://github.com/apache/parquet-format/blob/master/LogicalTypes.md#variant // [variant value types]: https://github.com/apache/parquet-format/blob/master/VariantShredding.md#shredded-value-types @@ -60,11 +100,11 @@ func ShreddedVariant(shreddedType Node) (Node, error) { if err != nil { return nil, err } - return variantNode{Group{ + return variantNode{variantOrderedGroup(Group{ "metadata": Required(Leaf(ByteArrayType)), "value": Optional(Leaf(ByteArrayType)), "typed_value": Optional(typedNode), - }}, nil + })}, nil } func variantTypedValueNode(node Node, fieldPath ...string) (typed Node, err error) { @@ -77,7 +117,7 @@ func variantTypedValueNode(node Node, fieldPath ...string) (typed Node, err erro return nil, errors.New("repeated types are not allowed unless they are part of a 3-level LIST logical type") } if lt := node.Type().LogicalType(); lt != nil { - switch lt := getLogicalType(lt).(type) { + switch lt := lt.Value.(type) { case *format.ListType: // We must first extract the inner list.element field of the 3-level LIST type. children := node.Fields() @@ -92,10 +132,10 @@ func variantTypedValueNode(node Node, fieldPath ...string) (typed Node, err erro if err != nil { return nil, err } - list := List(Required(Group{ + list := List(Required(variantOrderedGroup(Group{ "value": Optional(Leaf(ByteArrayType)), "typed_value": Optional(elementNode), - })) + }))) if node.ID() != 0 { return FieldID(list, node.ID()), nil } @@ -113,6 +153,8 @@ func variantTypedValueNode(node Node, fieldPath ...string) (typed Node, err erro case *format.TimestampType: case *format.StringType: case *format.UUIDType: + case nil: + // No logical type annotation. default: // No other logical types are allowed. return nil, fmt.Errorf("%s logical types are not allowed", lt) @@ -131,10 +173,10 @@ func variantTypedValueNode(node Node, fieldPath ...string) (typed Node, err erro if err != nil { return nil, err } - group[child.Name()] = Required(Group{ + group[child.Name()] = Required(variantOrderedGroup(Group{ "value": Optional(Leaf(ByteArrayType)), "typed_value": Optional(childNode), - }) + })) } if node.ID() != 0 { return FieldID(group, node.ID()), nil @@ -142,27 +184,13 @@ func variantTypedValueNode(node Node, fieldPath ...string) (typed Node, err erro return group, nil } -func getLogicalType(lt *format.LogicalType) any { - // We use reflection so we can always catch a logical type annotation. If a - // new one is added, we don't have to remember to update the switch above (unless - // a new one is added that is also supported as a variant value). - refVal := reflect.Indirect(reflect.ValueOf(lt)) - for i := range refVal.NumField() { - field := refVal.Field(i) - if field.CanInterface() && !field.IsZero() { - return field.Interface() - } - } - return nil -} - -type variantNode struct{ Group } +type variantNode struct{ Node } func (variantNode) Type() Type { return &variantType{} } type variantType format.VariantType -var variantLogicalType = format.LogicalType{Variant: new(format.VariantType)} +var variantLogicalType = format.LogicalType{Value: new(format.VariantType)} func (t *variantType) String() string { return (*format.VariantType)(t).String() } diff --git a/vendor/github.com/parquet-go/parquet-go/value.go b/vendor/github.com/parquet-go/parquet-go/value.go index b105dc45aa1..05d7f96b50e 100644 --- a/vendor/github.com/parquet-go/parquet-go/value.go +++ b/vendor/github.com/parquet-go/parquet-go/value.go @@ -269,16 +269,16 @@ func makeValue(k Kind, lt *format.LogicalType, v reflect.Value) Value { switch v.Type() { case reflect.TypeOf(time.Time{}): unit := Nanosecond.TimeUnit() - if lt != nil && lt.Timestamp != nil { - unit = lt.Timestamp.Unit + if ts, ok := logicalTypeOf[*format.TimestampType](lt); ok { + unit = ts.Unit } t := v.Interface().(time.Time) var val int64 - switch { - case unit.Millis != nil: + switch unit.Value.(type) { + case *format.MilliSeconds: val = t.UnixMilli() - case unit.Micros != nil: + case *format.MicroSeconds: val = t.UnixMicro() default: val = t.UnixNano() @@ -337,7 +337,7 @@ func makeValue(k Kind, lt *format.LogicalType, v reflect.Value) Value { case FixedLenByteArray: switch v.Kind() { case reflect.String: - if lt.UUID != nil { // uuid + if logicalTypeIs[*format.UUIDType](lt) { // uuid uuidStr := v.String() encoded, err := uuid.MustParse(uuidStr).MarshalBinary() if err != nil { @@ -788,7 +788,7 @@ func (v Value) String() string { case Float: return strconv.FormatFloat(float64(v.float()), 'g', -1, 32) case Double: - return strconv.FormatFloat(v.double(), 'g', -1, 32) + return strconv.FormatFloat(v.double(), 'g', -1, 64) case ByteArray, FixedLenByteArray: return string(v.byteArray()) default: @@ -802,14 +802,68 @@ func (v Value) GoString() string { return fmt.Sprintf("%#v", v) } // Level returns v with the repetition level, definition level, and column index // set to the values passed as arguments. // -// The method panics if either argument is negative. +// The method panics if any argument is negative or exceeds its maximum +// (MaxRepetitionLevel, MaxDefinitionLevel, MaxColumnIndex respectively). +// +// To mutate a single level field in place, see SetRepetitionLevel, +// SetDefinitionLevel, and SetColumnIndex, which the compiler can inline. func (v Value) Level(repetitionLevel, definitionLevel, columnIndex int) Value { - v.repetitionLevel = makeRepetitionLevel(repetitionLevel) - v.definitionLevel = makeDefinitionLevel(definitionLevel) - v.columnIndex = ^makeColumnIndex(columnIndex) + // MaxRepetitionLevel and MaxDefinitionLevel are both math.MaxUint8, so the + // two levels are bounds-checked with a single comparison: ORing them keeps + // the result in range only if both operands are; a negative value converts + // to a large uint and trips the check as well. + if uint(repetitionLevel)|uint(definitionLevel) > MaxRepetitionLevel || + uint(columnIndex) > MaxColumnIndex { + panicLevelOutOfRange(repetitionLevel, definitionLevel, columnIndex) + } + v.repetitionLevel = byte(repetitionLevel) + v.definitionLevel = byte(definitionLevel) + v.columnIndex = ^uint16(columnIndex) return v } +// SetRepetitionLevel sets the repetition level of v to the given value. +// +// Unlike Level, which sets all three level fields and returns a new Value, this +// method mutates a single field in place through a pointer receiver. Avoiding +// the value copy keeps it small enough for the compiler to inline, which lets +// the bounds check be eliminated entirely when the argument is provably in range +// (for example when forwarding an existing repetition level). Mutating a slice +// element in place (values[i].SetRepetitionLevel(...)) makes it a good fit for +// hot loops. +// +// The method panics if level is negative or greater than MaxRepetitionLevel. +func (v *Value) SetRepetitionLevel(level int) { + if uint(level) > MaxRepetitionLevel { + panicRepetitionLevelOutOfRange(level) + } + v.repetitionLevel = byte(level) +} + +// SetDefinitionLevel sets the definition level of v to the given value. +// +// See SetRepetitionLevel for the rationale behind the single-field setters. +// +// The method panics if level is negative or greater than MaxDefinitionLevel. +func (v *Value) SetDefinitionLevel(level int) { + if uint(level) > MaxDefinitionLevel { + panicDefinitionLevelOutOfRange(level) + } + v.definitionLevel = byte(level) +} + +// SetColumnIndex sets the column index of v to the given value. +// +// See SetRepetitionLevel for the rationale behind the single-field setters. +// +// The method panics if columnIndex is negative or greater than MaxColumnIndex. +func (v *Value) SetColumnIndex(columnIndex int) { + if uint(columnIndex) > MaxColumnIndex { + panicColumnIndexOutOfRange(columnIndex) + } + v.columnIndex = ^uint16(columnIndex) +} + // Clone returns a copy of v which does not share any pointers with it. func (v Value) Clone() Value { switch k := v.Kind(); k { @@ -1093,3 +1147,45 @@ type FixedLenByteArrayWriter interface { // is not a multiple of the expected item size. WriteFixedLenByteArrays(values []byte) (int, error) } + +// BE128Reader is an interface implemented by ValueReader instances which +// expose the content of a column of 128-bit big-endian byte array values. +type BE128Reader interface { + // Read 128-bit big-endian values into the buffer passed as argument, + // returning the number of values read. + // + // The method returns io.EOF when all values have been read. + ReadBE128s(values [][16]byte) (int, error) +} + +// BE128Writer is an interface implemented by ValueWriter instances which +// support writing columns of 128-bit big-endian byte array values. +type BE128Writer interface { + // Write 128-bit big-endian values. + // + // The method returns the number of values written, and any error that + // occurred while writing the values. + WriteBE128s(values [][16]byte) (int, error) +} + +// UUIDReader is an interface implemented by ValueReader instances which +// expose the content of a column of UUID values stored as 16-byte +// FIXED_LEN_BYTE_ARRAY with the UUID logical type. +type UUIDReader interface { + // Read UUID values into the buffer passed as argument, returning the + // number of values read. + // + // The method returns io.EOF when all values have been read. + ReadUUIDs(values []uuid.UUID) (int, error) +} + +// UUIDWriter is an interface implemented by ValueWriter instances which +// support writing columns of UUID values stored as 16-byte +// FIXED_LEN_BYTE_ARRAY with the UUID logical type. +type UUIDWriter interface { + // Write UUID values. + // + // The method returns the number of values written, and any error that + // occurred while writing the values. + WriteUUIDs(values []uuid.UUID) (int, error) +} diff --git a/vendor/github.com/parquet-go/parquet-go/variant/builder.go b/vendor/github.com/parquet-go/parquet-go/variant/builder.go new file mode 100644 index 00000000000..197f0259713 --- /dev/null +++ b/vendor/github.com/parquet-go/parquet-go/variant/builder.go @@ -0,0 +1,636 @@ +package variant + +import ( + "encoding/binary" + "errors" + "fmt" + "math" + "slices" + "strings" + + "github.com/google/uuid" +) + +// ValueBuilder is a streaming event sink for variant values. Callers describe +// a value as a sequence of events — scalars, or containers bracketed by +// Begin/End calls — and implementations consume the events without ever +// materializing the value as a tree. +// +// Exactly one value must be written: a single scalar event, or a single +// balanced container. Inside an object, every value must be preceded by a +// Field call naming it, and field names must be unique within their object +// (duplicates are an error). Errors (both misuse of the event sequence and +// implementation-specific failures) are sticky and reported by Err; events +// after an error are ignored. +// +// ValueBuilder is implemented by Builder, which encodes the events to variant +// binary, and by parquet.VariantColumnWriter, which shreds the events +// directly into parquet column buffers. +type ValueBuilder interface { + Null() + Bool(v bool) + Int8(v int8) + Int16(v int16) + Int32(v int32) + Int64(v int64) + Float(v float32) + Double(v float64) + String(v string) + Binary(v []byte) + Date(days int32) + Time(micros int64) + Timestamp(micros int64) + TimestampNTZ(micros int64) + TimestampNanos(nanos int64) + TimestampNTZNanos(nanos int64) + UUID(v uuid.UUID) + Decimal4(unscaled int32, scale byte) + Decimal8(unscaled int64, scale byte) + Decimal16(unscaled [16]byte, scale byte) + + // BeginObject starts an object value. Calls until the matching EndObject + // must alternate Field and value events. + BeginObject() + + // Field names the next value written as a field of the innermost open + // object. + Field(name string) + + // EndObject closes the innermost open object. + EndObject() + + // BeginArray starts an array value. Every value written until the + // matching EndArray is one element. + BeginArray() + + // EndArray closes the innermost open array. + EndArray() + + // Err returns the first error encountered, or nil. + Err() error +} + +// Write replays the value as a sequence of events on w. It is the bridge +// from the tree representation to any ValueBuilder. +func (v Value) Write(w ValueBuilder) { + switch v.basic { + case BasicObject: + w.BeginObject() + for _, f := range v.object.Fields { + w.Field(f.Name) + f.Value.Write(w) + } + w.EndObject() + case BasicArray: + w.BeginArray() + for _, e := range v.array.Elements { + e.Write(w) + } + w.EndArray() + case BasicShortString: + w.String(v.str) + default: + switch v.primitive { + case PrimitiveNull: + w.Null() + case PrimitiveTrue: + w.Bool(true) + case PrimitiveFalse: + w.Bool(false) + case PrimitiveInt8: + w.Int8(int8(v.i64)) + case PrimitiveInt16: + w.Int16(int16(v.i64)) + case PrimitiveInt32: + w.Int32(int32(v.i64)) + case PrimitiveInt64: + w.Int64(v.i64) + case PrimitiveFloat: + w.Float(float32(v.f64)) + case PrimitiveDouble: + w.Double(v.f64) + case PrimitiveString: + w.String(v.str) + case PrimitiveBinary: + w.Binary(v.bytes) + case PrimitiveDate: + w.Date(int32(v.i64)) + case PrimitiveTime: + w.Time(v.i64) + case PrimitiveTimestamp: + w.Timestamp(v.i64) + case PrimitiveTimestampNTZ: + w.TimestampNTZ(v.i64) + case PrimitiveTimestampNanos: + w.TimestampNanos(v.i64) + case PrimitiveTimestampNTZNanos: + w.TimestampNTZNanos(v.i64) + case PrimitiveUUID: + w.UUID(v.uuid) + case PrimitiveDecimal4: + w.Decimal4(int32(v.i64), v.scale) + case PrimitiveDecimal8: + w.Decimal8(v.i64, v.scale) + case PrimitiveDecimal16: + w.Decimal16(v.decimal16, v.scale) + default: + w.Null() + } + } +} + +// Builder is a streaming encoder for variant values: a ValueBuilder that +// encodes events directly to the variant binary format in a single growing +// buffer, without building a Value tree. +// +// Values are encoded as their events arrive. When a container closes, its +// header (field IDs, offsets) is spliced in front of the already-encoded +// children with one memmove, so encoding is a single pass with no per-value +// allocations beyond buffer growth. Object field values are kept in event +// order and only the header entries are sorted by field name, which the +// encoding permits (field IDs must be sorted, field offsets need not be +// monotonic). +// +// The zero value is ready to use and owns its metadata dictionary; Finish +// returns both the metadata and the value. NewBuilderWithMetadata creates a +// builder that interns field names into a shared, caller-owned dictionary, +// which is how multiple values (e.g. all residuals of one shredded row) +// share one dictionary. +// +// A Builder may be reused after Reset. Reset retains internal buffers, so a +// long-lived Builder encodes a stream of values with amortized zero +// allocation. A Builder must not be copied after first use. +type Builder struct { + meta *MetadataBuilder + ownMeta MetadataBuilder + + buf []byte + scratch []byte + + frames []builderFrame + fields []builderField // arena shared by all open object frames + elems []int // arena shared by all open array frames + + pendingField bool // inside an object, a Field awaits its value + complete bool // one complete top-level value has been written + err error +} + +type builderFrame struct { + isObject bool + start int // buf offset where the container's first child begins + fieldsBase int // objects: base of this frame's entries in the fields arena + elemsBase int // arrays: base of this frame's element starts in the elems arena +} + +type builderField struct { + id int + start int // buf offset where the field's value begins +} + +// NewBuilderWithMetadata returns a Builder that interns object field names +// into the given shared metadata dictionary instead of an internal one. +// Finish builds the shared dictionary; callers encoding multiple values +// against one dictionary typically use Bytes and build the metadata +// themselves once. +func NewBuilderWithMetadata(meta *MetadataBuilder) *Builder { + return &Builder{meta: meta} +} + +func (b *Builder) metadata() *MetadataBuilder { + if b.meta == nil { + b.meta = &b.ownMeta + } + return b.meta +} + +// Err returns the first error encountered, or nil. +func (b *Builder) Err() error { return b.err } + +func (b *Builder) fail(format string, args ...any) { + if b.err == nil { + b.err = fmt.Errorf("variant builder: "+format, args...) + } +} + +// Reset clears the builder for reuse, retaining internal buffers. If the +// builder owns its metadata dictionary the dictionary is cleared too; a +// shared dictionary (NewBuilderWithMetadata) is left untouched. +func (b *Builder) Reset() { + if b.meta == &b.ownMeta { + b.ownMeta.Reset() + } + b.buf = b.buf[:0] + b.frames = b.frames[:0] + b.fields = b.fields[:0] + b.elems = b.elems[:0] + b.pendingField = false + b.complete = false + b.err = nil +} + +// Finish returns the encoded metadata and value. It fails if no value or an +// incomplete value has been written. The value slice aliases the builder's +// internal buffer and is invalidated by Reset or further writes, the same +// as Bytes; the metadata slice is freshly allocated. +func (b *Builder) Finish() (metadata, value []byte, err error) { + value, err = b.Bytes() + if err != nil { + return nil, nil, err + } + meta := b.metadata() + // Dictionary offsets are at most 4 bytes wide; MetadataBuilder.AppendTo + // would silently truncate a larger dictionary. + if uint64(meta.Size()) > math.MaxUint32 { + return nil, nil, fmt.Errorf("variant builder: metadata dictionary of %d bytes exceeds the variant format's 4 GiB limit", meta.Size()) + } + metadata = meta.AppendTo(nil) + return metadata, value, nil +} + +// Bytes returns the encoded value bytes without building the metadata. The +// returned slice aliases the builder's internal buffer and is invalidated by +// Reset or further writes. +func (b *Builder) Bytes() ([]byte, error) { + switch { + case b.err != nil: + return nil, b.err + case len(b.frames) > 0: + return nil, errors.New("variant builder: unclosed object or array") + case !b.complete: + return nil, errors.New("variant builder: no value written") + } + return b.buf, nil +} + +// beginValue validates that a value event is legal in the current state and +// records array element boundaries. It reports whether to proceed. +func (b *Builder) beginValue() bool { + if b.err != nil { + return false + } + if n := len(b.frames); n == 0 { + if b.complete { + b.fail("more than one top-level value") + return false + } + } else if f := &b.frames[n-1]; f.isObject { + if !b.pendingField { + b.fail("value written inside an object without a Field call") + return false + } + b.pendingField = false + } else { + b.elems = append(b.elems, len(b.buf)) + } + return true +} + +func (b *Builder) endValue() { + if len(b.frames) == 0 { + b.complete = true + } +} + +func (b *Builder) appendScalar(data ...byte) { + if b.beginValue() { + b.buf = append(b.buf, data...) + b.endValue() + } +} + +func (b *Builder) Null() { b.appendScalar(makeHeader(BasicPrimitive, byte(PrimitiveNull))) } + +func (b *Builder) Bool(v bool) { + p := PrimitiveFalse + if v { + p = PrimitiveTrue + } + b.appendScalar(makeHeader(BasicPrimitive, byte(p))) +} + +func (b *Builder) Int8(v int8) { + b.appendScalar(makeHeader(BasicPrimitive, byte(PrimitiveInt8)), byte(v)) +} + +func (b *Builder) Int16(v int16) { b.scalar16(PrimitiveInt16, uint16(v)) } + +func (b *Builder) Int32(v int32) { b.scalar32(PrimitiveInt32, uint32(v)) } + +func (b *Builder) Int64(v int64) { b.scalar64(PrimitiveInt64, uint64(v)) } + +func (b *Builder) Float(v float32) { b.scalar32(PrimitiveFloat, math.Float32bits(v)) } + +func (b *Builder) Double(v float64) { b.scalar64(PrimitiveDouble, math.Float64bits(v)) } + +func (b *Builder) String(v string) { + if !b.beginValue() { + return + } + if uint64(len(v)) > math.MaxUint32 { + b.fail("string of %d bytes exceeds the variant format's 4 GiB limit", len(v)) + return + } + if len(v) <= 63 { + b.buf = append(b.buf, makeHeader(BasicShortString, byte(len(v)))) + } else { + b.buf = append(b.buf, makeHeader(BasicPrimitive, byte(PrimitiveString)), 0, 0, 0, 0) + binary.LittleEndian.PutUint32(b.buf[len(b.buf)-4:], uint32(len(v))) + } + b.buf = append(b.buf, v...) + b.endValue() +} + +func (b *Builder) Binary(v []byte) { + if !b.beginValue() { + return + } + if uint64(len(v)) > math.MaxUint32 { + b.fail("binary value of %d bytes exceeds the variant format's 4 GiB limit", len(v)) + return + } + b.buf = append(b.buf, makeHeader(BasicPrimitive, byte(PrimitiveBinary)), 0, 0, 0, 0) + binary.LittleEndian.PutUint32(b.buf[len(b.buf)-4:], uint32(len(v))) + b.buf = append(b.buf, v...) + b.endValue() +} + +func (b *Builder) Date(days int32) { b.scalar32(PrimitiveDate, uint32(days)) } + +func (b *Builder) Time(micros int64) { b.scalar64(PrimitiveTime, uint64(micros)) } + +func (b *Builder) Timestamp(micros int64) { b.scalar64(PrimitiveTimestamp, uint64(micros)) } + +func (b *Builder) TimestampNTZ(micros int64) { b.scalar64(PrimitiveTimestampNTZ, uint64(micros)) } + +func (b *Builder) TimestampNanos(nanos int64) { b.scalar64(PrimitiveTimestampNanos, uint64(nanos)) } + +func (b *Builder) TimestampNTZNanos(nanos int64) { + b.scalar64(PrimitiveTimestampNTZNanos, uint64(nanos)) +} + +func (b *Builder) UUID(v uuid.UUID) { + if !b.beginValue() { + return + } + b.buf = append(b.buf, makeHeader(BasicPrimitive, byte(PrimitiveUUID))) + b.buf = append(b.buf, v[:]...) + b.endValue() +} + +func (b *Builder) Decimal4(unscaled int32, scale byte) { + if !b.beginValue() { + return + } + b.buf = append(b.buf, makeHeader(BasicPrimitive, byte(PrimitiveDecimal4)), scale, 0, 0, 0, 0) + binary.LittleEndian.PutUint32(b.buf[len(b.buf)-4:], uint32(unscaled)) + b.endValue() +} + +func (b *Builder) Decimal8(unscaled int64, scale byte) { + if !b.beginValue() { + return + } + b.buf = append(b.buf, makeHeader(BasicPrimitive, byte(PrimitiveDecimal8)), scale, 0, 0, 0, 0, 0, 0, 0, 0) + binary.LittleEndian.PutUint64(b.buf[len(b.buf)-8:], uint64(unscaled)) + b.endValue() +} + +func (b *Builder) Decimal16(unscaled [16]byte, scale byte) { + if !b.beginValue() { + return + } + b.buf = append(b.buf, makeHeader(BasicPrimitive, byte(PrimitiveDecimal16)), scale) + b.buf = append(b.buf, unscaled[:]...) + b.endValue() +} + +func (b *Builder) scalar16(p PrimitiveType, v uint16) { + if !b.beginValue() { + return + } + b.buf = append(b.buf, makeHeader(BasicPrimitive, byte(p)), 0, 0) + binary.LittleEndian.PutUint16(b.buf[len(b.buf)-2:], v) + b.endValue() +} + +func (b *Builder) scalar32(p PrimitiveType, v uint32) { + if !b.beginValue() { + return + } + b.buf = append(b.buf, makeHeader(BasicPrimitive, byte(p)), 0, 0, 0, 0) + binary.LittleEndian.PutUint32(b.buf[len(b.buf)-4:], v) + b.endValue() +} + +func (b *Builder) scalar64(p PrimitiveType, v uint64) { + if !b.beginValue() { + return + } + b.buf = append(b.buf, makeHeader(BasicPrimitive, byte(p)), 0, 0, 0, 0, 0, 0, 0, 0) + binary.LittleEndian.PutUint64(b.buf[len(b.buf)-8:], v) + b.endValue() +} + +func (b *Builder) BeginObject() { + if !b.beginValue() { + return + } + b.frames = append(b.frames, builderFrame{ + isObject: true, + start: len(b.buf), + fieldsBase: len(b.fields), + }) +} + +func (b *Builder) Field(name string) { + if b.err != nil { + return + } + n := len(b.frames) + if n == 0 || !b.frames[n-1].isObject { + b.fail("Field %q outside of an object", name) + return + } + if b.pendingField { + b.fail("Field %q: previous field has no value", name) + return + } + id := b.metadata().Add(name) + b.fields = append(b.fields, builderField{ + id: id, + start: len(b.buf), + }) + b.pendingField = true +} + +func (b *Builder) EndObject() { + if b.err != nil { + return + } + n := len(b.frames) + if n == 0 || !b.frames[n-1].isObject { + b.fail("EndObject without matching BeginObject") + return + } + meta := b.metadata() + if b.pendingField { + b.fail("EndObject: field %q has no value", meta.stringAt(b.fields[len(b.fields)-1].id)) + return + } + f := b.frames[n-1] + entries := b.fields[f.fieldsBase:] + + // The encoding requires field IDs sorted lexicographically by name; + // field values stay where they were written, offsets need not be + // monotonic. Names are resolved from the metadata slab at close time + // so Field does not retain views that a later Add could invalidate. + slices.SortFunc(entries, func(a, c builderField) int { + return strings.Compare(meta.stringAt(a.id), meta.stringAt(c.id)) + }) + for i := 1; i < len(entries); i++ { + // Names are interned, so equal names always share one id. + if entries[i].id == entries[i-1].id { + b.fail("duplicate object field %q", meta.stringAt(entries[i].id)) + return + } + } + + numFields := len(entries) + contentSize := len(b.buf) - f.start + // Offsets are at most 4 bytes wide, so a container whose encoded + // children exceed math.MaxUint32 bytes is unrepresentable; failing + // beats the silent truncation of writeUint. Field offsets and counts + // are bounded by contentSize, so this one check covers them too. + if uint64(contentSize) > math.MaxUint32 { + b.fail("object content of %d bytes exceeds the variant format's 4 GiB limit", contentSize) + return + } + maxID := 0 + for i := range entries { + if entries[i].id > maxID { + maxID = entries[i].id + } + } + + fieldIDSzCode := offsetSizeCode(maxID) + fieldIDSz := offsetSize(fieldIDSzCode) + offsetSzCode := offsetSizeCode(contentSize) + offsetSz := offsetSize(offsetSzCode) + + isLarge := byte(0) + numElemSize := 1 + if numFields > 255 { + isLarge = 1 + numElemSize = 4 + } + + headerSize := 1 + numElemSize + numFields*fieldIDSz + (numFields+1)*offsetSz + h := b.header(headerSize) + h[0] = byte(BasicObject) | (offsetSzCode << 2) | (fieldIDSzCode << 4) | (isLarge << 6) + pos := 1 + if isLarge == 1 { + binary.LittleEndian.PutUint32(h[pos:], uint32(numFields)) + pos += 4 + } else { + h[pos] = byte(numFields) + pos++ + } + for i := range entries { + writeUint(h[pos:], entries[i].id, fieldIDSz) + pos += fieldIDSz + } + for i := range entries { + writeUint(h[pos:], entries[i].start-f.start, offsetSz) + pos += offsetSz + } + writeUint(h[pos:], contentSize, offsetSz) + + b.splice(f.start, h) + b.fields = b.fields[:f.fieldsBase] + b.frames = b.frames[:n-1] + b.endValue() +} + +func (b *Builder) BeginArray() { + if !b.beginValue() { + return + } + b.frames = append(b.frames, builderFrame{ + start: len(b.buf), + elemsBase: len(b.elems), + }) +} + +func (b *Builder) EndArray() { + if b.err != nil { + return + } + n := len(b.frames) + if n == 0 || b.frames[n-1].isObject { + b.fail("EndArray without matching BeginArray") + return + } + f := b.frames[n-1] + starts := b.elems[f.elemsBase:] + + numElems := len(starts) + contentSize := len(b.buf) - f.start + // See the matching check in EndObject. + if uint64(contentSize) > math.MaxUint32 { + b.fail("array content of %d bytes exceeds the variant format's 4 GiB limit", contentSize) + return + } + + offsetSzCode := offsetSizeCode(contentSize) + offsetSz := offsetSize(offsetSzCode) + + isLarge := byte(0) + numElemSize := 1 + if numElems > 255 { + isLarge = 1 + numElemSize = 4 + } + + headerSize := 1 + numElemSize + (numElems+1)*offsetSz + h := b.header(headerSize) + h[0] = byte(BasicArray) | (offsetSzCode << 2) | (isLarge << 4) + pos := 1 + if isLarge == 1 { + binary.LittleEndian.PutUint32(h[pos:], uint32(numElems)) + pos += 4 + } else { + h[pos] = byte(numElems) + pos++ + } + for _, start := range starts { + writeUint(h[pos:], start-f.start, offsetSz) + pos += offsetSz + } + writeUint(h[pos:], contentSize, offsetSz) + + b.splice(f.start, h) + b.elems = b.elems[:f.elemsBase] + b.frames = b.frames[:n-1] + b.endValue() +} + +// header returns a zeroed scratch slice of the given size for building a +// container header. +func (b *Builder) header(size int) []byte { + if cap(b.scratch) < size { + b.scratch = make([]byte, size) + } + h := b.scratch[:size] + clear(h) + return h +} + +// splice inserts header at position start, shifting the container's encoded +// children right by one memmove. +func (b *Builder) splice(start int, header []byte) { + n := len(header) + b.buf = append(b.buf, header...) + copy(b.buf[start+n:], b.buf[start:len(b.buf)-n]) + copy(b.buf[start:], header) +} diff --git a/vendor/github.com/parquet-go/parquet-go/variant/decoding.go b/vendor/github.com/parquet-go/parquet-go/variant/decoding.go index d426edbe2da..5023e339f25 100644 --- a/vendor/github.com/parquet-go/parquet-go/variant/decoding.go +++ b/vendor/github.com/parquet-go/parquet-go/variant/decoding.go @@ -5,10 +5,18 @@ import ( "errors" "fmt" "math" + "unicode/utf8" ) // Decode decodes a variant value from its binary representation using the // given metadata dictionary. +// +// Decode rejects input the spec declares invalid: strings that are not valid +// UTF-8, objects with duplicate field names, and structures whose declared +// sizes exceed the data. It accepts input that is non-canonical but +// unambiguous, as the spec directs for readers: reserved header bits are +// ignored, object fields need not be listed in lexicographic order, and +// bytes past the end of the value are ignored (values are self-delimiting). func Decode(m Metadata, data []byte) (Value, error) { if len(data) == 0 { return Null(), errors.New("variant value: empty data") @@ -35,8 +43,15 @@ func decodeValue(m Metadata, data []byte) (Value, int, error) { if len(data) < 1+length { return Null(), 0, fmt.Errorf("variant value: short string length %d exceeds data", length) } - v := Value{basic: BasicShortString, str: string(data[1 : 1+length])} - return v, 1 + length, nil + if !utf8.Valid(data[1 : 1+length]) { + return Null(), 0, errors.New("variant value: short string is not valid UTF-8") + } + // Normalize to the string primitive so the value re-encodes + // correctly. VariantEncoding.md: "The 'short string' basic type + // may be used as an optimization to fold string length into the + // type byte for strings less than 64 bytes. It is semantically + // identical to the 'string' primitive type." + return String(string(data[1 : 1+length])), 1 + length, nil case BasicObject: return decodeObject(m, header, data[1:]) case BasicArray: @@ -88,17 +103,31 @@ func decodePrimitive(pt PrimitiveType, data []byte) (Value, int, error) { if len(data) < 4 { return Null(), 0, errors.New("variant value: not enough data for string length") } + // On 32-bit platforms a 4-byte length above math.MaxInt32 + // overflows int and is negative, and 4+length can overflow the + // same way, so the bounds check avoids the addition. Neither + // overflow can happen on 64-bit platforms. length := int(binary.LittleEndian.Uint32(data[:4])) - if len(data) < 4+length { + if length < 0 || length > len(data)-4 { return Null(), 0, fmt.Errorf("variant value: string length %d exceeds data", length) } + // VariantEncoding.md: "All strings within the Variant binary + // format must be UTF-8 encoded. This includes the dictionary key + // string values, the 'short string' values, and the 'long string' + // values." (Short strings and dictionary entries are validated at + // their own decode sites.) + if !utf8.Valid(data[4 : 4+length]) { + return Null(), 0, errors.New("variant value: string is not valid UTF-8") + } return String(string(data[4 : 4+length])), 5 + length, nil case PrimitiveBinary: if len(data) < 4 { return Null(), 0, errors.New("variant value: not enough data for binary length") } length := int(binary.LittleEndian.Uint32(data[:4])) - if len(data) < 4+length { + // The check is phrased for 32-bit overflow safety; see the string + // case above. + if length < 0 || length > len(data)-4 { return Null(), 0, fmt.Errorf("variant value: binary length %d exceeds data", length) } b := make([]byte, length) @@ -124,6 +153,16 @@ func decodePrimitive(pt PrimitiveType, data []byte) (Value, int, error) { return Null(), 0, errors.New("variant value: not enough data for time") } return Time(int64(binary.LittleEndian.Uint64(data[:8]))), 9, nil + case PrimitiveTimestampNanos: + if len(data) < 8 { + return Null(), 0, errors.New("variant value: not enough data for timestamp nanos") + } + return TimestampNanos(int64(binary.LittleEndian.Uint64(data[:8]))), 9, nil + case PrimitiveTimestampNTZNanos: + if len(data) < 8 { + return Null(), 0, errors.New("variant value: not enough data for timestamp_ntz nanos") + } + return TimestampNTZNanos(int64(binary.LittleEndian.Uint64(data[:8]))), 9, nil case PrimitiveUUID: if len(data) < 16 { return Null(), 0, errors.New("variant value: not enough data for uuid") @@ -159,8 +198,11 @@ func decodePrimitive(pt PrimitiveType, data []byte) (Value, int, error) { } func decodeObject(m Metadata, header byte, data []byte) (Value, int, error) { - fieldIDSizeCode := (header >> 2) & 0x03 - offsetSzCode := (header >> 4) & 0x03 + // Object header byte layout (see encodeObject): bits 2-3 hold + // field_offset_size_minus_one, bits 4-5 hold field_id_size_minus_one, + // bit 6 holds is_large. + offsetSzCode := (header >> 2) & 0x03 + fieldIDSizeCode := (header >> 4) & 0x03 isLarge := (header >> 6) & 0x01 fieldIDSize := offsetSize(fieldIDSizeCode) @@ -184,6 +226,15 @@ func decodeObject(m Metadata, header byte, data []byte) (Value, int, error) { pos += 1 } + // Validate the declared element count against the available data + // before allocating, to reject corrupt inputs with absurd sizes. + // numElements < 0 happens only on 32-bit platforms, where a 4-byte + // count above math.MaxInt32 overflows int. + if remaining := len(data) - pos; numElements < 0 || + remaining/(fieldIDSize+offsetSz) < numElements { + return Null(), 0, fmt.Errorf("variant value: object element count %d exceeds data", numElements) + } + // Read field IDs fieldIDs := make([]int, numElements) for i := range numElements { @@ -206,23 +257,60 @@ func decodeObject(m Metadata, header byte, data []byte) (Value, int, error) { pos += n } - // Value data starts at pos + // Value data starts at pos. The last offset is the total size of the + // value data region. Fields must NOT be sliced as [offset[i], + // offset[i+1]) — per VariantEncoding.md, "the actual value entries do + // not need to be in any particular order. This implies that the + // field_offset values may not be monotonically increasing." (Spark + // writes such objects.) Each value is self-delimiting; the offset only + // determines where it starts. valueDataStart := pos + valueDataEnd := valueDataStart + offsets[numElements] + // valueDataEnd < valueDataStart rejects a last offset that overflowed + // int to a negative value on 32-bit platforms. + if valueDataEnd > len(data) || valueDataEnd < valueDataStart { + return Null(), 0, errors.New("variant value: object value data exceeds input") + } fields := make([]Field, numElements) + // VariantEncoding.md: "Field names are required to be unique for each + // object. It is an error for an object to contain two fields with the + // same name, whether or not they have distinct dictionary IDs." (The + // last clause is why the check compares names, not field IDs.) + // + // The spec also requires fields to be listed in lexicographic order of + // their names, so in well-formed input a duplicate is adjacent to its + // twin and one comparison against the previous name detects it. The + // map is only allocated for inputs that violate the sort order (which + // are otherwise accepted, for compatibility with lenient writers). + var seen map[string]struct{} for i := range numElements { name, err := m.Lookup(fieldIDs[i]) if err != nil { return Null(), 0, fmt.Errorf("variant value: object field %d: %w", i, err) } + if seen == nil && i > 0 && name <= fields[i-1].Name { + if name == fields[i-1].Name { + return Null(), 0, fmt.Errorf("variant value: duplicate object field %q", name) + } + seen = make(map[string]struct{}, numElements) + for _, f := range fields[:i] { + seen[f.Name] = struct{}{} + } + } + if seen != nil { + if _, dup := seen[name]; dup { + return Null(), 0, fmt.Errorf("variant value: duplicate object field %q", name) + } + seen[name] = struct{}{} + } valueStart := valueDataStart + offsets[i] - valueEnd := valueDataStart + offsets[i+1] - if valueStart > len(data) || valueEnd > len(data) || valueStart > valueEnd { + if valueStart < valueDataStart || valueStart > valueDataEnd { return Null(), 0, fmt.Errorf("variant value: object field %d: invalid value offset", i) } - v, _, err := decodeValue(m, data[valueStart:valueEnd]) + v, _, err := decodeValue(m, data[valueStart:valueDataEnd]) if err != nil { return Null(), 0, fmt.Errorf("variant value: object field %q: %w", name, err) } @@ -230,7 +318,7 @@ func decodeObject(m Metadata, header byte, data []byte) (Value, int, error) { fields[i] = Field{Name: name, Value: v} } - totalConsumed := 1 + valueDataStart + offsets[numElements] // +1 for header byte + totalConsumed := 1 + valueDataEnd // +1 for header byte return MakeObject(fields), totalConsumed, nil } @@ -258,6 +346,17 @@ func decodeArray(m Metadata, header byte, data []byte) (Value, int, error) { pos += 1 } + // Validate the declared element count against the available data + // before allocating, to reject corrupt inputs with absurd sizes. + // numElements < 0 happens only on 32-bit platforms, where a 4-byte + // count above math.MaxInt32 overflows int; the comparison is phrased + // as <= numElements rather than < numElements+1 (there are + // numElements+1 offsets) so the addition cannot overflow the same way. + if remaining := len(data) - pos; numElements < 0 || + remaining/offsetSz <= numElements { + return Null(), 0, fmt.Errorf("variant value: array element count %d exceeds data", numElements) + } + // Read offsets (numElements+1) offsets := make([]int, numElements+1) for i := range numElements + 1 { @@ -276,7 +375,11 @@ func decodeArray(m Metadata, header byte, data []byte) (Value, int, error) { for i := range numElements { elemStart := valueDataStart + offsets[i] elemEnd := valueDataStart + offsets[i+1] - if elemStart > len(data) || elemEnd > len(data) || elemStart > elemEnd { + // elemStart < 0 happens only on 32-bit platforms, where a 4-byte + // offset above math.MaxInt32 overflows int; without the check the + // slice below would panic. The remaining conditions imply + // elemStart <= elemEnd <= len(data). + if elemStart < 0 || elemEnd > len(data) || elemStart > elemEnd { return Null(), 0, fmt.Errorf("variant value: array element %d: invalid offset", i) } diff --git a/vendor/github.com/parquet-go/parquet-go/variant/encoding.go b/vendor/github.com/parquet-go/parquet-go/variant/encoding.go index 5767d13bcc9..d2b65a83dd2 100644 --- a/vendor/github.com/parquet-go/parquet-go/variant/encoding.go +++ b/vendor/github.com/parquet-go/parquet-go/variant/encoding.go @@ -2,8 +2,14 @@ package variant import ( "encoding/binary" + "fmt" "math" + "reflect" "sort" + "sync" + "time" + + "github.com/google/uuid" ) // Encode encodes a variant Value into its binary representation. @@ -12,9 +18,31 @@ import ( func Encode(b *MetadataBuilder, v Value) []byte { switch v.basic { case BasicObject: - return encodeObject(b, v.object) + enc := getEncoder(b) + + start, end, err := enc.encodeValueObject(v.object) + if err != nil { + releaseEncoder(enc) + return nil + } + res := make([]byte, end-start) + copy(res, enc.scratch[start:end]) + + releaseEncoder(enc) + return res case BasicArray: - return encodeArray(b, v.array) + enc := getEncoder(b) + + start, end, err := enc.encodeValueArray(v.array) + if err != nil { + releaseEncoder(enc) + return nil + } + res := make([]byte, end-start) + copy(res, enc.scratch[start:end]) + + releaseEncoder(enc) + return res default: return encodePrimitive(v) } @@ -58,13 +86,11 @@ func encodePrimitive(v Value) []byte { case PrimitiveString: s := v.str if len(s) <= 63 { - // Use short string encoding buf := make([]byte, 1+len(s)) buf[0] = makeHeader(BasicShortString, byte(len(s))) copy(buf[1:], s) return buf } - // Long string: primitive string type + 4-byte length + data buf := make([]byte, 5+len(s)) buf[0] = makeHeader(BasicPrimitive, byte(PrimitiveString)) binary.LittleEndian.PutUint32(buf[1:], uint32(len(s))) @@ -96,6 +122,16 @@ func encodePrimitive(v Value) []byte { buf[0] = makeHeader(BasicPrimitive, byte(PrimitiveTime)) binary.LittleEndian.PutUint64(buf[1:], uint64(v.i64)) return buf + case PrimitiveTimestampNanos: + buf := make([]byte, 9) + buf[0] = makeHeader(BasicPrimitive, byte(PrimitiveTimestampNanos)) + binary.LittleEndian.PutUint64(buf[1:], uint64(v.i64)) + return buf + case PrimitiveTimestampNTZNanos: + buf := make([]byte, 9) + buf[0] = makeHeader(BasicPrimitive, byte(PrimitiveTimestampNTZNanos)) + binary.LittleEndian.PutUint64(buf[1:], uint64(v.i64)) + return buf case PrimitiveUUID: buf := make([]byte, 17) buf[0] = makeHeader(BasicPrimitive, byte(PrimitiveUUID)) @@ -124,59 +160,408 @@ func encodePrimitive(v Value) []byte { } } -func encodeObject(b *MetadataBuilder, obj Object) []byte { +// makeHeader constructs a value_metadata byte. +func makeHeader(basic BasicType, valueHeader byte) byte { + return byte(basic) | (valueHeader << 2) +} + +type encoder struct { + b *MetadataBuilder + scratch []byte + temp []byte + positions []elementPos + fields []encodedField + offsets []int +} + +var encoderPool = sync.Pool{ + New: func() any { + return &encoder{ + scratch: make([]byte, 0, 1024), + temp: make([]byte, 0, 1024), + positions: make([]elementPos, 0, 32), + fields: make([]encodedField, 0, 32), + offsets: make([]int, 0, 32), + } + }, +} + +const ( + maxPooledEncoderBytes = 1 << 20 + maxPooledEncoderItems = 4096 +) + +func getEncoder(b *MetadataBuilder) *encoder { + enc := encoderPool.Get().(*encoder) + enc.b = b + enc.scratch = enc.scratch[:0] + enc.temp = enc.temp[:0] + enc.positions = enc.positions[:0] + enc.fields = enc.fields[:0] + enc.offsets = enc.offsets[:0] + return enc +} + +func releaseEncoder(enc *encoder) { + enc.b = nil + if cap(enc.scratch) > maxPooledEncoderBytes { + enc.scratch = nil + } else { + enc.scratch = enc.scratch[:0] + } + if cap(enc.temp) > maxPooledEncoderBytes { + enc.temp = nil + } else { + enc.temp = enc.temp[:0] + } + if cap(enc.positions) > maxPooledEncoderItems { + enc.positions = nil + } else { + enc.positions = enc.positions[:0] + } + if cap(enc.fields) > maxPooledEncoderItems { + enc.fields = nil + } else { + enc.fields = enc.fields[:0] + } + if cap(enc.offsets) > maxPooledEncoderItems { + enc.offsets = nil + } else { + enc.offsets = enc.offsets[:0] + } + encoderPool.Put(enc) +} + +type encodedField struct { + id int + name string + start int + end int +} + +type elementPos struct { + start int + end int +} + +var testHookVerifyArrayLayout func(e *encoder, positions []elementPos) +var testHookVerifyObjectLayout func(e *encoder, entries []encodedField) + +func (e *encoder) encodeValuePrimitive(v Value) (start, end int) { + start = len(e.scratch) + switch v.primitive { + case PrimitiveNull: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveNull))) + case PrimitiveTrue: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveTrue))) + case PrimitiveFalse: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveFalse))) + case PrimitiveInt8: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveInt8)), byte(v.i64)) + case PrimitiveInt16: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveInt16)), 0, 0) + binary.LittleEndian.PutUint16(e.scratch[start+1:], uint16(v.i64)) + case PrimitiveInt32: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveInt32)), 0, 0, 0, 0) + binary.LittleEndian.PutUint32(e.scratch[start+1:], uint32(v.i64)) + case PrimitiveInt64: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveInt64)), 0, 0, 0, 0, 0, 0, 0, 0) + binary.LittleEndian.PutUint64(e.scratch[start+1:], uint64(v.i64)) + case PrimitiveFloat: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveFloat)), 0, 0, 0, 0) + binary.LittleEndian.PutUint32(e.scratch[start+1:], math.Float32bits(float32(v.f64))) + case PrimitiveDouble: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveDouble)), 0, 0, 0, 0, 0, 0, 0, 0) + binary.LittleEndian.PutUint64(e.scratch[start+1:], math.Float64bits(v.f64)) + case PrimitiveString: + s := v.str + if len(s) <= 63 { + e.scratch = append(e.scratch, makeHeader(BasicShortString, byte(len(s)))) + e.scratch = append(e.scratch, s...) + } else { + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveString)), 0, 0, 0, 0) + binary.LittleEndian.PutUint32(e.scratch[start+1:], uint32(len(s))) + e.scratch = append(e.scratch, s...) + } + case PrimitiveBinary: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveBinary)), 0, 0, 0, 0) + binary.LittleEndian.PutUint32(e.scratch[start+1:], uint32(len(v.bytes))) + e.scratch = append(e.scratch, v.bytes...) + case PrimitiveDate: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveDate)), 0, 0, 0, 0) + binary.LittleEndian.PutUint32(e.scratch[start+1:], uint32(v.i64)) + case PrimitiveTimestamp: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveTimestamp)), 0, 0, 0, 0, 0, 0, 0, 0) + binary.LittleEndian.PutUint64(e.scratch[start+1:], uint64(v.i64)) + case PrimitiveTimestampNTZ: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveTimestampNTZ)), 0, 0, 0, 0, 0, 0, 0, 0) + binary.LittleEndian.PutUint64(e.scratch[start+1:], uint64(v.i64)) + case PrimitiveTime: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveTime)), 0, 0, 0, 0, 0, 0, 0, 0) + binary.LittleEndian.PutUint64(e.scratch[start+1:], uint64(v.i64)) + case PrimitiveTimestampNanos: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveTimestampNanos)), 0, 0, 0, 0, 0, 0, 0, 0) + binary.LittleEndian.PutUint64(e.scratch[start+1:], uint64(v.i64)) + case PrimitiveTimestampNTZNanos: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveTimestampNTZNanos)), 0, 0, 0, 0, 0, 0, 0, 0) + binary.LittleEndian.PutUint64(e.scratch[start+1:], uint64(v.i64)) + case PrimitiveUUID: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveUUID))) + e.scratch = append(e.scratch, v.uuid[:]...) + case PrimitiveDecimal4: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveDecimal4)), v.scale, 0, 0, 0, 0) + binary.LittleEndian.PutUint32(e.scratch[start+2:], uint32(v.i64)) + case PrimitiveDecimal8: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveDecimal8)), v.scale, 0, 0, 0, 0, 0, 0, 0, 0) + binary.LittleEndian.PutUint64(e.scratch[start+2:], uint64(v.i64)) + case PrimitiveDecimal16: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveDecimal16)), v.scale) + e.scratch = append(e.scratch, v.decimal16[:]...) + default: + e.scratch = append(e.scratch, makeHeader(BasicPrimitive, byte(PrimitiveNull))) + } + end = len(e.scratch) + return start, end +} + +func (e *encoder) encodeValue(v Value) (start, end int, err error) { + switch v.basic { + case BasicObject: + return e.encodeValueObject(v.object) + case BasicArray: + return e.encodeValueArray(v.array) + default: + start, end = e.encodeValuePrimitive(v) + return start, end, nil + } +} + +func (e *encoder) encodeValueArray(arr Array) (start, end int, err error) { + n := len(arr.Elements) + if n == 0 { + return e.buildArrayBytes(nil) + } + + savedStart := len(e.positions) + if cap(e.positions) < savedStart+n { + newCap := max(cap(e.positions)*2, savedStart+n) + newP := make([]elementPos, len(e.positions), newCap) + copy(newP, e.positions) + e.positions = newP + } + e.positions = e.positions[:savedStart+n] + positions := e.positions[savedStart : savedStart+n] + + for i := range n { + pStart, pEnd, err := e.encodeValue(arr.Elements[i]) + if err != nil { + e.positions = e.positions[:savedStart] + return 0, 0, err + } + positions[i] = elementPos{start: pStart, end: pEnd} + } + + resStart, resEnd, err := e.buildArrayBytes(positions) + e.positions = e.positions[:savedStart] + return resStart, resEnd, err +} + +func (e *encoder) encodeValueObject(obj Object) (start, end int, err error) { n := len(obj.Fields) + if n == 0 { + return e.buildObjectBytes(nil) + } - // Register all field names and get their IDs - type fieldEntry struct { - id int - name string - valueBytes []byte + savedStart := len(e.fields) + if cap(e.fields) < savedStart+n { + newCap := max(cap(e.fields)*2, savedStart+n) + newF := make([]encodedField, len(e.fields), newCap) + copy(newF, e.fields) + e.fields = newF } - entries := make([]fieldEntry, n) + e.fields = e.fields[:savedStart+n] + entries := e.fields[savedStart : savedStart+n] + for i, f := range obj.Fields { - entries[i] = fieldEntry{ - id: b.Add(f.Name), - name: f.Name, - valueBytes: Encode(b, f.Value), + id := e.b.Add(f.Name) + pStart, pEnd, err := e.encodeValue(f.Value) + if err != nil { + e.fields = e.fields[:savedStart] + return 0, 0, err + } + entries[i] = encodedField{ + id: id, + name: f.Name, + start: pStart, + end: pEnd, } } - // Sort by field name (as required by spec) sort.Slice(entries, func(i, j int) bool { return entries[i].name < entries[j].name }) - // Compute sizes - maxID := 0 - for _, e := range entries { - if e.id > maxID { - maxID = e.id + resStart, resEnd, err := e.buildObjectBytes(entries) + e.fields = e.fields[:savedStart] + return resStart, resEnd, err +} + +func (e *encoder) encodeReflect(rv reflect.Value) (start, end int, err error) { + if !rv.IsValid() { + start, end = e.encodeValuePrimitive(Null()) + return start, end, nil + } + + // Dereference pointers/interfaces + for rv.Kind() == reflect.Ptr || rv.Kind() == reflect.Interface { + if rv.IsNil() { + start, end = e.encodeValuePrimitive(Null()) + return start, end, nil } + rv = rv.Elem() } - // Encode all values and compute offsets - totalValueSize := 0 - valueOffsets := make([]int, n+1) - for i, e := range entries { - valueOffsets[i] = totalValueSize - totalValueSize += len(e.valueBytes) + // Check concrete types first + if rv.Type() == reflect.TypeFor[uuid.UUID]() { + start, end = e.encodeValuePrimitive(UUID(rv.Interface().(uuid.UUID))) + return start, end, nil + } + if rv.Type() == reflect.TypeFor[time.Time]() { + start, end = e.encodeValuePrimitive(timeToVariant(rv.Interface().(time.Time))) + return start, end, nil } - valueOffsets[n] = totalValueSize - fieldIDSizeCode := offsetSizeCode(maxID) - fieldIDSize := offsetSize(fieldIDSizeCode) - offsetSzCode := offsetSizeCode(totalValueSize) + switch rv.Kind() { + case reflect.Bool: + start, end = e.encodeValuePrimitive(Bool(rv.Bool())) + return start, end, nil + case reflect.Int8: + start, end = e.encodeValuePrimitive(Int8(int8(rv.Int()))) + return start, end, nil + case reflect.Int16: + start, end = e.encodeValuePrimitive(Int16(int16(rv.Int()))) + return start, end, nil + case reflect.Int32: + start, end = e.encodeValuePrimitive(Int32(int32(rv.Int()))) + return start, end, nil + case reflect.Int64, reflect.Int: + start, end = e.encodeValuePrimitive(Int64(rv.Int())) + return start, end, nil + case reflect.Uint8: + start, end = e.encodeValuePrimitive(Int16(int16(rv.Uint()))) + return start, end, nil + case reflect.Uint16: + start, end = e.encodeValuePrimitive(Int32(int32(rv.Uint()))) + return start, end, nil + case reflect.Uint32: + start, end = e.encodeValuePrimitive(Int64(int64(rv.Uint()))) + return start, end, nil + case reflect.Uint64, reflect.Uint: + u := rv.Uint() + if u > math.MaxInt64 { + return 0, 0, fmt.Errorf("variant marshal: uint64 value %d overflows int64", u) + } + start, end = e.encodeValuePrimitive(Int64(int64(u))) + return start, end, nil + case reflect.Float32: + start, end = e.encodeValuePrimitive(Float(float32(rv.Float()))) + return start, end, nil + case reflect.Float64: + start, end = e.encodeValuePrimitive(Double(rv.Float())) + return start, end, nil + case reflect.String: + start, end = e.encodeValuePrimitive(String(rv.String())) + return start, end, nil + case reflect.Slice: + if rv.Type().Elem().Kind() == reflect.Uint8 { + start, end = e.encodeValuePrimitive(Binary(rv.Bytes())) + return start, end, nil + } + return e.encodeSliceArray(rv) + case reflect.Array: + // Byte arrays (including [16]byte) map to Binary. uuid.UUID is + // handled above via its concrete type; without a logical UUID + // annotation a fixed-length byte array is just bytes. + if rv.Type().Elem().Kind() == reflect.Uint8 { + b := make([]byte, rv.Len()) + for i := range b { + b[i] = byte(rv.Index(i).Uint()) + } + start, end = e.encodeValuePrimitive(Binary(b)) + return start, end, nil + } + return e.encodeSliceArray(rv) + case reflect.Map: + return e.encodeMapObject(rv) + case reflect.Struct: + return e.encodeStructObject(rv) + default: + return 0, 0, fmt.Errorf("variant marshal: unsupported type %s", rv.Type()) + } +} + +func (e *encoder) encodeSliceArray(rv reflect.Value) (start, end int, err error) { + n := rv.Len() + if n == 0 { + return e.buildArrayBytes(nil) + } + + savedStart := len(e.positions) + if cap(e.positions) < savedStart+n { + newCap := max(cap(e.positions)*2, savedStart+n) + newP := make([]elementPos, len(e.positions), newCap) + copy(newP, e.positions) + e.positions = newP + } + e.positions = e.positions[:savedStart+n] + positions := e.positions[savedStart : savedStart+n] + + for i := range n { + pStart, pEnd, err := e.encodeReflect(rv.Index(i)) + if err != nil { + e.positions = e.positions[:savedStart] + return 0, 0, err + } + positions[i] = elementPos{start: pStart, end: pEnd} + } + + resStart, resEnd, err := e.buildArrayBytes(positions) + e.positions = e.positions[:savedStart] + return resStart, resEnd, err +} + +func (e *encoder) buildArrayBytes(positions []elementPos) (start, end int, err error) { + n := len(positions) + + if testHookVerifyArrayLayout != nil { + testHookVerifyArrayLayout(e, positions) + } + + totalSize := 0 + for _, pos := range positions { + totalSize += pos.end - pos.start + } + + var offsetBuf [32]int + var offsets []int + if n+1 <= len(offsetBuf) { + offsets = offsetBuf[:n+1] + } else { + if cap(e.offsets) < n+1 { + e.offsets = make([]int, n+1) + } + offsets = e.offsets[:n+1] + } + off := 0 + for i, pos := range positions { + offsets[i] = off + off += pos.end - pos.start + } + offsets[n] = off + + offsetSzCode := offsetSizeCode(totalSize) offsetSz := offsetSize(offsetSzCode) - // Header: basic_type=2 (object), value_header encodes num_fields, field_id_size, offset_size - // Object header byte: bits 0-1 = BasicObject(2), bits 2-3 = field_id_size_minus_one, - // bits 4-5 = offset_size_minus_one, bits 6-7 = unused - // Then: num_elements (1 byte for small objects, but spec says offset_size bytes) - // - // Actually the spec says: - // value_metadata byte: bits 0-1 = basic_type (2=object), bits 2-3 = field_id_size-1, - // bits 4-5 = offset_size-1, bits 6-7 = is_large (0=1-byte num_elements, 1=4-byte) isLarge := byte(0) numElemSize := 1 if n > 255 { @@ -184,66 +569,215 @@ func encodeObject(b *MetadataBuilder, obj Object) []byte { numElemSize = 4 } - header := byte(BasicObject) | (fieldIDSizeCode << 2) | (offsetSzCode << 4) | (isLarge << 6) + header := byte(BasicArray) | (offsetSzCode << 2) | (isLarge << 4) - // Total size: header(1) + num_elements + field_ids(n*fieldIDSize) + offsets((n+1)*offsetSz) + values - totalSize := 1 + numElemSize + n*fieldIDSize + (n+1)*offsetSz + totalValueSize - buf := make([]byte, totalSize) - buf[0] = header + bufSize := 1 + numElemSize + (n+1)*offsetSz + totalSize + if cap(e.temp) < bufSize { + e.temp = make([]byte, bufSize) + } else { + e.temp = e.temp[:bufSize] + } + e.temp[0] = header - pos := 1 + posIdx := 1 if isLarge == 1 { - binary.LittleEndian.PutUint32(buf[pos:], uint32(n)) - pos += 4 + binary.LittleEndian.PutUint32(e.temp[posIdx:], uint32(n)) + posIdx += 4 } else { - buf[pos] = byte(n) - pos += 1 + e.temp[posIdx] = byte(n) + posIdx += 1 } - // Write field IDs - for _, e := range entries { - writeUint(buf[pos:], e.id, fieldIDSize) - pos += fieldIDSize + for _, o := range offsets { + writeUint(e.temp[posIdx:], o, offsetSz) + posIdx += offsetSz } - // Write offsets - for _, off := range valueOffsets { - writeUint(buf[pos:], off, offsetSz) - pos += offsetSz + for _, p := range positions { + copy(e.temp[posIdx:], e.scratch[p.start:p.end]) + posIdx += p.end - p.start } - // Write values - for _, e := range entries { - copy(buf[pos:], e.valueBytes) - pos += len(e.valueBytes) + firstStart := len(e.scratch) + if n > 0 { + firstStart = positions[0].start } + e.scratch = e.scratch[:firstStart] - return buf + start = len(e.scratch) + e.scratch = append(e.scratch, e.temp...) + end = len(e.scratch) + + return start, end, nil } -func encodeArray(b *MetadataBuilder, arr Array) []byte { - n := len(arr.Elements) +func (e *encoder) encodeMapObject(rv reflect.Value) (start, end int, err error) { + if rv.IsNil() { + start, end = e.encodeValuePrimitive(Null()) + return start, end, nil + } - // Encode all elements - encodedElems := make([][]byte, n) - totalSize := 0 - for i, e := range arr.Elements { - encodedElems[i] = Encode(b, e) - totalSize += len(encodedElems[i]) + n := rv.Len() + if n == 0 { + return e.buildObjectBytes(nil) } - // Compute offsets - offsets := make([]int, n+1) + savedStart := len(e.fields) + if cap(e.fields) < savedStart+n { + newCap := max(cap(e.fields)*2, savedStart+n) + newF := make([]encodedField, len(e.fields), newCap) + copy(newF, e.fields) + e.fields = newF + } + e.fields = e.fields[:savedStart+n] + entries := e.fields[savedStart : savedStart+n] + + iter := rv.MapRange() + idx := 0 + for iter.Next() { + key := iter.Key() + if key.Kind() != reflect.String { + e.fields = e.fields[:savedStart] + return 0, 0, fmt.Errorf("variant marshal: map key must be string, got %s", key.Type()) + } + name := key.String() + id := e.b.Add(name) + + pStart, pEnd, err := e.encodeReflect(iter.Value()) + if err != nil { + e.fields = e.fields[:savedStart] + return 0, 0, err + } + entries[idx] = encodedField{ + id: id, + name: name, + start: pStart, + end: pEnd, + } + idx++ + } + + sort.Slice(entries, func(i, j int) bool { + return entries[i].name < entries[j].name + }) + + resStart, resEnd, err := e.buildObjectBytes(entries) + e.fields = e.fields[:savedStart] + return resStart, resEnd, err +} + +func (e *encoder) encodeStructObject(rv reflect.Value) (start, end int, err error) { + rt := rv.Type() + numFields := rt.NumField() + + visibleCount := 0 + for i := range numFields { + sf := rt.Field(i) + if !sf.IsExported() { + continue + } + name := fieldName(sf) + if name == "-" { + continue + } + visibleCount++ + } + + if visibleCount == 0 { + return e.buildObjectBytes(nil) + } + + savedStart := len(e.fields) + if cap(e.fields) < savedStart+visibleCount { + newCap := max(cap(e.fields)*2, savedStart+visibleCount) + newF := make([]encodedField, len(e.fields), newCap) + copy(newF, e.fields) + e.fields = newF + } + e.fields = e.fields[:savedStart+visibleCount] + entries := e.fields[savedStart : savedStart+visibleCount] + + idx := 0 + for i := range numFields { + sf := rt.Field(i) + if !sf.IsExported() { + continue + } + name := fieldName(sf) + if name == "-" { + continue + } + + id := e.b.Add(name) + pStart, pEnd, err := e.encodeReflect(rv.Field(i)) + if err != nil { + e.fields = e.fields[:savedStart] + return 0, 0, err + } + entries[idx] = encodedField{ + id: id, + name: name, + start: pStart, + end: pEnd, + } + idx++ + } + + sort.Slice(entries, func(i, j int) bool { + return entries[i].name < entries[j].name + }) + + resStart, resEnd, err := e.buildObjectBytes(entries) + e.fields = e.fields[:savedStart] + return resStart, resEnd, err +} + +func (e *encoder) buildObjectBytes(entries []encodedField) (start, end int, err error) { + n := len(entries) + + if testHookVerifyObjectLayout != nil { + testHookVerifyObjectLayout(e, entries) + } + + maxID := 0 + totalValueSize := 0 + for _, entry := range entries { + if entry.id > maxID { + maxID = entry.id + } + totalValueSize += entry.end - entry.start + } + + var offsetBuf [32]int + var valueOffsets []int + if n+1 <= len(offsetBuf) { + valueOffsets = offsetBuf[:n+1] + } else { + if cap(e.offsets) < n+1 { + e.offsets = make([]int, n+1) + } + valueOffsets = e.offsets[:n+1] + } off := 0 - for i, enc := range encodedElems { - offsets[i] = off - off += len(enc) + for i, entry := range entries { + valueOffsets[i] = off + off += entry.end - entry.start } - offsets[n] = off + valueOffsets[n] = off - offsetSzCode := offsetSizeCode(totalSize) + fieldIDSizeCode := offsetSizeCode(maxID) + fieldIDSize := offsetSize(fieldIDSizeCode) + offsetSzCode := offsetSizeCode(totalValueSize) offsetSz := offsetSize(offsetSzCode) + // Header byte layout for objects, per the spec's value encoding grammar + // (object_header: is_large << 4 | field_id_size_minus_one << 2 | + // field_offset_size_minus_one, shifted left 2 past the basic type): + // + // bits 0-1: basic_type (2 = object) + // bits 2-3: field_offset_size_minus_one + // bits 4-5: field_id_size_minus_one + // bit 6: is_large (0 = 1-byte num_elements, 1 = 4-byte) isLarge := byte(0) numElemSize := 1 if n > 255 { @@ -251,40 +785,54 @@ func encodeArray(b *MetadataBuilder, arr Array) []byte { numElemSize = 4 } - header := byte(BasicArray) | (offsetSzCode << 2) | (isLarge << 4) + header := byte(BasicObject) | (offsetSzCode << 2) | (fieldIDSizeCode << 4) | (isLarge << 6) - // Total: header(1) + num_elements + offsets((n+1)*offsetSz) + values - bufSize := 1 + numElemSize + (n+1)*offsetSz + totalSize - buf := make([]byte, bufSize) - buf[0] = header + totalSize := 1 + numElemSize + n*fieldIDSize + (n+1)*offsetSz + totalValueSize + if cap(e.temp) < totalSize { + e.temp = make([]byte, totalSize) + } else { + e.temp = e.temp[:totalSize] + } + e.temp[0] = header pos := 1 if isLarge == 1 { - binary.LittleEndian.PutUint32(buf[pos:], uint32(n)) + binary.LittleEndian.PutUint32(e.temp[pos:], uint32(n)) pos += 4 } else { - buf[pos] = byte(n) + e.temp[pos] = byte(n) pos += 1 } - // Write offsets - for _, o := range offsets { - writeUint(buf[pos:], o, offsetSz) + for _, entry := range entries { + writeUint(e.temp[pos:], entry.id, fieldIDSize) + pos += fieldIDSize + } + + for _, offsetVal := range valueOffsets { + writeUint(e.temp[pos:], offsetVal, offsetSz) pos += offsetSz } - // Write values - for _, enc := range encodedElems { - copy(buf[pos:], enc) - pos += len(enc) + for _, entry := range entries { + copy(e.temp[pos:], e.scratch[entry.start:entry.end]) + pos += entry.end - entry.start } - return buf -} + firstStart := len(e.scratch) + if n > 0 { + firstStart = entries[0].start + for _, entry := range entries { + if entry.start < firstStart { + firstStart = entry.start + } + } + } + e.scratch = e.scratch[:firstStart] -// makeHeader constructs a value_metadata byte. -// For primitives: bits 0-1 = basic_type(0), bits 2-7 = primitive_type -// For short strings: bits 0-1 = basic_type(1), bits 2-7 = string length -func makeHeader(basic BasicType, valueHeader byte) byte { - return byte(basic) | (valueHeader << 2) + start = len(e.scratch) + e.scratch = append(e.scratch, e.temp...) + end = len(e.scratch) + + return start, end, nil } diff --git a/vendor/github.com/parquet-go/parquet-go/variant/loc.go b/vendor/github.com/parquet-go/parquet-go/variant/loc.go new file mode 100644 index 00000000000..43ab7c47700 --- /dev/null +++ b/vendor/github.com/parquet-go/parquet-go/variant/loc.go @@ -0,0 +1,50 @@ +package variant + +// Loc describes where the value of a variant path lives for one row +// (or one list element) of a columnar reader window. +type Loc uint8 + +const ( + // LocMissing means the path has no value: an enclosing level is null, + // the field is absent from its parent object, or the whole variant + // column is null for the row. + LocMissing Loc = iota + + // LocNull means the path holds the variant null value. + LocNull + + // LocTyped means the value is a scalar stored in a shredded typed_value + // column; it appears in the cursor's typed vector. + LocTyped + + // LocTypedObject means the value is an object stored (at least + // partially) in shredded form. Leftover fields of a partially shredded + // object are available through the residual. + LocTypedObject + + // LocTypedList means the value is a list stored in shredded form. + LocTypedList + + // LocResidual means the value exists only as variant binary at this + // position. + LocResidual +) + +func (l Loc) String() string { + switch l { + case LocMissing: + return "missing" + case LocNull: + return "null" + case LocTyped: + return "typed" + case LocTypedObject: + return "typed-object" + case LocTypedList: + return "typed-list" + case LocResidual: + return "residual" + default: + return "unknown" + } +} diff --git a/vendor/github.com/parquet-go/parquet-go/variant/marshal.go b/vendor/github.com/parquet-go/parquet-go/variant/marshal.go index 377c020ca98..d3fd25b9ed1 100644 --- a/vendor/github.com/parquet-go/parquet-go/variant/marshal.go +++ b/vendor/github.com/parquet-go/parquet-go/variant/marshal.go @@ -5,6 +5,7 @@ import ( "math" "reflect" "strings" + "time" "github.com/google/uuid" ) @@ -12,16 +13,30 @@ import ( // Marshal converts a Go value to variant binary encoding, returning the // metadata and value byte slices. func Marshal(v any) (metadata, value []byte, err error) { - varVal, err := goToVariant(v) + var b MetadataBuilder + enc := getEncoder(&b) + + start, end, err := enc.encodeReflect(reflect.ValueOf(v)) if err != nil { + releaseEncoder(enc) return nil, nil, err } - var b MetadataBuilder - valueBytes := Encode(&b, varVal) + valueBytes := make([]byte, end-start) + copy(valueBytes, enc.scratch[start:end]) + + releaseEncoder(enc) + _, metadataBytes := b.Build() return metadataBytes, valueBytes, nil } +// ValueOf converts a Go value to a variant Value without encoding it. It is +// useful for callers that need to inspect or partially encode the value, +// such as shredded variant writers. +func ValueOf(v any) (Value, error) { + return goToVariant(v) +} + // Unmarshal decodes variant binary data into a Go value. func Unmarshal(metadata, value []byte) (any, error) { m, err := DecodeMetadata(metadata) @@ -35,7 +50,10 @@ func Unmarshal(metadata, value []byte) (any, error) { return v.GoValue(), nil } -// goToVariant converts a Go value to a variant Value. +// goToVariant converts a Go value to a variant Value. Marshal encodes +// through the streaming encoder instead (see encodeReflect); this tree +// walk backs ValueOf, whose callers need the Value tree to make per-field +// decisions before encoding. The two must map Go types identically. func goToVariant(v any) (Value, error) { if v == nil { return Null(), nil @@ -48,7 +66,6 @@ func goToVariantReflect(rv reflect.Value) (Value, error) { return Null(), nil } - // Dereference pointers/interfaces for rv.Kind() == reflect.Ptr || rv.Kind() == reflect.Interface { if rv.IsNil() { return Null(), nil @@ -56,11 +73,15 @@ func goToVariantReflect(rv reflect.Value) (Value, error) { rv = rv.Elem() } - // Check concrete types first + // uuid.UUID and time.Time must be recognized before the Kind switch: + // uuid.UUID is a [16]byte array and time.Time a struct with no exported + // fields, so the generic cases would mishandle them. iface := rv.Interface() switch val := iface.(type) { case uuid.UUID: return UUID(val), nil + case time.Time: + return timeToVariant(val), nil } switch rv.Kind() { @@ -94,15 +115,19 @@ func goToVariantReflect(rv reflect.Value) (Value, error) { return String(rv.String()), nil case reflect.Slice: if rv.Type().Elem().Kind() == reflect.Uint8 { - // []byte return Binary(rv.Bytes()), nil } return goSliceToArray(rv) case reflect.Array: - if rv.Type() == reflect.TypeFor[uuid.UUID]() { - var u uuid.UUID - reflect.ValueOf(&u).Elem().Set(rv) - return UUID(u), nil + // Byte arrays (including [16]byte) map to Binary. uuid.UUID is + // handled above via its concrete type; without a logical UUID + // annotation a fixed-length byte array is just bytes. + if rv.Type().Elem().Kind() == reflect.Uint8 { + b := make([]byte, rv.Len()) + for i := range b { + b[i] = byte(rv.Index(i).Uint()) + } + return Binary(b), nil } return goSliceToArray(rv) case reflect.Map: @@ -168,6 +193,18 @@ func goStructToObject(rv reflect.Value) (Value, error) { return MakeObject(fields), nil } +// timeToVariant converts a time.Time to a timestamp variant value. The +// timestamp is stored with time zone (isAdjustedToUTC), which is the natural +// mapping for time.Time since it represents an instant. Nanosecond precision +// is used when the value has sub-microsecond components and fits in the +// nanosecond timestamp range; microsecond precision otherwise. +func timeToVariant(t time.Time) Value { + if t.Nanosecond()%1000 != 0 && t.Year() >= 1678 && t.Year() <= 2261 { + return TimestampNanos(t.UnixNano()) + } + return Timestamp(t.UnixMicro()) +} + // fieldName returns the name to use for a struct field, checking variant and // json struct tags. func fieldName(sf reflect.StructField) string { diff --git a/vendor/github.com/parquet-go/parquet-go/variant/metadata.go b/vendor/github.com/parquet-go/parquet-go/variant/metadata.go index 030a23adf53..99549fe3f74 100644 --- a/vendor/github.com/parquet-go/parquet-go/variant/metadata.go +++ b/vendor/github.com/parquet-go/parquet-go/variant/metadata.go @@ -4,10 +4,13 @@ import ( "encoding/binary" "errors" "fmt" - "sort" + "unicode/utf8" + "unsafe" ) // Metadata holds the decoded metadata dictionary for a variant value. +// Sorted reports whether the dictionary strings were stored in +// lexicographic order (the sorted_strings header bit). type Metadata struct { Strings []string Sorted bool @@ -17,12 +20,17 @@ type Metadata struct { // // Format: header(1) | dictionary_size(uint) | offsets(dictionary_size+1) | string_data // -// Header bits: +// Header bits (per the spec's metadata encoding grammar, +// header = version | sorted_strings << 4 | offset_size_minus_one << 6): // // 0-3: version (must be 1) -// 4: sorted_strings -// 5-6: offset_size_minus_one -// 7: reserved (must be 0) +// 4: sorted_strings +// 6-7: offset_size_minus_one +// +// Like Decode, DecodeMetadata rejects what the spec declares invalid +// (non-UTF-8 dictionary strings, sizes exceeding the data) and does not +// validate the unused header bit, per VariantEncoding.md: "Bit 5 (marked R) +// is reserved; it must be ignored by readers." func DecodeMetadata(data []byte) (Metadata, error) { if len(data) == 0 { return Metadata{}, errors.New("variant metadata: empty data") @@ -33,12 +41,9 @@ func DecodeMetadata(data []byte) (Metadata, error) { if version != 1 { return Metadata{}, fmt.Errorf("variant metadata: unsupported version %d", version) } - if header&0x80 != 0 { - return Metadata{}, errors.New("variant metadata: reserved bit is set") - } sorted := (header>>4)&1 == 1 - offsetSz := offsetSize((header >> 5) & 0x03) + offsetSz := offsetSize((header >> 6) & 0x03) pos := 1 dictSize, n, err := readUint(data[pos:], offsetSz) @@ -47,7 +52,16 @@ func DecodeMetadata(data []byte) (Metadata, error) { } pos += n - // Read (dictSize+1) offsets + // The metadata must contain at least (dictSize+1) offsets; validate + // against the input size before allocating to reject corrupt data that + // declares an absurdly large dictionary. dictSize < 0 happens only on + // 32-bit platforms, where a 4-byte size above math.MaxInt32 overflows + // int; the comparison is phrased as <= dictSize rather than + // < dictSize+1 so the addition cannot overflow the same way. + if remaining := len(data) - pos; dictSize < 0 || remaining/offsetSz <= dictSize { + return Metadata{}, fmt.Errorf("variant metadata: dictionary size %d exceeds data", dictSize) + } + offsets := make([]int, dictSize+1) for i := range offsets { v, n, err := readUint(data[pos:], offsetSz) @@ -64,9 +78,15 @@ func DecodeMetadata(data []byte) (Metadata, error) { for i := range dictSize { start := offsets[i] end := offsets[i+1] - if start > end || end > len(stringData) { + // start < 0 happens only on 32-bit platforms, where a 4-byte + // offset above math.MaxInt32 overflows int; without the check the + // slice below would panic. + if start < 0 || start > end || end > len(stringData) { return Metadata{}, fmt.Errorf("variant metadata: invalid string offset [%d, %d) in data of length %d", start, end, len(stringData)) } + if !utf8.Valid(stringData[start:end]) { + return Metadata{}, fmt.Errorf("variant metadata: dictionary string %d is not valid UTF-8", i) + } strings[i] = string(stringData[start:end]) } @@ -81,14 +101,22 @@ func (m Metadata) Lookup(id int) (string, error) { return m.Strings[id], nil } -// MetadataBuilder builds a variant metadata dictionary. +// MetadataBuilder builds a variant metadata dictionary. Field names are +// interned into a single contiguous byte buffer so a high-cardinality key +// set pays for buffer growth rather than a heap string per key. type MetadataBuilder struct { - strings []string - index map[string]int + buf []byte // concatenated dictionary strings + offs []int // start offset of each string in buf; end is offs[i+1] or len(buf) + index map[string]int + // unsorted is set when some entry compares below its predecessor; it is + // tracked incrementally by Add so encoding a large dictionary need not + // re-compare every entry. + unsorted bool } -// Add adds a string to the dictionary and returns its index. -// If the string already exists, the existing index is returned. +// Add interns s into the dictionary and returns its stable index. The +// string is copied into the builder's buffer, so callers may reuse the +// argument's backing memory after Add returns. func (b *MetadataBuilder) Add(s string) int { if b.index == nil { b.index = make(map[string]int) @@ -96,73 +124,120 @@ func (b *MetadataBuilder) Add(s string) int { if idx, ok := b.index[s]; ok { return idx } - idx := len(b.strings) - b.strings = append(b.strings, s) - b.index[s] = idx + if n := len(b.offs); n > 0 && !b.unsorted && b.stringAt(n-1) > s { + b.unsorted = true + } + start := len(b.buf) + old := unsafe.SliceData(b.buf) + b.buf = append(b.buf, s...) + idx := len(b.offs) + // Record the new start before any reindex so stringAt can bound the + // previous last entry (and this one) correctly against the grown slab. + b.offs = append(b.offs, start) + if idx > 0 && unsafe.SliceData(b.buf) != old { + b.reindex() + } else { + b.index[b.stringAt(idx)] = idx + } return idx } +// stringAt returns a view of dictionary entry i into the slab. The view is +// only valid until the next Add that grows the buffer, or Reset. +func (b *MetadataBuilder) stringAt(i int) string { + start := b.offs[i] + end := len(b.buf) + if i+1 < len(b.offs) { + end = b.offs[i+1] + } + if end == start { + return "" + } + return unsafe.String(unsafe.SliceData(b.buf[start:end]), end-start) +} + +// reindex rebuilds the lookup map after the slab has been reallocated. +func (b *MetadataBuilder) reindex() { + clear(b.index) + for i := range b.offs { + b.index[b.stringAt(i)] = i + } +} + // Build returns the decoded Metadata and the encoded binary representation. // The dictionary indices in the output match those returned by Add, so -// encoded values referencing those indices remain valid. +// encoded values referencing those indices remain valid. The returned +// Metadata owns its strings and remains valid after Reset. func (b *MetadataBuilder) Build() (Metadata, []byte) { - n := len(b.strings) - - // Check if the strings happen to be sorted - sorted := sort.StringsAreSorted(b.strings) + strs := make([]string, len(b.offs)) + for i := range b.offs { + strs[i] = string(b.stringAt(i)) // detach from the slab so Reset cannot invalidate + } + return Metadata{Strings: strs, Sorted: !b.unsorted}, b.AppendTo(nil) +} - // Compute string data and offsets - offsets := make([]int, n+1) - totalLen := 0 - for i, s := range b.strings { - offsets[i] = totalLen - totalLen += len(s) +// AppendTo appends the encoded binary representation of the dictionary to +// dst and returns the extended slice. The dictionary indices in the output +// match those returned by Add, so encoded values referencing those indices +// remain valid. +// +// The variant format encodes dictionary offsets in at most 4 bytes, so the +// interned names must total at most math.MaxUint32 bytes; callers growing +// the dictionary without bound must check Size before encoding (as +// Builder.Finish and parquet.VariantColumnWriter do). +func (b *MetadataBuilder) AppendTo(dst []byte) []byte { + n := len(b.offs) + totalLen := len(b.buf) + sortedBit := byte(0) + if !b.unsorted { + sortedBit = 1 } - offsets[n] = totalLen - // Determine offset size maxOffset := max(totalLen, n) osc := offsetSizeCode(maxOffset) offsetSz := offsetSize(osc) - // Build the binary blob - // header(1) + dict_size(offsetSz) + offsets((n+1)*offsetSz) + string_data(totalLen) + // Layout: header(1) + dict_size(offsetSz) + offsets((n+1)*offsetSz) + + // string_data(totalLen). size := 1 + offsetSz + (n+1)*offsetSz + totalLen - buf := make([]byte, size) + base := len(dst) + dst = append(dst, make([]byte, size)...) + out := dst[base:] - // Header: version=1, sorted_strings flag, offset_size_minus_one - sortedBit := byte(0) - if sorted { - sortedBit = 1 - } - buf[0] = 1 | (sortedBit << 4) | (osc << 5) + // Header: version=1, sorted_strings flag at bit 4, offset_size_minus_one + // at bits 6-7 (per the spec's metadata encoding grammar). + out[0] = 1 | (sortedBit << 4) | (osc << 6) pos := 1 - writeUint(buf[pos:], n, offsetSz) + writeUint(out[pos:], n, offsetSz) pos += offsetSz - for _, off := range offsets { - writeUint(buf[pos:], off, offsetSz) + for _, off := range b.offs { + writeUint(out[pos:], off, offsetSz) pos += offsetSz } + writeUint(out[pos:], totalLen, offsetSz) + pos += offsetSz - for _, s := range b.strings { - copy(buf[pos:], s) - pos += len(s) - } - - return Metadata{Strings: b.strings, Sorted: sorted}, buf + copy(out[pos:], b.buf) + return dst } -// Reset clears the builder for reuse. +// Size returns the total number of bytes of interned dictionary strings. +func (b *MetadataBuilder) Size() int { return len(b.buf) } + +// Reset clears the builder for reuse, retaining the string buffer's capacity. func (b *MetadataBuilder) Reset() { - b.strings = b.strings[:0] - for k := range b.index { - delete(b.index, k) - } + b.buf = b.buf[:0] + b.offs = b.offs[:0] + b.unsorted = false + clear(b.index) } -// readUint reads an unsigned integer of the given byte width from data. +// readUint reads an unsigned integer of the given byte width from data. Note +// that on 32-bit platforms a 4-byte value above math.MaxInt32 overflows int +// and is returned negative; callers validating sizes and offsets against the +// input must guard against negative results before using them. func readUint(data []byte, size int) (int, int, error) { if len(data) < size { return 0, 0, errors.New("not enough data") diff --git a/vendor/github.com/parquet-go/parquet-go/variant/types.go b/vendor/github.com/parquet-go/parquet-go/variant/types.go index 7e1f76a68ca..70f2746076b 100644 --- a/vendor/github.com/parquet-go/parquet-go/variant/types.go +++ b/vendor/github.com/parquet-go/parquet-go/variant/types.go @@ -15,25 +15,27 @@ const ( type PrimitiveType byte const ( - PrimitiveNull PrimitiveType = 0 - PrimitiveTrue PrimitiveType = 1 - PrimitiveFalse PrimitiveType = 2 - PrimitiveInt8 PrimitiveType = 3 - PrimitiveInt16 PrimitiveType = 4 - PrimitiveInt32 PrimitiveType = 5 - PrimitiveInt64 PrimitiveType = 6 - PrimitiveDouble PrimitiveType = 7 - PrimitiveDecimal4 PrimitiveType = 8 - PrimitiveDecimal8 PrimitiveType = 9 - PrimitiveDecimal16 PrimitiveType = 10 - PrimitiveDate PrimitiveType = 11 - PrimitiveTimestamp PrimitiveType = 12 - PrimitiveTimestampNTZ PrimitiveType = 13 - PrimitiveFloat PrimitiveType = 14 - PrimitiveBinary PrimitiveType = 15 - PrimitiveString PrimitiveType = 16 - PrimitiveTime PrimitiveType = 17 - PrimitiveUUID PrimitiveType = 20 + PrimitiveNull PrimitiveType = 0 + PrimitiveTrue PrimitiveType = 1 + PrimitiveFalse PrimitiveType = 2 + PrimitiveInt8 PrimitiveType = 3 + PrimitiveInt16 PrimitiveType = 4 + PrimitiveInt32 PrimitiveType = 5 + PrimitiveInt64 PrimitiveType = 6 + PrimitiveDouble PrimitiveType = 7 + PrimitiveDecimal4 PrimitiveType = 8 + PrimitiveDecimal8 PrimitiveType = 9 + PrimitiveDecimal16 PrimitiveType = 10 + PrimitiveDate PrimitiveType = 11 + PrimitiveTimestamp PrimitiveType = 12 + PrimitiveTimestampNTZ PrimitiveType = 13 + PrimitiveFloat PrimitiveType = 14 + PrimitiveBinary PrimitiveType = 15 + PrimitiveString PrimitiveType = 16 + PrimitiveTime PrimitiveType = 17 + PrimitiveTimestampNanos PrimitiveType = 18 + PrimitiveTimestampNTZNanos PrimitiveType = 19 + PrimitiveUUID PrimitiveType = 20 ) // primitiveSize returns the byte size of a primitive value's data portion, @@ -48,7 +50,8 @@ func primitiveSize(p PrimitiveType) int { return 2 case PrimitiveInt32, PrimitiveFloat, PrimitiveDate: return 4 - case PrimitiveInt64, PrimitiveDouble, PrimitiveTimestamp, PrimitiveTimestampNTZ, PrimitiveTime: + case PrimitiveInt64, PrimitiveDouble, PrimitiveTimestamp, PrimitiveTimestampNTZ, PrimitiveTime, + PrimitiveTimestampNanos, PrimitiveTimestampNTZNanos: return 8 case PrimitiveDecimal4: return 5 // 1 scale + 4 value diff --git a/vendor/github.com/parquet-go/parquet-go/variant/value.go b/vendor/github.com/parquet-go/parquet-go/variant/value.go index 26611874848..e52aaf8f443 100644 --- a/vendor/github.com/parquet-go/parquet-go/variant/value.go +++ b/vendor/github.com/parquet-go/parquet-go/variant/value.go @@ -2,6 +2,7 @@ package variant import ( "math" + "time" "github.com/google/uuid" ) @@ -111,6 +112,17 @@ func Time(v int64) Value { return Value{basic: BasicPrimitive, primitive: PrimitiveTime, i64: v} } +// TimestampNanos returns a timestamp variant value (nanoseconds since epoch, UTC). +func TimestampNanos(v int64) Value { + return Value{basic: BasicPrimitive, primitive: PrimitiveTimestampNanos, i64: v} +} + +// TimestampNTZNanos returns a timestamp without timezone variant value +// (nanoseconds since epoch). +func TimestampNTZNanos(v int64) Value { + return Value{basic: BasicPrimitive, primitive: PrimitiveTimestampNTZNanos, i64: v} +} + // UUID returns a UUID variant value. func UUID(v uuid.UUID) Value { return Value{basic: BasicPrimitive, primitive: PrimitiveUUID, uuid: v} @@ -224,7 +236,10 @@ func (v Value) ArrayValue() Array { // Float → float32, Double → float64 // String → string, Binary → []byte // Date → int32 (days since epoch) -// Timestamp/TimestampNTZ → int64 (microseconds since epoch) +// Timestamp/TimestampNanos → time.Time (UTC) +// TimestampNTZ/TimestampNTZNanos → int64 (microseconds/nanoseconds since +// epoch; these have no time zone, so no time.Time instant exists for +// them) // Time → int64 (microseconds since midnight) // UUID → uuid.UUID // Decimal4 → int32 (unscaled), Decimal8 → int64 (unscaled), Decimal16 → [16]byte @@ -273,7 +288,11 @@ func (v Value) GoValue() any { return v.bytes case PrimitiveDate: return int32(v.i64) - case PrimitiveTimestamp, PrimitiveTimestampNTZ, PrimitiveTime: + case PrimitiveTimestamp: + return time.UnixMicro(v.i64).UTC() + case PrimitiveTimestampNanos: + return time.Unix(0, v.i64).UTC() + case PrimitiveTimestampNTZ, PrimitiveTimestampNTZNanos, PrimitiveTime: return v.i64 case PrimitiveUUID: return v.uuid @@ -288,8 +307,11 @@ func (v Value) GoValue() any { } } -// Equal reports whether two variant values are deeply equal. -// Short strings and primitive strings with the same content are considered equal. +// Equal reports whether two variant values are structurally equal: the same +// value with the same primitive type. Object fields are compared without +// regard to order, short strings and primitive strings with the same content +// are considered equal, and floating-point values are compared bitwise (NaN +// equals NaN, negative zero does not equal positive zero). func (v Value) Equal(other Value) bool { // Normalize: treat short strings and primitive strings as equivalent if v.isString() && other.isString() { @@ -300,12 +322,22 @@ func (v Value) Equal(other Value) bool { } switch v.basic { case BasicObject: + // Objects are unordered collections of named fields: two objects + // with the same fields in different order are equal. The encoded + // form sorts field IDs by name regardless of construction order — + // VariantEncoding.md: "The field values are not required to be in + // the same order as the field IDs, to enable flexibility when + // constructing Variant values." if len(v.object.Fields) != len(other.object.Fields) { return false } - for i, f := range v.object.Fields { - of := other.object.Fields[i] - if f.Name != of.Name || !f.Value.Equal(of.Value) { + otherByName := make(map[string]Value, len(other.object.Fields)) + for _, f := range other.object.Fields { + otherByName[f.Name] = f.Value + } + for _, f := range v.object.Fields { + ov, ok := otherByName[f.Name] + if !ok || !f.Value.Equal(ov) { return false } } diff --git a/vendor/github.com/parquet-go/parquet-go/variant_column_reader.go b/vendor/github.com/parquet-go/parquet-go/variant_column_reader.go new file mode 100644 index 00000000000..47b982015b0 --- /dev/null +++ b/vendor/github.com/parquet-go/parquet-go/variant_column_reader.go @@ -0,0 +1,1588 @@ +package parquet + +import ( + "fmt" + "io" + "slices" + "strings" + + "github.com/parquet-go/parquet-go/variant" +) + +// This file implements a columnar, cursor-based reader for VARIANT columns. +// +// Unlike the reconstruction path in variant_shredded_read.go — which rebuilds +// one variant.Value tree per row — VariantReader exposes the shredded layout +// of the file directly: every position in the shredding tree is a +// (typed_value, value) pair where at most one side is populated per row, and +// the API surfaces that duality as typed vectors plus a per-row location tag. +// A query engine evaluating a path expression such as $.a.b over a column +// shredded as INT64 runs a plain vector loop over Int64s()/Locs(), and only +// falls back to per-row work for rows where the value exists as residual +// variant binary. +// +// Navigation is total: a cursor exists for every path, whether or not the +// writer shredded it. Below a non-shredded position, cursors are backed by +// navigation of the nearest shredded ancestor's residual bytes, so location +// tags remain accurate through residuals: LocMissing means the path is +// missing even after looking inside ancestor residual values, and a type +// conflict anywhere along the path (a scalar where an object was shredded, a +// list where a scalar was expected) simply surfaces as variant.LocResidual +// with the residual value already navigated to the requested position. + +// VariantCursorKind is the static (schema-derived) kind of a cursor +// position. It tells the engine which access pattern the position supports; +// the per-row runtime disposition is in Locs. +type VariantCursorKind uint8 + +const ( + // VariantCursorUnshredded is a position with no typed_value column: + // either the schema stores only variant binary here, or the cursor + // navigates below the shredded schema entirely. All present values are + // variant.LocNull or variant.LocResidual. + VariantCursorUnshredded VariantCursorKind = iota + + // VariantCursorLeaf is a position shredded as a primitive type; typed + // values are read from the typed vector accessors. + VariantCursorLeaf + + // VariantCursorObject is a position shredded as an object; descend into + // shredded fields with Field. + VariantCursorObject + + // VariantCursorList is a position shredded as a list; descend with + // Elements and use ListOffsets. + VariantCursorList +) + +func (k VariantCursorKind) String() string { + switch k { + case VariantCursorUnshredded: + return "unshredded" + case VariantCursorLeaf: + return "leaf" + case VariantCursorObject: + return "object" + case VariantCursorList: + return "list" + default: + return "unknown" + } +} + +// VariantReader reads one VARIANT column of a row group in columnar form. +// +// All cursors created from a reader share one row window, advanced with +// Next. Vectors and residual views returned by cursors are valid until the +// next call to Next or SeekToRow. +// +// Only the columns reachable from cursors that have been created are read: +// creating cursors is how an engine declares projection. Cursors may be +// created at any time; cursors created after a call to Next take effect on +// the following call. +type VariantReader struct { + rowGroup RowGroup + group *shreddedVariantGroup + groupDef int // definition level at which the variant group is present + baseColumn int // first leaf column of the variant group + numRows int64 + rowOffset int64 + leafInfo []variantLeafInfo + leaves []*variantLeafReader // lazily created, indexed by relative column + metaLeaf *variantLeafReader + root *VariantCursor + metaCache map[string]variant.Metadata + leafSet map[*variantLeafReader]struct{} // reused by Next + err error + + // rootValueRequired is set for plain unshredded variant groups, whose + // value field is required rather than optional. + rootValueRequired bool +} + +// unshreddedVariantGroupOf recognizes the plain unshredded variant group +// shape (required binary metadata and required binary value, nothing else) +// and returns its reconstruction tree. Groups with an optional value field +// are handled by buildShreddedVariantGroup instead. +func unshreddedVariantGroupOf(node Node) (*shreddedVariantGroup, bool) { + g := &shreddedVariantGroup{metadataCol: -1, valueCol: -1} + col := 0 + for _, f := range node.Fields() { + if !f.Leaf() || f.Type().Kind() != ByteArray || f.Repeated() { + return nil, false + } + switch f.Name() { + case "metadata": + if f.Optional() { + return nil, false + } + g.metadataCol = col + case "value": + if f.Optional() { + // An optional value with no typed_value is handled by + // buildShreddedVariantGroup; this recognizer exists for + // the required-value shape it rejects. + return nil, false + } + g.valueCol = col + default: + return nil, false + } + col++ + } + if g.metadataCol < 0 || g.valueCol < 0 { + return nil, false + } + g.numCols = col + return g, true +} + +type variantLeafInfo struct { + typ Type + maxDef byte + maxRep byte +} + +// variantColumnInfo is the result of resolving a variant column path in a +// schema, shared by NewVariantReader and NewVariantColumnWriter. +type variantColumnInfo struct { + node Node + group *shreddedVariantGroup + valueRequired bool // plain unshredded shape (required binary value) + col int // first leaf column of the variant group + def int // definition level at which the group is present + optional bool // whether the group node itself is optional +} + +// variantGroupOf builds the shredding tree of a variant group node, +// accepting both the shredded shapes (optional value) and the plain +// unshredded shape (required value) that VariantEncoding.md declares. The +// boolean result reports the latter. +func variantGroupOf(node Node) (*shreddedVariantGroup, bool, error) { + g, err := buildShreddedVariantGroup(node, 0, 0, 0) + if err != nil { + if u, ok := unshreddedVariantGroupOf(node); ok { + return u, true, nil + } + return nil, false, err + } + if g.metadataCol < 0 { + return nil, false, fmt.Errorf("variant: variant group has no metadata field") + } + return g, false, nil +} + +// resolveVariantColumn walks the schema to the variant group node named by +// path and builds its shredding tree. +func resolveVariantColumn(schema Node, path []string) (info variantColumnInfo, err error) { + if len(path) == 0 { + return info, fmt.Errorf("variant: a column path is required") + } + node := schema + for _, name := range path { + if node.Leaf() { + return info, fmt.Errorf("variant: column %q not found: %q is a leaf", joinPath(path), name) + } + var next Node + for _, f := range node.Fields() { + if f.Name() == name { + next = f + break + } + info.col += int(numLeafColumnsOf(f)) + } + if next == nil { + return info, fmt.Errorf("variant: column %q not found: no field %q", joinPath(path), name) + } + if next.Repeated() { + return info, fmt.Errorf("variant: column %q is beneath a repeated field, which the columnar variant APIs do not support", joinPath(path)) + } + info.optional = next.Optional() + if info.optional { + info.def++ + } + node = next + } + if node.Leaf() { + return info, fmt.Errorf("variant: column %q is not a variant group", joinPath(path)) + } + info.node = node + info.group, info.valueRequired, err = variantGroupOf(node) + if err != nil { + return info, fmt.Errorf("variant: column %q: %w", joinPath(path), err) + } + return info, nil +} + +// NewVariantReader creates a reader for the variant column at the given path +// in the row group. The path names the variant group node in the schema +// (e.g. "event" for a top-level column, "attrs", "v" for a nested one). The +// column may be unshredded (metadata, value) or shredded (metadata, value, +// typed_value) in any shape permitted by the Variant Shredding +// specification. +func NewVariantReader(rowGroup RowGroup, path ...string) (*VariantReader, error) { + info, err := resolveVariantColumn(rowGroup.Schema(), path) + if err != nil { + return nil, err + } + group, node := info.group, info.node + + r := &VariantReader{ + rowGroup: rowGroup, + group: group, + groupDef: info.def, + baseColumn: info.col, + numRows: rowGroup.NumRows(), + leafInfo: make([]variantLeafInfo, group.numCols), + leaves: make([]*variantLeafReader, group.numCols), + metaCache: make(map[string]variant.Metadata), + + rootValueRequired: info.valueRequired, + } + + // Types in leaf order; the traversal order matches the column numbering + // of buildShreddedVariantGroup (both walk Fields() depth-first). + i := 0 + forEachLeafColumnOf(node, func(leaf leafColumn) { + if i < len(r.leafInfo) { + r.leafInfo[i].typ = leaf.node.Type() + } + i++ + }) + if i != group.numCols { + return nil, fmt.Errorf("variant: column %q has %d leaves but the shredded group spans %d", joinPath(path), i, group.numCols) + } + r.fillLeafLevels(group) + + for _, li := range r.leafInfo { + switch li.typ.Kind() { + case Boolean, Int32, Int64, Float, Double, ByteArray, FixedLenByteArray: + default: + return nil, fmt.Errorf("variant: unsupported leaf type %s in shredded variant group", li.typ) + } + } + + r.metaLeaf = r.leafFor(group.metadataCol) + r.root = r.newNodeCursor(nil, group, "", false) + return r, nil +} + +func joinPath(path []string) string { + return strings.Join(path, ".") +} + +// fillLeafLevels computes the absolute max definition and repetition level +// of every leaf column of the variant subtree from the shredding tree. +func (r *VariantReader) fillLeafLevels(g *shreddedVariantGroup) { + if g.metadataCol >= 0 { + r.leafInfo[g.metadataCol].maxDef = byte(r.groupDef + g.defLevel) + r.leafInfo[g.metadataCol].maxRep = byte(g.repDepth) + } + if g.valueCol >= 0 { + valueDef := r.groupDef + g.defLevel + 1 + if g == r.group && r.rootValueRequired { + valueDef = r.groupDef + } + r.leafInfo[g.valueCol].maxDef = byte(valueDef) + r.leafInfo[g.valueCol].maxRep = byte(g.repDepth) + } + if t := g.typed; t != nil { + switch t.kind { + case shreddedTypedPrimitive: + r.leafInfo[t.startCol].maxDef = byte(r.groupDef + t.defLevel) + r.leafInfo[t.startCol].maxRep = byte(g.repDepth) + case shreddedTypedList: + r.fillLeafLevels(t.element) + case shreddedTypedObject: + for _, f := range t.fields { + r.fillLeafLevels(f.group) + } + } + } +} + +func (r *VariantReader) leafFor(relCol int) *variantLeafReader { + if l := r.leaves[relCol]; l != nil { + return l + } + info := r.leafInfo[relCol] + l := &variantLeafReader{ + reader: r, + relCol: relCol, + typ: info.typ, + kind: info.typ.Kind(), + maxDef: info.maxDef, + maxRep: info.maxRep, + pendingSeek: -1, + } + r.leaves[relCol] = l + return l +} + +// Root returns the cursor for the variant value itself. +func (r *VariantReader) Root() *VariantCursor { return r.root } + +// Path returns the cursor for the object field path below the root, +// equivalent to chaining Field calls. +func (r *VariantReader) Path(path ...string) *VariantCursor { + c := r.root + for _, name := range path { + c = c.Field(name) + } + return c +} + +// NumRows returns the number of rows of the row group. +func (r *VariantReader) NumRows() int64 { return r.numRows } + +// Next advances the shared row window by up to n rows and recomputes the +// window state of every cursor. It returns the number of rows in the new +// window, or (0, io.EOF) when the row group is exhausted. +func (r *VariantReader) Next(n int) (int, error) { + if r.err != nil { + return 0, r.err + } + if n <= 0 { + return 0, nil + } + remaining := r.numRows - r.rowOffset + if remaining <= 0 { + return 0, io.EOF + } + if int64(n) > remaining { + n = int(remaining) + } + if r.leafSet == nil { + r.leafSet = make(map[*variantLeafReader]struct{}) + } + clear(r.leafSet) + r.collectLeaves(r.root, r.leafSet) + for l := range r.leafSet { + if err := l.readWindow(n); err != nil { + r.err = err + return 0, err + } + } + if err := r.root.process(n); err != nil { + r.err = err + return 0, err + } + r.rowOffset += int64(n) + return n, nil +} + +func (r *VariantReader) collectLeaves(c *VariantCursor, seen map[*variantLeafReader]struct{}) { + if c == r.root { + seen[r.metaLeaf] = struct{}{} + } + for _, l := range [...]*variantLeafReader{c.valueLeaf, c.typedLeaf, c.presenceLeaf} { + if l != nil { + seen[l] = struct{}{} + } + } + for _, ch := range c.childList { + r.collectLeaves(ch, seen) + } +} + +// SeekToRow positions the reader such that the next call to Next starts at +// the given row of the row group. +func (r *VariantReader) SeekToRow(rowIndex int64) error { + if r.err != nil { + return r.err + } + if rowIndex < 0 || rowIndex > r.numRows { + return fmt.Errorf("variant: seek to row %d out of range [0, %d]", rowIndex, r.numRows) + } + r.rowOffset = rowIndex + for _, l := range r.leaves { + if l != nil && l.opened { + l.pendingSeek = rowIndex + } + } + return nil +} + +// Close releases the page readers of all columns opened by the reader. +func (r *VariantReader) Close() error { + var firstErr error + for _, l := range r.leaves { + if l == nil || !l.opened { + continue + } + if l.page != nil { + Release(l.page) + l.page = nil + } + if err := l.pages.Close(); err != nil && firstErr == nil { + firstErr = err + } + l.opened = false + } + return firstErr +} + +func (r *VariantReader) metadataFor(row int32) (variant.Metadata, error) { + w := &r.metaLeaf.win + d := w.denseIdx[row] + if d < 0 { + return variant.Metadata{}, fmt.Errorf("variant: missing metadata for window row %d", row) + } + b := w.slab[w.offsets[d]:w.offsets[d+1]] + if m, ok := r.metaCache[string(b)]; ok { + return m, nil + } + m, err := variant.DecodeMetadata(b) + if err != nil { + return variant.Metadata{}, fmt.Errorf("variant metadata: %w", err) + } + // The cache key copies the bytes (they alias the window slab); cap the + // cache so files with per-row unique metadata do not grow it unboundedly. + if len(r.metaCache) < 4096 { + r.metaCache[string(b)] = m + } + return m, nil +} + +// VariantCursor is a position in the variant navigation tree: the root +// value, an object field, or a list element. See VariantReader. +type VariantCursor struct { + reader *VariantReader + parent *VariantCursor + node *shreddedVariantGroup // nil for cursors below the shredded schema + kind VariantCursorKind + + fieldName string // step from parent, for field cursors + isElements bool // step from parent, for element cursors + + depth int // repetition depth within the variant subtree + + valueLeaf *variantLeafReader + typedLeaf *variantLeafReader // primitive typed_value + presenceLeaf *variantLeafReader // first leaf under an object/list typed_value + valueMaxDef byte + typedMaxDef byte + typedDefAbs byte // definition level at which typed_value is present + elemsDefAbs byte // definition level at which a typed list has elements + + children map[string]*VariantCursor + childList []*VariantCursor + elemsCursor *VariantCursor + hasVirtualChild bool + + // Window state. All slices are indexed by entry: one entry per row for + // row-level cursors, one per list element for element cursors. + // + // Residual state is stored sparsely: entries holding residual bytes or + // values are rare in shredded-heavy data, and per-entry storage of a + // variant.Value (144 bytes) plus a byte-slice header dominated the + // reader's memory footprint and window-reset cost. + identityRows bool // entry i is row i; rows stays nil + identitySlots bool // entry i is slot group i; slotGroup stays nil + locs []variant.Loc + slotGroup []int32 // slot group in this node's own columns, -1 if none + rows []int32 // window row of each entry, nil means identity + res []variantResidual // residual state of tagged entries, ascending by entry + typedRows []int32 + listOffsets []int32 + residualCount int +} + +// variantResidual is the residual state of one entry: the raw bytes from the +// value column (nil for navigated entries, which are born decoded) and the +// lazily decoded value. +type variantResidual struct { + bytes []byte + val variant.Value + entry int32 + decoded bool +} + +func (r *VariantReader) newNodeCursor(parent *VariantCursor, node *shreddedVariantGroup, name string, elements bool) *VariantCursor { + c := &VariantCursor{ + reader: r, + parent: parent, + node: node, + fieldName: name, + isElements: elements, + depth: node.repDepth, + children: make(map[string]*VariantCursor), + } + c.identityRows = parent == nil || (!elements && parent.identityRows) + c.identitySlots = parent == nil || (!elements && parent.identitySlots) + if node.valueCol >= 0 { + c.valueLeaf = r.leafFor(node.valueCol) + c.valueMaxDef = r.leafInfo[node.valueCol].maxDef + } + if t := node.typed; t != nil { + c.typedDefAbs = byte(r.groupDef + t.defLevel) + switch t.kind { + case shreddedTypedPrimitive: + c.kind = VariantCursorLeaf + c.typedLeaf = r.leafFor(t.startCol) + c.typedMaxDef = byte(r.groupDef + t.defLevel) + case shreddedTypedObject: + c.kind = VariantCursorObject + c.presenceLeaf = r.leafFor(t.startCol) + case shreddedTypedList: + c.kind = VariantCursorList + c.presenceLeaf = r.leafFor(t.startCol) + c.elemsDefAbs = byte(r.groupDef + t.defLevel + 1) + } + } else { + c.kind = VariantCursorUnshredded + } + return c +} + +func (r *VariantReader) newVirtualCursor(parent *VariantCursor, name string, elements bool) *VariantCursor { + return &VariantCursor{ + reader: r, + parent: parent, + kind: VariantCursorUnshredded, + fieldName: name, + isElements: elements, + depth: parent.depth, + children: make(map[string]*VariantCursor), + identityRows: !elements && parent.identityRows, + // Virtual cursors have no columns of their own, so their slot + // groups are never read; leaving identitySlots set skips the + // per-entry slotGroup appends. + identitySlots: true, + } +} + +// Kind returns the static kind of the cursor position, derived from the +// shredded schema. +func (c *VariantCursor) Kind() VariantCursorKind { return c.kind } + +// LeafType returns the parquet type of the typed_value column for cursors of +// kind VariantCursorLeaf, and nil otherwise. The type's logical type +// identifies the variant type per the shredded types table (e.g. a +// STRING-annotated BYTE_ARRAY holds variant strings). +func (c *VariantCursor) LeafType() Type { + if c.typedLeaf != nil { + return c.typedLeaf.typ + } + return nil +} + +// Fields returns the names of the shredded fields at a cursor of kind +// VariantCursorObject, in schema order, and nil for other kinds. Residual +// fields of partially shredded objects are not listed; they are reached +// through Residual (or by name through Field). +func (c *VariantCursor) Fields() []string { + if c.node == nil || c.node.typed == nil || c.node.typed.kind != shreddedTypedObject { + return nil + } + names := make([]string, len(c.node.typed.fields)) + for i, f := range c.node.typed.fields { + names[i] = f.name + } + return names +} + +// Field returns the cursor for the object field with the given name below +// this cursor. Navigation is total: if the field is not part of the shredded +// schema at this position, the returned cursor is backed by per-row +// navigation of residual values. +func (c *VariantCursor) Field(name string) *VariantCursor { + if ch := c.children[name]; ch != nil { + return ch + } + var ch *VariantCursor + if c.node != nil && c.node.typed != nil && c.node.typed.kind == shreddedTypedObject { + if g := c.node.typed.fieldByName(name); g != nil { + ch = c.reader.newNodeCursor(c, g, name, false) + } + } + if ch == nil { + ch = c.reader.newVirtualCursor(c, name, false) + c.hasVirtualChild = true + } + c.children[name] = ch + c.childList = append(c.childList, ch) + return ch +} + +// Elements returns the cursor for the elements of lists at this position. +// The element entry space concatenates, in row order, the elements of typed +// (shredded) lists and the elements of residual values that turn out to be +// arrays, so an engine can process mixed shredded/residual lists in one +// loop. ListOffsets on this cursor maps entries to element ranges. +func (c *VariantCursor) Elements() *VariantCursor { + if c.elemsCursor != nil { + return c.elemsCursor + } + var ch *VariantCursor + if c.node != nil && c.node.typed != nil && c.node.typed.kind == shreddedTypedList { + ch = c.reader.newNodeCursor(c, c.node.typed.element, "", true) + } else { + ch = c.reader.newVirtualCursor(c, "", true) + c.hasVirtualChild = true + } + c.elemsCursor = ch + c.childList = append(c.childList, ch) + return ch +} + +// Locs returns the location tag of every entry of the current window: one +// per row for row-level cursors, one per element for element cursors. +func (c *VariantCursor) Locs() []variant.Loc { return c.locs } + +// Rows maps each entry of the current window to its row index within the +// window. For row-level cursors the mapping is the identity and Rows returns +// nil; for element cursors (and cursors below them) it returns one row index +// per entry, and several entries may map to one row. +func (c *VariantCursor) Rows() []int32 { return c.rows } + +// ResidualCount returns the number of entries tagged variant.LocResidual in +// the current window. A zero count lets an engine skip per-entry residual +// decoding, though Residual may still return values for entries tagged +// variant.LocNull or variant.LocTypedObject (partial-object leftovers). +func (c *VariantCursor) ResidualCount() int { return c.residualCount } + +// TypedRows maps each value of the typed vectors to its entry index in the +// current window: TypedRows()[i] is the entry holding the i-th typed value. +func (c *VariantCursor) TypedRows() []int32 { return c.typedRows } + +// Booleans returns the dense typed values of a BOOLEAN leaf cursor. +func (c *VariantCursor) Booleans() []bool { + if c.typedLeaf == nil { + return nil + } + return c.typedLeaf.win.bools +} + +// Int32s returns the dense typed values of an INT32-backed leaf cursor +// (int8, int16, int32, date, and decimal4 variant types). +func (c *VariantCursor) Int32s() []int32 { + if c.typedLeaf == nil { + return nil + } + return c.typedLeaf.win.i32 +} + +// Int64s returns the dense typed values of an INT64-backed leaf cursor +// (int64, timestamps, time, and decimal8 variant types). +func (c *VariantCursor) Int64s() []int64 { + if c.typedLeaf == nil { + return nil + } + return c.typedLeaf.win.i64 +} + +// Floats returns the dense typed values of a FLOAT leaf cursor. +func (c *VariantCursor) Floats() []float32 { + if c.typedLeaf == nil { + return nil + } + return c.typedLeaf.win.f32 +} + +// Doubles returns the dense typed values of a DOUBLE leaf cursor. +func (c *VariantCursor) Doubles() []float64 { + if c.typedLeaf == nil { + return nil + } + return c.typedLeaf.win.f64 +} + +// ByteArrays returns the dense typed values of a BYTE_ARRAY-backed leaf +// cursor (string, binary, and byte-array decimal variant types) as a shared +// slab plus len+1 offsets: value i is slab[offsets[i]:offsets[i+1]]. +func (c *VariantCursor) ByteArrays() (slab []byte, offsets []uint32) { + if c.typedLeaf == nil { + return nil, nil + } + return c.typedLeaf.win.slab, c.typedLeaf.win.offsets +} + +// FixedLenByteArrays returns the dense typed values of a +// FIXED_LEN_BYTE_ARRAY-backed leaf cursor (uuid and fixed decimal variant +// types) as a shared slab of size-byte values. +func (c *VariantCursor) FixedLenByteArrays() (slab []byte, size int) { + if c.typedLeaf == nil { + return nil, 0 + } + return c.typedLeaf.win.flba, c.typedLeaf.win.flbaSize +} + +// ListOffsets returns len(entries)+1 offsets into the entry space of the +// Elements cursor: the elements of entry e span +// Elements() entries [offsets[e], offsets[e+1]). It is computed only when +// Elements was called before the window was read. +func (c *VariantCursor) ListOffsets() []int32 { return c.listOffsets } + +// Residual returns the residual variant value of entry i. It is valid for +// entries tagged variant.LocResidual (the value itself), variant.LocNull (the +// variant null value), and variant.LocTypedObject when the row is a partially +// shredded object (the leftover fields not covered by the shredded schema, +// as a variant object). The boolean result reports whether a residual value +// exists at the entry. +func (c *VariantCursor) Residual(i int) (variant.Value, bool, error) { + if i < 0 || i >= len(c.locs) { + return variant.Null(), false, fmt.Errorf("variant: residual index %d out of range", i) + } + switch c.locs[i] { + case variant.LocNull: + return variant.Null(), true, nil + case variant.LocResidual, variant.LocTypedObject: + r := c.residualAt(i) + if r == nil { + return variant.Null(), false, nil + } + if r.decoded { + return r.val, true, nil + } + v, err := c.decodeResidual(r) + if err != nil { + return variant.Null(), false, err + } + return v, true, nil + default: + return variant.Null(), false, nil + } +} + +// residualAt returns the residual state of entry e, or nil if the entry has +// none. res is sorted by entry (windows are built in entry order). +func (c *VariantCursor) residualAt(e int) *variantResidual { + i, ok := slices.BinarySearchFunc(c.res, int32(e), func(r variantResidual, e int32) int { + return int(r.entry) - int(e) + }) + if !ok { + return nil + } + return &c.res[i] +} + +// addResidual appends residual state for entry e, which must be greater than +// the entry of any state added to this window before it. The pointer is +// valid only until the next call to addResidual. +func (c *VariantCursor) addResidual(e int) *variantResidual { + c.res = append(c.res, variantResidual{entry: int32(e)}) + return &c.res[len(c.res)-1] +} + +func (c *VariantCursor) decodeResidual(r *variantResidual) (variant.Value, error) { + m, err := c.reader.metadataFor(c.rowOf(int(r.entry))) + if err != nil { + return variant.Null(), err + } + v, err := variant.Decode(m, r.bytes) + if err != nil { + return variant.Null(), fmt.Errorf("variant: decoding residual value: %w", err) + } + r.val = v + r.decoded = true + return v, nil +} + +func (c *VariantCursor) rowOf(i int) int32 { + if c.rows == nil { + return int32(i) + } + return c.rows[i] +} + +// resetWindow clears the per-window state, retaining slice capacity. The +// residual entries are cleared so that references to window slabs and +// decoded values do not outlive the window. +func (c *VariantCursor) resetWindow() { + c.locs = c.locs[:0] + c.slotGroup = c.slotGroup[:0] + c.rows = c.rows[:0] + clear(c.res) + c.res = c.res[:0] + c.typedRows = c.typedRows[:0] + c.listOffsets = c.listOffsets[:0] + c.residualCount = 0 +} + +// growEntries bulk-extends the window to n entries, all tagged +// variant.LocMissing, for the flat window paths that fill locs in place. +func (c *VariantCursor) growEntries(n int) { + c.locs = slices.Grow(c.locs, n)[:n] + clear(c.locs) +} + +func (c *VariantCursor) appendEntry(group, row int32) int { + c.locs = append(c.locs, variant.LocMissing) + if !c.identitySlots { + c.slotGroup = append(c.slotGroup, group) + } + if !c.identityRows { + c.rows = append(c.rows, row) + } + return len(c.locs) - 1 +} + +// groupOf returns the slot group of entry e in this node's own columns. +func (c *VariantCursor) groupOf(e int) int32 { + if c.identitySlots { + return int32(e) + } + return c.slotGroup[e] +} + +func (c *VariantCursor) setNavigated(e int, v variant.Value) { + if v.IsNull() { + c.locs[e] = variant.LocNull + } else { + c.locs[e] = variant.LocResidual + c.residualCount++ + } + r := c.addResidual(e) + r.val = v + r.decoded = true +} + +// process recomputes the cursor's window state from its leaf windows (or its +// parent's residuals), then recurses into child cursors. +func (c *VariantCursor) process(n int) error { + c.resetWindow() + var err error + switch { + case c.parent == nil: + err = c.processRoot(n) + case c.isElements: + err = c.processElements() + case c.node != nil: + err = c.processShreddedField() + default: + err = c.processVirtualField() + } + if err != nil { + return err + } + if len(c.childList) > 0 { + if err := c.decodeResiduals(); err != nil { + return err + } + } + for _, ch := range c.childList { + if err := ch.process(n); err != nil { + return err + } + } + return nil +} + +// decodeResiduals eagerly decodes the residual values that child cursors +// navigate through: all variant.LocResidual entries, plus partial-object +// leftovers when a non-shredded field cursor exists below this one. +func (c *VariantCursor) decodeResiduals() error { + for i := range c.res { + r := &c.res[i] + if r.decoded || r.bytes == nil { + continue + } + if c.locs[r.entry] == variant.LocTypedObject && !c.hasVirtualChild { + continue + } + if _, err := c.decodeResidual(r); err != nil { + return err + } + } + return nil +} + +// flatWindow reports whether the cursor can use the bulk window path: no +// slot or row indirection, and one slot per entry in every leaf window it +// reads. The value and primitive typed_value leaves of a depth-0 cursor are +// never repeated, but the presence leaf can be: it is the first leaf under +// an object or list typed_value, which may sit below a repeated level (a +// list typed_value always does). +func (c *VariantCursor) flatWindow() bool { + return c.depth == 0 && c.identitySlots && c.identityRows && + (c.presenceLeaf == nil || c.presenceLeaf.maxRep == 0) +} + +func (c *VariantCursor) processRoot(n int) error { + mw := &c.reader.metaLeaf.win + if c.flatWindow() { + c.growEntries(n) + c.computeOwnFlat(n, mw.defs, byte(c.reader.groupDef), variant.LocNull) + return nil + } + for row := range n { + e := c.appendEntry(int32(row), int32(row)) + if mw.defs[row] < byte(c.reader.groupDef) { + c.locs[e] = variant.LocMissing + } else { + c.computeOwn(e, int32(row), variant.LocNull) + } + } + return nil +} + +func (c *VariantCursor) processShreddedField() error { + p := c.parent + n := len(p.locs) + if c.flatWindow() && p.residualCount == 0 { + // No parent entry needs residual navigation, so every entry is + // resolved from this node's own columns: entries below an absent + // parent read as missing there too (their definition levels are + // below the maxima). + c.growEntries(n) + c.computeOwnFlat(n, nil, 0, variant.LocMissing) + return nil + } + for e := range n { + g := p.groupOf(e) + e2 := c.appendEntry(g, p.rowOf(e)) + switch p.locs[e] { + case variant.LocTypedObject: + // A typed object always has its own column slots (navigated + // residual entries can only be tagged null or residual). + c.computeOwn(e2, g, variant.LocMissing) + case variant.LocResidual: + if r := p.residualAt(e); r != nil && r.decoded { + c.navigateField(e2, r.val) + } + } + } + return nil +} + +func (c *VariantCursor) processVirtualField() error { + p := c.parent + n := len(p.locs) + if c.identityRows && len(p.res) == 0 { + // Virtual fields exist only inside residual values; with none in + // the parent window every entry is missing. + c.growEntries(n) + return nil + } + for e := range n { + e2 := c.appendEntry(-1, p.rowOf(e)) + switch p.locs[e] { + case variant.LocResidual, variant.LocTypedObject: + if r := p.residualAt(e); r != nil && r.decoded { + c.navigateField(e2, r.val) + } + } + } + return nil +} + +func (c *VariantCursor) navigateField(e int, pv variant.Value) { + if pv.Basic() != variant.BasicObject { + return // stays missing + } + for _, f := range pv.ObjectValue().Fields { + if f.Name == c.fieldName { + c.setNavigated(e, f.Value) + return + } + } +} + +func (c *VariantCursor) processElements() error { + p := c.parent + var startsP, startsE []int32 + var plw *variantLeafWindow + h := 0 + if c.node != nil { + plw = &p.presenceLeaf.win + startsP = plw.starts(p.depth) + startsE = plw.starts(c.depth) + } + p.listOffsets = append(p.listOffsets[:0], 0) + for e := range p.locs { + switch p.locs[e] { + case variant.LocTypedList: + g := p.groupOf(e) + // g beyond the presence column's group count means the file + // is corrupt (sibling columns must agree); skip the entry. + if g < 0 || c.node == nil || int(g) >= len(startsP)-1 { + break + } + gs, ge := startsP[g], startsP[g+1] + for h < len(startsE)-1 && startsE[h] < gs { + h++ + } + if plw.defs[gs] >= p.elemsDefAbs { + for h < len(startsE)-1 && startsE[h] < ge { + e2 := c.appendEntry(int32(h), p.rowOf(e)) + c.computeOwn(e2, int32(h), variant.LocNull) + h++ + } + } + case variant.LocResidual: + if r := p.residualAt(e); r != nil && r.decoded && r.val.Basic() == variant.BasicArray { + for _, elem := range r.val.ArrayValue().Elements { + e2 := c.appendEntry(-1, p.rowOf(e)) + c.setNavigated(e2, elem) + } + } + } + p.listOffsets = append(p.listOffsets, int32(len(c.locs))) + } + return nil +} + +// computeOwn resolves the location of entry e from the node's own value and +// typed_value columns at slot group g. missingLoc is the tag used when both +// sides are null: variant.LocMissing for object fields, variant.LocNull for +// the root and list elements (where both-null is invalid per the spec and +// read as variant null, matching the row-based reader). +func (c *VariantCursor) computeOwn(e int, g int32, missingLoc variant.Loc) { + var vbytes []byte + valuePresent := false + if c.valueLeaf != nil { + w := &c.valueLeaf.win + if s, ok := w.slotOf(c.depth, g); ok && w.defs[s] == c.valueMaxDef { + d := w.denseIdx[s] + vbytes = w.slab[w.offsets[d]:w.offsets[d+1]] + valuePresent = true + } + } + if t := c.node.typed; t != nil { + switch t.kind { + case shreddedTypedPrimitive: + w := &c.typedLeaf.win + if s, ok := w.slotOf(c.depth, g); ok && w.defs[s] == c.typedMaxDef { + // The spec requires value to be null when a primitive + // typed_value is present; if a non-compliant writer set + // both, the typed side wins (readers may assume data is + // written correctly). + c.locs[e] = variant.LocTyped + c.typedRows = append(c.typedRows, int32(e)) + return + } + case shreddedTypedObject: + w := &c.presenceLeaf.win + if s, ok := w.slotOf(c.depth, g); ok && w.defs[s] >= c.typedDefAbs { + c.locs[e] = variant.LocTypedObject + if valuePresent { + c.addResidual(e).bytes = vbytes // partially shredded object + } + return + } + case shreddedTypedList: + w := &c.presenceLeaf.win + if s, ok := w.slotOf(c.depth, g); ok && w.defs[s] >= c.typedDefAbs { + c.locs[e] = variant.LocTypedList + return + } + } + } + if valuePresent { + if len(vbytes) == 0 || vbytes[0] == 0x00 { + // Variant null is a one-byte value with a zero header. Empty + // bytes are how the plain unshredded write path stores a zero + // variant value; the row-based reader reads them as null too. + c.locs[e] = variant.LocNull + } else { + c.locs[e] = variant.LocResidual + c.addResidual(e).bytes = vbytes + c.residualCount++ + } + return + } + c.locs[e] = missingLoc +} + +// computeOwnFlat is the bulk equivalent of computeOwn for flat cursors (see +// flatWindow): entry e reads slot e of every leaf window directly. Entries +// whose gate level (the metadata column for the root) is below gateDef stay +// variant.LocMissing; growEntries pre-tagged every entry that way, so the +// loops only write the other locations. +func (c *VariantCursor) computeOwnFlat(n int, gate []byte, gateDef byte, missingLoc variant.Loc) { + locs := c.locs + switch { + case c.typedLeaf != nil: // primitive typed_value + tdefs := c.typedLeaf.win.defs + for e := range n { + if gate != nil && gate[e] < gateDef { + continue + } + if tdefs[e] == c.typedMaxDef { + locs[e] = variant.LocTyped + c.typedRows = append(c.typedRows, int32(e)) + continue + } + c.resolveValueFlat(e, missingLoc, false) + } + case c.presenceLeaf != nil: // object or list typed_value + typedLoc := variant.LocTypedObject + isObject := c.node.typed.kind == shreddedTypedObject + if !isObject { + typedLoc = variant.LocTypedList + } + pdefs := c.presenceLeaf.win.defs + for e := range n { + if gate != nil && gate[e] < gateDef { + continue + } + if pdefs[e] >= c.typedDefAbs { + locs[e] = typedLoc + if isObject { + // A present value column holds the leftover fields of + // a partially shredded object. + c.resolveValueFlat(e, typedLoc, true) + } + continue + } + c.resolveValueFlat(e, missingLoc, false) + } + default: // no typed_value column + for e := range n { + if gate != nil && gate[e] < gateDef { + continue + } + c.resolveValueFlat(e, missingLoc, false) + } + } +} + +// resolveValueFlat resolves entry e of a flat cursor from the value column +// alone: fallbackLoc when the column is null there, variant.LocNull or +// variant.LocResidual otherwise. With partialObject set (entry already +// tagged variant.LocTypedObject) a present value only records its leftover +// bytes. +func (c *VariantCursor) resolveValueFlat(e int, fallbackLoc variant.Loc, partialObject bool) { + if c.valueLeaf != nil { + w := &c.valueLeaf.win + if w.defs[e] == c.valueMaxDef { + d := w.denseIdx[e] + vbytes := w.slab[w.offsets[d]:w.offsets[d+1]] + switch { + case partialObject: + c.addResidual(e).bytes = vbytes + case len(vbytes) == 0 || vbytes[0] == 0x00: + // See computeOwn: zero or empty bytes read as variant null. + c.locs[e] = variant.LocNull + default: + c.locs[e] = variant.LocResidual + c.addResidual(e).bytes = vbytes + c.residualCount++ + } + return + } + } + c.locs[e] = fallbackLoc +} + +// variantLeafWindow holds the current window of one leaf column in columnar +// form: one definition level (and repetition level for repeated leaves) per +// slot, and the non-null values densely in typed buffers. All buffers are +// reused across windows. +type variantLeafWindow struct { + defs []byte + reps []byte // nil when the leaf is not repeated + denseIdx []int32 // slot -> index in the typed buffers, -1 for null slots + dense int + + // starts[d] lists the first slot of every repetition-depth-d group in + // the window (plus a final sentinel of numSlots). Depth 0 groups are + // rows. Computed lazily per depth per window. + startsByDepth [][]int32 + startsValid []bool + + bools []bool + i32 []int32 + i64 []int64 + f32 []float32 + f64 []float64 + slab []byte + offsets []uint32 // ByteArray: len == dense+1 + flba []byte + flbaSize int +} + +func (w *variantLeafWindow) reset() { + w.defs = w.defs[:0] + w.reps = w.reps[:0] + w.denseIdx = w.denseIdx[:0] + w.dense = 0 + for i := range w.startsValid { + w.startsValid[i] = false + } + w.bools = w.bools[:0] + w.i32 = w.i32[:0] + w.i64 = w.i64[:0] + w.f32 = w.f32[:0] + w.f64 = w.f64[:0] + w.slab = w.slab[:0] + w.offsets = append(w.offsets[:0], 0) + w.flba = w.flba[:0] +} + +// slotOf returns the first slot of depth-d group g and whether the group +// exists in the window. Sibling columns of a valid file agree on group +// counts; a missing group means the file is corrupt, and the caller treats +// the position as missing rather than panicking. +func (w *variantLeafWindow) slotOf(depth int, g int32) (int32, bool) { + if len(w.reps) == 0 { + // Non-repeated window: every slot is its own group at every depth, + // so the starts mapping is the identity. + if int(g) >= len(w.defs) { + return 0, false + } + return g, true + } + starts := w.starts(depth) + if int(g) >= len(starts)-1 { + return 0, false + } + return starts[g], true +} + +func (w *variantLeafWindow) starts(depth int) []int32 { + for len(w.startsByDepth) <= depth { + w.startsByDepth = append(w.startsByDepth, nil) + w.startsValid = append(w.startsValid, false) + } + if w.startsValid[depth] { + return w.startsByDepth[depth] + } + s := w.startsByDepth[depth][:0] + if len(w.reps) == 0 { + for i := range w.defs { + s = append(s, int32(i)) + } + } else { + for i, rp := range w.reps { + if int(rp) <= depth { + s = append(s, int32(i)) + } + } + } + s = append(s, int32(len(w.defs))) + w.startsByDepth[depth] = s + w.startsValid[depth] = true + return s +} + +// variantLeafReader reads windows of one leaf column of the variant subtree +// from its pages, extracting levels and typed data without boxing values. +type variantLeafReader struct { + reader *VariantReader + relCol int + typ Type + kind Kind + maxDef byte + maxRep byte + + opened bool + pages Pages + pendingSeek int64 + + // Current page state. + page Page + pdefs []byte + preps []byte + pcount int // slots in the page + ppos int // slots consumed + pdense int // non-null values consumed + + // Typed data of the current page (one of these per kind), or dictionary + // indexes when the page is dictionary-encoded. + pi32 []int32 + pi64 []int64 + pf32 []float32 + pf64 []float64 + pba []byte + pbaOff []uint32 + pflba []byte + pflbaN int + pbools []bool + pidx []int32 + dictSet bool + di32 []int32 + di64 []int64 + df32 []float32 + df64 []float64 + dba []byte + dbaOff []uint32 + dflba []byte + dflbaN int + + win variantLeafWindow +} + +func (l *variantLeafReader) open() error { + chunks := l.reader.rowGroup.ColumnChunks() + col := l.reader.baseColumn + l.relCol + if col >= len(chunks) { + return fmt.Errorf("variant: column %d out of range", col) + } + l.pages = chunks[col].Pages() + l.opened = true + if l.reader.rowOffset > 0 && l.pendingSeek < 0 { + l.pendingSeek = l.reader.rowOffset + } + return nil +} + +func (l *variantLeafReader) readWindow(nRows int) error { + if !l.opened { + if err := l.open(); err != nil { + return err + } + } + if l.pendingSeek >= 0 { + if l.page != nil { + Release(l.page) + l.page = nil + } + if err := l.pages.SeekToRow(l.pendingSeek); err != nil { + return err + } + l.pendingSeek = -1 + } + w := &l.win + w.reset() + rowsDone := 0 + started := false + for { + if err := l.ensurePage(); err != nil { + if err == io.EOF { + if started { + rowsDone++ + } + if rowsDone == nRows { + return nil + } + return fmt.Errorf("variant: column %d ended after %d of %d rows", l.reader.baseColumn+l.relCol, rowsDone, nRows) + } + return err + } + rep := byte(0) + if l.preps != nil { + rep = l.preps[l.ppos] + } + if rep == 0 { + if started { + rowsDone++ + if rowsDone == nRows { + return nil + } + } + started = true + } + l.consumeSlot(w, rep) + } +} + +func (l *variantLeafReader) ensurePage() error { + for l.page == nil || l.ppos == l.pcount { + if l.page != nil { + Release(l.page) + l.page = nil + } + p, err := l.pages.ReadPage() + if err != nil { + return err + } + if err := l.setPage(p); err != nil { + // setPage stored the page in l.page; clear it so Close does + // not release it a second time. + l.page = nil + Release(p) + return err + } + } + return nil +} + +func (l *variantLeafReader) setPage(p Page) error { + l.page = p + l.pdefs = p.DefinitionLevels() + l.preps = p.RepetitionLevels() + if l.pdefs != nil { + l.pcount = len(l.pdefs) + } else { + l.pcount = int(p.NumValues()) + } + l.ppos, l.pdense = 0, 0 + l.pidx = nil + + if l.kind == Boolean { + // Boolean page data is bit-packed with an internal bit offset that + // Data() does not expose for sliced pages, so booleans go through + // the page's value reader instead. + if err := l.extractBooleans(p); err != nil { + return err + } + return l.checkPageValues() + } + + data := p.Data() + if d := p.Dictionary(); d != nil { + l.pidx = data.Int32() + if !l.dictSet { + dd := d.Page().Data() + switch l.kind { + case Int32: + l.di32 = dd.Int32() + case Int64: + l.di64 = dd.Int64() + case Float: + l.df32 = dd.Float() + case Double: + l.df64 = dd.Double() + case ByteArray: + l.dba, l.dbaOff = dd.ByteArray() + case FixedLenByteArray: + l.dflba, l.dflbaN = dd.FixedLenByteArray() + } + l.dictSet = true + } + return l.checkPageValues() + } + switch l.kind { + case Int32: + l.pi32 = data.Int32() + case Int64: + l.pi64 = data.Int64() + case Float: + l.pf32 = data.Float() + case Double: + l.pf64 = data.Double() + case ByteArray: + l.pba, l.pbaOff = data.ByteArray() + case FixedLenByteArray: + l.pflba, l.pflbaN = data.FixedLenByteArray() + default: + return fmt.Errorf("variant: unsupported page kind %s", l.kind) + } + return l.checkPageValues() +} + +// checkPageValues verifies that the page decoded at least as many non-null +// values as its definition levels declare, so that appendValue never indexes +// past the decoded data. The page decode layer does not enforce this for +// BYTE_ARRAY, dictionary-encoded, or data page v2 pages, where a corrupt +// value section can decode short without error. +func (l *variantLeafReader) checkPageValues() error { + needed := l.pcount + if l.pdefs != nil { + needed = countLevelsEqual(l.pdefs, l.maxDef) + } + var have int + switch { + case l.pidx != nil: + have = len(l.pidx) + case l.kind == Boolean: + have = len(l.pbools) + case l.kind == Int32: + have = len(l.pi32) + case l.kind == Int64: + have = len(l.pi64) + case l.kind == Float: + have = len(l.pf32) + case l.kind == Double: + have = len(l.pf64) + case l.kind == ByteArray: + if n := len(l.pbaOff); n > 0 { + have = n - 1 + } + case l.kind == FixedLenByteArray: + if l.pflbaN > 0 { + have = len(l.pflba) / l.pflbaN + } + } + if have < needed { + return fmt.Errorf("variant: column %d page declares %d non-null values but decoded %d: %w", + l.reader.baseColumn+l.relCol, needed, have, ErrCorrupted) + } + return nil +} + +func (l *variantLeafReader) extractBooleans(p Page) error { + l.pbools = l.pbools[:0] + vr := p.Values() + var buf [128]Value + for { + n, err := vr.ReadValues(buf[:]) + for _, v := range buf[:n] { + if !v.IsNull() { + l.pbools = append(l.pbools, v.Boolean()) + } + } + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if n == 0 { + return fmt.Errorf("variant: boolean page reader made no progress") + } + } +} + +func (l *variantLeafReader) consumeSlot(w *variantLeafWindow, rep byte) { + def := l.maxDef + if l.pdefs != nil { + def = l.pdefs[l.ppos] + } + w.defs = append(w.defs, def) + if l.maxRep > 0 { + w.reps = append(w.reps, rep) + } + if def == l.maxDef { + w.denseIdx = append(w.denseIdx, int32(w.dense)) + w.dense++ + l.appendValue(w) + } else { + w.denseIdx = append(w.denseIdx, -1) + } + l.ppos++ +} + +func (l *variantLeafReader) appendValue(w *variantLeafWindow) { + i := l.pdense + l.pdense++ + switch l.kind { + case Boolean: + w.bools = append(w.bools, l.pbools[i]) + case Int32: + if l.pidx != nil { + w.i32 = append(w.i32, l.di32[l.pidx[i]]) + } else { + w.i32 = append(w.i32, l.pi32[i]) + } + case Int64: + if l.pidx != nil { + w.i64 = append(w.i64, l.di64[l.pidx[i]]) + } else { + w.i64 = append(w.i64, l.pi64[i]) + } + case Float: + if l.pidx != nil { + w.f32 = append(w.f32, l.df32[l.pidx[i]]) + } else { + w.f32 = append(w.f32, l.pf32[i]) + } + case Double: + if l.pidx != nil { + w.f64 = append(w.f64, l.df64[l.pidx[i]]) + } else { + w.f64 = append(w.f64, l.pf64[i]) + } + case ByteArray: + var b []byte + if l.pidx != nil { + j := l.pidx[i] + b = l.dba[l.dbaOff[j]:l.dbaOff[j+1]] + } else { + b = l.pba[l.pbaOff[i]:l.pbaOff[i+1]] + } + w.slab = append(w.slab, b...) + w.offsets = append(w.offsets, uint32(len(w.slab))) + case FixedLenByteArray: + if l.pidx != nil { + j := int(l.pidx[i]) + w.flba = append(w.flba, l.dflba[j*l.dflbaN:(j+1)*l.dflbaN]...) + w.flbaSize = l.dflbaN + } else { + w.flba = append(w.flba, l.pflba[i*l.pflbaN:(i+1)*l.pflbaN]...) + w.flbaSize = l.pflbaN + } + } +} diff --git a/vendor/github.com/parquet-go/parquet-go/variant_column_writer.go b/vendor/github.com/parquet-go/parquet-go/variant_column_writer.go new file mode 100644 index 00000000000..7260236424c --- /dev/null +++ b/vendor/github.com/parquet-go/parquet-go/variant_column_writer.go @@ -0,0 +1,844 @@ +package parquet + +import ( + "fmt" + "math" + "strings" + + "github.com/google/uuid" + "github.com/parquet-go/parquet-go/variant" +) + +// This file implements a columnar, streaming writer for VARIANT columns. +// +// Unlike the row-based write path (column_buffer_variant.go) — which decodes +// each row into a variant.Value tree and shreds the tree — VariantColumnWriter +// consumes variant.ValueBuilder events and shreds them as they arrive: values +// matching the shredded type are appended directly to the typed_value column +// buffers, and everything else is encoded to variant binary residuals with a +// streaming variant.Builder. All rows share one metadata dictionary (reset +// only when it outgrows a bound), so a stable field set interns each name +// once and every row writes byte-identical metadata. No +// intermediate tree, map, or []parquet.Value is ever built, so transcoding +// e.g. JSON into a shredded variant column runs allocation-free per row once +// the writer's buffers are warm. +// +// The shredding semantics are identical to the row path: both follow the +// case tables of the Variant Shredding specification (summarized at the top +// of variant_shredded_write.go) and share variantToParquetValue and the +// shreddedVariantGroup tree. + +// VariantColumnWriter writes one VARIANT column of a parquet file in +// streaming, columnar form. It implements variant.ValueBuilder: each row is +// bracketed by BeginRow and EndRow, and the row's value is described by the +// event methods in between, following the event-sequence rules documented +// on variant.ValueBuilder. WriteValue and WriteNullRow are row-level +// conveniences. String and []byte event arguments, and Field names, are +// copied; callers may reuse their backing memory after the call returns. +// +// The writer appends to the column buffers of the ColumnWriters backing the +// variant column's leaf columns and flushes full pages at row boundaries, +// like ColumnWriter.WriteRowValues. To keep row boundaries cheap the +// page-size check is polled every few rows while the buffers are under half +// the configured page size (and every row past that), so pages may +// moderately overshoot the configured size. Other columns of the file must be +// written separately (e.g. through Writer.ColumnWriters) with the same +// number of rows, and the parent writer must be closed (or its row group +// committed) as usual to flush buffered sub-page data to the file. +// +// Errors are sticky: the first misuse or write failure is retained, +// subsequent events are ignored, and the error is reported by Err, EndRow, +// and row-level methods. After an error the underlying columns may hold a +// partial row, so the parent writer's current row group is inconsistent and +// must be abandoned as a whole, including the other columns' writers: for a +// ConcurrentRowGroupWriter target, do not Commit; for a Writer or +// GenericWriter target, discard the output. +// +// A VariantColumnWriter is not safe for concurrent use, and the parent +// writer must not be flushed, reset, or closed between BeginRow and EndRow +// (rows cannot span pages or row groups). +type VariantColumnWriter struct { + group *shreddedVariantGroup + groupDef int // definition level at which the variant group is present + optional bool // whether the variant group node itself is optional + columns []*ColumnWriter + + // rootValueRequired is set for plain unshredded variant groups, whose + // value field is required rather than optional. + rootValueRequired bool + + meta variant.MetadataBuilder + metaGen uint64 // bumped when meta resets; invalidates VariantFieldRef interns + metaBuf []byte + builders map[*shreddedVariantGroup]*variant.Builder + + // flushCountdown spaces out the page-size scan of flush, which is + // O(columns) and dominates wide schemas when run every row. + flushCountdown int + + // Row state. cur is the shredded node awaiting a value event, nil when + // no value is expected (inside an object before a Field call, or after + // the row's value completed). frames tracks open shredded containers; + // residual tracks an active residual stream. + inRow bool + cur *shreddedVariantGroup + curLevels shredLevels + frames []variantWriterFrame + residual variantResidualState + err error +} + +// variantWriterFrame is one open shredded container (an object or list +// being shredded field-wise or element-wise). +type variantWriterFrame struct { + node *shreddedVariantGroup + isList bool + levels shredLevels // level context of this container occurrence + seen []bool // objects: shredded fields that received a value + partial *variant.Builder + elems int // lists: elements written so far +} + +// variantResidualState tracks an active residual stream: events are +// forwarded to b until the container depth returns to base. +type variantResidualState struct { + b *variant.Builder + node *shreddedVariantGroup + levels shredLevels + depth int + base int +} + +// WriterTarget is the writer surface VariantColumnWriter binds to; +// it is satisfied by *Writer, *GenericWriter[T], and +// *ConcurrentRowGroupWriter. +type WriterTarget interface { + Schema() *Schema + ColumnWriters() []*ColumnWriter +} + +var ( + _ WriterTarget = (*Writer)(nil) + _ WriterTarget = (*GenericWriter[any])(nil) + _ WriterTarget = (*ConcurrentRowGroupWriter)(nil) +) + +// NewVariantColumnWriter returns a streaming columnar writer for the VARIANT +// column at the given path in w's schema (e.g. "event" for a top-level +// column, "attrs", "v" for one nested in a group). The column may be +// unshredded (metadata, value) or shredded (metadata, value, typed_value) +// in any shape permitted by the Variant Shredding specification. +func NewVariantColumnWriter(w WriterTarget, path ...string) (*VariantColumnWriter, error) { + schema := w.Schema() + if schema == nil { + return nil, fmt.Errorf("variant: the writer has no schema configured") + } + info, err := resolveVariantColumn(schema, path) + if err != nil { + return nil, err + } + group := info.group + + columnWriters := w.ColumnWriters() + if info.col+group.numCols > len(columnWriters) { + return nil, fmt.Errorf("variant: column %q spans columns [%d, %d) but the writer has %d", joinPath(path), info.col, info.col+group.numCols, len(columnWriters)) + } + + return &VariantColumnWriter{ + group: group, + groupDef: info.def, + optional: info.optional, + columns: columnWriters[info.col : info.col+group.numCols], + rootValueRequired: info.valueRequired, + builders: make(map[*shreddedVariantGroup]*variant.Builder), + }, nil +} + +// Err returns the first error encountered, or nil. +func (w *VariantColumnWriter) Err() error { return w.err } + +func (w *VariantColumnWriter) fail(format string, args ...any) { + if w.err == nil { + w.err = fmt.Errorf("variant writer: "+format, args...) + } +} + +// variantMetadataResetSize bounds the interned name bytes of the writer's +// metadata dictionary. The dictionary persists across rows so that a stable +// field set interns each name once and every row writes byte-identical +// metadata (which encodes and compresses well); the bound keeps workloads +// with unbounded field-name churn from bloating every row's metadata with +// names of earlier rows. +const variantMetadataResetSize = 4096 + +// variantFlushCheckRows is how many rows may pass between page-size checks +// of the variant group's columns while every column is under half its +// buffer size; past half, flush checks every row. +const variantFlushCheckRows = 16 + +// BeginRow starts a new row. Exactly one value — a single scalar event, or +// a single balanced object or array — must be written before the matching +// EndRow. +func (w *VariantColumnWriter) BeginRow() error { + if w.err != nil { + return w.err + } + if w.inRow { + w.fail("BeginRow inside a row") + return w.err + } + w.inRow = true + w.cur = w.group + w.curLevels = shredLevels{baseDef: w.groupDef} + if w.meta.Size() > variantMetadataResetSize { + w.meta.Reset() + w.metaGen++ + } + return nil +} + +// EndRow completes the current row: it writes the row's metadata dictionary +// and periodically flushes columns whose buffered page reached the writer's +// page size. +func (w *VariantColumnWriter) EndRow() error { + if w.err == nil && !w.inRow { + w.fail("EndRow outside of a row") + } + if w.err == nil && (w.residual.b != nil || len(w.frames) > 0) { + w.fail("EndRow with an unclosed object or array") + } + // With no open frames or residual, cur still set means the row's value + // never arrived (valueDone clears it when the value completes). + if w.err == nil && w.cur != nil { + w.fail("EndRow without a value; use WriteNullRow for SQL null rows") + } + if w.err != nil { + return w.err + } + // Dictionary offsets are at most 4 bytes wide; AppendTo would silently + // truncate a larger dictionary. Only reachable when a single row + // interns over 4 GiB of unique field names, since BeginRow resets the + // dictionary at variantMetadataResetSize. + if uint64(w.meta.Size()) > math.MaxUint32 { + w.fail("metadata dictionary of %d bytes exceeds the variant format's 4 GiB limit", w.meta.Size()) + return w.err + } + w.metaBuf = w.meta.AppendTo(w.metaBuf[:0]) + w.leaf(w.group.metadataCol).writeByteArray(w.levels(byte(w.groupDef), 0), w.metaBuf) + w.inRow = false + w.cur = nil + return w.flush() +} + +// WriteNullRow writes a row where the variant column itself is null (a SQL +// null, distinct from the variant null value). The variant group must be +// optional. Any optional ancestors of the variant group are written as +// present; the writer cannot express a row where an ancestor group is null. +func (w *VariantColumnWriter) WriteNullRow() error { + if w.err != nil { + return w.err + } + if w.inRow { + w.fail("WriteNullRow inside a row") + return w.err + } + if !w.optional { + w.fail("WriteNullRow on a required variant column") + return w.err + } + lv := w.levels(byte(w.groupDef-1), 0) + for col := range w.columns { + w.leaf(col).writeNull(lv) + } + return w.flush() +} + +// WriteValue writes one row holding the given variant value: it brackets +// v.Write(w) with BeginRow and EndRow and reports any error either raised. +func (w *VariantColumnWriter) WriteValue(v variant.Value) error { + if err := w.BeginRow(); err != nil { + return err + } + v.Write(w) + return w.EndRow() +} + +// leaf returns the column buffer of the relative leaf column, creating it on +// first use like ColumnWriter.WriteRowValues does. +func (w *VariantColumnWriter) leaf(col int) ColumnBuffer { + c := w.columns[col] + if c.columnBuffer == nil { + c.columnBuffer = c.newColumnBuffer() + if c.originalColumnBuffer == nil { + c.originalColumnBuffer = c.columnBuffer + } + } + return c.columnBuffer +} + +func (w *VariantColumnWriter) levels(def, rep byte) columnLevels { + return columnLevels{definitionLevel: def, repetitionLevel: rep} +} + +// flush flushes any column whose buffer reached the configured page size. +// It only runs at row boundaries, since a row cannot span two pages. While +// every column is under half its buffer size the poll is spaced out to +// every variantFlushCheckRows rows; once any column crosses half, it runs +// every row so a page cannot silently overshoot by many large rows. +func (w *VariantColumnWriter) flush() error { + if w.flushCountdown > 0 { + w.flushCountdown-- + return nil + } + w.flushCountdown = variantFlushCheckRows - 1 + for _, c := range w.columns { + if c.columnBuffer == nil { + continue + } + if size := c.columnBuffer.Size(); size >= int64(c.bufferSize) { + if err := c.Flush(); err != nil { + w.err = err + return err + } + } else if size >= int64(c.bufferSize)/2 { + w.flushCountdown = 0 + } + } + return nil +} + +// builder returns the residual builder of a shredded node, sharing the +// row's metadata dictionary. +func (w *VariantColumnWriter) builder(node *shreddedVariantGroup) *variant.Builder { + b := w.builders[node] + if b == nil { + b = variant.NewBuilderWithMetadata(&w.meta) + w.builders[node] = b + } + b.Reset() + return b +} + +// writeNulls writes one null to every leaf column in [startCol, endCol). +func (w *VariantColumnWriter) writeNulls(startCol, endCol int, def, rep byte) { + lv := w.levels(def, rep) + for col := startCol; col < endCol; col++ { + w.leaf(col).writeNull(lv) + } +} + +// writeMissing writes a missing occurrence of a shredded node (both value +// and typed_value null), which is how absent object fields are represented. +func (w *VariantColumnWriter) writeMissing(g *shreddedVariantGroup, l shredLevels) { + if g.valueCol >= 0 { + w.leaf(g.valueCol).writeNull(w.levels(l.def(g.defLevel), l.rep)) + } + if g.typed != nil { + w.writeNulls(g.typed.startCol, g.typed.startCol+g.typed.numCols, l.def(g.defLevel), l.rep) + } +} + +// writeResidualBytes writes encoded variant bytes to the node's value +// column. +func (w *VariantColumnWriter) writeResidualBytes(g *shreddedVariantGroup, l shredLevels, data []byte) { + if g.valueCol < 0 { + w.fail("value does not match the shredded type and the schema has no value column to fall back to") + return + } + def := l.def(g.defLevel) + 1 + if g == w.group && w.rootValueRequired { + def = byte(w.groupDef) + } + w.leaf(g.valueCol).writeByteArray(w.levels(def, l.rep), data) +} + +// writeTyped writes a matched scalar to the node's typed_value column. +func (w *VariantColumnWriter) writeTyped(col int, pv Value, def, rep byte) { + buf := w.leaf(col) + lv := w.levels(def, rep) + switch pv.Kind() { + case Boolean: + buf.writeBoolean(lv, pv.Boolean()) + case Int32: + buf.writeInt32(lv, pv.Int32()) + case Int64: + buf.writeInt64(lv, pv.Int64()) + case Float: + buf.writeFloat(lv, pv.Float()) + case Double: + buf.writeDouble(lv, pv.Double()) + default: + buf.writeByteArray(lv, pv.ByteArray()) + } +} + +// valueDone advances the row state after one value completed at node level: +// back to the row, to the enclosing object (awaiting the next Field), or to +// the next element of the enclosing list. +func (w *VariantColumnWriter) valueDone() { + w.cur = nil + if n := len(w.frames); n > 0 { + f := &w.frames[n-1] + if f.isList { + f.elems++ + w.cur = f.node.typed.element + w.curLevels = f.levels + w.curLevels.rep = byte(f.levels.baseRep + f.node.typed.element.repDepth) + } + } +} + +// forward reports whether events must stream into an active residual. +func (w *VariantColumnWriter) forward() bool { + return w.err == nil && w.residual.b != nil +} + +// checkResidual surfaces an error the residual builder recorded from a +// forwarded event (misuse of the event sequence, an oversized value) as the +// writer's error, so it is reported at the offending event rather than when +// the residual is committed. It reports whether the residual is healthy. +func (w *VariantColumnWriter) checkResidual() bool { + if err := w.residual.b.Err(); err != nil { + if w.err == nil { + w.err = err + } + return false + } + return true +} + +// residualDone finalizes a completed residual stream. +func (w *VariantColumnWriter) residualDone() { + r := w.residual + w.residual = variantResidualState{} + if r.base > 0 { + // A residual field of a partial object completed; the partial + // object builder stays open in its frame. + return + } + data, err := r.b.Bytes() + if err != nil { + w.err = err + return + } + w.writeResidualBytes(r.node, r.levels, data) + if w.err != nil { + return + } + w.valueDone() +} + +func (w *VariantColumnWriter) afterResidualScalar() { + if !w.checkResidual() { + return + } + if w.residual.depth == w.residual.base { + w.residualDone() + } +} + +// scalar shreds one scalar value at the current position: into typed_value +// on an exact type match, into the value column as variant binary otherwise. +func (w *VariantColumnWriter) scalar(v variant.Value) { + if w.err != nil { + return + } + node := w.cur + if node == nil { + w.fail("unexpected value event") + return + } + l := w.curLevels + if t := node.typed; t != nil && t.kind == shreddedTypedPrimitive { + if pv, ok := variantToParquetValue(v, t.typ); ok { + w.writeTyped(t.startCol, pv, l.def(t.defLevel), l.rep) + if node.valueCol >= 0 { + w.leaf(node.valueCol).writeNull(w.levels(l.def(node.defLevel), l.rep)) + } + w.valueDone() + return + } + } + b := w.builder(node) + v.Write(b) + data, err := b.Bytes() + if err != nil { + w.err = err + return + } + w.writeResidualBytes(node, l, data) + if w.err != nil { + return + } + if node.typed != nil { + w.writeNulls(node.typed.startCol, node.typed.startCol+node.typed.numCols, l.def(node.defLevel), l.rep) + } + w.valueDone() +} + +// startResidual begins streaming a container that does not match the +// shredded type into the node's residual builder, nulling the typed columns. +func (w *VariantColumnWriter) startResidual(node *shreddedVariantGroup, l shredLevels) *variant.Builder { + if node.typed != nil { + w.writeNulls(node.typed.startCol, node.typed.startCol+node.typed.numCols, l.def(node.defLevel), l.rep) + } + b := w.builder(node) + w.residual = variantResidualState{b: b, node: node, levels: l} + return b +} + +// BeginObject starts an object value at the current position. If the +// position is shredded as an object, its fields shred individually; any +// other shredded type is a conflict and the whole object streams into the +// position's value column. +func (w *VariantColumnWriter) BeginObject() { + if w.forward() { + w.residual.b.BeginObject() + w.residual.depth++ + w.checkResidual() + return + } + if w.err != nil { + return + } + node := w.cur + if node == nil { + w.fail("unexpected BeginObject event") + return + } + l := w.curLevels + if t := node.typed; t != nil && t.kind == shreddedTypedObject { + w.pushFrame(node, false, l) + w.cur = nil + return + } + b := w.startResidual(node, l) + b.BeginObject() + w.residual.depth = 1 + w.cur = nil +} + +// Field names the next value written as a field of the innermost open +// object. Values of shredded fields go to the field's columns; others +// stream into the object's partial residual. +func (w *VariantColumnWriter) Field(name string) { + if w.forward() { + w.residual.b.Field(name) + w.checkResidual() + return + } + f := w.fieldFrame(name) + if f == nil { + return + } + // VariantShredding.md requires all field names, shredded or not, to be + // present in the metadata dictionary. + w.meta.Add(name) + idx, ok := f.node.typed.index[name] + if !ok { + idx = -1 + } + w.beginField(f, name, idx) +} + +// VariantFieldRef is a pre-resolved object field name for FieldByRef: a ref +// caches its resolution (shredded position and metadata intern) against the +// last writer and object it was used with, so hot ingest loops writing the +// same fields on every row skip the per-event name hashing of Field. The +// cache re-resolves whenever the writer or object position changes, but +// FieldByRef mutates it, so a ref must not be used by multiple goroutines +// concurrently — for concurrency and peak performance use one ref per +// writer per field. +type VariantFieldRef struct { + name string + node *shreddedVariantGroup // object node the ref last resolved against + idx int // field index in node, -1 when not shredded + metaFor *VariantColumnWriter // writer whose dictionary holds the cached intern + metaGen uint64 // dictionary generation of the cached intern +} + +// NewVariantFieldRef pre-resolves an object field name for use with +// VariantColumnWriter.FieldByRef. The name is copied; the caller may reuse +// its backing memory. The ref is not bound to any writer: resolution is +// cached lazily by FieldByRef. +func NewVariantFieldRef(name string) *VariantFieldRef { + return &VariantFieldRef{name: strings.Clone(name)} +} + +// FieldByRef is Field with a pre-resolved name; see NewVariantFieldRef. +func (w *VariantColumnWriter) FieldByRef(ref *VariantFieldRef) { + if w.forward() { + w.residual.b.Field(ref.name) + w.checkResidual() + return + } + f := w.fieldFrame(ref.name) + if f == nil { + return + } + if ref.metaFor != w || ref.metaGen != w.metaGen { + w.meta.Add(ref.name) + ref.metaFor = w + ref.metaGen = w.metaGen + } + if ref.node != f.node { + ref.node = f.node + if i, ok := f.node.typed.index[ref.name]; ok { + ref.idx = i + } else { + ref.idx = -1 + } + } + w.beginField(f, ref.name, ref.idx) +} + +// fieldFrame validates that a field event is legal here and returns the +// innermost open object frame, or nil after recording the error. +func (w *VariantColumnWriter) fieldFrame(name string) *variantWriterFrame { + if w.err != nil { + return nil + } + n := len(w.frames) + if n == 0 || w.frames[n-1].isList { + w.fail("Field %q outside of an object", name) + return nil + } + if w.cur != nil { + w.fail("Field %q: previous field has no value", name) + return nil + } + return &w.frames[n-1] +} + +// beginField positions the writer at shredded field idx of the open object +// frame, or at the partial-object residual when idx is -1. +func (w *VariantColumnWriter) beginField(f *variantWriterFrame, name string, idx int) { + if idx >= 0 { + if f.seen[idx] { + w.fail("duplicate object field %q", name) + return + } + f.seen[idx] = true + w.cur = f.node.typed.fields[idx].group + w.curLevels = f.levels + return + } + // Not a shredded field: it goes into the partial-object residual. + if f.node.valueCol < 0 { + w.fail("object field %q is not in the shredded schema and the object has no value column to hold it", name) + return + } + if f.partial == nil { + f.partial = w.builder(f.node) + f.partial.BeginObject() + } + f.partial.Field(name) + w.residual = variantResidualState{b: f.partial, node: f.node, levels: f.levels, depth: 1, base: 1} +} + +// EndObject closes the innermost open object, recording shredded fields +// that received no value as missing and committing the partial residual, if +// any, to the object's value column. +func (w *VariantColumnWriter) EndObject() { + if w.forward() { + if w.residual.depth == w.residual.base { + // Only reachable in a partial-object residual, right after a + // Field: the event tries to close the enclosing shredded + // object while the field's value is still pending. Fail here + // rather than corrupting the residual's depth tracking. + w.fail("EndObject: last field has no value") + return + } + w.residual.b.EndObject() + w.residual.depth-- + if w.checkResidual() && w.residual.depth == w.residual.base { + w.residualDone() + } + return + } + if w.err != nil { + return + } + n := len(w.frames) + if n == 0 || w.frames[n-1].isList { + w.fail("EndObject without matching BeginObject") + return + } + f := &w.frames[n-1] + if w.cur != nil { + w.fail("EndObject: last field has no value") + return + } + node, l := f.node, f.levels + for i := range node.typed.fields { + if !f.seen[i] { + w.writeMissing(node.typed.fields[i].group, l) + } + } + if f.partial != nil { + f.partial.EndObject() + data, err := f.partial.Bytes() + if err != nil { + w.err = err + return + } + w.writeResidualBytes(node, l, data) + } else if node.valueCol >= 0 { + w.leaf(node.valueCol).writeNull(w.levels(l.def(node.defLevel), l.rep)) + } + w.frames = w.frames[:n-1] + w.valueDone() +} + +// BeginArray starts an array value at the current position. If the position +// is shredded as a list, every value until the matching EndArray shreds as +// one element; any other shredded type is a conflict and the whole array +// streams into the position's value column. +func (w *VariantColumnWriter) BeginArray() { + if w.forward() { + w.residual.b.BeginArray() + w.residual.depth++ + w.checkResidual() + return + } + if w.err != nil { + return + } + node := w.cur + if node == nil { + w.fail("unexpected BeginArray event") + return + } + l := w.curLevels + if t := node.typed; t != nil && t.kind == shreddedTypedList { + w.pushFrame(node, true, l) + // The first element carries the enclosing occurrence's repetition + // level; valueDone switches to the element repetition level for + // subsequent elements. + w.cur = t.element + w.curLevels = l + return + } + b := w.startResidual(node, l) + b.BeginArray() + w.residual.depth = 1 + w.cur = nil +} + +// EndArray closes the innermost open array. +func (w *VariantColumnWriter) EndArray() { + if w.forward() { + if w.residual.depth == w.residual.base { + // See the matching guard in EndObject; here the enclosing + // container is an object, so the array being closed was never + // opened. + w.fail("EndArray without matching BeginArray") + return + } + w.residual.b.EndArray() + w.residual.depth-- + if w.checkResidual() && w.residual.depth == w.residual.base { + w.residualDone() + } + return + } + if w.err != nil { + return + } + n := len(w.frames) + if n == 0 || !w.frames[n-1].isList { + w.fail("EndArray without matching BeginArray") + return + } + f := &w.frames[n-1] + node, l := f.node, f.levels + if f.elems == 0 { + // typed_value present but the list is empty: every leaf records + // the list's definition level. + t := node.typed + w.writeNulls(t.startCol, t.startCol+t.numCols, l.def(t.defLevel), l.rep) + } + if node.valueCol >= 0 { + w.leaf(node.valueCol).writeNull(w.levels(l.def(node.defLevel), l.rep)) + } + w.frames = w.frames[:n-1] + w.valueDone() +} + +func (w *VariantColumnWriter) pushFrame(node *shreddedVariantGroup, isList bool, l shredLevels) { + if len(w.frames) < cap(w.frames) { + w.frames = w.frames[:len(w.frames)+1] + } else { + w.frames = append(w.frames, variantWriterFrame{}) + } + f := &w.frames[len(w.frames)-1] + f.node = node + f.isList = isList + f.levels = l + f.partial = nil + f.elems = 0 + if !isList { + numFields := len(node.typed.fields) + if cap(f.seen) < numFields { + f.seen = make([]bool, numFields) + } else { + f.seen = f.seen[:numFields] + clear(f.seen) + } + } +} + +// scalarEvent handles one scalar event: forwarded into an active residual +// stream, or shredded at the current position. +func (w *VariantColumnWriter) scalarEvent(v variant.Value) { + if w.forward() { + v.Write(w.residual.b) + w.afterResidualScalar() + return + } + w.scalar(v) +} + +// The scalar event methods below write one scalar value at the current +// position: the row's value, the current object field, or the next array +// element. A scalar matching the position's shredded type goes to its +// typed_value column; any other scalar encodes into the value column. + +// Null writes the variant null value (distinct from a missing field and +// from a SQL null row; see WriteNullRow). Variant null never matches a +// shredded type: it encodes into the position's value column, or fails the +// row when the position is shredded without one. +func (w *VariantColumnWriter) Null() { w.scalarEvent(variant.Null()) } +func (w *VariantColumnWriter) Bool(v bool) { w.scalarEvent(variant.Bool(v)) } +func (w *VariantColumnWriter) Int8(v int8) { w.scalarEvent(variant.Int8(v)) } +func (w *VariantColumnWriter) Int16(v int16) { w.scalarEvent(variant.Int16(v)) } +func (w *VariantColumnWriter) Int32(v int32) { w.scalarEvent(variant.Int32(v)) } +func (w *VariantColumnWriter) Int64(v int64) { w.scalarEvent(variant.Int64(v)) } +func (w *VariantColumnWriter) Float(v float32) { w.scalarEvent(variant.Float(v)) } +func (w *VariantColumnWriter) Double(v float64) { w.scalarEvent(variant.Double(v)) } +func (w *VariantColumnWriter) String(v string) { w.scalarEvent(variant.String(v)) } +func (w *VariantColumnWriter) Binary(v []byte) { w.scalarEvent(variant.Binary(v)) } +func (w *VariantColumnWriter) Date(days int32) { w.scalarEvent(variant.Date(days)) } +func (w *VariantColumnWriter) Time(micros int64) { w.scalarEvent(variant.Time(micros)) } +func (w *VariantColumnWriter) UUID(v uuid.UUID) { w.scalarEvent(variant.UUID(v)) } +func (w *VariantColumnWriter) Timestamp(us int64) { w.scalarEvent(variant.Timestamp(us)) } +func (w *VariantColumnWriter) TimestampNTZ(us int64) { + w.scalarEvent(variant.TimestampNTZ(us)) +} +func (w *VariantColumnWriter) TimestampNanos(ns int64) { + w.scalarEvent(variant.TimestampNanos(ns)) +} +func (w *VariantColumnWriter) TimestampNTZNanos(ns int64) { + w.scalarEvent(variant.TimestampNTZNanos(ns)) +} +func (w *VariantColumnWriter) Decimal4(unscaled int32, scale byte) { + w.scalarEvent(variant.Decimal4(unscaled, scale)) +} +func (w *VariantColumnWriter) Decimal8(unscaled int64, scale byte) { + w.scalarEvent(variant.Decimal8(unscaled, scale)) +} +func (w *VariantColumnWriter) Decimal16(unscaled [16]byte, scale byte) { + w.scalarEvent(variant.Decimal16(unscaled, scale)) +} + +var _ variant.ValueBuilder = (*VariantColumnWriter)(nil) diff --git a/vendor/github.com/parquet-go/parquet-go/variant_shredded_read.go b/vendor/github.com/parquet-go/parquet-go/variant_shredded_read.go new file mode 100644 index 00000000000..98e32672c1c --- /dev/null +++ b/vendor/github.com/parquet-go/parquet-go/variant_shredded_read.go @@ -0,0 +1,562 @@ +package parquet + +import ( + "fmt" + "slices" + + "github.com/google/uuid" + "github.com/parquet-go/parquet-go/format" + "github.com/parquet-go/parquet-go/variant" +) + +// This file implements the construct_variant reconstruction algorithm from +// the Variant Shredding specification: +// https://github.com/apache/parquet-format/blob/master/VariantShredding.md +// +// Reconstruction is not optional — VariantShredding.md: "When typed_value is +// present, readers must reconstruct shredded values according to this +// specification." +// +// A shredded variant group has the shape: +// +// optional group v (VARIANT) { +// required binary metadata; +// optional binary value; +// optional typed_value; // primitive, LIST, or object group +// } +// +// where object typed_value groups contain one required group per shredded +// field, each with its own optional value/typed_value pair, and LIST +// typed_value groups contain a repeated list of elements with the same +// value/typed_value pair. Reconstruction walks the leaf columns of the +// variant subtree and rebuilds the variant value for each row. + +// shreddedVariantGroup describes one (value, typed_value) pair in a shredded +// variant schema: the top-level variant group, an object field group, or a +// list element group. Column indices are relative to the variant group's +// first leaf column; definition levels are relative to the definition level +// at which the variant group itself is present. +type shreddedVariantGroup struct { + metadataCol int // metadata leaf column, or -1 (top-level group only) + valueCol int // value leaf column, or -1 + typed *shreddedTypedValue + startCol int + numCols int + defLevel int // relative definition level at which this group exists + repDepth int // repetition depth added within the variant subtree +} + +type shreddedTypedKind int + +const ( + shreddedTypedPrimitive shreddedTypedKind = iota + shreddedTypedList + shreddedTypedObject +) + +// shreddedTypedValue describes the typed_value part of a shredded variant +// group. +type shreddedTypedValue struct { + kind shreddedTypedKind + startCol int + numCols int + defLevel int // relative definition level at which typed_value is present + + typ Type // primitive + element *shreddedVariantGroup // list + fields []shreddedVariantField // object + index map[string]int // object: field name to position in fields +} + +type shreddedVariantField struct { + name string + group *shreddedVariantGroup +} + +// fieldByName returns the shredded field with the given name, or nil. +func (t *shreddedTypedValue) fieldByName(name string) *shreddedVariantGroup { + if i, ok := t.index[name]; ok { + return t.fields[i].group + } + return nil +} + +// buildShreddedVariantGroup builds the reconstruction tree for a variant +// group node. defLevel is the relative definition level at which the group +// exists (0 for the top-level variant group), repDepth the repetition depth +// added within the variant subtree. +func buildShreddedVariantGroup(node Node, startCol, defLevel, repDepth int) (*shreddedVariantGroup, error) { + g := &shreddedVariantGroup{ + metadataCol: -1, + valueCol: -1, + startCol: startCol, + defLevel: defLevel, + repDepth: repDepth, + } + col := startCol + for _, f := range node.Fields() { + switch f.Name() { + case "metadata": + // Every schema in VariantShredding.md declares + // "required binary metadata;" — a row cannot lack a dictionary. + if !f.Leaf() || f.Type().Kind() != ByteArray || f.Optional() || f.Repeated() { + return nil, fmt.Errorf("variant: metadata field must be a required binary leaf") + } + g.metadataCol = col + col++ + case "value": + if !f.Leaf() || f.Type().Kind() != ByteArray { + return nil, fmt.Errorf("variant: value field must be a binary leaf") + } + // VariantShredding.md: "Both value and typed_value are optional + // fields". The reconstruction's level arithmetic relies on the + // value column contributing one definition level. + if !f.Optional() { + return nil, fmt.Errorf("variant: value field of a shredded variant group must be optional") + } + g.valueCol = col + col++ + case "typed_value": + typed, err := buildShreddedTypedValue(f, col, defLevel+1, repDepth) + if err != nil { + return nil, err + } + g.typed = typed + col += typed.numCols + default: + return nil, fmt.Errorf("variant: unexpected field %q in shredded variant group", f.Name()) + } + } + g.numCols = col - startCol + if g.valueCol < 0 && g.typed == nil { + return nil, fmt.Errorf("variant: shredded variant group has neither value nor typed_value") + } + return g, nil +} + +// buildShreddedTypedValue builds the reconstruction tree for a typed_value +// field. defLevel is the relative definition level at which typed_value is +// present (its parent group's level + 1, since typed_value is optional). +func buildShreddedTypedValue(node Node, startCol, defLevel, repDepth int) (*shreddedTypedValue, error) { + if !node.Optional() { + return nil, fmt.Errorf("variant: typed_value must be optional") + } + t := &shreddedTypedValue{ + startCol: startCol, + defLevel: defLevel, + } + switch { + case node.Leaf(): + t.kind = shreddedTypedPrimitive + t.typ = node.Type() + t.numCols = 1 + if err := validateShreddedPrimitiveType(t.typ); err != nil { + return nil, err + } + + case isList(node): + t.kind = shreddedTypedList + elem := listElementOf(node) + elemDef := defLevel + 1 // the repeated list group adds one level + if elem.Optional() { + // The spec requires list elements to be required groups, but + // tolerate optional elements by accounting for the extra level. + elemDef++ + } + element, err := buildShreddedVariantGroup(elem, startCol, elemDef, repDepth+1) + if err != nil { + return nil, fmt.Errorf("variant: list element: %w", err) + } + if element.metadataCol >= 0 { + return nil, fmt.Errorf("variant: list element must not contain metadata") + } + t.element = element + t.numCols = element.numCols + + default: + t.kind = shreddedTypedObject + col := startCol + for _, f := range node.Fields() { + if f.Leaf() { + return nil, fmt.Errorf("variant: object field %q must be a group", f.Name()) + } + if f.Repeated() { + return nil, fmt.Errorf("variant: object field %q must not be repeated", f.Name()) + } + // The spec requires field groups to be required, but tolerate + // optional groups (a null group reads as a missing field). + fieldDef := defLevel + if f.Optional() { + fieldDef++ + } + group, err := buildShreddedVariantGroup(f, col, fieldDef, repDepth) + if err != nil { + return nil, fmt.Errorf("variant: object field %q: %w", f.Name(), err) + } + if group.metadataCol >= 0 { + return nil, fmt.Errorf("variant: object field %q must not contain metadata", f.Name()) + } + t.fields = append(t.fields, shreddedVariantField{name: f.Name(), group: group}) + col += group.numCols + } + if len(t.fields) == 0 { + // An empty object group has no columns to carry its own + // presence, so it cannot be reconstructed. + return nil, fmt.Errorf("variant: object typed_value group must have at least one field") + } + // Object field events resolve names against this map; a linear + // scan makes wide shredded objects quadratic per row (measurably + // dominant from a few dozen fields up). + t.index = make(map[string]int, len(t.fields)) + for i := range t.fields { + t.index[t.fields[i].name] = i + } + t.numCols = col - startCol + } + return t, nil +} + +// variantColumnReader reads values from the leaf columns of a variant +// subtree, tracking a cursor per column. The column slices contain the +// values belonging to a single occurrence of the variant group. +type variantColumnReader struct { + columns [][]Value + pos []int +} + +func (r *variantColumnReader) peek(col int) (Value, bool) { + if col >= len(r.columns) || r.pos[col] >= len(r.columns[col]) { + return Value{}, false + } + return r.columns[col][r.pos[col]], true +} + +func (r *variantColumnReader) next(col int) (Value, bool) { + v, ok := r.peek(col) + if ok { + r.pos[col]++ + } + return v, ok +} + +// read reconstructs the variant value for one occurrence of the group. It +// consumes exactly one value from every leaf column of the group's subtree +// (more beneath repeated lists). baseDef and baseRep are the definition +// level and repetition depth of the variant group in the enclosing schema. +// +// The boolean result reports whether the value is present; a false result +// means both value and typed_value were null, which the spec defines as a +// missing object field (and is invalid elsewhere; callers decide). +func (g *shreddedVariantGroup) read(r *variantColumnReader, m variant.Metadata, baseDef, baseRep int) (variant.Value, bool, error) { + var valueBytes []byte + valuePresent := false + if g.valueCol >= 0 { + v, ok := r.next(g.valueCol) + if ok && !v.IsNull() && int(v.definitionLevel) >= baseDef+g.defLevel+1 { + valuePresent = true + valueBytes = v.ByteArray() + } + } + + if g.typed == nil { + if !valuePresent { + return variant.Null(), false, nil + } + val, err := variant.Decode(m, valueBytes) + if err != nil { + return variant.Null(), false, fmt.Errorf("variant: decoding value: %w", err) + } + return val, true, nil + } + + // For primitives and arrays, value and typed_value are mutually + // exclusive. VariantShredding.md: "Unless the value is shredded as an + // object (see Objects), typed_value or value (but not both) must be + // non-null." + switch g.typed.kind { + case shreddedTypedPrimitive: + v, ok := r.next(g.typed.startCol) + typedPresent := ok && !v.IsNull() && int(v.definitionLevel) >= baseDef+g.typed.defLevel + if typedPresent { + if valuePresent { + return variant.Null(), false, fmt.Errorf("variant: value and primitive typed_value are both non-null") + } + val, err := parquetToVariantValue(v, g.typed.typ) + if err != nil { + return variant.Null(), false, err + } + return val, true, nil + } + + case shreddedTypedList: + arr, listPresent, err := g.typed.readList(r, m, baseDef, baseRep) + if err != nil { + return variant.Null(), false, err + } + if listPresent { + if valuePresent { + return variant.Null(), false, fmt.Errorf("variant: value and array typed_value are both non-null") + } + return arr, true, nil + } + + case shreddedTypedObject: + obj, objPresent, err := g.typed.readObject(r, m, baseDef, baseRep) + if err != nil { + return variant.Null(), false, err + } + if objPresent { + if !valuePresent { + return obj, true, nil + } + // Partially shredded object: the residual value must be an + // object. VariantShredding.md: "The value column of a + // partially shredded object must never contain fields + // represented by the Parquet columns in typed_value (shredded + // fields). Readers may always assume that data is written + // correctly" — so if a writer repeats a shredded name anyway, + // readers use the shredded field and ignore the residual copy + // (matching parquet-java). + residual, err := variant.Decode(m, valueBytes) + if err != nil { + return variant.Null(), false, fmt.Errorf("variant: decoding partial object value: %w", err) + } + if residual.Basic() != variant.BasicObject { + return variant.Null(), false, fmt.Errorf("variant: object typed_value with non-object value") + } + fields := slices.Clone(obj.ObjectValue().Fields) + for _, f := range residual.ObjectValue().Fields { + if g.typed.fieldByName(f.Name) != nil { + continue + } + fields = append(fields, f) + } + return variant.MakeObject(fields), true, nil + } + } + + // typed_value is null: fall back to the value column. + if !valuePresent { + return variant.Null(), false, nil + } + val, err := variant.Decode(m, valueBytes) + if err != nil { + return variant.Null(), false, fmt.Errorf("variant: decoding value: %w", err) + } + return val, true, nil +} + +// readList reconstructs a shredded array. The boolean result reports whether +// the typed_value list was present (a present empty list yields an empty +// array). +func (t *shreddedTypedValue) readList(r *variantColumnReader, m variant.Metadata, baseDef, baseRep int) (variant.Value, bool, error) { + first, ok := r.peek(t.startCol) + listPresent := ok && int(first.definitionLevel) >= baseDef+t.defLevel + // The repeated list group adds one definition level when the list has at + // least one element (independent of the element group's own levels). + hasElements := ok && int(first.definitionLevel) >= baseDef+t.defLevel+1 + + if !hasElements { + // Null or empty list: one (null) value per leaf column to consume. + for col := t.startCol; col < t.startCol+t.numCols; col++ { + r.next(col) + } + if listPresent { + return variant.MakeArray(nil), true, nil + } + return variant.Null(), false, nil + } + + elemRep := baseRep + t.element.repDepth + var elements []variant.Value + for { + elem, present, err := t.element.read(r, m, baseDef, baseRep) + if err != nil { + return variant.Null(), false, err + } + if !present { + // Elements with both value and typed_value null are invalid + // per the spec; read them as variant null (matching + // parquet-java's behavior). + elem = variant.Null() + } + elements = append(elements, elem) + + next, ok := r.peek(t.startCol) + if !ok || int(next.repetitionLevel) != elemRep { + break + } + } + return variant.MakeArray(elements), true, nil +} + +// readObject reconstructs the shredded fields of an object typed_value. The +// boolean result reports whether the typed_value group was present. Field +// groups are always consumed, even when the object is absent, because their +// leaf columns carry one (null) value per occurrence either way. +func (t *shreddedTypedValue) readObject(r *variantColumnReader, m variant.Metadata, baseDef, baseRep int) (variant.Value, bool, error) { + objPresent := false + if first, ok := r.peek(t.startCol); ok { + objPresent = int(first.definitionLevel) >= baseDef+t.defLevel + } + + fields := make([]variant.Field, 0, len(t.fields)) + for _, f := range t.fields { + val, present, err := f.group.read(r, m, baseDef, baseRep) + if err != nil { + return variant.Null(), false, fmt.Errorf("variant: object field %q: %w", f.name, err) + } + // A missing field (value and typed_value both null) is simply + // omitted from the reconstructed object. + if objPresent && present { + fields = append(fields, variant.Field{Name: f.name, Value: val}) + } + } + if !objPresent { + return variant.Null(), false, nil + } + return variant.MakeObject(fields), true, nil +} + +// validateShreddedPrimitiveType checks that a typed_value leaf type is one +// of the shredded types permitted by the Variant Shredding specification +// (e.g. unsigned integers and non-UUID fixed-length byte arrays are not). +func validateShreddedPrimitiveType(typ Type) error { + lt := typ.LogicalType() + switch value := logicalTypeValueOf(lt).(type) { + case nil: + switch typ.Kind() { + case Boolean, Int32, Int64, Float, Double, ByteArray: + return nil + } + case *format.StringType: + return nil + case *format.IntType: + if !value.IsSigned { + return fmt.Errorf("variant: unsupported shredded type %s (unsigned integer)", typ) + } + switch value.BitWidth { + case 8, 16, 32, 64: + return nil + } + case *format.DateType: + return nil + case *format.TimeType: + if _, ok := value.Unit.Value.(*format.MicroSeconds); ok { + return nil + } + case *format.TimestampType: + switch value.Unit.Value.(type) { + case *format.MicroSeconds, *format.NanoSeconds: + return nil + } + case *format.DecimalType: + switch typ.Kind() { + case Int32, Int64, FixedLenByteArray, ByteArray: + return nil + } + case *format.UUIDType: + return nil + } + return fmt.Errorf("variant: unsupported shredded type %s", typ) +} + +// parquetToVariantValue converts a parquet leaf value of a shredded +// typed_value column to the corresponding variant value, per the shredded +// types table of the Variant Shredding specification. +func parquetToVariantValue(v Value, typ Type) (variant.Value, error) { + lt := typ.LogicalType() + switch value := logicalTypeValueOf(lt).(type) { + case nil: + switch typ.Kind() { + case Boolean: + return variant.Bool(v.Boolean()), nil + case Int32: + return variant.Int32(v.Int32()), nil + case Int64: + return variant.Int64(v.Int64()), nil + case Float: + return variant.Float(v.Float()), nil + case Double: + return variant.Double(v.Double()), nil + case ByteArray: + return variant.Binary(copyBytes(v.ByteArray())), nil + } + + case *format.StringType: + return variant.String(string(v.ByteArray())), nil + + case *format.IntType: + switch value.BitWidth { + case 8: + return variant.Int8(int8(v.Int32())), nil + case 16: + return variant.Int16(int16(v.Int32())), nil + case 32: + return variant.Int32(v.Int32()), nil + case 64: + return variant.Int64(v.Int64()), nil + } + + case *format.DateType: + return variant.Date(v.Int32()), nil + + case *format.TimeType: + if _, ok := value.Unit.Value.(*format.MicroSeconds); ok { + return variant.Time(v.Int64()), nil + } + + case *format.TimestampType: + switch value.Unit.Value.(type) { + case *format.MicroSeconds: + if value.IsAdjustedToUTC { + return variant.Timestamp(v.Int64()), nil + } + return variant.TimestampNTZ(v.Int64()), nil + case *format.NanoSeconds: + if value.IsAdjustedToUTC { + return variant.TimestampNanos(v.Int64()), nil + } + return variant.TimestampNTZNanos(v.Int64()), nil + } + + case *format.DecimalType: + scale := uint8(value.Scale) + switch typ.Kind() { + case Int32: + return variant.Decimal4(v.Int32(), scale), nil + case Int64: + return variant.Decimal8(v.Int64(), scale), nil + case FixedLenByteArray, ByteArray: + b := v.ByteArray() + if len(b) > 16 { + return variant.Null(), fmt.Errorf("variant: decimal value wider than 16 bytes") + } + return variant.Decimal16(bigEndianToLittleEndian16(b), scale), nil + } + + case *format.UUIDType: + b := v.ByteArray() + if len(b) != 16 { + return variant.Null(), fmt.Errorf("variant: UUID value must be 16 bytes, got %d", len(b)) + } + return variant.UUID(uuid.UUID(b)), nil + } + return variant.Null(), fmt.Errorf("variant: unsupported shredded type %s", typ) +} + +// bigEndianToLittleEndian16 converts a big-endian two's complement integer +// of up to 16 bytes (parquet decimal representation) to the little-endian +// 16-byte representation used by variant decimal16. +func bigEndianToLittleEndian16(b []byte) [16]byte { + var out [16]byte + for i := range b { + out[i] = b[len(b)-1-i] + } + if len(b) > 0 && b[0]&0x80 != 0 { + for i := len(b); i < 16; i++ { + out[i] = 0xFF + } + } + return out +} diff --git a/vendor/github.com/parquet-go/parquet-go/variant_shredded_write.go b/vendor/github.com/parquet-go/parquet-go/variant_shredded_write.go new file mode 100644 index 00000000000..8909d8c1927 --- /dev/null +++ b/vendor/github.com/parquet-go/parquet-go/variant_shredded_write.go @@ -0,0 +1,367 @@ +package parquet + +import ( + "math/bits" + + "github.com/parquet-go/parquet-go/format" + "github.com/parquet-go/parquet-go/variant" +) + +// This file implements the spec-compliant shredded variant write path. It +// reuses the shreddedVariantGroup tree from variant_shredded_read.go for +// column layout and level bookkeeping, and writes values per the case tables +// of the Variant Shredding specification: +// +// - Values that exactly match the shredded type go into typed_value with a +// null value column. +// - Values that do not match are encoded as plain variant values into the +// value column (sharing the row's top-level metadata dictionary), with +// all typed_value columns null. +// - Objects shred field-wise: shredded fields go into the typed_value +// group (missing fields have both columns null), residual fields are +// encoded as an object into the value column. Shredded field names never +// appear in the value column. +// - Arrays shred element-wise through the 3-level LIST structure; variant +// null elements are encoded as variant null (0x00) in the element's +// value column. +// +// The row's metadata dictionary contains every object field name of the +// value, shredded or not, so residual values and reconstruction share one +// dictionary. VariantShredding.md: "All value columns within the Variant +// must use the same metadata. All field names of a Variant, whether shredded +// or not, must be present in the metadata." + +// addVariantFieldNames pre-registers all object field names of v in the +// metadata builder, so the row metadata covers shredded and unshredded +// fields alike. +func addVariantFieldNames(b *variant.MetadataBuilder, v variant.Value) { + switch v.Basic() { + case variant.BasicObject: + for _, f := range v.ObjectValue().Fields { + b.Add(f.Name) + addVariantFieldNames(b, f.Value) + } + case variant.BasicArray: + for _, e := range v.ArrayValue().Elements { + addVariantFieldNames(b, e) + } + } +} + +// shredLevels carries the absolute level context for one occurrence of a +// shredded variant group during writing. +type shredLevels struct { + baseDef int // definition level at which the variant group is present + baseRep int // repetition depth of the variant group + rep byte // repetition level for the first value of this occurrence +} + +func (l shredLevels) def(rel int) byte { return byte(l.baseDef + rel) } + +// appendShredded appends a leaf value with the given levels. +func appendShredded(columns [][]Value, colBase uint16, col int, v Value, def, rep byte) { + c := colBase + uint16(col) + v.definitionLevel = def + v.repetitionLevel = rep + v.columnIndex = ^c + columns[c] = append(columns[c], v) +} + +// appendShreddedNulls appends a null to every leaf column in [start, end) at +// the given levels. +func appendShreddedNulls(columns [][]Value, colBase uint16, start, end int, def, rep byte) { + for col := start; col < end; col++ { + appendShredded(columns, colBase, col, Value{}, def, rep) + } +} + +// write encodes one occurrence of the variant group. present=false writes a +// missing occurrence (both value and typed_value null), which is how absent +// object fields are represented. +func (g *shreddedVariantGroup) write(columns [][]Value, colBase uint16, b *variant.MetadataBuilder, v variant.Value, present bool, l shredLevels) { + if !present { + if g.valueCol >= 0 { + appendShredded(columns, colBase, g.valueCol, Value{}, l.def(g.defLevel), l.rep) + } + if g.typed != nil { + appendShreddedNulls(columns, colBase, g.typed.startCol, g.typed.startCol+g.typed.numCols, l.def(g.defLevel), l.rep) + } + return + } + + if g.typed == nil { + g.writeValueFallback(columns, colBase, b, v, l) + return + } + + switch g.typed.kind { + case shreddedTypedPrimitive: + if pv, ok := variantToParquetValue(v, g.typed.typ); ok { + appendShredded(columns, colBase, g.typed.startCol, pv, l.def(g.typed.defLevel), l.rep) + if g.valueCol >= 0 { + appendShredded(columns, colBase, g.valueCol, Value{}, l.def(g.defLevel), l.rep) + } + return + } + + case shreddedTypedList: + if v.Basic() == variant.BasicArray { + g.typed.writeList(columns, colBase, b, v, l) + if g.valueCol >= 0 { + appendShredded(columns, colBase, g.valueCol, Value{}, l.def(g.defLevel), l.rep) + } + return + } + + case shreddedTypedObject: + if v.Basic() == variant.BasicObject { + g.typed.writeObject(columns, colBase, b, v, g, l) + return + } + } + + // The value does not match the shredded type: write it to the value + // column and null out the typed columns. + g.writeValueFallback(columns, colBase, b, v, l) + appendShreddedNulls(columns, colBase, g.typed.startCol, g.typed.startCol+g.typed.numCols, l.def(g.defLevel), l.rep) +} + +// writeValueFallback encodes v as a plain variant value into the value +// column, sharing the row's metadata dictionary. +func (g *shreddedVariantGroup) writeValueFallback(columns [][]Value, colBase uint16, b *variant.MetadataBuilder, v variant.Value, l shredLevels) { + if g.valueCol < 0 { + panic("variant: value does not match the shredded type and the schema has no value column to fall back to") + } + encoded := variant.Encode(b, v) + pv := ByteArrayValue(encoded) + appendShredded(columns, colBase, g.valueCol, pv, l.def(g.defLevel)+1, l.rep) +} + +// writeList shreds an array value through the 3-level LIST structure. +func (t *shreddedTypedValue) writeList(columns [][]Value, colBase uint16, b *variant.MetadataBuilder, v variant.Value, l shredLevels) { + elements := v.ArrayValue().Elements + if len(elements) == 0 { + // typed_value present but the list is empty: every leaf records the + // list's definition level. + for col := t.startCol; col < t.startCol+t.numCols; col++ { + appendShredded(columns, colBase, col, Value{}, l.def(t.defLevel), l.rep) + } + return + } + elemRep := byte(l.baseRep + t.element.repDepth) + for i, elem := range elements { + el := l + if i > 0 { + el.rep = elemRep + } + // Variant null elements are written as variant null (0x00) in the + // element's value column, via the fallback path. + t.element.write(columns, colBase, b, elem, true, el) + } +} + +// writeObject shreds an object value: schema fields go into the typed_value +// group, residual fields into the value column as a variant object. +func (t *shreddedTypedValue) writeObject(columns [][]Value, colBase uint16, b *variant.MetadataBuilder, v variant.Value, g *shreddedVariantGroup, l shredLevels) { + objFields := v.ObjectValue().Fields + for _, f := range t.fields { + fv, ok := findVariantField(objFields, f.name) + f.group.write(columns, colBase, b, fv, ok, l) + } + + var residual []variant.Field + for _, f := range objFields { + if t.fieldByName(f.Name) == nil { + residual = append(residual, f) + } + } + if len(residual) > 0 { + g.writeValueFallback(columns, colBase, b, variant.MakeObject(residual), l) + } else if g.valueCol >= 0 { + appendShredded(columns, colBase, g.valueCol, Value{}, l.def(g.defLevel), l.rep) + } +} + +// findVariantField returns the value of the named field and whether it was +// found. Objects are typically small, so a linear scan beats building a map +// per row. +func findVariantField(fields []variant.Field, name string) (variant.Value, bool) { + for _, f := range fields { + if f.Name == name { + return f.Value, true + } + } + return variant.Value{}, false +} + +// isSignedIntOrNil reports whether lt is absent, or carries a signed INT +// annotation of the given bit width. A physical int column with no annotation +// is treated as a signed integer of its natural width. +func isSignedIntOrNil(lt *format.LogicalType, bitWidth int8) bool { + if lt == nil { + return true + } + it, ok := logicalTypeOf[*format.IntType](lt) + return ok && it.IsSigned && it.BitWidth == bitWidth +} + +// variantToParquetValue converts a variant value to a parquet value of the +// given shredded column type when the types match exactly (following +// parquet-java's strict matching semantics: no numeric widening or +// narrowing). The boolean result reports whether the types matched. +func variantToParquetValue(v variant.Value, typ Type) (Value, bool) { + if v.Basic() != variant.BasicPrimitive && v.Basic() != variant.BasicShortString { + return Value{}, false + } + lt := typ.LogicalType() + switch v.Type() { + case variant.PrimitiveTrue, variant.PrimitiveFalse: + if lt == nil && typ.Kind() == Boolean { + return BooleanValue(v.BoolValue()), true + } + case variant.PrimitiveInt8: + if it, ok := logicalTypeOf[*format.IntType](lt); ok && it.IsSigned && it.BitWidth == 8 { + return Int32Value(int32(v.Int())), true + } + case variant.PrimitiveInt16: + if it, ok := logicalTypeOf[*format.IntType](lt); ok && it.IsSigned && it.BitWidth == 16 { + return Int32Value(int32(v.Int())), true + } + case variant.PrimitiveInt32: + if typ.Kind() == Int32 && isSignedIntOrNil(lt, 32) { + return Int32Value(int32(v.Int())), true + } + case variant.PrimitiveInt64: + if typ.Kind() == Int64 && isSignedIntOrNil(lt, 64) { + return Int64Value(v.Int()), true + } + case variant.PrimitiveFloat: + if lt == nil && typ.Kind() == Float { + return FloatValue(float32(v.FloatValue())), true + } + case variant.PrimitiveDouble: + if lt == nil && typ.Kind() == Double { + return DoubleValue(v.FloatValue()), true + } + case variant.PrimitiveString: + if logicalTypeIs[*format.StringType](lt) { + // Viewing the immutable string data in place avoids an + // allocation per string. Callers either copy the value into + // column buffers or expose it as a read-only parquet.Value + // (the deconstruct path), matching the library's aliasing + // semantics for byte array values. + return ByteArrayValue(unsafeByteArrayFromString(v.Str())), true + } + case variant.PrimitiveBinary: + if lt == nil && typ.Kind() == ByteArray { + return ByteArrayValue(v.Bytes()), true + } + case variant.PrimitiveDate: + if logicalTypeIs[*format.DateType](lt) { + return Int32Value(int32(v.Int())), true + } + case variant.PrimitiveTime: + if tt, ok := logicalTypeOf[*format.TimeType](lt); ok && isMicros(tt.Unit) { + return Int64Value(v.Int()), true + } + case variant.PrimitiveTimestamp: + if ts, ok := logicalTypeOf[*format.TimestampType](lt); ok && isMicros(ts.Unit) && ts.IsAdjustedToUTC { + return Int64Value(v.Int()), true + } + case variant.PrimitiveTimestampNTZ: + if ts, ok := logicalTypeOf[*format.TimestampType](lt); ok && isMicros(ts.Unit) && !ts.IsAdjustedToUTC { + return Int64Value(v.Int()), true + } + case variant.PrimitiveTimestampNanos: + if ts, ok := logicalTypeOf[*format.TimestampType](lt); ok && isNanos(ts.Unit) && ts.IsAdjustedToUTC { + return Int64Value(v.Int()), true + } + case variant.PrimitiveTimestampNTZNanos: + if ts, ok := logicalTypeOf[*format.TimestampType](lt); ok && isNanos(ts.Unit) && !ts.IsAdjustedToUTC { + return Int64Value(v.Int()), true + } + case variant.PrimitiveDecimal4: + if d, ok := logicalTypeOf[*format.DecimalType](lt); ok && typ.Kind() == Int32 && d.Scale == int32(v.Scale()) && + decimal64FitsPrecision(v.Int(), d.Precision) { + return Int32Value(int32(v.Int())), true + } + case variant.PrimitiveDecimal8: + if d, ok := logicalTypeOf[*format.DecimalType](lt); ok && typ.Kind() == Int64 && d.Scale == int32(v.Scale()) && + decimal64FitsPrecision(v.Int(), d.Precision) { + return Int64Value(v.Int()), true + } + case variant.PrimitiveDecimal16: + if dec, ok := logicalTypeOf[*format.DecimalType](lt); ok && dec.Scale == int32(v.Scale()) && + (typ.Kind() == ByteArray || (typ.Kind() == FixedLenByteArray && typ.Length() == 16)) && + decimal128FitsPrecision(v.Decimal16Value(), dec.Precision) { + d := v.Decimal16Value() + be := littleEndianToBigEndian16(d) + if typ.Kind() == ByteArray { + return ByteArrayValue(be[:]), true + } + return FixedLenByteArrayValue(be[:]), true + } + case variant.PrimitiveUUID: + if logicalTypeIs[*format.UUIDType](lt) { + u := v.UUIDValue() + return FixedLenByteArrayValue(u[:]), true + } + } + return Value{}, false +} + +// littleEndianToBigEndian16 converts the little-endian 16-byte decimal +// representation used by variant to parquet's big-endian representation. +func littleEndianToBigEndian16(b [16]byte) [16]byte { + var out [16]byte + for i := range b { + out[i] = b[15-i] + } + return out +} + +// decimal64FitsPrecision reports whether an unscaled decimal value fits in +// a DECIMAL(P, S) column, i.e. has at most P decimal digits. A DECIMAL(P, S) +// column declares that bound to readers, so writing a wider value would +// corrupt it for engines that trust the declaration (DuckDB renders such a +// column as a different decimal type); the value must fall back to the +// value column instead. +func decimal64FitsPrecision(unscaled int64, precision int32) bool { + if precision >= 19 { + return true // int64 has at most 19 digits + } + bound := int64(1) + for range precision { + bound *= 10 + } + return unscaled > -bound && unscaled < bound +} + +// decimal128FitsPrecision is decimal64FitsPrecision for the little-endian +// 16-byte representation used by variant decimal16. +func decimal128FitsPrecision(le [16]byte, precision int32) bool { + if precision >= 39 { + return true // 128 bits hold at most 39 digits + } + neg := le[15]&0x80 != 0 + var hi, lo uint64 + for i := range 8 { + lo |= uint64(le[i]) << (8 * i) + hi |= uint64(le[8+i]) << (8 * i) + } + if neg { // two's complement negation to get the magnitude + lo = ^lo + 1 + hi = ^hi + if lo == 0 { + hi++ + } + } + // magnitude < 10^precision, computed in 128 bits + boundHi, boundLo := uint64(0), uint64(1) + for range precision { + var carry uint64 + carry, boundLo = bits.Mul64(boundLo, 10) + boundHi = boundHi*10 + carry + } + return hi < boundHi || (hi == boundHi && lo < boundLo) +} diff --git a/vendor/github.com/parquet-go/parquet-go/writer.go b/vendor/github.com/parquet-go/parquet-go/writer.go index 645346eb5f0..3ffcc1402fe 100644 --- a/vendor/github.com/parquet-go/parquet-go/writer.go +++ b/vendor/github.com/parquet-go/parquet-go/writer.go @@ -206,6 +206,19 @@ func makeWriteFunc[T any](t reflect.Type, writeRows writeRowsFunc) writeFunc[T] // These fields are usually lazily initialized when writing rows, // we need them to exist now tho. c.columnBuffer = c.newColumnBuffer() + // Record the original buffer so the dictionary-encoded buffer is + // restored when the row group is flushed after a fallback to PLAIN + // switched the column to a different buffer. + c.originalColumnBuffer = c.columnBuffer + w.columns[i] = c.columnBuffer + } + } else { + // The column buffers may have been replaced since the previous call: + // when a column's dictionary outgrows DictionaryMaxBytes its buffer is + // swapped for a PLAIN-encoded one (fallbackDictionaryToPlain), and + // flushing a row group restores the original buffer. Re-resolve the + // cached references so rows are not written into abandoned buffers. + for i, c := range w.base.writer.currentRowGroup.columns { w.columns[i] = c.columnBuffer } } @@ -543,10 +556,37 @@ func (w *Writer) WriteRowGroup(rowGroup RowGroup) (int64, error) { case !EqualNodes(w.schema, rowGroupSchema): return 0, ErrRowGroupSchemaMismatch } + // When the row group is the in-order concatenation of independently writable + // segments and at least one segment can be copied verbatim (e.g. a merge of + // non-overlapping row groups), write each segment as its own output row group + // so the copyable ones take the fast path. Row group sizing below + // MaxRowsPerRowGroup is an unspecified internal; data and order are preserved. + if segments, ok := w.splittableCopyableSegments(rowGroup); ok { + return w.writeSegmentsPacked(segments, rowGroup.Schema(), rowGroup.SortingColumns()) + } if err := w.writer.flush(); err != nil { return 0, err } - w.writer.currentRowGroup.configureBloomFilters(rowGroup.ColumnChunks()) + // Fast path: when the whole row group can be copied verbatim from a source + // file, splice the compressed bytes in directly instead of decoding and + // re-encoding every value (see writer_copy.go). + if srcs, ok := w.copyableColumnChunks(rowGroup); ok { + if err := w.loadCopiedChunks(srcs); err != nil { + return 0, err + } + return w.writer.writeRowGroup(w.writer.currentRowGroup, rowGroup.Schema(), rowGroup.SortingColumns()) + } + // L3 fast path: a file-backed source whose schema matches but cannot be + // copied verbatim (config differs) is re-encoded column-by-column, skipping + // the row assembly/deconstruction round-trip of the path below. + if cols, ok := w.reencodableRowGroup(rowGroup); ok { + w.writer.currentRowGroup.configureBloomFilters(rowGroup.ColumnChunks(), rowGroup.NumRows()) + if err := w.writeRowGroupByColumn(cols); err != nil { + return 0, err + } + return w.writer.writeRowGroup(w.writer.currentRowGroup, rowGroup.Schema(), rowGroup.SortingColumns()) + } + w.writer.currentRowGroup.configureBloomFilters(rowGroup.ColumnChunks(), rowGroup.NumRows()) rows := rowGroup.Rows() defer rows.Close() n, err := CopyRows(w.writer, rows) @@ -723,6 +763,17 @@ func newConcurrentRowGroupWriter(w *writer, config *WriterConfig) *ConcurrentRow } if isDictionaryEncoding(encoding) { + // The deprecated PLAIN_DICTIONARY encoding is normalized to + // RLE_DICTIONARY: the spec defines a single dictionary data + // page layout for both enum values — Encodings.md: "Data page + // format: the bit width used to encode the entry ids stored + // as 1 byte (max bit width = 32), followed by the values + // encoded using the RLE/Bit-Packing described above" — so the + // plain int32 index layout of plain.DictionaryEncoding + // produces pages no reader understands. Schemas derived from + // files written by legacy writers report PLAIN_DICTIONARY as + // the column encoding, which is how the configuration arises. + encoding = &RLEDictionary dictBuffer := columnType.NewValues(make([]byte, 0, defaultDictBufferSize), nil) dictionary = columnType.NewDictionary(columnIndex, 0, dictBuffer) columnType = dictionary.Type() @@ -754,7 +805,7 @@ func newConcurrentRowGroupWriter(w *writer, config *WriterConfig) *ConcurrentRow dictionaryMaxBytes: config.DictionaryMaxBytes, } - if lt := leaf.node.Type().LogicalType(); lt != nil && (lt.Geometry != nil || lt.Geography != nil) { + if lt := leaf.node.Type().LogicalType(); logicalTypeIs[*format.GeometryType](lt) || logicalTypeIs[*format.GeographyType](lt) { c.geospatialAccumulator = newGeospatialBBoxAccumulator() } @@ -834,11 +885,53 @@ func (rg *ConcurrentRowGroupWriter) reset() { } } -func (rg *ConcurrentRowGroupWriter) configureBloomFilters(columnChunks []ColumnChunk) { +func (rg *ConcurrentRowGroupWriter) configureBloomFilters(columnChunks []ColumnChunk, numRows int64) { for i, c := range rg.columns { - if c.columnFilter != nil { - c.resizeBloomFilter(columnChunks[i].NumValues()) + if c.columnFilter == nil { + continue } + // When the source only knows an upper bound of its value count + // (row-range views of repeated columns), leave the filter + // unallocated: flushFilterPages then builds it from the actual + // number of values written, keeping the filter exactly the size + // the configuration prescribes. + if !chunkNumValuesIsExact(columnChunks[i]) { + continue + } + values := columnChunks[i].NumValues() + if numRows > rg.maxRows { + // The input will be split across multiple output row groups, so the + // whole-input value count over-sizes each group's filter. + if c.maxRepetitionLevel > 0 { + // Repeated columns can hold more values than rows, so we can't + // apportion the value count per group ahead of time. Leave the + // filter unallocated and let each group size itself exactly at + // flush time (see flushFilterPages). + continue + } + // Non-repeated columns hold at most one value per row, so a full + // output group holds at most maxRows values. + values = min(values, rg.maxRows) + } + c.resizeBloomFilter(values) + } +} + +// chunkNumValuesIsExact reports whether chunk.NumValues() is the exact number +// of values, as opposed to an upper bound (see rangeColumnChunk). +func chunkNumValuesIsExact(chunk ColumnChunk) bool { + switch c := chunk.(type) { + case *rangeColumnChunk: + return c.exactNumValues() + case *multiColumnChunk: + for _, part := range c.chunks { + if !chunkNumValuesIsExact(part) { + return false + } + } + return true + default: + return true } } @@ -1031,10 +1124,10 @@ func newWriter(output io.Writer, config *WriterConfig) *writer { // column is of logical type decimal. logicalType := nodeType.LogicalType() if logicalType != nil { - elem.LogicalType.Set(*logicalType) - if logicalType.Decimal != nil { - elem.Scale.Set(logicalType.Decimal.Scale) - elem.Precision.Set(logicalType.Decimal.Precision) + elem.LogicalType = *logicalType + if decimal, ok := logicalType.Value.(*format.DecimalType); ok { + elem.Scale.Set(decimal.Scale) + elem.Precision.Set(decimal.Precision) } } @@ -1226,11 +1319,11 @@ func (w *writer) writeFileFooter() error { if w.encryption == nil { return nil } - switch { - case c.CryptoMetadata.EncryptionWithFooterKey != nil: + switch crypto := c.CryptoMetadata.Value.(type) { + case *format.EncryptionWithFooterKey: return w.encryption.cfg.FooterKey - case c.CryptoMetadata.EncryptionWithColumnKey != nil: - return w.encryption.columnKeyFor(columnPathString(c.CryptoMetadata.EncryptionWithColumnKey.PathInSchema)) + case *format.EncryptionWithColumnKey: + return w.encryption.columnKeyFor(columnPathString(crypto.PathInSchema)) default: return nil } @@ -1313,7 +1406,7 @@ func (w *writer) writeFileFooter() error { if w.encryption != nil { enc := w.encryption algo := format.EncryptionAlgorithm{ - AesGcmV1: &format.AesGcmV1{ + Value: &format.AesGcmV1{ AadFileUnique: enc.fileUnique, AadPrefix: enc.cfg.AadPrefix, }, @@ -1433,6 +1526,12 @@ func (w *writer) writeRowGroup(rg *ConcurrentRowGroupWriter, rowGroupSchema *Sch if err := c.Flush(); err != nil { return 0, err } + // Columns copied verbatim carry the source's bloom filter bytes (when + // configured); building a filter from the writer's (empty) buffers would + // produce a bogus one. + if c.copied != nil { + continue + } if err := c.flushFilterPages(); err != nil { return 0, err } @@ -1444,6 +1543,34 @@ func (w *writer) writeRowGroup(rg *ConcurrentRowGroupWriter, rowGroupSchema *Sch fileOffset := w.writer.offset for i, c := range rg.columns { + if c.copied != nil { + // Column copied verbatim: use the source's column index and size + // statistics, and stream the dictionary and data page bytes straight + // from the source file into the output (no intermediate buffer). + cc := c.copied + rg.columnIndex[i] = cc.columnIndex + c.columnChunk.MetaData.SizeStatistics = cc.sizeStats + + if cc.dictLength > 0 { + c.columnChunk.MetaData.DictionaryPageOffset = w.writer.offset + if _, err := w.writer.ReadFrom(io.NewSectionReader(cc.reader, cc.dictOffset, cc.dictLength)); err != nil { + return 0, fmt.Errorf("writing copied dictionary page of row group column %d: %w", i, err) + } + } + + dataPageOffset := w.writer.offset + c.columnChunk.MetaData.DataPageOffset = dataPageOffset + for j := range c.offsetIndex.PageLocations { + c.offsetIndex.PageLocations[j].Offset += dataPageOffset + } + if cc.dataLength > 0 { + if _, err := w.writer.ReadFrom(io.NewSectionReader(cc.reader, cc.dataOffset, cc.dataLength)); err != nil { + return 0, fmt.Errorf("writing copied data pages of row group column %d: %w", i, err) + } + } + continue + } + rg.columnIndex[i] = c.columnIndex.ColumnIndex() rg.columnIndex[i].RepetitionLevelHistogram = append(rg.columnIndex[i].RepetitionLevelHistogram[:0], c.pageRepetitionLevelHistograms...) rg.columnIndex[i].DefinitionLevelHistogram = append(rg.columnIndex[i].DefinitionLevelHistogram[:0], c.pageDefinitionLevelHistograms...) @@ -1483,6 +1610,41 @@ func (w *writer) writeRowGroup(rg *ConcurrentRowGroupWriter, rowGroupSchema *Sch } for i, c := range rg.columns { + // Columns copied verbatim carry the source's bloom filter as a raw byte + // range (header + bitset); stream it through unchanged. + if c.copied != nil && c.copied.bloomLength > 0 { + cc := c.copied + bloom := io.NewSectionReader(cc.reader, cc.bloomOffset, cc.bloomLength) + + if rg.config.DeferredBloomFiltersBuffers != nil { + buf := rg.config.DeferredBloomFiltersBuffers.GetBuffer() + reset := func() { rg.config.DeferredBloomFiltersBuffers.PutBuffer(buf) } + if _, err := io.Copy(buf, bloom); err != nil { + reset() + return 0, fmt.Errorf("copying bloom filter of row group column %d: %w", i, err) + } + if _, err := buf.Seek(0, io.SeekStart); err != nil { + reset() + return 0, err + } + w.deferredBloomFilterSize += cc.bloomLength + w.deferredBloomFilters = append(w.deferredBloomFilters, deferredBloomFilter{ + rowGroup: rowGroupIndex, + column: i, + buf: buf, + reset: reset, + }) + continue + } + + c.columnChunk.MetaData.BloomFilterOffset = w.writer.offset + if _, err := w.writer.ReadFrom(bloom); err != nil { + return 0, fmt.Errorf("copying bloom filter of row group column %d: %w", i, err) + } + c.columnChunk.MetaData.BloomFilterLength = int32(cc.bloomLength) + continue + } + if len(c.filter) == 0 { continue } @@ -1541,12 +1703,12 @@ func (w *writer) writeRowGroup(rg *ConcurrentRowGroupWriter, rowGroupSchema *Sch _, hasColumnKey := w.encryption.cfg.ColumnKeys[path] if !hasColumnKey { c.columnChunk.CryptoMetadata = format.ColumnCryptoMetaData{ - EncryptionWithFooterKey: &format.EncryptionWithFooterKey{}, + Value: &format.EncryptionWithFooterKey{}, } } else { c.columnChunk.CryptoMetadata = format.ColumnCryptoMetaData{ - EncryptionWithColumnKey: &format.EncryptionWithColumnKey{ - PathInSchema: c.columnPath, + Value: &format.EncryptionWithColumnKey{ + PathInSchema: thrift.Slice[string](c.columnPath), }, } } @@ -1639,7 +1801,7 @@ func (w *writer) writeRowGroup(rg *ConcurrentRowGroupWriter, rowGroupSchema *Sch } for i := range columns { c := &columns[i] - c.MetaData.EncodingStats = append(c.MetaData.EncodingStats[:0], rg.columnChunk[i].MetaData.EncodingStats...) + c.MetaData.EncodingStats = slices.Clone(rg.columnChunk[i].MetaData.EncodingStats) } for i := range offsetIndex { @@ -1839,6 +2001,10 @@ type ColumnWriter struct { hasSwitchedToPlain bool // Tracks if dictionary encoding was switched to PLAIN dictionaryMaxBytes int64 // Per-column dictionary size limit + // Set when this column is being copied verbatim from a source file for the + // current row group (see writer_copy.go). nil for the regular re-encode path. + copied *copiedChunk + // Encryption state; nil encKey means column is not encrypted. encKey []byte rowGroupOrdinal int16 @@ -1878,6 +2044,7 @@ func (c *ColumnWriter) reset() { c.pageBuffer = nil } c.numPages = 0 + c.copied = nil // Bloom filters may change in size between row groups, but we retain the // buffer to avoid reallocating large memory blocks. c.filter = c.filter[:0] diff --git a/vendor/github.com/parquet-go/parquet-go/writer_copy.go b/vendor/github.com/parquet-go/parquet-go/writer_copy.go new file mode 100644 index 00000000000..067e35c6a72 --- /dev/null +++ b/vendor/github.com/parquet-go/parquet-go/writer_copy.go @@ -0,0 +1,426 @@ +package parquet + +import ( + "fmt" + "io" + "slices" + "sync/atomic" + + "github.com/parquet-go/parquet-go/encoding/thrift" + "github.com/parquet-go/parquet-go/format" +) + +// copyPathCounter counts column chunks copied verbatim. It exists so tests can +// assert that the L0 fast path was taken; it is otherwise unused. +var copyPathCounter atomic.Int64 + +// disableWriteCopy forces WriteRowGroup onto the regular re-encode path. It +// exists only so benchmarks can measure the copy optimization against an +// otherwise identical baseline. +var disableWriteCopy bool + +// This file implements the "L0" copy optimization for Writer.WriteRowGroup: +// when a source row group's column chunks can be copied verbatim (compressed +// bytes moved through without decompression, decoding, re-encoding, or +// re-compression), the writer splices the source bytes directly into the output +// and copies the associated statistics and page index. +// +// The optimization is transparent: WriteRowGroup detects copyable sources and +// falls back to the regular re-encode path otherwise. It is conservative — it +// only fires when a verbatim copy is provably indistinguishable from the +// configured re-encode behavior (matching type, encoding, codec, data page +// version; no encryption; no writer-requested bloom filter; source statistics +// and page index present). See docs/merge-copy-optimization.md. +// +// Increment 1 is all-or-nothing per row group: every column chunk must be +// copyable, otherwise the whole row group falls back to the regular path. + +// copiedChunk holds the prebuilt metadata for a column chunk copied verbatim +// from a source file, plus the source byte ranges of its dictionary and data +// pages. The bytes are streamed directly from the source into the output during +// row group assembly (no intermediate buffer or per-chunk allocation). +type copiedChunk struct { + reader io.ReaderAt // source file reader + dictOffset int64 // byte offset of the dictionary page in the source + dictLength int64 // length of the dictionary page, 0 if none + dataOffset int64 // byte offset of the first data page in the source + dataLength int64 // length of all data pages + bloomOffset int64 // byte offset of the bloom filter in the source + bloomLength int64 // length of the bloom filter (header + bitset), 0 if not copied + columnIndex format.ColumnIndex + sizeStats format.SizeStatistics + statistics format.Statistics + encodingStats []format.PageEncodingStats + numValues int64 + numRows int64 + + totalUncompressedSize int64 + totalCompressedSize int64 +} + +// orderedRowGroupSegments is implemented by row groups that are the in-order +// concatenation of independently writable sub-row-groups: writing the segments +// in sequence yields the same rows, in the same order, as reading Rows(). It is +// used so the writer can route copyable segments of a merge through the verbatim +// copy fast path. A row group whose order depends on interleaving across its +// children (e.g. an overlapping heap merge) or that applies cross-segment +// deduplication must return nil to opt out. +type orderedRowGroupSegments interface { + rowGroupSegments() []RowGroup +} + +// splittableCopyableSegments returns the writable segments of rowGroup when it +// is a segmented row group and at least one segment can be written through an +// optimized segment path. The writer then emits packed output row groups so +// copyable single segments can take the L0 fast path and multi-segment batches +// can take the L3 column-oriented packing path. Splitting is gated on +// optimization eligibility so that pure re-encode merges keep their existing +// output structure. +func (w *Writer) splittableCopyableSegments(rowGroup RowGroup) ([]RowGroup, bool) { + if disableWriteCopy && disableWriteReencode { + return nil, false + } + v, ok := rowGroup.(orderedRowGroupSegments) + if !ok { + return nil, false + } + segments := v.rowGroupSegments() + if len(segments) <= 1 { + return nil, false + } + for _, seg := range segments { + if _, ok := w.copyableColumnChunks(seg); ok { + return segments, true + } + if _, ok := w.reencodableRowGroup(seg); ok { + return segments, true + } + } + return nil, false +} + +// copyableColumnChunks returns the source column chunks of rowGroup if the whole +// row group can be copied verbatim into the writer's output, along with true. +// Otherwise it returns nil and false, indicating the caller must fall back to +// the regular re-encode path. +func (w *Writer) copyableColumnChunks(rowGroup RowGroup) ([]*FileColumnChunk, bool) { + if disableWriteCopy { + return nil, false + } + // A verbatim byte copy cannot honor encryption: per-page AAD keys depend on + // the output row-group/column/page ordinals, so an encrypted output requires + // re-encoding from plaintext. + if w.writer.encryption != nil { + return nil, false + } + // A verbatim copy reproduces the source row group as a single output row + // group, so it cannot honor a smaller configured MaxRowsPerRowGroup. When the + // source exceeds the limit, demote so the row path splits it correctly. + if rowGroup.NumRows() > w.writer.currentRowGroup.maxRows { + return nil, false + } + // Row groups whose Rows() implements semantics beyond reading the column + // chunks in order cannot be handled at the chunk level. + if !chunkTransparentRowGroup(rowGroup) { + return nil, false + } + + dst := w.writer.currentRowGroup.columns + columns := rowGroup.ColumnChunks() + if len(columns) != len(dst) { + return nil, false + } + + srcs := make([]*FileColumnChunk, len(columns)) + for i, col := range columns { + fc, ok := col.(*FileColumnChunk) + if !ok { + return nil, false + } + if !columnChunkIsCopyable(dst[i], fc) { + return nil, false + } + srcs[i] = fc + } + return srcs, true +} + +// chunkTransparentMarker is implemented by row group types for which reading +// the column chunks in order is equivalent to reading Rows(). The method is +// unexported on purpose: row group implementations outside this package cannot +// opt in, so they always take the row-oriented path, which honors whatever +// semantics their Rows() implements. +type chunkTransparentMarker interface { + chunkTransparentRowGroup() +} + +// chunkTransparentRowGroup reports whether reading rowGroup's column chunks in +// order is equivalent to reading its Rows(). The fast paths in this file and in +// writer_reencode.go operate on the column chunks directly, so they must only +// be applied to row group types that explicitly opt in via +// chunkTransparentMarker. Everything else — including application-defined +// RowGroup implementations — is conservatively assumed to implement semantics +// in Rows() and handled through the row-oriented path. +// +// Known examples of wrappers whose Rows() adds semantics on top of the chunks: +// +// - dedupRowGroup drops duplicated rows in Rows(); its ColumnChunks() are +// promoted unchanged from the wrapped row group, so a chunk-level copy +// would silently retain the duplicates. +// - convertedRowGroup applies value conversion in Rows() (e.g. numeric or +// time unit conversions); its ColumnChunks() expose the unconverted source +// chunks, so a chunk-level copy would emit pre-conversion values under the +// post-conversion schema. Note that a physical type check is not sufficient +// to detect this: conversions such as timestamp millis→micros change values +// while preserving the INT64 physical type. +// +// Identity conversions never produce wrappers (ConvertRowGroup returns the row +// group unwrapped when schemas are equal), so requiring the marker does not +// cost the fast paths anything in the matched-schema case. +func chunkTransparentRowGroup(rowGroup RowGroup) bool { + _, ok := rowGroup.(chunkTransparentMarker) + return ok +} + +// loadCopiedChunks stages every source column chunk into its destination +// ColumnWriter. The per-column work here is cheap (it reads only the page index +// and records byte ranges); the data bytes are streamed straight to the output +// during row group assembly, so this is done sequentially. +func (w *Writer) loadCopiedChunks(srcs []*FileColumnChunk) error { + cols := w.writer.currentRowGroup.columns + for i, src := range srcs { + if err := cols[i].loadCopiedChunk(src); err != nil { + return err + } + } + return nil +} + +// columnChunkIsCopyable reports whether the source chunk can be copied verbatim +// into the column managed by dst, producing output indistinguishable from the +// configured re-encode behavior. +func columnChunkIsCopyable(dst *ColumnWriter, src *FileColumnChunk) bool { + // Source must be plaintext; we cannot copy ciphertext into a plaintext file. + if src.decryptionKey != nil { + return false + } + // Destination must not be encrypting (also covered by the writer-level check, + // kept here for defensiveness). + if dst.encKey != nil { + return false + } + + meta := &src.chunk.MetaData + + // Physical type must match. + if meta.Type != format.Type(dst.columnType.Kind()) { + return false + } + // Compression codec must match the configured codec. + if meta.Codec != dst.compression.CompressionCodec() { + return false + } + // A writer-requested bloom filter can only be satisfied by a verbatim copy + // when the source chunk carries a filter equivalent to the one the writer + // would build; otherwise the filter must be recomputed from decoded values. + if dst.columnFilter != nil && !bloomFilterIsCopyable(dst, src) { + return false + } + // We copy statistics and the page index from the source; require both to be + // present so the output honors the writer's statistics configuration. + if src.chunk.ColumnIndexOffset == 0 || src.chunk.OffsetIndexOffset == 0 { + return false + } + // All data pages must use the configured encoding and data page version, and + // dictionary presence must match the configured encoding. + if !encodingStatsMatch(meta.EncodingStats, dst) { + return false + } + return true +} + +// encodingStatsMatch reports whether every page recorded in the source encoding +// stats is compatible with the destination column's configured encoding and +// data page version. +func encodingStatsMatch(stats []format.PageEncodingStats, dst *ColumnWriter) bool { + if len(stats) == 0 { + return false // cannot verify the source encodings; demote + } + + wantPageType := dst.header.page.Type // DataPage (v1) or DataPageV2 + wantEncoding := dst.encoding.Encoding() + wantDict := dst.dictionary != nil + sawDict := false + + for _, s := range stats { + switch s.PageType { + case format.DictionaryPage: + sawDict = true + if !wantDict { + return false + } + case format.DataPage, format.DataPageV2: + if s.PageType != wantPageType { + return false // data page version mismatch + } + if s.Encoding != wantEncoding { + return false // encoding mismatch + } + default: + return false + } + } + + if wantDict != sawDict { + return false + } + return true +} + +// bloomFilterIsCopyable reports whether the source chunk carries a bloom filter +// equivalent to the one the destination column writer is configured to build, +// so that copying its bytes verbatim is indistinguishable from recomputing it: +// +// - the source records the filter location and length (older files omit the +// length, in which case the byte range is unknown); +// - both source and destination use the uncompressed filter representation +// (this library's default; compressed filters would require comparing +// post-compression content); +// - the source header describes the same algorithm and hash the writer would +// use (split-block, xxhash — the only ones supported); and +// - the source bitset has exactly the size the destination filter would +// allocate for this chunk's value count, i.e. the same bits-per-value. +func bloomFilterIsCopyable(dst *ColumnWriter, src *FileColumnChunk) bool { + meta := &src.chunk.MetaData + if meta.BloomFilterOffset == 0 || meta.BloomFilterLength <= 0 { + return false + } + if dst.bloomFilterCompression != nil && dst.bloomFilterCompression.CompressionCodec() != format.Uncompressed { + return false + } + + section := io.NewSectionReader(src.file.reader, meta.BloomFilterOffset, int64(meta.BloomFilterLength)) + rbuf, rbufpool := getBufioReader(section, 1024) + defer putBufioReader(rbuf, rbufpool) + + var header format.BloomFilterHeader + compact := thrift.CompactProtocol{} + if err := thrift.NewDecoder(compact.NewReader(rbuf)).Decode(&header); err != nil { + return false + } + if !isSplitBlockAlgorithm(&header) || !isXxHash(&header) { + return false + } + if _, ok := header.Compression.Value.(*format.BloomFilterUncompressed); !ok { + return false + } + return int(header.NumBytes) == dst.columnFilter.Size(meta.NumValues) +} + +// loadCopiedChunk prepares the destination ColumnWriter to emit a source column +// chunk verbatim during row group assembly. It does not read the page bytes — +// only the (much smaller) page index and statistics — and records the source +// byte ranges so the data can be streamed straight to the output later, avoiding +// a per-chunk allocation and an extra copy. +func (c *ColumnWriter) loadCopiedChunk(src *FileColumnChunk) error { + meta := &src.chunk.MetaData + + // The dictionary page (if any) and the data pages are contiguous byte ranges + // in the source file. + dataOffset := meta.DataPageOffset + dataLength := meta.TotalCompressedSize + var dictOffset, dictLength int64 + if meta.DictionaryPageOffset != 0 { + dictOffset = meta.DictionaryPageOffset + dictLength = meta.DataPageOffset - meta.DictionaryPageOffset + if dictLength < 0 || dictLength > meta.TotalCompressedSize { + return fmt.Errorf("invalid source column chunk layout: dictionary offset %d, data offset %d, total %d", + meta.DictionaryPageOffset, meta.DataPageOffset, meta.TotalCompressedSize) + } + dataLength = meta.TotalCompressedSize - dictLength + } + + // Copy the column index verbatim (type matches, so the raw min/max bytes are + // directly reusable). + ci, err := src.ColumnIndex() + if err != nil { + return fmt.Errorf("reading source column index: %w", err) + } + + // Rebuild page locations relative to the start of the data region; the writer + // re-absolutizes them once the output data page offset is known. + oi, err := src.OffsetIndex() + if err != nil { + return fmt.Errorf("reading source offset index: %w", err) + } + srcLocations := oi.(*FileOffsetIndex).index.PageLocations + locations := make([]format.PageLocation, len(srcLocations)) + for i, loc := range srcLocations { + loc.Offset -= meta.DataPageOffset + locations[i] = loc + } + + cc := &copiedChunk{ + reader: src.file.reader, + dictOffset: dictOffset, + dictLength: dictLength, + dataOffset: dataOffset, + dataLength: dataLength, + columnIndex: cloneColumnIndex(ci.(*FileColumnIndex).index), + sizeStats: cloneSizeStatistics(meta.SizeStatistics), + statistics: cloneStatistics(meta.Statistics), + encodingStats: slices.Clone(meta.EncodingStats), + numValues: meta.NumValues, + numRows: src.rowGroup.NumRows, + totalUncompressedSize: meta.TotalUncompressedSize, + totalCompressedSize: meta.TotalCompressedSize, + } + + // When the destination column is configured with a bloom filter, the copy + // predicate has already verified that the source carries an equivalent one; + // record its byte range so it is copied verbatim during assembly. + if c.columnFilter != nil { + cc.bloomOffset = meta.BloomFilterOffset + cc.bloomLength = int64(meta.BloomFilterLength) + } + + c.copied = cc + c.numRows = cc.numRows + c.numPages = len(locations) + c.offsetIndex.PageLocations = locations + copyPathCounter.Add(1) + + // Populate the column chunk metadata that the regular path would accumulate + // via recordPageStats. + c.columnChunk.MetaData.NumValues = cc.numValues + c.columnChunk.MetaData.TotalUncompressedSize = cc.totalUncompressedSize + c.columnChunk.MetaData.TotalCompressedSize = cc.totalCompressedSize + c.columnChunk.MetaData.Statistics = cc.statistics + c.columnChunk.MetaData.EncodingStats = append(c.columnChunk.MetaData.EncodingStats[:0], cc.encodingStats...) + return nil +} + +func cloneStatistics(s format.Statistics) format.Statistics { + s.Min = slices.Clone(s.Min) + s.Max = slices.Clone(s.Max) + s.MinValue = slices.Clone(s.MinValue) + s.MaxValue = slices.Clone(s.MaxValue) + return s +} + +func cloneSizeStatistics(s format.SizeStatistics) format.SizeStatistics { + s.RepetitionLevelHistogram = slices.Clone(s.RepetitionLevelHistogram) + s.DefinitionLevelHistogram = slices.Clone(s.DefinitionLevelHistogram) + return s +} + +func cloneColumnIndex(index *format.ColumnIndex) format.ColumnIndex { + out := *index + out.NullPages = slices.Clone(index.NullPages) + out.MinValues = slices.Clone(index.MinValues) + out.MaxValues = slices.Clone(index.MaxValues) + out.NullCounts = slices.Clone(index.NullCounts) + out.RepetitionLevelHistogram = slices.Clone(index.RepetitionLevelHistogram) + out.DefinitionLevelHistogram = slices.Clone(index.DefinitionLevelHistogram) + return out +} diff --git a/vendor/github.com/parquet-go/parquet-go/writer_reencode.go b/vendor/github.com/parquet-go/parquet-go/writer_reencode.go new file mode 100644 index 00000000000..5b91b0884e1 --- /dev/null +++ b/vendor/github.com/parquet-go/parquet-go/writer_reencode.go @@ -0,0 +1,233 @@ +package parquet + +import ( + "io" + "sync/atomic" +) + +// This file implements the "L3" re-encode path for Writer.WriteRowGroup: when a +// single file-backed source row group's schema matches the writer but it cannot +// be copied verbatim (the configured codec/encoding/etc. differ), re-encode it +// column-by-column instead of assembling rows and then deconstructing them. +// +// The regular fallback reads the source columns, interleaves their values into +// Row objects, then immediately tears those rows back apart into columns to +// re-encode. L3 skips that round-trip: it reads each column's values directly +// and writes them straight through the column writer (which still re-encodes, +// re-compresses, computes statistics, and populates bloom filters exactly as the +// row path would). +// +// L3 still decodes and re-encodes values, so it is far less of a win than the +// verbatim copy (L0); its benefit is avoiding the row round-trip (measured +// ~1.4–1.8x faster with notably less garbage). See +// docs/merge-copy-optimization.md. + +// reencodePathCounter counts row groups written via the L3 column-oriented +// re-encode path. Test/benchmark instrumentation only. +var reencodePathCounter atomic.Int64 + +// disableWriteReencode forces WriteRowGroup onto the row-oriented fallback. It +// exists only so benchmarks can measure L3 against an otherwise identical +// baseline. +var disableWriteReencode bool + +// columnOrientedRowGroup reports whether every column of rowGroup can be read +// column-wise while preserving row order, and the row count fits the configured +// row group size. This holds for file-backed chunks (a single row group of a +// parquet file) and for in-memory column buffers (parquet.Buffer / +// GenericBuffer, whose columns are reordered together when sorted); it excludes +// overlapping heap merges, whose row order depends on cross-column +// interleaving. The size check ensures column-wise writing does not produce a +// row group larger than the row path would. Row groups whose Rows() adds +// semantics on top of the chunks (deduplication, value conversion) are rejected +// by chunkTransparentRowGroup — reading their chunks directly would bypass +// those semantics. +func (w *Writer) columnOrientedRowGroup(rowGroup RowGroup) ([]ColumnChunk, bool) { + if !chunkTransparentRowGroup(rowGroup) { + return nil, false + } + dst := w.writer.currentRowGroup.columns + columns := rowGroup.ColumnChunks() + if len(columns) == 0 || len(columns) != len(dst) { + return nil, false + } + for _, col := range columns { + if !columnOrientedChunk(col) { + return nil, false + } + } + if rowGroup.NumRows() > w.writer.currentRowGroup.maxRows { + return nil, false + } + return columns, true +} + +// columnOrientedChunk reports whether a column chunk can be read column-wise +// while preserving row order: file-backed chunks, in-memory column buffers, +// and row-range views over either. +func columnOrientedChunk(col ColumnChunk) bool { + switch c := col.(type) { + case *FileColumnChunk: + return true + case ColumnBuffer: + return true + case *rangeColumnChunk: + return columnOrientedChunk(c.base) + default: + return false + } +} + +// reencodableRowGroup reports whether rowGroup can be written via the L3 +// column-oriented re-encode path. +func (w *Writer) reencodableRowGroup(rowGroup RowGroup) ([]ColumnChunk, bool) { + if disableWriteReencode { + return nil, false + } + return w.columnOrientedRowGroup(rowGroup) +} + +// writeSegmentsPacked writes the segments of a split merge, packing consecutive +// file-backed (non-overlapping) segments into output row groups up to the +// configured MaxRowsPerRowGroup. A single-segment batch is written through the +// normal path (preserving the verbatim L0 fast path for the 1:1 case); a +// multi-segment batch is consolidated column-by-column via L3 into one output +// row group, undershooting MaxRowsPerRowGroup as needed. Non-file-backed +// segments (overlapping heap merges) or segments larger than the limit flush the +// pending batch and are written individually through the row path. +func (w *Writer) writeSegmentsPacked(segments []RowGroup, schema *Schema, sortingColumns []SortingColumn) (int64, error) { + maxRows := w.writer.currentRowGroup.maxRows + + var ( + total int64 + pending []RowGroup + pendingRows int64 + ) + + flushPending := func() error { + var ( + n int64 + err error + ) + switch len(pending) { + case 0: + return nil + case 1: + n, err = w.WriteRowGroup(pending[0]) + default: + n, err = w.packSegmentsByColumn(pending, schema, sortingColumns) + } + total += n + pending = pending[:0] + pendingRows = 0 + return err + } + + for _, seg := range segments { + if _, ok := w.columnOrientedRowGroup(seg); ok { + if pendingRows > 0 && pendingRows+seg.NumRows() > maxRows { + if err := flushPending(); err != nil { + return total, err + } + } + pending = append(pending, seg) + pendingRows += seg.NumRows() + continue + } + if err := flushPending(); err != nil { + return total, err + } + n, err := w.WriteRowGroup(seg) + total += n + if err != nil { + return total, err + } + } + if err := flushPending(); err != nil { + return total, err + } + return total, nil +} + +// packSegmentsByColumn consolidates several file-backed segments into a single +// output row group by re-encoding each column across all segments in order. +func (w *Writer) packSegmentsByColumn(segments []RowGroup, schema *Schema, sortingColumns []SortingColumn) (int64, error) { + if err := w.writer.flush(); err != nil { + return 0, err + } + dst := w.writer.currentRowGroup.columns + w.configureBloomFiltersForSegments(segments) + for _, seg := range segments { + columns := seg.ColumnChunks() + for i := range columns { + if err := copyColumnValues(dst[i], columns[i]); err != nil { + return 0, err + } + } + } + reencodePathCounter.Add(1) + return w.writer.writeRowGroup(w.writer.currentRowGroup, schema, sortingColumns) +} + +// configureBloomFiltersForSegments sizes each column's bloom filter for the +// total number of values across all segments being packed together. Columns +// whose value count is only an upper bound (row-range views of repeated +// columns) are left unallocated so flushFilterPages sizes the filter from the +// number of values actually written. +func (w *Writer) configureBloomFiltersForSegments(segments []RowGroup) { + for i, c := range w.writer.currentRowGroup.columns { + if c.columnFilter == nil { + continue + } + total := int64(0) + exact := true + for _, seg := range segments { + chunk := seg.ColumnChunks()[i] + exact = exact && chunkNumValuesIsExact(chunk) + total += chunk.NumValues() + } + if exact { + c.resizeBloomFilter(total) + } + } +} + +// writeRowGroupByColumn re-encodes each source column chunk into its destination +// column writer, reading values column-wise instead of materializing rows. +func (w *Writer) writeRowGroupByColumn(columns []ColumnChunk) error { + dst := w.writer.currentRowGroup.columns + for i, col := range columns { + if err := copyColumnValues(dst[i], col); err != nil { + return err + } + } + reencodePathCounter.Add(1) + return nil +} + +// reencodeValueBufferSize is the batch size for column-wise value copies. Larger +// than the default value buffer to amortize per-call overhead. +const reencodeValueBufferSize = 1024 + +// copyColumnValues reads every value of src in order and writes it to dst, +// without materializing rows. +func copyColumnValues(dst *ColumnWriter, src ColumnChunk) error { + reader := NewColumnChunkValueReader(src) + defer reader.Close() + + buf := make([]Value, reencodeValueBufferSize) + for { + n, err := reader.ReadValues(buf) + if n > 0 { + if _, werr := dst.WriteRowValues(buf[:n]); werr != nil { + return werr + } + } + if err != nil { + if err == io.EOF { + return nil + } + return err + } + } +} diff --git a/vendor/github.com/prometheus/client_golang/api/client.go b/vendor/github.com/prometheus/client_golang/api/client.go index 0e647b6756f..66844900d0c 100644 --- a/vendor/github.com/prometheus/client_golang/api/client.go +++ b/vendor/github.com/prometheus/client_golang/api/client.go @@ -27,13 +27,18 @@ import ( ) // DefaultRoundTripper is used if no RoundTripper is set in Config. +// refer https://github.com/golang/go/blob/master/src/net/http/transport.go#L46 var DefaultRoundTripper http.RoundTripper = &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, }).DialContext, - TLSHandshakeTimeout: 10 * time.Second, + ForceAttemptHTTP2: true, + MaxIdleConns: 100, + IdleConnTimeout: 90 * time.Second, + TLSHandshakeTimeout: 10 * time.Second, + ExpectContinueTimeout: 1 * time.Second, } // Config defines configuration parameters for a new client. @@ -136,21 +141,21 @@ func (c *httpClient) Do(ctx context.Context, req *http.Request) (*http.Response, } var body []byte - done := make(chan error, 1) + done := make(chan struct{}) + var readErr error go func() { + defer close(done) var buf bytes.Buffer - _, err := buf.ReadFrom(resp.Body) + _, readErr = buf.ReadFrom(resp.Body) body = buf.Bytes() - done <- err }() select { case <-ctx.Done(): resp.Body.Close() - <-done return resp, nil, ctx.Err() - case err = <-done: + case <-done: resp.Body.Close() - return resp, body, err + return resp, body, readErr } } diff --git a/vendor/github.com/prometheus/client_golang/api/prometheus/v1/api.go b/vendor/github.com/prometheus/client_golang/api/prometheus/v1/api.go index 8a72f9bfc7b..61094cb1ae2 100644 --- a/vendor/github.com/prometheus/client_golang/api/prometheus/v1/api.go +++ b/vendor/github.com/prometheus/client_golang/api/prometheus/v1/api.go @@ -380,7 +380,9 @@ const ( epBuildinfo = apiPrefix + "/status/buildinfo" epRuntimeinfo = apiPrefix + "/status/runtimeinfo" epTSDB = apiPrefix + "/status/tsdb" + epTSDBBlocks = apiPrefix + "/status/tsdb/blocks" epWalReplay = apiPrefix + "/status/walreplay" + epFormatQuery = apiPrefix + "/format_query" ) // AlertState models the state of an alert. @@ -475,7 +477,7 @@ type API interface { // Flags returns the flag values that Prometheus was launched with. Flags(ctx context.Context) (FlagsResult, error) // LabelNames returns the unique label names present in the block in sorted order by given time range and matchers. - LabelNames(ctx context.Context, matches []string, startTime, endTime time.Time, opts ...Option) ([]string, Warnings, error) + LabelNames(ctx context.Context, matches []string, startTime, endTime time.Time, opts ...Option) (model.LabelNames, Warnings, error) // LabelValues performs a query for the values of the given label, time range and matchers. LabelValues(ctx context.Context, label string, matches []string, startTime, endTime time.Time, opts ...Option) (model.LabelValues, Warnings, error) // Query performs a query for the given time. @@ -494,7 +496,7 @@ type API interface { // under the TSDB's data directory and returns the directory as response. Snapshot(ctx context.Context, skipHead bool) (SnapshotResult, error) // Rules returns a list of alerting and recording rules that are currently loaded. - Rules(ctx context.Context) (RulesResult, error) + Rules(ctx context.Context, matches []string) (RulesResult, error) // Targets returns an overview of the current state of the Prometheus target discovery. Targets(ctx context.Context) (TargetsResult, error) // TargetsMetadata returns metadata about metrics currently scraped by the target. @@ -503,8 +505,12 @@ type API interface { Metadata(ctx context.Context, metric, limit string) (map[string][]Metadata, error) // TSDB returns the cardinality statistics. TSDB(ctx context.Context, opts ...Option) (TSDBResult, error) + // TSDBBlocks returns the list of currently loaded TSDB blocks and their metadata. + TSDBBlocks(ctx context.Context) (TSDBBlocksResult, error) // WalReplay returns the current replay status of the wal. WalReplay(ctx context.Context) (WalReplayStatus, error) + // FormatQuery formats a PromQL expression in a prettified way. + FormatQuery(ctx context.Context, query string) (string, error) } // AlertsResult contains the result from querying the alerts endpoint. @@ -586,7 +592,7 @@ type RuleGroup struct { // default: // fmt.Printf("unknown rule type %s", v) // } -type Rules []interface{} +type Rules []any // AlertingRule models a alerting rule. type AlertingRule struct { @@ -666,7 +672,7 @@ type Metadata struct { // queryResult contains result data for a query. type queryResult struct { Type model.ValueType `json:"resultType"` - Result interface{} `json:"result"` + Result any `json:"result"` // The decoded value. v model.Value @@ -690,6 +696,40 @@ type TSDBHeadStats struct { MaxTime int `json:"maxTime"` } +// TSDBBlocksResult contains the results from querying the tsdb blocks endpoint. +type TSDBBlocksResult struct { + Status string `json:"status"` + Data TSDBBlocksData `json:"data"` +} + +// TSDBBlocksData contains the metadata for the tsdb blocks. +type TSDBBlocksData struct { + Blocks []TSDBBlocksBlockMetadata `json:"blocks"` +} + +// TSDBBlocksBlockMetadata contains the metadata for a single tsdb block. +type TSDBBlocksBlockMetadata struct { + Ulid string `json:"ulid"` + MinTime int64 `json:"minTime"` + MaxTime int64 `json:"maxTime"` + Stats TSDBBlocksStats `json:"stats"` + Compaction TSDBBlocksCompaction `json:"compaction"` + Version int `json:"version"` +} + +// TSDBBlocksStats contains block stats for a single tsdb block. +type TSDBBlocksStats struct { + NumSamples int `json:"numSamples"` + NumSeries int `json:"numSeries"` + NumChunks int `json:"numChunks"` +} + +// TSDBBlocksCompaction contains block compaction details for a single block. +type TSDBBlocksCompaction struct { + Level int `json:"level"` + Sources []string `json:"sources"` +} + // WalReplayStatus represents the wal replay status. type WalReplayStatus struct { Min int `json:"min"` @@ -1024,7 +1064,7 @@ func (h *httpAPI) Runtimeinfo(ctx context.Context) (RuntimeinfoResult, error) { return res, err } -func (h *httpAPI) LabelNames(ctx context.Context, matches []string, startTime, endTime time.Time, opts ...Option) ([]string, Warnings, error) { +func (h *httpAPI) LabelNames(ctx context.Context, matches []string, startTime, endTime time.Time, opts ...Option) (model.LabelNames, Warnings, error) { u := h.client.URL(epLabels, nil) q := addOptionalURLParams(u.Query(), opts) @@ -1042,7 +1082,7 @@ func (h *httpAPI) LabelNames(ctx context.Context, matches []string, startTime, e if err != nil { return nil, w, err } - var labelNames []string + var labelNames model.LabelNames err = json.Unmarshal(body, &labelNames) return labelNames, w, err } @@ -1235,8 +1275,15 @@ func (h *httpAPI) Snapshot(ctx context.Context, skipHead bool) (SnapshotResult, return res, err } -func (h *httpAPI) Rules(ctx context.Context) (RulesResult, error) { +func (h *httpAPI) Rules(ctx context.Context, matches []string) (RulesResult, error) { u := h.client.URL(epRules, nil) + q := u.Query() + + for _, m := range matches { + q.Add("match[]", m) + } + + u.RawQuery = q.Encode() req, err := http.NewRequest(http.MethodGet, u.String(), nil) if err != nil { @@ -1340,6 +1387,24 @@ func (h *httpAPI) TSDB(ctx context.Context, opts ...Option) (TSDBResult, error) return res, err } +func (h *httpAPI) TSDBBlocks(ctx context.Context) (TSDBBlocksResult, error) { + u := h.client.URL(epTSDBBlocks, nil) + + req, err := http.NewRequest(http.MethodGet, u.String(), nil) + if err != nil { + return TSDBBlocksResult{}, err + } + + _, body, _, err := h.client.Do(ctx, req) + if err != nil { + return TSDBBlocksResult{}, err + } + + var res TSDBBlocksResult + err = json.Unmarshal(body, &res) + return res, err +} + func (h *httpAPI) WalReplay(ctx context.Context) (WalReplayStatus, error) { u := h.client.URL(epWalReplay, nil) @@ -1380,6 +1445,19 @@ func (h *httpAPI) QueryExemplars(ctx context.Context, query string, startTime, e return res, err } +func (h *httpAPI) FormatQuery(ctx context.Context, query string) (string, error) { + u := h.client.URL(epFormatQuery, nil) + q := u.Query() + q.Set("query", query) + + _, body, _, err := h.client.DoGetFallback(ctx, u, q) + if err != nil { + return "", err + } + + return string(body), nil +} + // Warnings is an array of non critical errors type Warnings []string @@ -1467,8 +1545,8 @@ func (h *apiClientImpl) Do(ctx context.Context, req *http.Request) (*http.Respon return resp, []byte(result.Data), result.Warnings, err } -// DoGetFallback will attempt to do the request as-is, and on a 405 or 501 it -// will fallback to a GET request. +// DoGetFallback will attempt to do the request as-is, and on a 403, 405, or +// 501 it will fallback to a GET request. func (h *apiClientImpl) DoGetFallback(ctx context.Context, u *url.URL, args url.Values) (*http.Response, []byte, Warnings, error) { encodedArgs := args.Encode() req, err := http.NewRequest(http.MethodPost, u.String(), strings.NewReader(encodedArgs)) @@ -1486,7 +1564,7 @@ func (h *apiClientImpl) DoGetFallback(ctx context.Context, u *url.URL, args url. req.Header["Idempotency-Key"] = nil resp, body, warnings, err := h.Do(ctx, req) - if resp != nil && (resp.StatusCode == http.StatusMethodNotAllowed || resp.StatusCode == http.StatusNotImplemented) { + if resp != nil && (resp.StatusCode == http.StatusForbidden || resp.StatusCode == http.StatusMethodNotAllowed || resp.StatusCode == http.StatusNotImplemented) { u.RawQuery = encodedArgs req, err = http.NewRequest(http.MethodGet, u.String(), nil) if err != nil { diff --git a/vendor/github.com/prometheus/client_golang/internal/github.com/golang/gddo/httputil/header/header.go b/vendor/github.com/prometheus/client_golang/internal/github.com/golang/gddo/httputil/header/header.go index 8547c8dfd18..820bf436aba 100644 --- a/vendor/github.com/prometheus/client_golang/internal/github.com/golang/gddo/httputil/header/header.go +++ b/vendor/github.com/prometheus/client_golang/internal/github.com/golang/gddo/httputil/header/header.go @@ -90,7 +90,7 @@ loop: s = skipSpace(s[1:]) } } - return + return specs } func skipSpace(s string) (rest string) { diff --git a/vendor/github.com/prometheus/client_golang/prometheus/collectors/go_collector_go116.go b/vendor/github.com/prometheus/client_golang/prometheus/collectors/go_collector_go116.go deleted file mode 100644 index effc57840ae..00000000000 --- a/vendor/github.com/prometheus/client_golang/prometheus/collectors/go_collector_go116.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2021 The Prometheus Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//go:build !go1.17 -// +build !go1.17 - -package collectors - -import "github.com/prometheus/client_golang/prometheus" - -// NewGoCollector returns a collector that exports metrics about the current Go -// process. This includes memory stats. To collect those, runtime.ReadMemStats -// is called. This requires to “stop the world”, which usually only happens for -// garbage collection (GC). Take the following implications into account when -// deciding whether to use the Go collector: -// -// 1. The performance impact of stopping the world is the more relevant the more -// frequently metrics are collected. However, with Go1.9 or later the -// stop-the-world time per metrics collection is very short (~25µs) so that the -// performance impact will only matter in rare cases. However, with older Go -// versions, the stop-the-world duration depends on the heap size and can be -// quite significant (~1.7 ms/GiB as per -// https://go-review.googlesource.com/c/go/+/34937). -// -// 2. During an ongoing GC, nothing else can stop the world. Therefore, if the -// metrics collection happens to coincide with GC, it will only complete after -// GC has finished. Usually, GC is fast enough to not cause problems. However, -// with a very large heap, GC might take multiple seconds, which is enough to -// cause scrape timeouts in common setups. To avoid this problem, the Go -// collector will use the memstats from a previous collection if -// runtime.ReadMemStats takes more than 1s. However, if there are no previously -// collected memstats, or their collection is more than 5m ago, the collection -// will block until runtime.ReadMemStats succeeds. -// -// NOTE: The problem is solved in Go 1.15, see -// https://github.com/golang/go/issues/19812 for the related Go issue. -func NewGoCollector() prometheus.Collector { - return prometheus.NewGoCollector() -} diff --git a/vendor/github.com/prometheus/client_golang/prometheus/collectors/go_collector_latest.go b/vendor/github.com/prometheus/client_golang/prometheus/collectors/go_collector_latest.go index cc4ef1077e8..d29ade654fd 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/collectors/go_collector_latest.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/collectors/go_collector_latest.go @@ -90,13 +90,13 @@ func WithGoCollectorMemStatsMetricsDisabled() func(options *internal.GoCollector // GoRuntimeMetricsRule allow enabling and configuring particular group of runtime/metrics. // TODO(bwplotka): Consider adding ability to adjust buckets. type GoRuntimeMetricsRule struct { - // Matcher represents RE2 expression will match the runtime/metrics from https://golang.bg/src/runtime/metrics/description.go + // Matcher represents RE2 expression will match the runtime/metrics from https://pkg.go.dev/runtime/metrics // Use `regexp.MustCompile` or `regexp.Compile` to create this field. Matcher *regexp.Regexp } // WithGoCollectorRuntimeMetrics allows enabling and configuring particular group of runtime/metrics. -// See the list of metrics https://golang.bg/src/runtime/metrics/description.go (pick the Go version you use there!). +// See the list of metrics https://pkg.go.dev/runtime/metrics (pick the Go version you use there!). // You can use this option in repeated manner, which will add new rules. The order of rules is important, the last rule // that matches particular metrics is applied. func WithGoCollectorRuntimeMetrics(rules ...GoRuntimeMetricsRule) func(options *internal.GoCollectorOptions) { diff --git a/vendor/github.com/prometheus/client_golang/prometheus/collectors/version/version.go b/vendor/github.com/prometheus/client_golang/prometheus/collectors/version/version.go index c96e187126f..0306b5878c3 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/collectors/version/version.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/collectors/version/version.go @@ -15,15 +15,44 @@ package version import ( "fmt" + "maps" "github.com/prometheus/common/version" "github.com/prometheus/client_golang/prometheus" ) +type Option func(*options) + +type options struct { + extraConstLabels prometheus.Labels +} + +func WithExtraConstLabels(l prometheus.Labels) Option { + return func(o *options) { + o.extraConstLabels = l + } +} + // NewCollector returns a collector that exports metrics about current version // information. -func NewCollector(program string) prometheus.Collector { +func NewCollector(program string, opts ...Option) prometheus.Collector { + o := options{} + for _, opt := range opts { + opt(&o) + } + + constLabels := prometheus.Labels{ + "version": version.Version, + "revision": version.GetRevision(), + "branch": version.Branch, + "goversion": version.GoVersion, + "goos": version.GoOS, + "goarch": version.GoArch, + "tags": version.GetTags(), + } + maps.Copy(constLabels, o.extraConstLabels) + return prometheus.NewGaugeFunc( prometheus.GaugeOpts{ Namespace: program, @@ -32,15 +61,7 @@ func NewCollector(program string) prometheus.Collector { "A metric with a constant '1' value labeled by version, revision, branch, goversion from which %s was built, and the goos and goarch for the build.", program, ), - ConstLabels: prometheus.Labels{ - "version": version.Version, - "revision": version.GetRevision(), - "branch": version.Branch, - "goversion": version.GoVersion, - "goos": version.GoOS, - "goarch": version.GoArch, - "tags": version.GetTags(), - }, + ConstLabels: constLabels, }, func() float64 { return 1 }, ) diff --git a/vendor/github.com/prometheus/client_golang/prometheus/counter.go b/vendor/github.com/prometheus/client_golang/prometheus/counter.go index 4ce84e7a80e..7d963d3afb8 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/counter.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/counter.go @@ -85,11 +85,12 @@ type CounterVecOpts struct { // Both internal tracking values are added up in the Write method. This has to // be taken into account when it comes to precision and overflow behavior. func NewCounter(opts CounterOpts) Counter { - desc := NewDesc( + desc := V2.NewDesc( BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), opts.Help, - nil, + UnconstrainedLabels(nil), opts.ConstLabels, + WithUnit(opts.Unit), ) if opts.now == nil { opts.now = time.Now @@ -205,6 +206,7 @@ func (v2) NewCounterVec(opts CounterVecOpts) *CounterVec { opts.Help, opts.VariableLabels, opts.ConstLabels, + WithUnit(opts.Unit), ) if opts.now == nil { opts.now = time.Now @@ -349,10 +351,11 @@ type CounterFunc interface { // // Check out the ExampleGaugeFunc examples for the similar GaugeFunc. func NewCounterFunc(opts CounterOpts, function func() float64) CounterFunc { - return newValueFunc(NewDesc( + return newValueFunc(V2.NewDesc( BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), opts.Help, - nil, + UnconstrainedLabels(nil), opts.ConstLabels, + WithUnit(opts.Unit), ), CounterValue, function) } diff --git a/vendor/github.com/prometheus/client_golang/prometheus/desc.go b/vendor/github.com/prometheus/client_golang/prometheus/desc.go index 2331b8b4f3b..a3c92e7a4c1 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/desc.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/desc.go @@ -47,6 +47,8 @@ type Desc struct { fqName string // help provides some helpful information about this metric. help string + // unit provides the unit of this metric. + unit string // constLabelPairs contains precalculated DTO label pairs based on // the constant labels. constLabelPairs []*dto.LabelPair @@ -66,6 +68,16 @@ type Desc struct { err error } +// DescOpt allows setting optional fields for NewDesc. +type DescOpt func(*Desc) + +// WithUnit sets the unit for a Desc. +func WithUnit(unit string) DescOpt { + return func(d *Desc) { + d.unit = unit + } +} + // NewDesc allocates and initializes a new Desc. Errors are recorded in the Desc // and will be reported on registration time. variableLabels and constLabels can // be nil if no such labels should be set. fqName must not be empty. @@ -89,14 +101,17 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) * // // For constLabels, the label values are constant. Therefore, they are fully // specified in the Desc. See the Collector example for a usage pattern. -func (v2) NewDesc(fqName, help string, variableLabels ConstrainableLabels, constLabels Labels) *Desc { +func (v2) NewDesc(fqName, help string, variableLabels ConstrainableLabels, constLabels Labels, opts ...DescOpt) *Desc { d := &Desc{ fqName: fqName, help: help, variableLabels: variableLabels.compile(), } - //nolint:staticcheck // TODO: Don't use deprecated model.NameValidationScheme. - if !model.NameValidationScheme.IsValidMetricName(fqName) { + + for _, opt := range opts { + opt(d) + } + if !model.UTF8Validation.IsValidMetricName(fqName) { d.err = fmt.Errorf("%q is not a valid metric name", fqName) return d } @@ -150,11 +165,13 @@ func (v2) NewDesc(fqName, help string, variableLabels ConstrainableLabels, const d.id = xxh.Sum64() // Sort labelNames so that order doesn't matter for the hash. sort.Strings(labelNames) - // Now hash together (in this order) the help string and the sorted + // Now hash together (in this order) the help string, the unit string and the sorted // label names. xxh.Reset() xxh.WriteString(help) xxh.Write(separatorByteSlice) + xxh.WriteString(d.unit) + xxh.Write(separatorByteSlice) for _, labelName := range labelNames { xxh.WriteString(labelName) xxh.Write(separatorByteSlice) @@ -182,6 +199,15 @@ func NewInvalidDesc(err error) *Desc { } } +// Err returns an error that occurred during construction, if any. +// +// Calling this method is optional. It can be used to detect construction +// errors early, before invoking other methods on the Desc. If an error is +// present, later operations may not behave as expected. +func (d *Desc) Err() error { + return d.err +} + func (d *Desc) String() string { lpStrings := make([]string, 0, len(d.constLabelPairs)) for _, lp := range d.constLabelPairs { @@ -202,9 +228,10 @@ func (d *Desc) String() string { } } return fmt.Sprintf( - "Desc{fqName: %q, help: %q, constLabels: {%s}, variableLabels: {%s}}", + "Desc{fqName: %q, help: %q, unit: %q, constLabels: {%s}, variableLabels: {%s}}", d.fqName, d.help, + d.unit, strings.Join(lpStrings, ","), strings.Join(vlStrings, ","), ) diff --git a/vendor/github.com/prometheus/client_golang/prometheus/expvar_collector.go b/vendor/github.com/prometheus/client_golang/prometheus/expvar_collector.go index de5a8562931..327746f4337 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/expvar_collector.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/expvar_collector.go @@ -47,14 +47,14 @@ func (e *expvarCollector) Collect(ch chan<- Metric) { if expVar == nil { continue } - var v interface{} + var v any labels := make([]string, len(desc.variableLabels.names)) if err := json.Unmarshal([]byte(expVar.String()), &v); err != nil { ch <- NewInvalidMetric(desc, err) continue } - var processValue func(v interface{}, i int) - processValue = func(v interface{}, i int) { + var processValue func(v any, i int) + processValue = func(v any, i int) { if i >= len(labels) { copiedLabels := append(make([]string, 0, len(labels)), labels...) switch v := v.(type) { @@ -72,7 +72,7 @@ func (e *expvarCollector) Collect(ch chan<- Metric) { ch <- m return } - vm, ok := v.(map[string]interface{}) + vm, ok := v.(map[string]any) if !ok { return } diff --git a/vendor/github.com/prometheus/client_golang/prometheus/gauge.go b/vendor/github.com/prometheus/client_golang/prometheus/gauge.go index dd2eac94067..41e54bf270a 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/gauge.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/gauge.go @@ -76,11 +76,12 @@ type GaugeVecOpts struct { // scenarios for Gauges and Counters, where the former tends to be Set-heavy and // the latter Inc-heavy. func NewGauge(opts GaugeOpts) Gauge { - desc := NewDesc( + desc := V2.NewDesc( BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), opts.Help, - nil, + UnconstrainedLabels(nil), opts.ConstLabels, + WithUnit(opts.Unit), ) result := &gauge{desc: desc, labelPairs: desc.constLabelPairs} result.init(result) // Init self-collection. @@ -163,6 +164,7 @@ func (v2) NewGaugeVec(opts GaugeVecOpts) *GaugeVec { opts.Help, opts.VariableLabels, opts.ConstLabels, + WithUnit(opts.Unit), ) return &GaugeVec{ MetricVec: NewMetricVec(desc, func(lvs ...string) Metric { @@ -302,10 +304,11 @@ type GaugeFunc interface { // value of 1. Example: // https://github.com/prometheus/common/blob/8558a5b7db3c84fa38b4766966059a7bd5bfa2ee/version/info.go#L36-L56 func NewGaugeFunc(opts GaugeOpts, function func() float64) GaugeFunc { - return newValueFunc(NewDesc( + return newValueFunc(V2.NewDesc( BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), opts.Help, - nil, + UnconstrainedLabels(nil), opts.ConstLabels, + WithUnit(opts.Unit), ), GaugeValue, function) } diff --git a/vendor/github.com/prometheus/client_golang/prometheus/go_collector_go116.go b/vendor/github.com/prometheus/client_golang/prometheus/go_collector_go116.go deleted file mode 100644 index 897a6e906b3..00000000000 --- a/vendor/github.com/prometheus/client_golang/prometheus/go_collector_go116.go +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2021 The Prometheus Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//go:build !go1.17 -// +build !go1.17 - -package prometheus - -import ( - "runtime" - "sync" - "time" -) - -type goCollector struct { - base baseGoCollector - - // ms... are memstats related. - msLast *runtime.MemStats // Previously collected memstats. - msLastTimestamp time.Time - msMtx sync.Mutex // Protects msLast and msLastTimestamp. - msMetrics memStatsMetrics - msRead func(*runtime.MemStats) // For mocking in tests. - msMaxWait time.Duration // Wait time for fresh memstats. - msMaxAge time.Duration // Maximum allowed age of old memstats. -} - -// NewGoCollector is the obsolete version of collectors.NewGoCollector. -// See there for documentation. -// -// Deprecated: Use collectors.NewGoCollector instead. -func NewGoCollector() Collector { - msMetrics := goRuntimeMemStats() - msMetrics = append(msMetrics, struct { - desc *Desc - eval func(*runtime.MemStats) float64 - valType ValueType - }{ - // This metric is omitted in Go1.17+, see https://github.com/prometheus/client_golang/issues/842#issuecomment-861812034 - desc: NewDesc( - memstatNamespace("gc_cpu_fraction"), - "The fraction of this program's available CPU time used by the GC since the program started.", - nil, nil, - ), - eval: func(ms *runtime.MemStats) float64 { return ms.GCCPUFraction }, - valType: GaugeValue, - }) - return &goCollector{ - base: newBaseGoCollector(), - msLast: &runtime.MemStats{}, - msRead: runtime.ReadMemStats, - msMaxWait: time.Second, - msMaxAge: 5 * time.Minute, - msMetrics: msMetrics, - } -} - -// Describe returns all descriptions of the collector. -func (c *goCollector) Describe(ch chan<- *Desc) { - c.base.Describe(ch) - for _, i := range c.msMetrics { - ch <- i.desc - } -} - -// Collect returns the current state of all metrics of the collector. -func (c *goCollector) Collect(ch chan<- Metric) { - var ( - ms = &runtime.MemStats{} - done = make(chan struct{}) - ) - // Start reading memstats first as it might take a while. - go func() { - c.msRead(ms) - c.msMtx.Lock() - c.msLast = ms - c.msLastTimestamp = time.Now() - c.msMtx.Unlock() - close(done) - }() - - // Collect base non-memory metrics. - c.base.Collect(ch) - - timer := time.NewTimer(c.msMaxWait) - select { - case <-done: // Our own ReadMemStats succeeded in time. Use it. - timer.Stop() // Important for high collection frequencies to not pile up timers. - c.msCollect(ch, ms) - return - case <-timer.C: // Time out, use last memstats if possible. Continue below. - } - c.msMtx.Lock() - if time.Since(c.msLastTimestamp) < c.msMaxAge { - // Last memstats are recent enough. Collect from them under the lock. - c.msCollect(ch, c.msLast) - c.msMtx.Unlock() - return - } - // If we are here, the last memstats are too old or don't exist. We have - // to wait until our own ReadMemStats finally completes. For that to - // happen, we have to release the lock. - c.msMtx.Unlock() - <-done - c.msCollect(ch, ms) -} - -func (c *goCollector) msCollect(ch chan<- Metric, ms *runtime.MemStats) { - for _, i := range c.msMetrics { - ch <- MustNewConstMetric(i.desc, i.valType, i.eval(ms)) - } -} diff --git a/vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go b/vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go index 6b8684731c9..1db1c4be09a 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go @@ -98,7 +98,7 @@ type goCollector struct { // snapshot is always produced by Collect. mu sync.Mutex - // Contains all samples that has to retrieved from runtime/metrics (not all of them will be exposed). + // Contains all samples that have to be retrieved from runtime/metrics (not all of them will be exposed). sampleBuf []metrics.Sample // sampleMap allows lookup for MemStats metrics and runtime/metrics histograms for exact sums. sampleMap map[string]*metrics.Sample @@ -210,16 +210,26 @@ func NewGoCollector(opts ...func(o *internal.GoCollectorOptions)) Collector { sampleBuf = append(sampleBuf, metrics.Sample{Name: d.Name}) sampleMap[d.Name] = &sampleBuf[len(sampleBuf)-1] + // Extract unit from the runtime/metrics name (e.g., "/gc/heap/allocs:bytes" -> "bytes") + // and sanitize to match Prometheus naming conventions (e.g., "cpu-seconds" -> "cpu_seconds") + var unit string + if idx := strings.IndexRune(d.Name, ':'); idx >= 0 { + unit = d.Name[idx+1:] + unit = strings.ReplaceAll(unit, "-", "_") + unit = strings.ReplaceAll(unit, "*", "_") + unit = strings.ReplaceAll(unit, "/", "_per_") + } + var m collectorMetric if d.Kind == metrics.KindFloat64Histogram { _, hasSum := opt.RuntimeMetricSumForHist[d.Name] - unit := d.Name[strings.IndexRune(d.Name, ':')+1:] m = newBatchHistogram( - NewDesc( + V2.NewDesc( BuildFQName(namespace, subsystem, name), help, + UnconstrainedLabels(nil), nil, - nil, + WithUnit(unit), ), internal.RuntimeMetricsBucketsForUnit(bucketsMap[d.Name], unit), hasSum, @@ -230,6 +240,7 @@ func NewGoCollector(opts ...func(o *internal.GoCollectorOptions)) Collector { Subsystem: subsystem, Name: name, Help: help, + Unit: unit, }, ) } else { @@ -238,6 +249,7 @@ func NewGoCollector(opts ...func(o *internal.GoCollectorOptions)) Collector { Subsystem: subsystem, Name: name, Help: help, + Unit: unit, }) } metricSet = append(metricSet, m) diff --git a/vendor/github.com/prometheus/client_golang/prometheus/histogram.go b/vendor/github.com/prometheus/client_golang/prometheus/histogram.go index c453b754a7f..88bae3b32c2 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/histogram.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/histogram.go @@ -378,6 +378,9 @@ type HistogramOpts struct { // string. Help string + // Unit provides the unit of this Histogram. + Unit string + // ConstLabels are used to attach fixed labels to this metric. Metrics // with the same fully-qualified name must have the same label names in // their ConstLabels. @@ -522,11 +525,12 @@ type HistogramVecOpts struct { // for each bucket. func NewHistogram(opts HistogramOpts) Histogram { return newHistogram( - NewDesc( + V2.NewDesc( BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), opts.Help, - nil, + UnconstrainedLabels(nil), opts.ConstLabels, + WithUnit(opts.Unit), ), opts, ) @@ -966,7 +970,7 @@ func (h *histogram) maybeReset( // We are using the possibly mocked h.now() rather than // time.Since(h.lastResetTime) to enable testing. if h.nativeHistogramMinResetDuration == 0 || // No reset configured. - h.resetScheduled || // Do not interefere if a reset is already scheduled. + h.resetScheduled || // Do not interfere if a reset is already scheduled. h.now().Sub(h.lastResetTime) < h.nativeHistogramMinResetDuration { return false } @@ -1053,8 +1057,8 @@ func (h *histogram) maybeWidenZeroBucket(hot, cold *histogramCounts) bool { atomic.StoreUint64(&cold.nativeHistogramZeroThresholdBits, math.Float64bits(newZeroThreshold)) // ...and then merge the newly deleted buckets into the wider zero // bucket. - mergeAndDeleteOrAddAndReset := func(hotBuckets, coldBuckets *sync.Map) func(k, v interface{}) bool { - return func(k, v interface{}) bool { + mergeAndDeleteOrAddAndReset := func(hotBuckets, coldBuckets *sync.Map) func(k, v any) bool { + return func(k, v any) bool { key := k.(int) bucket := v.(*int64) if key == smallestKey { @@ -1107,8 +1111,8 @@ func (h *histogram) doubleBucketWidth(hot, cold *histogramCounts) { // ...adjust the schema in the cold counts, too... atomic.StoreInt32(&cold.nativeHistogramSchema, coldSchema) // ...and then merge the cold buckets into the wider hot buckets. - merge := func(hotBuckets *sync.Map) func(k, v interface{}) bool { - return func(k, v interface{}) bool { + merge := func(hotBuckets *sync.Map) func(k, v any) bool { + return func(k, v any) bool { key := k.(int) bucket := v.(*int64) // Adjust key to match the bucket to merge into. @@ -1190,6 +1194,7 @@ func (v2) NewHistogramVec(opts HistogramVecOpts) *HistogramVec { opts.Help, opts.VariableLabels, opts.ConstLabels, + WithUnit(opts.Unit), ) return &HistogramVec{ MetricVec: NewMetricVec(desc, func(lvs ...string) Metric { @@ -1476,7 +1481,7 @@ func pickSchema(bucketFactor float64) int32 { func makeBuckets(buckets *sync.Map) ([]*dto.BucketSpan, []int64) { var ii []int - buckets.Range(func(k, v interface{}) bool { + buckets.Range(func(k, v any) bool { ii = append(ii, k.(int)) return true }) @@ -1553,8 +1558,8 @@ func addToBucket(buckets *sync.Map, key int, increment int64) bool { // according to the buckets ranged through. It then resets all buckets ranged // through to 0 (but leaves them in place so that they don't need to get // recreated on the next scrape). -func addAndReset(hotBuckets *sync.Map, bucketNumber *uint32) func(k, v interface{}) bool { - return func(k, v interface{}) bool { +func addAndReset(hotBuckets *sync.Map, bucketNumber *uint32) func(k, v any) bool { + return func(k, v any) bool { bucket := v.(*int64) if addToBucket(hotBuckets, k.(int), atomic.LoadInt64(bucket)) { atomic.AddUint32(bucketNumber, 1) @@ -1565,7 +1570,7 @@ func addAndReset(hotBuckets *sync.Map, bucketNumber *uint32) func(k, v interface } func deleteSyncMap(m *sync.Map) { - m.Range(func(k, v interface{}) bool { + m.Range(func(k, v any) bool { m.Delete(k) return true }) @@ -1573,7 +1578,7 @@ func deleteSyncMap(m *sync.Map) { func findSmallestKey(m *sync.Map) int { result := math.MaxInt32 - m.Range(func(k, v interface{}) bool { + m.Range(func(k, v any) bool { key := k.(int) if key < result { result = key diff --git a/vendor/github.com/prometheus/client_golang/prometheus/internal/difflib.go b/vendor/github.com/prometheus/client_golang/prometheus/internal/difflib.go index 7bac0da33df..2db270f2166 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/internal/difflib.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/internal/difflib.go @@ -78,7 +78,7 @@ type OpCode struct { // notion, pairing up elements that appear uniquely in each sequence. // That, and the method here, appear to yield more intuitive difference // reports than does diff. This method appears to be the least vulnerable -// to synching up on blocks of "junk lines", though (like blank lines in +// to syncing up on blocks of "junk lines", though (like blank lines in // ordinary text files, or maybe "

" lines in HTML files). That may be // because this is the only method of the 3 that has a *concept* of // "junk" . @@ -567,7 +567,7 @@ type UnifiedDiff struct { func WriteUnifiedDiff(writer io.Writer, diff UnifiedDiff) error { buf := bufio.NewWriter(writer) defer buf.Flush() - wf := func(format string, args ...interface{}) error { + wf := func(format string, args ...any) error { _, err := fmt.Fprintf(buf, format, args...) return err } diff --git a/vendor/github.com/prometheus/client_golang/prometheus/labels.go b/vendor/github.com/prometheus/client_golang/prometheus/labels.go index 5fe8d3b4d29..a0285489a08 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/labels.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/labels.go @@ -184,6 +184,5 @@ func validateLabelValues(vals []string, expectedNumberOfValues int) error { } func checkLabelName(l string) bool { - //nolint:staticcheck // TODO: Don't use deprecated model.NameValidationScheme. - return model.NameValidationScheme.IsValidLabelName(l) && !strings.HasPrefix(l, reservedLabelPrefix) + return model.UTF8Validation.IsValidLabelName(l) && !strings.HasPrefix(l, reservedLabelPrefix) } diff --git a/vendor/github.com/prometheus/client_golang/prometheus/metric.go b/vendor/github.com/prometheus/client_golang/prometheus/metric.go index 76e59f12880..c5cb90adf8f 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/metric.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/metric.go @@ -81,6 +81,9 @@ type Opts struct { // string. Help string + // Unit provides the unit of this metric as per https://prometheus.io/docs/specs/om + Unit string + // ConstLabels are used to attach fixed labels to this metric. Metrics // with the same fully-qualified name must have the same label names in // their ConstLabels. diff --git a/vendor/github.com/prometheus/client_golang/prometheus/process_collector_darwin.go b/vendor/github.com/prometheus/client_golang/prometheus/process_collector_darwin.go index b32c95fa3fa..2b16298f406 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/process_collector_darwin.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/process_collector_darwin.go @@ -72,7 +72,13 @@ func getOpenFileCount() (float64, error) { } func (c *processCollector) processCollect(ch chan<- Metric) { - if procs, err := unix.SysctlKinfoProcSlice("kern.proc.pid", os.Getpid()); err == nil { + pid, err := c.pidFn() + if err != nil { + c.reportError(ch, nil, err) + return + } + + if procs, err := unix.SysctlKinfoProcSlice("kern.proc.pid", pid); err == nil { if len(procs) == 1 { startTime := float64(procs[0].Proc.P_starttime.Nano() / 1e9) ch <- MustNewConstMetric(c.startTime, GaugeValue, startTime) @@ -84,6 +90,11 @@ func (c *processCollector) processCollect(ch chan<- Metric) { c.reportError(ch, c.startTime, err) } + if pid != os.Getpid() { + c.reportError(ch, nil, fmt.Errorf("collecting metrics for pid %d is not supported on darwin: process metrics collection is limited to the current process (pid %d)", pid, os.Getpid())) + return + } + // The proc structure returned by kern.proc.pid above has an Rusage member, // but it is not filled in, so it needs to be fetched by getrusage(2). For // that call, the UTime, STime, and Maxrss members are filled out, but not diff --git a/vendor/github.com/prometheus/client_golang/prometheus/process_collector_windows.go b/vendor/github.com/prometheus/client_golang/prometheus/process_collector_windows.go index fa474289ef8..c08dd05f031 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/process_collector_windows.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/process_collector_windows.go @@ -30,6 +30,10 @@ var ( procGetProcessMemoryInfo = modpsapi.NewProc("GetProcessMemoryInfo") procGetProcessHandleCount = modkernel32.NewProc("GetProcessHandleCount") + + openProcess = windows.OpenProcess + closeHandle = windows.CloseHandle + getProcessTimes = windows.GetProcessTimes ) type processMemoryCounters struct { @@ -79,10 +83,21 @@ func getProcessHandleCount(handle windows.Handle) (uint32, error) { } func (c *processCollector) processCollect(ch chan<- Metric) { - h := windows.CurrentProcess() + pid, err := c.pidFn() + if err != nil { + c.reportError(ch, nil, err) + return + } + + h, err := openProcess(windows.PROCESS_QUERY_INFORMATION|windows.PROCESS_VM_READ, false, uint32(pid)) + if err != nil { + c.reportError(ch, nil, err) + return + } + defer closeHandle(h) var startTime, exitTime, kernelTime, userTime windows.Filetime - err := windows.GetProcessTimes(h, &startTime, &exitTime, &kernelTime, &userTime) + err = getProcessTimes(h, &startTime, &exitTime, &kernelTime, &userTime) if err != nil { c.reportError(ch, nil, err) return diff --git a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go index 763d99e3623..c28af5ce2ba 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go @@ -37,10 +37,12 @@ import ( "fmt" "io" "net/http" + "slices" "strconv" "sync" "time" + dto "github.com/prometheus/client_model/go" "github.com/prometheus/common/expfmt" "github.com/prometheus/client_golang/internal/github.com/golang/gddo/httputil" @@ -74,11 +76,118 @@ func defaultCompressionFormats() []Compression { } var gzipPool = sync.Pool{ - New: func() interface{} { + New: func() any { return gzip.NewWriter(nil) }, } +// coalescingGatherer wraps a TransactionalGatherer to deduplicate concurrent +// Gather calls. When a Gather is already in flight, new callers join the +// existing cycle and receive the same result once it completes. The underlying +// done function is called exactly once, when the last joined caller releases. +// +// This prevents goroutine pile-up when the scrape rate is faster than the +// time collectors need to produce metrics. +type coalescingGatherer struct { + g prometheus.TransactionalGatherer + mu sync.Mutex + cycle *gatherCycle +} + +// gatherCycle tracks a single in-flight Gather and all HTTP handlers sharing it. +type gatherCycle struct { + ready chan struct{} // closed when Gather completes; happens-before reads of mfs/err/done + mfs []*dto.MetricFamily // canonical result, set before ready is closed; callers get a slices.Clone, the element values stay shared and must not be mutated + err error // set before ready is closed + done func() // underlying done callback; set before ready is closed + refs int // number of handlers using this cycle; protected by coalescingGatherer.mu +} + +var _ prometheus.TransactionalGatherer = (*coalescingGatherer)(nil) // compile-time interface check + +// errGatherPanicked is returned to callers that joined an in-flight coalesced +// Gather whose underlying gatherer panicked. See the panic guard in Gather for +// why joiners receive this error instead of the panic itself. +var errGatherPanicked = errors.New("coalesced gather panicked") + +func (c *coalescingGatherer) Gather() ([]*dto.MetricFamily, func(), error) { + c.mu.Lock() + if cy := c.cycle; cy != nil { + // c.cycle is non-nil while Gather runs or handlers are still consuming its results. + cy.refs++ + c.mu.Unlock() + <-cy.ready + // Each caller gets its own slice header so it can filter or reorder + // without racing other callers sharing this cycle. The *dto.MetricFamily + // values remain shared and must not be mutated in place. + return slices.Clone(cy.mfs), c.releaseFunc(cy), cy.err + } + cy := &gatherCycle{ + ready: make(chan struct{}), + done: func() {}, + refs: 1, + } + c.cycle = cy + c.mu.Unlock() + + // Guard against a panic in c.g.Gather. The common case, a panicking + // Collector, never reaches here: Registry.Gather recovers Collector panics + // and returns them as an error. This guard only covers the rare case where + // the wrapped gatherer itself panics. + // + // We deliberately do not recover: the leader's panic propagates and is + // handled by net/http exactly as it would be without coalescing. We only + // set cy.err before closing cy.ready so joiners waiting on <-cy.ready fail + // with that error instead of silently returning an empty, successful + // response, and we clear c.cycle so the next Gather starts a fresh cycle. + // + // The leader never runs its own releaseFunc on this path, so its ref is + // not decremented; that is harmless because the cycle is detached (c.cycle + // = nil) and cy.done is still the no-op set at construction (c.g.Gather + // panicked before assigning a real done). If cy.done is ever made non-nil + // before c.g.Gather runs, this path would need to release it. + panicked := true + defer func() { + if panicked { + c.mu.Lock() + if c.cycle == cy { + c.cycle = nil + } + c.mu.Unlock() + cy.err = errGatherPanicked // set before close: happens-before joiners' reads + close(cy.ready) + } + }() + cy.mfs, cy.done, cy.err = c.g.Gather() + panicked = false + close(cy.ready) // happens-before joiners' reads of cy.mfs/err/done + + // Clone here too so cy.mfs stays the write-once canonical slice: joiners + // read it concurrently via slices.Clone, so the leader must not hand out + // (and potentially reorder) the same backing array. + return slices.Clone(cy.mfs), c.releaseFunc(cy), cy.err +} + +// releaseFunc returns the done callback for one caller sharing cy. +// When the last caller releases, the underlying done is invoked and the +// cycle is cleared so the next Gather starts fresh. +func (c *coalescingGatherer) releaseFunc(cy *gatherCycle) func() { + return func() { + c.mu.Lock() + cy.refs-- + if cy.refs > 0 { + c.mu.Unlock() + return + } + // Last caller. + if c.cycle == cy { + c.cycle = nil + } + c.mu.Unlock() + cy.done() // called outside the lock to avoid holding it during done + } +} + // Handler returns an http.Handler for the prometheus.DefaultGatherer, using // default HandlerOpts, i.e. it reports the first error as an HTTP error, it has // no error logging, and it applies compression if requested by the client. @@ -89,6 +198,10 @@ var gzipPool = sync.Pool{ // metrics used for instrumentation will be shared between them, providing // global scrape counts. // +// The handler supports filtering metrics by name using the `name[]` query parameter. +// Multiple metric names can be specified by providing the parameter multiple times. +// When no name[] parameters are provided, all metrics are returned. +// // This function is meant to cover the bulk of basic use cases. If you are doing // anything that requires more customization (including using a non-default // Gatherer, different instrumentation, and non-default HandlerOpts), use the @@ -105,6 +218,10 @@ func Handler() http.Handler { // Gatherers, with non-default HandlerOpts, and/or with custom (or no) // instrumentation. Use the InstrumentMetricHandler function to apply the same // kind of instrumentation as it is used by the Handler function. +// +// The handler supports filtering metrics by name using the `name[]` query parameter. +// Multiple metric names can be specified by providing the parameter multiple times. +// When no name[] parameters are provided, all metrics are returned. func HandlerFor(reg prometheus.Gatherer, opts HandlerOpts) http.Handler { return HandlerForTransactional(prometheus.ToTransactionalGatherer(reg), opts) } @@ -112,7 +229,15 @@ func HandlerFor(reg prometheus.Gatherer, opts HandlerOpts) http.Handler { // HandlerForTransactional is like HandlerFor, but it uses transactional gather, which // can safely change in-place returned *dto.MetricFamily before call to `Gather` and after // call to `done` of that `Gather`. +// +// The handler supports filtering metrics by name using the `name[]` query parameter. +// Multiple metric names can be specified by providing the parameter multiple times. +// When no name[] parameters are provided, all metrics are returned. func HandlerForTransactional(reg prometheus.TransactionalGatherer, opts HandlerOpts) http.Handler { + if opts.CoalesceGather { + reg = &coalescingGatherer{g: reg} + } + var ( inFlightSem chan struct{} errCnt = prometheus.NewCounterVec( @@ -214,12 +339,14 @@ func HandlerForTransactional(reg prometheus.TransactionalGatherer, opts HandlerO rsp.Header().Set(contentEncodingHeader, encodingHeader) } - var enc expfmt.Encoder + var ( + enc expfmt.Encoder + encOpts []expfmt.EncoderOption + ) if opts.EnableOpenMetricsTextCreatedSamples { - enc = expfmt.NewEncoder(w, contentType, expfmt.WithCreatedLines()) - } else { - enc = expfmt.NewEncoder(w, contentType) + encOpts = append(encOpts, expfmt.WithCreatedLines()) } + enc = expfmt.NewEncoder(w, contentType, encOpts...) // handleError handles the error according to opts.ErrorHandling // and returns true if we have to abort after the handling. @@ -245,7 +372,24 @@ func HandlerForTransactional(reg prometheus.TransactionalGatherer, opts HandlerO return false } + // Build metric name filter set from query params (if any). The URL + // can be nil on hand-constructed requests. + var metricFilter map[string]struct{} + if req.URL != nil { + if metricNames := req.URL.Query()["name[]"]; len(metricNames) > 0 { + metricFilter = make(map[string]struct{}, len(metricNames)) + for _, name := range metricNames { + metricFilter[name] = struct{}{} + } + } + } + for _, mf := range mfs { + if metricFilter != nil { + if _, ok := metricFilter[mf.GetName()]; !ok { + continue + } + } if handleError(enc.Encode(mf)) { return } @@ -353,7 +497,7 @@ const ( // log.Logger from the standard library implements this interface, and it is // easy to implement by custom loggers, if they don't do so already anyway. type Logger interface { - Println(v ...interface{}) + Println(v ...any) } // HandlerOpts specifies options how to serve metrics via an http.Handler. The @@ -400,6 +544,40 @@ type HandlerOpts struct { // Service Unavailable and a suitable message in the body. If // MaxRequestsInFlight is 0 or negative, no limit is applied. MaxRequestsInFlight int + // CoalesceGather, if true, deduplicates concurrent Gather calls so that + // only one collection runs at a time. Additional requests that arrive + // while a Gather is in flight will receive the same result once it + // completes. This prevents goroutine pile-up when the scrape rate is + // faster than the time collectors need to produce metrics. + // + // When enabled, concurrent scrapers share a single metric snapshot per + // collection cycle. Each request receives its own copy of the returned + // slice, so filtering or reordering it (for example via name[] query + // parameters) is safe. The pointed-to MetricFamily values are still + // shared: the built-in handler only reads them, so this is safe in + // practice, but a custom TransactionalGatherer that mutates the returned + // families in place after Gather returns must not use this option. + // + // Because the snapshot is shared, a request that arrives while a cycle is + // in flight receives that cycle's result even though collection began + // before the request; two scrapers joined to one cycle observe the same + // timestamps rather than independently gathered data. + // + // Consider using CoalesceGather together with Timeout. Timeout bounds the + // client-facing response time and keeps at most one collection running at + // a time, but it does not cancel the underlying Gather: a joined request + // that times out still holds a MaxRequestsInFlight slot until the shared + // collection completes. + // + // Panic handling: a panicking Collector is already turned into an error by + // the registry, so joiners receive that error like any other. In the rare + // case where the wrapped gatherer itself panics, the panicking request's + // panic propagates as usual (handled by net/http), while requests that + // joined the same cycle receive an error rather than an empty response. + // + // NOTE: This option is experimental and may change or be removed in a + // future release. + CoalesceGather bool // If handling a request takes longer than Timeout, it is responded to // with 503 ServiceUnavailable and a suitable Message. No timeout is // applied if Timeout is 0 or negative. Note that with the current @@ -407,8 +585,9 @@ type HandlerOpts struct { // described above (and even that only if sending of the body hasn't // started yet), while the bulk work of gathering all the metrics keeps // running in the background (with the eventual result to be thrown - // away). Until the implementation is improved, it is recommended to - // implement a separate timeout in potentially slow Collectors. + // away). When CoalesceGather is enabled, only one such background Gather + // can be in flight at a time. It is also recommended to implement a + // separate timeout in potentially slow Collectors. Timeout time.Duration // If true, the experimental OpenMetrics encoding is added to the // possible options during content negotiation. Note that Prometheus @@ -460,7 +639,7 @@ func httpError(rsp http.ResponseWriter, err error) { // negotiateEncodingWriter reads the Accept-Encoding header from a request and // selects the right compression based on an allow-list of supported -// compressions. It returns a writer implementing the compression and an the +// compressions. It returns a writer implementing the compression and the // correct value that the caller can set in the response header. func negotiateEncodingWriter(r *http.Request, rw io.Writer, compressions []string) (_ io.Writer, encodingHeaderValue string, closeWriter func(), _ error) { if len(compressions) == 0 { diff --git a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client.go b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client.go index d3482c40ca7..0248579742a 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client.go @@ -75,10 +75,10 @@ func InstrumentRoundTripperCounter(counter *prometheus.CounterVec, next http.Rou resp, err := next.RoundTrip(r) if err == nil { l := labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...) - for label, resolve := range rtOpts.extraLabelsFromCtx { - l[label] = resolve(resp.Request.Context()) + for label, resolve := range rtOpts.extraLabelsFromRequest { + l[label] = resolve(resp.Request) } - addWithExemplar(counter.With(l), 1, rtOpts.getExemplarFn(r.Context())) + addWithExemplar(counter.With(l), 1, rtOpts.getExemplarFn(r)) } return resp, err } @@ -119,10 +119,10 @@ func InstrumentRoundTripperDuration(obs prometheus.ObserverVec, next http.RoundT resp, err := next.RoundTrip(r) if err == nil { l := labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...) - for label, resolve := range rtOpts.extraLabelsFromCtx { - l[label] = resolve(resp.Request.Context()) + for label, resolve := range rtOpts.extraLabelsFromRequest { + l[label] = resolve(resp.Request) } - observeWithExemplar(obs.With(l), time.Since(start).Seconds(), rtOpts.getExemplarFn(r.Context())) + observeWithExemplar(obs.With(l), time.Since(start).Seconds(), rtOpts.getExemplarFn(r)) } return resp, err } diff --git a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go index 9332b0249a9..9dec091ac71 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go @@ -28,24 +28,36 @@ import ( // magicString is used for the hacky label test in checkLabels. Remove once fixed. const magicString = "zZgWfBxLqvG8kc8IMv3POi2Bb0tZI3vAnBx+gBaFi9FyPzB/CzKUer1yufDa" -// observeWithExemplar is a wrapper for [prometheus.ExemplarAdder.ExemplarObserver], -// which falls back to [prometheus.Observer.Observe] if no labels are provided. +// observeWithExemplar records val on obs. If labels is non-nil and obs +// implements [prometheus.ExemplarObserver], the exemplar is attached via +// ObserveWithExemplar; otherwise the exemplar is dropped and the value is +// recorded with a plain [prometheus.Observer.Observe]. This mirrors the +// safe-cast pattern in [prometheus.Timer.ObserveDurationWithExemplar] and +// ensures we never panic when callers pass an ObserverVec backed by a +// summary, which cannot carry exemplars in the Prometheus exposition format. func observeWithExemplar(obs prometheus.Observer, val float64, labels map[string]string) { - if labels == nil { - obs.Observe(val) - return + if labels != nil { + if eo, ok := obs.(prometheus.ExemplarObserver); ok { + eo.ObserveWithExemplar(val, labels) + return + } } - obs.(prometheus.ExemplarObserver).ObserveWithExemplar(val, labels) + obs.Observe(val) } -// addWithExemplar is a wrapper for [prometheus.ExemplarAdder.AddWithExemplar], -// which falls back to [prometheus.Counter.Add] if no labels are provided. -func addWithExemplar(obs prometheus.Counter, val float64, labels map[string]string) { - if labels == nil { - obs.Add(val) - return +// addWithExemplar records val on c. If labels is non-nil and c implements +// [prometheus.ExemplarAdder], the exemplar is attached via AddWithExemplar; +// otherwise the exemplar is dropped and the value is recorded with a plain +// [prometheus.Counter.Add]. The safe-cast keeps the helper robust against +// custom Counter implementations that do not advertise exemplar support. +func addWithExemplar(c prometheus.Counter, val float64, labels map[string]string) { + if labels != nil { + if ea, ok := c.(prometheus.ExemplarAdder); ok { + ea.AddWithExemplar(val, labels) + return + } } - obs.(prometheus.ExemplarAdder).AddWithExemplar(val, labels) + c.Add(val) } // InstrumentHandlerInFlight is a middleware that wraps the provided @@ -97,10 +109,10 @@ func InstrumentHandlerDuration(obs prometheus.ObserverVec, next http.Handler, op next.ServeHTTP(d, r) l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...) - for label, resolve := range hOpts.extraLabelsFromCtx { - l[label] = resolve(r.Context()) + for label, resolve := range hOpts.extraLabelsFromRequest { + l[label] = resolve(r) } - observeWithExemplar(obs.With(l), time.Since(now).Seconds(), hOpts.getExemplarFn(r.Context())) + observeWithExemplar(obs.With(l), time.Since(now).Seconds(), hOpts.getExemplarFn(r)) } } @@ -108,10 +120,10 @@ func InstrumentHandlerDuration(obs prometheus.ObserverVec, next http.Handler, op now := time.Now() next.ServeHTTP(w, r) l := labels(code, method, r.Method, 0, hOpts.extraMethods...) - for label, resolve := range hOpts.extraLabelsFromCtx { - l[label] = resolve(r.Context()) + for label, resolve := range hOpts.extraLabelsFromRequest { + l[label] = resolve(r) } - observeWithExemplar(obs.With(l), time.Since(now).Seconds(), hOpts.getExemplarFn(r.Context())) + observeWithExemplar(obs.With(l), time.Since(now).Seconds(), hOpts.getExemplarFn(r)) } } @@ -147,10 +159,10 @@ func InstrumentHandlerCounter(counter *prometheus.CounterVec, next http.Handler, next.ServeHTTP(d, r) l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...) - for label, resolve := range hOpts.extraLabelsFromCtx { - l[label] = resolve(r.Context()) + for label, resolve := range hOpts.extraLabelsFromRequest { + l[label] = resolve(r) } - addWithExemplar(counter.With(l), 1, hOpts.getExemplarFn(r.Context())) + addWithExemplar(counter.With(l), 1, hOpts.getExemplarFn(r)) } } @@ -158,10 +170,10 @@ func InstrumentHandlerCounter(counter *prometheus.CounterVec, next http.Handler, next.ServeHTTP(w, r) l := labels(code, method, r.Method, 0, hOpts.extraMethods...) - for label, resolve := range hOpts.extraLabelsFromCtx { - l[label] = resolve(r.Context()) + for label, resolve := range hOpts.extraLabelsFromRequest { + l[label] = resolve(r) } - addWithExemplar(counter.With(l), 1, hOpts.getExemplarFn(r.Context())) + addWithExemplar(counter.With(l), 1, hOpts.getExemplarFn(r)) } } @@ -200,10 +212,10 @@ func InstrumentHandlerTimeToWriteHeader(obs prometheus.ObserverVec, next http.Ha now := time.Now() d := newDelegator(w, func(status int) { l := labels(code, method, r.Method, status, hOpts.extraMethods...) - for label, resolve := range hOpts.extraLabelsFromCtx { - l[label] = resolve(r.Context()) + for label, resolve := range hOpts.extraLabelsFromRequest { + l[label] = resolve(r) } - observeWithExemplar(obs.With(l), time.Since(now).Seconds(), hOpts.getExemplarFn(r.Context())) + observeWithExemplar(obs.With(l), time.Since(now).Seconds(), hOpts.getExemplarFn(r)) }) next.ServeHTTP(d, r) } @@ -244,10 +256,10 @@ func InstrumentHandlerRequestSize(obs prometheus.ObserverVec, next http.Handler, size := computeApproximateRequestSize(r) l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...) - for label, resolve := range hOpts.extraLabelsFromCtx { - l[label] = resolve(r.Context()) + for label, resolve := range hOpts.extraLabelsFromRequest { + l[label] = resolve(r) } - observeWithExemplar(obs.With(l), float64(size), hOpts.getExemplarFn(r.Context())) + observeWithExemplar(obs.With(l), float64(size), hOpts.getExemplarFn(r)) } } @@ -256,10 +268,10 @@ func InstrumentHandlerRequestSize(obs prometheus.ObserverVec, next http.Handler, size := computeApproximateRequestSize(r) l := labels(code, method, r.Method, 0, hOpts.extraMethods...) - for label, resolve := range hOpts.extraLabelsFromCtx { - l[label] = resolve(r.Context()) + for label, resolve := range hOpts.extraLabelsFromRequest { + l[label] = resolve(r) } - observeWithExemplar(obs.With(l), float64(size), hOpts.getExemplarFn(r.Context())) + observeWithExemplar(obs.With(l), float64(size), hOpts.getExemplarFn(r)) } } @@ -296,10 +308,10 @@ func InstrumentHandlerResponseSize(obs prometheus.ObserverVec, next http.Handler next.ServeHTTP(d, r) l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...) - for label, resolve := range hOpts.extraLabelsFromCtx { - l[label] = resolve(r.Context()) + for label, resolve := range hOpts.extraLabelsFromRequest { + l[label] = resolve(r) } - observeWithExemplar(obs.With(l), float64(d.Written()), hOpts.getExemplarFn(r.Context())) + observeWithExemplar(obs.With(l), float64(d.Written()), hOpts.getExemplarFn(r)) }) } @@ -366,7 +378,7 @@ func checkLabels(c prometheus.Collector) (code, method bool) { panic("metric partitioned with non-supported labels") } } - return + return code, method } func isLabelCurried(c prometheus.Collector, label string) bool { diff --git a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/option.go b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/option.go index 5d4383aa14a..d4c0954f366 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/option.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/option.go @@ -15,6 +15,7 @@ package promhttp import ( "context" + "net/http" "github.com/prometheus/client_golang/prometheus" ) @@ -24,28 +25,31 @@ type Option interface { apply(*options) } +// LabelValueFromRequest is used to compute the label value from request. +type LabelValueFromRequest func(request *http.Request) string + // LabelValueFromCtx are used to compute the label value from request context. // Context can be filled with values from request through middleware. type LabelValueFromCtx func(ctx context.Context) string // options store options for both a handler or round tripper. type options struct { - extraMethods []string - getExemplarFn func(requestCtx context.Context) prometheus.Labels - extraLabelsFromCtx map[string]LabelValueFromCtx + extraMethods []string + getExemplarFn func(req *http.Request) prometheus.Labels + extraLabelsFromRequest map[string]LabelValueFromRequest } func defaultOptions() *options { return &options{ - getExemplarFn: func(ctx context.Context) prometheus.Labels { return nil }, - extraLabelsFromCtx: map[string]LabelValueFromCtx{}, + getExemplarFn: func(req *http.Request) prometheus.Labels { return nil }, + extraLabelsFromRequest: map[string]LabelValueFromRequest{}, } } func (o *options) emptyDynamicLabels() prometheus.Labels { labels := prometheus.Labels{} - for label := range o.extraLabelsFromCtx { + for label := range o.extraLabelsFromRequest { labels[label] = "" } @@ -66,19 +70,39 @@ func WithExtraMethods(methods ...string) Option { }) } -// WithExemplarFromContext allows to inject function that will get exemplar from context that will be put to counter and histogram metrics. +// WithExemplarFromRequest allows you to inject a function that will get exemplar from request that will be put to counter and histogram metrics. // If the function returns nil labels or the metric does not support exemplars, no exemplar will be added (noop), but // metric will continue to observe/increment. -func WithExemplarFromContext(getExemplarFn func(requestCtx context.Context) prometheus.Labels) Option { +func WithExemplarFromRequest(getExemplarFn func(req *http.Request) prometheus.Labels) Option { return optionApplyFunc(func(o *options) { o.getExemplarFn = getExemplarFn }) } +// WithExemplarFromContext allows you to inject a function that will get exemplar from context that will be put to counter and histogram metrics. +// If the function returns nil labels or the metric does not support exemplars, no exemplar will be added (noop), but +// metric will continue to observe/increment. +func WithExemplarFromContext(getExemplarFn func(requestCtx context.Context) prometheus.Labels) Option { + return optionApplyFunc(func(o *options) { + o.getExemplarFn = func(req *http.Request) prometheus.Labels { + return getExemplarFn(req.Context()) + } + }) +} + +// WithLabelFromRequest registers a label for dynamic resolution with access to the request. +func WithLabelFromRequest(name string, valueFn LabelValueFromRequest) Option { + return optionApplyFunc(func(o *options) { + o.extraLabelsFromRequest[name] = valueFn + }) +} + // WithLabelFromCtx registers a label for dynamic resolution with access to context. // See the example for ExampleInstrumentHandlerWithLabelResolver for example usage func WithLabelFromCtx(name string, valueFn LabelValueFromCtx) Option { return optionApplyFunc(func(o *options) { - o.extraLabelsFromCtx[name] = valueFn + o.extraLabelsFromRequest[name] = func(req *http.Request) string { + return valueFn(req.Context()) + } }) } diff --git a/vendor/github.com/prometheus/client_golang/prometheus/push/push.go b/vendor/github.com/prometheus/client_golang/prometheus/push/push.go index 1eb35ac9afa..c65b6a665ac 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/push/push.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/push/push.go @@ -182,8 +182,7 @@ func (p *Pusher) Error() error { // For convenience, this method returns a pointer to the Pusher itself. func (p *Pusher) Grouping(name, value string) *Pusher { if p.error == nil { - //nolint:staticcheck // TODO: Don't use deprecated model.NameValidationScheme. - if !model.NameValidationScheme.IsValidLabelName(name) { + if !model.UTF8Validation.IsValidLabelName(name) { p.error = fmt.Errorf("grouping label has invalid name: %s", name) return p } diff --git a/vendor/github.com/prometheus/client_golang/prometheus/registry.go b/vendor/github.com/prometheus/client_golang/prometheus/registry.go index c6fd2f58b74..ed0681c8b4e 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/registry.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/registry.go @@ -214,6 +214,19 @@ func (err AlreadyRegisteredError) Error() string { // by a Gatherer to report multiple errors during MetricFamily gathering. type MultiError []error +// SafeMultiError is a thread-safe wrapper around MultiError using a mutex. +type SafeMultiError struct { + mu sync.Mutex + errs MultiError +} + +// Appends the provided error to the contained MultiError in a thread-safe way. +func (s *SafeMultiError) Append(err error) { + s.mu.Lock() + s.errs.Append(err) + s.mu.Unlock() +} + // Error formats the contained errors as a bullet point list, preceded by the // total number of errors. Note that this results in a multi-line string. func (errs MultiError) Error() string { @@ -408,6 +421,16 @@ func (r *Registry) MustRegister(cs ...Collector) { } } +// MustGather implements Gatherer. +// Wraps around Gather and panics if Gather fails for any reason. +func (r *Registry) MustGather() []*dto.MetricFamily { + mfs, err := r.Gather() + if err != nil { + panic(err) + } + return mfs +} + // Gather implements Gatherer. func (r *Registry) Gather() ([]*dto.MetricFamily, error) { r.mtx.RLock() @@ -423,7 +446,7 @@ func (r *Registry) Gather() ([]*dto.MetricFamily, error) { uncheckedMetricChan = make(chan Metric, capMetricChan) metricHashes = map[uint64]struct{}{} wg sync.WaitGroup - errs MultiError // The collected errors to return in the end. + safeErrs = &SafeMultiError{} // To collect errors in a threadsafe way registeredDescIDs map[uint64]struct{} // Only used for pedantic checks ) @@ -453,9 +476,9 @@ func (r *Registry) Gather() ([]*dto.MetricFamily, error) { for { select { case collector := <-checkedCollectors: - collector.Collect(checkedMetricChan) + safeErrs.Append((safeCollect(collector, checkedMetricChan))) case collector := <-uncheckedCollectors: - collector.Collect(uncheckedMetricChan) + safeErrs.Append(safeCollect(collector, uncheckedMetricChan)) default: return } @@ -499,7 +522,7 @@ func (r *Registry) Gather() ([]*dto.MetricFamily, error) { cmc = nil break } - errs.Append(processMetric( + safeErrs.Append(processMetric( metric, metricFamiliesByName, metricHashes, registeredDescIDs, @@ -509,7 +532,7 @@ func (r *Registry) Gather() ([]*dto.MetricFamily, error) { umc = nil break } - errs.Append(processMetric( + safeErrs.Append(processMetric( metric, metricFamiliesByName, metricHashes, nil, @@ -526,7 +549,7 @@ func (r *Registry) Gather() ([]*dto.MetricFamily, error) { cmc = nil break } - errs.Append(processMetric( + safeErrs.Append(processMetric( metric, metricFamiliesByName, metricHashes, registeredDescIDs, @@ -536,7 +559,7 @@ func (r *Registry) Gather() ([]*dto.MetricFamily, error) { umc = nil break } - errs.Append(processMetric( + safeErrs.Append(processMetric( metric, metricFamiliesByName, metricHashes, nil, @@ -556,7 +579,8 @@ func (r *Registry) Gather() ([]*dto.MetricFamily, error) { break } } - return internal.NormalizeMetricFamilies(metricFamiliesByName), errs.MaybeUnwrap() + + return internal.NormalizeMetricFamilies(metricFamiliesByName), safeErrs.errs.MaybeUnwrap() } // Describe implements Collector. @@ -571,6 +595,24 @@ func (r *Registry) Describe(ch chan<- *Desc) { } } +// Helper wrapper around Collector.Collect. +// It tries to collect from the channel, recovers on panic and +// if it has recovered from a panic, then it sends an InvalidMetric into +// the channel with an InvalidDesc, and an error that includes a stack trace. +func safeCollect(c Collector, ch chan<- Metric) (err error) { + defer func() { + if r := recover(); r != nil { + buf := make([]byte, 64<<10) // 64 KB + n := runtime.Stack(buf, false) + err = fmt.Errorf("prometheus collector panic recovered: type=%T: error=%v\nstack trace=%s", c, r, buf[:n]) + ch <- NewInvalidMetric(NewInvalidDesc(err), err) + } + }() + c.Collect(ch) + + return err +} + // Collect implements Collector. func (r *Registry) Collect(ch chan<- Metric) { r.mtx.RLock() @@ -599,10 +641,12 @@ func WriteToTextfile(filename string, g Gatherer) error { mfs, err := g.Gather() if err != nil { + tmp.Close() return err } for _, mf := range mfs { if _, err := expfmt.MetricFamilyToText(tmp, mf); err != nil { + tmp.Close() return err } } @@ -685,6 +729,9 @@ func processMetric( metricFamily = &dto.MetricFamily{} metricFamily.Name = proto.String(desc.fqName) metricFamily.Help = proto.String(desc.help) + if desc.unit != "" { + metricFamily.Unit = proto.String(desc.unit) + } // TODO(beorn7): Simplify switch once Desc has type. switch { case dtoMetric.Gauge != nil: diff --git a/vendor/github.com/prometheus/client_golang/prometheus/summary.go b/vendor/github.com/prometheus/client_golang/prometheus/summary.go index ac5203c6faa..c12b8d13d4b 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/summary.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/summary.go @@ -101,6 +101,9 @@ type SummaryOpts struct { // string. Help string + // Unit provides the unit of this Summary. + Unit string + // ConstLabels are used to attach fixed labels to this metric. Metrics // with the same fully-qualified name must have the same label names in // their ConstLabels. @@ -181,11 +184,12 @@ type SummaryVecOpts struct { // NewSummary creates a new Summary based on the provided SummaryOpts. func NewSummary(opts SummaryOpts) Summary { return newSummary( - NewDesc( + V2.NewDesc( BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), opts.Help, - nil, + UnconstrainedLabels(nil), opts.ConstLabels, + WithUnit(opts.Unit), ), opts, ) @@ -578,6 +582,7 @@ func (v2) NewSummaryVec(opts SummaryVecOpts) *SummaryVec { opts.Help, opts.VariableLabels, opts.ConstLabels, + WithUnit(opts.Unit), ) return &SummaryVec{ MetricVec: NewMetricVec(desc, func(lvs ...string) Metric { diff --git a/vendor/github.com/prometheus/client_golang/prometheus/timer.go b/vendor/github.com/prometheus/client_golang/prometheus/timer.go index 52344fef53f..c1318ffb51e 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/timer.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/timer.go @@ -37,10 +37,10 @@ type Timer struct { // or // // func TimeMeWithExemplar() { -// timer := NewTimer(myHistogram) -// defer timer.ObserveDurationWithExemplar(exemplar) -// // Do actual work. -// } +// timer := NewTimer(myHistogram) +// defer timer.ObserveDurationWithExemplar(exemplar) +// // Do actual work. +// } func NewTimer(o Observer) *Timer { return &Timer{ begin: time.Now(), @@ -66,7 +66,7 @@ func (t *Timer) ObserveDuration() time.Duration { // ObserveDurationWithExemplar is like ObserveDuration, but it will also // observe exemplar with the duration unless exemplar is nil or provided Observer can't -// be casted to ExemplarObserver. +// be cast to ExemplarObserver. func (t *Timer) ObserveDurationWithExemplar(exemplar Labels) time.Duration { d := time.Since(t.begin) eo, ok := t.observer.(ExemplarObserver) diff --git a/vendor/github.com/prometheus/client_golang/prometheus/vec.go b/vendor/github.com/prometheus/client_golang/prometheus/vec.go index 487b466563b..121d2a96390 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/vec.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/vec.go @@ -193,9 +193,11 @@ func (m *MetricVec) CurryWith(labels Labels) (*MetricVec, error) { // // Keeping the Metric for later use is possible (and should be considered if // performance is critical), but keep in mind that Reset, DeleteLabelValues and -// Delete can be used to delete the Metric from the MetricVec. In that case, the -// Metric will still exist, but it will not be exported anymore, even if a -// Metric with the same label values is created later. +// Delete can be used to delete the Metric from the MetricVec. In that case, if +// you have previously kept a reference to that Metric, the Metric object still +// exists and can be used, but it will not be exported anymore. If a Metric with +// the same label values is created later, updates to the old Metric reference +// will not be exported. // // An error is returned if the number of label values is not the same as the // number of variable labels in Desc (minus any curried labels). @@ -657,7 +659,7 @@ func inlineLabelValues(lvs []string, curry []curriedLabelValue) []string { } var labelsPool = &sync.Pool{ - New: func() interface{} { + New: func() any { return make(Labels) }, } diff --git a/vendor/github.com/prometheus/client_golang/prometheus/wrap.go b/vendor/github.com/prometheus/client_golang/prometheus/wrap.go index 2ed1285068e..697f55558bd 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/wrap.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/wrap.go @@ -230,6 +230,7 @@ func wrapDesc(desc *Desc, prefix string, labels Labels) *Desc { return &Desc{ fqName: desc.fqName, help: desc.help, + unit: desc.unit, variableLabels: desc.variableLabels, constLabelPairs: desc.constLabelPairs, err: fmt.Errorf("attempted wrapping with already existing label name %q", ln), @@ -238,8 +239,8 @@ func wrapDesc(desc *Desc, prefix string, labels Labels) *Desc { constLabels[ln] = lv } // NewDesc will do remaining validations. - newDesc := V2.NewDesc(prefix+desc.fqName, desc.help, desc.variableLabels, constLabels) - // Propagate errors if there was any. This will override any errer + newDesc := V2.NewDesc(prefix+desc.fqName, desc.help, desc.variableLabels, constLabels, WithUnit(desc.unit)) + // Propagate errors if there was any. This will override any error // created by NewDesc above, i.e. earlier errors get precedence. if desc.err != nil { newDesc.err = desc.err diff --git a/vendor/github.com/prometheus/common/config/http_config.go b/vendor/github.com/prometheus/common/config/http_config.go index 88457375ff1..d633479c690 100644 --- a/vendor/github.com/prometheus/common/config/http_config.go +++ b/vendor/github.com/prometheus/common/config/http_config.go @@ -132,7 +132,7 @@ func (tv *TLSVersion) String() string { return s } } - return fmt.Sprintf("%d", tv) + return fmt.Sprintf("%d", *tv) } // BasicAuth contains basic HTTP authentication credentials. @@ -1178,10 +1178,8 @@ func originalRequestHost(req *http.Request) string { } // sensitiveHeadersOnRedirect lists the headers that must not be forwarded when -// following a redirect to a different host. The first four entries match the -// list stripped by makeHeadersCopier in net/http/client.go; we additionally -// strip the Proxy-* headers, which net/http does not, to avoid leaking proxy -// credentials to an untrusted host. +// following a redirect to a different host. The list matches the one stripped +// by makeHeadersCopier in net/http/client.go. var sensitiveHeadersOnRedirect = map[string]struct{}{ "Authorization": {}, // "Www-Authenticate" is the canonical form produced by diff --git a/vendor/github.com/prometheus/common/route/route.go b/vendor/github.com/prometheus/common/route/route.go index 18039fac0d5..b1f274c15d4 100644 --- a/vendor/github.com/prometheus/common/route/route.go +++ b/vendor/github.com/prometheus/common/route/route.go @@ -20,6 +20,11 @@ import ( "github.com/julienschmidt/httprouter" ) +// MethodQuery is the QUERY HTTP method. It is a safe, idempotent method that +// carries a request body, see https://datatracker.ietf.org/doc/rfc10008/. +// It is not yet part of net/http, so it is defined here. +const MethodQuery = "QUERY" + type param string // Param returns param p for the context, or the empty string when @@ -114,6 +119,11 @@ func (r *Router) Head(path string, h http.HandlerFunc) { r.rtr.HEAD(r.prefix+path, r.handle(path, h)) } +// Query registers a new QUERY route. +func (r *Router) Query(path string, h http.HandlerFunc) { + r.rtr.Handle(MethodQuery, r.prefix+path, r.handle(path, h)) +} + // Redirect takes an absolute path and sends an internal HTTP redirect for it, // prefixed by the router's path prefix. Note that this method does not include // functionality for handling relative paths or full URL redirects. diff --git a/vendor/github.com/prometheus/procfs/net_wireless.go b/vendor/github.com/prometheus/procfs/net_wireless.go index 69d07944516..f74dd3bed04 100644 --- a/vendor/github.com/prometheus/procfs/net_wireless.go +++ b/vendor/github.com/prometheus/procfs/net_wireless.go @@ -114,47 +114,47 @@ func parseWireless(r io.Reader) ([]*Wireless, error) { qlink, err := strconv.Atoi(strings.TrimSuffix(stats[1], ".")) if err != nil { - return nil, fmt.Errorf("%w: parse Quality:link as integer %q: %w", ErrFileParse, qlink, err) + return nil, fmt.Errorf("%w: parse Quality:link as integer %q: %w", ErrFileParse, stats[1], err) } qlevel, err := strconv.Atoi(strings.TrimSuffix(stats[2], ".")) if err != nil { - return nil, fmt.Errorf("%w: Quality:level as integer %q: %w", ErrFileParse, qlevel, err) + return nil, fmt.Errorf("%w: Quality:level as integer %q: %w", ErrFileParse, stats[2], err) } qnoise, err := strconv.Atoi(strings.TrimSuffix(stats[3], ".")) if err != nil { - return nil, fmt.Errorf("%w: Quality:noise as integer %q: %w", ErrFileParse, qnoise, err) + return nil, fmt.Errorf("%w: Quality:noise as integer %q: %w", ErrFileParse, stats[3], err) } dnwid, err := strconv.Atoi(stats[4]) if err != nil { - return nil, fmt.Errorf("%w: Discarded:nwid as integer %q: %w", ErrFileParse, dnwid, err) + return nil, fmt.Errorf("%w: Discarded:nwid as integer %q: %w", ErrFileParse, stats[4], err) } dcrypt, err := strconv.Atoi(stats[5]) if err != nil { - return nil, fmt.Errorf("%w: Discarded:crypt as integer %q: %w", ErrFileParse, dcrypt, err) + return nil, fmt.Errorf("%w: Discarded:crypt as integer %q: %w", ErrFileParse, stats[5], err) } dfrag, err := strconv.Atoi(stats[6]) if err != nil { - return nil, fmt.Errorf("%w: Discarded:frag as integer %q: %w", ErrFileParse, dfrag, err) + return nil, fmt.Errorf("%w: Discarded:frag as integer %q: %w", ErrFileParse, stats[6], err) } dretry, err := strconv.Atoi(stats[7]) if err != nil { - return nil, fmt.Errorf("%w: Discarded:retry as integer %q: %w", ErrFileParse, dretry, err) + return nil, fmt.Errorf("%w: Discarded:retry as integer %q: %w", ErrFileParse, stats[7], err) } dmisc, err := strconv.Atoi(stats[8]) if err != nil { - return nil, fmt.Errorf("%w: Discarded:misc as integer %q: %w", ErrFileParse, dmisc, err) + return nil, fmt.Errorf("%w: Discarded:misc as integer %q: %w", ErrFileParse, stats[8], err) } mbeacon, err := strconv.Atoi(stats[9]) if err != nil { - return nil, fmt.Errorf("%w: Missed:beacon as integer %q: %w", ErrFileParse, mbeacon, err) + return nil, fmt.Errorf("%w: Missed:beacon as integer %q: %w", ErrFileParse, stats[9], err) } w := &Wireless{ diff --git a/vendor/github.com/prometheus/procfs/proc_cgroup.go b/vendor/github.com/prometheus/procfs/proc_cgroup.go index 535c08d6fc0..7e8a122978f 100644 --- a/vendor/github.com/prometheus/procfs/proc_cgroup.go +++ b/vendor/github.com/prometheus/procfs/proc_cgroup.go @@ -60,7 +60,7 @@ func parseCgroupString(cgroupStr string) (*Cgroup, error) { } cgroup.HierarchyID, err = strconv.Atoi(fields[0]) if err != nil { - return nil, fmt.Errorf("%w: hierarchy ID: %q", ErrFileParse, cgroup.HierarchyID) + return nil, fmt.Errorf("%w: hierarchy ID: %q", ErrFileParse, fields[0]) } if fields[1] != "" { ssNames := strings.Split(fields[1], ",") diff --git a/vendor/github.com/stretchr/objx/README.md b/vendor/github.com/stretchr/objx/README.md index 78dc1f8b03e..e9ba8307354 100644 --- a/vendor/github.com/stretchr/objx/README.md +++ b/vendor/github.com/stretchr/objx/README.md @@ -1,8 +1,6 @@ # Objx [![Build Status](https://travis-ci.org/stretchr/objx.svg?branch=master)](https://travis-ci.org/stretchr/objx) [![Go Report Card](https://goreportcard.com/badge/github.com/stretchr/objx)](https://goreportcard.com/report/github.com/stretchr/objx) -[![Maintainability](https://api.codeclimate.com/v1/badges/1d64bc6c8474c2074f2b/maintainability)](https://codeclimate.com/github/stretchr/objx/maintainability) -[![Test Coverage](https://api.codeclimate.com/v1/badges/1d64bc6c8474c2074f2b/test_coverage)](https://codeclimate.com/github/stretchr/objx/test_coverage) [![Sourcegraph](https://sourcegraph.com/github.com/stretchr/objx/-/badge.svg)](https://sourcegraph.com/github.com/stretchr/objx) [![GoDoc](https://pkg.go.dev/badge/github.com/stretchr/objx?utm_source=godoc)](https://pkg.go.dev/github.com/stretchr/objx) @@ -19,49 +17,62 @@ Objx provides the `objx.Map` type, which is a `map[string]interface{}` that expo ### Pattern Objx uses a predictable pattern to make access data from within `map[string]interface{}` easy. Call one of the `objx.` functions to create your `objx.Map` to get going: - m, err := objx.FromJSON(json) +```go +m, err := objx.FromJSON(json) +``` NOTE: Any methods or functions with the `Must` prefix will panic if something goes wrong, the rest will be optimistic and try to figure things out without panicking. Use `Get` to access the value you're interested in. You can use dot and array notation too: - m.Get("places[0].latlng") +```go +m.Get("places[0].latlng") +``` Once you have sought the `Value` you're interested in, you can use the `Is*` methods to determine its type. - if m.Get("code").IsStr() { // Your code... } +```go +if m.Get("code").IsStr() { // Your code... } +``` Or you can just assume the type, and use one of the strong type methods to extract the real value: - m.Get("code").Int() +```go +m.Get("code").Int() +``` If there's no value there (or if it's the wrong type) then a default value will be returned, or you can be explicit about the default value. - Get("code").Int(-1) - +```go +Get("code").Int(-1) +``` If you're dealing with a slice of data as a value, Objx provides many useful methods for iterating, manipulating and selecting that data. You can find out more by exploring the index below. ### Reading data A simple example of how to use Objx: - // Use MustFromJSON to make an objx.Map from some JSON - m := objx.MustFromJSON(`{"name": "Mat", "age": 30}`) +```go +// Use MustFromJSON to make an objx.Map from some JSON +m := objx.MustFromJSON(`{"name": "Mat", "age": 30}`) - // Get the details - name := m.Get("name").Str() - age := m.Get("age").Int() +// Get the details +name := m.Get("name").Str() +age := m.Get("age").Int() - // Get their nickname (or use their name if they don't have one) - nickname := m.Get("nickname").Str(name) +// Get their nickname (or use their name if they don't have one) +nickname := m.Get("nickname").Str(name) +``` ### Ranging Since `objx.Map` is a `map[string]interface{}` you can treat it as such. For example, to `range` the data, do what you would expect: - m := objx.MustFromJSON(json) - for key, value := range m { - // Your code... - } +```go +m := objx.MustFromJSON(json) +for key, value := range m { + // Your code... +} +``` ## Installation To install Objx, use go get: diff --git a/vendor/github.com/stretchr/testify/assert/assertion_format.go b/vendor/github.com/stretchr/testify/assert/assertion_format.go index c592f6ad5fb..a19a89279cc 100644 --- a/vendor/github.com/stretchr/testify/assert/assertion_format.go +++ b/vendor/github.com/stretchr/testify/assert/assertion_format.go @@ -84,7 +84,7 @@ func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, ar return Equal(t, expected, actual, append([]interface{}{msg}, args...)...) } -// EqualErrorf asserts that a function returned an error (i.e. not `nil`) +// EqualErrorf asserts that a function returned a non-nil error (i.e. an error) // and that it is equal to the provided error. // // actualObj, err := SomeFunction() @@ -124,7 +124,7 @@ func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg stri return EqualValues(t, expected, actual, append([]interface{}{msg}, args...)...) } -// Errorf asserts that a function returned an error (i.e. not `nil`). +// Errorf asserts that a function returned a non-nil error (ie. an error). // // actualObj, err := SomeFunction() // assert.Errorf(t, err, "error message %s", "formatted") @@ -144,8 +144,8 @@ func ErrorAsf(t TestingT, err error, target interface{}, msg string, args ...int return ErrorAs(t, err, target, append([]interface{}{msg}, args...)...) } -// ErrorContainsf asserts that a function returned an error (i.e. not `nil`) -// and that the error contains the specified substring. +// ErrorContainsf asserts that a function returned a non-nil error (i.e. an +// error) and that the error contains the specified substring. // // actualObj, err := SomeFunction() // assert.ErrorContainsf(t, err, expectedErrorSubString, "error message %s", "formatted") @@ -190,10 +190,10 @@ func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick // time.Sleep(8*time.Second) // externalValue = true // }() -// assert.EventuallyWithTf(t, func(c *assert.CollectT, "error message %s", "formatted") { +// assert.EventuallyWithTf(t, func(c *assert.CollectT) { // // add assertions as needed; any assertion failure will fail the current tick // assert.True(c, externalValue, "expected 'externalValue' to be true") -// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false") +// }, 10*time.Second, 1*time.Second, "error message %s", "formatted") func EventuallyWithTf(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -552,7 +552,7 @@ func NoDirExistsf(t TestingT, path string, msg string, args ...interface{}) bool return NoDirExists(t, path, append([]interface{}{msg}, args...)...) } -// NoErrorf asserts that a function returned no error (i.e. `nil`). +// NoErrorf asserts that a function returned a nil error (ie. no error). // // actualObj, err := SomeFunction() // if assert.NoErrorf(t, err, "error message %s", "formatted") { @@ -849,7 +849,19 @@ func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, return WithinRange(t, actual, start, end, append([]interface{}{msg}, args...)...) } -// YAMLEqf asserts that two YAML strings are equivalent. +// YAMLEqf asserts that the first documents in the two YAML strings are equivalent. +// +// expected := `--- +// key: value +// --- +// key: this is a second document, it is not evaluated +// ` +// actual := `--- +// key: value +// --- +// key: this is a subsequent document, it is not evaluated +// ` +// assert.YAMLEqf(t, expected, actual, "error message %s", "formatted") func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() diff --git a/vendor/github.com/stretchr/testify/assert/assertion_forward.go b/vendor/github.com/stretchr/testify/assert/assertion_forward.go index 58db928450d..cd2a86061c6 100644 --- a/vendor/github.com/stretchr/testify/assert/assertion_forward.go +++ b/vendor/github.com/stretchr/testify/assert/assertion_forward.go @@ -146,7 +146,7 @@ func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs return Equal(a.t, expected, actual, msgAndArgs...) } -// EqualError asserts that a function returned an error (i.e. not `nil`) +// EqualError asserts that a function returned a non-nil error (i.e. an error) // and that it is equal to the provided error. // // actualObj, err := SomeFunction() @@ -158,7 +158,7 @@ func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ... return EqualError(a.t, theError, errString, msgAndArgs...) } -// EqualErrorf asserts that a function returned an error (i.e. not `nil`) +// EqualErrorf asserts that a function returned a non-nil error (i.e. an error) // and that it is equal to the provided error. // // actualObj, err := SomeFunction() @@ -240,7 +240,7 @@ func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string return Equalf(a.t, expected, actual, msg, args...) } -// Error asserts that a function returned an error (i.e. not `nil`). +// Error asserts that a function returned a non-nil error (ie. an error). // // actualObj, err := SomeFunction() // a.Error(err) @@ -269,8 +269,8 @@ func (a *Assertions) ErrorAsf(err error, target interface{}, msg string, args .. return ErrorAsf(a.t, err, target, msg, args...) } -// ErrorContains asserts that a function returned an error (i.e. not `nil`) -// and that the error contains the specified substring. +// ErrorContains asserts that a function returned a non-nil error (i.e. an +// error) and that the error contains the specified substring. // // actualObj, err := SomeFunction() // a.ErrorContains(err, expectedErrorSubString) @@ -281,8 +281,8 @@ func (a *Assertions) ErrorContains(theError error, contains string, msgAndArgs . return ErrorContains(a.t, theError, contains, msgAndArgs...) } -// ErrorContainsf asserts that a function returned an error (i.e. not `nil`) -// and that the error contains the specified substring. +// ErrorContainsf asserts that a function returned a non-nil error (i.e. an +// error) and that the error contains the specified substring. // // actualObj, err := SomeFunction() // a.ErrorContainsf(err, expectedErrorSubString, "error message %s", "formatted") @@ -311,7 +311,7 @@ func (a *Assertions) ErrorIsf(err error, target error, msg string, args ...inter return ErrorIsf(a.t, err, target, msg, args...) } -// Errorf asserts that a function returned an error (i.e. not `nil`). +// Errorf asserts that a function returned a non-nil error (ie. an error). // // actualObj, err := SomeFunction() // a.Errorf(err, "error message %s", "formatted") @@ -372,10 +372,10 @@ func (a *Assertions) EventuallyWithT(condition func(collect *CollectT), waitFor // time.Sleep(8*time.Second) // externalValue = true // }() -// a.EventuallyWithTf(func(c *assert.CollectT, "error message %s", "formatted") { +// a.EventuallyWithTf(func(c *assert.CollectT) { // // add assertions as needed; any assertion failure will fail the current tick // assert.True(c, externalValue, "expected 'externalValue' to be true") -// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false") +// }, 10*time.Second, 1*time.Second, "error message %s", "formatted") func (a *Assertions) EventuallyWithTf(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1096,7 +1096,7 @@ func (a *Assertions) NoDirExistsf(path string, msg string, args ...interface{}) return NoDirExistsf(a.t, path, msg, args...) } -// NoError asserts that a function returned no error (i.e. `nil`). +// NoError asserts that a function returned a nil error (ie. no error). // // actualObj, err := SomeFunction() // if a.NoError(err) { @@ -1109,7 +1109,7 @@ func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) bool { return NoError(a.t, err, msgAndArgs...) } -// NoErrorf asserts that a function returned no error (i.e. `nil`). +// NoErrorf asserts that a function returned a nil error (ie. no error). // // actualObj, err := SomeFunction() // if a.NoErrorf(err, "error message %s", "formatted") { @@ -1690,7 +1690,19 @@ func (a *Assertions) WithinRangef(actual time.Time, start time.Time, end time.Ti return WithinRangef(a.t, actual, start, end, msg, args...) } -// YAMLEq asserts that two YAML strings are equivalent. +// YAMLEq asserts that the first documents in the two YAML strings are equivalent. +// +// expected := `--- +// key: value +// --- +// key: this is a second document, it is not evaluated +// ` +// actual := `--- +// key: value +// --- +// key: this is a subsequent document, it is not evaluated +// ` +// a.YAMLEq(expected, actual) func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1698,7 +1710,19 @@ func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interf return YAMLEq(a.t, expected, actual, msgAndArgs...) } -// YAMLEqf asserts that two YAML strings are equivalent. +// YAMLEqf asserts that the first documents in the two YAML strings are equivalent. +// +// expected := `--- +// key: value +// --- +// key: this is a second document, it is not evaluated +// ` +// actual := `--- +// key: value +// --- +// key: this is a subsequent document, it is not evaluated +// ` +// a.YAMLEqf(expected, actual, "error message %s", "formatted") func (a *Assertions) YAMLEqf(expected string, actual string, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() diff --git a/vendor/github.com/stretchr/testify/assert/assertion_order.go b/vendor/github.com/stretchr/testify/assert/assertion_order.go index 2fdf80fdd30..a44b40ed3f5 100644 --- a/vendor/github.com/stretchr/testify/assert/assertion_order.go +++ b/vendor/github.com/stretchr/testify/assert/assertion_order.go @@ -9,7 +9,7 @@ import ( func isOrdered(t TestingT, object interface{}, allowedComparesResults []compareResult, failMessage string, msgAndArgs ...interface{}) bool { objKind := reflect.TypeOf(object).Kind() if objKind != reflect.Slice && objKind != reflect.Array { - return false + return Fail(t, fmt.Sprintf("object %T is not an ordered collection", object), msgAndArgs...) } objValue := reflect.ValueOf(object) @@ -50,6 +50,9 @@ func isOrdered(t TestingT, object interface{}, allowedComparesResults []compareR // assert.IsIncreasing(t, []float{1, 2}) // assert.IsIncreasing(t, []string{"a", "b"}) func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } return isOrdered(t, object, []compareResult{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...) } @@ -59,6 +62,9 @@ func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) boo // assert.IsNonIncreasing(t, []float{2, 1}) // assert.IsNonIncreasing(t, []string{"b", "a"}) func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } return isOrdered(t, object, []compareResult{compareEqual, compareGreater}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...) } @@ -68,6 +74,9 @@ func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) // assert.IsDecreasing(t, []float{2, 1}) // assert.IsDecreasing(t, []string{"b", "a"}) func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } return isOrdered(t, object, []compareResult{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...) } @@ -77,5 +86,8 @@ func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) boo // assert.IsNonDecreasing(t, []float{1, 2}) // assert.IsNonDecreasing(t, []string{"a", "b"}) func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } return isOrdered(t, object, []compareResult{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...) } diff --git a/vendor/github.com/stretchr/testify/assert/assertions.go b/vendor/github.com/stretchr/testify/assert/assertions.go index de8de0cb6c4..166f63726cf 100644 --- a/vendor/github.com/stretchr/testify/assert/assertions.go +++ b/vendor/github.com/stretchr/testify/assert/assertions.go @@ -17,11 +17,10 @@ import ( "unicode" "unicode/utf8" - "github.com/davecgh/go-spew/spew" - "github.com/pmezard/go-difflib/difflib" - - // Wrapper around gopkg.in/yaml.v3 + // Wrapper around go.yaml.in/yaml/v3 "github.com/stretchr/testify/assert/yaml" + "github.com/stretchr/testify/internal/difflib" + "github.com/stretchr/testify/internal/spew" ) //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=assert -template=assertion_format.go.tmpl" @@ -33,19 +32,19 @@ type TestingT interface { // ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful // for table driven tests. -type ComparisonAssertionFunc func(TestingT, interface{}, interface{}, ...interface{}) bool +type ComparisonAssertionFunc = func(TestingT, interface{}, interface{}, ...interface{}) bool // ValueAssertionFunc is a common function prototype when validating a single value. Can be useful // for table driven tests. -type ValueAssertionFunc func(TestingT, interface{}, ...interface{}) bool +type ValueAssertionFunc = func(TestingT, interface{}, ...interface{}) bool // BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful // for table driven tests. -type BoolAssertionFunc func(TestingT, bool, ...interface{}) bool +type BoolAssertionFunc = func(TestingT, bool, ...interface{}) bool // ErrorAssertionFunc is a common function prototype when validating an error value. Can be useful // for table driven tests. -type ErrorAssertionFunc func(TestingT, error, ...interface{}) bool +type ErrorAssertionFunc = func(TestingT, error, ...interface{}) bool // PanicAssertionFunc is a common function prototype when validating a panic value. Can be useful // for table driven tests. @@ -325,13 +324,15 @@ func messageFromMsgAndArgs(msgAndArgs ...interface{}) string { func indentMessageLines(message string, longestLabelLen int) string { outBuf := new(bytes.Buffer) - for i, scanner := 0, bufio.NewScanner(strings.NewReader(message)); scanner.Scan(); i++ { - // no need to align first line because it starts at the correct location (after the label) - if i != 0 { - // append alignLen+1 spaces to align with "{{longestLabel}}:" before adding tab - outBuf.WriteString("\n\t" + strings.Repeat(" ", longestLabelLen+1) + "\t") + scanner := bufio.NewScanner(strings.NewReader(message)) + for firstLine := true; scanner.Scan(); firstLine = false { + if !firstLine { + fmt.Fprint(outBuf, "\n\t"+strings.Repeat(" ", longestLabelLen+1)+"\t") } - outBuf.WriteString(scanner.Text()) + fmt.Fprint(outBuf, scanner.Text()) + } + if err := scanner.Err(); err != nil { + return fmt.Sprintf("cannot display message: %s", err) } return outBuf.String() @@ -544,9 +545,8 @@ func Same(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) b if !same { // both are pointers but not the same type & pointing to the same address return Fail(t, fmt.Sprintf("Not same: \n"+ - "expected: %p %#[1]v\n"+ - "actual : %p %#[2]v", - expected, actual), msgAndArgs...) + "expected: %[2]s (%[1]T)(%[1]p)\n"+ + "actual : %[4]s (%[3]T)(%[3]p)", expected, truncatingFormat("%#v", expected), actual, truncatingFormat("%#v", actual)), msgAndArgs...) } return true @@ -571,8 +571,8 @@ func NotSame(t TestingT, expected, actual interface{}, msgAndArgs ...interface{} if same { return Fail(t, fmt.Sprintf( - "Expected and actual point to the same object: %p %#[1]v", - expected), msgAndArgs...) + "Expected and actual point to the same object: %p %s", + expected, truncatingFormat("%#v", expected)), msgAndArgs...) } return true } @@ -604,25 +604,26 @@ func samePointers(first, second interface{}) (same bool, ok bool) { // to a type conversion in the Go grammar. func formatUnequalValues(expected, actual interface{}) (e string, a string) { if reflect.TypeOf(expected) != reflect.TypeOf(actual) { - return fmt.Sprintf("%T(%s)", expected, truncatingFormat(expected)), - fmt.Sprintf("%T(%s)", actual, truncatingFormat(actual)) + return fmt.Sprintf("%T(%s)", expected, truncatingFormat("%#v", expected)), + fmt.Sprintf("%T(%s)", actual, truncatingFormat("%#v", actual)) } switch expected.(type) { case time.Duration: return fmt.Sprintf("%v", expected), fmt.Sprintf("%v", actual) } - return truncatingFormat(expected), truncatingFormat(actual) + return truncatingFormat("%#v", expected), truncatingFormat("%#v", actual) } // truncatingFormat formats the data and truncates it if it's too long. // // This helps keep formatted error messages lines from exceeding the // bufio.MaxScanTokenSize max line length that the go testing framework imposes. -func truncatingFormat(data interface{}) string { - value := fmt.Sprintf("%#v", data) - max := bufio.MaxScanTokenSize - 100 // Give us some space the type info too if needed. - if len(value) > max { - value = value[0:max] + "<... truncated>" +func truncatingFormat(format string, data interface{}) string { + value := fmt.Sprintf(format, data) + // Give us space for two truncated objects and the surrounding sentence. + maxMessageSize := bufio.MaxScanTokenSize/2 - 100 + if len(value) > maxMessageSize { + value = value[0:maxMessageSize] + "<... truncated>" } return value } @@ -743,7 +744,7 @@ func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() } - return Fail(t, fmt.Sprintf("Expected nil, but got: %#v", object), msgAndArgs...) + return Fail(t, fmt.Sprintf("Expected nil, but got: %s", truncatingFormat("%#v", object)), msgAndArgs...) } // isEmpty gets whether the specified object is considered empty or not. @@ -793,7 +794,7 @@ func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() } - Fail(t, fmt.Sprintf("Should be empty, but was %v", object), msgAndArgs...) + Fail(t, fmt.Sprintf("Should be empty, but was %s", truncatingFormat("%v", object)), msgAndArgs...) } return pass @@ -836,11 +837,11 @@ func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) } l, ok := getLen(object) if !ok { - return Fail(t, fmt.Sprintf("\"%v\" could not be applied builtin len()", object), msgAndArgs...) + return Fail(t, fmt.Sprintf("%q could not be applied builtin len()", truncatingFormat("%v", object)), msgAndArgs...) } if l != length { - return Fail(t, fmt.Sprintf("\"%v\" should have %d item(s), but has %d", object, length, l), msgAndArgs...) + return Fail(t, fmt.Sprintf("%q should have %d item(s), but has %d", truncatingFormat("%v", object), length, l), msgAndArgs...) } return true } @@ -889,7 +890,7 @@ func NotEqual(t TestingT, expected, actual interface{}, msgAndArgs ...interface{ } if ObjectsAreEqual(expected, actual) { - return Fail(t, fmt.Sprintf("Should not be: %#v\n", actual), msgAndArgs...) + return Fail(t, fmt.Sprintf("Should not be: %s\n", truncatingFormat("%#v", actual)), msgAndArgs...) } return true @@ -904,7 +905,7 @@ func NotEqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...inte } if ObjectsAreEqualValues(expected, actual) { - return Fail(t, fmt.Sprintf("Should not be: %#v\n", actual), msgAndArgs...) + return Fail(t, fmt.Sprintf("Should not be: %s\n", truncatingFormat("%#v", actual)), msgAndArgs...) } return true @@ -964,10 +965,10 @@ func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bo ok, found := containsElement(s, contains) if !ok { - return Fail(t, fmt.Sprintf("%#v could not be applied builtin len()", s), msgAndArgs...) + return Fail(t, fmt.Sprintf("%s could not be applied builtin len()", truncatingFormat("%#v", s)), msgAndArgs...) } if !found { - return Fail(t, fmt.Sprintf("%#v does not contain %#v", s, contains), msgAndArgs...) + return Fail(t, fmt.Sprintf("%s does not contain %#v", truncatingFormat("%#v", s), contains), msgAndArgs...) } return true @@ -986,10 +987,10 @@ func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) ok, found := containsElement(s, contains) if !ok { - return Fail(t, fmt.Sprintf("%#v could not be applied builtin len()", s), msgAndArgs...) + return Fail(t, fmt.Sprintf("%s could not be applied builtin len()", truncatingFormat("%#v", s)), msgAndArgs...) } if found { - return Fail(t, fmt.Sprintf("%#v should not contain %#v", s, contains), msgAndArgs...) + return Fail(t, fmt.Sprintf("%s should not contain %#v", truncatingFormat("%#v", s), contains), msgAndArgs...) } return true @@ -1031,10 +1032,10 @@ func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok av := actualMap.MapIndex(k) if !av.IsValid() { - return Fail(t, fmt.Sprintf("%#v does not contain %#v", list, subset), msgAndArgs...) + return Fail(t, fmt.Sprintf("%s does not contain %s", truncatingFormat("%#v", list), truncatingFormat("%#v", subset)), msgAndArgs...) } if !ObjectsAreEqual(ev.Interface(), av.Interface()) { - return Fail(t, fmt.Sprintf("%#v does not contain %#v", list, subset), msgAndArgs...) + return Fail(t, fmt.Sprintf("%s does not contain %s", truncatingFormat("%#v", list), truncatingFormat("%#v", subset)), msgAndArgs...) } } @@ -1056,7 +1057,7 @@ func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok return Fail(t, fmt.Sprintf("%#v could not be applied builtin len()", list), msgAndArgs...) } if !found { - return Fail(t, fmt.Sprintf("%#v does not contain %#v", list, element), msgAndArgs...) + return Fail(t, fmt.Sprintf("%s does not contain %#v", truncatingFormat("%#v", list), element), msgAndArgs...) } } @@ -1082,12 +1083,12 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) listKind := reflect.TypeOf(list).Kind() if listKind != reflect.Array && listKind != reflect.Slice && listKind != reflect.Map { - return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...) + return Fail(t, fmt.Sprintf("%#v has an unsupported type %s", list, listKind), msgAndArgs...) } subsetKind := reflect.TypeOf(subset).Kind() if subsetKind != reflect.Array && subsetKind != reflect.Slice && subsetKind != reflect.Map { - return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...) + return Fail(t, fmt.Sprintf("%#v has an unsupported type %s", subset, subsetKind), msgAndArgs...) } if subsetKind == reflect.Map && listKind == reflect.Map { @@ -1106,7 +1107,7 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) } } - return Fail(t, fmt.Sprintf("%q is a subset of %q", subset, list), msgAndArgs...) + return Fail(t, fmt.Sprintf("%s is a subset of %s", truncatingFormat("%#v", subset), truncatingFormat("%#v", list)), msgAndArgs...) } subsetList := reflect.ValueOf(subset) @@ -1121,14 +1122,14 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) element := subsetList.Index(i).Interface() ok, found := containsElement(list, element) if !ok { - return Fail(t, fmt.Sprintf("%q could not be applied builtin len()", list), msgAndArgs...) + return Fail(t, fmt.Sprintf("%#v could not be applied builtin len()", list), msgAndArgs...) } if !found { return true } } - return Fail(t, fmt.Sprintf("%q is a subset of %q", subset, list), msgAndArgs...) + return Fail(t, fmt.Sprintf("%s is a subset of %s", truncatingFormat("%#v", subset), truncatingFormat("%#v", list)), msgAndArgs...) } // ElementsMatch asserts that the specified listA(array, slice...) is equal to specified @@ -1343,9 +1344,15 @@ func PanicsWithError(t TestingT, errString string, f PanicTestFunc, msgAndArgs . if !funcDidPanic { return Fail(t, fmt.Sprintf("func %#v should panic\n\tPanic value:\t%#v", f, panicValue), msgAndArgs...) } - panicErr, ok := panicValue.(error) - if !ok || panicErr.Error() != errString { - return Fail(t, fmt.Sprintf("func %#v should panic with error message:\t%#v\n\tPanic value:\t%#v\n\tPanic stack:\t%s", f, errString, panicValue, panickedStack), msgAndArgs...) + panicErr, isError := panicValue.(error) + if !isError || panicErr.Error() != errString { + msg := fmt.Sprintf("func %#v should panic with error message:\t%#v\n", f, errString) + if isError { + msg += fmt.Sprintf("\tError message:\t%#v\n", panicErr.Error()) + } + msg += fmt.Sprintf("\tPanic value:\t%#v\n", panicValue) + msg += fmt.Sprintf("\tPanic stack:\t%s\n", panickedStack) + return Fail(t, msg, msgAndArgs...) } return true @@ -1624,7 +1631,7 @@ func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon float64, m Errors */ -// NoError asserts that a function returned no error (i.e. `nil`). +// NoError asserts that a function returned a nil error (ie. no error). // // actualObj, err := SomeFunction() // if assert.NoError(t, err) { @@ -1635,13 +1642,13 @@ func NoError(t TestingT, err error, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() } - return Fail(t, fmt.Sprintf("Received unexpected error:\n%+v", err), msgAndArgs...) + return Fail(t, fmt.Sprintf("Received unexpected error:\n%s", truncatingFormat("%+v", err)), msgAndArgs...) } return true } -// Error asserts that a function returned an error (i.e. not `nil`). +// Error asserts that a function returned a non-nil error (ie. an error). // // actualObj, err := SomeFunction() // assert.Error(t, err) @@ -1656,7 +1663,7 @@ func Error(t TestingT, err error, msgAndArgs ...interface{}) bool { return true } -// EqualError asserts that a function returned an error (i.e. not `nil`) +// EqualError asserts that a function returned a non-nil error (i.e. an error) // and that it is equal to the provided error. // // actualObj, err := SomeFunction() @@ -1674,13 +1681,13 @@ func EqualError(t TestingT, theError error, errString string, msgAndArgs ...inte if expected != actual { return Fail(t, fmt.Sprintf("Error message not equal:\n"+ "expected: %q\n"+ - "actual : %q", expected, actual), msgAndArgs...) + "actual : %s", expected, truncatingFormat("%q", actual)), msgAndArgs...) } return true } -// ErrorContains asserts that a function returned an error (i.e. not `nil`) -// and that the error contains the specified substring. +// ErrorContains asserts that a function returned a non-nil error (i.e. an +// error) and that the error contains the specified substring. // // actualObj, err := SomeFunction() // assert.ErrorContains(t, err, expectedErrorSubString) @@ -1694,7 +1701,7 @@ func ErrorContains(t TestingT, theError error, contains string, msgAndArgs ...in actual := theError.Error() if !strings.Contains(actual, contains) { - return Fail(t, fmt.Sprintf("Error %#v does not contain %#v", actual, contains), msgAndArgs...) + return Fail(t, fmt.Sprintf("Error %s does not contain %#v", truncatingFormat("%#v", actual), contains), msgAndArgs...) } return true @@ -1760,7 +1767,7 @@ func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) bool { h.Helper() } if i != nil && !reflect.DeepEqual(i, reflect.Zero(reflect.TypeOf(i)).Interface()) { - return Fail(t, fmt.Sprintf("Should be zero, but was %v", i), msgAndArgs...) + return Fail(t, fmt.Sprintf("Should be zero, but was %s", truncatingFormat("%v", i)), msgAndArgs...) } return true } @@ -1874,7 +1881,19 @@ func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{ return Equal(t, expectedJSONAsInterface, actualJSONAsInterface, msgAndArgs...) } -// YAMLEq asserts that two YAML strings are equivalent. +// YAMLEq asserts that the first documents in the two YAML strings are equivalent. +// +// expected := `--- +// key: value +// --- +// key: this is a second document, it is not evaluated +// ` +// actual := `--- +// key: value +// --- +// key: this is a subsequent document, it is not evaluated +// ` +// assert.YAMLEq(t, expected, actual) func YAMLEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -2188,8 +2207,8 @@ func ErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) bool { chain := buildErrorChainString(err, false) return Fail(t, fmt.Sprintf("Target error should be in err chain:\n"+ - "expected: %q\n"+ - "in chain: %s", expectedText, chain, + "expected: %s\n"+ + "in chain: %s", truncatingFormat("%q", expectedText), truncatingFormat("%s", chain), ), msgAndArgs...) } @@ -2211,8 +2230,8 @@ func NotErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) bool { chain := buildErrorChainString(err, false) return Fail(t, fmt.Sprintf("Target error should not be in err chain:\n"+ - "found: %q\n"+ - "in chain: %s", expectedText, chain, + "found: %s\n"+ + "in chain: %s", truncatingFormat("%q", expectedText), truncatingFormat("%s", chain), ), msgAndArgs...) } @@ -2236,7 +2255,7 @@ func ErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...interface{ return Fail(t, fmt.Sprintf("Should be in error chain:\n"+ "expected: %s\n"+ - "in chain: %s", expectedType, chain, + "in chain: %s", expectedType, truncatingFormat("%s", chain), ), msgAndArgs...) } @@ -2254,7 +2273,7 @@ func NotErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...interfa return Fail(t, fmt.Sprintf("Target error should not be in err chain:\n"+ "found: %s\n"+ - "in chain: %s", reflect.TypeOf(target).Elem().String(), chain, + "in chain: %s", reflect.TypeOf(target).Elem().String(), truncatingFormat("%s", chain), ), msgAndArgs...) } diff --git a/vendor/github.com/stretchr/testify/assert/doc.go b/vendor/github.com/stretchr/testify/assert/doc.go index a0b953aa5cf..c111589c7eb 100644 --- a/vendor/github.com/stretchr/testify/assert/doc.go +++ b/vendor/github.com/stretchr/testify/assert/doc.go @@ -40,8 +40,8 @@ // // # Assertions // -// Assertions allow you to easily write test code, and are global funcs in the `assert` package. -// All assertion functions take, as the first argument, the `*testing.T` object provided by the +// Assertions allow you to easily write test code, and are global funcs in the assert package. +// All assertion functions take, as the first argument, the [*testing.T] object provided by the // testing framework. This allows the assertion funcs to write the failings and other details to // the correct place. // diff --git a/vendor/github.com/stretchr/testify/assert/yaml/yaml_custom.go b/vendor/github.com/stretchr/testify/assert/yaml/yaml_custom.go index 5a74c4f4d5b..956227ca272 100644 --- a/vendor/github.com/stretchr/testify/assert/yaml/yaml_custom.go +++ b/vendor/github.com/stretchr/testify/assert/yaml/yaml_custom.go @@ -7,7 +7,7 @@ // go test -tags testify_yaml_custom // // This implementation can be used at build time to replace the default implementation -// to avoid linking with [gopkg.in/yaml.v3]. +// to avoid linking with [go.yaml.in/yaml/v3]. // // In your test package: // diff --git a/vendor/github.com/stretchr/testify/assert/yaml/yaml_default.go b/vendor/github.com/stretchr/testify/assert/yaml/yaml_default.go index 0bae80e34a3..dd89ac03aab 100644 --- a/vendor/github.com/stretchr/testify/assert/yaml/yaml_default.go +++ b/vendor/github.com/stretchr/testify/assert/yaml/yaml_default.go @@ -6,7 +6,7 @@ // indirection with an alternative implementation of this package that uses // another implementation of YAML deserialization. This allows to not either not // use YAML deserialization at all, or to use another implementation than -// [gopkg.in/yaml.v3] (for example for license compatibility reasons, see [PR #1120]). +// [go.yaml.in/yaml/v3] (for example for license compatibility reasons, see [PR #1120]). // // Alternative implementations are selected using build tags: // @@ -28,9 +28,9 @@ // [PR #1120]: https://github.com/stretchr/testify/pull/1120 package yaml -import goyaml "gopkg.in/yaml.v3" +import goyaml "go.yaml.in/yaml/v3" -// Unmarshal is just a wrapper of [gopkg.in/yaml.v3.Unmarshal]. +// Unmarshal is just a wrapper of [go.yaml.in/yaml/v3.Unmarshal]. func Unmarshal(in []byte, out interface{}) error { return goyaml.Unmarshal(in, out) } diff --git a/vendor/github.com/stretchr/testify/assert/yaml/yaml_fail.go b/vendor/github.com/stretchr/testify/assert/yaml/yaml_fail.go index 8041803fd2f..a51d2792508 100644 --- a/vendor/github.com/stretchr/testify/assert/yaml/yaml_fail.go +++ b/vendor/github.com/stretchr/testify/assert/yaml/yaml_fail.go @@ -3,7 +3,7 @@ // Package yaml is an implementation of YAML functions that always fail. // // This implementation can be used at build time to replace the default implementation -// to avoid linking with [gopkg.in/yaml.v3]: +// to avoid linking with [go.yaml.in/yaml/v3]: // // go test -tags testify_yaml_fail package yaml diff --git a/vendor/github.com/pmezard/go-difflib/LICENSE b/vendor/github.com/stretchr/testify/internal/difflib/LICENSE similarity index 95% rename from vendor/github.com/pmezard/go-difflib/LICENSE rename to vendor/github.com/stretchr/testify/internal/difflib/LICENSE index c67dad612a3..485be13c67b 100644 --- a/vendor/github.com/pmezard/go-difflib/LICENSE +++ b/vendor/github.com/stretchr/testify/internal/difflib/LICENSE @@ -24,4 +24,4 @@ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/vendor/github.com/pmezard/go-difflib/difflib/difflib.go b/vendor/github.com/stretchr/testify/internal/difflib/difflib.go similarity index 77% rename from vendor/github.com/pmezard/go-difflib/difflib/difflib.go rename to vendor/github.com/stretchr/testify/internal/difflib/difflib.go index 003e99fadb4..9984599b4ff 100644 --- a/vendor/github.com/pmezard/go-difflib/difflib/difflib.go +++ b/vendor/github.com/stretchr/testify/internal/difflib/difflib.go @@ -8,11 +8,14 @@ // // - unified_diff // -// - context_diff -// // Getting unified diffs was the main goal of the port. Keep in mind this code // is mostly suitable to output text differences in a human friendly way, there // are no guarantees generated diffs are consumable by patch(1). +// +// This package was adopted from [github.com/pmezard/go-difflib] which +// is no longer maintained. +// +// [github.com/pmezard/go-difflib]: https://github.com/pmezard/go-difflib package difflib import ( @@ -37,13 +40,6 @@ func max(a, b int) int { return b } -func calculateRatio(matches, length int) float64 { - if length > 0 { - return 2.0 * float64(matches) / float64(length) - } - return 1.0 -} - type Match struct { A int B int @@ -103,14 +99,6 @@ func NewMatcher(a, b []string) *SequenceMatcher { return &m } -func NewMatcherWithJunk(a, b []string, autoJunk bool, - isJunk func(string) bool) *SequenceMatcher { - - m := SequenceMatcher{IsJunk: isJunk, autoJunk: autoJunk} - m.SetSeqs(a, b) - return &m -} - // Set two sequences to be compared. func (m *SequenceMatcher) SetSeqs(a, b []string) { m.SetSeq1(a) @@ -199,12 +187,15 @@ func (m *SequenceMatcher) isBJunk(s string) bool { // If IsJunk is not defined: // // Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where -// alo <= i <= i+k <= ahi -// blo <= j <= j+k <= bhi +// +// alo <= i <= i+k <= ahi +// blo <= j <= j+k <= bhi +// // and for all (i',j',k') meeting those conditions, -// k >= k' -// i <= i' -// and if i == i', j <= j' +// +// k >= k' +// i <= i' +// and if i == i', j <= j' // // In other words, of all maximal matching blocks, return one that // starts earliest in a, and of all those maximal matching blocks that @@ -451,66 +442,6 @@ func (m *SequenceMatcher) GetGroupedOpCodes(n int) [][]OpCode { return groups } -// Return a measure of the sequences' similarity (float in [0,1]). -// -// Where T is the total number of elements in both sequences, and -// M is the number of matches, this is 2.0*M / T. -// Note that this is 1 if the sequences are identical, and 0 if -// they have nothing in common. -// -// .Ratio() is expensive to compute if you haven't already computed -// .GetMatchingBlocks() or .GetOpCodes(), in which case you may -// want to try .QuickRatio() or .RealQuickRation() first to get an -// upper bound. -func (m *SequenceMatcher) Ratio() float64 { - matches := 0 - for _, m := range m.GetMatchingBlocks() { - matches += m.Size - } - return calculateRatio(matches, len(m.a)+len(m.b)) -} - -// Return an upper bound on ratio() relatively quickly. -// -// This isn't defined beyond that it is an upper bound on .Ratio(), and -// is faster to compute. -func (m *SequenceMatcher) QuickRatio() float64 { - // viewing a and b as multisets, set matches to the cardinality - // of their intersection; this counts the number of matches - // without regard to order, so is clearly an upper bound - if m.fullBCount == nil { - m.fullBCount = map[string]int{} - for _, s := range m.b { - m.fullBCount[s] = m.fullBCount[s] + 1 - } - } - - // avail[x] is the number of times x appears in 'b' less the - // number of times we've seen it in 'a' so far ... kinda - avail := map[string]int{} - matches := 0 - for _, s := range m.a { - n, ok := avail[s] - if !ok { - n = m.fullBCount[s] - } - avail[s] = n - 1 - if n > 0 { - matches += 1 - } - } - return calculateRatio(matches, len(m.a)+len(m.b)) -} - -// Return an upper bound on ratio() very quickly. -// -// This isn't defined beyond that it is an upper bound on .Ratio(), and -// is faster to compute than either .Ratio() or .QuickRatio(). -func (m *SequenceMatcher) RealQuickRatio() float64 { - la, lb := len(m.a), len(m.b) - return calculateRatio(min(la, lb), la+lb) -} - // Convert range to the "ed" format func formatRangeUnified(start, stop int) string { // Per the diff spec at http://www.unix.org/single_unix_specification/ @@ -652,117 +583,6 @@ func formatRangeContext(start, stop int) string { return fmt.Sprintf("%d,%d", beginning, beginning+length-1) } -type ContextDiff UnifiedDiff - -// Compare two sequences of lines; generate the delta as a context diff. -// -// Context diffs are a compact way of showing line changes and a few -// lines of context. The number of context lines is set by diff.Context -// which defaults to three. -// -// By default, the diff control lines (those with *** or ---) are -// created with a trailing newline. -// -// For inputs that do not have trailing newlines, set the diff.Eol -// argument to "" so that the output will be uniformly newline free. -// -// The context diff format normally has a header for filenames and -// modification times. Any or all of these may be specified using -// strings for diff.FromFile, diff.ToFile, diff.FromDate, diff.ToDate. -// The modification times are normally expressed in the ISO 8601 format. -// If not specified, the strings default to blanks. -func WriteContextDiff(writer io.Writer, diff ContextDiff) error { - buf := bufio.NewWriter(writer) - defer buf.Flush() - var diffErr error - wf := func(format string, args ...interface{}) { - _, err := buf.WriteString(fmt.Sprintf(format, args...)) - if diffErr == nil && err != nil { - diffErr = err - } - } - ws := func(s string) { - _, err := buf.WriteString(s) - if diffErr == nil && err != nil { - diffErr = err - } - } - - if len(diff.Eol) == 0 { - diff.Eol = "\n" - } - - prefix := map[byte]string{ - 'i': "+ ", - 'd': "- ", - 'r': "! ", - 'e': " ", - } - - started := false - m := NewMatcher(diff.A, diff.B) - for _, g := range m.GetGroupedOpCodes(diff.Context) { - if !started { - started = true - fromDate := "" - if len(diff.FromDate) > 0 { - fromDate = "\t" + diff.FromDate - } - toDate := "" - if len(diff.ToDate) > 0 { - toDate = "\t" + diff.ToDate - } - if diff.FromFile != "" || diff.ToFile != "" { - wf("*** %s%s%s", diff.FromFile, fromDate, diff.Eol) - wf("--- %s%s%s", diff.ToFile, toDate, diff.Eol) - } - } - - first, last := g[0], g[len(g)-1] - ws("***************" + diff.Eol) - - range1 := formatRangeContext(first.I1, last.I2) - wf("*** %s ****%s", range1, diff.Eol) - for _, c := range g { - if c.Tag == 'r' || c.Tag == 'd' { - for _, cc := range g { - if cc.Tag == 'i' { - continue - } - for _, line := range diff.A[cc.I1:cc.I2] { - ws(prefix[cc.Tag] + line) - } - } - break - } - } - - range2 := formatRangeContext(first.J1, last.J2) - wf("--- %s ----%s", range2, diff.Eol) - for _, c := range g { - if c.Tag == 'r' || c.Tag == 'i' { - for _, cc := range g { - if cc.Tag == 'd' { - continue - } - for _, line := range diff.B[cc.J1:cc.J2] { - ws(prefix[cc.Tag] + line) - } - } - break - } - } - } - return diffErr -} - -// Like WriteContextDiff but returns the diff a string. -func GetContextDiffString(diff ContextDiff) (string, error) { - w := &bytes.Buffer{} - err := WriteContextDiff(w, diff) - return string(w.Bytes()), err -} - // Split a string on "\n" while preserving them. The output can be used // as input for UnifiedDiff and ContextDiff structures. func SplitLines(s string) []string { diff --git a/vendor/github.com/stretchr/testify/internal/spew/LICENSE b/vendor/github.com/stretchr/testify/internal/spew/LICENSE new file mode 100644 index 00000000000..bc52e96f2b0 --- /dev/null +++ b/vendor/github.com/stretchr/testify/internal/spew/LICENSE @@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2012-2016 Dave Collins + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/vendor/github.com/stretchr/testify/internal/spew/README.md b/vendor/github.com/stretchr/testify/internal/spew/README.md new file mode 100644 index 00000000000..51a909e2ef0 --- /dev/null +++ b/vendor/github.com/stretchr/testify/internal/spew/README.md @@ -0,0 +1,12 @@ +go-spew +======= + +[![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) + +Go-spew implements a deep pretty printer for Go data structures to aid in +debugging. A comprehensive suite of tests with 100% test coverage is provided +to ensure proper functionality. + +## License + +Go-spew is licensed under the [copyfree](http://copyfree.org) ISC License. diff --git a/vendor/github.com/stretchr/testify/internal/spew/bypass.go b/vendor/github.com/stretchr/testify/internal/spew/bypass.go new file mode 100644 index 00000000000..70ddeaad3e5 --- /dev/null +++ b/vendor/github.com/stretchr/testify/internal/spew/bypass.go @@ -0,0 +1,146 @@ +// Copyright (c) 2015-2016 Dave Collins +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// NOTE: Due to the following build constraints, this file will only be compiled +// when the code is not running on Google App Engine, compiled by GopherJS, and +// "-tags safe" is not added to the go build command line. The "disableunsafe" +// tag is deprecated and thus should not be used. +// Go versions prior to 1.4 are disabled because they use a different layout +// for interfaces which make the implementation of unsafeReflectValue more complex. +//go:build !js && !appengine && !safe && !disableunsafe && go1.4 +// +build !js,!appengine,!safe,!disableunsafe,go1.4 + +package spew + +import ( + "reflect" + "unsafe" +) + +const ( + // UnsafeDisabled is a build-time constant which specifies whether or + // not access to the unsafe package is available. + UnsafeDisabled = false + + // ptrSize is the size of a pointer on the current arch. + ptrSize = unsafe.Sizeof((*byte)(nil)) +) + +type flag uintptr + +var ( + // flagRO indicates whether the value field of a reflect.Value + // is read-only. + flagRO flag + + // flagAddr indicates whether the address of the reflect.Value's + // value may be taken. + flagAddr flag +) + +// flagKindMask holds the bits that make up the kind +// part of the flags field. In all the supported versions, +// it is in the lower 5 bits. +const flagKindMask = flag(0x1f) + +// Different versions of Go have used different +// bit layouts for the flags type. This table +// records the known combinations. +var okFlags = []struct { + ro, addr flag +}{{ + // From Go 1.4 to 1.5 + ro: 1 << 5, + addr: 1 << 7, +}, { + // Up to Go tip. + ro: 1<<5 | 1<<6, + addr: 1 << 8, +}} + +var flagValOffset = func() uintptr { + field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag") + if !ok { + panic("reflect.Value has no flag field") + } + return field.Offset +}() + +// flagField returns a pointer to the flag field of a reflect.Value. +func flagField(v *reflect.Value) *flag { + return (*flag)(unsafe.Pointer(uintptr(unsafe.Pointer(v)) + flagValOffset)) +} + +// unsafeReflectValue converts the passed reflect.Value into a one that bypasses +// the typical safety restrictions preventing access to unaddressable and +// unexported data. It works by digging the raw pointer to the underlying +// value out of the protected value and generating a new unprotected (unsafe) +// reflect.Value to it. +// +// This allows us to check for implementations of the Stringer and error +// interfaces to be used for pretty printing ordinarily unaddressable and +// inaccessible values such as unexported struct fields. +func unsafeReflectValue(v reflect.Value) reflect.Value { + if !v.IsValid() || (v.CanInterface() && v.CanAddr()) { + return v + } + flagFieldPtr := flagField(&v) + *flagFieldPtr &^= flagRO + *flagFieldPtr |= flagAddr + return v +} + +// Sanity checks against future reflect package changes +// to the type or semantics of the Value.flag field. +func init() { + field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag") + if !ok { + panic("reflect.Value has no flag field") + } + if field.Type.Kind() != reflect.TypeOf(flag(0)).Kind() { + panic("reflect.Value flag field has changed kind") + } + type t0 int + var t struct { + A t0 + // t0 will have flagEmbedRO set. + t0 + // a will have flagStickyRO set + a t0 + } + vA := reflect.ValueOf(t).FieldByName("A") + va := reflect.ValueOf(t).FieldByName("a") + vt0 := reflect.ValueOf(t).FieldByName("t0") + + // Infer flagRO from the difference between the flags + // for the (otherwise identical) fields in t. + flagPublic := *flagField(&vA) + flagWithRO := *flagField(&va) | *flagField(&vt0) + flagRO = flagPublic ^ flagWithRO + + // Infer flagAddr from the difference between a value + // taken from a pointer and not. + vPtrA := reflect.ValueOf(&t).Elem().FieldByName("A") + flagNoPtr := *flagField(&vA) + flagPtr := *flagField(&vPtrA) + flagAddr = flagNoPtr ^ flagPtr + + // Check that the inferred flags tally with one of the known versions. + for _, f := range okFlags { + if flagRO == f.ro && flagAddr == f.addr { + return + } + } + panic("reflect.Value read-only flag has changed semantics") +} diff --git a/vendor/github.com/stretchr/testify/internal/spew/bypasssafe.go b/vendor/github.com/stretchr/testify/internal/spew/bypasssafe.go new file mode 100644 index 00000000000..5e2d890d6ac --- /dev/null +++ b/vendor/github.com/stretchr/testify/internal/spew/bypasssafe.go @@ -0,0 +1,39 @@ +// Copyright (c) 2015-2016 Dave Collins +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// NOTE: Due to the following build constraints, this file will only be compiled +// when the code is running on Google App Engine, compiled by GopherJS, or +// "-tags safe" is added to the go build command line. The "disableunsafe" +// tag is deprecated and thus should not be used. +//go:build js || appengine || safe || disableunsafe || !go1.4 +// +build js appengine safe disableunsafe !go1.4 + +package spew + +import "reflect" + +const ( + // UnsafeDisabled is a build-time constant which specifies whether or + // not access to the unsafe package is available. + UnsafeDisabled = true +) + +// unsafeReflectValue typically converts the passed reflect.Value into a one +// that bypasses the typical safety restrictions preventing access to +// unaddressable and unexported data. However, doing this relies on access to +// the unsafe package. This is a stub version which simply returns the passed +// reflect.Value when the unsafe package is not available. +func unsafeReflectValue(v reflect.Value) reflect.Value { + return v +} diff --git a/vendor/github.com/stretchr/testify/internal/spew/common.go b/vendor/github.com/stretchr/testify/internal/spew/common.go new file mode 100644 index 00000000000..1be8ce94576 --- /dev/null +++ b/vendor/github.com/stretchr/testify/internal/spew/common.go @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew + +import ( + "bytes" + "fmt" + "io" + "reflect" + "sort" + "strconv" +) + +// Some constants in the form of bytes to avoid string overhead. This mirrors +// the technique used in the fmt package. +var ( + panicBytes = []byte("(PANIC=") + plusBytes = []byte("+") + iBytes = []byte("i") + trueBytes = []byte("true") + falseBytes = []byte("false") + interfaceBytes = []byte("(interface {})") + commaNewlineBytes = []byte(",\n") + newlineBytes = []byte("\n") + openBraceBytes = []byte("{") + openBraceNewlineBytes = []byte("{\n") + closeBraceBytes = []byte("}") + asteriskBytes = []byte("*") + colonBytes = []byte(":") + colonSpaceBytes = []byte(": ") + openParenBytes = []byte("(") + closeParenBytes = []byte(")") + spaceBytes = []byte(" ") + pointerChainBytes = []byte("->") + nilAngleBytes = []byte("") + maxNewlineBytes = []byte("\n") + maxShortBytes = []byte("") + circularBytes = []byte("") + circularShortBytes = []byte("") + invalidAngleBytes = []byte("") + openBracketBytes = []byte("[") + closeBracketBytes = []byte("]") + percentBytes = []byte("%") + precisionBytes = []byte(".") + openAngleBytes = []byte("<") + closeAngleBytes = []byte(">") + openMapBytes = []byte("map[") + closeMapBytes = []byte("]") + lenEqualsBytes = []byte("len=") + capEqualsBytes = []byte("cap=") +) + +// hexDigits is used to map a decimal value to a hex digit. +var hexDigits = "0123456789abcdef" + +// catchPanic handles any panics that might occur during the handleMethods +// calls. +func catchPanic(w io.Writer, v reflect.Value) { + if err := recover(); err != nil { + w.Write(panicBytes) + fmt.Fprintf(w, "%v", err) + w.Write(closeParenBytes) + } +} + +// handleMethods attempts to call the Error and String methods on the underlying +// type the passed reflect.Value represents and outputes the result to Writer w. +// +// It handles panics in any called methods by catching and displaying the error +// as the formatted value. +func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool) { + // We need an interface to check if the type implements the error or + // Stringer interface. However, the reflect package won't give us an + // interface on certain things like unexported struct fields in order + // to enforce visibility rules. We use unsafe, when it's available, + // to bypass these restrictions since this package does not mutate the + // values. + if !v.CanInterface() { + if UnsafeDisabled { + return false + } + + v = unsafeReflectValue(v) + } + + // Choose whether or not to do error and Stringer interface lookups against + // the base type or a pointer to the base type depending on settings. + // Technically calling one of these methods with a pointer receiver can + // mutate the value, however, types which choose to satisify an error or + // Stringer interface with a pointer receiver should not be mutating their + // state inside these interface methods. + if !cs.DisablePointerMethods && !UnsafeDisabled && !v.CanAddr() { + v = unsafeReflectValue(v) + } + if v.CanAddr() { + v = v.Addr() + } + + // Is it an error or Stringer? + switch iface := v.Interface().(type) { + case error: + defer catchPanic(w, v) + if cs.ContinueOnMethod { + w.Write(openParenBytes) + w.Write([]byte(iface.Error())) + w.Write(closeParenBytes) + w.Write(spaceBytes) + return false + } + + w.Write([]byte(iface.Error())) + return true + + case fmt.Stringer: + defer catchPanic(w, v) + if cs.ContinueOnMethod { + w.Write(openParenBytes) + w.Write([]byte(iface.String())) + w.Write(closeParenBytes) + w.Write(spaceBytes) + return false + } + w.Write([]byte(iface.String())) + return true + } + return false +} + +// printBool outputs a boolean value as true or false to Writer w. +func printBool(w io.Writer, val bool) { + if val { + w.Write(trueBytes) + } else { + w.Write(falseBytes) + } +} + +// printInt outputs a signed integer value to Writer w. +func printInt(w io.Writer, val int64, base int) { + w.Write([]byte(strconv.FormatInt(val, base))) +} + +// printUint outputs an unsigned integer value to Writer w. +func printUint(w io.Writer, val uint64, base int) { + w.Write([]byte(strconv.FormatUint(val, base))) +} + +// printFloat outputs a floating point value using the specified precision, +// which is expected to be 32 or 64bit, to Writer w. +func printFloat(w io.Writer, val float64, precision int) { + w.Write([]byte(strconv.FormatFloat(val, 'g', -1, precision))) +} + +// printComplex outputs a complex value using the specified float precision +// for the real and imaginary parts to Writer w. +func printComplex(w io.Writer, c complex128, floatPrecision int) { + r := real(c) + w.Write(openParenBytes) + w.Write([]byte(strconv.FormatFloat(r, 'g', -1, floatPrecision))) + i := imag(c) + if i >= 0 { + w.Write(plusBytes) + } + w.Write([]byte(strconv.FormatFloat(i, 'g', -1, floatPrecision))) + w.Write(iBytes) + w.Write(closeParenBytes) +} + +// printHexPtr outputs a uintptr formatted as hexadecimal with a leading '0x' +// prefix to Writer w. +func printHexPtr(w io.Writer, p uintptr) { + // Null pointer. + num := uint64(p) + if num == 0 { + w.Write(nilAngleBytes) + return + } + + // Max uint64 is 16 bytes in hex + 2 bytes for '0x' prefix + buf := make([]byte, 18) + + // It's simpler to construct the hex string right to left. + base := uint64(16) + i := len(buf) - 1 + for num >= base { + buf[i] = hexDigits[num%base] + num /= base + i-- + } + buf[i] = hexDigits[num] + + // Add '0x' prefix. + i-- + buf[i] = 'x' + i-- + buf[i] = '0' + + // Strip unused leading bytes. + buf = buf[i:] + w.Write(buf) +} + +// valuesSorter implements sort.Interface to allow a slice of reflect.Value +// elements to be sorted. +type valuesSorter struct { + values []reflect.Value + strings []string // either nil or same len and values + cs *ConfigState +} + +// newValuesSorter initializes a valuesSorter instance, which holds a set of +// surrogate keys on which the data should be sorted. It uses flags in +// ConfigState to decide if and how to populate those surrogate keys. +func newValuesSorter(values []reflect.Value, cs *ConfigState) sort.Interface { + vs := &valuesSorter{values: values, cs: cs} + if canSortSimply(vs.values[0].Kind()) { + return vs + } + if !cs.DisableMethods { + vs.strings = make([]string, len(values)) + for i := range vs.values { + b := bytes.Buffer{} + if !handleMethods(cs, &b, vs.values[i]) { + vs.strings = nil + break + } + vs.strings[i] = b.String() + } + } + if vs.strings == nil && cs.SpewKeys { + vs.strings = make([]string, len(values)) + for i := range vs.values { + vs.strings[i] = Sprintf("%#v", vs.values[i].Interface()) + } + } + return vs +} + +// canSortSimply tests whether a reflect.Kind is a primitive that can be sorted +// directly, or whether it should be considered for sorting by surrogate keys +// (if the ConfigState allows it). +func canSortSimply(kind reflect.Kind) bool { + // This switch parallels valueSortLess, except for the default case. + switch kind { + case reflect.Bool: + return true + case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: + return true + case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: + return true + case reflect.Float32, reflect.Float64: + return true + case reflect.String: + return true + case reflect.Uintptr: + return true + case reflect.Array: + return true + } + return false +} + +// Len returns the number of values in the slice. It is part of the +// sort.Interface implementation. +func (s *valuesSorter) Len() int { + return len(s.values) +} + +// Swap swaps the values at the passed indices. It is part of the +// sort.Interface implementation. +func (s *valuesSorter) Swap(i, j int) { + s.values[i], s.values[j] = s.values[j], s.values[i] + if s.strings != nil { + s.strings[i], s.strings[j] = s.strings[j], s.strings[i] + } +} + +// valueSortLess returns whether the first value should sort before the second +// value. It is used by valueSorter.Less as part of the sort.Interface +// implementation. +func valueSortLess(a, b reflect.Value) bool { + switch a.Kind() { + case reflect.Bool: + return !a.Bool() && b.Bool() + case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: + return a.Int() < b.Int() + case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: + return a.Uint() < b.Uint() + case reflect.Float32, reflect.Float64: + return a.Float() < b.Float() + case reflect.String: + return a.String() < b.String() + case reflect.Uintptr: + return a.Uint() < b.Uint() + case reflect.Array: + // Compare the contents of both arrays. + l := a.Len() + for i := 0; i < l; i++ { + av := a.Index(i) + bv := b.Index(i) + if av.Interface() == bv.Interface() { + continue + } + return valueSortLess(av, bv) + } + } + return a.String() < b.String() +} + +// Less returns whether the value at index i should sort before the +// value at index j. It is part of the sort.Interface implementation. +func (s *valuesSorter) Less(i, j int) bool { + if s.strings == nil { + return valueSortLess(s.values[i], s.values[j]) + } + return s.strings[i] < s.strings[j] +} + +// sortValues is a sort function that handles both native types and any type that +// can be converted to error or Stringer. Other inputs are sorted according to +// their Value.String() value to ensure display stability. +func sortValues(values []reflect.Value, cs *ConfigState) { + if len(values) == 0 { + return + } + sort.Sort(newValuesSorter(values, cs)) +} diff --git a/vendor/github.com/stretchr/testify/internal/spew/config.go b/vendor/github.com/stretchr/testify/internal/spew/config.go new file mode 100644 index 00000000000..161895fc6db --- /dev/null +++ b/vendor/github.com/stretchr/testify/internal/spew/config.go @@ -0,0 +1,306 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew + +import ( + "bytes" + "fmt" + "io" + "os" +) + +// ConfigState houses the configuration options used by spew to format and +// display values. There is a global instance, Config, that is used to control +// all top-level Formatter and Dump functionality. Each ConfigState instance +// provides methods equivalent to the top-level functions. +// +// The zero value for ConfigState provides no indentation. You would typically +// want to set it to a space or a tab. +// +// Alternatively, you can use NewDefaultConfig to get a ConfigState instance +// with default settings. See the documentation of NewDefaultConfig for default +// values. +type ConfigState struct { + // Indent specifies the string to use for each indentation level. The + // global config instance that all top-level functions use set this to a + // single space by default. If you would like more indentation, you might + // set this to a tab with "\t" or perhaps two spaces with " ". + Indent string + + // MaxDepth controls the maximum number of levels to descend into nested + // data structures. The default, 0, means there is no limit. + // + // NOTE: Circular data structures are properly detected, so it is not + // necessary to set this value unless you specifically want to limit deeply + // nested data structures. + MaxDepth int + + // DisableMethods specifies whether or not error and Stringer interfaces are + // invoked for types that implement them. + DisableMethods bool + + // DisablePointerMethods specifies whether or not to check for and invoke + // error and Stringer interfaces on types which only accept a pointer + // receiver when the current type is not a pointer. + // + // NOTE: This might be an unsafe action since calling one of these methods + // with a pointer receiver could technically mutate the value, however, + // in practice, types which choose to satisify an error or Stringer + // interface with a pointer receiver should not be mutating their state + // inside these interface methods. As a result, this option relies on + // access to the unsafe package, so it will not have any effect when + // running in environments without access to the unsafe package such as + // Google App Engine or with the "safe" build tag specified. + DisablePointerMethods bool + + // DisablePointerAddresses specifies whether to disable the printing of + // pointer addresses. This is useful when diffing data structures in tests. + DisablePointerAddresses bool + + // DisableCapacities specifies whether to disable the printing of capacities + // for arrays, slices, maps and channels. This is useful when diffing + // data structures in tests. + DisableCapacities bool + + // ContinueOnMethod specifies whether or not recursion should continue once + // a custom error or Stringer interface is invoked. The default, false, + // means it will print the results of invoking the custom error or Stringer + // interface and return immediately instead of continuing to recurse into + // the internals of the data type. + // + // NOTE: This flag does not have any effect if method invocation is disabled + // via the DisableMethods or DisablePointerMethods options. + ContinueOnMethod bool + + // SortKeys specifies map keys should be sorted before being printed. Use + // this to have a more deterministic, diffable output. Note that only + // native types (bool, int, uint, floats, uintptr and string) and types + // that support the error or Stringer interfaces (if methods are + // enabled) are supported, with other types sorted according to the + // reflect.Value.String() output which guarantees display stability. + SortKeys bool + + // SpewKeys specifies that, as a last resort attempt, map keys should + // be spewed to strings and sorted by those strings. This is only + // considered if SortKeys is true. + SpewKeys bool +} + +// Config is the active configuration of the top-level functions. +// The configuration can be changed by modifying the contents of spew.Config. +var Config = ConfigState{Indent: " "} + +// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the formatted string as a value that satisfies error. See NewFormatter +// for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Errorf(format, c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Errorf(format string, a ...interface{}) (err error) { + return fmt.Errorf(format, c.convertArgs(a)...) +} + +// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Fprint(w, c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Fprint(w io.Writer, a ...interface{}) (n int, err error) { + return fmt.Fprint(w, c.convertArgs(a)...) +} + +// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Fprintf(w, format, c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) { + return fmt.Fprintf(w, format, c.convertArgs(a)...) +} + +// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it +// passed with a Formatter interface returned by c.NewFormatter. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Fprintln(w, c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Fprintln(w io.Writer, a ...interface{}) (n int, err error) { + return fmt.Fprintln(w, c.convertArgs(a)...) +} + +// Print is a wrapper for fmt.Print that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Print(c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Print(a ...interface{}) (n int, err error) { + return fmt.Print(c.convertArgs(a)...) +} + +// Printf is a wrapper for fmt.Printf that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Printf(format, c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Printf(format string, a ...interface{}) (n int, err error) { + return fmt.Printf(format, c.convertArgs(a)...) +} + +// Println is a wrapper for fmt.Println that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Println(c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Println(a ...interface{}) (n int, err error) { + return fmt.Println(c.convertArgs(a)...) +} + +// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the resulting string. See NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Sprint(c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Sprint(a ...interface{}) string { + return fmt.Sprint(c.convertArgs(a)...) +} + +// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the resulting string. See NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Sprintf(format, c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Sprintf(format string, a ...interface{}) string { + return fmt.Sprintf(format, c.convertArgs(a)...) +} + +// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it +// were passed with a Formatter interface returned by c.NewFormatter. It +// returns the resulting string. See NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Sprintln(c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Sprintln(a ...interface{}) string { + return fmt.Sprintln(c.convertArgs(a)...) +} + +/* +NewFormatter returns a custom formatter that satisfies the fmt.Formatter +interface. As a result, it integrates cleanly with standard fmt package +printing functions. The formatter is useful for inline printing of smaller data +types similar to the standard %v format specifier. + +The custom formatter only responds to the %v (most compact), %+v (adds pointer +addresses), %#v (adds types), and %#+v (adds types and pointer addresses) verb +combinations. Any other verbs such as %x and %q will be sent to the the +standard fmt package for formatting. In addition, the custom formatter ignores +the width and precision arguments (however they will still work on the format +specifiers not handled by the custom formatter). + +Typically this function shouldn't be called directly. It is much easier to make +use of the custom formatter by calling one of the convenience functions such as +c.Printf, c.Println, or c.Printf. +*/ +func (c *ConfigState) NewFormatter(v interface{}) fmt.Formatter { + return newFormatter(c, v) +} + +// Fdump formats and displays the passed arguments to io.Writer w. It formats +// exactly the same as Dump. +func (c *ConfigState) Fdump(w io.Writer, a ...interface{}) { + fdump(c, w, a...) +} + +/* +Dump displays the passed parameters to standard out with newlines, customizable +indentation, and additional debug information such as complete types and all +pointer addresses used to indirect to the final value. It provides the +following features over the built-in printing facilities provided by the fmt +package: + + - Pointers are dereferenced and followed + - Circular data structures are detected and handled properly + - Custom Stringer/error interfaces are optionally invoked, including + on unexported types + - Custom types which only implement the Stringer/error interfaces via + a pointer receiver are optionally invoked when passing non-pointer + variables + - Byte arrays and slices are dumped like the hexdump -C command which + includes offsets, byte values in hex, and ASCII output + +The configuration options are controlled by modifying the public members +of c. See ConfigState for options documentation. + +See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to +get the formatted result as a string. +*/ +func (c *ConfigState) Dump(a ...interface{}) { + fdump(c, os.Stdout, a...) +} + +// Sdump returns a string with the passed arguments formatted exactly the same +// as Dump. +func (c *ConfigState) Sdump(a ...interface{}) string { + var buf bytes.Buffer + fdump(c, &buf, a...) + return buf.String() +} + +// convertArgs accepts a slice of arguments and returns a slice of the same +// length with each argument converted to a spew Formatter interface using +// the ConfigState associated with s. +func (c *ConfigState) convertArgs(args []interface{}) (formatters []interface{}) { + formatters = make([]interface{}, len(args)) + for index, arg := range args { + formatters[index] = newFormatter(c, arg) + } + return formatters +} + +// NewDefaultConfig returns a ConfigState with the following default settings. +// +// Indent: " " +// MaxDepth: 0 +// DisableMethods: false +// DisablePointerMethods: false +// ContinueOnMethod: false +// SortKeys: false +func NewDefaultConfig() *ConfigState { + return &ConfigState{Indent: " "} +} diff --git a/vendor/github.com/stretchr/testify/internal/spew/doc.go b/vendor/github.com/stretchr/testify/internal/spew/doc.go new file mode 100644 index 00000000000..722e9aa7912 --- /dev/null +++ b/vendor/github.com/stretchr/testify/internal/spew/doc.go @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* +Package spew implements a deep pretty printer for Go data structures to aid in +debugging. + +A quick overview of the additional features spew provides over the built-in +printing facilities for Go data types are as follows: + + - Pointers are dereferenced and followed + - Circular data structures are detected and handled properly + - Custom Stringer/error interfaces are optionally invoked, including + on unexported types + - Custom types which only implement the Stringer/error interfaces via + a pointer receiver are optionally invoked when passing non-pointer + variables + - Byte arrays and slices are dumped like the hexdump -C command which + includes offsets, byte values in hex, and ASCII output (only when using + Dump style) + +There are two different approaches spew allows for dumping Go data structures: + + - Dump style which prints with newlines, customizable indentation, + and additional debug information such as types and all pointer addresses + used to indirect to the final value + - A custom Formatter interface that integrates cleanly with the standard fmt + package and replaces %v, %+v, %#v, and %#+v to provide inline printing + similar to the default %v while providing the additional functionality + outlined above and passing unsupported format verbs such as %x and %q + along to fmt + +# Quick Start + +This section demonstrates how to quickly get started with spew. See the +sections below for further details on formatting and configuration options. + +To dump a variable with full newlines, indentation, type, and pointer +information use Dump, Fdump, or Sdump: + + spew.Dump(myVar1, myVar2, ...) + spew.Fdump(someWriter, myVar1, myVar2, ...) + str := spew.Sdump(myVar1, myVar2, ...) + +Alternatively, if you would prefer to use format strings with a compacted inline +printing style, use the convenience wrappers Printf, Fprintf, etc with +%v (most compact), %+v (adds pointer addresses), %#v (adds types), or +%#+v (adds types and pointer addresses): + + spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2) + spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) + spew.Fprintf(someWriter, "myVar1: %v -- myVar2: %+v", myVar1, myVar2) + spew.Fprintf(someWriter, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) + +# Configuration Options + +Configuration of spew is handled by fields in the ConfigState type. For +convenience, all of the top-level functions use a global state available +via the spew.Config global. + +It is also possible to create a ConfigState instance that provides methods +equivalent to the top-level functions. This allows concurrent configuration +options. See the ConfigState documentation for more details. + +The following configuration options are available: + + - Indent + String to use for each indentation level for Dump functions. + It is a single space by default. A popular alternative is "\t". + + - MaxDepth + Maximum number of levels to descend into nested data structures. + There is no limit by default. + + - DisableMethods + Disables invocation of error and Stringer interface methods. + Method invocation is enabled by default. + + - DisablePointerMethods + Disables invocation of error and Stringer interface methods on types + which only accept pointer receivers from non-pointer variables. + Pointer method invocation is enabled by default. + + - DisablePointerAddresses + DisablePointerAddresses specifies whether to disable the printing of + pointer addresses. This is useful when diffing data structures in tests. + + - DisableCapacities + DisableCapacities specifies whether to disable the printing of + capacities for arrays, slices, maps and channels. This is useful when + diffing data structures in tests. + + - ContinueOnMethod + Enables recursion into types after invoking error and Stringer interface + methods. Recursion after method invocation is disabled by default. + + - SortKeys + Specifies map keys should be sorted before being printed. Use + this to have a more deterministic, diffable output. Note that + only native types (bool, int, uint, floats, uintptr and string) + and types which implement error or Stringer interfaces are + supported with other types sorted according to the + reflect.Value.String() output which guarantees display + stability. Natural map order is used by default. + + - SpewKeys + Specifies that, as a last resort attempt, map keys should be + spewed to strings and sorted by those strings. This is only + considered if SortKeys is true. + +# Dump Usage + +Simply call spew.Dump with a list of variables you want to dump: + + spew.Dump(myVar1, myVar2, ...) + +You may also call spew.Fdump if you would prefer to output to an arbitrary +io.Writer. For example, to dump to standard error: + + spew.Fdump(os.Stderr, myVar1, myVar2, ...) + +A third option is to call spew.Sdump to get the formatted output as a string: + + str := spew.Sdump(myVar1, myVar2, ...) + +# Sample Dump Output + +See the Dump example for details on the setup of the types and variables being +shown here. + + (main.Foo) { + unexportedField: (*main.Bar)(0xf84002e210)({ + flag: (main.Flag) flagTwo, + data: (uintptr) + }), + ExportedField: (map[interface {}]interface {}) (len=1) { + (string) (len=3) "one": (bool) true + } + } + +Byte (and uint8) arrays and slices are displayed uniquely like the hexdump -C +command as shown. + + ([]uint8) (len=32 cap=32) { + 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... | + 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0| + 00000020 31 32 |12| + } + +# Custom Formatter + +Spew provides a custom formatter that implements the fmt.Formatter interface +so that it integrates cleanly with standard fmt package printing functions. The +formatter is useful for inline printing of smaller data types similar to the +standard %v format specifier. + +The custom formatter only responds to the %v (most compact), %+v (adds pointer +addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb +combinations. Any other verbs such as %x and %q will be sent to the the +standard fmt package for formatting. In addition, the custom formatter ignores +the width and precision arguments (however they will still work on the format +specifiers not handled by the custom formatter). + +# Custom Formatter Usage + +The simplest way to make use of the spew custom formatter is to call one of the +convenience functions such as spew.Printf, spew.Println, or spew.Printf. The +functions have syntax you are most likely already familiar with: + + spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2) + spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) + spew.Println(myVar, myVar2) + spew.Fprintf(os.Stderr, "myVar1: %v -- myVar2: %+v", myVar1, myVar2) + spew.Fprintf(os.Stderr, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) + +See the Index for the full list convenience functions. + +# Sample Formatter Output + +Double pointer to a uint8: + + %v: <**>5 + %+v: <**>(0xf8400420d0->0xf8400420c8)5 + %#v: (**uint8)5 + %#+v: (**uint8)(0xf8400420d0->0xf8400420c8)5 + +Pointer to circular struct with a uint8 field and a pointer to itself: + + %v: <*>{1 <*>} + %+v: <*>(0xf84003e260){ui8:1 c:<*>(0xf84003e260)} + %#v: (*main.circular){ui8:(uint8)1 c:(*main.circular)} + %#+v: (*main.circular)(0xf84003e260){ui8:(uint8)1 c:(*main.circular)(0xf84003e260)} + +See the Printf example for details on the setup of variables being shown +here. + +# Errors + +Since it is possible for custom Stringer/error interfaces to panic, spew +detects them and handles them internally by printing the panic information +inline with the output. Since spew is intended to provide deep pretty printing +capabilities on structures, it intentionally does not return any errors. +*/ +package spew diff --git a/vendor/github.com/stretchr/testify/internal/spew/dump.go b/vendor/github.com/stretchr/testify/internal/spew/dump.go new file mode 100644 index 00000000000..8323041a481 --- /dev/null +++ b/vendor/github.com/stretchr/testify/internal/spew/dump.go @@ -0,0 +1,509 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew + +import ( + "bytes" + "encoding/hex" + "fmt" + "io" + "os" + "reflect" + "regexp" + "strconv" + "strings" +) + +var ( + // uint8Type is a reflect.Type representing a uint8. It is used to + // convert cgo types to uint8 slices for hexdumping. + uint8Type = reflect.TypeOf(uint8(0)) + + // cCharRE is a regular expression that matches a cgo char. + // It is used to detect character arrays to hexdump them. + cCharRE = regexp.MustCompile(`^.*\._Ctype_char$`) + + // cUnsignedCharRE is a regular expression that matches a cgo unsigned + // char. It is used to detect unsigned character arrays to hexdump + // them. + cUnsignedCharRE = regexp.MustCompile(`^.*\._Ctype_unsignedchar$`) + + // cUint8tCharRE is a regular expression that matches a cgo uint8_t. + // It is used to detect uint8_t arrays to hexdump them. + cUint8tCharRE = regexp.MustCompile(`^.*\._Ctype_uint8_t$`) +) + +// dumpState contains information about the state of a dump operation. +type dumpState struct { + w io.Writer + depth int + pointers map[uintptr]int + ignoreNextType bool + ignoreNextIndent bool + cs *ConfigState +} + +// indent performs indentation according to the depth level and cs.Indent +// option. +func (d *dumpState) indent() { + if d.ignoreNextIndent { + d.ignoreNextIndent = false + return + } + d.w.Write(bytes.Repeat([]byte(d.cs.Indent), d.depth)) +} + +// unpackValue returns values inside of non-nil interfaces when possible. +// This is useful for data types like structs, arrays, slices, and maps which +// can contain varying types packed inside an interface. +func (d *dumpState) unpackValue(v reflect.Value) reflect.Value { + if v.Kind() == reflect.Interface && !v.IsNil() { + v = v.Elem() + } + return v +} + +// dumpPtr handles formatting of pointers by indirecting them as necessary. +func (d *dumpState) dumpPtr(v reflect.Value) { + // Remove pointers at or below the current depth from map used to detect + // circular refs. + for k, depth := range d.pointers { + if depth >= d.depth { + delete(d.pointers, k) + } + } + + // Keep list of all dereferenced pointers to show later. + pointerChain := make([]uintptr, 0) + + // Figure out how many levels of indirection there are by dereferencing + // pointers and unpacking interfaces down the chain while detecting circular + // references. + nilFound := false + cycleFound := false + indirects := 0 + ve := v + for ve.Kind() == reflect.Ptr { + if ve.IsNil() { + nilFound = true + break + } + indirects++ + addr := ve.Pointer() + pointerChain = append(pointerChain, addr) + if pd, ok := d.pointers[addr]; ok && pd < d.depth { + cycleFound = true + indirects-- + break + } + d.pointers[addr] = d.depth + + ve = ve.Elem() + if ve.Kind() == reflect.Interface { + if ve.IsNil() { + nilFound = true + break + } + ve = ve.Elem() + } + } + + // Display type information. + d.w.Write(openParenBytes) + d.w.Write(bytes.Repeat(asteriskBytes, indirects)) + d.w.Write([]byte(ve.Type().String())) + d.w.Write(closeParenBytes) + + // Display pointer information. + if !d.cs.DisablePointerAddresses && len(pointerChain) > 0 { + d.w.Write(openParenBytes) + for i, addr := range pointerChain { + if i > 0 { + d.w.Write(pointerChainBytes) + } + printHexPtr(d.w, addr) + } + d.w.Write(closeParenBytes) + } + + // Display dereferenced value. + d.w.Write(openParenBytes) + switch { + case nilFound: + d.w.Write(nilAngleBytes) + + case cycleFound: + d.w.Write(circularBytes) + + default: + d.ignoreNextType = true + d.dump(ve) + } + d.w.Write(closeParenBytes) +} + +// dumpSlice handles formatting of arrays and slices. Byte (uint8 under +// reflection) arrays and slices are dumped in hexdump -C fashion. +func (d *dumpState) dumpSlice(v reflect.Value) { + // Determine whether this type should be hex dumped or not. Also, + // for types which should be hexdumped, try to use the underlying data + // first, then fall back to trying to convert them to a uint8 slice. + var buf []uint8 + doConvert := false + doHexDump := false + numEntries := v.Len() + if numEntries > 0 { + vt := v.Index(0).Type() + vts := vt.String() + switch { + // C types that need to be converted. + case cCharRE.MatchString(vts): + fallthrough + case cUnsignedCharRE.MatchString(vts): + fallthrough + case cUint8tCharRE.MatchString(vts): + doConvert = true + + // Try to use existing uint8 slices and fall back to converting + // and copying if that fails. + case vt.Kind() == reflect.Uint8: + // We need an addressable interface to convert the type + // to a byte slice. However, the reflect package won't + // give us an interface on certain things like + // unexported struct fields in order to enforce + // visibility rules. We use unsafe, when available, to + // bypass these restrictions since this package does not + // mutate the values. + vs := v + if !vs.CanInterface() || !vs.CanAddr() { + vs = unsafeReflectValue(vs) + } + if !UnsafeDisabled { + vs = vs.Slice(0, numEntries) + + // Use the existing uint8 slice if it can be + // type asserted. + iface := vs.Interface() + if slice, ok := iface.([]uint8); ok { + buf = slice + doHexDump = true + break + } + } + + // The underlying data needs to be converted if it can't + // be type asserted to a uint8 slice. + doConvert = true + } + + // Copy and convert the underlying type if needed. + if doConvert && vt.ConvertibleTo(uint8Type) { + // Convert and copy each element into a uint8 byte + // slice. + buf = make([]uint8, numEntries) + for i := 0; i < numEntries; i++ { + vv := v.Index(i) + buf[i] = uint8(vv.Convert(uint8Type).Uint()) + } + doHexDump = true + } + } + + // Hexdump the entire slice as needed. + if doHexDump { + indent := strings.Repeat(d.cs.Indent, d.depth) + str := indent + hex.Dump(buf) + str = strings.Replace(str, "\n", "\n"+indent, -1) + str = strings.TrimRight(str, d.cs.Indent) + d.w.Write([]byte(str)) + return + } + + // Recursively call dump for each item. + for i := 0; i < numEntries; i++ { + d.dump(d.unpackValue(v.Index(i))) + if i < (numEntries - 1) { + d.w.Write(commaNewlineBytes) + } else { + d.w.Write(newlineBytes) + } + } +} + +// dump is the main workhorse for dumping a value. It uses the passed reflect +// value to figure out what kind of object we are dealing with and formats it +// appropriately. It is a recursive function, however circular data structures +// are detected and handled properly. +func (d *dumpState) dump(v reflect.Value) { + // Handle invalid reflect values immediately. + kind := v.Kind() + if kind == reflect.Invalid { + d.w.Write(invalidAngleBytes) + return + } + + // Handle pointers specially. + if kind == reflect.Ptr { + d.indent() + d.dumpPtr(v) + return + } + + // Print type information unless already handled elsewhere. + if !d.ignoreNextType { + d.indent() + d.w.Write(openParenBytes) + d.w.Write([]byte(v.Type().String())) + d.w.Write(closeParenBytes) + d.w.Write(spaceBytes) + } + d.ignoreNextType = false + + // Display length and capacity if the built-in len and cap functions + // work with the value's kind and the len/cap itself is non-zero. + valueLen, valueCap := 0, 0 + switch v.Kind() { + case reflect.Array, reflect.Slice, reflect.Chan: + valueLen, valueCap = v.Len(), v.Cap() + case reflect.Map, reflect.String: + valueLen = v.Len() + } + if valueLen != 0 || !d.cs.DisableCapacities && valueCap != 0 { + d.w.Write(openParenBytes) + if valueLen != 0 { + d.w.Write(lenEqualsBytes) + printInt(d.w, int64(valueLen), 10) + } + if !d.cs.DisableCapacities && valueCap != 0 { + if valueLen != 0 { + d.w.Write(spaceBytes) + } + d.w.Write(capEqualsBytes) + printInt(d.w, int64(valueCap), 10) + } + d.w.Write(closeParenBytes) + d.w.Write(spaceBytes) + } + + // Call Stringer/error interfaces if they exist and the handle methods flag + // is enabled + if !d.cs.DisableMethods { + if (kind != reflect.Invalid) && (kind != reflect.Interface) { + if handled := handleMethods(d.cs, d.w, v); handled { + return + } + } + } + + switch kind { + case reflect.Invalid: + // Do nothing. We should never get here since invalid has already + // been handled above. + + case reflect.Bool: + printBool(d.w, v.Bool()) + + case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: + printInt(d.w, v.Int(), 10) + + case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: + printUint(d.w, v.Uint(), 10) + + case reflect.Float32: + printFloat(d.w, v.Float(), 32) + + case reflect.Float64: + printFloat(d.w, v.Float(), 64) + + case reflect.Complex64: + printComplex(d.w, v.Complex(), 32) + + case reflect.Complex128: + printComplex(d.w, v.Complex(), 64) + + case reflect.Slice: + if v.IsNil() { + d.w.Write(nilAngleBytes) + break + } + fallthrough + + case reflect.Array: + d.w.Write(openBraceNewlineBytes) + d.depth++ + if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) { + d.indent() + d.w.Write(maxNewlineBytes) + } else { + d.dumpSlice(v) + } + d.depth-- + d.indent() + d.w.Write(closeBraceBytes) + + case reflect.String: + d.w.Write([]byte(strconv.Quote(v.String()))) + + case reflect.Interface: + // The only time we should get here is for nil interfaces due to + // unpackValue calls. + if v.IsNil() { + d.w.Write(nilAngleBytes) + } + + case reflect.Ptr: + // Do nothing. We should never get here since pointers have already + // been handled above. + + case reflect.Map: + // nil maps should be indicated as different than empty maps + if v.IsNil() { + d.w.Write(nilAngleBytes) + break + } + + d.w.Write(openBraceNewlineBytes) + d.depth++ + if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) { + d.indent() + d.w.Write(maxNewlineBytes) + } else { + numEntries := v.Len() + keys := v.MapKeys() + if d.cs.SortKeys { + sortValues(keys, d.cs) + } + for i, key := range keys { + d.dump(d.unpackValue(key)) + d.w.Write(colonSpaceBytes) + d.ignoreNextIndent = true + d.dump(d.unpackValue(v.MapIndex(key))) + if i < (numEntries - 1) { + d.w.Write(commaNewlineBytes) + } else { + d.w.Write(newlineBytes) + } + } + } + d.depth-- + d.indent() + d.w.Write(closeBraceBytes) + + case reflect.Struct: + d.w.Write(openBraceNewlineBytes) + d.depth++ + if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) { + d.indent() + d.w.Write(maxNewlineBytes) + } else { + vt := v.Type() + numFields := v.NumField() + for i := 0; i < numFields; i++ { + d.indent() + vtf := vt.Field(i) + d.w.Write([]byte(vtf.Name)) + d.w.Write(colonSpaceBytes) + d.ignoreNextIndent = true + d.dump(d.unpackValue(v.Field(i))) + if i < (numFields - 1) { + d.w.Write(commaNewlineBytes) + } else { + d.w.Write(newlineBytes) + } + } + } + d.depth-- + d.indent() + d.w.Write(closeBraceBytes) + + case reflect.Uintptr: + printHexPtr(d.w, uintptr(v.Uint())) + + case reflect.UnsafePointer, reflect.Chan, reflect.Func: + printHexPtr(d.w, v.Pointer()) + + // There were not any other types at the time this code was written, but + // fall back to letting the default fmt package handle it in case any new + // types are added. + default: + if v.CanInterface() { + fmt.Fprintf(d.w, "%v", v.Interface()) + } else { + fmt.Fprintf(d.w, "%v", v.String()) + } + } +} + +// fdump is a helper function to consolidate the logic from the various public +// methods which take varying writers and config states. +func fdump(cs *ConfigState, w io.Writer, a ...interface{}) { + for _, arg := range a { + if arg == nil { + w.Write(interfaceBytes) + w.Write(spaceBytes) + w.Write(nilAngleBytes) + w.Write(newlineBytes) + continue + } + + d := dumpState{w: w, cs: cs} + d.pointers = make(map[uintptr]int) + d.dump(reflect.ValueOf(arg)) + d.w.Write(newlineBytes) + } +} + +// Fdump formats and displays the passed arguments to io.Writer w. It formats +// exactly the same as Dump. +func Fdump(w io.Writer, a ...interface{}) { + fdump(&Config, w, a...) +} + +// Sdump returns a string with the passed arguments formatted exactly the same +// as Dump. +func Sdump(a ...interface{}) string { + var buf bytes.Buffer + fdump(&Config, &buf, a...) + return buf.String() +} + +/* +Dump displays the passed parameters to standard out with newlines, customizable +indentation, and additional debug information such as complete types and all +pointer addresses used to indirect to the final value. It provides the +following features over the built-in printing facilities provided by the fmt +package: + + - Pointers are dereferenced and followed + - Circular data structures are detected and handled properly + - Custom Stringer/error interfaces are optionally invoked, including + on unexported types + - Custom types which only implement the Stringer/error interfaces via + a pointer receiver are optionally invoked when passing non-pointer + variables + - Byte arrays and slices are dumped like the hexdump -C command which + includes offsets, byte values in hex, and ASCII output + +The configuration options are controlled by an exported package global, +spew.Config. See ConfigState for options documentation. + +See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to +get the formatted result as a string. +*/ +func Dump(a ...interface{}) { + fdump(&Config, os.Stdout, a...) +} diff --git a/vendor/github.com/stretchr/testify/internal/spew/format.go b/vendor/github.com/stretchr/testify/internal/spew/format.go new file mode 100644 index 00000000000..b04edb7d7ac --- /dev/null +++ b/vendor/github.com/stretchr/testify/internal/spew/format.go @@ -0,0 +1,419 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew + +import ( + "bytes" + "fmt" + "reflect" + "strconv" + "strings" +) + +// supportedFlags is a list of all the character flags supported by fmt package. +const supportedFlags = "0-+# " + +// formatState implements the fmt.Formatter interface and contains information +// about the state of a formatting operation. The NewFormatter function can +// be used to get a new Formatter which can be used directly as arguments +// in standard fmt package printing calls. +type formatState struct { + value interface{} + fs fmt.State + depth int + pointers map[uintptr]int + ignoreNextType bool + cs *ConfigState +} + +// buildDefaultFormat recreates the original format string without precision +// and width information to pass in to fmt.Sprintf in the case of an +// unrecognized type. Unless new types are added to the language, this +// function won't ever be called. +func (f *formatState) buildDefaultFormat() (format string) { + buf := bytes.NewBuffer(percentBytes) + + for _, flag := range supportedFlags { + if f.fs.Flag(int(flag)) { + buf.WriteRune(flag) + } + } + + buf.WriteRune('v') + + format = buf.String() + return format +} + +// constructOrigFormat recreates the original format string including precision +// and width information to pass along to the standard fmt package. This allows +// automatic deferral of all format strings this package doesn't support. +func (f *formatState) constructOrigFormat(verb rune) (format string) { + buf := bytes.NewBuffer(percentBytes) + + for _, flag := range supportedFlags { + if f.fs.Flag(int(flag)) { + buf.WriteRune(flag) + } + } + + if width, ok := f.fs.Width(); ok { + buf.WriteString(strconv.Itoa(width)) + } + + if precision, ok := f.fs.Precision(); ok { + buf.Write(precisionBytes) + buf.WriteString(strconv.Itoa(precision)) + } + + buf.WriteRune(verb) + + format = buf.String() + return format +} + +// unpackValue returns values inside of non-nil interfaces when possible and +// ensures that types for values which have been unpacked from an interface +// are displayed when the show types flag is also set. +// This is useful for data types like structs, arrays, slices, and maps which +// can contain varying types packed inside an interface. +func (f *formatState) unpackValue(v reflect.Value) reflect.Value { + if v.Kind() == reflect.Interface { + f.ignoreNextType = false + if !v.IsNil() { + v = v.Elem() + } + } + return v +} + +// formatPtr handles formatting of pointers by indirecting them as necessary. +func (f *formatState) formatPtr(v reflect.Value) { + // Display nil if top level pointer is nil. + showTypes := f.fs.Flag('#') + if v.IsNil() && (!showTypes || f.ignoreNextType) { + f.fs.Write(nilAngleBytes) + return + } + + // Remove pointers at or below the current depth from map used to detect + // circular refs. + for k, depth := range f.pointers { + if depth >= f.depth { + delete(f.pointers, k) + } + } + + // Keep list of all dereferenced pointers to possibly show later. + pointerChain := make([]uintptr, 0) + + // Figure out how many levels of indirection there are by derferencing + // pointers and unpacking interfaces down the chain while detecting circular + // references. + nilFound := false + cycleFound := false + indirects := 0 + ve := v + for ve.Kind() == reflect.Ptr { + if ve.IsNil() { + nilFound = true + break + } + indirects++ + addr := ve.Pointer() + pointerChain = append(pointerChain, addr) + if pd, ok := f.pointers[addr]; ok && pd < f.depth { + cycleFound = true + indirects-- + break + } + f.pointers[addr] = f.depth + + ve = ve.Elem() + if ve.Kind() == reflect.Interface { + if ve.IsNil() { + nilFound = true + break + } + ve = ve.Elem() + } + } + + // Display type or indirection level depending on flags. + if showTypes && !f.ignoreNextType { + f.fs.Write(openParenBytes) + f.fs.Write(bytes.Repeat(asteriskBytes, indirects)) + f.fs.Write([]byte(ve.Type().String())) + f.fs.Write(closeParenBytes) + } else { + if nilFound || cycleFound { + indirects += strings.Count(ve.Type().String(), "*") + } + f.fs.Write(openAngleBytes) + f.fs.Write([]byte(strings.Repeat("*", indirects))) + f.fs.Write(closeAngleBytes) + } + + // Display pointer information depending on flags. + if f.fs.Flag('+') && (len(pointerChain) > 0) { + f.fs.Write(openParenBytes) + for i, addr := range pointerChain { + if i > 0 { + f.fs.Write(pointerChainBytes) + } + printHexPtr(f.fs, addr) + } + f.fs.Write(closeParenBytes) + } + + // Display dereferenced value. + switch { + case nilFound: + f.fs.Write(nilAngleBytes) + + case cycleFound: + f.fs.Write(circularShortBytes) + + default: + f.ignoreNextType = true + f.format(ve) + } +} + +// format is the main workhorse for providing the Formatter interface. It +// uses the passed reflect value to figure out what kind of object we are +// dealing with and formats it appropriately. It is a recursive function, +// however circular data structures are detected and handled properly. +func (f *formatState) format(v reflect.Value) { + // Handle invalid reflect values immediately. + kind := v.Kind() + if kind == reflect.Invalid { + f.fs.Write(invalidAngleBytes) + return + } + + // Handle pointers specially. + if kind == reflect.Ptr { + f.formatPtr(v) + return + } + + // Print type information unless already handled elsewhere. + if !f.ignoreNextType && f.fs.Flag('#') { + f.fs.Write(openParenBytes) + f.fs.Write([]byte(v.Type().String())) + f.fs.Write(closeParenBytes) + } + f.ignoreNextType = false + + // Call Stringer/error interfaces if they exist and the handle methods + // flag is enabled. + if !f.cs.DisableMethods { + if (kind != reflect.Invalid) && (kind != reflect.Interface) { + if handled := handleMethods(f.cs, f.fs, v); handled { + return + } + } + } + + switch kind { + case reflect.Invalid: + // Do nothing. We should never get here since invalid has already + // been handled above. + + case reflect.Bool: + printBool(f.fs, v.Bool()) + + case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: + printInt(f.fs, v.Int(), 10) + + case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: + printUint(f.fs, v.Uint(), 10) + + case reflect.Float32: + printFloat(f.fs, v.Float(), 32) + + case reflect.Float64: + printFloat(f.fs, v.Float(), 64) + + case reflect.Complex64: + printComplex(f.fs, v.Complex(), 32) + + case reflect.Complex128: + printComplex(f.fs, v.Complex(), 64) + + case reflect.Slice: + if v.IsNil() { + f.fs.Write(nilAngleBytes) + break + } + fallthrough + + case reflect.Array: + f.fs.Write(openBracketBytes) + f.depth++ + if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) { + f.fs.Write(maxShortBytes) + } else { + numEntries := v.Len() + for i := 0; i < numEntries; i++ { + if i > 0 { + f.fs.Write(spaceBytes) + } + f.ignoreNextType = true + f.format(f.unpackValue(v.Index(i))) + } + } + f.depth-- + f.fs.Write(closeBracketBytes) + + case reflect.String: + f.fs.Write([]byte(v.String())) + + case reflect.Interface: + // The only time we should get here is for nil interfaces due to + // unpackValue calls. + if v.IsNil() { + f.fs.Write(nilAngleBytes) + } + + case reflect.Ptr: + // Do nothing. We should never get here since pointers have already + // been handled above. + + case reflect.Map: + // nil maps should be indicated as different than empty maps + if v.IsNil() { + f.fs.Write(nilAngleBytes) + break + } + + f.fs.Write(openMapBytes) + f.depth++ + if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) { + f.fs.Write(maxShortBytes) + } else { + keys := v.MapKeys() + if f.cs.SortKeys { + sortValues(keys, f.cs) + } + for i, key := range keys { + if i > 0 { + f.fs.Write(spaceBytes) + } + f.ignoreNextType = true + f.format(f.unpackValue(key)) + f.fs.Write(colonBytes) + f.ignoreNextType = true + f.format(f.unpackValue(v.MapIndex(key))) + } + } + f.depth-- + f.fs.Write(closeMapBytes) + + case reflect.Struct: + numFields := v.NumField() + f.fs.Write(openBraceBytes) + f.depth++ + if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) { + f.fs.Write(maxShortBytes) + } else { + vt := v.Type() + for i := 0; i < numFields; i++ { + if i > 0 { + f.fs.Write(spaceBytes) + } + vtf := vt.Field(i) + if f.fs.Flag('+') || f.fs.Flag('#') { + f.fs.Write([]byte(vtf.Name)) + f.fs.Write(colonBytes) + } + f.format(f.unpackValue(v.Field(i))) + } + } + f.depth-- + f.fs.Write(closeBraceBytes) + + case reflect.Uintptr: + printHexPtr(f.fs, uintptr(v.Uint())) + + case reflect.UnsafePointer, reflect.Chan, reflect.Func: + printHexPtr(f.fs, v.Pointer()) + + // There were not any other types at the time this code was written, but + // fall back to letting the default fmt package handle it if any get added. + default: + format := f.buildDefaultFormat() + if v.CanInterface() { + fmt.Fprintf(f.fs, format, v.Interface()) + } else { + fmt.Fprintf(f.fs, format, v.String()) + } + } +} + +// Format satisfies the fmt.Formatter interface. See NewFormatter for usage +// details. +func (f *formatState) Format(fs fmt.State, verb rune) { + f.fs = fs + + // Use standard formatting for verbs that are not v. + if verb != 'v' { + format := f.constructOrigFormat(verb) + fmt.Fprintf(fs, format, f.value) + return + } + + if f.value == nil { + if fs.Flag('#') { + fs.Write(interfaceBytes) + } + fs.Write(nilAngleBytes) + return + } + + f.format(reflect.ValueOf(f.value)) +} + +// newFormatter is a helper function to consolidate the logic from the various +// public methods which take varying config states. +func newFormatter(cs *ConfigState, v interface{}) fmt.Formatter { + fs := &formatState{value: v, cs: cs} + fs.pointers = make(map[uintptr]int) + return fs +} + +/* +NewFormatter returns a custom formatter that satisfies the fmt.Formatter +interface. As a result, it integrates cleanly with standard fmt package +printing functions. The formatter is useful for inline printing of smaller data +types similar to the standard %v format specifier. + +The custom formatter only responds to the %v (most compact), %+v (adds pointer +addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb +combinations. Any other verbs such as %x and %q will be sent to the the +standard fmt package for formatting. In addition, the custom formatter ignores +the width and precision arguments (however they will still work on the format +specifiers not handled by the custom formatter). + +Typically this function shouldn't be called directly. It is much easier to make +use of the custom formatter by calling one of the convenience functions such as +Printf, Println, or Fprintf. +*/ +func NewFormatter(v interface{}) fmt.Formatter { + return newFormatter(&Config, v) +} diff --git a/vendor/github.com/stretchr/testify/internal/spew/spew.go b/vendor/github.com/stretchr/testify/internal/spew/spew.go new file mode 100644 index 00000000000..32c0e338825 --- /dev/null +++ b/vendor/github.com/stretchr/testify/internal/spew/spew.go @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew + +import ( + "fmt" + "io" +) + +// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the formatted string as a value that satisfies error. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Errorf(format, spew.NewFormatter(a), spew.NewFormatter(b)) +func Errorf(format string, a ...interface{}) (err error) { + return fmt.Errorf(format, convertArgs(a)...) +} + +// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Fprint(w, spew.NewFormatter(a), spew.NewFormatter(b)) +func Fprint(w io.Writer, a ...interface{}) (n int, err error) { + return fmt.Fprint(w, convertArgs(a)...) +} + +// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Fprintf(w, format, spew.NewFormatter(a), spew.NewFormatter(b)) +func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) { + return fmt.Fprintf(w, format, convertArgs(a)...) +} + +// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it +// passed with a default Formatter interface returned by NewFormatter. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Fprintln(w, spew.NewFormatter(a), spew.NewFormatter(b)) +func Fprintln(w io.Writer, a ...interface{}) (n int, err error) { + return fmt.Fprintln(w, convertArgs(a)...) +} + +// Print is a wrapper for fmt.Print that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Print(spew.NewFormatter(a), spew.NewFormatter(b)) +func Print(a ...interface{}) (n int, err error) { + return fmt.Print(convertArgs(a)...) +} + +// Printf is a wrapper for fmt.Printf that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Printf(format, spew.NewFormatter(a), spew.NewFormatter(b)) +func Printf(format string, a ...interface{}) (n int, err error) { + return fmt.Printf(format, convertArgs(a)...) +} + +// Println is a wrapper for fmt.Println that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Println(spew.NewFormatter(a), spew.NewFormatter(b)) +func Println(a ...interface{}) (n int, err error) { + return fmt.Println(convertArgs(a)...) +} + +// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the resulting string. See NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Sprint(spew.NewFormatter(a), spew.NewFormatter(b)) +func Sprint(a ...interface{}) string { + return fmt.Sprint(convertArgs(a)...) +} + +// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the resulting string. See NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Sprintf(format, spew.NewFormatter(a), spew.NewFormatter(b)) +func Sprintf(format string, a ...interface{}) string { + return fmt.Sprintf(format, convertArgs(a)...) +} + +// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it +// were passed with a default Formatter interface returned by NewFormatter. It +// returns the resulting string. See NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Sprintln(spew.NewFormatter(a), spew.NewFormatter(b)) +func Sprintln(a ...interface{}) string { + return fmt.Sprintln(convertArgs(a)...) +} + +// convertArgs accepts a slice of arguments and returns a slice of the same +// length with each argument converted to a default spew Formatter interface. +func convertArgs(args []interface{}) (formatters []interface{}) { + formatters = make([]interface{}, len(args)) + for index, arg := range args { + formatters[index] = NewFormatter(arg) + } + return formatters +} diff --git a/vendor/github.com/stretchr/testify/mock/mock.go b/vendor/github.com/stretchr/testify/mock/mock.go index efc89deff38..7f4d28d5ee6 100644 --- a/vendor/github.com/stretchr/testify/mock/mock.go +++ b/vendor/github.com/stretchr/testify/mock/mock.go @@ -11,11 +11,11 @@ import ( "sync" "time" - "github.com/davecgh/go-spew/spew" - "github.com/pmezard/go-difflib/difflib" "github.com/stretchr/objx" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/internal/difflib" + "github.com/stretchr/testify/internal/spew" ) // regex for GCCGO functions @@ -470,7 +470,7 @@ func callString(method string, arguments Arguments, includeArgumentValues bool) // Called tells the mock object that a method has been called, and gets an array // of arguments to return. Panics if the call is unexpected (i.e. not preceded by -// appropriate .On .Return() calls) +// appropriate [Mock.On] calls) // If Call.WaitFor is set, blocks until the channel is closed or receives a message. func (m *Mock) Called(arguments ...interface{}) Arguments { // get the calling function's name @@ -493,7 +493,7 @@ func (m *Mock) Called(arguments ...interface{}) Arguments { // MethodCalled tells the mock object that the given method has been called, and gets // an array of arguments to return. Panics if the call is unexpected (i.e. not preceded -// by appropriate .On .Return() calls) +// by appropriate [Mock.On] calls) // If Call.WaitFor is set, blocks until the channel is closed or receives a message. func (m *Mock) MethodCalled(methodName string, arguments ...interface{}) Arguments { m.mutex.Lock() @@ -510,8 +510,7 @@ func (m *Mock) MethodCalled(methodName string, arguments ...interface{}) Argumen // as the return arguments. This is because: // // a) this is a totally unexpected call to this method, - // b) the arguments are not what was expected, or - // c) the developer has forgotten to add an accompanying On...Return pair. + // b) the arguments are not what was expected closestCall, mismatch := m.findClosestCall(methodName, arguments...) m.mutex.Unlock() @@ -595,7 +594,7 @@ type assertExpectationiser interface { AssertExpectations(TestingT) bool } -// AssertExpectationsForObjects asserts that everything specified with On and Return +// AssertExpectationsForObjects asserts that everything specified with [Mock.On] // of the specified objects was in fact called as expected. // // Calls may have occurred in any order. @@ -604,11 +603,12 @@ func AssertExpectationsForObjects(t TestingT, testObjects ...interface{}) bool { h.Helper() } for _, obj := range testObjects { - if m, ok := obj.(*Mock); ok { - t.Logf("Deprecated mock.AssertExpectationsForObjects(myMock.Mock) use mock.AssertExpectationsForObjects(myMock)") - obj = m + m, ok := obj.(assertExpectationiser) + if !ok { + t.Errorf("Invalid test object type %T. Expected reference to a mock.Mock, eg: 'AssertExpectationsForObjects(t, myMock)' or 'AssertExpectationsForObjects(t, &myMock.Mock)'", obj) + continue + } - m := obj.(assertExpectationiser) if !m.AssertExpectations(t) { t.Logf("Expectations didn't match for Mock: %+v", reflect.TypeOf(m)) return false @@ -617,7 +617,7 @@ func AssertExpectationsForObjects(t TestingT, testObjects ...interface{}) bool { return true } -// AssertExpectations asserts that everything specified with On and Return was +// AssertExpectations asserts that everything specified with [Mock.On] was // in fact called as expected. Calls may have occurred in any order. func (m *Mock) AssertExpectations(t TestingT) bool { if s, ok := t.(interface{ Skipped() bool }); ok && s.Skipped() { @@ -712,8 +712,8 @@ func (m *Mock) AssertNotCalled(t TestingT, methodName string, arguments ...inter return true } -// IsMethodCallable checking that the method can be called -// If the method was called more than `Repeatability` return false +// IsMethodCallable returns true if given methodName and arguments have an +// unsatisfied expected call registered in the Mock. func (m *Mock) IsMethodCallable(t TestingT, methodName string, arguments ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -833,6 +833,10 @@ type IsTypeArgument struct { // For example: // // args.Assert(t, IsType(""), IsType(0)) +// +// Mock cannot match interface types because the contained type will be passed +// to both IsType and Mock.Called, for the zero value of all interfaces this +// will be type. func IsType(t interface{}) *IsTypeArgument { return &IsTypeArgument{t: reflect.TypeOf(t)} } @@ -1012,7 +1016,7 @@ func (args Arguments) Diff(objects []interface{}) (string, int) { actualT := reflect.TypeOf(actual) if actualT != expected.t { differences++ - output = fmt.Sprintf("%s\t%d: FAIL: type %s != type %s - %s\n", output, i, expected.t.Name(), actualT.Name(), actualFmt) + output = fmt.Sprintf("%s\t%d: FAIL: type %s != type %s - %s\n", output, i, safeTypeName(expected.t), safeTypeName(actualT), actualFmt) } case *FunctionalOptionsArgument: var name string @@ -1141,6 +1145,15 @@ func (args Arguments) Bool(index int) bool { return s } +// safeTypeName returns the reflect.Type's name without causing a panic. +// If the provided reflect.Type is nil, it returns the placeholder string "" +func safeTypeName(t reflect.Type) string { + if t == nil { + return "" + } + return t.Name() +} + func typeAndKind(v interface{}) (reflect.Type, reflect.Kind) { t := reflect.TypeOf(v) k := t.Kind() diff --git a/vendor/github.com/stretchr/testify/require/doc.go b/vendor/github.com/stretchr/testify/require/doc.go index c8e3f94a803..ee84cc47916 100644 --- a/vendor/github.com/stretchr/testify/require/doc.go +++ b/vendor/github.com/stretchr/testify/require/doc.go @@ -1,4 +1,4 @@ -// Package require implements the same assertions as the `assert` package but +// Package require implements the same assertions as the assert package but // stops test execution when a test fails. // // # Example Usage @@ -21,8 +21,8 @@ // // # Assertions // -// The `require` package have same global functions as in the `assert` package, -// but instead of returning a boolean result they call `t.FailNow()`. +// The require package have same global functions as in the assert package, +// but instead of returning a boolean result they call [testing.T.FailNow]. // A consequence of this is that it must be called from the goroutine running // the test function, not from other goroutines created during the test. // diff --git a/vendor/github.com/stretchr/testify/require/require.go b/vendor/github.com/stretchr/testify/require/require.go index 2d02f9bcef1..652871f2eb7 100644 --- a/vendor/github.com/stretchr/testify/require/require.go +++ b/vendor/github.com/stretchr/testify/require/require.go @@ -180,7 +180,7 @@ func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...i t.FailNow() } -// EqualError asserts that a function returned an error (i.e. not `nil`) +// EqualError asserts that a function returned a non-nil error (i.e. an error) // and that it is equal to the provided error. // // actualObj, err := SomeFunction() @@ -195,7 +195,7 @@ func EqualError(t TestingT, theError error, errString string, msgAndArgs ...inte t.FailNow() } -// EqualErrorf asserts that a function returned an error (i.e. not `nil`) +// EqualErrorf asserts that a function returned a non-nil error (i.e. an error) // and that it is equal to the provided error. // // actualObj, err := SomeFunction() @@ -295,7 +295,7 @@ func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, ar t.FailNow() } -// Error asserts that a function returned an error (i.e. not `nil`). +// Error asserts that a function returned a non-nil error (ie. an error). // // actualObj, err := SomeFunction() // require.Error(t, err) @@ -333,8 +333,8 @@ func ErrorAsf(t TestingT, err error, target interface{}, msg string, args ...int t.FailNow() } -// ErrorContains asserts that a function returned an error (i.e. not `nil`) -// and that the error contains the specified substring. +// ErrorContains asserts that a function returned a non-nil error (i.e. an +// error) and that the error contains the specified substring. // // actualObj, err := SomeFunction() // require.ErrorContains(t, err, expectedErrorSubString) @@ -348,8 +348,8 @@ func ErrorContains(t TestingT, theError error, contains string, msgAndArgs ...in t.FailNow() } -// ErrorContainsf asserts that a function returned an error (i.e. not `nil`) -// and that the error contains the specified substring. +// ErrorContainsf asserts that a function returned a non-nil error (i.e. an +// error) and that the error contains the specified substring. // // actualObj, err := SomeFunction() // require.ErrorContainsf(t, err, expectedErrorSubString, "error message %s", "formatted") @@ -387,7 +387,7 @@ func ErrorIsf(t TestingT, err error, target error, msg string, args ...interface t.FailNow() } -// Errorf asserts that a function returned an error (i.e. not `nil`). +// Errorf asserts that a function returned a non-nil error (ie. an error). // // actualObj, err := SomeFunction() // require.Errorf(t, err, "error message %s", "formatted") @@ -429,7 +429,7 @@ func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick t // time.Sleep(8*time.Second) // externalValue = true // }() -// require.EventuallyWithT(t, func(c *require.CollectT) { +// require.EventuallyWithT(t, func(c *assert.CollectT) { // // add assertions as needed; any assertion failure will fail the current tick // require.True(c, externalValue, "expected 'externalValue' to be true") // }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false") @@ -457,10 +457,10 @@ func EventuallyWithT(t TestingT, condition func(collect *assert.CollectT), waitF // time.Sleep(8*time.Second) // externalValue = true // }() -// require.EventuallyWithTf(t, func(c *require.CollectT, "error message %s", "formatted") { +// require.EventuallyWithTf(t, func(c *assert.CollectT) { // // add assertions as needed; any assertion failure will fail the current tick // require.True(c, externalValue, "expected 'externalValue' to be true") -// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false") +// }, 10*time.Second, 1*time.Second, "error message %s", "formatted") func EventuallyWithTf(t TestingT, condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -671,8 +671,6 @@ func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...in // body that contains a string. // // require.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") -// -// Returns whether the assertion was successful (true) or not (false). func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -687,8 +685,6 @@ func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url s // body that contains a string. // // require.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -703,8 +699,6 @@ func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url // body that does not contain a string. // // require.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") -// -// Returns whether the assertion was successful (true) or not (false). func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -719,8 +713,6 @@ func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, ur // body that does not contain a string. // // require.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -734,8 +726,6 @@ func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, u // HTTPError asserts that a specified handler returns an error status code. // // require.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -749,8 +739,6 @@ func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string, // HTTPErrorf asserts that a specified handler returns an error status code. // // require.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -764,8 +752,6 @@ func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, // HTTPRedirect asserts that a specified handler returns a redirect status code. // // require.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -779,8 +765,6 @@ func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url strin // HTTPRedirectf asserts that a specified handler returns a redirect status code. // // require.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -794,8 +778,6 @@ func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url stri // HTTPStatusCode asserts that a specified handler returns a specified status code. // // require.HTTPStatusCode(t, myHandler, "GET", "/notImplemented", nil, 501) -// -// Returns whether the assertion was successful (true) or not (false). func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -809,8 +791,6 @@ func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method string, url str // HTTPStatusCodef asserts that a specified handler returns a specified status code. // // require.HTTPStatusCodef(t, myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -824,8 +804,6 @@ func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string, url st // HTTPSuccess asserts that a specified handler returns a success status code. // // require.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) -// -// Returns whether the assertion was successful (true) or not (false). func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -839,8 +817,6 @@ func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string // HTTPSuccessf asserts that a specified handler returns a success status code. // // require.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1385,12 +1361,11 @@ func NoDirExistsf(t TestingT, path string, msg string, args ...interface{}) { t.FailNow() } -// NoError asserts that a function returned no error (i.e. `nil`). +// NoError asserts that a function returned a nil error (ie. no error). // -// actualObj, err := SomeFunction() -// if require.NoError(t, err) { -// require.Equal(t, expectedObj, actualObj) -// } +// actualObj, err := SomeFunction() +// require.NoError(t, err) +// require.Equal(t, expectedObj, actualObj) func NoError(t TestingT, err error, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1401,12 +1376,11 @@ func NoError(t TestingT, err error, msgAndArgs ...interface{}) { t.FailNow() } -// NoErrorf asserts that a function returned no error (i.e. `nil`). +// NoErrorf asserts that a function returned a nil error (ie. no error). // -// actualObj, err := SomeFunction() -// if require.NoErrorf(t, err, "error message %s", "formatted") { -// require.Equal(t, expectedObj, actualObj) -// } +// actualObj, err := SomeFunction() +// require.NoErrorf(t, err, "error message %s", "formatted") +// require.Equal(t, expectedObj, actualObj) func NoErrorf(t TestingT, err error, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1515,9 +1489,8 @@ func NotElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg str // NotEmpty asserts that the specified object is NOT [Empty]. // -// if require.NotEmpty(t, obj) { -// require.Equal(t, "two", obj[1]) -// } +// require.NotEmpty(t, obj) +// require.Equal(t, "two", obj[1]) func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1530,9 +1503,8 @@ func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) { // NotEmptyf asserts that the specified object is NOT [Empty]. // -// if require.NotEmptyf(t, obj, "error message %s", "formatted") { -// require.Equal(t, "two", obj[1]) -// } +// require.NotEmptyf(t, obj, "error message %s", "formatted") +// require.Equal(t, "two", obj[1]) func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -2135,7 +2107,19 @@ func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, t.FailNow() } -// YAMLEq asserts that two YAML strings are equivalent. +// YAMLEq asserts that the first documents in the two YAML strings are equivalent. +// +// expected := `--- +// key: value +// --- +// key: this is a second document, it is not evaluated +// ` +// actual := `--- +// key: value +// --- +// key: this is a subsequent document, it is not evaluated +// ` +// require.YAMLEq(t, expected, actual) func YAMLEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -2146,7 +2130,19 @@ func YAMLEq(t TestingT, expected string, actual string, msgAndArgs ...interface{ t.FailNow() } -// YAMLEqf asserts that two YAML strings are equivalent. +// YAMLEqf asserts that the first documents in the two YAML strings are equivalent. +// +// expected := `--- +// key: value +// --- +// key: this is a second document, it is not evaluated +// ` +// actual := `--- +// key: value +// --- +// key: this is a subsequent document, it is not evaluated +// ` +// require.YAMLEqf(t, expected, actual, "error message %s", "formatted") func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() diff --git a/vendor/github.com/stretchr/testify/require/require.go.tmpl b/vendor/github.com/stretchr/testify/require/require.go.tmpl index 8b328368509..6a975501ee7 100644 --- a/vendor/github.com/stretchr/testify/require/require.go.tmpl +++ b/vendor/github.com/stretchr/testify/require/require.go.tmpl @@ -1,4 +1,4 @@ -{{ replace .Comment "assert." "require."}} +{{.CommentRequire}} func {{.DocInfo.Name}}(t TestingT, {{.Params}}) { if h, ok := t.(tHelper); ok { h.Helper() } if assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) { return } diff --git a/vendor/github.com/stretchr/testify/require/require_forward.go b/vendor/github.com/stretchr/testify/require/require_forward.go index e6f7e944684..edac147ef46 100644 --- a/vendor/github.com/stretchr/testify/require/require_forward.go +++ b/vendor/github.com/stretchr/testify/require/require_forward.go @@ -147,7 +147,7 @@ func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs Equal(a.t, expected, actual, msgAndArgs...) } -// EqualError asserts that a function returned an error (i.e. not `nil`) +// EqualError asserts that a function returned a non-nil error (i.e. an error) // and that it is equal to the provided error. // // actualObj, err := SomeFunction() @@ -159,7 +159,7 @@ func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ... EqualError(a.t, theError, errString, msgAndArgs...) } -// EqualErrorf asserts that a function returned an error (i.e. not `nil`) +// EqualErrorf asserts that a function returned a non-nil error (i.e. an error) // and that it is equal to the provided error. // // actualObj, err := SomeFunction() @@ -241,7 +241,7 @@ func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string Equalf(a.t, expected, actual, msg, args...) } -// Error asserts that a function returned an error (i.e. not `nil`). +// Error asserts that a function returned a non-nil error (ie. an error). // // actualObj, err := SomeFunction() // a.Error(err) @@ -270,8 +270,8 @@ func (a *Assertions) ErrorAsf(err error, target interface{}, msg string, args .. ErrorAsf(a.t, err, target, msg, args...) } -// ErrorContains asserts that a function returned an error (i.e. not `nil`) -// and that the error contains the specified substring. +// ErrorContains asserts that a function returned a non-nil error (i.e. an +// error) and that the error contains the specified substring. // // actualObj, err := SomeFunction() // a.ErrorContains(err, expectedErrorSubString) @@ -282,8 +282,8 @@ func (a *Assertions) ErrorContains(theError error, contains string, msgAndArgs . ErrorContains(a.t, theError, contains, msgAndArgs...) } -// ErrorContainsf asserts that a function returned an error (i.e. not `nil`) -// and that the error contains the specified substring. +// ErrorContainsf asserts that a function returned a non-nil error (i.e. an +// error) and that the error contains the specified substring. // // actualObj, err := SomeFunction() // a.ErrorContainsf(err, expectedErrorSubString, "error message %s", "formatted") @@ -312,7 +312,7 @@ func (a *Assertions) ErrorIsf(err error, target error, msg string, args ...inter ErrorIsf(a.t, err, target, msg, args...) } -// Errorf asserts that a function returned an error (i.e. not `nil`). +// Errorf asserts that a function returned a non-nil error (ie. an error). // // actualObj, err := SomeFunction() // a.Errorf(err, "error message %s", "formatted") @@ -373,10 +373,10 @@ func (a *Assertions) EventuallyWithT(condition func(collect *assert.CollectT), w // time.Sleep(8*time.Second) // externalValue = true // }() -// a.EventuallyWithTf(func(c *assert.CollectT, "error message %s", "formatted") { +// a.EventuallyWithTf(func(c *assert.CollectT) { // // add assertions as needed; any assertion failure will fail the current tick // assert.True(c, externalValue, "expected 'externalValue' to be true") -// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false") +// }, 10*time.Second, 1*time.Second, "error message %s", "formatted") func (a *Assertions) EventuallyWithTf(condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -539,8 +539,6 @@ func (a *Assertions) Greaterf(e1 interface{}, e2 interface{}, msg string, args . // body that contains a string. // // a.HTTPBodyContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -552,8 +550,6 @@ func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, u // body that contains a string. // // a.HTTPBodyContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -565,8 +561,6 @@ func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, // body that does not contain a string. // // a.HTTPBodyNotContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -578,8 +572,6 @@ func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string // body that does not contain a string. // // a.HTTPBodyNotContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -590,8 +582,6 @@ func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method strin // HTTPError asserts that a specified handler returns an error status code. // // a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -602,8 +592,6 @@ func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url stri // HTTPErrorf asserts that a specified handler returns an error status code. // // a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -614,8 +602,6 @@ func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url str // HTTPRedirect asserts that a specified handler returns a redirect status code. // // a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -626,8 +612,6 @@ func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url s // HTTPRedirectf asserts that a specified handler returns a redirect status code. // // a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -638,8 +622,6 @@ func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url // HTTPStatusCode asserts that a specified handler returns a specified status code. // // a.HTTPStatusCode(myHandler, "GET", "/notImplemented", nil, 501) -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPStatusCode(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -650,8 +632,6 @@ func (a *Assertions) HTTPStatusCode(handler http.HandlerFunc, method string, url // HTTPStatusCodef asserts that a specified handler returns a specified status code. // // a.HTTPStatusCodef(myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPStatusCodef(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -662,8 +642,6 @@ func (a *Assertions) HTTPStatusCodef(handler http.HandlerFunc, method string, ur // HTTPSuccess asserts that a specified handler returns a success status code. // // a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil) -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -674,8 +652,6 @@ func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url st // HTTPSuccessf asserts that a specified handler returns a success status code. // // a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1097,12 +1073,11 @@ func (a *Assertions) NoDirExistsf(path string, msg string, args ...interface{}) NoDirExistsf(a.t, path, msg, args...) } -// NoError asserts that a function returned no error (i.e. `nil`). +// NoError asserts that a function returned a nil error (ie. no error). // -// actualObj, err := SomeFunction() -// if a.NoError(err) { -// assert.Equal(t, expectedObj, actualObj) -// } +// actualObj, err := SomeFunction() +// a.NoError(err) +// a.Equal(expectedObj, actualObj) func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1110,12 +1085,11 @@ func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) { NoError(a.t, err, msgAndArgs...) } -// NoErrorf asserts that a function returned no error (i.e. `nil`). +// NoErrorf asserts that a function returned a nil error (ie. no error). // -// actualObj, err := SomeFunction() -// if a.NoErrorf(err, "error message %s", "formatted") { -// assert.Equal(t, expectedObj, actualObj) -// } +// actualObj, err := SomeFunction() +// a.NoErrorf(err, "error message %s", "formatted") +// a.Equal(expectedObj, actualObj) func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1203,9 +1177,8 @@ func (a *Assertions) NotElementsMatchf(listA interface{}, listB interface{}, msg // NotEmpty asserts that the specified object is NOT [Empty]. // -// if a.NotEmpty(obj) { -// assert.Equal(t, "two", obj[1]) -// } +// a.NotEmpty(obj) +// a.Equal("two", obj[1]) func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1215,9 +1188,8 @@ func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) { // NotEmptyf asserts that the specified object is NOT [Empty]. // -// if a.NotEmptyf(obj, "error message %s", "formatted") { -// assert.Equal(t, "two", obj[1]) -// } +// a.NotEmptyf(obj, "error message %s", "formatted") +// a.Equal("two", obj[1]) func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1691,7 +1663,19 @@ func (a *Assertions) WithinRangef(actual time.Time, start time.Time, end time.Ti WithinRangef(a.t, actual, start, end, msg, args...) } -// YAMLEq asserts that two YAML strings are equivalent. +// YAMLEq asserts that the first documents in the two YAML strings are equivalent. +// +// expected := `--- +// key: value +// --- +// key: this is a second document, it is not evaluated +// ` +// actual := `--- +// key: value +// --- +// key: this is a subsequent document, it is not evaluated +// ` +// a.YAMLEq(expected, actual) func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1699,7 +1683,19 @@ func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interf YAMLEq(a.t, expected, actual, msgAndArgs...) } -// YAMLEqf asserts that two YAML strings are equivalent. +// YAMLEqf asserts that the first documents in the two YAML strings are equivalent. +// +// expected := `--- +// key: value +// --- +// key: this is a second document, it is not evaluated +// ` +// actual := `--- +// key: value +// --- +// key: this is a subsequent document, it is not evaluated +// ` +// a.YAMLEqf(expected, actual, "error message %s", "formatted") func (a *Assertions) YAMLEqf(expected string, actual string, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() diff --git a/vendor/github.com/stretchr/testify/require/require_forward.go.tmpl b/vendor/github.com/stretchr/testify/require/require_forward.go.tmpl index 54124df1d3b..b3b751de48a 100644 --- a/vendor/github.com/stretchr/testify/require/require_forward.go.tmpl +++ b/vendor/github.com/stretchr/testify/require/require_forward.go.tmpl @@ -1,4 +1,4 @@ -{{.CommentWithoutT "a"}} +{{.CommentRequireWithoutT "a"}} func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) { if h, ok := a.t.(tHelper); ok { h.Helper() } {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) diff --git a/vendor/github.com/stretchr/testify/require/requirements.go b/vendor/github.com/stretchr/testify/require/requirements.go index 6b7ce929eb1..375adb0a6ad 100644 --- a/vendor/github.com/stretchr/testify/require/requirements.go +++ b/vendor/github.com/stretchr/testify/require/requirements.go @@ -12,18 +12,18 @@ type tHelper = interface { // ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful // for table driven tests. -type ComparisonAssertionFunc func(TestingT, interface{}, interface{}, ...interface{}) +type ComparisonAssertionFunc = func(TestingT, interface{}, interface{}, ...interface{}) // ValueAssertionFunc is a common function prototype when validating a single value. Can be useful // for table driven tests. -type ValueAssertionFunc func(TestingT, interface{}, ...interface{}) +type ValueAssertionFunc = func(TestingT, interface{}, ...interface{}) // BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful // for table driven tests. -type BoolAssertionFunc func(TestingT, bool, ...interface{}) +type BoolAssertionFunc = func(TestingT, bool, ...interface{}) // ErrorAssertionFunc is a common function prototype when validating an error value. Can be useful // for table driven tests. -type ErrorAssertionFunc func(TestingT, error, ...interface{}) +type ErrorAssertionFunc = func(TestingT, error, ...interface{}) //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=require -template=require.go.tmpl -include-format-funcs" diff --git a/vendor/github.com/tinylib/msgp/msgp/json.go b/vendor/github.com/tinylib/msgp/msgp/json.go index 896d690ba09..49bd54bf124 100644 --- a/vendor/github.com/tinylib/msgp/msgp/json.go +++ b/vendor/github.com/tinylib/msgp/msgp/json.go @@ -131,11 +131,35 @@ func rwMap(dst jsWriter, src *Reader) (n int, err error) { n++ } - field, err = src.ReadMapKeyPtr() + var kt Type + kt, err = src.NextType() if err != nil { return } - nn, err = rwquoted(dst, field) + switch kt { + case IntType: + var i64 int64 + i64, err = src.ReadInt64() + if err != nil { + return + } + src.scratch = strconv.AppendInt(src.scratch[:0], i64, 10) + nn, err = rwquoted(dst, src.scratch) + case UintType: + var u64 uint64 + u64, err = src.ReadUint64() + if err != nil { + return + } + src.scratch = strconv.AppendUint(src.scratch[:0], u64, 10) + nn, err = rwquoted(dst, src.scratch) + default: + field, err = src.ReadMapKeyPtr() + if err != nil { + return + } + nn, err = rwquoted(dst, field) + } n += nn if err != nil { return diff --git a/vendor/github.com/tinylib/msgp/msgp/json_bytes.go b/vendor/github.com/tinylib/msgp/msgp/json_bytes.go index 7efd162f199..4aced1b16c3 100644 --- a/vendor/github.com/tinylib/msgp/msgp/json_bytes.go +++ b/vendor/github.com/tinylib/msgp/msgp/json_bytes.go @@ -144,6 +144,27 @@ func rwMapBytes(w jsWriter, msg []byte, scratch []byte, depth int) ([]byte, []by } func rwMapKeyBytes(w jsWriter, msg []byte, scratch []byte, depth int) ([]byte, []byte, error) { + if len(msg) < 1 { + return msg, scratch, ErrShortBytes + } + switch getType(msg[0]) { + case IntType: + i, msg, err := ReadInt64Bytes(msg) + if err != nil { + return msg, scratch, err + } + scratch = strconv.AppendInt(scratch[:0], i, 10) + _, err = rwquoted(w, scratch) + return msg, scratch, err + case UintType: + u, msg, err := ReadUint64Bytes(msg) + if err != nil { + return msg, scratch, err + } + scratch = strconv.AppendUint(scratch[:0], u, 10) + _, err = rwquoted(w, scratch) + return msg, scratch, err + } msg, scratch, err := rwStringBytes(w, msg, scratch, depth) if err != nil { if tperr, ok := err.(TypeError); ok && tperr.Encoded == BinType { diff --git a/vendor/github.com/tinylib/msgp/msgp/read.go b/vendor/github.com/tinylib/msgp/msgp/read.go index 264933ad0ef..b029e5740c7 100644 --- a/vendor/github.com/tinylib/msgp/msgp/read.go +++ b/vendor/github.com/tinylib/msgp/msgp/read.go @@ -121,6 +121,10 @@ func Decode(r io.Reader, d Decodable) error { // reader will be buffered. func NewReader(r io.Reader) *Reader { p := readerPool.Get().(*Reader) + p.recursionDepth = 0 + p.maxElements = 0 + p.maxRecursionDepth = 0 + p.maxStrLen = 0 if p.R == nil { p.R = fwd.NewReader(r) } else { @@ -1009,6 +1013,62 @@ func (m *Reader) ReadBytes(scratch []byte) (b []byte, err error) { return } +// ReadBytesLimit reads a MessagePack 'bin' object +// from the reader and returns its value. It may +// use 'scratch' for storage if it is non-nil. +// If n >= 0 this will be the maximum bytes read. +// If n < 0, the cap(scratch) will be the limit. +// If SetMaxElements has been used on the Reader, +// that will only be checked if the scratch is too small. +func (m *Reader) ReadBytesLimit(scratch []byte, n int64) (b []byte, err error) { + var p []byte + var lead byte + p, err = m.R.Peek(2) + if err != nil { + return + } + lead = p[0] + var read int64 + switch lead { + case mbin8: + read = int64(p[1]) + m.R.Skip(2) + case mbin16: + p, err = m.R.Next(3) + if err != nil { + return + } + read = int64(big.Uint16(p[1:])) + case mbin32: + p, err = m.R.Next(5) + if err != nil { + return + } + read = int64(big.Uint32(p[1:])) + default: + err = badPrefix(BinType, lead) + return + } + if n < 0 { + n = int64(cap(scratch)) + } + if read > n { + err = ErrLimitExceeded + return + } + if int64(cap(scratch)) < read { + b = make([]byte, read) + if read > int64(m.GetMaxElements()) { + err = ErrLimitExceeded + return + } + } else { + b = scratch[0:read] + } + _, err = m.R.ReadFull(b) + return +} + // ReadBytesHeader reads the size header // of a MessagePack 'bin' object. The user // is responsible for dealing with the next diff --git a/vendor/github.com/tjhop/slog-gokit/handler.go b/vendor/github.com/tjhop/slog-gokit/handler.go index 4743e301e0e..61d45d34fc5 100644 --- a/vendor/github.com/tjhop/slog-gokit/handler.go +++ b/vendor/github.com/tjhop/slog-gokit/handler.go @@ -4,6 +4,10 @@ import ( "context" "log/slog" "os" + "runtime" + "strconv" + "strings" + "sync" "github.com/go-kit/log" ) @@ -12,19 +16,32 @@ var _ slog.Handler = (*GoKitHandler)(nil) var defaultGoKitLogger = log.NewLogfmtLogger(os.Stderr) -// Pay boxing cost once at package init, save 2 heap escapes per Handle() call. +// Pay boxing cost once at package init, save 3 heap escapes per Handle() call. var ( - timeKey any = slog.TimeKey - msgKey any = slog.MessageKey + timeKey any = slog.TimeKey + msgKey any = slog.MessageKey + callerKey any = "caller" ) +// callerCache memoizes resolved caller strings keyed by record PC. A PC's +// file:line mapping is fixed for the process lifetime and log call sites are +// static, so the cache is write-once, read-many and bounded by the number of +// distinct call sites. +// +// Kubernetes's klog does something similar to cache per-call-site verbosity +// levels by PC (`vmap` in +// https://github.com/kubernetes/klog/blob/main/klog.go). +// +// Values are stored pre-boxed as `any` so cache hits append into the pairs +// slice with zero allocations, and no need to walk the call stack. +var callerCache sync.Map // map[uintptr]any, values are `file:line` strings. + // GoKitHandler implements the slog.Handler interface. It holds an internal // go-kit logger that is used to perform the true logging. type GoKitHandler struct { level slog.Leveler logger log.Logger - levelLoggers *levelLoggerCache // pre-built leveled loggers - preformatted []any // pre-flattened key-value pairs, ready to pass directly to logger.Log() + preformatted []any // pre-flattened key-value pairs, ready to pass directly to logger.Log() group string } @@ -32,23 +49,23 @@ type GoKitHandler struct { // logger. Calls to the slog logger are chained to the handler's internal // go-kit logger. If provided a level, it will be used to filter log events in // the handler's Enabled() method. +// +// The handler adds a `caller` key to each record, resolved from the program +// counter that slog captured at the log call site. Records handled directly +// (without going through an slog.Logger) have no PC set, and thus omit the +// caller. func NewGoKitHandler(logger log.Logger, level slog.Leveler) slog.Handler { if logger == nil { logger = defaultGoKitLogger } - // Adjust runtime call depth to compensate for the adapter and point to - // the appropriate source line. - logger = log.With(logger, "caller", log.Caller(6)) - if level == nil { level = &slog.LevelVar{} // Info level by default. } return &GoKitHandler{ - logger: logger, - level: level, - levelLoggers: newLevelCache(logger), + logger: logger, + level: level, } } @@ -63,21 +80,51 @@ func (h *GoKitHandler) Enabled(_ context.Context, level slog.Level) bool { // are formatted and added to the log call as individual key/value pairs. It // implements slog.Handler. func (h *GoKitHandler) Handle(_ context.Context, record slog.Record) error { - logger := h.levelLoggers.get(record.Level) - - // Pre-compute slice capacity. h.preformatted is already flattened to []any - // key-value pairs at WithAttrs time, so len(h.preformatted) is the exact - // item count -- no expansion buffer needed for that portion. Record attrs - // may contain groups that expand beyond 2 items per attr, so include a 50% - // buffer for that portion's estimated capacity only. - // - // We know we need: + // Pre-compute slice capacity, sized exactly for records with flat attrs + // (the common shape): + // - 2 for level (key + value) + // - 2 for caller (key + value) // - 2 for timestamp (key + value) // - 2 for message (key + value) - // - len(h.preformatted) exact items (pre-flattened, no expansion) - // - 2 * record.NumAttrs() for record attrs, +50% buffer for group expansion - capacity := 4 + len(h.preformatted) + (3 * record.NumAttrs()) + // - len(h.preformatted) exact items (pre-flattened at WithAttrs time) + // - 2 * record.NumAttrs() for record attrs + // + // Group attrs expand beyond 2 items per attr (a group with n items + // counts as one attr but flattens to 2n entries), so they'll need to + // be grown anyway. + numAttrs := record.NumAttrs() + capacity := 8 + len(h.preformatted) + (2 * numAttrs) pairs := make([]any, 0, capacity) + + // Append the level directly as the first pair. Matches how the log + // message is constructed through level.Info()/level.Debug()/etc + // wrappers, but without the extra allocation/copy per call. + pairs = append(pairs, levelKey, gokitLevelValue(record.Level)) + + // Resolve the log call site from the PC that slog captured when the + // record was created. Cheaper and more accurate to do it here since + // it's already captured, vs relying on setting `log.Caller()` depth + // and hoping it unwinds correctly. + if record.PC != 0 { + if caller, ok := callerCache.Load(record.PC); ok { + pairs = append(pairs, callerKey, caller) + } else { + fs := runtime.CallersFrames([]uintptr{record.PC}) + f, _ := fs.Next() + if f.File != "" { + // Trim to basename:line with the same logic as + // go-kit's log.Caller: + // https://github.com/go-kit/log/blob/v0.2.1/value.go#L84-L93 + // + // path.Base() would work, opting for direct compatibility. + idx := strings.LastIndexByte(f.File, '/') + caller := any(f.File[idx+1:] + ":" + strconv.Itoa(f.Line)) + callerCache.Store(record.PC, caller) + pairs = append(pairs, callerKey, caller) + } + } + } + if !record.Time.IsZero() { pairs = append(pairs, timeKey, record.Time) } @@ -87,17 +134,25 @@ func (h *GoKitHandler) Handle(_ context.Context, record slog.Record) error { // WithAttrs() call. pairs = append(pairs, h.preformatted...) - record.Attrs(func(a slog.Attr) bool { - pairs = appendPair(pairs, h.group, a) - return true - }) + // Skip the Attrs() call entirely when there are no attrs. + if numAttrs > 0 { + record.Attrs(func(a slog.Attr) bool { + pairs = appendPair(pairs, h.group, a) + return true + }) + } - return logger.Log(pairs...) + return h.logger.Log(pairs...) } // WithAttrs formats the provided attributes and caches them in the handler to // attach to all future log calls. It implements slog.Handler. func (h *GoKitHandler) WithAttrs(attrs []slog.Attr) slog.Handler { + // No attrs, return it untouched. + if len(attrs) == 0 { + return h + } + // Make a defensive copy of preformatted attrs to avoid race conditions // when multiple goroutines call WithAttrs concurrently on the same handler. // Attrs are pre-flattened to []any key-value pairs here so that Handle() @@ -115,7 +170,6 @@ func (h *GoKitHandler) WithAttrs(attrs []slog.Attr) slog.Handler { return &GoKitHandler{ logger: h.logger, level: h.level, - levelLoggers: h.levelLoggers, preformatted: pairs, group: h.group, } @@ -136,13 +190,20 @@ func (h *GoKitHandler) WithGroup(name string) slog.Handler { return &GoKitHandler{ logger: h.logger, level: h.level, - levelLoggers: h.levelLoggers, preformatted: h.preformatted, group: g, } } func appendPair(pairs []any, groupPrefix string, attr slog.Attr) []any { + // Resolve LogValuers before the kind switch so value that resolves to + // a group is expanded into individual pairs. Aligns with how the + // stdlib handlers resolve before expanding, and also avoids the + // defer/recover that `Resolve()` incurs. + if attr.Value.Kind() == slog.KindLogValuer { + attr.Value = attr.Value.Resolve() + } + if attr.Equal(slog.Attr{}) { return pairs } @@ -175,7 +236,14 @@ func appendPair(pairs []any, groupPrefix string, attr slog.Attr) []any { key = groupPrefix + "." + key } - pairs = append(pairs, key, attr.Value.Resolve()) + // Append string values as raw strings rather than boxed + // slog.Values, lean on string path optimizations in slog and + // go-kit/log. + if attr.Value.Kind() == slog.KindString { + pairs = append(pairs, key, attr.Value.String()) + } else { + pairs = append(pairs, key, attr.Value) + } } return pairs diff --git a/vendor/github.com/tjhop/slog-gokit/level.go b/vendor/github.com/tjhop/slog-gokit/level.go index 58b0b58ade8..29c10d0d9f2 100644 --- a/vendor/github.com/tjhop/slog-gokit/level.go +++ b/vendor/github.com/tjhop/slog-gokit/level.go @@ -3,38 +3,34 @@ package sloggokit import ( "log/slog" - "github.com/go-kit/log" "github.com/go-kit/log/level" ) -// levelLoggerCache holds pre-built leveled loggers so that Handle() can -// retrieve an existing leveled logger rather than creating a new one each -// time. -type levelLoggerCache struct { - debugLogger log.Logger - infoLogger log.Logger - warnLogger log.Logger - errorLogger log.Logger -} - -func newLevelCache(logger log.Logger) *levelLoggerCache { - return &levelLoggerCache{ - debugLogger: level.Debug(logger), - infoLogger: level.Info(logger), - warnLogger: level.Warn(logger), - errorLogger: level.Error(logger), - } -} +// go-kit/log hoists these into package level variables to pre-pay boxing cost +// once, same that we do for slog keys in the handler: +// https://github.com/go-kit/log/blob/v0.2.1/level/level.go#L229-L239 +// +// Re-hoist them here for the same reasons so they can be appended right into +// the log's kv pairs. +var ( + levelKey any = level.Key() + debugLevelValue any = level.DebugValue() + infoLevelValue any = level.InfoValue() + warnLevelValue any = level.WarnValue() + errorLevelValue any = level.ErrorValue() +) -func (c *levelLoggerCache) get(lvl slog.Level) log.Logger { +// gokitLevelValue maps an slog.Level to the boxed go-kit level value. +// Unnamed levels bucket to the highest named level at or below them. +func gokitLevelValue(lvl slog.Level) any { switch { case lvl >= slog.LevelError: - return c.errorLogger + return errorLevelValue case lvl >= slog.LevelWarn: - return c.warnLogger + return warnLevelValue case lvl >= slog.LevelInfo: - return c.infoLogger + return infoLevelValue default: - return c.debugLogger + return debugLevelValue } } diff --git a/vendor/go.opentelemetry.io/collector/featuregate/flag.go b/vendor/go.opentelemetry.io/collector/featuregate/flag.go index 1c6f3a5e873..6f5a27070cf 100644 --- a/vendor/go.opentelemetry.io/collector/featuregate/flag.go +++ b/vendor/go.opentelemetry.io/collector/featuregate/flag.go @@ -5,6 +5,7 @@ package featuregate // import "go.opentelemetry.io/collector/featuregate" import ( "flag" + "fmt" "strings" "go.uber.org/multierr" @@ -57,6 +58,10 @@ func (f *flagValue) Set(s string) error { ids := strings.Split(s, ",") for i := range ids { id := ids[i] + if id == "" { + errs = multierr.Append(errs, fmt.Errorf("empty feature gate identifier at index %d", i)) + continue + } val := true switch id[0] { case '-': diff --git a/vendor/go.opentelemetry.io/contrib/propagators/aws/xray/idgenerator.go b/vendor/go.opentelemetry.io/contrib/propagators/aws/xray/idgenerator.go index df439448b57..7058ff45bfc 100644 --- a/vendor/go.opentelemetry.io/contrib/propagators/aws/xray/idgenerator.go +++ b/vendor/go.opentelemetry.io/contrib/propagators/aws/xray/idgenerator.go @@ -1,14 +1,13 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package xray // import "go.opentelemetry.io/contrib/propagators/aws/xray" +package xray import ( "context" - crand "crypto/rand" "encoding/binary" "encoding/hex" - "math/rand" + "math/rand/v2" "strconv" "sync" "time" @@ -18,19 +17,27 @@ import ( ) // IDGenerator is used for generating a new traceID and spanID. +// +// math/rand/v2's top-level generator is used instead of a per-instance +// math/rand.Rand seeded from crypto/rand: the former is safe for concurrent +// use without a mutex and, unlike a locally seeded math/rand.Rand, has no +// seed-read step that can silently fail and leave it deterministic. type IDGenerator struct { + // Mutex is embedded for backward compatibility but is not used internally. sync.Mutex - randSource *rand.Rand } var _ sdktrace.IDGenerator = &IDGenerator{} // NewSpanID returns a non-zero span ID from a randomly-chosen sequence. -func (gen *IDGenerator) NewSpanID(context.Context, trace.TraceID) trace.SpanID { - gen.Lock() - defer gen.Unlock() +func (gen *IDGenerator) NewSpanID(context.Context, trace.TraceID) trace.SpanID { //nolint:revive // ignore linter sid := trace.SpanID{} - _, _ = gen.randSource.Read(sid[:]) + for { + binary.NativeEndian.PutUint64(sid[:], rand.Uint64()) //nolint:gosec // G404: Use of weak random number generator (math/rand instead of crypto/rand) is ignored as this is not security-sensitive. + if sid.IsValid() { + break + } + } return sid } @@ -39,27 +46,26 @@ func (gen *IDGenerator) NewSpanID(context.Context, trace.TraceID) trace.SpanID { // - https://docs.aws.amazon.com/xray/latest/devguide/xray-api-sendingdata.html#xray-api-traceids // // span ID is from a randomly-chosen sequence. -func (gen *IDGenerator) NewIDs(context.Context) (trace.TraceID, trace.SpanID) { - gen.Lock() - defer gen.Unlock() - +func (gen *IDGenerator) NewIDs(context.Context) (trace.TraceID, trace.SpanID) { //nolint:revive // ignore linter tid := trace.TraceID{} currentTime := getCurrentTimeHex() copy(tid[:4], currentTime) - _, _ = gen.randSource.Read(tid[4:]) + binary.NativeEndian.PutUint64(tid[4:12], rand.Uint64()) //nolint:gosec // G404: Use of weak random number generator (math/rand instead of crypto/rand) is ignored as this is not security-sensitive. + binary.NativeEndian.PutUint32(tid[12:16], rand.Uint32()) //nolint:gosec // G404: Use of weak random number generator (math/rand instead of crypto/rand) is ignored as this is not security-sensitive. sid := trace.SpanID{} - _, _ = gen.randSource.Read(sid[:]) + for { + binary.NativeEndian.PutUint64(sid[:], rand.Uint64()) //nolint:gosec // G404: Use of weak random number generator (math/rand instead of crypto/rand) is ignored as this is not security-sensitive. + if sid.IsValid() { + break + } + } return tid, sid } // NewIDGenerator returns an IDGenerator reference used for sending traces to AWS X-Ray. func NewIDGenerator() *IDGenerator { - gen := &IDGenerator{} - var rngSeed int64 - _ = binary.Read(crand.Reader, binary.LittleEndian, &rngSeed) - gen.randSource = rand.New(rand.NewSource(rngSeed)) //nolint:gosec // G404: Use of weak random number generator (math/rand instead of crypto/rand) is ignored as this is not security-sensitive. - return gen + return &IDGenerator{} } func getCurrentTimeHex() []uint8 { diff --git a/vendor/go.opentelemetry.io/contrib/propagators/aws/xray/propagator.go b/vendor/go.opentelemetry.io/contrib/propagators/aws/xray/propagator.go index 8929bf05ff3..59f17c5ec41 100644 --- a/vendor/go.opentelemetry.io/contrib/propagators/aws/xray/propagator.go +++ b/vendor/go.opentelemetry.io/contrib/propagators/aws/xray/propagator.go @@ -3,7 +3,7 @@ // Package xray provides an OpenTelemetry propagator for the AWS XRAY // propagation format. -package xray // import "go.opentelemetry.io/contrib/propagators/aws/xray" +package xray import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/clients.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/clients.go index 3c1a625c067..d97fada29fb 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/clients.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/clients.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package otlptrace // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace" +package otlptrace import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/doc.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/doc.go index 09ad5eadb6f..5fd4bf5bb55 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/doc.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/doc.go @@ -7,4 +7,4 @@ See the official OTLP span exporter implementations: - [go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc], - [go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp]. */ -package otlptrace // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace" +package otlptrace diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/exporter.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/exporter.go index 30446bd28b6..037d485d5e0 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/exporter.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/exporter.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package otlptrace // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace" +package otlptrace import ( "context" @@ -97,9 +97,9 @@ func NewUnstarted(client Client) *Exporter { func (e *Exporter) MarshalLog() any { return struct { Type string - Client Client + Client string }{ Type: "otlptrace", - Client: e.client, + Client: fmt.Sprintf("%T", e.client), } } diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform/attribute.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform/attribute.go index 0d43a5dc5b7..86a34d3b9fb 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform/attribute.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform/attribute.go @@ -3,7 +3,7 @@ // Package tracetransform provides conversion functionality for the otlptrace // exporters. -package tracetransform // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform" +package tracetransform import ( commonpb "go.opentelemetry.io/proto/otlp/common/v1" @@ -97,6 +97,12 @@ func Value(v attribute.Value) *commonpb.AnyValue { Values: values(v.AsSlice()), }, } + case attribute.MAP: + av.Value = &commonpb.AnyValue_KvlistValue{ + KvlistValue: &commonpb.KeyValueList{ + Values: KeyValues(v.AsMap()), + }, + } case attribute.STRINGSLICE: av.Value = &commonpb.AnyValue_ArrayValue{ ArrayValue: &commonpb.ArrayValue{ diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform/instrumentation.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform/instrumentation.go index 43359c89449..078a9db0ab9 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform/instrumentation.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform/instrumentation.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package tracetransform // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform" +package tracetransform import ( commonpb "go.opentelemetry.io/proto/otlp/common/v1" diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform/resource.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform/resource.go index 526bb5e070b..14e5bdc5630 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform/resource.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform/resource.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package tracetransform // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform" +package tracetransform import ( resourcepb "go.opentelemetry.io/proto/otlp/resource/v1" diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform/span.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform/span.go index d431fc4517d..3ab14b54fd1 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform/span.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform/span.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package tracetransform // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform" +package tracetransform import ( "math" @@ -37,21 +37,22 @@ func Spans(sdl []tracesdk.ReadOnlySpan) []*tracepb.ResourceSpans { } rKey := sd.Resource().Equivalent() + scope := sd.InstrumentationScope() k := key{ r: rKey, - is: sd.InstrumentationScope(), + is: scope, } scopeSpan, iOk := ssm[k] if !iOk { // Either the resource or instrumentation scope were unknown. scopeSpan = &tracepb.ScopeSpans{ - Scope: InstrumentationScope(sd.InstrumentationScope()), + Scope: InstrumentationScope(scope), Spans: []*tracepb.Span{}, - SchemaUrl: sd.InstrumentationScope().SchemaURL, + SchemaUrl: scope.SchemaURL, } + ssm[k] = scopeSpan } scopeSpan.Spans = append(scopeSpan.Spans, span(sd)) - ssm[k] = scopeSpan rs, rOk := rsm[rKey] if !rOk { @@ -90,14 +91,16 @@ func span(sd tracesdk.ReadOnlySpan) *tracepb.Span { return nil } - tid := sd.SpanContext().TraceID() - sid := sd.SpanContext().SpanID() + spanContext := sd.SpanContext() + tid := spanContext.TraceID() + sid := spanContext.SpanID() + sdStatus := sd.Status() s := &tracepb.Span{ TraceId: tid[:], SpanId: sid[:], - TraceState: sd.SpanContext().TraceState().String(), - Status: status(sd.Status().Code, sd.Status().Description), + TraceState: spanContext.TraceState().String(), + Status: status(sdStatus.Code, sdStatus.Description), StartTimeUnixNano: uint64(max(0, sd.StartTime().UnixNano())), // nolint:gosec // Overflow checked. EndTimeUnixNano: uint64(max(0, sd.EndTime().UnixNano())), // nolint:gosec // Overflow checked. Links: links(sd.Links()), @@ -110,10 +113,11 @@ func span(sd tracesdk.ReadOnlySpan) *tracepb.Span { DroppedLinksCount: clampUint32(sd.DroppedLinks()), } - if psid := sd.Parent().SpanID(); psid.IsValid() { + sdParent := sd.Parent() + if psid := sdParent.SpanID(); psid.IsValid() { s.ParentSpanId = psid[:] } - s.Flags = buildSpanFlagsWith(sd.SpanContext().TraceFlags(), sd.Parent()) + s.Flags = buildSpanFlagsWith(spanContext.TraceFlags(), sdParent) return s } diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/client.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/client.go index e8b33d3fa55..494bece44ea 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/client.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/client.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package otlptracegrpc // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" +package otlptracegrpc import ( "context" @@ -328,12 +328,10 @@ func throttleDelay(s *status.Status) (bool, time.Duration) { } // MarshalLog is the marshaling function used by the logging system to represent this Client. -func (c *client) MarshalLog() any { +func (*client) MarshalLog() any { return struct { - Type string - Endpoint string + Type string }{ - Type: "otlptracegrpc", - Endpoint: c.endpoint, + Type: "otlptracegrpc", } } diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/doc.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/doc.go index b7bd429ffdf..b01358fc83c 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/doc.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/doc.go @@ -62,4 +62,4 @@ The configuration can be overridden by [WithTLSCredentials], [WithGRPCConn] opti [W3C Baggage HTTP Header Content Format]: https://www.w3.org/TR/baggage/#header-content */ -package otlptracegrpc // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" +package otlptracegrpc diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/exporter.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/exporter.go index b826b84247e..d75b18443d3 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/exporter.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/exporter.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package otlptracegrpc // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" +package otlptracegrpc import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/counter/counter.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/counter/counter.go index 323b2a2c9a6..57c6acb781d 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/counter/counter.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/counter/counter.go @@ -1,14 +1,14 @@ -// Code generated by gotmpl. DO NOT MODIFY. -// source: internal/shared/counter/counter.go.tmpl - // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +// DO NOT MODIFY. Generated by gotmpl. +// source: internal/shared/counter/counter.go.tmpl + // Package counter provides a simple counter for generating unique IDs. // // This package is used to generate unique IDs while allowing testing packages // to reset the counter. -package counter // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/counter" +package counter import "sync/atomic" diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/envconfig/envconfig.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/envconfig/envconfig.go index 6eacdf311d2..87764a6952d 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/envconfig/envconfig.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/envconfig/envconfig.go @@ -1,12 +1,12 @@ -// Code generated by gotmpl. DO NOT MODIFY. -// source: internal/shared/otlp/envconfig/envconfig.go.tmpl - // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +// DO NOT MODIFY. Generated by gotmpl. +// source: internal/shared/otlp/envconfig/envconfig.go.tmpl + // Package envconfig provides functionality to parse configuration from // environment variables. -package envconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/envconfig" +package envconfig import ( "crypto/tls" @@ -60,7 +60,7 @@ func WithString(n string, fn func(string)) func(e *EnvOptionsReader) { func WithBool(n string, fn func(bool)) ConfigFn { return func(e *EnvOptionsReader) { if v, ok := e.GetEnvValue(n); ok { - b := strings.ToLower(v) == "true" + b := strings.EqualFold(v, "true") fn(b) } } diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/gen.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/gen.go index 7fe9c9f3a33..ec16d01457f 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/gen.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/gen.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // Package internal provides internal functionally for the otlptracegrpc package. -package internal // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal" +package internal //go:generate gotmpl --body=../../../../../internal/shared/otlp/partialsuccess.go.tmpl "--data={}" --out=partialsuccess.go //go:generate gotmpl --body=../../../../../internal/shared/otlp/partialsuccess_test.go.tmpl "--data={}" --out=partialsuccess_test.go @@ -27,8 +27,8 @@ package internal // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/ot //go:generate gotmpl --body=../../../../../internal/shared/x/x.go.tmpl "--data={ \"pkg\": \"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc\" }" --out=x/x.go //go:generate gotmpl --body=../../../../../internal/shared/x/x_test.go.tmpl "--data={}" --out=x/x_test.go -//go:generate gotmpl --body=../../../../../internal/shared/otlp/observ/target.go.tmpl "--data={ \"pkg\": \"observ\", \"pkg_path\": \"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/observ\" }" --out=observ/target.go +//go:generate gotmpl --body=../../../../../internal/shared/otlp/observ/target.go.tmpl "--data={ \"pkg\": \"observ\" }" --out=observ/target.go //go:generate gotmpl --body=../../../../../internal/shared/otlp/observ/target_test.go.tmpl "--data={ \"pkg\": \"observ\" }" --out=observ/target_test.go -//go:generate gotmpl --body=../../../../../internal/shared/counter/counter.go.tmpl "--data={ \"pkg\": \"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/counter\" }" --out=counter/counter.go +//go:generate gotmpl --body=../../../../../internal/shared/counter/counter.go.tmpl "--data={}" --out=counter/counter.go //go:generate gotmpl --body=../../../../../internal/shared/counter/counter_test.go.tmpl "--data={}" --out=counter/counter_test.go diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/observ/doc.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/observ/doc.go index 0dd54e4b969..32188bf72be 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/observ/doc.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/observ/doc.go @@ -3,4 +3,4 @@ // Package observ provides experimental observability instrumentation for the // otlptracegrpc exporter. -package observ // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/observ" +package observ diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/observ/instrumentation.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/observ/instrumentation.go index 676a93514bd..d6730bc1ecd 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/observ/instrumentation.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/observ/instrumentation.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package observ // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/observ" +package observ import ( "context" @@ -18,8 +18,8 @@ import ( "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/x" "go.opentelemetry.io/otel/internal/global" "go.opentelemetry.io/otel/metric" - semconv "go.opentelemetry.io/otel/semconv/v1.41.0" - "go.opentelemetry.io/otel/semconv/v1.41.0/otelconv" + semconv "go.opentelemetry.io/otel/semconv/v1.43.0" + "go.opentelemetry.io/otel/semconv/v1.43.0/otelconv" ) const ( diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/observ/target.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/observ/target.go index 34eee27db0d..4d066589417 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/observ/target.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/observ/target.go @@ -1,10 +1,10 @@ -// Code generated by gotmpl. DO NOT MODIFY. -// source: internal/shared/otlp/observ/target.go.tmpl - // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package observ // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/observ" +// DO NOT MODIFY. Generated by gotmpl. +// source: internal/shared/otlp/observ/target.go.tmpl + +package observ import ( "errors" @@ -41,11 +41,10 @@ func ParseCanonicalTarget(target string) (string, int, error) { const sep = "://" // Find scheme. Do not allocate the string by using url.Parse. - idx := strings.Index(target, sep) - if idx == -1 { + scheme, endpoint, found := strings.Cut(target, sep) + if !found { return "", -1, fmt.Errorf("invalid target %q: missing scheme", target) } - scheme, endpoint := target[:idx], target[idx+len(sep):] // Check for unix schemes. if scheme == schemeUnix || scheme == schemeUnixAbstract { diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/envconfig.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/envconfig.go index 1d840be205b..8b3f729fde2 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/envconfig.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/envconfig.go @@ -1,10 +1,10 @@ -// Code generated by gotmpl. DO NOT MODIFY. -// source: internal/shared/otlp/otlptrace/otlpconfig/envconfig.go.tmpl - // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig" +// DO NOT MODIFY. Generated by gotmpl. +// source: internal/shared/otlp/otlptrace/otlpconfig/envconfig.go.tmpl + +package otlpconfig import ( "crypto/tls" @@ -49,31 +49,37 @@ func getOptionsFromEnv() []GenericOption { tlsConf := &tls.Config{} DefaultEnvOptionsReader.Apply( envconfig.WithURL("ENDPOINT", func(u *url.URL) { - opts = append(opts, withEndpointScheme(u)) - opts = append(opts, newSplitOption(func(cfg Config) Config { - cfg.Traces.Endpoint = u.Host - // For OTLP/HTTP endpoint URLs without a per-signal - // configuration, the passed endpoint is used as a base URL - // and the signals are sent to these paths relative to that. - cfg.Traces.URLPath = path.Join(u.Path, DefaultTracesPath) - return cfg - }, withEndpointForGRPC(u))) + opts = append( + opts, + withEndpointScheme(u), + newSplitOption(func(cfg Config) Config { + cfg.Traces.Endpoint = u.Host + // For OTLP/HTTP endpoint URLs without a per-signal + // configuration, the passed endpoint is used as a base URL + // and the signals are sent to these paths relative to that. + cfg.Traces.URLPath = path.Join(u.Path, DefaultTracesPath) + return cfg + }, withEndpointForGRPC(u)), + ) }), envconfig.WithURL("TRACES_ENDPOINT", func(u *url.URL) { - opts = append(opts, withEndpointScheme(u)) - opts = append(opts, newSplitOption(func(cfg Config) Config { - cfg.Traces.Endpoint = u.Host - // For endpoint URLs for OTLP/HTTP per-signal variables, the - // URL MUST be used as-is without any modification. The only - // exception is that if an URL contains no path part, the root - // path / MUST be used. - path := u.Path - if path == "" { - path = "/" - } - cfg.Traces.URLPath = path - return cfg - }, withEndpointForGRPC(u))) + opts = append( + opts, + withEndpointScheme(u), + newSplitOption(func(cfg Config) Config { + cfg.Traces.Endpoint = u.Host + // For endpoint URLs for OTLP/HTTP per-signal variables, the + // URL MUST be used as-is without any modification. The only + // exception is that if an URL contains no path part, the root + // path / MUST be used. + path := u.Path + if path == "" { + path = "/" + } + cfg.Traces.URLPath = path + return cfg + }, withEndpointForGRPC(u)), + ) }), envconfig.WithCertPool("CERTIFICATE", func(p *x509.CertPool) { tlsConf.RootCAs = p }), envconfig.WithCertPool("TRACES_CERTIFICATE", func(p *x509.CertPool) { tlsConf.RootCAs = p }), @@ -142,7 +148,7 @@ func withInsecure(b bool) GenericOption { } func withTLSConfig(c *tls.Config, fn func(*tls.Config)) func(e *envconfig.EnvOptionsReader) { - return func(e *envconfig.EnvOptionsReader) { + return func(*envconfig.EnvOptionsReader) { if c.RootCAs != nil || len(c.Certificates) > 0 { fn(c) } diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/options.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/options.go index d940b67625f..36cf1e267cb 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/options.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/options.go @@ -1,11 +1,11 @@ -// Code generated by gotmpl. DO NOT MODIFY. -// source: internal/shared/otlp/otlptrace/otlpconfig/options.go.tmpl - // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +// DO NOT MODIFY. Generated by gotmpl. +// source: internal/shared/otlp/otlptrace/otlpconfig/options.go.tmpl + // Package otlpconfig provides configuration for the otlptrace exporters. -package otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig" +package otlpconfig import ( "crypto/tls" @@ -99,7 +99,7 @@ func NewHTTPConfig(opts ...HTTPOption) Config { // cleanPath returns a path with all spaces trimmed. If urlPath is empty, // defaultPath is returned instead. -func cleanPath(urlPath string, defaultPath string) string { +func cleanPath(urlPath, defaultPath string) string { tmp := strings.TrimSpace(urlPath) if tmp == "" || tmp == "." { return defaultPath @@ -134,7 +134,7 @@ func NewGRPCConfig(opts ...GRPCOption) Config { cfg.DialOptions = append(cfg.DialOptions, grpc.WithDefaultServiceConfig(cfg.ServiceConfig)) } // Prioritize GRPCCredentials over Insecure (passing both is an error). - if cfg.Traces.GRPCCredentials != nil { + if cfg.Traces.GRPCCredentials != nil { //nolint:gocritic // if-else is clearer than switch cfg.DialOptions = append(cfg.DialOptions, grpc.WithTransportCredentials(cfg.Traces.GRPCCredentials)) } else if cfg.Traces.Insecure { cfg.DialOptions = append(cfg.DialOptions, grpc.WithTransportCredentials(insecure.NewCredentials())) @@ -228,7 +228,7 @@ func (g *splitOption) ApplyHTTPOption(cfg Config) Config { func (splitOption) private() {} -func newSplitOption(httpFn func(cfg Config) Config, grpcFn func(cfg Config) Config) GenericOption { +func newSplitOption(httpFn, grpcFn func(cfg Config) Config) GenericOption { return &splitOption{httpFn: httpFn, grpcFn: grpcFn} } @@ -286,6 +286,11 @@ func WithEndpointURL(v string) GenericOption { cfg.Traces.Endpoint = u.Host cfg.Traces.URLPath = u.Path + if cfg.Traces.URLPath == "" { + // For HTTP exporters, a URL without a path targets the root path. Set it explicitly so the default signal + // path is not appended by cleanPath. (URLPath is ignored by gRPC exporters.) + cfg.Traces.URLPath = "/" + } cfg.Traces.Insecure = u.Scheme != "https" return cfg diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/optiontypes.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/optiontypes.go index 91849038722..213c3605f20 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/optiontypes.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/optiontypes.go @@ -1,10 +1,10 @@ -// Code generated by gotmpl. DO NOT MODIFY. -// source: internal/shared/otlp/otlptrace/otlpconfig/optiontypes.go.tmpl - // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig" +// DO NOT MODIFY. Generated by gotmpl. +// source: internal/shared/otlp/otlptrace/otlpconfig/optiontypes.go.tmpl + +package otlpconfig const ( // DefaultCollectorGRPCPort is the default gRPC port of the collector. diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/tls.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/tls.go index ba6e411835f..a14d5e6ecfe 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/tls.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/tls.go @@ -1,10 +1,10 @@ -// Code generated by gotmpl. DO NOT MODIFY. -// source: internal/shared/otlp/otlptrace/otlpconfig/tls.go.tmpl - // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig" +// DO NOT MODIFY. Generated by gotmpl. +// source: internal/shared/otlp/otlptrace/otlpconfig/tls.go.tmpl + +package otlpconfig import ( "crypto/tls" diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/partialsuccess.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/partialsuccess.go index a811a07b352..1138f2e718b 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/partialsuccess.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/partialsuccess.go @@ -1,10 +1,10 @@ -// Code generated by gotmpl. DO NOT MODIFY. -// source: internal/shared/otlp/partialsuccess.go - // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package internal // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal" +// DO NOT MODIFY. Generated by gotmpl. +// source: internal/shared/otlp/partialsuccess.go + +package internal import "fmt" @@ -41,7 +41,7 @@ func (ps PartialSuccess) As(target any) bool { } // Is supports the errors.Is() interface. -func (ps PartialSuccess) Is(err error) bool { +func (PartialSuccess) Is(err error) bool { _, ok := err.(PartialSuccess) return ok } diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/retry/retry.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/retry/retry.go index a7b8e81a786..1883d0600a8 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/retry/retry.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/retry/retry.go @@ -1,13 +1,13 @@ -// Code generated by gotmpl. DO NOT MODIFY. -// source: internal/shared/otlp/retry/retry.go.tmpl - // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +// DO NOT MODIFY. Generated by gotmpl. +// source: internal/shared/otlp/retry/retry.go.tmpl + // Package retry provides request retry functionality that can perform // configurable exponential backoff for transient errors and honor any // explicit throttle responses received. -package retry // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/retry" +package retry import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/version.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/version.go index 28e51e443fc..942d37af7cb 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/version.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/version.go @@ -1,8 +1,8 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package internal // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal" +package internal // Version is the current release version of the OpenTelemetry OTLP gRPC trace // exporter in use. -const Version = "1.44.0" +const Version = "1.45.0" diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/x/observ.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/x/observ.go index 4e89c6524f0..76b6fdebdb0 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/x/observ.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/x/observ.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package x // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/x" +package x import "strings" diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/x/x.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/x/x.go index 741ba62c97f..69ce31eef35 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/x/x.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/x/x.go @@ -1,11 +1,11 @@ -// Code generated by gotmpl. DO NOT MODIFY. -// source: internal/shared/x/x.go.tmpl - // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +// DO NOT MODIFY. Generated by gotmpl. +// source: internal/shared/x/x.go.tmpl + // Package x documents experimental features for [go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc]. -package x // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/x" +package x import ( "os" diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/options.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/options.go index b320060525e..ea20363c05f 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/options.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/options.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package otlptracegrpc // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" +package otlptracegrpc import ( "fmt" diff --git a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/version.go b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/version.go index d847210dbaf..da70f3f5402 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/version.go +++ b/vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/version.go @@ -1,9 +1,9 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package otlptrace // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace" +package otlptrace // Version is the current release version of the OpenTelemetry OTLP trace exporter in use. func Version() string { - return "1.44.0" + return "1.45.0" } diff --git a/vendor/go.opentelemetry.io/otel/sdk/instrumentation/doc.go b/vendor/go.opentelemetry.io/otel/sdk/instrumentation/doc.go index a4faa6a03d5..39b34eabeae 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/instrumentation/doc.go +++ b/vendor/go.opentelemetry.io/otel/sdk/instrumentation/doc.go @@ -10,4 +10,4 @@ // and // https://github.com/open-telemetry/oteps/blob/d226b677d73a785523fe9b9701be13225ebc528d/text/0201-scope-attributes.md // for more information. -package instrumentation // import "go.opentelemetry.io/otel/sdk/instrumentation" +package instrumentation diff --git a/vendor/go.opentelemetry.io/otel/sdk/instrumentation/library.go b/vendor/go.opentelemetry.io/otel/sdk/instrumentation/library.go index f2cdf3c6518..8baf8dbb359 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/instrumentation/library.go +++ b/vendor/go.opentelemetry.io/otel/sdk/instrumentation/library.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package instrumentation // import "go.opentelemetry.io/otel/sdk/instrumentation" +package instrumentation // Library represents the instrumentation library. // diff --git a/vendor/go.opentelemetry.io/otel/sdk/instrumentation/scope.go b/vendor/go.opentelemetry.io/otel/sdk/instrumentation/scope.go index 34852a47b21..1fd06db75b7 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/instrumentation/scope.go +++ b/vendor/go.opentelemetry.io/otel/sdk/instrumentation/scope.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package instrumentation // import "go.opentelemetry.io/otel/sdk/instrumentation" +package instrumentation import "go.opentelemetry.io/otel/attribute" diff --git a/vendor/go.opentelemetry.io/otel/sdk/internal/attrnorm/dedup.go b/vendor/go.opentelemetry.io/otel/sdk/internal/attrnorm/dedup.go new file mode 100644 index 00000000000..fe9ddc96db7 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/sdk/internal/attrnorm/dedup.go @@ -0,0 +1,300 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// DO NOT MODIFY. Generated by gotmpl. +// source: internal/shared/attrnorm/dedup.go.tmpl + +// Package attrnorm normalizes attribute values. +package attrnorm + +import ( + "reflect" + "unsafe" + + "go.opentelemetry.io/otel/attribute" +) + +var ( + keyValueType = reflect.TypeFor[attribute.KeyValue]() + valueType = reflect.TypeFor[attribute.Value]() +) + +// rawValue mirrors attribute.Value. It is used only to read immutable slice +// storage without calling AsMap or AsSlice on no-op paths. +type rawValue struct { + vtype attribute.Type + numeric uint64 + stringly string + slice any +} + +// Value returns value with all map values deduplicated and whether it changed. +// +// Duplicate map keys are resolved using last-value-wins semantics. +func Value(value attribute.Value) (attribute.Value, bool) { + switch value.Type() { + case attribute.SLICE: + return deduplicateSliceValue(value) + case attribute.MAP: + return deduplicateMapValue(value) + default: + return value, false + } +} + +// KeyValue returns kv with all map values deduplicated and whether it changed. +func KeyValue(kv attribute.KeyValue) (attribute.KeyValue, bool) { + value, changed := Value(kv.Value) + if changed { + kv.Value = value + } + return kv, changed +} + +// KeyValues returns kvs with all map values deduplicated and whether they changed. +// +// The returned slice is the original kvs slice if no value needs +// deduplication. Top-level keys in kvs are not deduplicated. +func KeyValues(kvs []attribute.KeyValue) ([]attribute.KeyValue, bool) { + // Preserve the caller's slice on the common no-op path. Once a changed + // value is found, copy the prior values exactly once and fill the rest in + // place as the scan continues. + var normalized []attribute.KeyValue + for i, kv := range kvs { + kv, changed := KeyValue(kv) + if normalized != nil { + normalized[i] = kv + continue + } + if !changed { + continue + } + + normalized = make([]attribute.KeyValue, len(kvs)) + copy(normalized, kvs[:i]) + normalized[i] = kv + } + if normalized == nil { + return kvs, false + } + return normalized, true +} + +// Set returns set with all map values deduplicated and whether it changed. +// +// The returned Set is the original set if no value needs deduplication. +// Top-level key uniqueness remains attribute.Set's responsibility; this only +// normalizes map attribute values. +func Set(set attribute.Set) (attribute.Set, bool) { + if set.Len() == 0 { + return set, false + } + + // Most attribute sets contain no duplicate map keys. Delay allocation until + // the first changed value so the no-op path returns the original Set. + var normalized []attribute.KeyValue + for i := range set.Len() { + kv, _ := set.Get(i) + kv, changed := KeyValue(kv) + if normalized != nil { + normalized = append(normalized, kv) + continue + } + if !changed { + continue + } + + normalized = make([]attribute.KeyValue, 0, set.Len()) + for j := range i { + prior, _ := set.Get(j) + normalized = append(normalized, prior) + } + normalized = append(normalized, kv) + } + if normalized == nil { + return set, false + } + + return attribute.NewSet(normalized...), true +} + +func deduplicateSliceValue(value attribute.Value) (attribute.Value, bool) { + storage := valueStorage(value) + length := valueLen(storage) + + // Slice values can contain map values, so recurse into each element while + // keeping the original attribute.Value when no element changes. + var normalized []attribute.Value + for i := range length { + elem := valueAt(storage, i) + elem, changed := Value(elem) + if normalized != nil { + normalized[i] = elem + continue + } + if !changed { + continue + } + + normalized = make([]attribute.Value, length) + for j := range i { + normalized[j] = valueAt(storage, j) + } + normalized[i] = elem + } + if normalized == nil { + return value, false + } + return attribute.SliceValue(normalized...), true +} + +func deduplicateMapValue(value attribute.Value) (attribute.Value, bool) { + storage := valueStorage(value) + length := keyValueLen(storage) + if length <= 1 { + // A single map entry cannot duplicate its own key, but its value might + // contain a map or slice that needs recursive normalization. + if length == 1 { + kv, changed := KeyValue(keyValueAt(storage, 0)) + if changed { + return attribute.MapValue(kv), true + } + } + return value, false + } + + var normalized []attribute.KeyValue + for i := 0; i < length; { + // attribute.MapValue stores key-values sorted by key using a stable + // sort. Equal keys therefore form a contiguous run, and the last + // element in that run is the last value provided by the caller. + first := keyValueAt(storage, i) + j := i + 1 + for j < length && keyValueAt(storage, j).Key == first.Key { + j++ + } + + kv, nestedChanged := KeyValue(keyValueAt(storage, j-1)) + // j-i > 1 means the current key run contained duplicates. + changed := nestedChanged || j-i > 1 + if normalized != nil { + normalized = append(normalized, kv) + } else if changed { + normalized = make([]attribute.KeyValue, 0, length) + for k := range i { + normalized = append(normalized, keyValueAt(storage, k)) + } + normalized = append(normalized, kv) + } + i = j + } + if normalized == nil { + return value, false + } + return attribute.MapValue(normalized...), true +} + +func valueStorage(value attribute.Value) any { + // attribute.Value does not expose allocation-free map/slice iteration. + // The raw mirror lets us read the immutable backing array directly and + // reserve AsMap/AsSlice-style allocation for paths that actually change. + return (*rawValue)( + unsafe.Pointer(&value), + ).slice //nolint:gosec // Read-only mirror of attribute.Value for allocation-free iteration. +} + +func valueLen(storage any) int { + // attribute.Value stores small slices in fixed-size array values. Handle + // the common sizes directly and fall back to reflection for larger arrays. + switch storage.(type) { + case [0]attribute.Value: + return 0 + case [1]attribute.Value: + return 1 + case [2]attribute.Value: + return 2 + case [3]attribute.Value: + return 3 + case [4]attribute.Value: + return 4 + case [5]attribute.Value: + return 5 + default: + return arrayLen(storage, valueType) + } +} + +func valueAt(storage any, i int) attribute.Value { + switch values := storage.(type) { + case [1]attribute.Value: + return values[i] + case [2]attribute.Value: + return values[i] + case [3]attribute.Value: + return values[i] + case [4]attribute.Value: + return values[i] + case [5]attribute.Value: + return values[i] + default: + return arrayAt[attribute.Value](storage, valueType, i) + } +} + +func keyValueLen(storage any) int { + // attribute.Value stores small maps in fixed-size key-value arrays. Handle + // the common sizes directly and fall back to reflection for larger arrays. + switch storage.(type) { + case [0]attribute.KeyValue: + return 0 + case [1]attribute.KeyValue: + return 1 + case [2]attribute.KeyValue: + return 2 + case [3]attribute.KeyValue: + return 3 + case [4]attribute.KeyValue: + return 4 + case [5]attribute.KeyValue: + return 5 + default: + return arrayLen(storage, keyValueType) + } +} + +func keyValueAt(storage any, i int) attribute.KeyValue { + switch kvs := storage.(type) { + case [1]attribute.KeyValue: + return kvs[i] + case [2]attribute.KeyValue: + return kvs[i] + case [3]attribute.KeyValue: + return kvs[i] + case [4]attribute.KeyValue: + return kvs[i] + case [5]attribute.KeyValue: + return kvs[i] + default: + return arrayAt[attribute.KeyValue](storage, keyValueType, i) + } +} + +func arrayLen(storage any, elem reflect.Type) int { + // Be defensive around invalid or unexpected Value storage. Returning zero + // makes malformed storage a no-op instead of panicking in telemetry paths. + array := reflect.ValueOf(storage) + if array.Kind() != reflect.Array || array.Type().Elem() != elem { + return 0 + } + return array.Len() +} + +func arrayAt[T any](storage any, elem reflect.Type, i int) T { + // Match arrayLen's fail-closed behavior for unexpected storage. + array := reflect.ValueOf(storage) + if array.Kind() != reflect.Array || array.Type().Elem() != elem || i < 0 || i >= array.Len() { + var zero T + return zero + } + return array.Index(i).Interface().(T) +} diff --git a/vendor/go.opentelemetry.io/otel/sdk/internal/attrnorm/truncate.go b/vendor/go.opentelemetry.io/otel/sdk/internal/attrnorm/truncate.go new file mode 100644 index 00000000000..9955e907268 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/sdk/internal/attrnorm/truncate.go @@ -0,0 +1,232 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// DO NOT MODIFY. Generated by gotmpl. +// source: internal/shared/attrnorm/truncate.go.tmpl + +package attrnorm + +import ( + "slices" + "strings" + "unicode/utf8" + + "go.opentelemetry.io/otel/attribute" +) + +// Truncate returns a truncated version of attr. Only string, string slice, +// byte slice, slice, and map attribute values are truncated. String values are +// truncated to at most a length of limit. Each string slice value is truncated +// in this fashion (the slice length itself is unaffected), and byte slice +// values are truncated to at most limit bytes. For slice and map attribute +// values, the limit is applied recursively to contained values. +// +// No truncation is performed for a negative limit. +func Truncate(limit int, attr attribute.KeyValue) attribute.KeyValue { + if limit < 0 { + return attr + } + switch attr.Value.Type() { + case attribute.STRING: + v := attr.Value.AsString() + return attr.Key.String(truncate(limit, v)) + case attribute.STRINGSLICE: + v := attr.Value.AsStringSlice() + for i := range v { + v[i] = truncate(limit, v[i]) + } + return attr.Key.StringSlice(v) + case attribute.BYTESLICE: + v := attr.Value.AsString() + if len(v) > limit { + return attr.Key.ByteSlice([]byte(v[:limit])) + } + return attr + case attribute.SLICE: + v := attr.Value.AsSlice() + if !slices.ContainsFunc(v, func(e attribute.Value) bool { return needsTruncation(limit, e) }) { + return attr + } + newV := make([]attribute.Value, len(v)) + for i, elem := range v { + newV[i] = TruncateValue(limit, elem) + } + return attr.Key.Slice(newV...) + case attribute.MAP: + v := attr.Value.AsMap() + if !slices.ContainsFunc(v, func(kv attribute.KeyValue) bool { return needsTruncation(limit, kv.Value) }) { + return attr + } + newV := make([]attribute.KeyValue, len(v)) + for i, elem := range v { + elem.Value = TruncateValue(limit, elem.Value) + newV[i] = elem + } + return attr.Key.Map(newV...) + } + return attr +} + +// TruncateValue returns a truncated version of v. Only string, string +// slice, byte slice, and (recursively) slice and map values are modified. +// +// No truncation is performed for a negative limit. +func TruncateValue(limit int, v attribute.Value) attribute.Value { + if limit < 0 { + return v + } + + switch v.Type() { + case attribute.STRING: + return attribute.StringValue(truncate(limit, v.AsString())) + case attribute.STRINGSLICE: + ss := v.AsStringSlice() + for i := range ss { + ss[i] = truncate(limit, ss[i]) + } + return attribute.StringSliceValue(ss) + case attribute.BYTESLICE: + // len(v.AsString()) is identical to len(v.AsByteSlice()) but + // avoids allocating the full slice before truncation. + s := v.AsString() + if limit >= 0 && len(s) > limit { + return attribute.ByteSliceValue([]byte(s[:limit])) + } + case attribute.SLICE: + sl := v.AsSlice() + if !slices.ContainsFunc(sl, func(e attribute.Value) bool { return needsTruncation(limit, e) }) { + return v + } + newSl := make([]attribute.Value, len(sl)) + for i, elem := range sl { + newSl[i] = TruncateValue(limit, elem) + } + return attribute.SliceValue(newSl...) + case attribute.MAP: + m := v.AsMap() + if !slices.ContainsFunc(m, func(kv attribute.KeyValue) bool { return needsTruncation(limit, kv.Value) }) { + return v + } + newM := make([]attribute.KeyValue, len(m)) + for i, elem := range m { + elem.Value = TruncateValue(limit, elem.Value) + newM[i] = elem + } + return attribute.MapValue(newM...) + } + return v +} + +// stringNeedsTruncation reports whether s would be modified by truncate for the +// given limit. +func stringNeedsTruncation(limit int, s string) bool { + if limit < 0 || len(s) <= limit { + return false + } + return utf8.RuneCountInString(s) > limit || !utf8.ValidString(s) +} + +// needsTruncation reports whether v would be modified by TruncateValue for the +// given limit. +func needsTruncation(limit int, v attribute.Value) bool { + switch v.Type() { + case attribute.STRING: + return stringNeedsTruncation(limit, v.AsString()) + case attribute.BYTESLICE: + // len(v.AsString()) is identical to len(v.AsByteSlice()) but + // avoids memory allocation. + if limit >= 0 && len(v.AsString()) > limit { + return true + } + case attribute.STRINGSLICE: + for _, s := range v.AsStringSlice() { + if stringNeedsTruncation(limit, s) { + return true + } + } + case attribute.SLICE: + return slices.ContainsFunc(v.AsSlice(), func(e attribute.Value) bool { return needsTruncation(limit, e) }) + case attribute.MAP: + return slices.ContainsFunc( + v.AsMap(), + func(kv attribute.KeyValue) bool { return needsTruncation(limit, kv.Value) }, + ) + } + return false +} + +// truncate returns a truncated version of s such that it contains less than +// the limit number of characters. Truncation is applied by returning the limit +// number of valid characters contained in s. +// +// If limit is negative, it returns the original string. +// +// UTF-8 is supported. When truncating, all invalid characters are dropped +// before applying truncation. +// +// If s already contains less than the limit number of bytes, it is returned +// unchanged. No invalid characters are removed. +func truncate(limit int, s string) string { + // This prioritize performance in the following order based on the most + // common expected use-cases. + // + // - Short values less than the default limit (128). + // - Strings with valid encodings that exceed the limit. + // - No limit. + // - Strings with invalid encodings that exceed the limit. + if limit < 0 || len(s) <= limit { + return s + } + + // Optimistically, assume all valid UTF-8. + var b strings.Builder + count := 0 + for i, c := range s { + if c != utf8.RuneError { + count++ + if count > limit { + return s[:i] + } + continue + } + + _, size := utf8.DecodeRuneInString(s[i:]) + if size == 1 { + // Invalid encoding. + b.Grow(len(s) - 1) + _, _ = b.WriteString(s[:i]) + s = s[i:] + break + } + } + + // Fast-path, no invalid input. + if b.Cap() == 0 { + return s + } + + // Truncate while validating UTF-8. + for i := 0; i < len(s) && count < limit; { + c := s[i] + if c < utf8.RuneSelf { + // Optimization for single byte runes (common case). + _ = b.WriteByte(c) + i++ + count++ + continue + } + + _, size := utf8.DecodeRuneInString(s[i:]) + if size == 1 { + // We checked for all 1-byte runes above, this is a RuneError. + i++ + continue + } + + _, _ = b.WriteString(s[i : i+size]) + i += size + count++ + } + + return b.String() +} diff --git a/vendor/go.opentelemetry.io/otel/sdk/internal/x/features.go b/vendor/go.opentelemetry.io/otel/sdk/internal/x/features.go index 694b64a3180..13ff34b276f 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/internal/x/features.go +++ b/vendor/go.opentelemetry.io/otel/sdk/internal/x/features.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // Package x documents experimental features for [go.opentelemetry.io/otel/sdk]. -package x // import "go.opentelemetry.io/otel/sdk/internal/x" +package x import "strings" diff --git a/vendor/go.opentelemetry.io/otel/sdk/internal/x/x.go b/vendor/go.opentelemetry.io/otel/sdk/internal/x/x.go index 13347e56052..e829d179488 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/internal/x/x.go +++ b/vendor/go.opentelemetry.io/otel/sdk/internal/x/x.go @@ -1,11 +1,11 @@ -// Code generated by gotmpl. DO NOT MODIFY. -// source: internal/shared/x/x.go.tmpl - // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +// DO NOT MODIFY. Generated by gotmpl. +// source: internal/shared/x/x.go.tmpl + // Package x documents experimental features for [go.opentelemetry.io/otel/sdk]. -package x // import "go.opentelemetry.io/otel/sdk/internal/x" +package x import ( "os" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/aggregation.go b/vendor/go.opentelemetry.io/otel/sdk/metric/aggregation.go index e6f5cfb2ad9..f52e7ea5421 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/aggregation.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/aggregation.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package metric // import "go.opentelemetry.io/otel/sdk/metric" +package metric import ( "errors" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/cache.go b/vendor/go.opentelemetry.io/otel/sdk/metric/cache.go index 63b88f08664..1d6f6a089aa 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/cache.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/cache.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package metric // import "go.opentelemetry.io/otel/sdk/metric" +package metric import ( "sync" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/config.go b/vendor/go.opentelemetry.io/otel/sdk/metric/config.go index dda4e086db8..444a8cfda91 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/config.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/config.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package metric // import "go.opentelemetry.io/otel/sdk/metric" +package metric import ( "context" @@ -157,6 +157,8 @@ func WithView(views ...View) Option { // exemplar reservoir, but the exemplar reservoir makes the final decision of // whether to store an exemplar. // +// The filter must not be nil. +// // By default, the [exemplar.TraceBasedFilter] // is used. Exemplars can be entirely disabled by providing the // [exemplar.AlwaysOffFilter]. diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/doc.go b/vendor/go.opentelemetry.io/otel/sdk/metric/doc.go index 51e168c7504..61410b33091 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/doc.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/doc.go @@ -86,4 +86,4 @@ // // See [go.opentelemetry.io/otel/sdk/metric/internal/x] for information about // the experimental features. -package metric // import "go.opentelemetry.io/otel/sdk/metric" +package metric diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/env.go b/vendor/go.opentelemetry.io/otel/sdk/metric/env.go index a6c403797f6..132664a7e61 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/env.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/env.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package metric // import "go.opentelemetry.io/otel/sdk/metric" +package metric import ( "os" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar.go b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar.go index 993f001ae91..fb124052c63 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package metric // import "go.opentelemetry.io/otel/sdk/metric" +package metric import ( "reflect" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/doc.go b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/doc.go index 9f238937688..f7e54761769 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/doc.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/doc.go @@ -3,4 +3,4 @@ // Package exemplar provides an implementation of the OpenTelemetry exemplar // reservoir to be used in metric collection pipelines. -package exemplar // import "go.opentelemetry.io/otel/sdk/metric/exemplar" +package exemplar diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/exemplar.go b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/exemplar.go index 1ab69467868..32913a6e5d4 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/exemplar.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/exemplar.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package exemplar // import "go.opentelemetry.io/otel/sdk/metric/exemplar" +package exemplar import ( "time" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/filter.go b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/filter.go index b50f5c1531c..a9efd20d1ad 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/filter.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/filter.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package exemplar // import "go.opentelemetry.io/otel/sdk/metric/exemplar" +package exemplar import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/fixed_size_reservoir.go b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/fixed_size_reservoir.go index ce97ab1bf72..48f2b464cb8 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/fixed_size_reservoir.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/fixed_size_reservoir.go @@ -1,12 +1,10 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package exemplar // import "go.opentelemetry.io/otel/sdk/metric/exemplar" +package exemplar import ( "context" - "math" - "math/rand/v2" "sync" "time" @@ -26,7 +24,12 @@ func FixedSizeReservoirProvider(k int) ReservoirProvider { // sample each one. If there are more than k, the Reservoir will then randomly // sample all additional measurement with a decreasing probability. func NewFixedSizeReservoir(k int) *FixedSizeReservoir { - return newFixedSizeReservoir(newStorage(k)) + r := &FixedSizeReservoir{ + storage: make([]measurement, k), + } + r.nt.k = k + r.nt.reset() + return r } var _ Reservoir = &FixedSizeReservoir{} @@ -37,43 +40,9 @@ var _ Reservoir = &FixedSizeReservoir{} // additional measurement with a decreasing probability. type FixedSizeReservoir struct { reservoir.ConcurrentSafe - *storage - mu sync.Mutex - - // count is the number of measurement seen. - count int64 - // next is the next count that will store a measurement at a random index - // once the reservoir has been filled. - next int64 - // w is the largest random number in a distribution that is used to compute - // the next next. - w float64 -} - -func newFixedSizeReservoir(s *storage) *FixedSizeReservoir { - r := &FixedSizeReservoir{ - storage: s, - } - if cap(r.measurements) > 0 { - r.reset() - } - return r -} - -// randomFloat64 returns, as a float64, a uniform pseudo-random number in the -// open interval (0.0,1.0). -func (*FixedSizeReservoir) randomFloat64() float64 { - // TODO: Use an algorithm that avoids rejection sampling. For example: - // - // const precision = 1 << 53 // 2^53 - // // Generate an integer in [1, 2^53 - 1] - // v := rand.Uint64() % (precision - 1) + 1 - // return float64(v) / float64(precision) - f := rand.Float64() - for f == 0 { - f = rand.Float64() - } - return f + mu sync.Mutex + storage []measurement + nt nextTracker } // Offer accepts the parameters associated with a measurement. The @@ -88,128 +57,39 @@ func (*FixedSizeReservoir) randomFloat64() float64 { // parameters are the value and dropped (filtered) attributes of the // measurement respectively. func (r *FixedSizeReservoir) Offer(ctx context.Context, t time.Time, n Value, a []attribute.KeyValue) { - if cap(r.measurements) == 0 { + if len(r.storage) == 0 { return } - // The following algorithm is "Algorithm L" from Li, Kim-Hung (4 December - // 1994). "Reservoir-Sampling Algorithms of Time Complexity - // O(n(1+log(N/n)))". ACM Transactions on Mathematical Software. 20 (4): - // 481–493 (https://dl.acm.org/doi/10.1145/198429.198435). - // - // A high-level overview of "Algorithm L": - // 0) Pre-calculate the random count greater than the storage size when - // an exemplar will be replaced. - // 1) Accept all measurements offered until the configured storage size is - // reached. - // 2) Loop: - // a) When the pre-calculate count is reached, replace a random - // existing exemplar with the offered measurement. - // b) Calculate the next random count greater than the existing one - // which will replace another exemplars - // - // The way a "replacement" count is computed is by looking at `n` number of - // independent random numbers each corresponding to an offered measurement. - // Of these numbers the smallest `k` (the same size as the storage - // capacity) of them are kept as a subset. The maximum value in this - // subset, called `w` is used to weight another random number generation - // for the next count that will be considered. - // - // By weighting the next count computation like described, it is able to - // perform a uniformly-weighted sampling algorithm based on the number of - // samples the reservoir has seen so far. The sampling will "slow down" as - // more and more samples are offered so as to reduce a bias towards those - // offered just prior to the end of the collection. - // - // This algorithm is preferred because of its balance of simplicity and - // performance. It will compute three random numbers (the bulk of - // computation time) for each item that becomes part of the reservoir, but - // it does not spend any time on items that do not. In particular it has an - // asymptotic runtime of O(k(1 + log(n/k)) where n is the number of - // measurements offered and k is the reservoir size. - // - // See https://en.wikipedia.org/wiki/Reservoir_sampling for an overview of - // this and other reservoir sampling algorithms. See - // https://github.com/MrAlias/reservoir-sampling for a performance - // comparison of reservoir sampling algorithms. - r.mu.Lock() defer r.mu.Unlock() - if int(r.count) < cap(r.measurements) { - r.store(ctx, int(r.count), t, n, a) - } else if r.count == r.next { - // Overwrite a random existing measurement with the one offered. - idx := int(rand.Int64N(int64(cap(r.measurements)))) - r.store(ctx, idx, t, n, a) - r.advance() + sampled, idx := r.nt.shouldSample() + if sampled { + r.storage[idx].store(ctx, t, n, a) } - r.count++ -} - -// reset resets r to the initial state. -func (r *FixedSizeReservoir) reset() { - // This resets the number of exemplars known. - r.count = 0 - // Random index inserts should only happen after the storage is full. - r.next = int64(cap(r.measurements)) - - // Initial random number in the series used to generate r.next. - // - // This is set before r.advance to reset or initialize the random number - // series. Without doing so it would always be 0 or never restart a new - // random number series. - // - // This maps the uniform random number in (0,1) to a geometric distribution - // over the same interval. The mean of the distribution is inversely - // proportional to the storage capacity. - r.w = math.Exp(math.Log(r.randomFloat64()) / float64(cap(r.measurements))) - - r.advance() -} - -// advance updates the count at which the offered measurement will overwrite an -// existing exemplar. -func (r *FixedSizeReservoir) advance() { - // Calculate the next value in the random number series. - // - // The current value of r.w is based on the max of a distribution of random - // numbers (i.e. `w = max(u_1,u_2,...,u_k)` for `k` equal to the capacity - // of the storage and each `u` in the interval (0,w)). To calculate the - // next r.w we use the fact that when the next exemplar is selected to be - // included in the storage an existing one will be dropped, and the - // corresponding random number in the set used to calculate r.w will also - // be replaced. The replacement random number will also be within (0,w), - // therefore the next r.w will be based on the same distribution (i.e. - // `max(u_1,u_2,...,u_k)`). Therefore, we can sample the next r.w by - // computing the next random number `u` and take r.w as `w * u^(1/k)`. - r.w *= math.Exp(math.Log(r.randomFloat64()) / float64(cap(r.measurements))) - // Use the new random number in the series to calculate the count of the - // next measurement that will be stored. - // - // Given 0 < r.w < 1, each iteration will result in subsequent r.w being - // smaller. This translates here into the next next being selected against - // a distribution with a higher mean (i.e. the expected value will increase - // and replacements become less likely) - // - // Important to note, the new r.next will always be at least 1 more than - // the last r.next. - r.next += int64(math.Log(r.randomFloat64())/math.Log(1-r.w)) + 1 } // Collect returns all the held exemplars. // -// The Reservoir state is preserved after this call. +// The stored exemplars are preserved after this call, but the sampling state is reset. func (r *FixedSizeReservoir) Collect(dest *[]Exemplar) { - if cap(r.measurements) == 0 { + if len(r.storage) == 0 { *dest = (*dest)[:0] return } r.mu.Lock() defer r.mu.Unlock() - r.storage.Collect(dest) + *dest = reset(*dest, len(r.storage), len(r.storage)) + var n int + for i := range r.storage { + if r.storage[i].exemplar(&(*dest)[n]) { + n++ + } + } + *dest = (*dest)[:n] // Call reset here even though it will reset r.count and restart the random // number series. This will persist any old exemplars as long as no new // measurements are offered, but it will also prioritize those new // measurements that are made over the older collection cycle ones. - r.reset() + r.nt.reset() } diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/histogram_reservoir.go b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/histogram_reservoir.go index dacac3ebaec..e1001e4dc74 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/histogram_reservoir.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/histogram_reservoir.go @@ -1,12 +1,13 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package exemplar // import "go.opentelemetry.io/otel/sdk/metric/exemplar" +package exemplar import ( "context" "slices" "sort" + "sync" "time" "go.opentelemetry.io/otel/attribute" @@ -22,29 +23,39 @@ func HistogramReservoirProvider(bounds []float64) ReservoirProvider { } } -// NewHistogramReservoir returns a [HistogramReservoir] that samples the last -// measurement that falls within a histogram bucket. The histogram bucket -// upper-boundaries are define by bounds. +type bucket struct { + mu sync.Mutex + nt nextTracker + measurement +} + +// NewHistogramReservoir returns a [HistogramReservoir] that samples +// measurements that fall within a histogram bucket using Algorithm L. The +// histogram bucket upper-boundaries are defined by bounds. // // The passed bounds must be sorted before calling this function. func NewHistogramReservoir(bounds []float64) *HistogramReservoir { + buckets := make([]bucket, len(bounds)+1) + for i := range buckets { + buckets[i].nt.k = 1 + buckets[i].nt.reset() + } return &HistogramReservoir{ bounds: bounds, - storage: newStorage(len(bounds) + 1), + buckets: buckets, } } var _ Reservoir = &HistogramReservoir{} -// HistogramReservoir is a [Reservoir] that samples the last measurement that -// falls within a histogram bucket. The histogram bucket upper-boundaries are -// define by bounds. +// HistogramReservoir is a [Reservoir] that samples +// measurements that fall within a histogram bucket using Algorithm L. The +// histogram bucket upper-boundaries are defined by bounds. type HistogramReservoir struct { reservoir.ConcurrentSafe - *storage - // bounds are bucket bounds in ascending order. - bounds []float64 + bounds []float64 + buckets []bucket } // Offer accepts the parameters associated with a measurement. The @@ -69,14 +80,31 @@ func (r *HistogramReservoir) Offer(ctx context.Context, t time.Time, v Value, a panic("unknown value type") } - idx := sort.SearchFloat64s(r.bounds, n) + b := &r.buckets[sort.SearchFloat64s(r.bounds, n)] - r.store(ctx, idx, t, v, a) + b.mu.Lock() + defer b.mu.Unlock() + + sampled, _ := b.nt.shouldSample() + if sampled { + b.store(ctx, t, v, a) + } } // Collect returns all the held exemplars. // -// The Reservoir state is preserved after this call. +// The stored exemplars are preserved after this call, but the sampling state is reset. func (r *HistogramReservoir) Collect(dest *[]Exemplar) { - r.storage.Collect(dest) + *dest = reset(*dest, len(r.buckets), len(r.buckets)) + var n int + for i := range r.buckets { + b := &r.buckets[i] + b.mu.Lock() + if b.exemplar(&(*dest)[n]) { + n++ + } + b.nt.reset() + b.mu.Unlock() + } + *dest = (*dest)[:n] } diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/next_tracker.go b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/next_tracker.go new file mode 100644 index 00000000000..da5eb241c81 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/next_tracker.go @@ -0,0 +1,154 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package exemplar + +import ( + "math" + "math/rand/v2" +) + +// nextTracker tracks the next measurement that should be sampled using Algorithm L. +type nextTracker struct { + // count is the number of measurements seen. + count int64 + // next is the next count that will store a measurement at a random index + // once the reservoir has been filled. + next int64 + // w is the largest random number in a distribution that is used to compute + // the next next. + w float64 + // k is the size of the reservoir. + k int +} + +// reset resets the tracker to the initial state for a reservoir of size k. +func (t *nextTracker) reset() { + t.count = 0 + if t.k <= 0 { + return + } + // Random index inserts should only happen after the storage is full. + // -1 accounts for the fact that advance() will unconditionally add 1 to + // t.next below. + t.next = int64(t.k) - 1 + + // Initial random number in the series used to generate t.next. + // + // This is set before t.advance to reset or initialize the random number + // series. Without doing so it would always be 0 or never restart a new + // random number series. + // + // This maps the uniform random number in (0,1) to a geometric distribution + // over the same interval. The mean of the distribution is inversely + // proportional to the storage capacity. + t.w = math.Exp(math.Log(randomFloat64()) / float64(t.k)) + t.advance() +} + +// advance updates the count at which the offered measurement will overwrite an +// existing exemplar. +func (t *nextTracker) advance() { + // Use the current random number in the series to calculate the count of the + // next measurement that will be stored. + // + // Given 0 < t.w < 1, each iteration will result in subsequent t.w being + // smaller. This translates here into the next next being selected against + // a distribution with a higher mean (i.e. the expected value will increase + // and replacements become less likely) + // + // Important to note, the new t.next will always be at least 1 more than + // the last t.next. + t.next += int64(math.Log(randomFloat64())/math.Log(1-t.w)) + 1 + + // Calculate the next value in the random number series. + // + // The current value of t.w is based on the max of a distribution of random + // numbers (i.e. `w = max(u_1,u_2,...,u_k)` for `k` equal to the capacity + // of the storage and each `u` in the interval (0,w)). To calculate the + // next t.w we use the fact that when the next exemplar is selected to be + // included in the storage an existing one will be dropped, and the + // corresponding random number in the set used to calculate t.w will also + // be replaced. The replacement random number will also be within (0,w), + // therefore the next t.w will be based on the same distribution (i.e. + // `max(u_1,u_2,...,u_k)`). Therefore, we can sample the next t.w by + // computing the next random number `u` and take t.w as `w * u^(1/k)`. + t.w *= math.Exp(math.Log(randomFloat64()) / float64(t.k)) +} + +// shouldSample returns true if the measurement should be sampled. +// It also returns the index at which the measurement should be stored. +// +// The following algorithm is "Algorithm L" from Li, Kim-Hung (4 December +// 1994). "Reservoir-Sampling Algorithms of Time Complexity +// O(n(1+log(N/n)))". ACM Transactions on Mathematical Software. 20 (4): +// 481–493 (https://dl.acm.org/doi/10.1145/198429.198435). +// +// A high-level overview of "Algorithm L": +// 0. Pre-calculate the random count greater than the storage size when +// an exemplar will be replaced. +// 1. Accept all measurements offered until the configured storage size is +// reached. +// 2. Loop: +// a) When the pre-calculate count is reached, replace a random +// existing exemplar with the offered measurement. +// b) Calculate the next random count greater than the existing one +// which will replace another exemplars +// +// The way a "replacement" count is computed is by looking at `n` number of +// independent random numbers each corresponding to an offered measurement. +// Of these numbers the smallest `k` (the same size as the storage +// capacity) of them are kept as a subset. The maximum value in this +// subset, called `w` is used to weight another random number generation +// for the next count that will be considered. +// +// By weighting the next count computation like described, it is able to +// perform a uniformly-weighted sampling algorithm based on the number of +// samples the reservoir has seen so far. The sampling will "slow down" as +// more and more samples are offered so as to reduce a bias towards those +// offered just prior to the end of the collection. +// +// This algorithm is preferred because of its balance of simplicity and +// performance. It will compute three random numbers (the bulk of +// computation time) for each item that becomes part of the reservoir, but +// it does not spend any time on items that do not. In particular it has an +// asymptotic runtime of O(k(1 + log(n/k))) where n is the number of +// measurements offered and k is the reservoir size. +// +// See https://en.wikipedia.org/wiki/Reservoir_sampling for an overview of +// this and other reservoir sampling algorithms. See +// https://github.com/MrAlias/reservoir-sampling for a performance +// comparison of reservoir sampling algorithms. +func (t *nextTracker) shouldSample() (bool, int) { + if t.k <= 0 { + return false, 0 + } + if t.count < int64(t.k) { + idx := int(t.count) + t.count++ + return true, idx + } + if t.count == t.next { + idx := 0 + if t.k > 1 { + idx = int(rand.Int64N(int64(t.k))) + } + t.advance() + t.count++ + return true, idx + } + t.count++ + return false, 0 +} + +// randomFloat64 returns a pseudo-random value uniformly selected from +// {k / 2^53 | 1 <= k < 2^53}. +func randomFloat64() float64 { + // rand.Float64 returns a value in [0, 1). Retry in the extremely + // unlikely event that it returns zero to produce a value in (0, 1). + f := rand.Float64() + for f == 0 { + f = rand.Float64() + } + return f +} diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/reservoir.go b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/reservoir.go index ba5cd1a6b3d..a6cfdf44f99 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/reservoir.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/reservoir.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package exemplar // import "go.opentelemetry.io/otel/sdk/metric/exemplar" +package exemplar import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/storage.go b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/storage.go index 790496027da..9a0be05a24a 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/storage.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/storage.go @@ -1,74 +1,41 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package exemplar // import "go.opentelemetry.io/otel/sdk/metric/exemplar" +package exemplar import ( "context" - "sync" "time" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" ) -// storage is an exemplar storage for [Reservoir] implementations. -type storage struct { - // measurements are the measurements sampled. - // - // This does not use []metricdata.Exemplar because it potentially would - // require an allocation for trace and span IDs in the hot path of Offer. - measurements []measurement -} - -func newStorage(n int) *storage { - return &storage{measurements: make([]measurement, n)} -} - -func (r *storage) store(ctx context.Context, idx int, ts time.Time, v Value, droppedAttr []attribute.KeyValue) { - r.measurements[idx].mux.Lock() - defer r.measurements[idx].mux.Unlock() - r.measurements[idx].FilteredAttributes = droppedAttr - r.measurements[idx].Time = ts - r.measurements[idx].Value = v - r.measurements[idx].Ctx = ctx - r.measurements[idx].valid = true -} - -// Collect returns all the held exemplars. -// -// The Reservoir state is preserved after this call. -func (r *storage) Collect(dest *[]Exemplar) { - *dest = reset(*dest, len(r.measurements), len(r.measurements)) - var n int - for i := range r.measurements { - if r.measurements[i].exemplar(&(*dest)[n]) { - n++ - } - } - *dest = (*dest)[:n] -} - // measurement is a measurement made by a telemetry system. type measurement struct { - mux sync.Mutex // FilteredAttributes are the attributes dropped during the measurement. FilteredAttributes []attribute.KeyValue // Time is the time when the measurement was made. Time time.Time // Value is the value of the measurement. Value Value - // Ctx is the context active when a measurement was made. - Ctx context.Context + // SpanContext is the SpanContext active when a measurement was made. + SpanContext trace.SpanContext valid bool } +func (m *measurement) store(ctx context.Context, ts time.Time, v Value, droppedAttr []attribute.KeyValue) { + m.FilteredAttributes = droppedAttr + m.Time = ts + m.Value = v + m.SpanContext = trace.SpanContextFromContext(ctx) + m.valid = true +} + // exemplar returns m as an [Exemplar]. // returns true if it populated the exemplar. func (m *measurement) exemplar(dest *Exemplar) bool { - m.mux.Lock() - defer m.mux.Unlock() if !m.valid { return false } @@ -77,7 +44,7 @@ func (m *measurement) exemplar(dest *Exemplar) bool { dest.Time = m.Time dest.Value = m.Value - sc := trace.SpanContextFromContext(m.Ctx) + sc := m.SpanContext if sc.HasTraceID() { traceID := sc.TraceID() dest.TraceID = traceID[:] diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/value.go b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/value.go index 590b089a806..c7d1645b6e9 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/value.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/value.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package exemplar // import "go.opentelemetry.io/otel/sdk/metric/exemplar" +package exemplar import "math" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/exporter.go b/vendor/go.opentelemetry.io/otel/sdk/metric/exporter.go index 1969cb42cf4..7bec415296f 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/exporter.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/exporter.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package metric // import "go.opentelemetry.io/otel/sdk/metric" +package metric import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/instrument.go b/vendor/go.opentelemetry.io/otel/sdk/metric/instrument.go index dfb4964d9f8..31f7afef903 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/instrument.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/instrument.go @@ -3,7 +3,7 @@ //go:generate stringer -type=InstrumentKind -trimprefix=InstrumentKind -package metric // import "go.opentelemetry.io/otel/sdk/metric" +package metric import ( "context" @@ -16,6 +16,7 @@ import ( "go.opentelemetry.io/otel/metric/embedded" "go.opentelemetry.io/otel/sdk/instrumentation" "go.opentelemetry.io/otel/sdk/metric/internal/aggregate" + "go.opentelemetry.io/otel/sdk/metric/internal/attrnorm" ) var zeroScope instrumentation.Scope @@ -180,6 +181,46 @@ func (i instID) normalize() instID { return i } +type rawAttributesOption interface { + RawAttributes() []attribute.KeyValue + Experimental() +} + +func extractRawKVs[T any](opts []T) []attribute.KeyValue { + var rawKVs []attribute.KeyValue + var count int + for _, opt := range opts { + if r, ok := any(opt).(rawAttributesOption); ok { + count++ + if count == 1 { + rawKVs = r.RawAttributes() + } else { + if count == 2 { + // Create a new slice to avoid modifying the original slice from the first option. + rawKVs = append([]attribute.KeyValue(nil), rawKVs...) + } + rawKVs = append(rawKVs, r.RawAttributes()...) + } + } + } + return rawKVs +} + +func resolveAttributes(configAttrs attribute.Set, rawKVs []attribute.KeyValue) attribute.Set { + configAttrs, _ = attrnorm.Set(configAttrs) + if len(rawKVs) == 0 { + return configAttrs + } + rawKVs, _ = attrnorm.KeyValues(rawKVs) + merged := make([]attribute.KeyValue, 0, configAttrs.Len()+len(rawKVs)) + merged = append(merged, configAttrs.ToSlice()...) + // rawKVs are appended after configAttrs, meaning they will override any duplicate keys in configAttrs. + // This behavior is documented in WithUnsafeAttributes. + merged = append(merged, rawKVs...) + // TODO(#7743): Defer computing the full attribute.NewSet. + return attribute.NewSet(merged...) +} + type int64Inst struct { measures []aggregate.Measure[int64] @@ -198,12 +239,14 @@ var ( func (i *int64Inst) Add(ctx context.Context, val int64, opts ...metric.AddOption) { c := metric.NewAddConfig(opts) - i.aggregate(ctx, val, c.Attributes()) + rawKVs := extractRawKVs(opts) + i.aggregate(ctx, val, resolveAttributes(c.Attributes(), rawKVs)) } func (i *int64Inst) Record(ctx context.Context, val int64, opts ...metric.RecordOption) { c := metric.NewRecordConfig(opts) - i.aggregate(ctx, val, c.Attributes()) + rawKVs := extractRawKVs(opts) + i.aggregate(ctx, val, resolveAttributes(c.Attributes(), rawKVs)) } func (i *int64Inst) Enabled(context.Context) bool { @@ -238,12 +281,14 @@ var ( func (i *float64Inst) Add(ctx context.Context, val float64, opts ...metric.AddOption) { c := metric.NewAddConfig(opts) - i.aggregate(ctx, val, c.Attributes()) + rawKVs := extractRawKVs(opts) + i.aggregate(ctx, val, resolveAttributes(c.Attributes(), rawKVs)) } func (i *float64Inst) Record(ctx context.Context, val float64, opts ...metric.RecordOption) { c := metric.NewRecordConfig(opts) - i.aggregate(ctx, val, c.Attributes()) + rawKVs := extractRawKVs(opts) + i.aggregate(ctx, val, resolveAttributes(c.Attributes(), rawKVs)) } func (i *float64Inst) Enabled(context.Context) bool { diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/aggregate.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/aggregate.go index a35f3bcc1bb..696fc21cab1 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/aggregate.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/aggregate.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package aggregate // import "go.opentelemetry.io/otel/sdk/metric/internal/aggregate" +package aggregate import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/atomic.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/atomic.go index eb69e965079..675c23fc3c9 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/atomic.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/atomic.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package aggregate // import "go.opentelemetry.io/otel/sdk/metric/internal/aggregate" +package aggregate import ( "math" @@ -221,23 +221,23 @@ func (l *hotColdWaitGroup) swapHotAndWait() uint64 { // limitedSyncMap is a sync.Map which enforces the aggregation limit on // attribute sets and provides a Len() function. -type limitedSyncMap struct { +type limitedSyncMap[V any] struct { sync.Map aggLimit int len int lenMux sync.Mutex } -func (m *limitedSyncMap) LoadOrStoreAttr(fltrAttr attribute.Set, newValue func(attribute.Set) any) any { +func (m *limitedSyncMap[V]) LoadOrStoreAttr(fltrAttr attribute.Set, newValue func(attribute.Set) V) V { actual, loaded := m.Load(fltrAttr.Equivalent()) if loaded { - return actual + return actual.(V) } // If the overflow set exists, assume we have already overflowed and don't // bother with the slow path below. actual, loaded = m.Load(overflowSet.Equivalent()) if loaded { - return actual + return actual.(V) } // Slow path: add a new attribute set. m.lenMux.Lock() @@ -248,7 +248,7 @@ func (m *limitedSyncMap) LoadOrStoreAttr(fltrAttr attribute.Set, newValue func(a // concurrently. actual, loaded = m.Load(fltrAttr.Equivalent()) if loaded { - return actual + return actual.(V) } if m.aggLimit > 0 && m.len >= m.aggLimit-1 { @@ -258,17 +258,17 @@ func (m *limitedSyncMap) LoadOrStoreAttr(fltrAttr attribute.Set, newValue func(a if !loaded { m.len++ } - return actual + return actual.(V) } -func (m *limitedSyncMap) Clear() { +func (m *limitedSyncMap[V]) Clear() { m.lenMux.Lock() defer m.lenMux.Unlock() m.len = 0 m.Map.Clear() } -func (m *limitedSyncMap) Len() int { +func (m *limitedSyncMap[V]) Len() int { m.lenMux.Lock() defer m.lenMux.Unlock() return m.len diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/doc.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/doc.go index 7b7225e6ef9..c0399c4087b 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/doc.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/doc.go @@ -4,4 +4,4 @@ // Package aggregate provides aggregate types used compute aggregations and // cycle the state of metric measurements made by the SDK. These types and // functionality are meant only for internal SDK use. -package aggregate // import "go.opentelemetry.io/otel/sdk/metric/internal/aggregate" +package aggregate diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/drop.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/drop.go index 7adfcaf8531..47ec26dba91 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/drop.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/drop.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package aggregate // import "go.opentelemetry.io/otel/sdk/metric/internal/aggregate" +package aggregate import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/exemplar.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/exemplar.go index 25d709948e9..45b62041925 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/exemplar.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/exemplar.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package aggregate // import "go.opentelemetry.io/otel/sdk/metric/internal/aggregate" +package aggregate import ( "sync" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/exponential_histogram.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/exponential_histogram.go index 767b1d6dc7d..77c20a315c2 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/exponential_histogram.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/exponential_histogram.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package aggregate // import "go.opentelemetry.io/otel/sdk/metric/internal/aggregate" +package aggregate import ( "context" @@ -412,12 +412,15 @@ func (e *expoHistogram[N]) delta( if !e.noSum { hDPts[i].Sum = val.sum.load() + } else { + hDPts[i].Sum = 0 } - if !e.noMinMax { - if val.minMax.set.Load() { - hDPts[i].Min = metricdata.NewExtrema(val.minMax.minimum.Load()) - hDPts[i].Max = metricdata.NewExtrema(val.minMax.maximum.Load()) - } + if !e.noMinMax && val.minMax.set.Load() { + hDPts[i].Min = metricdata.NewExtrema(val.minMax.minimum.Load()) + hDPts[i].Max = metricdata.NewExtrema(val.minMax.maximum.Load()) + } else { + hDPts[i].Min = metricdata.Extrema[N]{} + hDPts[i].Max = metricdata.Extrema[N]{} } collectExemplars(&hDPts[i].Exemplars, val.res.Collect) @@ -488,12 +491,15 @@ func (e *expoHistogram[N]) cumulative( if !e.noSum { hDPts[i].Sum = val.sum.load() + } else { + hDPts[i].Sum = 0 } - if !e.noMinMax { - if val.minMax.set.Load() { - hDPts[i].Min = metricdata.NewExtrema(val.minMax.minimum.Load()) - hDPts[i].Max = metricdata.NewExtrema(val.minMax.maximum.Load()) - } + if !e.noMinMax && val.minMax.set.Load() { + hDPts[i].Min = metricdata.NewExtrema(val.minMax.minimum.Load()) + hDPts[i].Max = metricdata.NewExtrema(val.minMax.maximum.Load()) + } else { + hDPts[i].Min = metricdata.Extrema[N]{} + hDPts[i].Max = metricdata.Extrema[N]{} } collectExemplars(&hDPts[i].Exemplars, val.res.Collect) diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/filtered_reservoir.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/filtered_reservoir.go index e4f9409bc80..9aac90f0350 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/filtered_reservoir.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/filtered_reservoir.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package aggregate // import "go.opentelemetry.io/otel/sdk/metric/internal/aggregate" +package aggregate import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/histogram.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/histogram.go index 50c82ff32f9..17807e11e4e 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/histogram.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/histogram.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package aggregate // import "go.opentelemetry.io/otel/sdk/metric/internal/aggregate" +package aggregate import ( "context" @@ -44,8 +44,6 @@ type histogramPointCounters[N int64 | float64] struct { } func (b *histogramPointCounters[N]) loadCountsInto(into *[]uint64) uint64 { - // TODO (#3047): Making copies for counts incurs a large - // memory allocation footprint. Alternatives should be explored. counts := reset(*into, len(b.counts), len(b.counts)) count := uint64(0) for i := range b.counts { @@ -97,7 +95,7 @@ func (b *histogramPointCounters[N]) mergeIntoAndReset( // nolint:revive // Inten // unused attribute sets do not report in subsequent collect() calls. type deltaHistogram[N int64 | float64] struct { hcwg hotColdWaitGroup - hotColdValMap [2]limitedSyncMap + hotColdValMap [2]limitedSyncMap[*histogramPoint[N]] start time.Time noMinMax bool @@ -114,7 +112,7 @@ func (s *deltaHistogram[N]) measure( ) { hotIdx := s.hcwg.start() defer s.hcwg.done(hotIdx) - h := s.hotColdValMap[hotIdx].LoadOrStoreAttr(fltrAttr, func(attr attribute.Set) any { + h := s.hotColdValMap[hotIdx].LoadOrStoreAttr(fltrAttr, func(attr attribute.Set) *histogramPoint[N] { r := s.newRes(attr) _, isDrop := r.(*dropRes[N]) hPt := &histogramPoint[N]{ @@ -131,7 +129,7 @@ func (s *deltaHistogram[N]) measure( histogramPointCounters: histogramPointCounters[N]{counts: make([]atomic.Uint64, len(s.bounds)+1)}, } return hPt - }).(*histogramPoint[N]) + }) // This search will return an index in the range [0, len(s.bounds)], where // it will return len(s.bounds) if value is greater than the last element @@ -171,7 +169,7 @@ func newDeltaHistogram[N int64 | float64]( noSum: noSum, bounds: b, newRes: r, - hotColdValMap: [2]limitedSyncMap{ + hotColdValMap: [2]limitedSyncMap[*histogramPoint[N]]{ {aggLimit: limit}, {aggLimit: limit}, }, @@ -212,13 +210,16 @@ func (s *deltaHistogram[N]) collect( if !s.noSum { hDPts[i].Sum = val.total.load() + } else { + hDPts[i].Sum = 0 } - if !s.noMinMax { - if val.minMax.set.Load() { - hDPts[i].Min = metricdata.NewExtrema(val.minMax.minimum.Load()) - hDPts[i].Max = metricdata.NewExtrema(val.minMax.maximum.Load()) - } + if !s.noMinMax && val.minMax.set.Load() { + hDPts[i].Min = metricdata.NewExtrema(val.minMax.minimum.Load()) + hDPts[i].Max = metricdata.NewExtrema(val.minMax.maximum.Load()) + } else { + hDPts[i].Min = metricdata.Extrema[N]{} + hDPts[i].Max = metricdata.Extrema[N]{} } collectExemplars(&hDPts[i].Exemplars, val.res.Collect) @@ -249,7 +250,7 @@ func (s *deltaHistogram[N]) collect( // to reading. Unlike deltaHistogram, this maintains a single map so that the // preserved attribute sets do not change when collect() is called. type cumulativeHistogram[N int64 | float64] struct { - values limitedSyncMap + values limitedSyncMap[*hotColdHistogramPoint[N]] start time.Time noMinMax bool @@ -278,7 +279,7 @@ func newCumulativeHistogram[N int64 | float64]( noSum: noSum, bounds: b, newRes: r, - values: limitedSyncMap{aggLimit: limit}, + values: limitedSyncMap[*hotColdHistogramPoint[N]]{aggLimit: limit}, } } @@ -288,7 +289,7 @@ func (s *cumulativeHistogram[N]) measure( fltrAttr attribute.Set, droppedAttr []attribute.KeyValue, ) { - h := s.values.LoadOrStoreAttr(fltrAttr, func(attr attribute.Set) any { + h := s.values.LoadOrStoreAttr(fltrAttr, func(attr attribute.Set) *hotColdHistogramPoint[N] { r := s.newRes(attr) _, isDrop := r.(*dropRes[N]) hPt := &hotColdHistogramPoint[N]{ @@ -313,7 +314,7 @@ func (s *cumulativeHistogram[N]) measure( }, } return hPt - }).(*hotColdHistogramPoint[N]) + }) // This search will return an index in the range [0, len(s.bounds)], where // it will return len(s.bounds) if value is greater than the last element @@ -350,9 +351,16 @@ func (s *cumulativeHistogram[N]) collect( // Do not allow modification of our copy of bounds. bounds := slices.Clone(s.bounds) - // Values are being concurrently written while we iterate, so only use the - // current length for capacity. - hDPts := reset(h.DataPoints, 0, s.values.Len()) + // Pre-size hDPts so per-series destination slots are addressable by index. + // This lets loadCountsInto and collectExemplars reuse each slot's existing + // BucketCounts/Exemplars slices from the previous cycle. s.values is + // append-only here during cumulative collect, and limitedSyncMap only + // increments its len after a successful underlying LoadOrStore, so Range + // will visit at least n entries. Concurrent measurers may add more between + // Len() and Range; those extra slots are appended on demand inside the + // loop. + n := s.values.Len() + hDPts := reset(h.DataPoints, n, n) perSeriesStartTimeEnabled := x.PerSeriesStartTimestamps.Enabled() @@ -366,35 +374,41 @@ func (s *cumulativeHistogram[N]) collect( } // swap, observe, and clear the point readIdx := val.hcwg.swapHotAndWait() - var bucketCounts []uint64 - count := val.hotColdPoint[readIdx].loadCountsInto(&bucketCounts) - newPt := metricdata.HistogramDataPoint[N]{ - Attributes: val.attrs, - StartTime: startTime, - Time: t, - Count: count, - Bounds: bounds, - // The HistogramDataPoint field values returned need to be copies of - // the histogramPoint value as we will keep updating them. - BucketCounts: bucketCounts, - } + // Concurrent writers can grow s.values between Len() and Range. + // Cold-path grow. + if i >= len(hDPts) { + hDPts = append(hDPts, metricdata.HistogramDataPoint[N]{}) + } + dp := &hDPts[i] + + count := val.hotColdPoint[readIdx].loadCountsInto(&dp.BucketCounts) + dp.Attributes = val.attrs + dp.StartTime = startTime + dp.Time = t + dp.Count = count + dp.Bounds = bounds if !s.noSum { - newPt.Sum = val.hotColdPoint[readIdx].total.load() + dp.Sum = val.hotColdPoint[readIdx].total.load() + } else { + // Slot may be reused; clear stale Sum from previous series. + var zero N + dp.Sum = zero } - if !s.noMinMax { - if val.hotColdPoint[readIdx].minMax.set.Load() { - newPt.Min = metricdata.NewExtrema(val.hotColdPoint[readIdx].minMax.minimum.Load()) - newPt.Max = metricdata.NewExtrema(val.hotColdPoint[readIdx].minMax.maximum.Load()) - } + if !s.noMinMax && val.hotColdPoint[readIdx].minMax.set.Load() { + dp.Min = metricdata.NewExtrema(val.hotColdPoint[readIdx].minMax.minimum.Load()) + dp.Max = metricdata.NewExtrema(val.hotColdPoint[readIdx].minMax.maximum.Load()) + } else { + // Slot may be reused; clear stale Min/Max from previous series. + dp.Min = metricdata.Extrema[N]{} + dp.Max = metricdata.Extrema[N]{} } // Once we've read the point, merge it back into the hot histogram // point since it is cumulative. hotIdx := (readIdx + 1) % 2 val.hotColdPoint[readIdx].mergeIntoAndReset(&val.hotColdPoint[hotIdx], s.noMinMax, s.noSum) - collectExemplars(&newPt.Exemplars, val.res.Collect) - hDPts = append(hDPts, newPt) + collectExemplars(&dp.Exemplars, val.res.Collect) i++ // TODO (#3006): This will use an unbounded amount of memory if there diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/lastvalue.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/lastvalue.go index 2af252ec5df..0fddc9dcc9e 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/lastvalue.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/lastvalue.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package aggregate // import "go.opentelemetry.io/otel/sdk/metric/internal/aggregate" +package aggregate import ( "context" @@ -24,7 +24,7 @@ type lastValuePoint[N int64 | float64] struct { // lastValueMap summarizes a set of measurements as the last one made. type lastValueMap[N int64 | float64] struct { newRes func(attribute.Set) FilteredExemplarReservoir[N] - values limitedSyncMap + values limitedSyncMap[*lastValuePoint[N]] } func (s *lastValueMap[N]) measure( @@ -33,7 +33,7 @@ func (s *lastValueMap[N]) measure( fltrAttr attribute.Set, droppedAttr []attribute.KeyValue, ) { - lv := s.values.LoadOrStoreAttr(fltrAttr, func(attr attribute.Set) any { + lv := s.values.LoadOrStoreAttr(fltrAttr, func(attr attribute.Set) *lastValuePoint[N] { r := s.newRes(attr) _, isDrop := r.(*dropRes[N]) p := &lastValuePoint[N]{ @@ -44,7 +44,7 @@ func (s *lastValueMap[N]) measure( } p.value.Store(value) return p - }).(*lastValuePoint[N]) + }) lv.value.Store(value) if !lv.dropExemplars { @@ -61,12 +61,12 @@ func newDeltaLastValue[N int64 | float64]( start: now(), hotColdValMap: [2]lastValueMap[N]{ { - values: limitedSyncMap{aggLimit: limit}, newRes: r, + values: limitedSyncMap[*lastValuePoint[N]]{aggLimit: limit}, }, { - values: limitedSyncMap{aggLimit: limit}, newRes: r, + values: limitedSyncMap[*lastValuePoint[N]]{aggLimit: limit}, }, }, } @@ -148,8 +148,8 @@ func newCumulativeLastValue[N int64 | float64]( ) *cumulativeLastValue[N] { return &cumulativeLastValue[N]{ lastValueMap: lastValueMap[N]{ - values: limitedSyncMap{aggLimit: limit}, newRes: r, + values: limitedSyncMap[*lastValuePoint[N]]{aggLimit: limit}, }, start: now(), } diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/limit.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/limit.go index c19a1aff68f..426a8b275ed 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/limit.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/limit.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package aggregate // import "go.opentelemetry.io/otel/sdk/metric/internal/aggregate" +package aggregate import "go.opentelemetry.io/otel/attribute" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/sum.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/sum.go index 0cd3c94575b..bee5ca37010 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/sum.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/sum.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package aggregate // import "go.opentelemetry.io/otel/sdk/metric/internal/aggregate" +package aggregate import ( "context" @@ -21,8 +21,8 @@ type sumValue[N int64 | float64] struct { } type sumValueMap[N int64 | float64] struct { - values limitedSyncMap newRes func(attribute.Set) FilteredExemplarReservoir[N] + values limitedSyncMap[*sumValue[N]] } func (s *sumValueMap[N]) measure( @@ -31,7 +31,7 @@ func (s *sumValueMap[N]) measure( fltrAttr attribute.Set, droppedAttr []attribute.KeyValue, ) { - sv := s.values.LoadOrStoreAttr(fltrAttr, func(attr attribute.Set) any { + sv := s.values.LoadOrStoreAttr(fltrAttr, func(attr attribute.Set) *sumValue[N] { r := s.newRes(attr) _, isDrop := r.(*dropRes[N]) return &sumValue[N]{ @@ -40,7 +40,7 @@ func (s *sumValueMap[N]) measure( startTime: now(), dropExemplars: isDrop, } - }).(*sumValue[N]) + }) sv.n.add(value) // It is possible for collection to race with measurement and observe the // exemplar in the batch of metrics after the add() for cumulative sums. @@ -63,12 +63,12 @@ func newDeltaSum[N int64 | float64]( start: now(), hotColdValMap: [2]sumValueMap[N]{ { - values: limitedSyncMap{aggLimit: limit}, newRes: r, + values: limitedSyncMap[*sumValue[N]]{aggLimit: limit}, }, { - values: limitedSyncMap{aggLimit: limit}, newRes: r, + values: limitedSyncMap[*sumValue[N]]{aggLimit: limit}, }, }, } @@ -140,8 +140,8 @@ func newCumulativeSum[N int64 | float64]( monotonic: monotonic, start: now(), sumValueMap: sumValueMap[N]{ - values: limitedSyncMap{aggLimit: limit}, newRes: r, + values: limitedSyncMap[*sumValue[N]]{aggLimit: limit}, }, } } diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/attrnorm/dedup.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/attrnorm/dedup.go new file mode 100644 index 00000000000..fe9ddc96db7 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/attrnorm/dedup.go @@ -0,0 +1,300 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// DO NOT MODIFY. Generated by gotmpl. +// source: internal/shared/attrnorm/dedup.go.tmpl + +// Package attrnorm normalizes attribute values. +package attrnorm + +import ( + "reflect" + "unsafe" + + "go.opentelemetry.io/otel/attribute" +) + +var ( + keyValueType = reflect.TypeFor[attribute.KeyValue]() + valueType = reflect.TypeFor[attribute.Value]() +) + +// rawValue mirrors attribute.Value. It is used only to read immutable slice +// storage without calling AsMap or AsSlice on no-op paths. +type rawValue struct { + vtype attribute.Type + numeric uint64 + stringly string + slice any +} + +// Value returns value with all map values deduplicated and whether it changed. +// +// Duplicate map keys are resolved using last-value-wins semantics. +func Value(value attribute.Value) (attribute.Value, bool) { + switch value.Type() { + case attribute.SLICE: + return deduplicateSliceValue(value) + case attribute.MAP: + return deduplicateMapValue(value) + default: + return value, false + } +} + +// KeyValue returns kv with all map values deduplicated and whether it changed. +func KeyValue(kv attribute.KeyValue) (attribute.KeyValue, bool) { + value, changed := Value(kv.Value) + if changed { + kv.Value = value + } + return kv, changed +} + +// KeyValues returns kvs with all map values deduplicated and whether they changed. +// +// The returned slice is the original kvs slice if no value needs +// deduplication. Top-level keys in kvs are not deduplicated. +func KeyValues(kvs []attribute.KeyValue) ([]attribute.KeyValue, bool) { + // Preserve the caller's slice on the common no-op path. Once a changed + // value is found, copy the prior values exactly once and fill the rest in + // place as the scan continues. + var normalized []attribute.KeyValue + for i, kv := range kvs { + kv, changed := KeyValue(kv) + if normalized != nil { + normalized[i] = kv + continue + } + if !changed { + continue + } + + normalized = make([]attribute.KeyValue, len(kvs)) + copy(normalized, kvs[:i]) + normalized[i] = kv + } + if normalized == nil { + return kvs, false + } + return normalized, true +} + +// Set returns set with all map values deduplicated and whether it changed. +// +// The returned Set is the original set if no value needs deduplication. +// Top-level key uniqueness remains attribute.Set's responsibility; this only +// normalizes map attribute values. +func Set(set attribute.Set) (attribute.Set, bool) { + if set.Len() == 0 { + return set, false + } + + // Most attribute sets contain no duplicate map keys. Delay allocation until + // the first changed value so the no-op path returns the original Set. + var normalized []attribute.KeyValue + for i := range set.Len() { + kv, _ := set.Get(i) + kv, changed := KeyValue(kv) + if normalized != nil { + normalized = append(normalized, kv) + continue + } + if !changed { + continue + } + + normalized = make([]attribute.KeyValue, 0, set.Len()) + for j := range i { + prior, _ := set.Get(j) + normalized = append(normalized, prior) + } + normalized = append(normalized, kv) + } + if normalized == nil { + return set, false + } + + return attribute.NewSet(normalized...), true +} + +func deduplicateSliceValue(value attribute.Value) (attribute.Value, bool) { + storage := valueStorage(value) + length := valueLen(storage) + + // Slice values can contain map values, so recurse into each element while + // keeping the original attribute.Value when no element changes. + var normalized []attribute.Value + for i := range length { + elem := valueAt(storage, i) + elem, changed := Value(elem) + if normalized != nil { + normalized[i] = elem + continue + } + if !changed { + continue + } + + normalized = make([]attribute.Value, length) + for j := range i { + normalized[j] = valueAt(storage, j) + } + normalized[i] = elem + } + if normalized == nil { + return value, false + } + return attribute.SliceValue(normalized...), true +} + +func deduplicateMapValue(value attribute.Value) (attribute.Value, bool) { + storage := valueStorage(value) + length := keyValueLen(storage) + if length <= 1 { + // A single map entry cannot duplicate its own key, but its value might + // contain a map or slice that needs recursive normalization. + if length == 1 { + kv, changed := KeyValue(keyValueAt(storage, 0)) + if changed { + return attribute.MapValue(kv), true + } + } + return value, false + } + + var normalized []attribute.KeyValue + for i := 0; i < length; { + // attribute.MapValue stores key-values sorted by key using a stable + // sort. Equal keys therefore form a contiguous run, and the last + // element in that run is the last value provided by the caller. + first := keyValueAt(storage, i) + j := i + 1 + for j < length && keyValueAt(storage, j).Key == first.Key { + j++ + } + + kv, nestedChanged := KeyValue(keyValueAt(storage, j-1)) + // j-i > 1 means the current key run contained duplicates. + changed := nestedChanged || j-i > 1 + if normalized != nil { + normalized = append(normalized, kv) + } else if changed { + normalized = make([]attribute.KeyValue, 0, length) + for k := range i { + normalized = append(normalized, keyValueAt(storage, k)) + } + normalized = append(normalized, kv) + } + i = j + } + if normalized == nil { + return value, false + } + return attribute.MapValue(normalized...), true +} + +func valueStorage(value attribute.Value) any { + // attribute.Value does not expose allocation-free map/slice iteration. + // The raw mirror lets us read the immutable backing array directly and + // reserve AsMap/AsSlice-style allocation for paths that actually change. + return (*rawValue)( + unsafe.Pointer(&value), + ).slice //nolint:gosec // Read-only mirror of attribute.Value for allocation-free iteration. +} + +func valueLen(storage any) int { + // attribute.Value stores small slices in fixed-size array values. Handle + // the common sizes directly and fall back to reflection for larger arrays. + switch storage.(type) { + case [0]attribute.Value: + return 0 + case [1]attribute.Value: + return 1 + case [2]attribute.Value: + return 2 + case [3]attribute.Value: + return 3 + case [4]attribute.Value: + return 4 + case [5]attribute.Value: + return 5 + default: + return arrayLen(storage, valueType) + } +} + +func valueAt(storage any, i int) attribute.Value { + switch values := storage.(type) { + case [1]attribute.Value: + return values[i] + case [2]attribute.Value: + return values[i] + case [3]attribute.Value: + return values[i] + case [4]attribute.Value: + return values[i] + case [5]attribute.Value: + return values[i] + default: + return arrayAt[attribute.Value](storage, valueType, i) + } +} + +func keyValueLen(storage any) int { + // attribute.Value stores small maps in fixed-size key-value arrays. Handle + // the common sizes directly and fall back to reflection for larger arrays. + switch storage.(type) { + case [0]attribute.KeyValue: + return 0 + case [1]attribute.KeyValue: + return 1 + case [2]attribute.KeyValue: + return 2 + case [3]attribute.KeyValue: + return 3 + case [4]attribute.KeyValue: + return 4 + case [5]attribute.KeyValue: + return 5 + default: + return arrayLen(storage, keyValueType) + } +} + +func keyValueAt(storage any, i int) attribute.KeyValue { + switch kvs := storage.(type) { + case [1]attribute.KeyValue: + return kvs[i] + case [2]attribute.KeyValue: + return kvs[i] + case [3]attribute.KeyValue: + return kvs[i] + case [4]attribute.KeyValue: + return kvs[i] + case [5]attribute.KeyValue: + return kvs[i] + default: + return arrayAt[attribute.KeyValue](storage, keyValueType, i) + } +} + +func arrayLen(storage any, elem reflect.Type) int { + // Be defensive around invalid or unexpected Value storage. Returning zero + // makes malformed storage a no-op instead of panicking in telemetry paths. + array := reflect.ValueOf(storage) + if array.Kind() != reflect.Array || array.Type().Elem() != elem { + return 0 + } + return array.Len() +} + +func arrayAt[T any](storage any, elem reflect.Type, i int) T { + // Match arrayLen's fail-closed behavior for unexpected storage. + array := reflect.ValueOf(storage) + if array.Kind() != reflect.Array || array.Type().Elem() != elem || i < 0 || i >= array.Len() { + var zero T + return zero + } + return array.Index(i).Interface().(T) +} diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/gen.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/gen.go new file mode 100644 index 00000000000..5f077dfe93b --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/gen.go @@ -0,0 +1,10 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Package internal provides internal functionality for the sdk/metric package. +package internal + +//go:generate gotmpl --body=../../../internal/shared/x/x.go.tmpl "--data={ \"pkg\": \"go.opentelemetry.io/otel/sdk/metric\" }" --out=x/x.go +//go:generate gotmpl --body=../../../internal/shared/x/x_test.go.tmpl "--data={}" --out=x/x_test.go +//go:generate gotmpl --body=../../../internal/shared/attrnorm/dedup.go.tmpl "--data={}" --out=attrnorm/dedup.go +//go:generate gotmpl --body=../../../internal/shared/attrnorm/dedup_test.go.tmpl "--data={}" --out=attrnorm/dedup_test.go diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/observ/instrumentation.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/observ/instrumentation.go index c580dcc30d2..b09748a79fa 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/observ/instrumentation.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/observ/instrumentation.go @@ -3,7 +3,7 @@ // Package observ provides experimental observability instrumentation for the // metric reader. -package observ // import "go.opentelemetry.io/otel/sdk/metric/internal/observ" +package observ import ( "context" @@ -16,8 +16,8 @@ import ( "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/sdk" "go.opentelemetry.io/otel/sdk/internal/x" - semconv "go.opentelemetry.io/otel/semconv/v1.41.0" - "go.opentelemetry.io/otel/semconv/v1.41.0/otelconv" + semconv "go.opentelemetry.io/otel/semconv/v1.43.0" + "go.opentelemetry.io/otel/semconv/v1.43.0/otelconv" ) const ( diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/reservoir/concurrent_safe.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/reservoir/concurrent_safe.go index 3be234a4108..8542fd94bd7 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/reservoir/concurrent_safe.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/reservoir/concurrent_safe.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package reservoir // import "go.opentelemetry.io/otel/sdk/metric/internal/reservoir" +package reservoir // ConcurrentSafe is an interface that can be embedded in an // exemplar.Reservoir to indicate to the SDK that it is safe to invoke its diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/reservoir/doc.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/reservoir/doc.go index 6cd213b5f32..6dbf906c8ad 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/reservoir/doc.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/reservoir/doc.go @@ -3,4 +3,4 @@ // Package reservoir contains experimental features used by built-in exemplar // reservoirs which require coordination with the metrics SDK. -package reservoir // import "go.opentelemetry.io/otel/sdk/metric/internal/reservoir" +package reservoir diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/reuse_slice.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/reuse_slice.go index ea452be6c2c..6ddf01473b4 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/reuse_slice.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/reuse_slice.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // Package internal provides internal functionality for the metric package. -package internal // import "go.opentelemetry.io/otel/sdk/metric/internal" +package internal // ReuseSlice returns a zeroed view of slice if its capacity is greater than or // equal to n. Otherwise, it returns a new []T with capacity equal to n. diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/x/features.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/x/features.go new file mode 100644 index 00000000000..a8268702a6d --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/x/features.go @@ -0,0 +1,22 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package x + +import "strconv" + +// MetricExportBatchSize is an experimental feature flag that controls the +// max export batch size for metric data. +// +// To enable this feature set the OTEL_GO_X_METRIC_EXPORT_BATCH_SIZE environment +// variable to a positive integer value. +var MetricExportBatchSize = newFeature( + []string{"METRIC_EXPORT_BATCH_SIZE"}, + func(v string) (int, bool) { + val, err := strconv.Atoi(v) + if err == nil && val > 0 { + return val, true + } + return 0, false + }, +) diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/x/x.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/x/x.go index 8e3c62a13d2..f501984ae54 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/x/x.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/x/x.go @@ -1,36 +1,38 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -// Package x contains support for OTel metric SDK experimental features. -// -// This package should only be used for features defined in the specification. -// It should not be used for experiments or new project ideas. -package x // import "go.opentelemetry.io/otel/sdk/metric/internal/x" +// DO NOT MODIFY. Generated by gotmpl. +// source: internal/shared/x/x.go.tmpl + +// Package x documents experimental features for [go.opentelemetry.io/otel/sdk/metric]. +package x import ( "os" - "strconv" ) // Feature is an experimental feature control flag. It provides a uniform way // to interact with these feature flags and parse their values. type Feature[T any] struct { - key string + keys []string parse func(v string) (T, bool) } -//nolint:unused -func newFeature[T any](suffix string, parse func(string) (T, bool)) Feature[T] { +func newFeature[T any](suffix []string, parse func(string) (T, bool)) Feature[T] { const envKeyRoot = "OTEL_GO_X_" + keys := make([]string, 0, len(suffix)) + for _, s := range suffix { + keys = append(keys, envKeyRoot+s) + } return Feature[T]{ - key: envKeyRoot + suffix, + keys: keys, parse: parse, } } -// Key returns the environment variable key that needs to be set to enable the +// Keys returns the environment variable keys that can be set to enable the // feature. -func (f Feature[T]) Key() string { return f.key } +func (f Feature[T]) Keys() []string { return f.keys } // Lookup returns the user configured value for the feature and true if the // user has enabled the feature. Otherwise, if the feature is not enabled, a @@ -40,11 +42,13 @@ func (f Feature[T]) Lookup() (v T, ok bool) { // // > The SDK MUST interpret an empty value of an environment variable the // > same way as when the variable is unset. - vRaw := os.Getenv(f.key) - if vRaw == "" { - return v, ok + for _, key := range f.keys { + vRaw := os.Getenv(key) + if vRaw != "" { + return f.parse(vRaw) + } } - return f.parse(vRaw) + return v, ok } // Enabled reports whether the feature is enabled. @@ -52,19 +56,3 @@ func (f Feature[T]) Enabled() bool { _, ok := f.Lookup() return ok } - -// MetricExportBatchSize is an experimental feature flag that controls the -// max export batch size for metric data. -// -// To enable this feature set the OTEL_GO_X_METRIC_EXPORT_BATCH_SIZE environment -// variable to a positive integer value. -var MetricExportBatchSize = newFeature( - "METRIC_EXPORT_BATCH_SIZE", - func(v string) (int, bool) { - val, err := strconv.Atoi(v) - if err == nil && val > 0 { - return val, true - } - return 0, false - }, -) diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/manual_reader.go b/vendor/go.opentelemetry.io/otel/sdk/metric/manual_reader.go index 7e0cccdff60..b98e255d8c4 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/manual_reader.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/manual_reader.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package metric // import "go.opentelemetry.io/otel/sdk/metric" +package metric import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/meter.go b/vendor/go.opentelemetry.io/otel/sdk/metric/meter.go index e9a2d59572e..8c54974e062 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/meter.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/meter.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package metric // import "go.opentelemetry.io/otel/sdk/metric" +package metric import ( "context" @@ -593,11 +593,13 @@ func (r observer) ObserveFloat64(o metric.Float64Observable, v float64, opts ... return } c := metric.NewObserveConfig(opts) + rawKVs := extractRawKVs(opts) + set := resolveAttributes(c.Attributes(), rawKVs) // Access to r.pipe.float64Measure is already guarded by a lock in pipeline.produce. // TODO (#5946): Refactor pipeline and observable measures. measures := r.pipe.float64Measures[oImpl.observableID] for _, m := range measures { - m(context.Background(), v, c.Attributes()) + m(context.Background(), v, set) } } @@ -624,11 +626,13 @@ func (r observer) ObserveInt64(o metric.Int64Observable, v int64, opts ...metric return } c := metric.NewObserveConfig(opts) + rawKVs := extractRawKVs(opts) + set := resolveAttributes(c.Attributes(), rawKVs) // Access to r.pipe.int64Measures is already guarded b a lock in pipeline.produce. // TODO (#5946): Refactor pipeline and observable measures. measures := r.pipe.int64Measures[oImpl.observableID] for _, m := range measures { - m(context.Background(), v, c.Attributes()) + m(context.Background(), v, set) } } @@ -793,7 +797,8 @@ type int64Observer struct { func (o int64Observer) Observe(val int64, opts ...metric.ObserveOption) { c := metric.NewObserveConfig(opts) - o.observe(val, c.Attributes()) + rawKVs := extractRawKVs(opts) + o.observe(val, resolveAttributes(c.Attributes(), rawKVs)) } type float64Observer struct { @@ -803,7 +808,8 @@ type float64Observer struct { func (o float64Observer) Observe(val float64, opts ...metric.ObserveOption) { c := metric.NewObserveConfig(opts) - o.observe(val, c.Attributes()) + rawKVs := extractRawKVs(opts) + o.observe(val, resolveAttributes(c.Attributes(), rawKVs)) } func defaultAttributes[T any](opts []T) []attribute.Key { diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/metricdata/data.go b/vendor/go.opentelemetry.io/otel/sdk/metric/metricdata/data.go index af835e9d992..1caed336e95 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/metricdata/data.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/metricdata/data.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // Package metricdata provides types for the metric SDK data model. -package metricdata // import "go.opentelemetry.io/otel/sdk/metric/metricdata" +package metricdata import ( "encoding/json" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/metricdata/temporality.go b/vendor/go.opentelemetry.io/otel/sdk/metric/metricdata/temporality.go index 2ac840ff356..8d7c89d857f 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/metricdata/temporality.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/metricdata/temporality.go @@ -3,7 +3,7 @@ //go:generate stringer -type=Temporality -package metricdata // import "go.opentelemetry.io/otel/sdk/metric/metricdata" +package metricdata // Temporality defines the window that an aggregation was calculated over. type Temporality uint8 diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/periodic_reader.go b/vendor/go.opentelemetry.io/otel/sdk/metric/periodic_reader.go index c1c2e3e2f0a..9f7712bd516 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/periodic_reader.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/periodic_reader.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package metric // import "go.opentelemetry.io/otel/sdk/metric" +package metric import ( "context" @@ -16,7 +16,7 @@ import ( "go.opentelemetry.io/otel/sdk/metric/internal/observ" "go.opentelemetry.io/otel/sdk/metric/internal/x" "go.opentelemetry.io/otel/sdk/metric/metricdata" - semconv "go.opentelemetry.io/otel/semconv/v1.41.0" + semconv "go.opentelemetry.io/otel/semconv/v1.43.0" ) // Default periodic reader timing. diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/pipeline.go b/vendor/go.opentelemetry.io/otel/sdk/metric/pipeline.go index 09d10eeb5f2..f04c2ddcecd 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/pipeline.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/pipeline.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package metric // import "go.opentelemetry.io/otel/sdk/metric" +package metric import ( "container/list" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/provider.go b/vendor/go.opentelemetry.io/otel/sdk/metric/provider.go index fd4cdccd0ff..9f9f01f4323 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/provider.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/provider.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package metric // import "go.opentelemetry.io/otel/sdk/metric" +package metric import ( "context" @@ -12,6 +12,7 @@ import ( "go.opentelemetry.io/otel/metric/embedded" "go.opentelemetry.io/otel/metric/noop" "go.opentelemetry.io/otel/sdk/instrumentation" + "go.opentelemetry.io/otel/sdk/metric/internal/attrnorm" ) // MeterProvider handles the creation and coordination of Meters. All Meters @@ -76,11 +77,12 @@ func (mp *MeterProvider) Meter(name string, options ...metric.MeterOption) metri } c := metric.NewMeterConfig(options...) + attrs, _ := attrnorm.Set(c.InstrumentationAttributes()) s := instrumentation.Scope{ Name: name, Version: c.InstrumentationVersion(), SchemaURL: c.SchemaURL(), - Attributes: c.InstrumentationAttributes(), + Attributes: attrs, } global.Info( diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/reader.go b/vendor/go.opentelemetry.io/otel/sdk/metric/reader.go index 556afcea6bb..505c9ad9388 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/reader.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/reader.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package metric // import "go.opentelemetry.io/otel/sdk/metric" +package metric import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/splitmetrics.go b/vendor/go.opentelemetry.io/otel/sdk/metric/splitmetrics.go index a7931412bb2..b183cf4863c 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/splitmetrics.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/splitmetrics.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package metric // import "go.opentelemetry.io/otel/sdk/metric" +package metric import ( "go.opentelemetry.io/otel/sdk/metric/metricdata" diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/version.go b/vendor/go.opentelemetry.io/otel/sdk/metric/version.go index 3e1bea4b446..4c1cd75e2c0 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/version.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/version.go @@ -1,9 +1,9 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package metric // import "go.opentelemetry.io/otel/sdk/metric" +package metric // version is the current release version of the metric SDK in use. func version() string { - return "1.44.0" + return "1.45.0" } diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/view.go b/vendor/go.opentelemetry.io/otel/sdk/metric/view.go index 13fb7143ce0..3f98928f96a 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/view.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/view.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package metric // import "go.opentelemetry.io/otel/sdk/metric" +package metric import ( "errors" diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/auto.go b/vendor/go.opentelemetry.io/otel/sdk/resource/auto.go index c02aeefdde5..8754313af99 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/auto.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/auto.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/builtin.go b/vendor/go.opentelemetry.io/otel/sdk/resource/builtin.go index 28823edd53d..d5f6dc0a6d3 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/builtin.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/builtin.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource import ( "context" @@ -13,7 +13,7 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/sdk" - semconv "go.opentelemetry.io/otel/semconv/v1.41.0" + semconv "go.opentelemetry.io/otel/semconv/v1.43.0" ) type ( diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/config.go b/vendor/go.opentelemetry.io/otel/sdk/resource/config.go index a3d647d92c2..c5ffa45d022 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/config.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/config.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource import ( "context" @@ -23,7 +23,9 @@ type Option interface { apply(config) config } -// WithAttributes adds attributes to the configured Resource. +// WithAttributes adds attributes to the configured Resource. Duplicate +// top-level attribute keys and duplicate keys inside map values are +// resolved using last-value-wins semantics. func WithAttributes(attributes ...attribute.KeyValue) Option { return WithDetectors(detectAttributes{attributes}) } diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/container.go b/vendor/go.opentelemetry.io/otel/sdk/resource/container.go index ce03e24c419..c81163bf85e 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/container.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/container.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource import ( "bufio" @@ -11,7 +11,7 @@ import ( "os" "regexp" - semconv "go.opentelemetry.io/otel/semconv/v1.41.0" + semconv "go.opentelemetry.io/otel/semconv/v1.43.0" ) type containerIDProvider func() (string, error) diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/doc.go b/vendor/go.opentelemetry.io/otel/sdk/resource/doc.go index 64939a27131..f5a79d3fe49 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/doc.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/doc.go @@ -17,4 +17,4 @@ // // While this package provides a stable API, // the attributes added by resource detectors may change. -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/env.go b/vendor/go.opentelemetry.io/otel/sdk/resource/env.go index ac5691c08d9..0eeb1e2ae5e 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/env.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/env.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource import ( "context" @@ -12,7 +12,7 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" - semconv "go.opentelemetry.io/otel/semconv/v1.41.0" + semconv "go.opentelemetry.io/otel/semconv/v1.43.0" ) const ( diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/host_id.go b/vendor/go.opentelemetry.io/otel/sdk/resource/host_id.go index cb38fa1a8b0..47219be223a 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/host_id.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/host_id.go @@ -1,14 +1,14 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource import ( "context" "errors" "strings" - semconv "go.opentelemetry.io/otel/semconv/v1.41.0" + semconv "go.opentelemetry.io/otel/semconv/v1.43.0" ) type hostIDProvider func() (string, error) diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_bsd.go b/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_bsd.go index 4c1c30f2560..bcd174342b2 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_bsd.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_bsd.go @@ -3,7 +3,7 @@ //go:build dragonfly || freebsd || netbsd || openbsd || solaris -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource var platformHostIDReader hostIDReader = &hostIDReaderBSD{ execCommand: execCommand, diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_darwin.go b/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_darwin.go index b09fde3b735..81ece5b34d6 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_darwin.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_darwin.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource var platformHostIDReader hostIDReader = &hostIDReaderDarwin{ execCommand: execCommand, diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_exec.go b/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_exec.go index e239ead0287..c058f0d26b0 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_exec.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_exec.go @@ -3,7 +3,7 @@ //go:build darwin || dragonfly || freebsd || netbsd || openbsd || solaris -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_linux.go b/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_linux.go index 4a26096c8d0..26cf6a5d1e2 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_linux.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_linux.go @@ -3,7 +3,7 @@ //go:build linux -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource var platformHostIDReader hostIDReader = &hostIDReaderLinux{ readFile: readFile, diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_readfile.go b/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_readfile.go index c95d87685c9..d955c2c909f 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_readfile.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_readfile.go @@ -3,7 +3,7 @@ //go:build linux || dragonfly || freebsd || netbsd || openbsd || solaris -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource import "os" diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_unsupported.go b/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_unsupported.go index 63ad2fa4e05..9f6ca82118c 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_unsupported.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_unsupported.go @@ -3,7 +3,7 @@ //go:build !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !windows -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource // hostIDReaderUnsupported is a placeholder implementation for operating systems // for which this project currently doesn't support host.id diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_windows.go b/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_windows.go index 2b8ca20b381..e9e4a038484 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_windows.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/host_id_windows.go @@ -3,7 +3,7 @@ //go:build windows -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource import ( "golang.org/x/sys/windows/registry" diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/os.go b/vendor/go.opentelemetry.io/otel/sdk/resource/os.go index 4c0def41483..6af4915679f 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/os.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/os.go @@ -1,14 +1,14 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource import ( "context" "strings" "go.opentelemetry.io/otel/attribute" - semconv "go.opentelemetry.io/otel/semconv/v1.41.0" + semconv "go.opentelemetry.io/otel/semconv/v1.43.0" ) type osDescriptionProvider func() (string, error) diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/os_release_darwin.go b/vendor/go.opentelemetry.io/otel/sdk/resource/os_release_darwin.go index 3d703c5d98e..f12876d17a5 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/os_release_darwin.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/os_release_darwin.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource import ( "encoding/xml" diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/os_release_unix.go b/vendor/go.opentelemetry.io/otel/sdk/resource/os_release_unix.go index a1763267c22..ad92858546e 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/os_release_unix.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/os_release_unix.go @@ -3,7 +3,7 @@ //go:build aix || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource import ( "bufio" diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/os_unix.go b/vendor/go.opentelemetry.io/otel/sdk/resource/os_unix.go index 1cd87c39834..ba5e48db244 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/os_unix.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/os_unix.go @@ -3,7 +3,7 @@ //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource import ( "fmt" diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/os_unsupported.go b/vendor/go.opentelemetry.io/otel/sdk/resource/os_unsupported.go index 25f629532a3..e2c19c2b3aa 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/os_unsupported.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/os_unsupported.go @@ -3,7 +3,7 @@ //go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !windows && !zos -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource // platformOSDescription is a placeholder implementation for OSes // for which this project currently doesn't support os.description diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/os_windows.go b/vendor/go.opentelemetry.io/otel/sdk/resource/os_windows.go index ebd50826d6e..9b76489577a 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/os_windows.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/os_windows.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource import ( "fmt" diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/process.go b/vendor/go.opentelemetry.io/otel/sdk/resource/process.go index b015f8233c6..a578fc3258e 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/process.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/process.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource import ( "context" @@ -11,7 +11,7 @@ import ( "path/filepath" "runtime" - semconv "go.opentelemetry.io/otel/semconv/v1.41.0" + semconv "go.opentelemetry.io/otel/semconv/v1.43.0" ) type ( diff --git a/vendor/go.opentelemetry.io/otel/sdk/resource/resource.go b/vendor/go.opentelemetry.io/otel/sdk/resource/resource.go index f715be53eda..68ab274d2f1 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/resource/resource.go +++ b/vendor/go.opentelemetry.io/otel/sdk/resource/resource.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package resource // import "go.opentelemetry.io/otel/sdk/resource" +package resource import ( "context" @@ -11,6 +11,7 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/sdk/internal/attrnorm" "go.opentelemetry.io/otel/sdk/internal/x" ) @@ -47,6 +48,8 @@ var ( var ErrSchemaURLConflict = errors.New("conflicting Schema URL") // New returns a [Resource] built using opts. +// Duplicate top-level attribute keys and duplicate keys inside map +// values are resolved using last-value-wins semantics. // // This may return a partial Resource along with an error containing // [ErrPartialResource] if options that provide a [Detector] are used and that @@ -66,25 +69,29 @@ func New(ctx context.Context, opts ...Option) (*Resource, error) { return r, detect(ctx, r, cfg.detectors) } -// NewWithAttributes creates a resource from attrs and associates the resource with a -// schema URL. If attrs contains duplicate keys, the last value will be used. If attrs -// contains any invalid items those items will be dropped. The attrs are assumed to be -// in a schema identified by schemaURL. +// NewWithAttributes creates a resource from attrs and associates the resource +// with a schema URL. If attrs contains duplicate top-level attribute keys or +// duplicate keys inside map values, the last value will be used. If attrs +// contains any invalid items those items will be dropped. The attrs are assumed +// to be in a schema identified by schemaURL. func NewWithAttributes(schemaURL string, attrs ...attribute.KeyValue) *Resource { resource := NewSchemaless(attrs...) resource.schemaURL = schemaURL return resource } -// NewSchemaless creates a resource from attrs. If attrs contains duplicate keys, -// the last value will be used. If attrs contains any invalid items those items will -// be dropped. The resource will not be associated with a schema URL. If the schema +// NewSchemaless creates a resource from attrs. If attrs contains duplicate +// top-level attribute keys or duplicate keys inside map values, the last +// value will be used. If attrs contains any invalid items those items will be +// dropped. The resource will not be associated with a schema URL. If the schema // of the attrs is known use NewWithAttributes instead. func NewSchemaless(attrs ...attribute.KeyValue) *Resource { if len(attrs) == 0 { return &Resource{} } + attrs, _ = attrnorm.KeyValues(attrs) + // Ensure attributes comply with the specification: // https://github.com/open-telemetry/opentelemetry-specification/blob/v1.20.0/specification/common/README.md#attribute s, _ := attribute.NewSetWithFiltered(attrs, func(kv attribute.KeyValue) bool { diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/batch_span_processor.go b/vendor/go.opentelemetry.io/otel/sdk/trace/batch_span_processor.go index f9f2a6c2c85..2b9560ee7f9 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/batch_span_processor.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/batch_span_processor.go @@ -1,11 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package trace // import "go.opentelemetry.io/otel/sdk/trace" +package trace import ( "context" "errors" + "fmt" "sync" "sync/atomic" "time" @@ -435,11 +436,11 @@ func (bsp *batchSpanProcessor) enqueueDrop(ctx context.Context, sd ReadOnlySpan) func (bsp *batchSpanProcessor) MarshalLog() any { return struct { Type string - SpanExporter SpanExporter + SpanExporter string Config BatchSpanProcessorOptions }{ Type: "BatchSpanProcessor", - SpanExporter: bsp.e, + SpanExporter: fmt.Sprintf("%T", bsp.e), Config: bsp.o, } } diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/doc.go b/vendor/go.opentelemetry.io/otel/sdk/trace/doc.go index b502c7d4798..b292fa3113e 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/doc.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/doc.go @@ -10,4 +10,4 @@ See https://opentelemetry.io. See [go.opentelemetry.io/otel/sdk/internal/x] for information about the experimental features. */ -package trace // import "go.opentelemetry.io/otel/sdk/trace" +package trace diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/event.go b/vendor/go.opentelemetry.io/otel/sdk/trace/event.go index 60a7ed1349b..49eac0459f4 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/event.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/event.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package trace // import "go.opentelemetry.io/otel/sdk/trace" +package trace import ( "time" diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/evictedqueue.go b/vendor/go.opentelemetry.io/otel/sdk/trace/evictedqueue.go index 8c308dd60a9..1f62b528c3e 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/evictedqueue.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/evictedqueue.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package trace // import "go.opentelemetry.io/otel/sdk/trace" +package trace import ( "slices" diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/id_generator.go b/vendor/go.opentelemetry.io/otel/sdk/trace/id_generator.go index 3649322a6e4..be22ac63228 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/id_generator.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/id_generator.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package trace // import "go.opentelemetry.io/otel/sdk/trace" +package trace import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/internal/env/env.go b/vendor/go.opentelemetry.io/otel/sdk/trace/internal/env/env.go index 58f68df4417..1385ae6fc24 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/internal/env/env.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/internal/env/env.go @@ -3,7 +3,7 @@ // Package env provides types and functionality for environment variable support // in the OpenTelemetry SDK. -package env // import "go.opentelemetry.io/otel/sdk/trace/internal/env" +package env import ( "os" diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/internal/observ/batch_span_processor.go b/vendor/go.opentelemetry.io/otel/sdk/trace/internal/observ/batch_span_processor.go index c725ebf372d..896ed517f02 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/internal/observ/batch_span_processor.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/internal/observ/batch_span_processor.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package observ // import "go.opentelemetry.io/otel/sdk/trace/internal/observ" +package observ import ( "context" @@ -13,8 +13,8 @@ import ( "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/sdk" "go.opentelemetry.io/otel/sdk/internal/x" - semconv "go.opentelemetry.io/otel/semconv/v1.41.0" - "go.opentelemetry.io/otel/semconv/v1.41.0/otelconv" + semconv "go.opentelemetry.io/otel/semconv/v1.43.0" + "go.opentelemetry.io/otel/semconv/v1.43.0/otelconv" ) const ( diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/internal/observ/doc.go b/vendor/go.opentelemetry.io/otel/sdk/trace/internal/observ/doc.go index b542121e6a2..64fd5238d04 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/internal/observ/doc.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/internal/observ/doc.go @@ -3,4 +3,4 @@ // Package observ provides observability instrumentation for the OTel trace SDK // package. -package observ // import "go.opentelemetry.io/otel/sdk/trace/internal/observ" +package observ diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/internal/observ/simple_span_processor.go b/vendor/go.opentelemetry.io/otel/sdk/trace/internal/observ/simple_span_processor.go index cf4b5d481fc..89922e4b807 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/internal/observ/simple_span_processor.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/internal/observ/simple_span_processor.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package observ // import "go.opentelemetry.io/otel/sdk/trace/internal/observ" +package observ import ( "context" @@ -13,8 +13,8 @@ import ( "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/sdk" "go.opentelemetry.io/otel/sdk/internal/x" - semconv "go.opentelemetry.io/otel/semconv/v1.41.0" - "go.opentelemetry.io/otel/semconv/v1.41.0/otelconv" + semconv "go.opentelemetry.io/otel/semconv/v1.43.0" + "go.opentelemetry.io/otel/semconv/v1.43.0/otelconv" ) var measureAttrsPool = sync.Pool{ diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/internal/observ/tracer.go b/vendor/go.opentelemetry.io/otel/sdk/trace/internal/observ/tracer.go index 5aae89e883c..3428aa89497 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/internal/observ/tracer.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/internal/observ/tracer.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package observ // import "go.opentelemetry.io/otel/sdk/trace/internal/observ" +package observ import ( "context" @@ -13,7 +13,7 @@ import ( "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/sdk" "go.opentelemetry.io/otel/sdk/internal/x" - "go.opentelemetry.io/otel/semconv/v1.41.0/otelconv" + "go.opentelemetry.io/otel/semconv/v1.43.0/otelconv" "go.opentelemetry.io/otel/trace" ) diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/link.go b/vendor/go.opentelemetry.io/otel/sdk/trace/link.go index c03bdc90f68..d4a07a714be 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/link.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/link.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package trace // import "go.opentelemetry.io/otel/sdk/trace" +package trace import ( "go.opentelemetry.io/otel/attribute" diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/provider.go b/vendor/go.opentelemetry.io/otel/sdk/trace/provider.go index 9d90c2eda5a..6b2368413a1 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/provider.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/provider.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package trace // import "go.opentelemetry.io/otel/sdk/trace" +package trace import ( "context" @@ -13,6 +13,7 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/internal/global" "go.opentelemetry.io/otel/sdk/instrumentation" + "go.opentelemetry.io/otel/sdk/internal/attrnorm" "go.opentelemetry.io/otel/sdk/resource" "go.opentelemetry.io/otel/sdk/trace/internal/observ" "go.opentelemetry.io/otel/trace" @@ -42,22 +43,27 @@ type tracerProviderConfig struct { // resource contains attributes representing an entity that produces telemetry. resource *resource.Resource + + // panicRecordingDisabled disables recording exception events from panics. + panicRecordingDisabled bool } // MarshalLog is the marshaling function used by the logging system to represent this Provider. func (cfg tracerProviderConfig) MarshalLog() any { return struct { - SpanProcessors []SpanProcessor - SamplerType string - IDGeneratorType string - SpanLimits SpanLimits - Resource *resource.Resource + SpanProcessors []SpanProcessor + SamplerType string + IDGeneratorType string + SpanLimits SpanLimits + Resource *resource.Resource + PanicRecordingDisabled bool }{ - SpanProcessors: cfg.processors, - SamplerType: fmt.Sprintf("%T", cfg.sampler), - IDGeneratorType: fmt.Sprintf("%T", cfg.idGenerator), - SpanLimits: cfg.spanLimits, - Resource: cfg.resource, + SpanProcessors: cfg.processors, + SamplerType: fmt.Sprintf("%T", cfg.sampler), + IDGeneratorType: fmt.Sprintf("%T", cfg.idGenerator), + SpanLimits: cfg.spanLimits, + Resource: cfg.resource, + PanicRecordingDisabled: cfg.panicRecordingDisabled, } } @@ -74,10 +80,11 @@ type TracerProvider struct { // These fields are not protected by the lock mu. They are assumed to be // immutable after creation of the TracerProvider. - sampler Sampler - idGenerator IDGenerator - spanLimits SpanLimits - resource *resource.Resource + sampler Sampler + idGenerator IDGenerator + spanLimits SpanLimits + resource *resource.Resource + panicRecordingDisabled bool } var _ trace.TracerProvider = &TracerProvider{} @@ -112,11 +119,12 @@ func NewTracerProvider(opts ...TracerProviderOption) *TracerProvider { o = ensureValidTracerProviderConfig(o) tp := &TracerProvider{ - namedTracer: make(map[instrumentation.Scope]*tracer), - sampler: o.sampler, - idGenerator: o.idGenerator, - spanLimits: o.spanLimits, - resource: o.resource, + namedTracer: make(map[instrumentation.Scope]*tracer), + sampler: o.sampler, + idGenerator: o.idGenerator, + spanLimits: o.spanLimits, + resource: o.resource, + panicRecordingDisabled: o.panicRecordingDisabled, } global.Info("TracerProvider created", "config", o) @@ -142,6 +150,7 @@ func (p *TracerProvider) Tracer(name string, opts ...trace.TracerOption) trace.T return noop.NewTracerProvider().Tracer(name, opts...) } c := trace.NewTracerConfig(opts...) + attrs, _ := attrnorm.Set(c.InstrumentationAttributes()) if name == "" { name = defaultTracerName } @@ -149,7 +158,7 @@ func (p *TracerProvider) Tracer(name string, opts ...trace.TracerOption) trace.T Name: name, Version: c.InstrumentationVersion(), SchemaURL: c.SchemaURL(), - Attributes: c.InstrumentationAttributes(), + Attributes: attrs, } t, ok := func() (trace.Tracer, bool) { @@ -357,6 +366,16 @@ func WithSpanProcessor(sp SpanProcessor) TracerProviderOption { }) } +// WithoutPanicRecording configures the TracerProvider to not record exception +// events when a Span is ended while panicking. The panic continues to +// propagate, and the span is ended without adding the event. +func WithoutPanicRecording() TracerProviderOption { + return traceProviderOptionFunc(func(cfg tracerProviderConfig) tracerProviderConfig { + cfg.panicRecordingDisabled = true + return cfg + }) +} + // WithResource returns a TracerProviderOption that will configure the // Resource r as a TracerProvider's Resource. The configured Resource is // referenced by all the Tracers the TracerProvider creates. It represents the diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/sampler_env.go b/vendor/go.opentelemetry.io/otel/sdk/trace/sampler_env.go index 9b672a1d70d..b0fa94ed2d6 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/sampler_env.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/sampler_env.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package trace // import "go.opentelemetry.io/otel/sdk/trace" +package trace import ( "errors" diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/sampling.go b/vendor/go.opentelemetry.io/otel/sdk/trace/sampling.go index 5a4c74318b8..c79177ae8d5 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/sampling.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/sampling.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package trace // import "go.opentelemetry.io/otel/sdk/trace" +package trace import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/simple_span_processor.go b/vendor/go.opentelemetry.io/otel/sdk/trace/simple_span_processor.go index 771e427a4c5..e9bec439483 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/simple_span_processor.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/simple_span_processor.go @@ -1,10 +1,11 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package trace // import "go.opentelemetry.io/otel/sdk/trace" +package trace import ( "context" + "fmt" "sync" "sync/atomic" @@ -140,11 +141,18 @@ func (*simpleSpanProcessor) ForceFlush(context.Context) error { // MarshalLog is the marshaling function used by the logging system to represent // this Span Processor. func (ssp *simpleSpanProcessor) MarshalLog() any { + // Shutdown clears exporter under exporterMu. + // Copy it while holding the same lock so MarshalLog + // can run concurrently without racing with Shutdown. + ssp.exporterMu.Lock() + exp := ssp.exporter + ssp.exporterMu.Unlock() + return struct { Type string - Exporter SpanExporter + Exporter string }{ Type: "SimpleSpanProcessor", - Exporter: ssp.exporter, + Exporter: fmt.Sprintf("%T", exp), } } diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/snapshot.go b/vendor/go.opentelemetry.io/otel/sdk/trace/snapshot.go index 63aa337800c..8893dc39f13 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/snapshot.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/snapshot.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package trace // import "go.opentelemetry.io/otel/sdk/trace" +package trace import ( "time" diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/span.go b/vendor/go.opentelemetry.io/otel/sdk/trace/span.go index d1d9af29d79..0aae5f5bb2f 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/span.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/span.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package trace // import "go.opentelemetry.io/otel/sdk/trace" +package trace import ( "context" @@ -10,17 +10,16 @@ import ( "runtime" rt "runtime/trace" "slices" - "strings" "sync" "time" - "unicode/utf8" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/internal/global" "go.opentelemetry.io/otel/sdk/instrumentation" + "go.opentelemetry.io/otel/sdk/internal/attrnorm" "go.opentelemetry.io/otel/sdk/resource" - semconv "go.opentelemetry.io/otel/semconv/v1.41.0" + semconv "go.opentelemetry.io/otel/semconv/v1.43.0" "go.opentelemetry.io/otel/trace" "go.opentelemetry.io/otel/trace/embedded" ) @@ -269,7 +268,8 @@ func (s *recordingSpan) SetAttributes(attributes ...attribute.KeyValue) { s.addDroppedAttr(1) continue } - a = truncateAttr(s.tracer.provider.spanLimits.AttributeValueLengthLimit, a) + a = dedupAttr(a) + a = attrnorm.Truncate(s.tracer.provider.spanLimits.AttributeValueLengthLimit, a) s.attributes = append(s.attributes, a) } } @@ -329,7 +329,8 @@ func (s *recordingSpan) addOverCapAttrs(limit int, attrs []attribute.KeyValue) { if idx, ok := exists[a.Key]; ok { // Perform all updates before dropping, even when at capacity. - a = truncateAttr(s.tracer.provider.spanLimits.AttributeValueLengthLimit, a) + a = dedupAttr(a) + a = attrnorm.Truncate(s.tracer.provider.spanLimits.AttributeValueLengthLimit, a) s.attributes[idx] = a continue } @@ -339,208 +340,31 @@ func (s *recordingSpan) addOverCapAttrs(limit int, attrs []attribute.KeyValue) { // updates are checked and performed. s.addDroppedAttr(1) } else { - a = truncateAttr(s.tracer.provider.spanLimits.AttributeValueLengthLimit, a) + a = dedupAttr(a) + a = attrnorm.Truncate(s.tracer.provider.spanLimits.AttributeValueLengthLimit, a) s.attributes = append(s.attributes, a) exists[a.Key] = len(s.attributes) - 1 } } } -// truncateAttr returns a truncated version of attr. Only string, string -// slice, byte slice, and slice attribute values are truncated. String values are truncated -// to at most a length of limit. Each string slice value is truncated in this -// fashion (the slice length itself is unaffected), and byte slice values are truncated to at most -// limit bytes. For slice attribute values, the limit is applied to each -// element recursively. -// -// No truncation is performed for a negative limit. -func truncateAttr(limit int, attr attribute.KeyValue) attribute.KeyValue { - if limit < 0 { - return attr - } +func dedupAttr(attr attribute.KeyValue) attribute.KeyValue { switch attr.Value.Type() { - case attribute.STRING: - v := attr.Value.AsString() - return attr.Key.String(truncate(limit, v)) - case attribute.STRINGSLICE: - v := attr.Value.AsStringSlice() - for i := range v { - v[i] = truncate(limit, v[i]) - } - return attr.Key.StringSlice(v) - case attribute.BYTESLICE: - v := attr.Value.AsString() - if len(v) > limit { - return attr.Key.ByteSlice([]byte(v[:limit])) - } + case attribute.SLICE, attribute.MAP: + attr, _ = attrnorm.KeyValue(attr) + return attr + default: return attr - case attribute.SLICE: - v := attr.Value.AsSlice() - if !slices.ContainsFunc(v, func(e attribute.Value) bool { return needsTruncation(limit, e) }) { - return attr - } - newV := make([]attribute.Value, len(v)) - for i, elem := range v { - newV[i] = truncateValue(limit, elem) - } - return attr.Key.Slice(newV...) - } - return attr -} - -// truncateValue returns a truncated version of v. Only string, string slice, -// byte slice, and (recursively) slice values are modified. -// -// No truncation is performed for a negative limit. -func truncateValue(limit int, v attribute.Value) attribute.Value { - switch v.Type() { - case attribute.STRING: - return attribute.StringValue(truncate(limit, v.AsString())) - case attribute.STRINGSLICE: - ss := v.AsStringSlice() - for i := range ss { - ss[i] = truncate(limit, ss[i]) - } - return attribute.StringSliceValue(ss) - - case attribute.BYTESLICE: - // len(v.AsString()) is identical to len(v.AsByteSlice()) but - // avoids allocating the full slice before truncation. - s := v.AsString() - if limit >= 0 && len(s) > limit { - return attribute.ByteSliceValue([]byte(s[:limit])) - } - case attribute.SLICE: - sl := v.AsSlice() - if !slices.ContainsFunc(sl, func(e attribute.Value) bool { return needsTruncation(limit, e) }) { - return v - } - newSl := make([]attribute.Value, len(sl)) - for i, elem := range sl { - newSl[i] = truncateValue(limit, elem) - } - return attribute.SliceValue(newSl...) - } - return v -} - -// stringNeedsTruncation reports whether s would be modified by truncate for the -// given limit. -func stringNeedsTruncation(limit int, s string) bool { - if limit < 0 || len(s) <= limit { - return false - } - return utf8.RuneCountInString(s) > limit || !utf8.ValidString(s) -} - -// needsTruncation reports whether v would be modified by truncateValue for the -// given limit. -func needsTruncation(limit int, v attribute.Value) bool { - switch v.Type() { - case attribute.STRING: - return stringNeedsTruncation(limit, v.AsString()) - case attribute.BYTESLICE: - // len(v.AsString()) is identical to len(v.AsByteSlice()) but - // avoids memory allocation. - if limit >= 0 && len(v.AsString()) > limit { - return true - } - case attribute.STRINGSLICE: - for _, s := range v.AsStringSlice() { - if stringNeedsTruncation(limit, s) { - return true - } - } - case attribute.SLICE: - return slices.ContainsFunc(v.AsSlice(), func(e attribute.Value) bool { return needsTruncation(limit, e) }) - } - return false -} - -// truncate returns a truncated version of s such that it contains less than -// the limit number of characters. Truncation is applied by returning the limit -// number of valid characters contained in s. -// -// If limit is negative, it returns the original string. -// -// UTF-8 is supported. When truncating, all invalid characters are dropped -// before applying truncation. -// -// If s already contains less than the limit number of bytes, it is returned -// unchanged. No invalid characters are removed. -func truncate(limit int, s string) string { - // This prioritize performance in the following order based on the most - // common expected use-cases. - // - // - Short values less than the default limit (128). - // - Strings with valid encodings that exceed the limit. - // - No limit. - // - Strings with invalid encodings that exceed the limit. - if limit < 0 || len(s) <= limit { - return s - } - - // Optimistically, assume all valid UTF-8. - var b strings.Builder - count := 0 - for i, c := range s { - if c != utf8.RuneError { - count++ - if count > limit { - return s[:i] - } - continue - } - - _, size := utf8.DecodeRuneInString(s[i:]) - if size == 1 { - // Invalid encoding. - b.Grow(len(s) - 1) - _, _ = b.WriteString(s[:i]) - s = s[i:] - break - } - } - - // Fast-path, no invalid input. - if b.Cap() == 0 { - return s - } - - // Truncate while validating UTF-8. - for i := 0; i < len(s) && count < limit; { - c := s[i] - if c < utf8.RuneSelf { - // Optimization for single byte runes (common case). - _ = b.WriteByte(c) - i++ - count++ - continue - } - - _, size := utf8.DecodeRuneInString(s[i:]) - if size == 1 { - // We checked for all 1-byte runes above, this is a RuneError. - i++ - continue - } - - _, _ = b.WriteString(s[i : i+size]) - i += size - count++ } - - return b.String() } // End ends the span. This method does nothing if the span is already ended or // is not being recorded. // -// The only SpanEndOption currently supported are [trace.WithTimestamp], and -// [trace.WithStackTrace]. -// -// If this method is called while panicking an error event is added to the -// Span before ending it and the panic is continued. +// The only supported SpanEndOptions are [trace.WithTimestamp] and [trace.WithStackTrace]. +// If this method is called while panicking and panic recording is not disabled +// on the TracerProvider, an error event is added to the Span before ending it +// and the panic is continued. func (s *recordingSpan) End(options ...trace.SpanEndOption) { // Do not start by checking if the span is being recorded which requires // acquiring a lock. Make a minimal check that the span is not nil. @@ -560,23 +384,25 @@ func (s *recordingSpan) End(options ...trace.SpanEndOption) { } config := trace.NewSpanEndConfig(options...) - if recovered := recover(); recovered != nil { - // Record but don't stop the panic. - defer panic(recovered) - opts := []trace.EventOption{ - trace.WithAttributes( - semconv.ExceptionType(typeStr(recovered)), - semconv.ExceptionMessage(fmt.Sprint(recovered)), - ), - } + if !s.tracer.provider.panicRecordingDisabled { + if recovered := recover(); recovered != nil { + // Record but don't stop the panic. + defer panic(recovered) + opts := []trace.EventOption{ + trace.WithAttributes( + semconv.ExceptionType(typeStr(recovered)), + semconv.ExceptionMessage(fmt.Sprint(recovered)), + ), + } - if config.StackTrace() { - opts = append(opts, trace.WithAttributes( - semconv.ExceptionStacktrace(recordStackTrace()), - )) - } + if config.StackTrace() { + opts = append(opts, trace.WithAttributes( + semconv.ExceptionStacktrace(recordStackTrace()), + )) + } - s.addEvent(semconv.ExceptionEventName, opts...) + s.addEvent(semconv.ExceptionEventName, opts...) + } } if s.executionTracerTaskEnd != nil { @@ -690,7 +516,8 @@ func (s *recordingSpan) AddEvent(name string, o ...trace.EventOption) { // This method assumes s.mu.Lock is held by the caller. func (s *recordingSpan) addEvent(name string, o ...trace.EventOption) { c := trace.NewEventConfig(o...) - e := Event{Name: name, Attributes: c.Attributes(), Time: c.Timestamp()} + attrs, _ := attrnorm.KeyValues(c.Attributes()) + e := Event{Name: name, Attributes: attrs, Time: c.Timestamp()} // Discard attributes over limit. limit := s.tracer.provider.spanLimits.AttributePerEventCountLimit @@ -863,7 +690,8 @@ func (s *recordingSpan) AddLink(link trace.Link) { return } - l := Link{SpanContext: link.SpanContext, Attributes: link.Attributes} + attrs, _ := attrnorm.KeyValues(link.Attributes) + l := Link{SpanContext: link.SpanContext, Attributes: attrs} // Discard attributes over limit. limit := s.tracer.provider.spanLimits.AttributePerLinkCountLimit diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/span_exporter.go b/vendor/go.opentelemetry.io/otel/sdk/trace/span_exporter.go index 6bdda3d94a4..fad839a24e4 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/span_exporter.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/span_exporter.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package trace // import "go.opentelemetry.io/otel/sdk/trace" +package trace import "context" diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/span_limits.go b/vendor/go.opentelemetry.io/otel/sdk/trace/span_limits.go index 348ee0e808b..5ee15a88485 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/span_limits.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/span_limits.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package trace // import "go.opentelemetry.io/otel/sdk/trace" +package trace import "go.opentelemetry.io/otel/sdk/trace/internal/env" @@ -35,10 +35,10 @@ const ( type SpanLimits struct { // AttributeValueLengthLimit is the maximum allowed attribute value length. // - // This limit only applies to string, string slice, byte slice, and slice attribute - // values. Any string and byte slice longer than this value will be truncated to this - // length. For slice attribute values, the limit is applied to each string and byte slice - // element recursively. + // This limit only applies to string, string slice, byte slice, slice, and + // map attribute values. Any string and byte slice longer than this value + // will be truncated to this length. For slice and map attribute values, + // the limit is applied recursively to contained values. // // Setting this to a negative value means no limit is applied. AttributeValueLengthLimit int diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/span_processor.go b/vendor/go.opentelemetry.io/otel/sdk/trace/span_processor.go index af7f9177fc5..ffd093a2f7e 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/span_processor.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/span_processor.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package trace // import "go.opentelemetry.io/otel/sdk/trace" +package trace import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/tracer.go b/vendor/go.opentelemetry.io/otel/sdk/trace/tracer.go index e1d08fd4d8d..be576ffe088 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/tracer.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/tracer.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package trace // import "go.opentelemetry.io/otel/sdk/trace" +package trace import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/tracetest/exporter.go b/vendor/go.opentelemetry.io/otel/sdk/trace/tracetest/exporter.go index e12fa67e63b..4aa2d562fdd 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/tracetest/exporter.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/tracetest/exporter.go @@ -4,7 +4,7 @@ // Package tracetest is a testing helper package for the SDK. User can // configure no-op or in-memory exporters to verify different SDK behaviors or // custom instrumentation. -package tracetest // import "go.opentelemetry.io/otel/sdk/trace/tracetest" +package tracetest import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/tracetest/recorder.go b/vendor/go.opentelemetry.io/otel/sdk/trace/tracetest/recorder.go index ca63038f34e..11e3d5b3f61 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/tracetest/recorder.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/tracetest/recorder.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package tracetest // import "go.opentelemetry.io/otel/sdk/trace/tracetest" +package tracetest import ( "context" diff --git a/vendor/go.opentelemetry.io/otel/sdk/trace/tracetest/span.go b/vendor/go.opentelemetry.io/otel/sdk/trace/tracetest/span.go index 12b384b0884..6ee1b3f9854 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/trace/tracetest/span.go +++ b/vendor/go.opentelemetry.io/otel/sdk/trace/tracetest/span.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package tracetest // import "go.opentelemetry.io/otel/sdk/trace/tracetest" +package tracetest import ( "time" diff --git a/vendor/go.opentelemetry.io/otel/sdk/version.go b/vendor/go.opentelemetry.io/otel/sdk/version.go index 218dce1f562..1619fb3fa13 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/version.go +++ b/vendor/go.opentelemetry.io/otel/sdk/version.go @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // Package sdk provides the OpenTelemetry default SDK for Go. -package sdk // import "go.opentelemetry.io/otel/sdk" +package sdk // Version is the current release version of the OpenTelemetry SDK in use. func Version() string { - return "1.44.0" + return "1.45.0" } diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.41.0/otelconv/metric.go b/vendor/go.opentelemetry.io/otel/semconv/v1.43.0/otelconv/metric.go similarity index 94% rename from vendor/go.opentelemetry.io/otel/semconv/v1.41.0/otelconv/metric.go rename to vendor/go.opentelemetry.io/otel/semconv/v1.43.0/otelconv/metric.go index 367b5876020..9eaf0fd9a2d 100644 --- a/vendor/go.opentelemetry.io/otel/semconv/v1.41.0/otelconv/metric.go +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.43.0/otelconv/metric.go @@ -187,6 +187,12 @@ func (SDKExporterLogExported) Description() string { // non-rejected log records count as success. // If no rejection reason is available, `rejected` SHOULD be used as value for // `error.type`. +// If the exporter retries failed export attempts, the export operation is +// considered finished only after the final attempt has concluded. +// Each log record MUST be counted exactly once per export operation: +// intermediate failed attempts that are followed by a retry MUST NOT increment +// the counter, +// and `error.type` reflects the cause of the final attempt. func (m SDKExporterLogExported) Add( ctx context.Context, incr int64, @@ -222,6 +228,12 @@ func (m SDKExporterLogExported) Add( // non-rejected log records count as success. // If no rejection reason is available, `rejected` SHOULD be used as value for // `error.type`. +// If the exporter retries failed export attempts, the export operation is +// considered finished only after the final attempt has concluded. +// Each log record MUST be counted exactly once per export operation: +// intermediate failed attempts that are followed by a retry MUST NOT increment +// the counter, +// and `error.type` reflects the cause of the final attempt. func (m SDKExporterLogExported) AddSet(ctx context.Context, incr int64, set attribute.Set) { if !m.Int64Counter.Enabled(ctx) { return @@ -429,8 +441,10 @@ func (SDKExporterLogInflight) Description() string { // // All additional attrs passed are included in the recorded value. // -// For successful exports, `error.type` MUST NOT be set. For failed exports, -// `error.type` MUST contain the failure cause. +// Log records are counted as inflight from when they are passed to the exporter +// until the export operation has concluded. +// If the exporter retries failed export attempts, log records remain inflight +// across all retry attempts and any backoff between them. func (m SDKExporterLogInflight) Add( ctx context.Context, incr int64, @@ -459,8 +473,10 @@ func (m SDKExporterLogInflight) Add( // AddSet adds incr to the existing count for set. // -// For successful exports, `error.type` MUST NOT be set. For failed exports, -// `error.type` MUST contain the failure cause. +// Log records are counted as inflight from when they are passed to the exporter +// until the export operation has concluded. +// If the exporter retries failed export attempts, log records remain inflight +// across all retry attempts and any backoff between them. func (m SDKExporterLogInflight) AddSet(ctx context.Context, incr int64, set attribute.Set) { if !m.Int64UpDownCounter.Enabled(ctx) { return @@ -662,6 +678,12 @@ func (SDKExporterMetricDataPointExported) Description() string { // non-rejected data points count as success. // If no rejection reason is available, `rejected` SHOULD be used as value for // `error.type`. +// If the exporter retries failed export attempts, the export operation is +// considered finished only after the final attempt has concluded. +// Each metric data point MUST be counted exactly once per export operation: +// intermediate failed attempts that are followed by a retry MUST NOT increment +// the counter, +// and `error.type` reflects the cause of the final attempt. func (m SDKExporterMetricDataPointExported) Add( ctx context.Context, incr int64, @@ -697,6 +719,12 @@ func (m SDKExporterMetricDataPointExported) Add( // non-rejected data points count as success. // If no rejection reason is available, `rejected` SHOULD be used as value for // `error.type`. +// If the exporter retries failed export attempts, the export operation is +// considered finished only after the final attempt has concluded. +// Each metric data point MUST be counted exactly once per export operation: +// intermediate failed attempts that are followed by a retry MUST NOT increment +// the counter, +// and `error.type` reflects the cause of the final attempt. func (m SDKExporterMetricDataPointExported) AddSet(ctx context.Context, incr int64, set attribute.Set) { if !m.Int64Counter.Enabled(ctx) { return @@ -906,8 +934,10 @@ func (SDKExporterMetricDataPointInflight) Description() string { // // All additional attrs passed are included in the recorded value. // -// For successful exports, `error.type` MUST NOT be set. For failed exports, -// `error.type` MUST contain the failure cause. +// Metric data points are counted as inflight from when they are passed to the +// exporter until the export operation has concluded. +// If the exporter retries failed export attempts, metric data points remain +// inflight across all retry attempts and any backoff between them. func (m SDKExporterMetricDataPointInflight) Add( ctx context.Context, incr int64, @@ -936,8 +966,10 @@ func (m SDKExporterMetricDataPointInflight) Add( // AddSet adds incr to the existing count for set. // -// For successful exports, `error.type` MUST NOT be set. For failed exports, -// `error.type` MUST contain the failure cause. +// Metric data points are counted as inflight from when they are passed to the +// exporter until the export operation has concluded. +// If the exporter retries failed export attempts, metric data points remain +// inflight across all retry attempts and any backoff between them. func (m SDKExporterMetricDataPointInflight) AddSet(ctx context.Context, incr int64, set attribute.Set) { if !m.Int64UpDownCounter.Enabled(ctx) { return @@ -1138,6 +1170,11 @@ func (SDKExporterOperationDuration) Description() string { // successful // operations, `error.type` MUST NOT be set. For unsuccessful export operations, // `error.type` MUST contain a relevant failure cause. +// If the exporter retries failed export attempts, exactly one observation MUST +// be recorded per export operation, +// covering the wall-clock duration from the start of the first attempt through +// the conclusion of the final attempt (including any backoff between attempts). +// `error.type` reflects the cause of the final attempt. // // [http]: https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/docs/specification.md#full-success-1 // [grpc]: https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/docs/specification.md#full-success @@ -1175,6 +1212,11 @@ func (m SDKExporterOperationDuration) Record( // successful // operations, `error.type` MUST NOT be set. For unsuccessful export operations, // `error.type` MUST contain a relevant failure cause. +// If the exporter retries failed export attempts, exactly one observation MUST +// be recorded per export operation, +// covering the wall-clock duration from the start of the first attempt through +// the conclusion of the final attempt (including any backoff between attempts). +// `error.type` reflects the cause of the final attempt. // // [http]: https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/docs/specification.md#full-success-1 // [grpc]: https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/docs/specification.md#full-success @@ -1312,6 +1354,11 @@ func (SDKExporterSpanExported) Description() string { // success. // If no rejection reason is available, `rejected` SHOULD be used as value for // `error.type`. +// If the exporter retries failed export attempts, the export operation is +// considered finished only after the final attempt has concluded. +// Each span MUST be counted exactly once per export operation: intermediate +// failed attempts that are followed by a retry MUST NOT increment the counter, +// and `error.type` reflects the cause of the final attempt. func (m SDKExporterSpanExported) Add( ctx context.Context, incr int64, @@ -1347,6 +1394,11 @@ func (m SDKExporterSpanExported) Add( // success. // If no rejection reason is available, `rejected` SHOULD be used as value for // `error.type`. +// If the exporter retries failed export attempts, the export operation is +// considered finished only after the final attempt has concluded. +// Each span MUST be counted exactly once per export operation: intermediate +// failed attempts that are followed by a retry MUST NOT increment the counter, +// and `error.type` reflects the cause of the final attempt. func (m SDKExporterSpanExported) AddSet(ctx context.Context, incr int64, set attribute.Set) { if !m.Int64Counter.Enabled(ctx) { return @@ -1554,8 +1606,10 @@ func (SDKExporterSpanInflight) Description() string { // // All additional attrs passed are included in the recorded value. // -// For successful exports, `error.type` MUST NOT be set. For failed exports, -// `error.type` MUST contain the failure cause. +// Spans are counted as inflight from when they are passed to the exporter until +// the export operation has concluded. +// If the exporter retries failed export attempts, spans remain inflight across +// all retry attempts and any backoff between them. func (m SDKExporterSpanInflight) Add( ctx context.Context, incr int64, @@ -1584,8 +1638,10 @@ func (m SDKExporterSpanInflight) Add( // AddSet adds incr to the existing count for set. // -// For successful exports, `error.type` MUST NOT be set. For failed exports, -// `error.type` MUST contain the failure cause. +// Spans are counted as inflight from when they are passed to the exporter until +// the export operation has concluded. +// If the exporter retries failed export attempts, spans remain inflight across +// all retry attempts and any backoff between them. func (m SDKExporterSpanInflight) AddSet(ctx context.Context, incr int64, set attribute.Set) { if !m.Int64UpDownCounter.Enabled(ctx) { return @@ -2071,6 +2127,11 @@ func (SDKProcessorLogProcessed) Description() string { // // For successful processing, `error.type` MUST NOT be set. For failed // processing, `error.type` MUST contain the failure cause. +// SDK Batching Log Record Processors MUST use `queue_full` as the value of +// `error.type` for log records dropped due to a full queue. +// SDK Log Record Processors MUST use `already_shutdown` as the value of +// `error.type` for log records dropped because the processor has already been +// shut down. // For the SDK Simple and Batching Log Record Processor a log record is // considered to be processed already when it has been submitted to the exporter, // not when the corresponding export call has finished. @@ -2104,6 +2165,11 @@ func (m SDKProcessorLogProcessed) Add( // // For successful processing, `error.type` MUST NOT be set. For failed // processing, `error.type` MUST contain the failure cause. +// SDK Batching Log Record Processors MUST use `queue_full` as the value of +// `error.type` for log records dropped due to a full queue. +// SDK Log Record Processors MUST use `already_shutdown` as the value of +// `error.type` for log records dropped because the processor has already been +// shut down. // For the SDK Simple and Batching Log Record Processor a log record is // considered to be processed already when it has been submitted to the exporter, // not when the corresponding export call has finished. @@ -2125,8 +2191,6 @@ func (m SDKProcessorLogProcessed) AddSet(ctx context.Context, incr int64, set at // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents a low-cardinality description of the failure reason. -// SDK Batching Log Record Processors MUST use `queue_full` for log records -// dropped due to a full queue. func (SDKProcessorLogProcessed) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue { return attribute.String("error.type", string(val)) } @@ -2207,8 +2271,6 @@ func (SDKProcessorLogProcessedObservable) Description() string { // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents a low-cardinality description of the failure reason. -// SDK Batching Log Record Processors MUST use `queue_full` for log records -// dropped due to a full queue. func (SDKProcessorLogProcessedObservable) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue { return attribute.String("error.type", string(val)) } @@ -2440,6 +2502,10 @@ func (SDKProcessorSpanProcessed) Description() string { // // For successful processing, `error.type` MUST NOT be set. For failed // processing, `error.type` MUST contain the failure cause. +// SDK Batching Span Processors MUST use `queue_full` as the value of +// `error.type` for spans dropped due to a full queue. +// SDK Span Processors MUST use `already_shutdown` as the value of `error.type` +// for spans dropped because the processor has already been shut down. // For the SDK Simple and Batching Span Processor a span is considered to be // processed already when it has been submitted to the exporter, not when the // corresponding export call has finished. @@ -2473,6 +2539,10 @@ func (m SDKProcessorSpanProcessed) Add( // // For successful processing, `error.type` MUST NOT be set. For failed // processing, `error.type` MUST contain the failure cause. +// SDK Batching Span Processors MUST use `queue_full` as the value of +// `error.type` for spans dropped due to a full queue. +// SDK Span Processors MUST use `already_shutdown` as the value of `error.type` +// for spans dropped because the processor has already been shut down. // For the SDK Simple and Batching Span Processor a span is considered to be // processed already when it has been submitted to the exporter, not when the // corresponding export call has finished. @@ -2494,8 +2564,6 @@ func (m SDKProcessorSpanProcessed) AddSet(ctx context.Context, incr int64, set a // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents a low-cardinality description of the failure reason. -// SDK Batching Span Processors MUST use `queue_full` for spans dropped due to a -// full queue. func (SDKProcessorSpanProcessed) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue { return attribute.String("error.type", string(val)) } @@ -2576,8 +2644,6 @@ func (SDKProcessorSpanProcessedObservable) Description() string { // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents a low-cardinality description of the failure reason. -// SDK Batching Span Processors MUST use `queue_full` for spans dropped due to a -// full queue. func (SDKProcessorSpanProcessedObservable) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue { return attribute.String("error.type", string(val)) } @@ -2806,6 +2872,9 @@ func (SDKSpanLive) Description() string { // Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. +// +// Non-recording spans are not counted, hence `otel.span.sampling_result` can +// only take values `RECORD_ONLY` and `RECORD_AND_SAMPLE`, not `DROP`. func (m SDKSpanLive) Add( ctx context.Context, incr int64, @@ -2833,6 +2902,9 @@ func (m SDKSpanLive) Add( } // AddSet adds incr to the existing count for set. +// +// Non-recording spans are not counted, hence `otel.span.sampling_result` can +// only take values `RECORD_ONLY` and `RECORD_AND_SAMPLE`, not `DROP`. func (m SDKSpanLive) AddSet(ctx context.Context, incr int64, set attribute.Set) { if !m.Int64UpDownCounter.Enabled(ctx) { return diff --git a/vendor/go.opentelemetry.io/proto/otlp/common/v1/common.pb.go b/vendor/go.opentelemetry.io/proto/otlp/common/v1/common.pb.go index 304f6476374..cef3580008e 100644 --- a/vendor/go.opentelemetry.io/proto/otlp/common/v1/common.pb.go +++ b/vendor/go.opentelemetry.io/proto/otlp/common/v1/common.pb.go @@ -194,7 +194,7 @@ type AnyValue_StringValueStrindex struct { // Profiling signal and process the data as if this value were absent or // empty, ignoring its semantic content for the non-Profiling signal. // - // Status: [Development] + // Status: [Alpha] StringValueStrindex int32 `protobuf:"varint,8,opt,name=string_value_strindex,json=stringValueStrindex,proto3,oneof"` } @@ -330,7 +330,7 @@ type KeyValue struct { unknownFields protoimpl.UnknownFields // The key name of the pair. - // key_ref MUST NOT be set if key is used. + // key_strindex MUST NOT be set if key is used. Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` // The value of the pair. Value *AnyValue `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` @@ -344,7 +344,7 @@ type KeyValue struct { // Profiling signal and process the data as if this value were absent or // empty, ignoring its semantic content for the non-Profiling signal. // - // Status: [Development] + // Status: [Alpha] KeyStrindex int32 `protobuf:"varint,3,opt,name=key_strindex,json=keyStrindex,proto3" json:"key_strindex,omitempty"` } diff --git a/vendor/go.yaml.in/yaml/v3/parserc.go b/vendor/go.yaml.in/yaml/v3/parserc.go index 25fe823637a..f35829db4da 100644 --- a/vendor/go.yaml.in/yaml/v3/parserc.go +++ b/vendor/go.yaml.in/yaml/v3/parserc.go @@ -226,9 +226,9 @@ func yaml_parser_state_machine(parser *yaml_parser_t, event *yaml_event_t) bool } // Parse the production: -// stream ::= STREAM-START implicit_document? explicit_document* STREAM-END // -// ************ +// stream ::= STREAM-START implicit_document? explicit_document* STREAM-END +// ************ func yaml_parser_parse_stream_start(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { @@ -249,13 +249,11 @@ func yaml_parser_parse_stream_start(parser *yaml_parser_t, event *yaml_event_t) } // Parse the productions: -// implicit_document ::= block_node DOCUMENT-END* -// -// * // -// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* -// -// ************************* +// implicit_document ::= block_node DOCUMENT-END* +// * +// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* +// ************************* func yaml_parser_parse_document_start(parser *yaml_parser_t, event *yaml_event_t, implicit bool) bool { token := peek_token(parser) @@ -359,9 +357,9 @@ func yaml_parser_parse_document_start(parser *yaml_parser_t, event *yaml_event_t } // Parse the productions: -// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* // -// *********** +// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* +// *********** func yaml_parser_parse_document_content(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { @@ -382,11 +380,10 @@ func yaml_parser_parse_document_content(parser *yaml_parser_t, event *yaml_event } // Parse the productions: -// implicit_document ::= block_node DOCUMENT-END* -// -// ************* // -// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* +// implicit_document ::= block_node DOCUMENT-END* +// ************* +// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* func yaml_parser_parse_document_end(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { @@ -432,42 +429,32 @@ func yaml_parser_set_event_comments(parser *yaml_parser_t, event *yaml_event_t) } // Parse the productions: -// block_node_or_indentless_sequence ::= -// -// ALIAS -// ***** -// | properties (block_content | indentless_block_sequence)? -// ********** * -// | block_content | indentless_block_sequence -// * -// -// block_node ::= ALIAS -// -// ***** -// | properties block_content? -// ********** * -// | block_content -// * -// -// flow_node ::= ALIAS -// -// ***** -// | properties flow_content? -// ********** * -// | flow_content -// * -// -// properties ::= TAG ANCHOR? | ANCHOR TAG? -// -// ************************* -// -// block_content ::= block_collection | flow_collection | SCALAR -// -// ****** // -// flow_content ::= flow_collection | SCALAR -// -// ****** +// block_node_or_indentless_sequence ::= +// ALIAS +// ***** +// | properties (block_content | indentless_block_sequence)? +// ********** * +// | block_content | indentless_block_sequence +// * +// block_node ::= ALIAS +// ***** +// | properties block_content? +// ********** * +// | block_content +// * +// flow_node ::= ALIAS +// ***** +// | properties flow_content? +// ********** * +// | flow_content +// * +// properties ::= TAG ANCHOR? | ANCHOR TAG? +// ************************* +// block_content ::= block_collection | flow_collection | SCALAR +// ****** +// flow_content ::= flow_collection | SCALAR +// ****** func yaml_parser_parse_node(parser *yaml_parser_t, event *yaml_event_t, block, indentless_sequence bool) bool { //defer trace("yaml_parser_parse_node", "block:", block, "indentless_sequence:", indentless_sequence)() @@ -697,9 +684,9 @@ func yaml_parser_parse_node(parser *yaml_parser_t, event *yaml_event_t, block, i } // Parse the productions: -// block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END // -// ******************** *********** * ********* +// block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END +// ******************** *********** * ********* func yaml_parser_parse_block_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { if first { token := peek_token(parser) @@ -755,9 +742,9 @@ func yaml_parser_parse_block_sequence_entry(parser *yaml_parser_t, event *yaml_e } // Parse the productions: -// indentless_sequence ::= (BLOCK-ENTRY block_node?)+ // -// *********** * +// indentless_sequence ::= (BLOCK-ENTRY block_node?)+ +// *********** * func yaml_parser_parse_indentless_sequence_entry(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { @@ -821,15 +808,15 @@ func yaml_parser_split_stem_comment(parser *yaml_parser_t, stem_len int) { } // Parse the productions: -// block_mapping ::= BLOCK-MAPPING_START // -// ******************* -// ((KEY block_node_or_indentless_sequence?)? -// *** * -// (VALUE block_node_or_indentless_sequence?)?)* +// block_mapping ::= BLOCK-MAPPING_START +// ******************* +// ((KEY block_node_or_indentless_sequence?)? +// *** * +// (VALUE block_node_or_indentless_sequence?)?)* // -// BLOCK-END -// ********* +// BLOCK-END +// ********* func yaml_parser_parse_block_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { if first { token := peek_token(parser) @@ -896,13 +883,14 @@ func yaml_parser_parse_block_mapping_key(parser *yaml_parser_t, event *yaml_even } // Parse the productions: -// block_mapping ::= BLOCK-MAPPING_START // -// ((KEY block_node_or_indentless_sequence?)? +// block_mapping ::= BLOCK-MAPPING_START +// +// ((KEY block_node_or_indentless_sequence?)? // -// (VALUE block_node_or_indentless_sequence?)?)* -// ***** * -// BLOCK-END +// (VALUE block_node_or_indentless_sequence?)?)* +// ***** * +// BLOCK-END func yaml_parser_parse_block_mapping_value(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { @@ -929,19 +917,17 @@ func yaml_parser_parse_block_mapping_value(parser *yaml_parser_t, event *yaml_ev } // Parse the productions: -// flow_sequence ::= FLOW-SEQUENCE-START -// -// ******************* -// (flow_sequence_entry FLOW-ENTRY)* -// * ********** -// flow_sequence_entry? -// * -// FLOW-SEQUENCE-END -// ***************** // -// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? -// -// * +// flow_sequence ::= FLOW-SEQUENCE-START +// ******************* +// (flow_sequence_entry FLOW-ENTRY)* +// * ********** +// flow_sequence_entry? +// * +// FLOW-SEQUENCE-END +// ***************** +// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// * func yaml_parser_parse_flow_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { if first { token := peek_token(parser) @@ -1005,9 +991,9 @@ func yaml_parser_parse_flow_sequence_entry(parser *yaml_parser_t, event *yaml_ev } // Parse the productions: -// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? // -// *** * +// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// *** * func yaml_parser_parse_flow_sequence_entry_mapping_key(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { @@ -1026,9 +1012,9 @@ func yaml_parser_parse_flow_sequence_entry_mapping_key(parser *yaml_parser_t, ev } // Parse the productions: -// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? // -// ***** * +// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// ***** * func yaml_parser_parse_flow_sequence_entry_mapping_value(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { @@ -1050,9 +1036,9 @@ func yaml_parser_parse_flow_sequence_entry_mapping_value(parser *yaml_parser_t, } // Parse the productions: -// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? // -// * +// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// * func yaml_parser_parse_flow_sequence_entry_mapping_end(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { @@ -1068,18 +1054,17 @@ func yaml_parser_parse_flow_sequence_entry_mapping_end(parser *yaml_parser_t, ev } // Parse the productions: -// flow_mapping ::= FLOW-MAPPING-START -// -// ****************** -// (flow_mapping_entry FLOW-ENTRY)* -// * ********** -// flow_mapping_entry? -// ****************** -// FLOW-MAPPING-END -// **************** // -// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? -// - *** * +// flow_mapping ::= FLOW-MAPPING-START +// ****************** +// (flow_mapping_entry FLOW-ENTRY)* +// * ********** +// flow_mapping_entry? +// ****************** +// FLOW-MAPPING-END +// **************** +// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// * *** * func yaml_parser_parse_flow_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { if first { token := peek_token(parser) @@ -1144,8 +1129,9 @@ func yaml_parser_parse_flow_mapping_key(parser *yaml_parser_t, event *yaml_event } // Parse the productions: -// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? -// - ***** * +// +// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// * ***** * func yaml_parser_parse_flow_mapping_value(parser *yaml_parser_t, event *yaml_event_t, empty bool) bool { token := peek_token(parser) if token == nil { diff --git a/vendor/go.yaml.in/yaml/v3/yamlh.go b/vendor/go.yaml.in/yaml/v3/yamlh.go index f59aa40f640..07c442361ce 100644 --- a/vendor/go.yaml.in/yaml/v3/yamlh.go +++ b/vendor/go.yaml.in/yaml/v3/yamlh.go @@ -433,21 +433,19 @@ type yaml_document_t struct { // The prototype of a read handler. // -// The read handler is called when the parser needs to read more bytes from the -// source. The handler should write not more than size bytes to the buffer. -// The number of written bytes should be set to the size_read variable. +// The read handler is called when the parser needs to read more bytes from the +// source. The handler should write not more than size bytes to the buffer. +// The number of written bytes should be set to the size_read variable. // -// [in,out] data A pointer to an application data specified by +// [in,out] data A pointer to an application data specified by +// yaml_parser_set_input(). +// [out] buffer The buffer to write the data from the source. +// [in] size The size of the buffer. +// [out] size_read The actual number of bytes read from the source. // -// yaml_parser_set_input(). -// -// [out] buffer The buffer to write the data from the source. -// [in] size The size of the buffer. -// [out] size_read The actual number of bytes read from the source. -// -// On success, the handler should return 1. If the handler failed, -// the returned value should be 0. On EOF, the handler should set the -// size_read to 0 and return 1. +// On success, the handler should return 1. If the handler failed, +// the returned value should be 0. On EOF, the handler should set the +// size_read to 0 and return 1. type yaml_read_handler_t func(parser *yaml_parser_t, buffer []byte) (n int, err error) // This structure holds information about a potential simple key. @@ -655,19 +653,17 @@ type yaml_comment_t struct { // The prototype of a write handler. // -// The write handler is called when the emitter needs to flush the accumulated -// characters to the output. The handler should write @a size bytes of the -// @a buffer to the output. -// -// @param[in,out] data A pointer to an application data specified by -// -// yaml_emitter_set_output(). +// The write handler is called when the emitter needs to flush the accumulated +// characters to the output. The handler should write @a size bytes of the +// @a buffer to the output. // -// @param[in] buffer The buffer with bytes to be written. -// @param[in] size The size of the buffer. +// @param[in,out] data A pointer to an application data specified by +// yaml_emitter_set_output(). +// @param[in] buffer The buffer with bytes to be written. +// @param[in] size The size of the buffer. // -// @returns On success, the handler should return @c 1. If the handler failed, -// the returned value should be @c 0. +// @returns On success, the handler should return @c 1. If the handler failed, +// the returned value should be @c 0. type yaml_write_handler_t func(emitter *yaml_emitter_t, buffer []byte) error type yaml_emitter_state_t int diff --git a/vendor/golang.org/x/crypto/internal/poly1305/mac_noasm.go b/vendor/golang.org/x/crypto/internal/poly1305/mac_noasm.go index 8d99551feec..b1da45687cc 100644 --- a/vendor/golang.org/x/crypto/internal/poly1305/mac_noasm.go +++ b/vendor/golang.org/x/crypto/internal/poly1305/mac_noasm.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build (!amd64 && !loong64 && !ppc64le && !ppc64 && !s390x) || !gc || purego +//go:build (!amd64 && !loong64 && !ppc64le && !ppc64 && !riscv64 && !s390x) || !gc || purego package poly1305 diff --git a/vendor/golang.org/x/crypto/internal/poly1305/sum_asm.go b/vendor/golang.org/x/crypto/internal/poly1305/sum_asm.go index 315b84ac39b..55041bf51d5 100644 --- a/vendor/golang.org/x/crypto/internal/poly1305/sum_asm.go +++ b/vendor/golang.org/x/crypto/internal/poly1305/sum_asm.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build gc && !purego && (amd64 || loong64 || ppc64 || ppc64le) +//go:build gc && !purego && (amd64 || loong64 || ppc64 || ppc64le || riscv64) package poly1305 diff --git a/vendor/golang.org/x/crypto/internal/poly1305/sum_riscv64.s b/vendor/golang.org/x/crypto/internal/poly1305/sum_riscv64.s new file mode 100644 index 00000000000..ce5eb3d43d9 --- /dev/null +++ b/vendor/golang.org/x/crypto/internal/poly1305/sum_riscv64.s @@ -0,0 +1,158 @@ +// Copyright 2026 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build gc && !purego + +#define LOAD64U(base, offset, t0, t1, t2, t3, dst) \ + MOVBU (offset+0*1)(base), t0; \ + MOVBU (offset+1*1)(base), t1; \ + MOVBU (offset+2*1)(base), t2; \ + MOVBU (offset+3*1)(base), t3; \ + SLL $8, t1; \ + SLL $16, t2; \ + SLL $24, t3; \ + OR t1, t0; \ + OR t3, t2; \ + OR t2, t0, dst; \ + MOVBU (offset+4*1)(base), t0; \ + MOVBU (offset+5*1)(base), t1; \ + MOVBU (offset+6*1)(base), t2; \ + MOVBU (offset+7*1)(base), t3; \ + SLL $32, t0; \ + SLL $40, t1; \ + SLL $48, t2; \ + SLL $56, t3; \ + OR t1, t0; \ + OR t3, t2; \ + OR t2, t0; \ + OR t0, dst + +// func update(state *macState, msg []byte) +TEXT ·update(SB), $0-32 + MOV state+0(FP), X5 + MOV msg_base+8(FP), X6 + MOV msg_len+16(FP), X7 + + MOV $16, X8 + + AND $7, X6, X28 + + MOV (0*8)(X5), X9 // h0 + MOV (1*8)(X5), X10 // h1 + MOV (2*8)(X5), X11 // h2 + MOV (3*8)(X5), X12 // r0 + MOV (4*8)(X5), X13 // r1 + + BLT X7, X8, tail + +loop: + BEQZ X28, aligned_load + + LOAD64U(X6, 0*8, X16, X18, X19, X20, X15) // msg[0:8] + LOAD64U(X6, 1*8, X16, X18, X19, X20, X17) // msg[8:16] + JMP block + +aligned_load: + MOV (0*8)(X6), X15 // msg[0:8] + MOV (1*8)(X6), X17 // msg[8:16] + +block: + ADD X15, X9 // h0 (x1 + y1 = z1', if z1' < x1 then z1' overflow) + SLTU X15, X9, X19 // h0.carry + ADD X17, X10, X22 + SLTU X17, X22, X23 + ADD X22, X19, X10 // h1 + SLTU X22, X10, X19 + OR X23, X19 // h1.carry + ADD $1, X19 + ADD X19, X11 // h2 + + ADD $16, X6 // msg = msg[16:] + +multiply: + MULHU X9, X12, X16 // h0r0.hi + MUL X9, X12, X15 // h0r0.lo + MULHU X10, X12, X17 // h1r0.hi + MUL X10, X12, X14 // h1r0.lo + ADD X14, X16 + SLTU X14, X16, X19 + ADD X19, X17 + MUL X11, X12, X20 + ADD X17, X20 + MULHU X9, X13, X17 // h0r1.hi + MUL X9, X13, X14 // h0r1.lo + ADD X14, X16 + SLTU X14, X16, X19 + ADD X19, X17 + MOV X17, X9 + MUL X11, X13, X21 // h2r1 + MULHU X10, X13, X17 // h1r1.hi + MUL X10, X13, X14 // h1r1.lo + ADD X14, X20 + ADD X17, X21, X22 + SLTU X14, X20, X19 + ADD X22, X19, X21 + ADD X9, X20 + SLTU X9, X20, X19 + ADD X19, X21 + AND $3, X20, X11 + AND $-4, X20, X18 + ADD X18, X15, X9 + ADD X21, X16, X22 + SLTU X18, X9, X19 + SLTU X21, X22, X23 + ADD X22, X19, X10 + SLTU X22, X10, X19 + OR X19, X23, X19 + ADD X19, X11 + SLL $62, X21, X22 + SRL $2, X20, X23 + SRL $2, X21, X21 + OR X22, X23, X20 + ADD X20, X9, X9 + ADD X21, X10, X22 + SLTU X20, X9, X19 + SLTU X21, X22, X23 + ADD X22, X19, X10 + SLTU X22, X10, X19 + OR X19, X23, X19 + ADD X19, X11, X11 + + SUB $16, X7, X7 + BGE X7, X8, loop + +tail: + BEQ X7, X0, done + MOV $1, X15 + MOV $0, X16 + ADD X7, X6, X6 + +flush_buffer: + MOVBU -1(X6), X20 + SRL $56, X15, X19 + SLL $8, X16, X23 + SLL $8, X15, X15 + OR X19, X23, X16 + XOR X20, X15 + SUB $1, X7, X7 + SUB $1, X6, X6 + BNE X7, X0, flush_buffer + + ADD X15, X9 + SLTU X15, X9, X19 + ADD X16, X10, X22 + SLTU X16, X22, X23 + ADD X22, X19, X10 + SLTU X22, X10, X19 + OR X23, X19 + ADD X19, X11 + + MOV $16, X7 + JMP multiply + +done: + MOV X9, (0*8)(X5) // h0 + MOV X10, (1*8)(X5) + MOV X11, (2*8)(X5) + RET diff --git a/vendor/golang.org/x/net/http/httpproxy/proxy.go b/vendor/golang.org/x/net/http/httpproxy/proxy.go index 5ab499b0bcb..1e260f4444a 100644 --- a/vendor/golang.org/x/net/http/httpproxy/proxy.go +++ b/vendor/golang.org/x/net/http/httpproxy/proxy.go @@ -80,18 +80,19 @@ type config struct { domainMatchers []matcher } -// FromEnvironment returns a Config instance populated from the -// environment variables HTTP_PROXY, HTTPS_PROXY and NO_PROXY (or the -// lowercase versions thereof). +// FromEnvironment returns a Config instance populated from the environment +// variables HTTP_PROXY, HTTPS_PROXY and NO_PROXY (or the lowercase versions +// thereof). When both the uppercase and lowercase versions are provided, the +// lowercase versions are prioritized. // // The environment values may be either a complete URL or a // "host[:port]", in which case the "http" scheme is assumed. An error // is returned if the value is a different form. func FromEnvironment() *Config { return &Config{ - HTTPProxy: getEnvAny("HTTP_PROXY", "http_proxy"), - HTTPSProxy: getEnvAny("HTTPS_PROXY", "https_proxy"), - NoProxy: getEnvAny("NO_PROXY", "no_proxy"), + HTTPProxy: getEnvAny("http_proxy", "HTTP_PROXY"), + HTTPSProxy: getEnvAny("https_proxy", "HTTPS_PROXY"), + NoProxy: getEnvAny("no_proxy", "NO_PROXY"), CGI: os.Getenv("REQUEST_METHOD") != "", } } diff --git a/vendor/golang.org/x/net/http2/hpack/encode.go b/vendor/golang.org/x/net/http2/hpack/encode.go index 46219da2b01..e6d0c265acf 100644 --- a/vendor/golang.org/x/net/http2/hpack/encode.go +++ b/vendor/golang.org/x/net/http2/hpack/encode.go @@ -39,7 +39,6 @@ func NewEncoder(w io.Writer) *Encoder { tableSizeUpdate: false, w: w, } - e.dynTab.table.init() e.dynTab.setMaxSize(initialHeaderTableSize) return e } diff --git a/vendor/golang.org/x/net/http2/hpack/hpack.go b/vendor/golang.org/x/net/http2/hpack/hpack.go index 7a1d976696a..ecd3eeca99a 100644 --- a/vendor/golang.org/x/net/http2/hpack/hpack.go +++ b/vendor/golang.org/x/net/http2/hpack/hpack.go @@ -105,7 +105,6 @@ func NewDecoder(maxDynamicTableSize uint32, emitFunc func(f HeaderField)) *Decod emitEnabled: true, firstField: true, } - d.dynTab.table.init() d.dynTab.allowedMaxSize = maxDynamicTableSize d.dynTab.setMaxSize(maxDynamicTableSize) return d diff --git a/vendor/golang.org/x/net/http2/hpack/tables.go b/vendor/golang.org/x/net/http2/hpack/tables.go index 8cbdf3f019c..3bd7eb75332 100644 --- a/vendor/golang.org/x/net/http2/hpack/tables.go +++ b/vendor/golang.org/x/net/http2/hpack/tables.go @@ -31,10 +31,18 @@ type headerFieldTable struct { // byName maps a HeaderField name to the unique id of the newest entry with // the same name. See above for a definition of "unique id". + // + // byName and byNameValue are used only by search, which is only called + // for tables used by encoders. For tables used only by decoders, the + // maps are never built, as a memory optimization for servers with many + // mostly-idle connections, each pinning a dynamic table. The maps are + // built lazily by the first search call and are nil until then. The two + // maps are always both nil or both non-nil. byName map[string]uint64 // byNameValue maps a HeaderField name/value pair to the unique id of the newest // entry with the same name and value. See above for a definition of "unique id". + // See byName for when this map is non-nil. byNameValue map[pairNameValue]uint64 } @@ -42,9 +50,17 @@ type pairNameValue struct { name, value string } -func (t *headerFieldTable) init() { - t.byName = make(map[string]uint64) - t.byNameValue = make(map[pairNameValue]uint64) +// buildMaps initializes byName and byNameValue from ents. +func (t *headerFieldTable) buildMaps() { + t.byName = make(map[string]uint64, len(t.ents)) + t.byNameValue = make(map[pairNameValue]uint64, len(t.ents)) + for k, f := range t.ents { + // Map to the newest matching entry: later (newer) entries + // overwrite earlier ones, matching addEntry's behavior. + id := t.evictCount + uint64(k) + 1 + t.byName[f.Name] = id + t.byNameValue[pairNameValue{f.Name, f.Value}] = id + } } // len reports the number of entries in the table. @@ -54,9 +70,11 @@ func (t *headerFieldTable) len() int { // addEntry adds a new entry. func (t *headerFieldTable) addEntry(f HeaderField) { - id := uint64(t.len()) + t.evictCount + 1 - t.byName[f.Name] = id - t.byNameValue[pairNameValue{f.Name, f.Value}] = id + if t.byName != nil { + id := uint64(t.len()) + t.evictCount + 1 + t.byName[f.Name] = id + t.byNameValue[pairNameValue{f.Name, f.Value}] = id + } t.ents = append(t.ents, f) } @@ -65,14 +83,16 @@ func (t *headerFieldTable) evictOldest(n int) { if n > t.len() { panic(fmt.Sprintf("evictOldest(%v) on table with %v entries", n, t.len())) } - for k := 0; k < n; k++ { - f := t.ents[k] - id := t.evictCount + uint64(k) + 1 - if t.byName[f.Name] == id { - delete(t.byName, f.Name) - } - if p := (pairNameValue{f.Name, f.Value}); t.byNameValue[p] == id { - delete(t.byNameValue, p) + if t.byName != nil { + for k := 0; k < n; k++ { + f := t.ents[k] + id := t.evictCount + uint64(k) + 1 + if t.byName[f.Name] == id { + delete(t.byName, f.Name) + } + if p := (pairNameValue{f.Name, f.Value}); t.byNameValue[p] == id { + delete(t.byNameValue, p) + } } } copy(t.ents, t.ents[n:]) @@ -100,6 +120,9 @@ func (t *headerFieldTable) evictOldest(n int) { // // See Section 2.3.3. func (t *headerFieldTable) search(f HeaderField) (i uint64, nameValueMatch bool) { + if t.byName == nil { + t.buildMaps() + } if !f.Sensitive { if id := t.byNameValue[pairNameValue{f.Name, f.Value}]; id != 0 { return t.idToIndex(id), true diff --git a/vendor/golang.org/x/net/http2/transport_wrap.go b/vendor/golang.org/x/net/http2/transport_wrap.go index 534e77ab963..741fb97062e 100644 --- a/vendor/golang.org/x/net/http2/transport_wrap.go +++ b/vendor/golang.org/x/net/http2/transport_wrap.go @@ -237,32 +237,40 @@ type ClientConn struct { } func (cc *ClientConn) roundTrip(req *http.Request) (*http.Response, error) { - err := func() error { + haveReservation, err := func() (bool, error) { cc.mu.Lock() defer cc.mu.Unlock() if cc.doNotReuse { - return errClientConnUnusable - } - cc.roundTrips++ - if cc.reserved > 0 { - // We've already reserved a concurrency slot for this request. - cc.reserved-- - } else if cc.cc.Reserve() != nil { - // We don't seem to have an available concurrency slot, - // so bump the pending count (requests waiting for a slot). - cc.pending++ + return false, errClientConnUnusable } + // ClientConn.Shutdown will not shut down the conn while // cc.starting > 0 or cc.cc.InFlight() > 0. // // The starting state covers the gap between us deciding to // start sending the request, and actually sending it. cc.starting++ - return nil + + cc.roundTrips++ + if cc.reserved == 0 { + // We do not have a concurrency slot reserved for this request. + return false, nil + } + cc.reserved-- + return true, nil }() if err != nil { return nil, err } + // If we have no reservation, try to acquire one. + // (This must be done without cc.mu held, since Reserve may call back to the state hook.) + if !haveReservation && cc.cc.Reserve() != nil { + // We could not acquire a concurrency slot, so bump the pending count + // (requests waiting for a slot). + cc.mu.Lock() + cc.pending++ + cc.mu.Unlock() + } resp, err := cc.cc.RoundTrip(req) cc.mu.Lock() cc.starting-- @@ -293,16 +301,21 @@ func (cc *ClientConn) ping(ctx context.Context) error { } func (cc *ClientConn) reserveNewRequest() bool { + if err := cc.cc.Reserve(); err != nil { + return false + } + reserved := true cc.mu.Lock() - defer cc.mu.Unlock() if cc.doNotReuse { - return false + reserved = false + } else { + cc.reserved++ } - if err := cc.cc.Reserve(); err != nil { - return false + cc.mu.Unlock() + if !reserved { + cc.cc.Release() } - cc.reserved++ - return true + return reserved } func (cc *ClientConn) setDoNotReuse() { diff --git a/vendor/golang.org/x/text/currency/common.go b/vendor/golang.org/x/text/currency/common.go new file mode 100644 index 00000000000..fef15be5545 --- /dev/null +++ b/vendor/golang.org/x/text/currency/common.go @@ -0,0 +1,67 @@ +// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. + +package currency + +import ( + "time" + + "golang.org/x/text/language" +) + +// This file contains code common to gen.go and the package code. + +const ( + cashShift = 3 + roundMask = 0x7 + + nonTenderBit = 0x8000 +) + +// currencyInfo contains information about a currency. +// bits 0..2: index into roundings for standard rounding +// bits 3..5: index into roundings for cash rounding +type currencyInfo byte + +// roundingType defines the scale (number of fractional decimals) and increments +// in terms of units of size 10^-scale. For example, for scale == 2 and +// increment == 1, the currency is rounded to units of 0.01. +type roundingType struct { + scale, increment uint8 +} + +// roundings contains rounding data for currencies. This struct is +// created by hand as it is very unlikely to change much. +var roundings = [...]roundingType{ + {2, 1}, // default + {0, 1}, + {1, 1}, + {3, 1}, + {4, 1}, + {2, 5}, // cash rounding alternative + {2, 50}, +} + +// regionToCode returns a 16-bit region code. Only two-letter codes are +// supported. (Three-letter codes are not needed.) +func regionToCode(r language.Region) uint16 { + if s := r.String(); len(s) == 2 { + return uint16(s[0])<<8 | uint16(s[1]) + } + return 0 +} + +func toDate(t time.Time) uint32 { + y := t.Year() + if y == 1 { + return 0 + } + date := uint32(y) << 4 + date |= uint32(t.Month()) + date <<= 5 + date |= uint32(t.Day()) + return date +} + +func fromDate(date uint32) time.Time { + return time.Date(int(date>>9), time.Month((date>>5)&0xf), int(date&0x1f), 0, 0, 0, 0, time.UTC) +} diff --git a/vendor/golang.org/x/text/currency/currency.go b/vendor/golang.org/x/text/currency/currency.go new file mode 100644 index 00000000000..598ddeff420 --- /dev/null +++ b/vendor/golang.org/x/text/currency/currency.go @@ -0,0 +1,185 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:generate go run gen.go gen_common.go -output tables.go + +// Package currency contains currency-related functionality. +// +// NOTE: the formatting functionality is currently under development and may +// change without notice. +package currency // import "golang.org/x/text/currency" + +import ( + "errors" + "sort" + + "golang.org/x/text/internal/tag" + "golang.org/x/text/language" +) + +// TODO: +// - language-specific currency names. +// - currency formatting. +// - currency information per region +// - register currency code (there are no private use area) + +// TODO: remove Currency type from package language. + +// Kind determines the rounding and rendering properties of a currency value. +type Kind struct { + rounding rounding + // TODO: formatting type: standard, accounting. See CLDR. +} + +type rounding byte + +const ( + standard rounding = iota + cash +) + +var ( + // Standard defines standard rounding and formatting for currencies. + Standard Kind = Kind{rounding: standard} + + // Cash defines rounding and formatting standards for cash transactions. + Cash Kind = Kind{rounding: cash} + + // Accounting defines rounding and formatting standards for accounting. + Accounting Kind = Kind{rounding: standard} +) + +// Rounding reports the rounding characteristics for the given currency, where +// scale is the number of fractional decimals and increment is the number of +// units in terms of 10^(-scale) to which to round to. +func (k Kind) Rounding(cur Unit) (scale, increment int) { + info := currency.Elem(int(cur.index))[3] + switch k.rounding { + case standard: + info &= roundMask + case cash: + info >>= cashShift + } + return int(roundings[info].scale), int(roundings[info].increment) +} + +// Unit is an ISO 4217 currency designator. +type Unit struct { + index uint16 +} + +// String returns the ISO code of u. +func (u Unit) String() string { + if u.index == 0 { + return "XXX" + } + return currency.Elem(int(u.index))[:3] +} + +// Amount creates an Amount for the given currency unit and amount. +func (u Unit) Amount(amount interface{}) Amount { + // TODO: verify amount is a supported number type + return Amount{amount: amount, currency: u} +} + +var ( + errSyntax = errors.New("currency: tag is not well-formed") + errValue = errors.New("currency: tag is not a recognized currency") +) + +// ParseISO parses a 3-letter ISO 4217 currency code. It returns an error if s +// is not well-formed or not a recognized currency code. +func ParseISO(s string) (Unit, error) { + var buf [4]byte // Take one byte more to detect oversize keys. + key := buf[:copy(buf[:], s)] + if !tag.FixCase("XXX", key) { + return Unit{}, errSyntax + } + if i := currency.Index(key); i >= 0 { + if i == xxx { + return Unit{}, nil + } + return Unit{uint16(i)}, nil + } + return Unit{}, errValue +} + +// MustParseISO is like ParseISO, but panics if the given currency unit +// cannot be parsed. It simplifies safe initialization of Unit values. +func MustParseISO(s string) Unit { + c, err := ParseISO(s) + if err != nil { + panic(err) + } + return c +} + +// FromRegion reports the currency unit that is currently legal tender in the +// given region according to CLDR. It will return false if region currently does +// not have a legal tender. +func FromRegion(r language.Region) (currency Unit, ok bool) { + x := regionToCode(r) + i := sort.Search(len(regionToCurrency), func(i int) bool { + return regionToCurrency[i].region >= x + }) + if i < len(regionToCurrency) && regionToCurrency[i].region == x { + return Unit{regionToCurrency[i].code}, true + } + return Unit{}, false +} + +// FromTag reports the most likely currency for the given tag. It considers the +// currency defined in the -u extension and infers the region if necessary. +func FromTag(t language.Tag) (Unit, language.Confidence) { + if cur := t.TypeForKey("cu"); len(cur) == 3 { + c, _ := ParseISO(cur) + return c, language.Exact + } + r, conf := t.Region() + if cur, ok := FromRegion(r); ok { + return cur, conf + } + return Unit{}, language.No +} + +var ( + // Undefined and testing. + XXX Unit = Unit{} + XTS Unit = Unit{xts} + + // G10 currencies https://en.wikipedia.org/wiki/G10_currencies. + USD Unit = Unit{usd} + EUR Unit = Unit{eur} + JPY Unit = Unit{jpy} + GBP Unit = Unit{gbp} + CHF Unit = Unit{chf} + AUD Unit = Unit{aud} + NZD Unit = Unit{nzd} + CAD Unit = Unit{cad} + SEK Unit = Unit{sek} + NOK Unit = Unit{nok} + + // Additional common currencies as defined by CLDR. + BRL Unit = Unit{brl} + CNY Unit = Unit{cny} + DKK Unit = Unit{dkk} + INR Unit = Unit{inr} + RUB Unit = Unit{rub} + HKD Unit = Unit{hkd} + IDR Unit = Unit{idr} + KRW Unit = Unit{krw} + MXN Unit = Unit{mxn} + PLN Unit = Unit{pln} + SAR Unit = Unit{sar} + THB Unit = Unit{thb} + TRY Unit = Unit{try} + TWD Unit = Unit{twd} + ZAR Unit = Unit{zar} + + // Precious metals. + XAG Unit = Unit{xag} + XAU Unit = Unit{xau} + XPT Unit = Unit{xpt} + XPD Unit = Unit{xpd} +) diff --git a/vendor/golang.org/x/text/currency/format.go b/vendor/golang.org/x/text/currency/format.go new file mode 100644 index 00000000000..cc4570d3b68 --- /dev/null +++ b/vendor/golang.org/x/text/currency/format.go @@ -0,0 +1,220 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package currency + +import ( + "fmt" + "sort" + + "golang.org/x/text/internal/format" + "golang.org/x/text/internal/language/compact" + "golang.org/x/text/internal/number" + + "golang.org/x/text/language" +) + +// Amount is an amount-currency unit pair. +type Amount struct { + amount interface{} // Change to decimal(64|128). + currency Unit +} + +// Currency reports the currency unit of this amount. +func (a Amount) Currency() Unit { return a.currency } + +// TODO: based on decimal type, but may make sense to customize a bit. +// func (a Amount) Decimal() +// func (a Amount) Int() (int64, error) +// func (a Amount) Fraction() (int64, error) +// func (a Amount) Rat() *big.Rat +// func (a Amount) Float() (float64, error) +// func (a Amount) Scale() uint +// func (a Amount) Precision() uint +// func (a Amount) Sign() int +// +// Add/Sub/Div/Mul/Round. + +// Format implements fmt.Formatter. It accepts format.State for +// language-specific rendering. +func (a Amount) Format(s fmt.State, verb rune) { + v := formattedValue{ + currency: a.currency, + amount: a.amount, + format: defaultFormat, + } + v.Format(s, verb) +} + +// formattedValue is currency amount or unit that implements language-sensitive +// formatting. +type formattedValue struct { + currency Unit + amount interface{} // Amount, Unit, or number. + format *options +} + +// Format implements fmt.Formatter. It accepts format.State for +// language-specific rendering. +func (v formattedValue) Format(s fmt.State, verb rune) { + var tag language.Tag + var lang compact.ID + if state, ok := s.(format.State); ok { + tag = state.Language() + lang, _ = compact.RegionalID(compact.Tag(tag)) + } + + // Get the options. Use DefaultFormat if not present. + opt := v.format + if opt == nil { + opt = defaultFormat + } + cur := v.currency + if cur.index == 0 { + cur = opt.currency + } + + sym := opt.symbol(lang, cur) + if v.amount != nil { + var f number.Formatter + f.InitDecimal(tag) + + scale, increment := opt.kind.Rounding(cur) + f.RoundingContext.SetScale(scale) + f.RoundingContext.Increment = uint32(increment) + f.RoundingContext.IncrementScale = uint8(scale) + f.RoundingContext.Mode = number.ToNearestAway + + d := f.Append(nil, v.amount) + + fmt.Fprint(s, sym, " ", string(d)) + } else { + fmt.Fprint(s, sym) + } +} + +// Formatter decorates a given number, Unit or Amount with formatting options. +type Formatter func(amount interface{}) formattedValue + +// func (f Formatter) Options(opts ...Option) Formatter + +// TODO: call this a Formatter or FormatFunc? + +var dummy = USD.Amount(0) + +// adjust creates a new Formatter based on the adjustments of fn on f. +func (f Formatter) adjust(fn func(*options)) Formatter { + var o options = *(f(dummy).format) + fn(&o) + return o.format +} + +// Default creates a new Formatter that defaults to currency unit c if a numeric +// value is passed that is not associated with a currency. +func (f Formatter) Default(currency Unit) Formatter { + return f.adjust(func(o *options) { o.currency = currency }) +} + +// Kind sets the kind of the underlying currency unit. +func (f Formatter) Kind(k Kind) Formatter { + return f.adjust(func(o *options) { o.kind = k }) +} + +var defaultFormat *options = ISO(dummy).format + +var ( + // Uses Narrow symbols. Overrides Symbol, if present. + NarrowSymbol Formatter = Formatter(formNarrow) + + // Use Symbols instead of ISO codes, when available. + Symbol Formatter = Formatter(formSymbol) + + // Use ISO code as symbol. + ISO Formatter = Formatter(formISO) + + // TODO: + // // Use full name as symbol. + // Name Formatter +) + +// options configures rendering and rounding options for an Amount. +type options struct { + currency Unit + kind Kind + + symbol func(compactIndex compact.ID, c Unit) string +} + +func (o *options) format(amount interface{}) formattedValue { + v := formattedValue{format: o} + switch x := amount.(type) { + case Amount: + v.amount = x.amount + v.currency = x.currency + case *Amount: + v.amount = x.amount + v.currency = x.currency + case Unit: + v.currency = x + case *Unit: + v.currency = *x + default: + if o.currency.index == 0 { + panic("cannot format number without a currency being set") + } + // TODO: Must be a number. + v.amount = x + v.currency = o.currency + } + return v +} + +var ( + optISO = options{symbol: lookupISO} + optSymbol = options{symbol: lookupSymbol} + optNarrow = options{symbol: lookupNarrow} +) + +// These need to be functions, rather than curried methods, as curried methods +// are evaluated at init time, causing tables to be included unconditionally. +func formISO(x interface{}) formattedValue { return optISO.format(x) } +func formSymbol(x interface{}) formattedValue { return optSymbol.format(x) } +func formNarrow(x interface{}) formattedValue { return optNarrow.format(x) } + +func lookupISO(x compact.ID, c Unit) string { return c.String() } +func lookupSymbol(x compact.ID, c Unit) string { return normalSymbol.lookup(x, c) } +func lookupNarrow(x compact.ID, c Unit) string { return narrowSymbol.lookup(x, c) } + +type symbolIndex struct { + index []uint16 // position corresponds with compact index of language. + data []curToIndex +} + +var ( + normalSymbol = symbolIndex{normalLangIndex, normalSymIndex} + narrowSymbol = symbolIndex{narrowLangIndex, narrowSymIndex} +) + +func (x *symbolIndex) lookup(lang compact.ID, c Unit) string { + for { + index := x.data[x.index[lang]:x.index[lang+1]] + i := sort.Search(len(index), func(i int) bool { + return index[i].cur >= c.index + }) + if i < len(index) && index[i].cur == c.index { + x := index[i].idx + start := x + 1 + end := start + uint16(symbols[x]) + if start == end { + return c.String() + } + return symbols[start:end] + } + if lang == 0 { + break + } + lang = lang.Parent() + } + return c.String() +} diff --git a/vendor/golang.org/x/text/currency/query.go b/vendor/golang.org/x/text/currency/query.go new file mode 100644 index 00000000000..7bf9430a62c --- /dev/null +++ b/vendor/golang.org/x/text/currency/query.go @@ -0,0 +1,152 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package currency + +import ( + "sort" + "time" + + "golang.org/x/text/language" +) + +// QueryIter represents a set of Units. The default set includes all Units that +// are currently in use as legal tender in any Region. +type QueryIter interface { + // Next returns true if there is a next element available. + // It must be called before any of the other methods are called. + Next() bool + + // Unit returns the unit of the current iteration. + Unit() Unit + + // Region returns the Region for the current iteration. + Region() language.Region + + // From returns the date from which the unit was used in the region. + // It returns false if this date is unknown. + From() (time.Time, bool) + + // To returns the date up till which the unit was used in the region. + // It returns false if this date is unknown or if the unit is still in use. + To() (time.Time, bool) + + // IsTender reports whether the unit is a legal tender in the region during + // the specified date range. + IsTender() bool +} + +// Query represents a set of Units. The default set includes all Units that are +// currently in use as legal tender in any Region. +func Query(options ...QueryOption) QueryIter { + it := &iter{ + end: len(regionData), + date: 0xFFFFFFFF, + } + for _, fn := range options { + fn(it) + } + return it +} + +// NonTender returns a new query that also includes matching Units that are not +// legal tender. +var NonTender QueryOption = nonTender + +func nonTender(i *iter) { + i.nonTender = true +} + +// Historical selects the units for all dates. +var Historical QueryOption = historical + +func historical(i *iter) { + i.date = hist +} + +// A QueryOption can be used to change the set of unit information returned by +// a query. +type QueryOption func(*iter) + +// Date queries the units that were in use at the given point in history. +func Date(t time.Time) QueryOption { + d := toDate(t) + return func(i *iter) { + i.date = d + } +} + +// Region limits the query to only return entries for the given region. +func Region(r language.Region) QueryOption { + p, end := len(regionData), len(regionData) + x := regionToCode(r) + i := sort.Search(len(regionData), func(i int) bool { + return regionData[i].region >= x + }) + if i < len(regionData) && regionData[i].region == x { + p = i + for i++; i < len(regionData) && regionData[i].region == x; i++ { + } + end = i + } + return func(i *iter) { + i.p, i.end = p, end + } +} + +const ( + hist = 0x00 + now = 0xFFFFFFFF +) + +type iter struct { + *regionInfo + p, end int + date uint32 + nonTender bool +} + +func (i *iter) Next() bool { + for ; i.p < i.end; i.p++ { + i.regionInfo = ®ionData[i.p] + if !i.nonTender && !i.IsTender() { + continue + } + if i.date == hist || (i.from <= i.date && (i.to == 0 || i.date <= i.to)) { + i.p++ + return true + } + } + return false +} + +func (r *regionInfo) Region() language.Region { + // TODO: this could be much faster. + var buf [2]byte + buf[0] = uint8(r.region >> 8) + buf[1] = uint8(r.region) + return language.MustParseRegion(string(buf[:])) +} + +func (r *regionInfo) Unit() Unit { + return Unit{r.code &^ nonTenderBit} +} + +func (r *regionInfo) IsTender() bool { + return r.code&nonTenderBit == 0 +} + +func (r *regionInfo) From() (time.Time, bool) { + if r.from == 0 { + return time.Time{}, false + } + return fromDate(r.from), true +} + +func (r *regionInfo) To() (time.Time, bool) { + if r.to == 0 { + return time.Time{}, false + } + return fromDate(r.to), true +} diff --git a/vendor/golang.org/x/text/currency/tables.go b/vendor/golang.org/x/text/currency/tables.go new file mode 100644 index 00000000000..d1a7440a6bd --- /dev/null +++ b/vendor/golang.org/x/text/currency/tables.go @@ -0,0 +1,2629 @@ +// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. + +package currency + +import "golang.org/x/text/internal/tag" + +// CLDRVersion is the CLDR version from which the tables in this package are derived. +const CLDRVersion = "32" + +const ( + xxx = 285 + xts = 283 + usd = 252 + eur = 94 + jpy = 133 + gbp = 99 + chf = 61 + aud = 19 + nzd = 192 + cad = 58 + sek = 219 + nok = 190 + dkk = 82 + xag = 266 + xau = 267 + xpt = 280 + xpd = 278 + brl = 46 + cny = 68 + inr = 125 + rub = 210 + hkd = 114 + idr = 120 + krw = 141 + mxn = 178 + pln = 201 + sar = 213 + thb = 235 + try = 244 + twd = 246 + zar = 293 +) + +// currency holds an alphabetically sorted list of canonical 3-letter currency +// identifiers. Each identifier is followed by a byte of type currencyInfo, +// defined in gen_common.go. +const currency tag.Index = "" + // Size: 1208 bytes + "\x00\x00\x00\x00ADP\x09AED\x00AFA\x00AFN\x09ALK\x00ALL\x09AMD\x09ANG\x00" + + "AOA\x00AOK\x00AON\x00AOR\x00ARA\x00ARL\x00ARM\x00ARP\x00ARS\x00ATS\x00AU" + + "D\x00AWG\x00AZM\x00AZN\x00BAD\x00BAM\x00BAN\x00BBD\x00BDT\x00BEC\x00BEF" + + "\x00BEL\x00BGL\x00BGM\x00BGN\x00BGO\x00BHD\x1bBIF\x09BMD\x00BND\x00BOB" + + "\x00BOL\x00BOP\x00BOV\x00BRB\x00BRC\x00BRE\x00BRL\x00BRN\x00BRR\x00BRZ" + + "\x00BSD\x00BTN\x00BUK\x00BWP\x00BYB\x00BYN\x00BYR\x09BZD\x00CAD(CDF\x00C" + + "HE\x00CHF(CHW\x00CLE\x00CLF$CLP\x09CNH\x00CNX\x00CNY\x00COP\x09COU\x00CR" + + "C\x08CSD\x00CSK\x00CUC\x00CUP\x00CVE\x00CYP\x00CZK\x08DDM\x00DEM\x00DJF" + + "\x09DKK0DOP\x00DZD\x00ECS\x00ECV\x00EEK\x00EGP\x00ERN\x00ESA\x00ESB\x00E" + + "SP\x09ETB\x00EUR\x00FIM\x00FJD\x00FKP\x00FRF\x00GBP\x00GEK\x00GEL\x00GHC" + + "\x00GHS\x00GIP\x00GMD\x00GNF\x09GNS\x00GQE\x00GRD\x00GTQ\x00GWE\x00GWP" + + "\x00GYD\x09HKD\x00HNL\x00HRD\x00HRK\x00HTG\x00HUF\x08IDR\x09IEP\x00ILP" + + "\x00ILR\x00ILS\x00INR\x00IQD\x09IRR\x09ISJ\x00ISK\x09ITL\x09JMD\x00JOD" + + "\x1bJPY\x09KES\x00KGS\x00KHR\x00KMF\x09KPW\x09KRH\x00KRO\x00KRW\x09KWD" + + "\x1bKYD\x00KZT\x00LAK\x09LBP\x09LKR\x00LRD\x00LSL\x00LTL\x00LTT\x00LUC" + + "\x00LUF\x09LUL\x00LVL\x00LVR\x00LYD\x1bMAD\x00MAF\x00MCF\x00MDC\x00MDL" + + "\x00MGA\x09MGF\x09MKD\x00MKN\x00MLF\x00MMK\x09MNT\x09MOP\x00MRO\x09MTL" + + "\x00MTP\x00MUR\x09MVP\x00MVR\x00MWK\x00MXN\x00MXP\x00MXV\x00MYR\x00MZE" + + "\x00MZM\x00MZN\x00NAD\x00NGN\x00NIC\x00NIO\x00NLG\x00NOK\x08NPR\x00NZD" + + "\x00OMR\x1bPAB\x00PEI\x00PEN\x00PES\x00PGK\x00PHP\x00PKR\x09PLN\x00PLZ" + + "\x00PTE\x00PYG\x09QAR\x00RHD\x00ROL\x00RON\x00RSD\x09RUB\x00RUR\x00RWF" + + "\x09SAR\x00SBD\x00SCR\x00SDD\x00SDG\x00SDP\x00SEK\x08SGD\x00SHP\x00SIT" + + "\x00SKK\x00SLL\x09SOS\x09SRD\x00SRG\x00SSP\x00STD\x09STN\x00SUR\x00SVC" + + "\x00SYP\x09SZL\x00THB\x00TJR\x00TJS\x00TMM\x09TMT\x00TND\x1bTOP\x00TPE" + + "\x00TRL\x09TRY\x00TTD\x00TWD\x08TZS\x09UAH\x00UAK\x00UGS\x00UGX\x09USD" + + "\x00USN\x00USS\x00UYI\x09UYP\x00UYU\x00UZS\x09VEB\x00VEF\x00VND\x09VNN" + + "\x00VUV\x09WST\x00XAF\x09XAG\x00XAU\x00XBA\x00XBB\x00XBC\x00XBD\x00XCD" + + "\x00XDR\x00XEU\x00XFO\x00XFU\x00XOF\x09XPD\x00XPF\x09XPT\x00XRE\x00XSU" + + "\x00XTS\x00XUA\x00XXX\x00YDD\x00YER\x09YUD\x00YUM\x00YUN\x00YUR\x00ZAL" + + "\x00ZAR\x00ZMK\x09ZMW\x00ZRN\x00ZRZ\x00ZWD\x09ZWL\x00ZWR\x00\xff\xff\xff" + + "\xff" + +const numCurrencies = 300 + +type toCurrency struct { + region uint16 + code uint16 +} + +var regionToCurrency = []toCurrency{ // 255 elements + 0: {region: 0x4143, code: 0xdd}, + 1: {region: 0x4144, code: 0x5e}, + 2: {region: 0x4145, code: 0x2}, + 3: {region: 0x4146, code: 0x4}, + 4: {region: 0x4147, code: 0x110}, + 5: {region: 0x4149, code: 0x110}, + 6: {region: 0x414c, code: 0x6}, + 7: {region: 0x414d, code: 0x7}, + 8: {region: 0x414f, code: 0x9}, + 9: {region: 0x4152, code: 0x11}, + 10: {region: 0x4153, code: 0xfc}, + 11: {region: 0x4154, code: 0x5e}, + 12: {region: 0x4155, code: 0x13}, + 13: {region: 0x4157, code: 0x14}, + 14: {region: 0x4158, code: 0x5e}, + 15: {region: 0x415a, code: 0x16}, + 16: {region: 0x4241, code: 0x18}, + 17: {region: 0x4242, code: 0x1a}, + 18: {region: 0x4244, code: 0x1b}, + 19: {region: 0x4245, code: 0x5e}, + 20: {region: 0x4246, code: 0x115}, + 21: {region: 0x4247, code: 0x21}, + 22: {region: 0x4248, code: 0x23}, + 23: {region: 0x4249, code: 0x24}, + 24: {region: 0x424a, code: 0x115}, + 25: {region: 0x424c, code: 0x5e}, + 26: {region: 0x424d, code: 0x25}, + 27: {region: 0x424e, code: 0x26}, + 28: {region: 0x424f, code: 0x27}, + 29: {region: 0x4251, code: 0xfc}, + 30: {region: 0x4252, code: 0x2e}, + 31: {region: 0x4253, code: 0x32}, + 32: {region: 0x4254, code: 0x33}, + 33: {region: 0x4256, code: 0xbe}, + 34: {region: 0x4257, code: 0x35}, + 35: {region: 0x4259, code: 0x37}, + 36: {region: 0x425a, code: 0x39}, + 37: {region: 0x4341, code: 0x3a}, + 38: {region: 0x4343, code: 0x13}, + 39: {region: 0x4344, code: 0x3b}, + 40: {region: 0x4346, code: 0x109}, + 41: {region: 0x4347, code: 0x109}, + 42: {region: 0x4348, code: 0x3d}, + 43: {region: 0x4349, code: 0x115}, + 44: {region: 0x434b, code: 0xc0}, + 45: {region: 0x434c, code: 0x41}, + 46: {region: 0x434d, code: 0x109}, + 47: {region: 0x434e, code: 0x44}, + 48: {region: 0x434f, code: 0x45}, + 49: {region: 0x4352, code: 0x47}, + 50: {region: 0x4355, code: 0x4b}, + 51: {region: 0x4356, code: 0x4c}, + 52: {region: 0x4357, code: 0x8}, + 53: {region: 0x4358, code: 0x13}, + 54: {region: 0x4359, code: 0x5e}, + 55: {region: 0x435a, code: 0x4e}, + 56: {region: 0x4445, code: 0x5e}, + 57: {region: 0x4447, code: 0xfc}, + 58: {region: 0x444a, code: 0x51}, + 59: {region: 0x444b, code: 0x52}, + 60: {region: 0x444d, code: 0x110}, + 61: {region: 0x444f, code: 0x53}, + 62: {region: 0x445a, code: 0x54}, + 63: {region: 0x4541, code: 0x5e}, + 64: {region: 0x4543, code: 0xfc}, + 65: {region: 0x4545, code: 0x5e}, + 66: {region: 0x4547, code: 0x58}, + 67: {region: 0x4548, code: 0x9e}, + 68: {region: 0x4552, code: 0x59}, + 69: {region: 0x4553, code: 0x5e}, + 70: {region: 0x4554, code: 0x5d}, + 71: {region: 0x4555, code: 0x5e}, + 72: {region: 0x4649, code: 0x5e}, + 73: {region: 0x464a, code: 0x60}, + 74: {region: 0x464b, code: 0x61}, + 75: {region: 0x464d, code: 0xfc}, + 76: {region: 0x464f, code: 0x52}, + 77: {region: 0x4652, code: 0x5e}, + 78: {region: 0x4741, code: 0x109}, + 79: {region: 0x4742, code: 0x63}, + 80: {region: 0x4744, code: 0x110}, + 81: {region: 0x4745, code: 0x65}, + 82: {region: 0x4746, code: 0x5e}, + 83: {region: 0x4747, code: 0x63}, + 84: {region: 0x4748, code: 0x67}, + 85: {region: 0x4749, code: 0x68}, + 86: {region: 0x474c, code: 0x52}, + 87: {region: 0x474d, code: 0x69}, + 88: {region: 0x474e, code: 0x6a}, + 89: {region: 0x4750, code: 0x5e}, + 90: {region: 0x4751, code: 0x109}, + 91: {region: 0x4752, code: 0x5e}, + 92: {region: 0x4753, code: 0x63}, + 93: {region: 0x4754, code: 0x6e}, + 94: {region: 0x4755, code: 0xfc}, + 95: {region: 0x4757, code: 0x115}, + 96: {region: 0x4759, code: 0x71}, + 97: {region: 0x484b, code: 0x72}, + 98: {region: 0x484d, code: 0x13}, + 99: {region: 0x484e, code: 0x73}, + 100: {region: 0x4852, code: 0x75}, + 101: {region: 0x4854, code: 0x76}, + 102: {region: 0x4855, code: 0x77}, + 103: {region: 0x4943, code: 0x5e}, + 104: {region: 0x4944, code: 0x78}, + 105: {region: 0x4945, code: 0x5e}, + 106: {region: 0x494c, code: 0x7c}, + 107: {region: 0x494d, code: 0x63}, + 108: {region: 0x494e, code: 0x7d}, + 109: {region: 0x494f, code: 0xfc}, + 110: {region: 0x4951, code: 0x7e}, + 111: {region: 0x4952, code: 0x7f}, + 112: {region: 0x4953, code: 0x81}, + 113: {region: 0x4954, code: 0x5e}, + 114: {region: 0x4a45, code: 0x63}, + 115: {region: 0x4a4d, code: 0x83}, + 116: {region: 0x4a4f, code: 0x84}, + 117: {region: 0x4a50, code: 0x85}, + 118: {region: 0x4b45, code: 0x86}, + 119: {region: 0x4b47, code: 0x87}, + 120: {region: 0x4b48, code: 0x88}, + 121: {region: 0x4b49, code: 0x13}, + 122: {region: 0x4b4d, code: 0x89}, + 123: {region: 0x4b4e, code: 0x110}, + 124: {region: 0x4b50, code: 0x8a}, + 125: {region: 0x4b52, code: 0x8d}, + 126: {region: 0x4b57, code: 0x8e}, + 127: {region: 0x4b59, code: 0x8f}, + 128: {region: 0x4b5a, code: 0x90}, + 129: {region: 0x4c41, code: 0x91}, + 130: {region: 0x4c42, code: 0x92}, + 131: {region: 0x4c43, code: 0x110}, + 132: {region: 0x4c49, code: 0x3d}, + 133: {region: 0x4c4b, code: 0x93}, + 134: {region: 0x4c52, code: 0x94}, + 135: {region: 0x4c53, code: 0x125}, + 136: {region: 0x4c54, code: 0x5e}, + 137: {region: 0x4c55, code: 0x5e}, + 138: {region: 0x4c56, code: 0x5e}, + 139: {region: 0x4c59, code: 0x9d}, + 140: {region: 0x4d41, code: 0x9e}, + 141: {region: 0x4d43, code: 0x5e}, + 142: {region: 0x4d44, code: 0xa2}, + 143: {region: 0x4d45, code: 0x5e}, + 144: {region: 0x4d46, code: 0x5e}, + 145: {region: 0x4d47, code: 0xa3}, + 146: {region: 0x4d48, code: 0xfc}, + 147: {region: 0x4d4b, code: 0xa5}, + 148: {region: 0x4d4c, code: 0x115}, + 149: {region: 0x4d4d, code: 0xa8}, + 150: {region: 0x4d4e, code: 0xa9}, + 151: {region: 0x4d4f, code: 0xaa}, + 152: {region: 0x4d50, code: 0xfc}, + 153: {region: 0x4d51, code: 0x5e}, + 154: {region: 0x4d52, code: 0xab}, + 155: {region: 0x4d53, code: 0x110}, + 156: {region: 0x4d54, code: 0x5e}, + 157: {region: 0x4d55, code: 0xae}, + 158: {region: 0x4d56, code: 0xb0}, + 159: {region: 0x4d57, code: 0xb1}, + 160: {region: 0x4d58, code: 0xb2}, + 161: {region: 0x4d59, code: 0xb5}, + 162: {region: 0x4d5a, code: 0xb8}, + 163: {region: 0x4e41, code: 0xb9}, + 164: {region: 0x4e43, code: 0x117}, + 165: {region: 0x4e45, code: 0x115}, + 166: {region: 0x4e46, code: 0x13}, + 167: {region: 0x4e47, code: 0xba}, + 168: {region: 0x4e49, code: 0xbc}, + 169: {region: 0x4e4c, code: 0x5e}, + 170: {region: 0x4e4f, code: 0xbe}, + 171: {region: 0x4e50, code: 0xbf}, + 172: {region: 0x4e52, code: 0x13}, + 173: {region: 0x4e55, code: 0xc0}, + 174: {region: 0x4e5a, code: 0xc0}, + 175: {region: 0x4f4d, code: 0xc1}, + 176: {region: 0x5041, code: 0xc2}, + 177: {region: 0x5045, code: 0xc4}, + 178: {region: 0x5046, code: 0x117}, + 179: {region: 0x5047, code: 0xc6}, + 180: {region: 0x5048, code: 0xc7}, + 181: {region: 0x504b, code: 0xc8}, + 182: {region: 0x504c, code: 0xc9}, + 183: {region: 0x504d, code: 0x5e}, + 184: {region: 0x504e, code: 0xc0}, + 185: {region: 0x5052, code: 0xfc}, + 186: {region: 0x5053, code: 0x7c}, + 187: {region: 0x5054, code: 0x5e}, + 188: {region: 0x5057, code: 0xfc}, + 189: {region: 0x5059, code: 0xcc}, + 190: {region: 0x5141, code: 0xcd}, + 191: {region: 0x5245, code: 0x5e}, + 192: {region: 0x524f, code: 0xd0}, + 193: {region: 0x5253, code: 0xd1}, + 194: {region: 0x5255, code: 0xd2}, + 195: {region: 0x5257, code: 0xd4}, + 196: {region: 0x5341, code: 0xd5}, + 197: {region: 0x5342, code: 0xd6}, + 198: {region: 0x5343, code: 0xd7}, + 199: {region: 0x5344, code: 0xd9}, + 200: {region: 0x5345, code: 0xdb}, + 201: {region: 0x5347, code: 0xdc}, + 202: {region: 0x5348, code: 0xdd}, + 203: {region: 0x5349, code: 0x5e}, + 204: {region: 0x534a, code: 0xbe}, + 205: {region: 0x534b, code: 0x5e}, + 206: {region: 0x534c, code: 0xe0}, + 207: {region: 0x534d, code: 0x5e}, + 208: {region: 0x534e, code: 0x115}, + 209: {region: 0x534f, code: 0xe1}, + 210: {region: 0x5352, code: 0xe2}, + 211: {region: 0x5353, code: 0xe4}, + 212: {region: 0x5354, code: 0xe6}, + 213: {region: 0x5356, code: 0xfc}, + 214: {region: 0x5358, code: 0x8}, + 215: {region: 0x5359, code: 0xe9}, + 216: {region: 0x535a, code: 0xea}, + 217: {region: 0x5441, code: 0x63}, + 218: {region: 0x5443, code: 0xfc}, + 219: {region: 0x5444, code: 0x109}, + 220: {region: 0x5446, code: 0x5e}, + 221: {region: 0x5447, code: 0x115}, + 222: {region: 0x5448, code: 0xeb}, + 223: {region: 0x544a, code: 0xed}, + 224: {region: 0x544b, code: 0xc0}, + 225: {region: 0x544c, code: 0xfc}, + 226: {region: 0x544d, code: 0xef}, + 227: {region: 0x544e, code: 0xf0}, + 228: {region: 0x544f, code: 0xf1}, + 229: {region: 0x5452, code: 0xf4}, + 230: {region: 0x5454, code: 0xf5}, + 231: {region: 0x5456, code: 0x13}, + 232: {region: 0x5457, code: 0xf6}, + 233: {region: 0x545a, code: 0xf7}, + 234: {region: 0x5541, code: 0xf8}, + 235: {region: 0x5547, code: 0xfb}, + 236: {region: 0x554d, code: 0xfc}, + 237: {region: 0x5553, code: 0xfc}, + 238: {region: 0x5559, code: 0x101}, + 239: {region: 0x555a, code: 0x102}, + 240: {region: 0x5641, code: 0x5e}, + 241: {region: 0x5643, code: 0x110}, + 242: {region: 0x5645, code: 0x104}, + 243: {region: 0x5647, code: 0xfc}, + 244: {region: 0x5649, code: 0xfc}, + 245: {region: 0x564e, code: 0x105}, + 246: {region: 0x5655, code: 0x107}, + 247: {region: 0x5746, code: 0x117}, + 248: {region: 0x5753, code: 0x108}, + 249: {region: 0x584b, code: 0x5e}, + 250: {region: 0x5945, code: 0x11f}, + 251: {region: 0x5954, code: 0x5e}, + 252: {region: 0x5a41, code: 0x125}, + 253: {region: 0x5a4d, code: 0x127}, + 254: {region: 0x5a57, code: 0xfc}, +} // Size: 1044 bytes + +type regionInfo struct { + region uint16 + code uint16 + from uint32 + to uint32 +} + +var regionData = []regionInfo{ // 495 elements + 0: {region: 0x4143, code: 0xdd, from: 0xf7021, to: 0x0}, + 1: {region: 0x4144, code: 0x5e, from: 0xf9e21, to: 0x0}, + 2: {region: 0x4144, code: 0x5c, from: 0xea221, to: 0xfa45c}, + 3: {region: 0x4144, code: 0x62, from: 0xf5021, to: 0xfa451}, + 4: {region: 0x4144, code: 0x1, from: 0xf2021, to: 0xfa39f}, + 5: {region: 0x4145, code: 0x2, from: 0xf6ab3, to: 0x0}, + 6: {region: 0x4146, code: 0x4, from: 0xfa547, to: 0x0}, + 7: {region: 0x4146, code: 0x3, from: 0xf0e6e, to: 0xfa59f}, + 8: {region: 0x4147, code: 0x110, from: 0xf5b46, to: 0x0}, + 9: {region: 0x4149, code: 0x110, from: 0xf5b46, to: 0x0}, + 10: {region: 0x414c, code: 0x6, from: 0xf5b10, to: 0x0}, + 11: {region: 0x414c, code: 0x5, from: 0xf3561, to: 0xf5b10}, + 12: {region: 0x414d, code: 0x7, from: 0xf9376, to: 0x0}, + 13: {region: 0x414d, code: 0xd3, from: 0xf8f99, to: 0xf9376}, + 14: {region: 0x414d, code: 0xe7, from: 0xf5221, to: 0xf8f99}, + 15: {region: 0x414f, code: 0x9, from: 0xf9f8d, to: 0x0}, + 16: {region: 0x414f, code: 0xc, from: 0xf96e1, to: 0xfa041}, + 17: {region: 0x414f, code: 0xb, from: 0xf8d39, to: 0xfa041}, + 18: {region: 0x414f, code: 0xa, from: 0xf7228, to: 0xf8e61}, + 19: {region: 0x4151, code: 0x811d, from: 0x0, to: 0x0}, + 20: {region: 0x4152, code: 0x11, from: 0xf9021, to: 0x0}, + 21: {region: 0x4152, code: 0xd, from: 0xf82ce, to: 0xf9021}, + 22: {region: 0x4152, code: 0x10, from: 0xf7ec1, to: 0xf82ce}, + 23: {region: 0x4152, code: 0xe, from: 0xf6421, to: 0xf7ec1}, + 24: {region: 0x4152, code: 0xf, from: 0xeb365, to: 0xf6421}, + 25: {region: 0x4153, code: 0xfc, from: 0xee0f0, to: 0x0}, + 26: {region: 0x4154, code: 0x5e, from: 0xf9e21, to: 0x0}, + 27: {region: 0x4154, code: 0x12, from: 0xf3784, to: 0xfa45c}, + 28: {region: 0x4155, code: 0x13, from: 0xf5c4e, to: 0x0}, + 29: {region: 0x4157, code: 0x14, from: 0xf8421, to: 0x0}, + 30: {region: 0x4157, code: 0x8, from: 0xf28aa, to: 0xf8421}, + 31: {region: 0x4158, code: 0x5e, from: 0xf9e21, to: 0x0}, + 32: {region: 0x415a, code: 0x16, from: 0xfac21, to: 0x0}, + 33: {region: 0x415a, code: 0x15, from: 0xf9376, to: 0xfad9f}, + 34: {region: 0x415a, code: 0xd3, from: 0xf8f99, to: 0xf9421}, + 35: {region: 0x415a, code: 0xe7, from: 0xf5221, to: 0xf8f99}, + 36: {region: 0x4241, code: 0x18, from: 0xf9621, to: 0x0}, + 37: {region: 0x4241, code: 0x19, from: 0xf950f, to: 0xf9ae1}, + 38: {region: 0x4241, code: 0x17, from: 0xf90e1, to: 0xf950f}, + 39: {region: 0x4241, code: 0x123, from: 0xf90e1, to: 0xf9341}, + 40: {region: 0x4241, code: 0x122, from: 0xf8c21, to: 0xf90e1}, + 41: {region: 0x4241, code: 0x120, from: 0xf5c21, to: 0xf8c21}, + 42: {region: 0x4242, code: 0x1a, from: 0xf6b83, to: 0x0}, + 43: {region: 0x4242, code: 0x110, from: 0xf5b46, to: 0xf6b83}, + 44: {region: 0x4244, code: 0x1b, from: 0xf6821, to: 0x0}, + 45: {region: 0x4244, code: 0xc8, from: 0xf3881, to: 0xf6821}, + 46: {region: 0x4244, code: 0x7d, from: 0xe5711, to: 0xf3881}, + 47: {region: 0x4245, code: 0x5e, from: 0xf9e21, to: 0x0}, + 48: {region: 0x4245, code: 0x1d, from: 0xe4e47, to: 0xfa45c}, + 49: {region: 0x4245, code: 0xbd, from: 0xe318f, to: 0xe4e47}, + 50: {region: 0x4245, code: 0x801e, from: 0xf6421, to: 0xf8c65}, + 51: {region: 0x4245, code: 0x801c, from: 0xf6421, to: 0xf8c65}, + 52: {region: 0x4246, code: 0x115, from: 0xf8104, to: 0x0}, + 53: {region: 0x4247, code: 0x21, from: 0xf9ee5, to: 0x0}, + 54: {region: 0x4247, code: 0x1f, from: 0xf5421, to: 0xf9ee5}, + 55: {region: 0x4247, code: 0x20, from: 0xf40ac, to: 0xf5421}, + 56: {region: 0x4247, code: 0x22, from: 0xeaee8, to: 0xf40ac}, + 57: {region: 0x4248, code: 0x23, from: 0xf5b50, to: 0x0}, + 58: {region: 0x4249, code: 0x24, from: 0xf58b3, to: 0x0}, + 59: {region: 0x424a, code: 0x115, from: 0xf6f7e, to: 0x0}, + 60: {region: 0x424c, code: 0x5e, from: 0xf9e21, to: 0x0}, + 61: {region: 0x424c, code: 0x62, from: 0xf5021, to: 0xfa451}, + 62: {region: 0x424d, code: 0x25, from: 0xf6446, to: 0x0}, + 63: {region: 0x424e, code: 0x26, from: 0xf5ecc, to: 0x0}, + 64: {region: 0x424e, code: 0xb5, from: 0xf5730, to: 0xf5ecc}, + 65: {region: 0x424f, code: 0x27, from: 0xf8621, to: 0x0}, + 66: {region: 0x424f, code: 0x29, from: 0xf5621, to: 0xf859f}, + 67: {region: 0x424f, code: 0x28, from: 0xe8ed7, to: 0xf5621}, + 68: {region: 0x424f, code: 0x802a, from: 0x0, to: 0x0}, + 69: {region: 0x4251, code: 0xfc, from: 0xfb621, to: 0x0}, + 70: {region: 0x4251, code: 0x8, from: 0xfb54a, to: 0xfb621}, + 71: {region: 0x4252, code: 0x2e, from: 0xf94e1, to: 0x0}, + 72: {region: 0x4252, code: 0x30, from: 0xf9301, to: 0xf94e1}, + 73: {region: 0x4252, code: 0x2d, from: 0xf8c70, to: 0xf9301}, + 74: {region: 0x4252, code: 0x2f, from: 0xf8a2f, to: 0xf8c70}, + 75: {region: 0x4252, code: 0x2c, from: 0xf845c, to: 0xf8a2f}, + 76: {region: 0x4252, code: 0x2b, from: 0xf5e4d, to: 0xf845c}, + 77: {region: 0x4252, code: 0x31, from: 0xf2d61, to: 0xf5e4d}, + 78: {region: 0x4253, code: 0x32, from: 0xf5cb9, to: 0x0}, + 79: {region: 0x4254, code: 0x33, from: 0xf6c90, to: 0x0}, + 80: {region: 0x4254, code: 0x7d, from: 0xee621, to: 0x0}, + 81: {region: 0x4255, code: 0x34, from: 0xf40e1, to: 0xf8ad2}, + 82: {region: 0x4256, code: 0xbe, from: 0xee2c7, to: 0x0}, + 83: {region: 0x4257, code: 0x35, from: 0xf7117, to: 0x0}, + 84: {region: 0x4257, code: 0x125, from: 0xf524e, to: 0xf7117}, + 85: {region: 0x4259, code: 0x37, from: 0xfc0e1, to: 0x0}, + 86: {region: 0x4259, code: 0x38, from: 0xfa021, to: 0xfc221}, + 87: {region: 0x4259, code: 0x36, from: 0xf9501, to: 0xfa19f}, + 88: {region: 0x4259, code: 0xd3, from: 0xf8f99, to: 0xf9568}, + 89: {region: 0x4259, code: 0xe7, from: 0xf5221, to: 0xf8f99}, + 90: {region: 0x425a, code: 0x39, from: 0xf6c21, to: 0x0}, + 91: {region: 0x4341, code: 0x3a, from: 0xe8421, to: 0x0}, + 92: {region: 0x4343, code: 0x13, from: 0xf5c4e, to: 0x0}, + 93: {region: 0x4344, code: 0x3b, from: 0xf9ce1, to: 0x0}, + 94: {region: 0x4344, code: 0x128, from: 0xf9361, to: 0xf9ce1}, + 95: {region: 0x4344, code: 0x129, from: 0xf675b, to: 0xf9361}, + 96: {region: 0x4346, code: 0x109, from: 0xf9221, to: 0x0}, + 97: {region: 0x4347, code: 0x109, from: 0xf9221, to: 0x0}, + 98: {region: 0x4348, code: 0x3d, from: 0xe0e71, to: 0x0}, + 99: {region: 0x4348, code: 0x803c, from: 0x0, to: 0x0}, + 100: {region: 0x4348, code: 0x803e, from: 0x0, to: 0x0}, + 101: {region: 0x4349, code: 0x115, from: 0xf4d84, to: 0x0}, + 102: {region: 0x434b, code: 0xc0, from: 0xf5eea, to: 0x0}, + 103: {region: 0x434c, code: 0x41, from: 0xf6f3d, to: 0x0}, + 104: {region: 0x434c, code: 0x3f, from: 0xf5021, to: 0xf6f3d}, + 105: {region: 0x434c, code: 0x8040, from: 0x0, to: 0x0}, + 106: {region: 0x434d, code: 0x109, from: 0xf6a81, to: 0x0}, + 107: {region: 0x434e, code: 0x44, from: 0xf4261, to: 0x0}, + 108: {region: 0x434e, code: 0x8043, from: 0xf7621, to: 0xf9d9f}, + 109: {region: 0x434e, code: 0x8042, from: 0xfb4f3, to: 0x0}, + 110: {region: 0x434f, code: 0x45, from: 0xee221, to: 0x0}, + 111: {region: 0x434f, code: 0x8046, from: 0x0, to: 0x0}, + 112: {region: 0x4350, code: 0x811d, from: 0x0, to: 0x0}, + 113: {region: 0x4352, code: 0x47, from: 0xed15a, to: 0x0}, + 114: {region: 0x4353, code: 0x48, from: 0xfa4af, to: 0xfacc3}, + 115: {region: 0x4353, code: 0x5e, from: 0xfa644, to: 0xfacc3}, + 116: {region: 0x4353, code: 0x121, from: 0xf9438, to: 0xfa4af}, + 117: {region: 0x4355, code: 0x4b, from: 0xe8621, to: 0x0}, + 118: {region: 0x4355, code: 0x4a, from: 0xf9421, to: 0x0}, + 119: {region: 0x4355, code: 0xfc, from: 0xed621, to: 0xf4e21}, + 120: {region: 0x4356, code: 0x4c, from: 0xef421, to: 0x0}, + 121: {region: 0x4356, code: 0xcb, from: 0xeeeb6, to: 0xf6ee5}, + 122: {region: 0x4357, code: 0x8, from: 0xfb54a, to: 0x0}, + 123: {region: 0x4358, code: 0x13, from: 0xf5c4e, to: 0x0}, + 124: {region: 0x4359, code: 0x5e, from: 0xfb021, to: 0x0}, + 125: {region: 0x4359, code: 0x4d, from: 0xef52a, to: 0xfb03f}, + 126: {region: 0x435a, code: 0x4e, from: 0xf9221, to: 0x0}, + 127: {region: 0x435a, code: 0x49, from: 0xf42c1, to: 0xf9261}, + 128: {region: 0x4444, code: 0x4f, from: 0xf38f4, to: 0xf8d42}, + 129: {region: 0x4445, code: 0x5e, from: 0xf9e21, to: 0x0}, + 130: {region: 0x4445, code: 0x50, from: 0xf38d4, to: 0xfa45c}, + 131: {region: 0x4447, code: 0xfc, from: 0xf5b68, to: 0x0}, + 132: {region: 0x444a, code: 0x51, from: 0xf72db, to: 0x0}, + 133: {region: 0x444b, code: 0x52, from: 0xea2bb, to: 0x0}, + 134: {region: 0x444d, code: 0x110, from: 0xf5b46, to: 0x0}, + 135: {region: 0x444f, code: 0x53, from: 0xf3741, to: 0x0}, + 136: {region: 0x444f, code: 0xfc, from: 0xee2d5, to: 0xf3741}, + 137: {region: 0x445a, code: 0x54, from: 0xf5881, to: 0x0}, + 138: {region: 0x4541, code: 0x5e, from: 0xf9e21, to: 0x0}, + 139: {region: 0x4543, code: 0xfc, from: 0xfa142, to: 0x0}, + 140: {region: 0x4543, code: 0x55, from: 0xeb881, to: 0xfa142}, + 141: {region: 0x4543, code: 0x8056, from: 0xf92b7, to: 0xfa029}, + 142: {region: 0x4545, code: 0x5e, from: 0xfb621, to: 0x0}, + 143: {region: 0x4545, code: 0x57, from: 0xf90d5, to: 0xfb59f}, + 144: {region: 0x4545, code: 0xe7, from: 0xf5221, to: 0xf90d4}, + 145: {region: 0x4547, code: 0x58, from: 0xebb6e, to: 0x0}, + 146: {region: 0x4548, code: 0x9e, from: 0xf705a, to: 0x0}, + 147: {region: 0x4552, code: 0x59, from: 0xf9b68, to: 0x0}, + 148: {region: 0x4552, code: 0x5d, from: 0xf92b8, to: 0xf9b68}, + 149: {region: 0x4553, code: 0x5e, from: 0xf9e21, to: 0x0}, + 150: {region: 0x4553, code: 0x5c, from: 0xe9953, to: 0xfa45c}, + 151: {region: 0x4553, code: 0x805a, from: 0xf7421, to: 0xf7b9f}, + 152: {region: 0x4553, code: 0x805b, from: 0xf6e21, to: 0xf959f}, + 153: {region: 0x4554, code: 0x5d, from: 0xf712f, to: 0x0}, + 154: {region: 0x4555, code: 0x5e, from: 0xf9e21, to: 0x0}, + 155: {region: 0x4555, code: 0x8112, from: 0xf7621, to: 0xf9d9f}, + 156: {region: 0x4649, code: 0x5e, from: 0xf9e21, to: 0x0}, + 157: {region: 0x4649, code: 0x5f, from: 0xf5621, to: 0xfa45c}, + 158: {region: 0x464a, code: 0x60, from: 0xf622d, to: 0x0}, + 159: {region: 0x464b, code: 0x61, from: 0xeda21, to: 0x0}, + 160: {region: 0x464d, code: 0xfc, from: 0xf3021, to: 0x0}, + 161: {region: 0x464d, code: 0x85, from: 0xef543, to: 0xf3021}, + 162: {region: 0x464f, code: 0x52, from: 0xf3821, to: 0x0}, + 163: {region: 0x4652, code: 0x5e, from: 0xf9e21, to: 0x0}, + 164: {region: 0x4652, code: 0x62, from: 0xf5021, to: 0xfa451}, + 165: {region: 0x4741, code: 0x109, from: 0xf9221, to: 0x0}, + 166: {region: 0x4742, code: 0x63, from: 0xd3cfb, to: 0x0}, + 167: {region: 0x4744, code: 0x110, from: 0xf5e5b, to: 0x0}, + 168: {region: 0x4745, code: 0x65, from: 0xf9737, to: 0x0}, + 169: {region: 0x4745, code: 0x64, from: 0xf9285, to: 0xf9739}, + 170: {region: 0x4745, code: 0xd3, from: 0xf8f99, to: 0xf92cb}, + 171: {region: 0x4745, code: 0xe7, from: 0xf5221, to: 0xf8f99}, + 172: {region: 0x4746, code: 0x5e, from: 0xf9e21, to: 0x0}, + 173: {region: 0x4746, code: 0x62, from: 0xf5021, to: 0xfa451}, + 174: {region: 0x4747, code: 0x63, from: 0xe4c21, to: 0x0}, + 175: {region: 0x4748, code: 0x67, from: 0xfaee3, to: 0x0}, + 176: {region: 0x4748, code: 0x66, from: 0xf7669, to: 0xfaf9f}, + 177: {region: 0x4749, code: 0x68, from: 0xd6221, to: 0x0}, + 178: {region: 0x474c, code: 0x52, from: 0xea2bb, to: 0x0}, + 179: {region: 0x474d, code: 0x69, from: 0xf66e1, to: 0x0}, + 180: {region: 0x474e, code: 0x6a, from: 0xf8426, to: 0x0}, + 181: {region: 0x474e, code: 0x6b, from: 0xf6942, to: 0xf8426}, + 182: {region: 0x4750, code: 0x5e, from: 0xf9e21, to: 0x0}, + 183: {region: 0x4750, code: 0x62, from: 0xf5021, to: 0xfa451}, + 184: {region: 0x4751, code: 0x109, from: 0xf9221, to: 0x0}, + 185: {region: 0x4751, code: 0x6c, from: 0xf6ee7, to: 0xf84c1}, + 186: {region: 0x4752, code: 0x5e, from: 0xfa221, to: 0x0}, + 187: {region: 0x4752, code: 0x6d, from: 0xf44a1, to: 0xfa45c}, + 188: {region: 0x4753, code: 0x63, from: 0xee821, to: 0x0}, + 189: {region: 0x4754, code: 0x6e, from: 0xf0abb, to: 0x0}, + 190: {region: 0x4755, code: 0xfc, from: 0xf3115, to: 0x0}, + 191: {region: 0x4757, code: 0x115, from: 0xf9a7f, to: 0x0}, + 192: {region: 0x4757, code: 0x70, from: 0xf705c, to: 0xf9a7f}, + 193: {region: 0x4757, code: 0x6f, from: 0xef421, to: 0xf705c}, + 194: {region: 0x4759, code: 0x71, from: 0xf5cba, to: 0x0}, + 195: {region: 0x484b, code: 0x72, from: 0xece42, to: 0x0}, + 196: {region: 0x484d, code: 0x13, from: 0xf5e50, to: 0x0}, + 197: {region: 0x484e, code: 0x73, from: 0xf0c83, to: 0x0}, + 198: {region: 0x4852, code: 0x75, from: 0xf94be, to: 0x0}, + 199: {region: 0x4852, code: 0x74, from: 0xf8f97, to: 0xf9621}, + 200: {region: 0x4852, code: 0x122, from: 0xf8c21, to: 0xf8f97}, + 201: {region: 0x4852, code: 0x120, from: 0xf5c21, to: 0xf8c21}, + 202: {region: 0x4854, code: 0x76, from: 0xea11a, to: 0x0}, + 203: {region: 0x4854, code: 0xfc, from: 0xef621, to: 0x0}, + 204: {region: 0x4855, code: 0x77, from: 0xf34f7, to: 0x0}, + 205: {region: 0x4943, code: 0x5e, from: 0xf9e21, to: 0x0}, + 206: {region: 0x4944, code: 0x78, from: 0xf5b8d, to: 0x0}, + 207: {region: 0x4945, code: 0x5e, from: 0xf9e21, to: 0x0}, + 208: {region: 0x4945, code: 0x79, from: 0xf0421, to: 0xfa449}, + 209: {region: 0x4945, code: 0x63, from: 0xe1021, to: 0xf0421}, + 210: {region: 0x494c, code: 0x7c, from: 0xf8324, to: 0x0}, + 211: {region: 0x494c, code: 0x7b, from: 0xf7856, to: 0xf8324}, + 212: {region: 0x494c, code: 0x7a, from: 0xf3910, to: 0xf7856}, + 213: {region: 0x494d, code: 0x63, from: 0xe6023, to: 0x0}, + 214: {region: 0x494e, code: 0x7d, from: 0xe5711, to: 0x0}, + 215: {region: 0x494f, code: 0xfc, from: 0xf5b68, to: 0x0}, + 216: {region: 0x4951, code: 0x7e, from: 0xf1693, to: 0x0}, + 217: {region: 0x4951, code: 0x58, from: 0xf016b, to: 0xf1693}, + 218: {region: 0x4951, code: 0x7d, from: 0xf016b, to: 0xf1693}, + 219: {region: 0x4952, code: 0x7f, from: 0xf18ad, to: 0x0}, + 220: {region: 0x4953, code: 0x81, from: 0xf7a21, to: 0x0}, + 221: {region: 0x4953, code: 0x80, from: 0xefd81, to: 0xf7a21}, + 222: {region: 0x4953, code: 0x52, from: 0xea2bb, to: 0xefd81}, + 223: {region: 0x4954, code: 0x5e, from: 0xf9e21, to: 0x0}, + 224: {region: 0x4954, code: 0x82, from: 0xe8d18, to: 0xfa45c}, + 225: {region: 0x4a45, code: 0x63, from: 0xe5a21, to: 0x0}, + 226: {region: 0x4a4d, code: 0x83, from: 0xf6328, to: 0x0}, + 227: {region: 0x4a4f, code: 0x84, from: 0xf3ce1, to: 0x0}, + 228: {region: 0x4a50, code: 0x85, from: 0xe9ec1, to: 0x0}, + 229: {region: 0x4b45, code: 0x86, from: 0xf5d2e, to: 0x0}, + 230: {region: 0x4b47, code: 0x87, from: 0xf92aa, to: 0x0}, + 231: {region: 0x4b47, code: 0xd3, from: 0xf8f99, to: 0xf92aa}, + 232: {region: 0x4b47, code: 0xe7, from: 0xf5221, to: 0xf8f99}, + 233: {region: 0x4b48, code: 0x88, from: 0xf7874, to: 0x0}, + 234: {region: 0x4b49, code: 0x13, from: 0xf5c4e, to: 0x0}, + 235: {region: 0x4b4d, code: 0x89, from: 0xf6ee6, to: 0x0}, + 236: {region: 0x4b4e, code: 0x110, from: 0xf5b46, to: 0x0}, + 237: {region: 0x4b50, code: 0x8a, from: 0xf4e91, to: 0x0}, + 238: {region: 0x4b52, code: 0x8d, from: 0xf54ca, to: 0x0}, + 239: {region: 0x4b52, code: 0x8b, from: 0xf424f, to: 0xf54ca}, + 240: {region: 0x4b52, code: 0x8c, from: 0xf330f, to: 0xf424f}, + 241: {region: 0x4b57, code: 0x8e, from: 0xf5281, to: 0x0}, + 242: {region: 0x4b59, code: 0x8f, from: 0xf6621, to: 0x0}, + 243: {region: 0x4b59, code: 0x83, from: 0xf6328, to: 0xf6621}, + 244: {region: 0x4b5a, code: 0x90, from: 0xf9365, to: 0x0}, + 245: {region: 0x4c41, code: 0x91, from: 0xf778a, to: 0x0}, + 246: {region: 0x4c42, code: 0x92, from: 0xf3842, to: 0x0}, + 247: {region: 0x4c43, code: 0x110, from: 0xf5b46, to: 0x0}, + 248: {region: 0x4c49, code: 0x3d, from: 0xf0241, to: 0x0}, + 249: {region: 0x4c4b, code: 0x93, from: 0xf74b6, to: 0x0}, + 250: {region: 0x4c52, code: 0x94, from: 0xf3021, to: 0x0}, + 251: {region: 0x4c53, code: 0x125, from: 0xf524e, to: 0x0}, + 252: {region: 0x4c53, code: 0x95, from: 0xf7836, to: 0x0}, + 253: {region: 0x4c54, code: 0x5e, from: 0xfbe21, to: 0x0}, + 254: {region: 0x4c54, code: 0x96, from: 0xf92d9, to: 0xfbd9f}, + 255: {region: 0x4c54, code: 0x97, from: 0xf9141, to: 0xf92d9}, + 256: {region: 0x4c54, code: 0xe7, from: 0xf5221, to: 0xf9141}, + 257: {region: 0x4c55, code: 0x5e, from: 0xf9e21, to: 0x0}, + 258: {region: 0x4c55, code: 0x99, from: 0xf3124, to: 0xfa45c}, + 259: {region: 0x4c55, code: 0x8098, from: 0xf6421, to: 0xf8c65}, + 260: {region: 0x4c55, code: 0x809a, from: 0xf6421, to: 0xf8c65}, + 261: {region: 0x4c56, code: 0x5e, from: 0xfbc21, to: 0x0}, + 262: {region: 0x4c56, code: 0x9b, from: 0xf92dc, to: 0xfbb9f}, + 263: {region: 0x4c56, code: 0x9c, from: 0xf90a7, to: 0xf9351}, + 264: {region: 0x4c56, code: 0xe7, from: 0xf5221, to: 0xf90f4}, + 265: {region: 0x4c59, code: 0x9d, from: 0xf6721, to: 0x0}, + 266: {region: 0x4d41, code: 0x9e, from: 0xf4f51, to: 0x0}, + 267: {region: 0x4d41, code: 0x9f, from: 0xeb221, to: 0xf4f51}, + 268: {region: 0x4d43, code: 0x5e, from: 0xf9e21, to: 0x0}, + 269: {region: 0x4d43, code: 0x62, from: 0xf5021, to: 0xfa451}, + 270: {region: 0x4d43, code: 0xa0, from: 0xf5021, to: 0xfa451}, + 271: {region: 0x4d44, code: 0xa2, from: 0xf937d, to: 0x0}, + 272: {region: 0x4d44, code: 0xa1, from: 0xf90c1, to: 0xf937d}, + 273: {region: 0x4d45, code: 0x5e, from: 0xfa421, to: 0x0}, + 274: {region: 0x4d45, code: 0x50, from: 0xf9f42, to: 0xfa4af}, + 275: {region: 0x4d45, code: 0x121, from: 0xf9438, to: 0xfa4af}, + 276: {region: 0x4d46, code: 0x5e, from: 0xf9e21, to: 0x0}, + 277: {region: 0x4d46, code: 0x62, from: 0xf5021, to: 0xfa451}, + 278: {region: 0x4d47, code: 0xa3, from: 0xf7f61, to: 0x0}, + 279: {region: 0x4d47, code: 0xa4, from: 0xf56e1, to: 0xfa99f}, + 280: {region: 0x4d48, code: 0xfc, from: 0xf3021, to: 0x0}, + 281: {region: 0x4d4b, code: 0xa5, from: 0xf92b4, to: 0x0}, + 282: {region: 0x4d4b, code: 0xa6, from: 0xf909a, to: 0xf92b4}, + 283: {region: 0x4d4c, code: 0x115, from: 0xf80c1, to: 0x0}, + 284: {region: 0x4d4c, code: 0xa7, from: 0xf54e2, to: 0xf811f}, + 285: {region: 0x4d4c, code: 0x115, from: 0xf4d78, to: 0xf54e2}, + 286: {region: 0x4d4d, code: 0xa8, from: 0xf8ad2, to: 0x0}, + 287: {region: 0x4d4d, code: 0x34, from: 0xf40e1, to: 0xf8ad2}, + 288: {region: 0x4d4e, code: 0xa9, from: 0xef661, to: 0x0}, + 289: {region: 0x4d4f, code: 0xaa, from: 0xeda21, to: 0x0}, + 290: {region: 0x4d50, code: 0xfc, from: 0xf3021, to: 0x0}, + 291: {region: 0x4d51, code: 0x5e, from: 0xf9e21, to: 0x0}, + 292: {region: 0x4d51, code: 0x62, from: 0xf5021, to: 0xfa451}, + 293: {region: 0x4d52, code: 0xab, from: 0xf6add, to: 0x0}, + 294: {region: 0x4d52, code: 0x115, from: 0xf4d7c, to: 0xf6add}, + 295: {region: 0x4d53, code: 0x110, from: 0xf5e5b, to: 0x0}, + 296: {region: 0x4d54, code: 0x5e, from: 0xfb021, to: 0x0}, + 297: {region: 0x4d54, code: 0xac, from: 0xf60c7, to: 0xfb03f}, + 298: {region: 0x4d54, code: 0xad, from: 0xef50d, to: 0xf60c7}, + 299: {region: 0x4d55, code: 0xae, from: 0xf1c81, to: 0x0}, + 300: {region: 0x4d56, code: 0xb0, from: 0xf7ae1, to: 0x0}, + 301: {region: 0x4d57, code: 0xb1, from: 0xf664f, to: 0x0}, + 302: {region: 0x4d58, code: 0xb2, from: 0xf9221, to: 0x0}, + 303: {region: 0x4d58, code: 0xb3, from: 0xe3c21, to: 0xf919f}, + 304: {region: 0x4d58, code: 0x80b4, from: 0x0, to: 0x0}, + 305: {region: 0x4d59, code: 0xb5, from: 0xf5730, to: 0x0}, + 306: {region: 0x4d5a, code: 0xb8, from: 0xface1, to: 0x0}, + 307: {region: 0x4d5a, code: 0xb7, from: 0xf78d0, to: 0xfad9f}, + 308: {region: 0x4d5a, code: 0xb6, from: 0xf6ed9, to: 0xf78d0}, + 309: {region: 0x4e41, code: 0xb9, from: 0xf9221, to: 0x0}, + 310: {region: 0x4e41, code: 0x125, from: 0xf524e, to: 0x0}, + 311: {region: 0x4e43, code: 0x117, from: 0xf8221, to: 0x0}, + 312: {region: 0x4e45, code: 0x115, from: 0xf4d93, to: 0x0}, + 313: {region: 0x4e46, code: 0x13, from: 0xf5c4e, to: 0x0}, + 314: {region: 0x4e47, code: 0xba, from: 0xf6a21, to: 0x0}, + 315: {region: 0x4e49, code: 0xbc, from: 0xf8e9e, to: 0x0}, + 316: {region: 0x4e49, code: 0xbb, from: 0xf884f, to: 0xf8e9e}, + 317: {region: 0x4e4c, code: 0x5e, from: 0xf9e21, to: 0x0}, + 318: {region: 0x4e4c, code: 0xbd, from: 0xe2a21, to: 0xfa45c}, + 319: {region: 0x4e4f, code: 0xbe, from: 0xee2c7, to: 0x0}, + 320: {region: 0x4e4f, code: 0xdb, from: 0xea2bb, to: 0xee2c7}, + 321: {region: 0x4e50, code: 0xbf, from: 0xf1a21, to: 0x0}, + 322: {region: 0x4e50, code: 0x7d, from: 0xe9c21, to: 0xf5d51}, + 323: {region: 0x4e52, code: 0x13, from: 0xf5c4e, to: 0x0}, + 324: {region: 0x4e55, code: 0xc0, from: 0xf5eea, to: 0x0}, + 325: {region: 0x4e5a, code: 0xc0, from: 0xf5eea, to: 0x0}, + 326: {region: 0x4f4d, code: 0xc1, from: 0xf696b, to: 0x0}, + 327: {region: 0x5041, code: 0xc2, from: 0xedf64, to: 0x0}, + 328: {region: 0x5041, code: 0xfc, from: 0xedf72, to: 0x0}, + 329: {region: 0x5045, code: 0xc4, from: 0xf8ee1, to: 0x0}, + 330: {region: 0x5045, code: 0xc3, from: 0xf8241, to: 0xf8ee1}, + 331: {region: 0x5045, code: 0xc5, from: 0xe8e4e, to: 0xf8241}, + 332: {region: 0x5046, code: 0x117, from: 0xf339a, to: 0x0}, + 333: {region: 0x5047, code: 0xc6, from: 0xf6f30, to: 0x0}, + 334: {region: 0x5047, code: 0x13, from: 0xf5c4e, to: 0xf6f30}, + 335: {region: 0x5048, code: 0xc7, from: 0xf34e4, to: 0x0}, + 336: {region: 0x504b, code: 0xc8, from: 0xf3881, to: 0x0}, + 337: {region: 0x504b, code: 0x7d, from: 0xe5711, to: 0xf370f}, + 338: {region: 0x504c, code: 0xc9, from: 0xf9621, to: 0x0}, + 339: {region: 0x504c, code: 0xca, from: 0xf3d5c, to: 0xf959f}, + 340: {region: 0x504d, code: 0x5e, from: 0xf9e21, to: 0x0}, + 341: {region: 0x504d, code: 0x62, from: 0xf6995, to: 0xfa451}, + 342: {region: 0x504e, code: 0xc0, from: 0xf622d, to: 0x0}, + 343: {region: 0x5052, code: 0xfc, from: 0xed58a, to: 0x0}, + 344: {region: 0x5052, code: 0x5c, from: 0xe1021, to: 0xed58a}, + 345: {region: 0x5053, code: 0x7c, from: 0xf8324, to: 0x0}, + 346: {region: 0x5053, code: 0x84, from: 0xf984c, to: 0x0}, + 347: {region: 0x5053, code: 0x7a, from: 0xf5ec1, to: 0xf7856}, + 348: {region: 0x5053, code: 0x84, from: 0xf3ce1, to: 0xf5ec1}, + 349: {region: 0x5054, code: 0x5e, from: 0xf9e21, to: 0x0}, + 350: {region: 0x5054, code: 0xcb, from: 0xeeeb6, to: 0xfa45c}, + 351: {region: 0x5057, code: 0xfc, from: 0xf3021, to: 0x0}, + 352: {region: 0x5059, code: 0xcc, from: 0xf2f61, to: 0x0}, + 353: {region: 0x5141, code: 0xcd, from: 0xf6ab3, to: 0x0}, + 354: {region: 0x5245, code: 0x5e, from: 0xf9e21, to: 0x0}, + 355: {region: 0x5245, code: 0x62, from: 0xf6e21, to: 0xfa451}, + 356: {region: 0x524f, code: 0xd0, from: 0xfaae1, to: 0x0}, + 357: {region: 0x524f, code: 0xcf, from: 0xf403c, to: 0xfad9f}, + 358: {region: 0x5253, code: 0xd1, from: 0xfad59, to: 0x0}, + 359: {region: 0x5253, code: 0x48, from: 0xfa4af, to: 0xfad59}, + 360: {region: 0x5253, code: 0x121, from: 0xf9438, to: 0xfa4af}, + 361: {region: 0x5255, code: 0xd2, from: 0xf9e21, to: 0x0}, + 362: {region: 0x5255, code: 0xd3, from: 0xf8f99, to: 0xf9d9f}, + 363: {region: 0x5257, code: 0xd4, from: 0xf58b3, to: 0x0}, + 364: {region: 0x5341, code: 0xd5, from: 0xf4156, to: 0x0}, + 365: {region: 0x5342, code: 0xd6, from: 0xf7358, to: 0x0}, + 366: {region: 0x5342, code: 0x13, from: 0xf5c4e, to: 0xf74de}, + 367: {region: 0x5343, code: 0xd7, from: 0xedf61, to: 0x0}, + 368: {region: 0x5344, code: 0xd9, from: 0xfae2a, to: 0x0}, + 369: {region: 0x5344, code: 0xd8, from: 0xf90c8, to: 0xfaede}, + 370: {region: 0x5344, code: 0xda, from: 0xf4a88, to: 0xf9cc1}, + 371: {region: 0x5344, code: 0x58, from: 0xec233, to: 0xf4c21}, + 372: {region: 0x5344, code: 0x63, from: 0xec233, to: 0xf4c21}, + 373: {region: 0x5345, code: 0xdb, from: 0xea2bb, to: 0x0}, + 374: {region: 0x5347, code: 0xdc, from: 0xf5ecc, to: 0x0}, + 375: {region: 0x5347, code: 0xb5, from: 0xf5730, to: 0xf5ecc}, + 376: {region: 0x5348, code: 0xdd, from: 0xefa4f, to: 0x0}, + 377: {region: 0x5349, code: 0x5e, from: 0xfae21, to: 0x0}, + 378: {region: 0x5349, code: 0xde, from: 0xf9147, to: 0xfae2e}, + 379: {region: 0x534a, code: 0xbe, from: 0xee2c7, to: 0x0}, + 380: {region: 0x534b, code: 0x5e, from: 0xfb221, to: 0x0}, + 381: {region: 0x534b, code: 0xdf, from: 0xf919f, to: 0xfb221}, + 382: {region: 0x534b, code: 0x49, from: 0xf42c1, to: 0xf919f}, + 383: {region: 0x534c, code: 0xe0, from: 0xf5904, to: 0x0}, + 384: {region: 0x534c, code: 0x63, from: 0xe217e, to: 0xf5c44}, + 385: {region: 0x534d, code: 0x5e, from: 0xf9e21, to: 0x0}, + 386: {region: 0x534d, code: 0x82, from: 0xe9397, to: 0xfa25c}, + 387: {region: 0x534e, code: 0x115, from: 0xf4e84, to: 0x0}, + 388: {region: 0x534f, code: 0xe1, from: 0xf50e1, to: 0x0}, + 389: {region: 0x5352, code: 0xe2, from: 0xfa821, to: 0x0}, + 390: {region: 0x5352, code: 0xe3, from: 0xf28aa, to: 0xfa79f}, + 391: {region: 0x5352, code: 0xbd, from: 0xe2f74, to: 0xf28aa}, + 392: {region: 0x5353, code: 0xe4, from: 0xfb6f2, to: 0x0}, + 393: {region: 0x5353, code: 0xd9, from: 0xfae2a, to: 0xfb721}, + 394: {region: 0x5354, code: 0xe6, from: 0xfc421, to: 0x0}, + 395: {region: 0x5354, code: 0xe5, from: 0xf7328, to: 0xfc39f}, + 396: {region: 0x5355, code: 0xe7, from: 0xf5221, to: 0xf8f99}, + 397: {region: 0x5356, code: 0xfc, from: 0xfa221, to: 0x0}, + 398: {region: 0x5356, code: 0xe8, from: 0xeff6b, to: 0xfa221}, + 399: {region: 0x5358, code: 0x8, from: 0xfb54a, to: 0x0}, + 400: {region: 0x5359, code: 0xe9, from: 0xf3821, to: 0x0}, + 401: {region: 0x535a, code: 0xea, from: 0xf6d26, to: 0x0}, + 402: {region: 0x5441, code: 0x63, from: 0xf242c, to: 0x0}, + 403: {region: 0x5443, code: 0xfc, from: 0xf6328, to: 0x0}, + 404: {region: 0x5444, code: 0x109, from: 0xf9221, to: 0x0}, + 405: {region: 0x5446, code: 0x5e, from: 0xf9e21, to: 0x0}, + 406: {region: 0x5446, code: 0x62, from: 0xf4e21, to: 0xfa451}, + 407: {region: 0x5447, code: 0x115, from: 0xf4d7c, to: 0x0}, + 408: {region: 0x5448, code: 0xeb, from: 0xf108f, to: 0x0}, + 409: {region: 0x544a, code: 0xed, from: 0xfa15a, to: 0x0}, + 410: {region: 0x544a, code: 0xec, from: 0xf96aa, to: 0xfa159}, + 411: {region: 0x544a, code: 0xd3, from: 0xf8f99, to: 0xf96aa}, + 412: {region: 0x544b, code: 0xc0, from: 0xf5eea, to: 0x0}, + 413: {region: 0x544c, code: 0xfc, from: 0xf9f54, to: 0x0}, + 414: {region: 0x544c, code: 0xf2, from: 0xf4e22, to: 0xfa4b4}, + 415: {region: 0x544c, code: 0x78, from: 0xf6f87, to: 0xfa4b4}, + 416: {region: 0x544d, code: 0xef, from: 0xfb221, to: 0x0}, + 417: {region: 0x544d, code: 0xee, from: 0xf9361, to: 0xfb221}, + 418: {region: 0x544d, code: 0xd3, from: 0xf8f99, to: 0xf9361}, + 419: {region: 0x544d, code: 0xe7, from: 0xf5221, to: 0xf8f99}, + 420: {region: 0x544e, code: 0xf0, from: 0xf4d61, to: 0x0}, + 421: {region: 0x544f, code: 0xf1, from: 0xf5c4e, to: 0x0}, + 422: {region: 0x5450, code: 0xf2, from: 0xf4e22, to: 0xfa4b4}, + 423: {region: 0x5450, code: 0x78, from: 0xf6f87, to: 0xfa4b4}, + 424: {region: 0x5452, code: 0xf4, from: 0xfaa21, to: 0x0}, + 425: {region: 0x5452, code: 0xf3, from: 0xf0561, to: 0xfab9f}, + 426: {region: 0x5454, code: 0xf5, from: 0xf5821, to: 0x0}, + 427: {region: 0x5456, code: 0x13, from: 0xf5c4e, to: 0x0}, + 428: {region: 0x5457, code: 0xf6, from: 0xf3acf, to: 0x0}, + 429: {region: 0x545a, code: 0xf7, from: 0xf5cce, to: 0x0}, + 430: {region: 0x5541, code: 0xf8, from: 0xf9922, to: 0x0}, + 431: {region: 0x5541, code: 0xf9, from: 0xf916d, to: 0xf9351}, + 432: {region: 0x5541, code: 0xd3, from: 0xf8f99, to: 0xf916d}, + 433: {region: 0x5541, code: 0xe7, from: 0xf5221, to: 0xf8f99}, + 434: {region: 0x5547, code: 0xfb, from: 0xf86af, to: 0x0}, + 435: {region: 0x5547, code: 0xfa, from: 0xf5d0f, to: 0xf86af}, + 436: {region: 0x554d, code: 0xfc, from: 0xf3021, to: 0x0}, + 437: {region: 0x5553, code: 0xfc, from: 0xe0021, to: 0x0}, + 438: {region: 0x5553, code: 0x80fd, from: 0x0, to: 0x0}, + 439: {region: 0x5553, code: 0x80fe, from: 0x0, to: 0xfbc61}, + 440: {region: 0x5559, code: 0x101, from: 0xf9261, to: 0x0}, + 441: {region: 0x5559, code: 0x100, from: 0xf6ee1, to: 0xf9261}, + 442: {region: 0x5559, code: 0x80ff, from: 0x0, to: 0x0}, + 443: {region: 0x555a, code: 0x102, from: 0xf94e1, to: 0x0}, + 444: {region: 0x5641, code: 0x5e, from: 0xf9e21, to: 0x0}, + 445: {region: 0x5641, code: 0x82, from: 0xe9d53, to: 0xfa45c}, + 446: {region: 0x5643, code: 0x110, from: 0xf5b46, to: 0x0}, + 447: {region: 0x5645, code: 0x104, from: 0xfb021, to: 0x0}, + 448: {region: 0x5645, code: 0x103, from: 0xe9eab, to: 0xfb0de}, + 449: {region: 0x5647, code: 0xfc, from: 0xe5221, to: 0x0}, + 450: {region: 0x5647, code: 0x63, from: 0xe5221, to: 0xf4e21}, + 451: {region: 0x5649, code: 0xfc, from: 0xe5a21, to: 0x0}, + 452: {region: 0x564e, code: 0x105, from: 0xf832e, to: 0x0}, + 453: {region: 0x564e, code: 0x106, from: 0xf74a3, to: 0xf832e}, + 454: {region: 0x5655, code: 0x107, from: 0xf7a21, to: 0x0}, + 455: {region: 0x5746, code: 0x117, from: 0xf52fe, to: 0x0}, + 456: {region: 0x5753, code: 0x108, from: 0xf5eea, to: 0x0}, + 457: {region: 0x584b, code: 0x5e, from: 0xfa421, to: 0x0}, + 458: {region: 0x584b, code: 0x50, from: 0xf9f21, to: 0xfa469}, + 459: {region: 0x584b, code: 0x121, from: 0xf9438, to: 0xf9f3e}, + 460: {region: 0x5944, code: 0x11e, from: 0xf5a81, to: 0xf9821}, + 461: {region: 0x5945, code: 0x11f, from: 0xf8cb6, to: 0x0}, + 462: {region: 0x5954, code: 0x5e, from: 0xf9e21, to: 0x0}, + 463: {region: 0x5954, code: 0x62, from: 0xf7057, to: 0xfa451}, + 464: {region: 0x5954, code: 0x89, from: 0xf6e21, to: 0xf7057}, + 465: {region: 0x5955, code: 0x121, from: 0xf9438, to: 0xfa4af}, + 466: {region: 0x5955, code: 0x122, from: 0xf8c21, to: 0xf90f8}, + 467: {region: 0x5955, code: 0x120, from: 0xf5c21, to: 0xf8c21}, + 468: {region: 0x5a41, code: 0x125, from: 0xf524e, to: 0x0}, + 469: {region: 0x5a41, code: 0x8124, from: 0xf8321, to: 0xf966d}, + 470: {region: 0x5a4d, code: 0x127, from: 0xfba21, to: 0x0}, + 471: {region: 0x5a4d, code: 0x126, from: 0xf6030, to: 0xfba21}, + 472: {region: 0x5a52, code: 0x128, from: 0xf9361, to: 0xf9cff}, + 473: {region: 0x5a52, code: 0x129, from: 0xf675b, to: 0xf9361}, + 474: {region: 0x5a57, code: 0xfc, from: 0xfb28c, to: 0x0}, + 475: {region: 0x5a57, code: 0x12b, from: 0xfb242, to: 0xfb28c}, + 476: {region: 0x5a57, code: 0x12c, from: 0xfb101, to: 0xfb242}, + 477: {region: 0x5a57, code: 0x12a, from: 0xf7892, to: 0xfb101}, + 478: {region: 0x5a57, code: 0xce, from: 0xf6451, to: 0xf7892}, + 479: {region: 0x5a5a, code: 0x810a, from: 0x0, to: 0x0}, + 480: {region: 0x5a5a, code: 0x810b, from: 0x0, to: 0x0}, + 481: {region: 0x5a5a, code: 0x810c, from: 0x0, to: 0x0}, + 482: {region: 0x5a5a, code: 0x810d, from: 0x0, to: 0x0}, + 483: {region: 0x5a5a, code: 0x810e, from: 0x0, to: 0x0}, + 484: {region: 0x5a5a, code: 0x810f, from: 0x0, to: 0x0}, + 485: {region: 0x5a5a, code: 0x8111, from: 0x0, to: 0x0}, + 486: {region: 0x5a5a, code: 0x8113, from: 0xf1421, to: 0xfa681}, + 487: {region: 0x5a5a, code: 0x8114, from: 0x0, to: 0xfbb7e}, + 488: {region: 0x5a5a, code: 0x8116, from: 0x0, to: 0x0}, + 489: {region: 0x5a5a, code: 0x8118, from: 0x0, to: 0x0}, + 490: {region: 0x5a5a, code: 0x8119, from: 0x0, to: 0xf9f7e}, + 491: {region: 0x5a5a, code: 0x811a, from: 0x0, to: 0x0}, + 492: {region: 0x5a5a, code: 0x811b, from: 0x0, to: 0x0}, + 493: {region: 0x5a5a, code: 0x811c, from: 0x0, to: 0x0}, + 494: {region: 0x5a5a, code: 0x811d, from: 0x0, to: 0x0}, +} // Size: 5964 bytes + +// symbols holds symbol data of the form , where n is the length of +// the symbol string str. +const symbols string = "" + // Size: 1445 bytes + "\x00\x02Kz\x01$\x02A$\x02KM\x03৳\x02Bs\x02R$\x01P\x03р.\x03CA$\x04CN¥" + + "\x02¥\x03₡\x03Kč\x02kr\x03E£\x03₧\x03€\x02£\x03₾\x02FG\x01Q\x03HK$\x01L" + + "\x02kn\x02Ft\x02Rp\x03₪\x03₹\x04JP¥\x03៛\x02CF\x03₩\x03₸\x03₭\x03L£\x02R" + + "s\x02Lt\x02Ls\x02Ar\x01K\x03₮\x03MX$\x02RM\x03₦\x02C$\x03NZ$\x03₱\x03zł" + + "\x03₲\x03lei\x03₽\x02RF\x02Db\x03฿\x02T$\x03₺\x03NT$\x03₴\x03US$\x03₫" + + "\x04FCFA\x03EC$\x03CFA\x04CFPF\x01R\x02ZK\x03leu\x05GH₵\x03AU$\x16የቻይና ዩ" + + "ዋን\x06ብር\x03***\x09د.إ.\u200f\x03AR$\x03BB$\x09د.ب.\u200f\x03BM$\x03BN" + + "$\x03BS$\x03BZ$\x03CL$\x03CO$\x03CU$\x03DO$\x09د.ج.\u200f\x09ج.م.\u200f" + + "\x03FJ$\x04UK£\x03GY$\x09د.ع.\u200f\x06ر.إ.\x03JM$\x09د.أ.\u200f\x09د.ك." + + "\u200f\x03KY$\x09ل.ل.\u200f\x09د.ل.\u200f\x09د.م.\u200f\x09أ.م.\u200f" + + "\x09ر.ع.\u200f\x09ر.ق.\u200f\x09ر.س.\u200f\x03SB$\x09د.س.\u200f\x06ج.س." + + "\x03SR$\x09ل.س.\u200f\x09د.ت.\u200f\x03TT$\x03UY$\x09ر.ي.\u200f\x03Fdj" + + "\x03Nfk\x01S\x04GB£\x03TSh\x03₼\x03ley\x03S£\x04Bds$\x03BD$\x02B$\x02Br" + + "\x04CUC$\x03$MN\x03RD$\x04FK£\x02G$\x04Íkr\x02J$\x03CI$\x02L$\x02N$\x07р" + + "уб.\x03SI$\x02S$\x02$U\x05лв.\x06щ.д.\x02$A\x03$CA\x04£ E\x05£ RU\x04$ " + + "HK\x03£L\x04$ ZN\x03$ T\x04$ SU\x04din.\x04КМ\x04Кч\x04зл\x07дин.\x04Тл" + + "\x01F\x06лей\x03USh\x04Kčs\x03ECU\x02TK\x03kr.\x03Ksh\x03öS\x03BGK\x03BG" + + "J\x04Cub$\x02DM\x04Fl£\x04F.G.\x02FC\x04F.Rw\x03Nu.\x05KR₩\x05TH฿\x06Δρχ" + + "\x02Tk\x02$b\x02Kr\x02Gs\x03CFP\x03FBu\x01D\x04MOP$\x02MK\x02SR\x02Le" + + "\x04NAf.\x01E\x02VT\x03WS$\x04SD£\x03BsF\x02p.\x03B/.\x02S/\x03Gs.\x03Bs" + + ".\x02؋\x04¥CN\x03$HK\x08ریال\x03$MX\x03$NZ\x03$EC\x02UM\x02mk\x03$AR\x03" + + "$AU\x02FB\x03$BM\x03$BN\x03$BS\x03$BZ\x03$CL\x03$CO\x04£CY\x03£E\x03$FJ" + + "\x04£FK\x04£GB\x04£GI\x04£IE\x04£IL\x05₤IT\x04£LB\x04£MT\x03$NA\x02$C" + + "\x03$RH\x02FR\x03$SB\x03$SG\x03$SR\x03$TT\x03$US\x03$UY\x04FCFP\x02Kw" + + "\x05$\u00a0AU\x05$\u00a0HK\x05$\u00a0NZ\x05$\u00a0SG\x05$\u00a0US\x02DA" + + "\x01G\x02LS\x02DT\x06руб\x07રૂ.\x0a\u200eCN¥\u200e\x06ל״י\x09लेई\x02֏" + + "\x03NKr\x03元\x03¥\x06レイ\x03\u200b\x06ಲೀ\x02LE\x02Kn\x06сом\x02zl\x02rb" + + "\x03MTn\x06ден\x04кр\x03NAf\x03Afl\x0cनेरू\x06रू\x04Afl.\x02ر\x03lej\x04" + + "Esc.\x06\u200bPTE\x04XXXX\x03ლ\x06ТМТ\x03Dkr\x03Skr\x03Nkr\x07රු.\x0fසිෆ" + + "්එ\x03NIS\x05Lekë\x03den\x02r.\x03BR$\x03Ekr\x04EG£\x04IE£\x03Ikr\x03R" + + "s.\x07сом.\x04AUD$\x04NZD$\x07крб.\x05soʻm\x06сўм\x03₩\x03ILS\x02P.\x03Z" + + "ł" + +type curToIndex struct { + cur uint16 + idx uint16 +} + +var normalLangIndex = []uint16{ // 776 elements + // Entry 0 - 3F + 0x0000, 0x0014, 0x0017, 0x0018, 0x0018, 0x0018, 0x0018, 0x0019, + 0x0019, 0x001d, 0x001d, 0x0034, 0x0034, 0x0034, 0x0034, 0x0035, + 0x0035, 0x0035, 0x0035, 0x0036, 0x0036, 0x0036, 0x0036, 0x0037, + 0x0037, 0x0038, 0x0038, 0x0038, 0x0038, 0x0038, 0x0038, 0x0038, + 0x0038, 0x0038, 0x0039, 0x003b, 0x003b, 0x003b, 0x003b, 0x003b, + 0x003b, 0x003b, 0x003b, 0x003c, 0x003c, 0x003f, 0x003f, 0x0041, + 0x0042, 0x0042, 0x0042, 0x0042, 0x0042, 0x0042, 0x0049, 0x0049, + 0x004a, 0x004a, 0x004b, 0x004b, 0x005c, 0x005c, 0x005c, 0x005c, + // Entry 40 - 7F + 0x005c, 0x005e, 0x005e, 0x005e, 0x005f, 0x005f, 0x0060, 0x006e, + 0x006e, 0x006e, 0x006e, 0x007f, 0x0085, 0x0085, 0x0085, 0x0085, + 0x008e, 0x008e, 0x008e, 0x008f, 0x008f, 0x0091, 0x0091, 0x0091, + 0x0092, 0x0092, 0x0093, 0x0093, 0x0094, 0x0094, 0x0095, 0x0095, + 0x0095, 0x009c, 0x009c, 0x009d, 0x009d, 0x009f, 0x009f, 0x00a3, + 0x00a3, 0x00a3, 0x00a4, 0x00a4, 0x00ac, 0x00ac, 0x00ac, 0x00ad, + 0x00ad, 0x00ad, 0x00ae, 0x00af, 0x00af, 0x00af, 0x00b4, 0x00b4, + 0x00b4, 0x00b4, 0x00b4, 0x00b4, 0x00b4, 0x00ba, 0x00ba, 0x00bb, + // Entry 80 - BF + 0x00bb, 0x00be, 0x00be, 0x00be, 0x00c1, 0x00c1, 0x00c1, 0x00c3, + 0x00c5, 0x00c5, 0x00c6, 0x00c7, 0x00c7, 0x00c7, 0x00dc, 0x00dd, + 0x00dd, 0x00de, 0x00df, 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, + 0x00e4, 0x00e5, 0x00e5, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e7, + 0x00e8, 0x00e9, 0x00e9, 0x00ea, 0x00ec, 0x00ec, 0x00ec, 0x00ed, + 0x00ed, 0x00ee, 0x00f0, 0x00f1, 0x00f1, 0x00f2, 0x00f2, 0x00f2, + 0x00f2, 0x00f2, 0x00f2, 0x00f2, 0x00f2, 0x00f3, 0x00f4, 0x00f5, + 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fb, 0x00fc, + // Entry C0 - FF + 0x00fc, 0x00fd, 0x00fe, 0x00ff, 0x0100, 0x0101, 0x0102, 0x0103, + 0x0104, 0x0104, 0x0105, 0x0106, 0x0107, 0x0108, 0x0109, 0x010a, + 0x010b, 0x010b, 0x010b, 0x010c, 0x010d, 0x010e, 0x010e, 0x010f, + 0x0110, 0x0112, 0x0112, 0x0113, 0x0115, 0x0116, 0x0117, 0x0117, + 0x0118, 0x0119, 0x011a, 0x011b, 0x011c, 0x011d, 0x011d, 0x011d, + 0x011e, 0x011e, 0x011e, 0x011f, 0x0120, 0x0121, 0x0122, 0x0122, + 0x0122, 0x0122, 0x0133, 0x0138, 0x013a, 0x013b, 0x013c, 0x013d, + 0x013f, 0x0141, 0x0142, 0x0144, 0x0146, 0x0146, 0x0147, 0x0147, + // Entry 100 - 13F + 0x0148, 0x0149, 0x014a, 0x014a, 0x014b, 0x014c, 0x014d, 0x014e, + 0x014f, 0x0150, 0x0151, 0x0152, 0x0154, 0x0156, 0x0157, 0x015c, + 0x015c, 0x015e, 0x015e, 0x015e, 0x015e, 0x0169, 0x0169, 0x0169, + 0x0169, 0x0169, 0x016a, 0x016b, 0x016b, 0x017c, 0x017c, 0x0180, + 0x0180, 0x0181, 0x0182, 0x0182, 0x01a8, 0x01a8, 0x01a8, 0x01a9, + 0x01a9, 0x01a9, 0x01ca, 0x01cb, 0x01cb, 0x01cb, 0x01cb, 0x01cb, + 0x01cb, 0x01cc, 0x01cd, 0x01cd, 0x01cd, 0x01cd, 0x01ce, 0x01ce, + 0x01ce, 0x01cf, 0x01d0, 0x01d2, 0x01d2, 0x01d2, 0x01d2, 0x01d3, + // Entry 140 - 17F + 0x01d3, 0x01d3, 0x01d4, 0x01d5, 0x01d5, 0x01d5, 0x01d5, 0x01d5, + 0x01d5, 0x01d6, 0x01d7, 0x01d7, 0x01d8, 0x01d8, 0x01d8, 0x01d9, + 0x01da, 0x01da, 0x01da, 0x01da, 0x01da, 0x01e0, 0x01e0, 0x01e3, + 0x01e3, 0x01e5, 0x01e5, 0x01e9, 0x01e9, 0x01ec, 0x01ec, 0x01ec, + 0x01ec, 0x01ed, 0x01ed, 0x01ed, 0x01ee, 0x01ee, 0x01ee, 0x01ee, + 0x01ef, 0x01f0, 0x01f0, 0x01f0, 0x01f1, 0x01f1, 0x01f6, 0x01f6, + 0x01f8, 0x01f8, 0x020a, 0x020b, 0x020b, 0x0210, 0x0210, 0x0222, + 0x0222, 0x0225, 0x0225, 0x0229, 0x0229, 0x022a, 0x022a, 0x022b, + // Entry 180 - 1BF + 0x022b, 0x022b, 0x022b, 0x0237, 0x0237, 0x023f, 0x023f, 0x023f, + 0x023f, 0x023f, 0x023f, 0x023f, 0x0242, 0x0242, 0x0242, 0x0242, + 0x0242, 0x0242, 0x0243, 0x0243, 0x0243, 0x0243, 0x024d, 0x024d, + 0x024e, 0x024e, 0x024e, 0x024f, 0x024f, 0x024f, 0x0250, 0x0250, + 0x0253, 0x0253, 0x0253, 0x0253, 0x0254, 0x0254, 0x0258, 0x0258, + 0x0258, 0x0258, 0x0259, 0x0259, 0x025a, 0x025a, 0x025d, 0x025d, + 0x025f, 0x025f, 0x0260, 0x0260, 0x0260, 0x0260, 0x0260, 0x0260, + 0x0260, 0x0261, 0x0261, 0x0261, 0x0261, 0x0261, 0x0261, 0x0261, + // Entry 1C0 - 1FF + 0x0261, 0x0261, 0x0270, 0x0270, 0x0271, 0x0271, 0x0276, 0x0276, + 0x0277, 0x0277, 0x0278, 0x0278, 0x0279, 0x027a, 0x027a, 0x027a, + 0x027a, 0x027c, 0x027c, 0x027d, 0x027d, 0x027d, 0x0290, 0x0290, + 0x0291, 0x0291, 0x0292, 0x0292, 0x0293, 0x0293, 0x0298, 0x0298, + 0x0299, 0x0299, 0x029a, 0x029b, 0x029b, 0x029c, 0x029c, 0x029d, + 0x029d, 0x029e, 0x029e, 0x029e, 0x029e, 0x02aa, 0x02aa, 0x02ad, + 0x02ad, 0x02b0, 0x02b0, 0x02b0, 0x02b2, 0x02b2, 0x02b6, 0x02b7, + 0x02b7, 0x02b8, 0x02b8, 0x02b8, 0x02b8, 0x02b8, 0x02bf, 0x02bf, + // Entry 200 - 23F + 0x02c0, 0x02c0, 0x02c0, 0x02c1, 0x02c1, 0x02d3, 0x02d3, 0x02d3, + 0x02d3, 0x02d3, 0x02d3, 0x02d3, 0x02d3, 0x02d5, 0x02d5, 0x02d5, + 0x02db, 0x02dc, 0x02dc, 0x02dd, 0x02de, 0x02de, 0x02df, 0x02e0, + 0x02e0, 0x02e0, 0x02f3, 0x02f3, 0x02f3, 0x02f3, 0x02f3, 0x02f3, + 0x02f3, 0x02f3, 0x02f5, 0x02f5, 0x02f5, 0x02f6, 0x02f6, 0x02f7, + 0x02f7, 0x02f8, 0x02fa, 0x02fa, 0x02fc, 0x02fc, 0x02fe, 0x02ff, + 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x030f, 0x030f, 0x030f, + 0x030f, 0x0310, 0x0310, 0x0313, 0x0314, 0x0314, 0x0314, 0x0316, + // Entry 240 - 27F + 0x0316, 0x0316, 0x0317, 0x0318, 0x0319, 0x031a, 0x031b, 0x031b, + 0x031c, 0x031e, 0x0320, 0x0320, 0x0320, 0x0320, 0x0321, 0x0321, + 0x0332, 0x0333, 0x0333, 0x0334, 0x0334, 0x033c, 0x033e, 0x033f, + 0x0340, 0x0341, 0x0341, 0x0341, 0x0342, 0x0342, 0x0343, 0x0343, + 0x0344, 0x0344, 0x0345, 0x0345, 0x0346, 0x0346, 0x0347, 0x0347, + 0x0347, 0x034b, 0x034b, 0x034b, 0x034d, 0x034e, 0x034e, 0x034e, + 0x034e, 0x034e, 0x034e, 0x034e, 0x034e, 0x034e, 0x034e, 0x034e, + 0x034e, 0x0351, 0x0351, 0x035f, 0x035f, 0x0369, 0x0369, 0x0369, + // Entry 280 - 2BF + 0x0369, 0x0369, 0x0369, 0x0369, 0x0369, 0x0369, 0x0369, 0x036a, + 0x036b, 0x036c, 0x036d, 0x036d, 0x036f, 0x036f, 0x0370, 0x0370, + 0x0376, 0x0376, 0x0376, 0x0376, 0x0376, 0x0376, 0x037c, 0x037c, + 0x037c, 0x037c, 0x037c, 0x037c, 0x037c, 0x037c, 0x0394, 0x0394, + 0x0394, 0x0394, 0x0397, 0x0398, 0x0398, 0x0398, 0x0399, 0x0399, + 0x039c, 0x039c, 0x039d, 0x039f, 0x03a2, 0x03a4, 0x03a4, 0x03a5, + 0x03a6, 0x03a6, 0x03a8, 0x03a8, 0x03aa, 0x03aa, 0x03ab, 0x03ac, + 0x03ac, 0x03ac, 0x03ae, 0x03ae, 0x03ae, 0x03ae, 0x03b1, 0x03b1, + // Entry 2C0 - 2FF + 0x03b6, 0x03b6, 0x03b6, 0x03b6, 0x03b8, 0x03b8, 0x03b8, 0x03b8, + 0x03b8, 0x03b8, 0x03ba, 0x03ba, 0x03cd, 0x03cd, 0x03d0, 0x03d1, + 0x03d1, 0x03d2, 0x03d3, 0x03d3, 0x03d5, 0x03d5, 0x03d5, 0x03d5, + 0x03d6, 0x03d7, 0x03d7, 0x03d7, 0x03d7, 0x03d7, 0x03d9, 0x03d9, + 0x03d9, 0x03d9, 0x03da, 0x03da, 0x03da, 0x03dc, 0x03dc, 0x03dd, + 0x03dd, 0x03dd, 0x03de, 0x03de, 0x03de, 0x03de, 0x03de, 0x03de, + 0x03df, 0x03df, 0x03df, 0x03e2, 0x03e5, 0x03e5, 0x03e5, 0x03e5, + 0x03e5, 0x03e5, 0x03e9, 0x03e9, 0x03e9, 0x03ea, 0x03ec, 0x03ee, + // Entry 300 - 33F + 0x03f2, 0x03f4, 0x03f5, 0x03f5, 0x03f7, 0x03f7, 0x03f7, 0x03f7, +} // Size: 1576 bytes + +var normalSymIndex = []curToIndex{ // 1015 elements + 0: {cur: 0x13, idx: 0x6}, + 1: {cur: 0x2e, idx: 0x13}, + 2: {cur: 0x3a, idx: 0x1c}, + 3: {cur: 0x44, idx: 0x20}, + 4: {cur: 0x5e, idx: 0x3b}, + 5: {cur: 0x63, idx: 0x3f}, + 6: {cur: 0x72, idx: 0x4b}, + 7: {cur: 0x7c, idx: 0x5a}, + 8: {cur: 0x7d, idx: 0x5e}, + 9: {cur: 0x85, idx: 0x62}, + 10: {cur: 0x8d, idx: 0x6e}, + 11: {cur: 0xb2, idx: 0x90}, + 12: {cur: 0xc0, idx: 0x9e}, + 13: {cur: 0xf6, idx: 0xc7}, + 14: {cur: 0xfc, idx: 0xcf}, + 15: {cur: 0x105, idx: 0xd3}, + 16: {cur: 0x109, idx: 0xd7}, + 17: {cur: 0x110, idx: 0xdc}, + 18: {cur: 0x115, idx: 0xe0}, + 19: {cur: 0x117, idx: 0xe4}, + 20: {cur: 0xb2, idx: 0x0}, + 21: {cur: 0xeb, idx: 0xbc}, + 22: {cur: 0x125, idx: 0xe9}, + 23: {cur: 0xb9, idx: 0x4}, + 24: {cur: 0x67, idx: 0xf2}, + 25: {cur: 0x13, idx: 0xf8}, + 26: {cur: 0x42, idx: 0xfc}, + 27: {cur: 0x5d, idx: 0x113}, + 28: {cur: 0xeb, idx: 0xbc}, + 29: {cur: 0x0, idx: 0x11a}, + 30: {cur: 0x2, idx: 0x11e}, + 31: {cur: 0x13, idx: 0xf8}, + 32: {cur: 0x23, idx: 0x130}, + 33: {cur: 0x54, idx: 0x15a}, + 34: {cur: 0x58, idx: 0x164}, + 35: {cur: 0x7e, idx: 0x17b}, + 36: {cur: 0x7f, idx: 0x185}, + 37: {cur: 0x84, idx: 0x190}, + 38: {cur: 0x8e, idx: 0x19a}, + 39: {cur: 0x92, idx: 0x1a8}, + 40: {cur: 0x9d, idx: 0x1b2}, + 41: {cur: 0x9e, idx: 0x1bc}, + 42: {cur: 0xab, idx: 0x1c6}, + 43: {cur: 0xc1, idx: 0x1d0}, + 44: {cur: 0xcd, idx: 0x1da}, + 45: {cur: 0xd5, idx: 0x1e4}, + 46: {cur: 0xd8, idx: 0x1f2}, + 47: {cur: 0xd9, idx: 0x1fc}, + 48: {cur: 0xe9, idx: 0x207}, + 49: {cur: 0xeb, idx: 0xbc}, + 50: {cur: 0xf0, idx: 0x211}, + 51: {cur: 0x11f, idx: 0x223}, + 52: {cur: 0x51, idx: 0x22d}, + 53: {cur: 0x59, idx: 0x231}, + 54: {cur: 0x89, idx: 0x6b}, + 55: {cur: 0xd9, idx: 0x0}, + 56: {cur: 0xe1, idx: 0x235}, + 57: {cur: 0x63, idx: 0x237}, + 58: {cur: 0xe4, idx: 0x3f}, + 59: {cur: 0xf7, idx: 0x23c}, + 60: {cur: 0x85, idx: 0x25}, + 61: {cur: 0xeb, idx: 0xbc}, + 62: {cur: 0xfc, idx: 0x4}, + 63: {cur: 0x16, idx: 0x240}, + 64: {cur: 0xeb, idx: 0xbc}, + 65: {cur: 0x16, idx: 0x240}, + 66: {cur: 0x2e, idx: 0x0}, + 67: {cur: 0x37, idx: 0x258}, + 68: {cur: 0x3a, idx: 0x0}, + 69: {cur: 0x85, idx: 0x25}, + 70: {cur: 0xc0, idx: 0x0}, + 71: {cur: 0xd2, idx: 0xb2}, + 72: {cur: 0xfc, idx: 0x4}, + 73: {cur: 0x127, idx: 0x8a}, + 74: {cur: 0xf7, idx: 0x23c}, + 75: {cur: 0x13, idx: 0x0}, + 76: {cur: 0x21, idx: 0x294}, + 77: {cur: 0x2e, idx: 0x0}, + 78: {cur: 0x3a, idx: 0x0}, + 79: {cur: 0x44, idx: 0x0}, + 80: {cur: 0x63, idx: 0x0}, + 81: {cur: 0x72, idx: 0x0}, + 82: {cur: 0x7c, idx: 0x0}, + 83: {cur: 0x7d, idx: 0x0}, + 84: {cur: 0x85, idx: 0x0}, + 85: {cur: 0x8d, idx: 0x0}, + 86: {cur: 0xb2, idx: 0x0}, + 87: {cur: 0xc0, idx: 0x0}, + 88: {cur: 0xf6, idx: 0x0}, + 89: {cur: 0xfc, idx: 0x29a}, + 90: {cur: 0x105, idx: 0x0}, + 91: {cur: 0x110, idx: 0x0}, + 92: {cur: 0x1b, idx: 0xc}, + 93: {cur: 0xeb, idx: 0xbc}, + 94: {cur: 0x44, idx: 0x25}, + 95: {cur: 0x44, idx: 0x20}, + 96: {cur: 0x13, idx: 0x2a1}, + 97: {cur: 0x2e, idx: 0x0}, + 98: {cur: 0x3a, idx: 0x2a4}, + 99: {cur: 0x44, idx: 0x0}, + 100: {cur: 0x63, idx: 0x2ad}, + 101: {cur: 0x72, idx: 0x2b3}, + 102: {cur: 0x7c, idx: 0x0}, + 103: {cur: 0x85, idx: 0x0}, + 104: {cur: 0x8d, idx: 0x0}, + 105: {cur: 0xc0, idx: 0x2bc}, + 106: {cur: 0xf6, idx: 0x0}, + 107: {cur: 0xfc, idx: 0x2c5}, + 108: {cur: 0x105, idx: 0x0}, + 109: {cur: 0x110, idx: 0x0}, + 110: {cur: 0x13, idx: 0x0}, + 111: {cur: 0x18, idx: 0x9}, + 112: {cur: 0x2e, idx: 0x0}, + 113: {cur: 0x3a, idx: 0x0}, + 114: {cur: 0x44, idx: 0x0}, + 115: {cur: 0x63, idx: 0x0}, + 116: {cur: 0x72, idx: 0x0}, + 117: {cur: 0x75, idx: 0x51}, + 118: {cur: 0x7c, idx: 0x0}, + 119: {cur: 0x85, idx: 0x25}, + 120: {cur: 0xb2, idx: 0x0}, + 121: {cur: 0xc0, idx: 0x0}, + 122: {cur: 0xd1, idx: 0x2ca}, + 123: {cur: 0xeb, idx: 0xbc}, + 124: {cur: 0xfc, idx: 0x0}, + 125: {cur: 0x110, idx: 0x0}, + 126: {cur: 0x117, idx: 0x0}, + 127: {cur: 0x18, idx: 0x2cf}, + 128: {cur: 0x4e, idx: 0x2d4}, + 129: {cur: 0x85, idx: 0x25}, + 130: {cur: 0xc9, idx: 0x2d9}, + 131: {cur: 0xd1, idx: 0x2de}, + 132: {cur: 0xf4, idx: 0x2e6}, + 133: {cur: 0x13, idx: 0xf8}, + 134: {cur: 0x2e, idx: 0x0}, + 135: {cur: 0x3a, idx: 0x0}, + 136: {cur: 0x44, idx: 0x25}, + 137: {cur: 0x5c, idx: 0x37}, + 138: {cur: 0xb2, idx: 0x0}, + 139: {cur: 0xeb, idx: 0xbc}, + 140: {cur: 0xfc, idx: 0x0}, + 141: {cur: 0x110, idx: 0x0}, + 142: {cur: 0x62, idx: 0x2eb}, + 143: {cur: 0x1b, idx: 0xc}, + 144: {cur: 0xeb, idx: 0xbc}, + 145: {cur: 0xd2, idx: 0xb2}, + 146: {cur: 0xfb, idx: 0x2f4}, + 147: {cur: 0xfc, idx: 0x4}, + 148: {cur: 0x7e, idx: 0x17b}, + 149: {cur: 0x13, idx: 0xf8}, + 150: {cur: 0x49, idx: 0x2f8}, + 151: {cur: 0x4e, idx: 0x2c}, + 152: {cur: 0x7c, idx: 0x0}, + 153: {cur: 0x7d, idx: 0x0}, + 154: {cur: 0x105, idx: 0x0}, + 155: {cur: 0x112, idx: 0x2fd}, + 156: {cur: 0xd2, idx: 0xb2}, + 157: {cur: 0x8d, idx: 0x0}, + 158: {cur: 0xeb, idx: 0xbc}, + 159: {cur: 0x13, idx: 0xf8}, + 160: {cur: 0x52, idx: 0x304}, + 161: {cur: 0xeb, idx: 0xbc}, + 162: {cur: 0xfc, idx: 0x4}, + 163: {cur: 0x86, idx: 0x308}, + 164: {cur: 0x12, idx: 0x30c}, + 165: {cur: 0x13, idx: 0xf8}, + 166: {cur: 0x20, idx: 0x310}, + 167: {cur: 0x22, idx: 0x314}, + 168: {cur: 0x50, idx: 0x31d}, + 169: {cur: 0x85, idx: 0x25}, + 170: {cur: 0xeb, idx: 0xbc}, + 171: {cur: 0xfc, idx: 0x4}, + 172: {cur: 0x5e, idx: 0x0}, + 173: {cur: 0x5e, idx: 0x0}, + 174: {cur: 0x99, idx: 0x2eb}, + 175: {cur: 0x13, idx: 0x0}, + 176: {cur: 0x85, idx: 0x25}, + 177: {cur: 0xc9, idx: 0xa6}, + 178: {cur: 0xeb, idx: 0xbc}, + 179: {cur: 0xfc, idx: 0x4}, + 180: {cur: 0x13, idx: 0xf8}, + 181: {cur: 0x33, idx: 0x332}, + 182: {cur: 0x7c, idx: 0x0}, + 183: {cur: 0x8d, idx: 0x336}, + 184: {cur: 0xeb, idx: 0x33c}, + 185: {cur: 0x109, idx: 0x0}, + 186: {cur: 0x86, idx: 0x308}, + 187: {cur: 0x13, idx: 0xf8}, + 188: {cur: 0x67, idx: 0xf2}, + 189: {cur: 0xeb, idx: 0xbc}, + 190: {cur: 0x6d, idx: 0x342}, + 191: {cur: 0xeb, idx: 0xbc}, + 192: {cur: 0xfc, idx: 0x4}, + 193: {cur: 0x85, idx: 0x25}, + 194: {cur: 0xfc, idx: 0x4}, + 195: {cur: 0x85, idx: 0x62}, + 196: {cur: 0xfc, idx: 0xcf}, + 197: {cur: 0x110, idx: 0x4}, + 198: {cur: 0x110, idx: 0x4}, + 199: {cur: 0x13, idx: 0x4}, + 200: {cur: 0x2e, idx: 0x0}, + 201: {cur: 0x3a, idx: 0x0}, + 202: {cur: 0x44, idx: 0x0}, + 203: {cur: 0x5e, idx: 0x0}, + 204: {cur: 0x63, idx: 0x0}, + 205: {cur: 0x72, idx: 0x0}, + 206: {cur: 0x7c, idx: 0x0}, + 207: {cur: 0x7d, idx: 0x0}, + 208: {cur: 0x85, idx: 0x0}, + 209: {cur: 0x8d, idx: 0x0}, + 210: {cur: 0xb2, idx: 0x0}, + 211: {cur: 0xc0, idx: 0x0}, + 212: {cur: 0xd7, idx: 0x7e}, + 213: {cur: 0xf6, idx: 0x0}, + 214: {cur: 0xfc, idx: 0x0}, + 215: {cur: 0x105, idx: 0x0}, + 216: {cur: 0x109, idx: 0x0}, + 217: {cur: 0x110, idx: 0x0}, + 218: {cur: 0x115, idx: 0x0}, + 219: {cur: 0x117, idx: 0x355}, + 220: {cur: 0x1a, idx: 0x4}, + 221: {cur: 0x24, idx: 0x359}, + 222: {cur: 0x25, idx: 0x4}, + 223: {cur: 0x32, idx: 0x4}, + 224: {cur: 0x35, idx: 0x16}, + 225: {cur: 0x39, idx: 0x4}, + 226: {cur: 0x3a, idx: 0x4}, + 227: {cur: 0x13, idx: 0x4}, + 228: {cur: 0xc0, idx: 0x4}, + 229: {cur: 0x13, idx: 0x4}, + 230: {cur: 0x52, idx: 0x304}, + 231: {cur: 0x110, idx: 0x4}, + 232: {cur: 0x59, idx: 0x231}, + 233: {cur: 0x60, idx: 0x4}, + 234: {cur: 0x61, idx: 0x3f}, + 235: {cur: 0x63, idx: 0x237}, + 236: {cur: 0x110, idx: 0x4}, + 237: {cur: 0x67, idx: 0xf2}, + 238: {cur: 0x63, idx: 0x237}, + 239: {cur: 0x68, idx: 0x3f}, + 240: {cur: 0x69, idx: 0x35d}, + 241: {cur: 0x71, idx: 0x4}, + 242: {cur: 0x83, idx: 0x4}, + 243: {cur: 0x86, idx: 0x308}, + 244: {cur: 0x13, idx: 0x4}, + 245: {cur: 0x110, idx: 0x4}, + 246: {cur: 0x8f, idx: 0x4}, + 247: {cur: 0x110, idx: 0x4}, + 248: {cur: 0x94, idx: 0x4}, + 249: {cur: 0x125, idx: 0xe9}, + 250: {cur: 0xa3, idx: 0x87}, + 251: {cur: 0xaa, idx: 0x35f}, + 252: {cur: 0x110, idx: 0x4}, + 253: {cur: 0x63, idx: 0x237}, + 254: {cur: 0xae, idx: 0x7e}, + 255: {cur: 0xb1, idx: 0x364}, + 256: {cur: 0xb5, idx: 0x94}, + 257: {cur: 0xb9, idx: 0x4}, + 258: {cur: 0x13, idx: 0x4}, + 259: {cur: 0xba, idx: 0x97}, + 260: {cur: 0x13, idx: 0x4}, + 261: {cur: 0xc0, idx: 0x4}, + 262: {cur: 0xc0, idx: 0x4}, + 263: {cur: 0xc6, idx: 0x8a}, + 264: {cur: 0xc7, idx: 0xa2}, + 265: {cur: 0xc8, idx: 0x7e}, + 266: {cur: 0xc0, idx: 0x4}, + 267: {cur: 0xd4, idx: 0xb6}, + 268: {cur: 0xd6, idx: 0x4}, + 269: {cur: 0xd7, idx: 0x367}, + 270: {cur: 0xdb, idx: 0x30}, + 271: {cur: 0xdc, idx: 0x4}, + 272: {cur: 0x63, idx: 0x237}, + 273: {cur: 0xdd, idx: 0x3f}, + 274: {cur: 0xe0, idx: 0x36a}, + 275: {cur: 0x63, idx: 0x237}, + 276: {cur: 0xe4, idx: 0x3f}, + 277: {cur: 0x8, idx: 0x36d}, + 278: {cur: 0xea, idx: 0x372}, + 279: {cur: 0xc0, idx: 0x4}, + 280: {cur: 0xf1, idx: 0xc0}, + 281: {cur: 0xf5, idx: 0x4}, + 282: {cur: 0x13, idx: 0x4}, + 283: {cur: 0xf7, idx: 0x23c}, + 284: {cur: 0xfb, idx: 0x2f4}, + 285: {cur: 0x110, idx: 0x4}, + 286: {cur: 0x107, idx: 0x374}, + 287: {cur: 0x108, idx: 0x377}, + 288: {cur: 0x125, idx: 0xe9}, + 289: {cur: 0x127, idx: 0x8a}, + 290: {cur: 0x13, idx: 0x0}, + 291: {cur: 0x2e, idx: 0x0}, + 292: {cur: 0x44, idx: 0x0}, + 293: {cur: 0x5c, idx: 0x37}, + 294: {cur: 0x63, idx: 0x0}, + 295: {cur: 0x72, idx: 0x0}, + 296: {cur: 0x7c, idx: 0x0}, + 297: {cur: 0x7d, idx: 0x0}, + 298: {cur: 0x85, idx: 0x0}, + 299: {cur: 0x8d, idx: 0x0}, + 300: {cur: 0xb2, idx: 0x0}, + 301: {cur: 0xc0, idx: 0x0}, + 302: {cur: 0xeb, idx: 0xbc}, + 303: {cur: 0xf6, idx: 0x0}, + 304: {cur: 0x109, idx: 0x0}, + 305: {cur: 0x110, idx: 0x0}, + 306: {cur: 0x115, idx: 0x0}, + 307: {cur: 0x3a, idx: 0x0}, + 308: {cur: 0x5e, idx: 0x0}, + 309: {cur: 0xeb, idx: 0x0}, + 310: {cur: 0xfc, idx: 0x0}, + 311: {cur: 0x105, idx: 0x0}, + 312: {cur: 0x11, idx: 0x4}, + 313: {cur: 0xfc, idx: 0xcf}, + 314: {cur: 0x27, idx: 0x10}, + 315: {cur: 0x2e, idx: 0x13}, + 316: {cur: 0x39, idx: 0x4}, + 317: {cur: 0x41, idx: 0x4}, + 318: {cur: 0xfc, idx: 0xcf}, + 319: {cur: 0x45, idx: 0x4}, + 320: {cur: 0xfc, idx: 0xcf}, + 321: {cur: 0x47, idx: 0x28}, + 322: {cur: 0x4b, idx: 0x4}, + 323: {cur: 0xfc, idx: 0xcf}, + 324: {cur: 0x53, idx: 0x264}, + 325: {cur: 0xfc, idx: 0xcf}, + 326: {cur: 0xfc, idx: 0x4}, + 327: {cur: 0x109, idx: 0xd7}, + 328: {cur: 0x6e, idx: 0x49}, + 329: {cur: 0x73, idx: 0x4f}, + 330: {cur: 0xb2, idx: 0x4}, + 331: {cur: 0xbc, idx: 0x9b}, + 332: {cur: 0xc2, idx: 0x387}, + 333: {cur: 0xc4, idx: 0x38b}, + 334: {cur: 0xc7, idx: 0xa2}, + 335: {cur: 0xfc, idx: 0x4}, + 336: {cur: 0xcc, idx: 0x38e}, + 337: {cur: 0xfc, idx: 0x4}, + 338: {cur: 0x85, idx: 0x25}, + 339: {cur: 0xfc, idx: 0x4}, + 340: {cur: 0xfc, idx: 0xcf}, + 341: {cur: 0x101, idx: 0x4}, + 342: {cur: 0x104, idx: 0x392}, + 343: {cur: 0x13, idx: 0xf8}, + 344: {cur: 0x57, idx: 0x30}, + 345: {cur: 0x85, idx: 0x25}, + 346: {cur: 0xeb, idx: 0xbc}, + 347: {cur: 0xfc, idx: 0x4}, + 348: {cur: 0x5c, idx: 0x37}, + 349: {cur: 0xeb, idx: 0xbc}, + 350: {cur: 0x4, idx: 0x396}, + 351: {cur: 0x3a, idx: 0x2a4}, + 352: {cur: 0x44, idx: 0x399}, + 353: {cur: 0x72, idx: 0x39e}, + 354: {cur: 0x7f, idx: 0x3a2}, + 355: {cur: 0x85, idx: 0x25}, + 356: {cur: 0xb2, idx: 0x3ab}, + 357: {cur: 0xc0, idx: 0x3af}, + 358: {cur: 0xeb, idx: 0xbc}, + 359: {cur: 0xfc, idx: 0x4}, + 360: {cur: 0x110, idx: 0x3b3}, + 361: {cur: 0x6a, idx: 0x46}, + 362: {cur: 0xab, idx: 0x3b7}, + 363: {cur: 0x13, idx: 0x0}, + 364: {cur: 0x2e, idx: 0x0}, + 365: {cur: 0x3a, idx: 0x0}, + 366: {cur: 0x44, idx: 0x0}, + 367: {cur: 0x5f, idx: 0x3ba}, + 368: {cur: 0x72, idx: 0x0}, + 369: {cur: 0x7c, idx: 0x0}, + 370: {cur: 0x7d, idx: 0x0}, + 371: {cur: 0x85, idx: 0x25}, + 372: {cur: 0x8d, idx: 0x0}, + 373: {cur: 0xb2, idx: 0x0}, + 374: {cur: 0xc0, idx: 0x0}, + 375: {cur: 0xf6, idx: 0x0}, + 376: {cur: 0xfc, idx: 0x4}, + 377: {cur: 0x105, idx: 0x0}, + 378: {cur: 0x110, idx: 0x0}, + 379: {cur: 0x117, idx: 0x0}, + 380: {cur: 0x85, idx: 0x25}, + 381: {cur: 0xc7, idx: 0xa2}, + 382: {cur: 0xeb, idx: 0xbc}, + 383: {cur: 0xfc, idx: 0x4}, + 384: {cur: 0x52, idx: 0x30}, + 385: {cur: 0x52, idx: 0x304}, + 386: {cur: 0x11, idx: 0x3bd}, + 387: {cur: 0x13, idx: 0x3c1}, + 388: {cur: 0x1d, idx: 0x3c5}, + 389: {cur: 0x25, idx: 0x3c8}, + 390: {cur: 0x26, idx: 0x3cc}, + 391: {cur: 0x32, idx: 0x3d0}, + 392: {cur: 0x39, idx: 0x3d4}, + 393: {cur: 0x3a, idx: 0x2a4}, + 394: {cur: 0x41, idx: 0x3d8}, + 395: {cur: 0x44, idx: 0x0}, + 396: {cur: 0x45, idx: 0x3dc}, + 397: {cur: 0x4d, idx: 0x3e0}, + 398: {cur: 0x60, idx: 0x3e9}, + 399: {cur: 0x61, idx: 0x3ed}, + 400: {cur: 0x62, idx: 0x2eb}, + 401: {cur: 0x63, idx: 0x3f2}, + 402: {cur: 0x68, idx: 0x3f7}, + 403: {cur: 0x72, idx: 0x0}, + 404: {cur: 0x79, idx: 0x3fc}, + 405: {cur: 0x7a, idx: 0x401}, + 406: {cur: 0x82, idx: 0x406}, + 407: {cur: 0x85, idx: 0x0}, + 408: {cur: 0x92, idx: 0x40c}, + 409: {cur: 0xad, idx: 0x411}, + 410: {cur: 0xb2, idx: 0x3ab}, + 411: {cur: 0xb9, idx: 0x416}, + 412: {cur: 0xc0, idx: 0x3af}, + 413: {cur: 0xce, idx: 0x41d}, + 414: {cur: 0xd6, idx: 0x424}, + 415: {cur: 0xdc, idx: 0x428}, + 416: {cur: 0xe2, idx: 0x42c}, + 417: {cur: 0xf5, idx: 0x430}, + 418: {cur: 0xf6, idx: 0x0}, + 419: {cur: 0xfc, idx: 0x434}, + 420: {cur: 0x101, idx: 0x438}, + 421: {cur: 0x108, idx: 0x377}, + 422: {cur: 0x110, idx: 0x0}, + 423: {cur: 0x117, idx: 0x43c}, + 424: {cur: 0x24, idx: 0x359}, + 425: {cur: 0x11, idx: 0x0}, + 426: {cur: 0x13, idx: 0x444}, + 427: {cur: 0x25, idx: 0x0}, + 428: {cur: 0x26, idx: 0x0}, + 429: {cur: 0x32, idx: 0x0}, + 430: {cur: 0x39, idx: 0x0}, + 431: {cur: 0x3a, idx: 0x4}, + 432: {cur: 0x41, idx: 0x0}, + 433: {cur: 0x44, idx: 0x20}, + 434: {cur: 0x45, idx: 0x0}, + 435: {cur: 0x60, idx: 0x0}, + 436: {cur: 0x61, idx: 0x0}, + 437: {cur: 0x63, idx: 0x3f}, + 438: {cur: 0x68, idx: 0x0}, + 439: {cur: 0x72, idx: 0x44a}, + 440: {cur: 0x7c, idx: 0x0}, + 441: {cur: 0x7d, idx: 0x0}, + 442: {cur: 0x85, idx: 0x25}, + 443: {cur: 0x8d, idx: 0x0}, + 444: {cur: 0x92, idx: 0x0}, + 445: {cur: 0xb2, idx: 0x0}, + 446: {cur: 0xb9, idx: 0x0}, + 447: {cur: 0xc0, idx: 0x450}, + 448: {cur: 0xd6, idx: 0x0}, + 449: {cur: 0xdc, idx: 0x456}, + 450: {cur: 0xe2, idx: 0x0}, + 451: {cur: 0xf5, idx: 0x0}, + 452: {cur: 0xfc, idx: 0x45c}, + 453: {cur: 0x101, idx: 0x0}, + 454: {cur: 0x105, idx: 0x0}, + 455: {cur: 0x109, idx: 0x0}, + 456: {cur: 0x115, idx: 0x0}, + 457: {cur: 0x117, idx: 0x0}, + 458: {cur: 0x3b, idx: 0x32a}, + 459: {cur: 0x51, idx: 0x22d}, + 460: {cur: 0x54, idx: 0x462}, + 461: {cur: 0x6a, idx: 0x46}, + 462: {cur: 0x76, idx: 0x465}, + 463: {cur: 0x89, idx: 0x6b}, + 464: {cur: 0x62, idx: 0x0}, + 465: {cur: 0x99, idx: 0x2eb}, + 466: {cur: 0xa3, idx: 0x87}, + 467: {cur: 0xab, idx: 0x3b7}, + 468: {cur: 0xae, idx: 0x7e}, + 469: {cur: 0xd4, idx: 0xb6}, + 470: {cur: 0xd7, idx: 0x367}, + 471: {cur: 0xe9, idx: 0x467}, + 472: {cur: 0xf0, idx: 0x46a}, + 473: {cur: 0x107, idx: 0x374}, + 474: {cur: 0x13, idx: 0xf8}, + 475: {cur: 0x3a, idx: 0x9b}, + 476: {cur: 0x60, idx: 0x16e}, + 477: {cur: 0xd6, idx: 0x28a}, + 478: {cur: 0xeb, idx: 0xbc}, + 479: {cur: 0x117, idx: 0x0}, + 480: {cur: 0x85, idx: 0x25}, + 481: {cur: 0xeb, idx: 0xbc}, + 482: {cur: 0xfc, idx: 0x4}, + 483: {cur: 0xeb, idx: 0xbc}, + 484: {cur: 0xfc, idx: 0x4}, + 485: {cur: 0x5c, idx: 0x37}, + 486: {cur: 0xb2, idx: 0x3ab}, + 487: {cur: 0xeb, idx: 0xbc}, + 488: {cur: 0xfc, idx: 0x4}, + 489: {cur: 0x12, idx: 0x30c}, + 490: {cur: 0x85, idx: 0x25}, + 491: {cur: 0xfc, idx: 0x4}, + 492: {cur: 0xeb, idx: 0xbc}, + 493: {cur: 0x86, idx: 0x308}, + 494: {cur: 0xba, idx: 0x97}, + 495: {cur: 0x67, idx: 0xf2}, + 496: {cur: 0xfc, idx: 0x4}, + 497: {cur: 0x44, idx: 0x47c}, + 498: {cur: 0x7a, idx: 0x487}, + 499: {cur: 0x85, idx: 0x25}, + 500: {cur: 0xeb, idx: 0xbc}, + 501: {cur: 0xfc, idx: 0x4}, + 502: {cur: 0xeb, idx: 0xbc}, + 503: {cur: 0xfc, idx: 0x4}, + 504: {cur: 0x13, idx: 0x0}, + 505: {cur: 0x2e, idx: 0x0}, + 506: {cur: 0x3a, idx: 0x0}, + 507: {cur: 0x44, idx: 0x0}, + 508: {cur: 0x5e, idx: 0x0}, + 509: {cur: 0x63, idx: 0x0}, + 510: {cur: 0x72, idx: 0x0}, + 511: {cur: 0x7c, idx: 0x0}, + 512: {cur: 0x7d, idx: 0x0}, + 513: {cur: 0x85, idx: 0x0}, + 514: {cur: 0x8d, idx: 0x0}, + 515: {cur: 0xb2, idx: 0x0}, + 516: {cur: 0xc0, idx: 0x0}, + 517: {cur: 0xf6, idx: 0x0}, + 518: {cur: 0xfc, idx: 0x0}, + 519: {cur: 0x105, idx: 0x0}, + 520: {cur: 0x110, idx: 0x0}, + 521: {cur: 0x117, idx: 0x0}, + 522: {cur: 0x18, idx: 0x9}, + 523: {cur: 0x13, idx: 0x0}, + 524: {cur: 0x85, idx: 0x25}, + 525: {cur: 0xc9, idx: 0xa6}, + 526: {cur: 0xeb, idx: 0xbc}, + 527: {cur: 0xfc, idx: 0x4}, + 528: {cur: 0x13, idx: 0x0}, + 529: {cur: 0x2e, idx: 0x0}, + 530: {cur: 0x3a, idx: 0x0}, + 531: {cur: 0x44, idx: 0x0}, + 532: {cur: 0x5e, idx: 0x0}, + 533: {cur: 0x63, idx: 0x0}, + 534: {cur: 0x72, idx: 0x0}, + 535: {cur: 0x77, idx: 0x54}, + 536: {cur: 0x7c, idx: 0x0}, + 537: {cur: 0x7d, idx: 0x0}, + 538: {cur: 0x85, idx: 0x25}, + 539: {cur: 0x8d, idx: 0x0}, + 540: {cur: 0xb2, idx: 0x0}, + 541: {cur: 0xc0, idx: 0x0}, + 542: {cur: 0xf6, idx: 0x0}, + 543: {cur: 0xfc, idx: 0x0}, + 544: {cur: 0x105, idx: 0x0}, + 545: {cur: 0x110, idx: 0x0}, + 546: {cur: 0x7, idx: 0x498}, + 547: {cur: 0xeb, idx: 0xbc}, + 548: {cur: 0xfc, idx: 0x4}, + 549: {cur: 0x13, idx: 0xf8}, + 550: {cur: 0x78, idx: 0x57}, + 551: {cur: 0x7d, idx: 0x7e}, + 552: {cur: 0xeb, idx: 0xbc}, + 553: {cur: 0xba, idx: 0x97}, + 554: {cur: 0x44, idx: 0x25}, + 555: {cur: 0x13, idx: 0x0}, + 556: {cur: 0x2e, idx: 0x0}, + 557: {cur: 0x3a, idx: 0x0}, + 558: {cur: 0x5e, idx: 0x0}, + 559: {cur: 0x63, idx: 0x0}, + 560: {cur: 0x7d, idx: 0x0}, + 561: {cur: 0x8d, idx: 0x0}, + 562: {cur: 0xb2, idx: 0x0}, + 563: {cur: 0xc0, idx: 0x0}, + 564: {cur: 0xf6, idx: 0x0}, + 565: {cur: 0xfc, idx: 0x0}, + 566: {cur: 0x105, idx: 0x0}, + 567: {cur: 0x2e, idx: 0x0}, + 568: {cur: 0x72, idx: 0x0}, + 569: {cur: 0x85, idx: 0x0}, + 570: {cur: 0x8d, idx: 0x0}, + 571: {cur: 0xb2, idx: 0x0}, + 572: {cur: 0xeb, idx: 0xbc}, + 573: {cur: 0xf6, idx: 0x0}, + 574: {cur: 0xfc, idx: 0x0}, + 575: {cur: 0x44, idx: 0x49f}, + 576: {cur: 0x85, idx: 0x4a3}, + 577: {cur: 0xfc, idx: 0x4}, + 578: {cur: 0xf7, idx: 0x23c}, + 579: {cur: 0x13, idx: 0x0}, + 580: {cur: 0x44, idx: 0x0}, + 581: {cur: 0x65, idx: 0x42}, + 582: {cur: 0x72, idx: 0x0}, + 583: {cur: 0x7c, idx: 0x0}, + 584: {cur: 0x7d, idx: 0x0}, + 585: {cur: 0x85, idx: 0x0}, + 586: {cur: 0x8d, idx: 0x0}, + 587: {cur: 0xc0, idx: 0x0}, + 588: {cur: 0x105, idx: 0x0}, + 589: {cur: 0x54, idx: 0x462}, + 590: {cur: 0x86, idx: 0x308}, + 591: {cur: 0xf7, idx: 0x23c}, + 592: {cur: 0x13, idx: 0xf8}, + 593: {cur: 0x4c, idx: 0x4ae}, + 594: {cur: 0xeb, idx: 0xbc}, + 595: {cur: 0x86, idx: 0x308}, + 596: {cur: 0x90, idx: 0x72}, + 597: {cur: 0xd2, idx: 0xb2}, + 598: {cur: 0xeb, idx: 0xbc}, + 599: {cur: 0xfc, idx: 0x4}, + 600: {cur: 0x52, idx: 0x304}, + 601: {cur: 0x86, idx: 0x308}, + 602: {cur: 0x88, idx: 0x67}, + 603: {cur: 0xeb, idx: 0xbc}, + 604: {cur: 0xfc, idx: 0x4}, + 605: {cur: 0xeb, idx: 0xbc}, + 606: {cur: 0xfc, idx: 0x4}, + 607: {cur: 0x13, idx: 0xf8}, + 608: {cur: 0xf7, idx: 0x23c}, + 609: {cur: 0x13, idx: 0x0}, + 610: {cur: 0x2e, idx: 0x0}, + 611: {cur: 0x3a, idx: 0x0}, + 612: {cur: 0x63, idx: 0x0}, + 613: {cur: 0x72, idx: 0x0}, + 614: {cur: 0x7c, idx: 0x0}, + 615: {cur: 0x7d, idx: 0x0}, + 616: {cur: 0x87, idx: 0x4bf}, + 617: {cur: 0x8d, idx: 0x0}, + 618: {cur: 0xb2, idx: 0x0}, + 619: {cur: 0xc0, idx: 0x0}, + 620: {cur: 0xeb, idx: 0xbc}, + 621: {cur: 0xf6, idx: 0x0}, + 622: {cur: 0xfc, idx: 0x0}, + 623: {cur: 0x110, idx: 0x0}, + 624: {cur: 0xf7, idx: 0x23c}, + 625: {cur: 0x12, idx: 0x30c}, + 626: {cur: 0x13, idx: 0xf8}, + 627: {cur: 0x85, idx: 0x25}, + 628: {cur: 0xeb, idx: 0xbc}, + 629: {cur: 0xfc, idx: 0x4}, + 630: {cur: 0xfb, idx: 0x2f4}, + 631: {cur: 0xfc, idx: 0x4}, + 632: {cur: 0x3b, idx: 0x32a}, + 633: {cur: 0x9, idx: 0x1}, + 634: {cur: 0x91, idx: 0x76}, + 635: {cur: 0xeb, idx: 0xbc}, + 636: {cur: 0x7e, idx: 0x17b}, + 637: {cur: 0x13, idx: 0x0}, + 638: {cur: 0x2e, idx: 0x0}, + 639: {cur: 0x3a, idx: 0x0}, + 640: {cur: 0x44, idx: 0x0}, + 641: {cur: 0x63, idx: 0x0}, + 642: {cur: 0x72, idx: 0x0}, + 643: {cur: 0x7c, idx: 0x0}, + 644: {cur: 0x7d, idx: 0x0}, + 645: {cur: 0x85, idx: 0x0}, + 646: {cur: 0x8d, idx: 0x0}, + 647: {cur: 0xb2, idx: 0x0}, + 648: {cur: 0xc0, idx: 0x0}, + 649: {cur: 0xf6, idx: 0x0}, + 650: {cur: 0xfc, idx: 0x0}, + 651: {cur: 0x105, idx: 0x0}, + 652: {cur: 0x109, idx: 0x0}, + 653: {cur: 0x110, idx: 0x0}, + 654: {cur: 0x115, idx: 0x0}, + 655: {cur: 0x117, idx: 0x0}, + 656: {cur: 0x3b, idx: 0x32a}, + 657: {cur: 0x86, idx: 0x308}, + 658: {cur: 0x86, idx: 0x308}, + 659: {cur: 0x13, idx: 0xf8}, + 660: {cur: 0x85, idx: 0x25}, + 661: {cur: 0x9b, idx: 0x84}, + 662: {cur: 0xeb, idx: 0xbc}, + 663: {cur: 0xfc, idx: 0x4}, + 664: {cur: 0x86, idx: 0x308}, + 665: {cur: 0xf7, idx: 0x23c}, + 666: {cur: 0x86, idx: 0x308}, + 667: {cur: 0xae, idx: 0x7e}, + 668: {cur: 0xa3, idx: 0x87}, + 669: {cur: 0xb8, idx: 0x4cc}, + 670: {cur: 0x13, idx: 0x0}, + 671: {cur: 0x44, idx: 0x0}, + 672: {cur: 0x63, idx: 0x0}, + 673: {cur: 0x72, idx: 0x0}, + 674: {cur: 0x7c, idx: 0x0}, + 675: {cur: 0x7d, idx: 0x0}, + 676: {cur: 0x85, idx: 0x0}, + 677: {cur: 0x8d, idx: 0x0}, + 678: {cur: 0xa5, idx: 0x4d0}, + 679: {cur: 0xc0, idx: 0x0}, + 680: {cur: 0xf6, idx: 0x0}, + 681: {cur: 0x105, idx: 0x0}, + 682: {cur: 0x85, idx: 0x25}, + 683: {cur: 0xeb, idx: 0xbc}, + 684: {cur: 0xfc, idx: 0x4}, + 685: {cur: 0xa9, idx: 0x8c}, + 686: {cur: 0xeb, idx: 0xbc}, + 687: {cur: 0xfc, idx: 0x4}, + 688: {cur: 0xeb, idx: 0xbc}, + 689: {cur: 0xfc, idx: 0x4}, + 690: {cur: 0x3a, idx: 0x0}, + 691: {cur: 0xb2, idx: 0x0}, + 692: {cur: 0xb5, idx: 0x94}, + 693: {cur: 0xfc, idx: 0x0}, + 694: {cur: 0x26, idx: 0x4}, + 695: {cur: 0xdc, idx: 0x4}, + 696: {cur: 0x8, idx: 0x4dc}, + 697: {cur: 0x14, idx: 0x4e0}, + 698: {cur: 0x76, idx: 0x465}, + 699: {cur: 0xa8, idx: 0x8a}, + 700: {cur: 0xc2, idx: 0x387}, + 701: {cur: 0xeb, idx: 0xbc}, + 702: {cur: 0xf5, idx: 0x21b}, + 703: {cur: 0xfc, idx: 0x4}, + 704: {cur: 0xb9, idx: 0x4}, + 705: {cur: 0x13, idx: 0x0}, + 706: {cur: 0x2e, idx: 0x0}, + 707: {cur: 0x3a, idx: 0x0}, + 708: {cur: 0x44, idx: 0x0}, + 709: {cur: 0x72, idx: 0x0}, + 710: {cur: 0x7c, idx: 0x0}, + 711: {cur: 0x7d, idx: 0x0}, + 712: {cur: 0x85, idx: 0x0}, + 713: {cur: 0x8d, idx: 0x0}, + 714: {cur: 0xb2, idx: 0x0}, + 715: {cur: 0xbe, idx: 0x30}, + 716: {cur: 0xc0, idx: 0x0}, + 717: {cur: 0xf6, idx: 0x0}, + 718: {cur: 0xfc, idx: 0x0}, + 719: {cur: 0x105, idx: 0x0}, + 720: {cur: 0x109, idx: 0x0}, + 721: {cur: 0x110, idx: 0x0}, + 722: {cur: 0x117, idx: 0x0}, + 723: {cur: 0xbf, idx: 0x4e4}, + 724: {cur: 0xeb, idx: 0xbc}, + 725: {cur: 0x13, idx: 0xf8}, + 726: {cur: 0x3a, idx: 0x9b}, + 727: {cur: 0x60, idx: 0x16e}, + 728: {cur: 0xd6, idx: 0x28a}, + 729: {cur: 0xeb, idx: 0xbc}, + 730: {cur: 0x117, idx: 0x0}, + 731: {cur: 0x14, idx: 0x4f8}, + 732: {cur: 0xfc, idx: 0x4}, + 733: {cur: 0x8, idx: 0x36d}, + 734: {cur: 0xe2, idx: 0x4}, + 735: {cur: 0x8, idx: 0x36d}, + 736: {cur: 0x13, idx: 0x0}, + 737: {cur: 0x2e, idx: 0x0}, + 738: {cur: 0x3a, idx: 0x0}, + 739: {cur: 0x44, idx: 0x0}, + 740: {cur: 0x63, idx: 0x0}, + 741: {cur: 0x72, idx: 0x0}, + 742: {cur: 0x7c, idx: 0x0}, + 743: {cur: 0x7d, idx: 0x0}, + 744: {cur: 0x85, idx: 0x0}, + 745: {cur: 0x8d, idx: 0x0}, + 746: {cur: 0xb2, idx: 0x0}, + 747: {cur: 0xbe, idx: 0x30}, + 748: {cur: 0xc0, idx: 0x0}, + 749: {cur: 0xf6, idx: 0x0}, + 750: {cur: 0xfc, idx: 0x0}, + 751: {cur: 0x105, idx: 0x0}, + 752: {cur: 0x109, idx: 0x0}, + 753: {cur: 0x110, idx: 0x0}, + 754: {cur: 0x117, idx: 0x0}, + 755: {cur: 0x63, idx: 0x237}, + 756: {cur: 0xe4, idx: 0x3f}, + 757: {cur: 0xfb, idx: 0x2f4}, + 758: {cur: 0x5d, idx: 0x258}, + 759: {cur: 0x86, idx: 0x308}, + 760: {cur: 0x85, idx: 0x25}, + 761: {cur: 0xfc, idx: 0x4}, + 762: {cur: 0x65, idx: 0x42}, + 763: {cur: 0xfc, idx: 0x4}, + 764: {cur: 0x65, idx: 0x0}, + 765: {cur: 0xd2, idx: 0xb2}, + 766: {cur: 0xeb, idx: 0xbc}, + 767: {cur: 0xc8, idx: 0x4fd}, + 768: {cur: 0x13, idx: 0x0}, + 769: {cur: 0x3a, idx: 0x0}, + 770: {cur: 0x44, idx: 0x0}, + 771: {cur: 0x63, idx: 0x0}, + 772: {cur: 0x72, idx: 0x0}, + 773: {cur: 0x7c, idx: 0x0}, + 774: {cur: 0x7d, idx: 0x0}, + 775: {cur: 0x85, idx: 0x0}, + 776: {cur: 0x8d, idx: 0x0}, + 777: {cur: 0xb2, idx: 0x0}, + 778: {cur: 0xc0, idx: 0x0}, + 779: {cur: 0xc9, idx: 0xa6}, + 780: {cur: 0xf6, idx: 0x0}, + 781: {cur: 0xfc, idx: 0x0}, + 782: {cur: 0x105, idx: 0x0}, + 783: {cur: 0x4, idx: 0x396}, + 784: {cur: 0x13, idx: 0xf8}, + 785: {cur: 0xcb, idx: 0x504}, + 786: {cur: 0xeb, idx: 0xbc}, + 787: {cur: 0x9, idx: 0x1}, + 788: {cur: 0x4c, idx: 0x4ae}, + 789: {cur: 0xcb, idx: 0x509}, + 790: {cur: 0x99, idx: 0x2eb}, + 791: {cur: 0xaa, idx: 0x35f}, + 792: {cur: 0xb8, idx: 0x4cc}, + 793: {cur: 0xcb, idx: 0x4ae}, + 794: {cur: 0xe5, idx: 0xb9}, + 795: {cur: 0xc4, idx: 0x38b}, + 796: {cur: 0x27, idx: 0x10}, + 797: {cur: 0xc4, idx: 0x0}, + 798: {cur: 0xc4, idx: 0x0}, + 799: {cur: 0xfc, idx: 0x4}, + 800: {cur: 0x24, idx: 0x359}, + 801: {cur: 0x13, idx: 0x0}, + 802: {cur: 0x2e, idx: 0x0}, + 803: {cur: 0x3a, idx: 0x0}, + 804: {cur: 0x44, idx: 0x0}, + 805: {cur: 0x5e, idx: 0x0}, + 806: {cur: 0x63, idx: 0x0}, + 807: {cur: 0x72, idx: 0x0}, + 808: {cur: 0x7c, idx: 0x0}, + 809: {cur: 0x7d, idx: 0x0}, + 810: {cur: 0x85, idx: 0x0}, + 811: {cur: 0x8d, idx: 0x0}, + 812: {cur: 0xb2, idx: 0x0}, + 813: {cur: 0xc0, idx: 0x0}, + 814: {cur: 0xf6, idx: 0x0}, + 815: {cur: 0xfc, idx: 0x0}, + 816: {cur: 0x105, idx: 0x0}, + 817: {cur: 0x110, idx: 0x0}, + 818: {cur: 0xa2, idx: 0x4f}, + 819: {cur: 0xf7, idx: 0x23c}, + 820: {cur: 0x0, idx: 0x510}, + 821: {cur: 0x85, idx: 0x25}, + 822: {cur: 0xd2, idx: 0xb2}, + 823: {cur: 0xd3, idx: 0x18}, + 824: {cur: 0xeb, idx: 0xbc}, + 825: {cur: 0xef, idx: 0x519}, + 826: {cur: 0xf8, idx: 0xcb}, + 827: {cur: 0xfc, idx: 0x4}, + 828: {cur: 0x37, idx: 0x258}, + 829: {cur: 0xd3, idx: 0x0}, + 830: {cur: 0x87, idx: 0x4bf}, + 831: {cur: 0x90, idx: 0x72}, + 832: {cur: 0xa2, idx: 0x4f}, + 833: {cur: 0xd4, idx: 0xb6}, + 834: {cur: 0xf7, idx: 0x23c}, + 835: {cur: 0xd2, idx: 0xb2}, + 836: {cur: 0x86, idx: 0x308}, + 837: {cur: 0xf7, idx: 0x23c}, + 838: {cur: 0xc8, idx: 0x7e}, + 839: {cur: 0x52, idx: 0x520}, + 840: {cur: 0xbe, idx: 0x30}, + 841: {cur: 0xdb, idx: 0x524}, + 842: {cur: 0xeb, idx: 0xbc}, + 843: {cur: 0xbe, idx: 0x528}, + 844: {cur: 0xdb, idx: 0x30}, + 845: {cur: 0xb8, idx: 0x4cc}, + 846: {cur: 0x93, idx: 0x52c}, + 847: {cur: 0xeb, idx: 0xbc}, + 848: {cur: 0x115, idx: 0x534}, + 849: {cur: 0x13, idx: 0x0}, + 850: {cur: 0x2e, idx: 0x0}, + 851: {cur: 0x3a, idx: 0x0}, + 852: {cur: 0x44, idx: 0x0}, + 853: {cur: 0x63, idx: 0x0}, + 854: {cur: 0x72, idx: 0x0}, + 855: {cur: 0x7c, idx: 0x544}, + 856: {cur: 0x7d, idx: 0x0}, + 857: {cur: 0x85, idx: 0x0}, + 858: {cur: 0x8d, idx: 0x0}, + 859: {cur: 0xc0, idx: 0x0}, + 860: {cur: 0xf6, idx: 0x0}, + 861: {cur: 0xfc, idx: 0x0}, + 862: {cur: 0x105, idx: 0x0}, + 863: {cur: 0x13, idx: 0x0}, + 864: {cur: 0x2e, idx: 0x0}, + 865: {cur: 0x3a, idx: 0x0}, + 866: {cur: 0x63, idx: 0x0}, + 867: {cur: 0x85, idx: 0x25}, + 868: {cur: 0xb2, idx: 0x0}, + 869: {cur: 0xc0, idx: 0x0}, + 870: {cur: 0xf6, idx: 0x0}, + 871: {cur: 0xfc, idx: 0x4}, + 872: {cur: 0x110, idx: 0x0}, + 873: {cur: 0xe1, idx: 0x235}, + 874: {cur: 0x51, idx: 0x22d}, + 875: {cur: 0x5d, idx: 0x258}, + 876: {cur: 0x86, idx: 0x308}, + 877: {cur: 0x6, idx: 0x548}, + 878: {cur: 0xeb, idx: 0xbc}, + 879: {cur: 0xa5, idx: 0x54e}, + 880: {cur: 0x13, idx: 0x0}, + 881: {cur: 0x18, idx: 0x2cf}, + 882: {cur: 0x85, idx: 0x25}, + 883: {cur: 0x8d, idx: 0x0}, + 884: {cur: 0xc0, idx: 0x0}, + 885: {cur: 0x105, idx: 0x0}, + 886: {cur: 0x13, idx: 0x0}, + 887: {cur: 0x18, idx: 0x9}, + 888: {cur: 0x85, idx: 0x25}, + 889: {cur: 0x8d, idx: 0x0}, + 890: {cur: 0xc0, idx: 0x0}, + 891: {cur: 0x105, idx: 0x0}, + 892: {cur: 0x13, idx: 0x0}, + 893: {cur: 0x1a, idx: 0x24c}, + 894: {cur: 0x25, idx: 0x13a}, + 895: {cur: 0x2e, idx: 0x555}, + 896: {cur: 0x32, idx: 0x142}, + 897: {cur: 0x39, idx: 0x146}, + 898: {cur: 0x44, idx: 0x0}, + 899: {cur: 0x52, idx: 0x520}, + 900: {cur: 0x53, idx: 0x264}, + 901: {cur: 0x57, idx: 0x559}, + 902: {cur: 0x58, idx: 0x55d}, + 903: {cur: 0x63, idx: 0x0}, + 904: {cur: 0x72, idx: 0x0}, + 905: {cur: 0x79, idx: 0x562}, + 906: {cur: 0x7d, idx: 0x0}, + 907: {cur: 0x81, idx: 0x567}, + 908: {cur: 0x83, idx: 0x18c}, + 909: {cur: 0x85, idx: 0x0}, + 910: {cur: 0x8d, idx: 0x0}, + 911: {cur: 0xbe, idx: 0x528}, + 912: {cur: 0xc0, idx: 0x0}, + 913: {cur: 0xdb, idx: 0x30}, + 914: {cur: 0xf6, idx: 0x0}, + 915: {cur: 0x105, idx: 0x0}, + 916: {cur: 0x86, idx: 0x308}, + 917: {cur: 0xeb, idx: 0xbc}, + 918: {cur: 0xf7, idx: 0x23c}, + 919: {cur: 0x3b, idx: 0x32a}, + 920: {cur: 0xfb, idx: 0x2f4}, + 921: {cur: 0x85, idx: 0x25}, + 922: {cur: 0xeb, idx: 0xbc}, + 923: {cur: 0xfc, idx: 0x4}, + 924: {cur: 0x93, idx: 0x56b}, + 925: {cur: 0xb5, idx: 0x94}, + 926: {cur: 0xdc, idx: 0x28e}, + 927: {cur: 0xb5, idx: 0x94}, + 928: {cur: 0xdc, idx: 0x4}, + 929: {cur: 0xfc, idx: 0xcf}, + 930: {cur: 0xeb, idx: 0xbc}, + 931: {cur: 0xfc, idx: 0x4}, + 932: {cur: 0xfb, idx: 0x2f4}, + 933: {cur: 0x86, idx: 0x308}, + 934: {cur: 0xed, idx: 0x56f}, + 935: {cur: 0xfc, idx: 0x4}, + 936: {cur: 0x13, idx: 0xf8}, + 937: {cur: 0x85, idx: 0x25}, + 938: {cur: 0x5d, idx: 0x258}, + 939: {cur: 0x59, idx: 0x231}, + 940: {cur: 0x5e, idx: 0x0}, + 941: {cur: 0x63, idx: 0x0}, + 942: {cur: 0x13, idx: 0x577}, + 943: {cur: 0xc0, idx: 0x57c}, + 944: {cur: 0xf1, idx: 0xc0}, + 945: {cur: 0x13, idx: 0xf8}, + 946: {cur: 0x85, idx: 0x25}, + 947: {cur: 0xeb, idx: 0xbc}, + 948: {cur: 0xf4, idx: 0xc3}, + 949: {cur: 0xfc, idx: 0x4}, + 950: {cur: 0xd2, idx: 0xb2}, + 951: {cur: 0xfc, idx: 0x4}, + 952: {cur: 0x44, idx: 0x4a3}, + 953: {cur: 0xfc, idx: 0x4}, + 954: {cur: 0x13, idx: 0x0}, + 955: {cur: 0x2e, idx: 0x0}, + 956: {cur: 0x3a, idx: 0x0}, + 957: {cur: 0x44, idx: 0x0}, + 958: {cur: 0x5e, idx: 0x0}, + 959: {cur: 0x63, idx: 0x0}, + 960: {cur: 0x72, idx: 0x0}, + 961: {cur: 0x7c, idx: 0x0}, + 962: {cur: 0x7d, idx: 0x0}, + 963: {cur: 0x85, idx: 0x25}, + 964: {cur: 0x8d, idx: 0x0}, + 965: {cur: 0xb2, idx: 0x0}, + 966: {cur: 0xc0, idx: 0x0}, + 967: {cur: 0xf6, idx: 0x0}, + 968: {cur: 0xf8, idx: 0xcb}, + 969: {cur: 0xf9, idx: 0x581}, + 970: {cur: 0xfc, idx: 0x0}, + 971: {cur: 0x105, idx: 0x0}, + 972: {cur: 0x110, idx: 0x0}, + 973: {cur: 0xc8, idx: 0x7e}, + 974: {cur: 0xeb, idx: 0xbc}, + 975: {cur: 0xfc, idx: 0x4}, + 976: {cur: 0xc8, idx: 0x0}, + 977: {cur: 0x102, idx: 0x589}, + 978: {cur: 0x4, idx: 0x396}, + 979: {cur: 0xeb, idx: 0xbc}, + 980: {cur: 0x102, idx: 0x58f}, + 981: {cur: 0x94, idx: 0x4}, + 982: {cur: 0x94, idx: 0x4}, + 983: {cur: 0x13, idx: 0xf8}, + 984: {cur: 0xeb, idx: 0xbc}, + 985: {cur: 0xf7, idx: 0x23c}, + 986: {cur: 0x85, idx: 0x25}, + 987: {cur: 0xfc, idx: 0x4}, + 988: {cur: 0xfc, idx: 0x4}, + 989: {cur: 0xfb, idx: 0x2f4}, + 990: {cur: 0xba, idx: 0x97}, + 991: {cur: 0x13, idx: 0xf8}, + 992: {cur: 0x85, idx: 0x25}, + 993: {cur: 0x8d, idx: 0x596}, + 994: {cur: 0x13, idx: 0xf8}, + 995: {cur: 0x44, idx: 0x4a3}, + 996: {cur: 0x8d, idx: 0x596}, + 997: {cur: 0x13, idx: 0xf8}, + 998: {cur: 0x44, idx: 0x4a3}, + 999: {cur: 0x7b, idx: 0x59a}, + 1000: {cur: 0x8d, idx: 0x596}, + 1001: {cur: 0x44, idx: 0x20}, + 1002: {cur: 0x44, idx: 0x20}, + 1003: {cur: 0xaa, idx: 0x35f}, + 1004: {cur: 0x44, idx: 0x20}, + 1005: {cur: 0xdc, idx: 0x4}, + 1006: {cur: 0x13, idx: 0xf8}, + 1007: {cur: 0x85, idx: 0x25}, + 1008: {cur: 0x8d, idx: 0x596}, + 1009: {cur: 0xf6, idx: 0x4}, + 1010: {cur: 0x8d, idx: 0x6e}, + 1011: {cur: 0xf6, idx: 0xc7}, + 1012: {cur: 0xaa, idx: 0x35f}, + 1013: {cur: 0xeb, idx: 0xbc}, + 1014: {cur: 0x125, idx: 0xe9}, +} // Size: 4084 bytes + +var narrowLangIndex = []uint16{ // 776 elements + // Entry 0 - 3F + 0x0000, 0x0062, 0x0064, 0x0064, 0x0064, 0x0064, 0x0064, 0x0064, + 0x0064, 0x0065, 0x0065, 0x0081, 0x0081, 0x0082, 0x0082, 0x0082, + 0x0082, 0x0082, 0x0082, 0x0082, 0x0082, 0x0082, 0x0082, 0x0082, + 0x0082, 0x0082, 0x0082, 0x0082, 0x0082, 0x0082, 0x0082, 0x0082, + 0x0082, 0x0082, 0x0082, 0x0082, 0x0082, 0x0082, 0x0082, 0x0082, + 0x0082, 0x0082, 0x0082, 0x0082, 0x0082, 0x008b, 0x008b, 0x008e, + 0x008e, 0x008e, 0x008e, 0x008e, 0x008e, 0x008e, 0x00a8, 0x00a8, + 0x00a8, 0x00a8, 0x00a8, 0x00a8, 0x00d8, 0x00d8, 0x00d8, 0x00d8, + // Entry 40 - 7F + 0x00d8, 0x00d9, 0x00d9, 0x00d9, 0x00d9, 0x00d9, 0x00d9, 0x00dc, + 0x00dc, 0x00dc, 0x00dc, 0x00dd, 0x00dd, 0x00dd, 0x00dd, 0x00dd, + 0x00de, 0x00de, 0x00de, 0x00de, 0x00de, 0x00df, 0x00df, 0x00df, + 0x00e0, 0x00e0, 0x00e0, 0x00e0, 0x00e0, 0x00e0, 0x00e0, 0x00e0, + 0x00e0, 0x00e2, 0x00e2, 0x00e2, 0x00e2, 0x00e8, 0x00e8, 0x00ee, + 0x00ee, 0x00ee, 0x00ee, 0x00ee, 0x00f7, 0x00f7, 0x00f7, 0x00f8, + 0x00f8, 0x00f8, 0x00f8, 0x00f8, 0x00f8, 0x00f8, 0x00f8, 0x00f8, + 0x00f8, 0x00f8, 0x00f8, 0x00f8, 0x00f8, 0x00f8, 0x00f8, 0x00f8, + // Entry 80 - BF + 0x00f8, 0x00f8, 0x00f8, 0x00f8, 0x00f8, 0x00f8, 0x00f8, 0x00f8, + 0x00f8, 0x00f8, 0x00f8, 0x00f8, 0x00f8, 0x00f8, 0x0100, 0x0100, + 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, + 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, + 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, + 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, + 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, + 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, + // Entry C0 - FF + 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, + 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, + 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, + 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, + 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, + 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, + 0x0100, 0x0100, 0x0103, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, + 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, + // Entry 100 - 13F + 0x0108, 0x0108, 0x0108, 0x0108, 0x010d, 0x010d, 0x010d, 0x010d, + 0x010d, 0x010d, 0x010d, 0x010d, 0x0111, 0x0111, 0x0112, 0x0113, + 0x0113, 0x0114, 0x0114, 0x0114, 0x0114, 0x0114, 0x0114, 0x0114, + 0x0114, 0x0114, 0x0114, 0x0114, 0x0114, 0x0171, 0x0171, 0x0172, + 0x0172, 0x0172, 0x0172, 0x0172, 0x017a, 0x017a, 0x017a, 0x017a, + 0x017a, 0x017a, 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, + 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, + 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, + // Entry 140 - 17F + 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, + 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, + 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, 0x017f, 0x0180, + 0x0180, 0x0182, 0x0182, 0x0185, 0x0185, 0x0185, 0x0185, 0x0185, + 0x0185, 0x0187, 0x0187, 0x0187, 0x0187, 0x0187, 0x0187, 0x0187, + 0x0187, 0x0187, 0x0187, 0x0187, 0x0187, 0x0187, 0x0188, 0x0188, + 0x018a, 0x018a, 0x018b, 0x018b, 0x018b, 0x018b, 0x018b, 0x018c, + 0x018c, 0x018d, 0x018d, 0x018e, 0x018e, 0x018e, 0x018e, 0x018e, + // Entry 180 - 1BF + 0x018e, 0x018e, 0x018e, 0x018f, 0x018f, 0x0193, 0x0193, 0x0193, + 0x0193, 0x0193, 0x0193, 0x0193, 0x0196, 0x0196, 0x0196, 0x0196, + 0x0196, 0x0196, 0x0196, 0x0196, 0x0196, 0x0196, 0x0197, 0x0197, + 0x0197, 0x0197, 0x0197, 0x0197, 0x0197, 0x0197, 0x0197, 0x0197, + 0x0197, 0x0197, 0x0197, 0x0197, 0x0197, 0x0197, 0x0198, 0x0198, + 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0199, 0x0199, + 0x019b, 0x019b, 0x019d, 0x019d, 0x019d, 0x019d, 0x019d, 0x019d, + 0x019d, 0x019d, 0x019d, 0x019d, 0x019d, 0x019d, 0x019d, 0x019d, + // Entry 1C0 - 1FF + 0x019d, 0x019d, 0x01a8, 0x01a8, 0x01a8, 0x01a8, 0x01a9, 0x01a9, + 0x01a9, 0x01a9, 0x01a9, 0x01a9, 0x01a9, 0x01a9, 0x01a9, 0x01a9, + 0x01a9, 0x01aa, 0x01aa, 0x01aa, 0x01aa, 0x01aa, 0x01b5, 0x01b5, + 0x01b5, 0x01b5, 0x01b5, 0x01b5, 0x01b5, 0x01b5, 0x01b6, 0x01b6, + 0x01b6, 0x01b6, 0x01b6, 0x01b6, 0x01b6, 0x01b6, 0x01b6, 0x01b6, + 0x01b6, 0x01b6, 0x01b6, 0x01b6, 0x01b6, 0x01b7, 0x01b7, 0x01b8, + 0x01b8, 0x01ba, 0x01ba, 0x01ba, 0x01bb, 0x01bb, 0x01bc, 0x01bc, + 0x01bc, 0x01bc, 0x01bc, 0x01bc, 0x01bc, 0x01bc, 0x01be, 0x01be, + // Entry 200 - 23F + 0x01be, 0x01be, 0x01be, 0x01be, 0x01be, 0x01c0, 0x01c0, 0x01c0, + 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c1, 0x01c1, 0x01c1, + 0x01c2, 0x01c2, 0x01c2, 0x01c2, 0x01c2, 0x01c2, 0x01c2, 0x01c2, + 0x01c2, 0x01c2, 0x01c2, 0x01c2, 0x01c2, 0x01c2, 0x01c2, 0x01c2, + 0x01c2, 0x01c2, 0x01c2, 0x01c2, 0x01c2, 0x01c2, 0x01c2, 0x01c2, + 0x01c2, 0x01c2, 0x01c2, 0x01c2, 0x01c2, 0x01c2, 0x01c2, 0x01c3, + 0x01c3, 0x01c3, 0x01c3, 0x01c3, 0x01c3, 0x01c5, 0x01c5, 0x01c5, + 0x01c5, 0x01c5, 0x01c5, 0x01c7, 0x01c7, 0x01c7, 0x01c7, 0x01c7, + // Entry 240 - 27F + 0x01c7, 0x01c7, 0x01c7, 0x01c7, 0x01c7, 0x01c7, 0x01c7, 0x01c7, + 0x01c7, 0x01c7, 0x01c7, 0x01c7, 0x01c7, 0x01c7, 0x01c7, 0x01c7, + 0x01c8, 0x01c8, 0x01c8, 0x01c8, 0x01c8, 0x01cb, 0x01cc, 0x01cc, + 0x01cc, 0x01cc, 0x01cc, 0x01cc, 0x01cc, 0x01cc, 0x01cc, 0x01cc, + 0x01cc, 0x01cc, 0x01cc, 0x01cc, 0x01cc, 0x01cc, 0x01cc, 0x01cc, + 0x01cc, 0x01cc, 0x01cc, 0x01cc, 0x01cc, 0x01cc, 0x01cc, 0x01cc, + 0x01cc, 0x01cc, 0x01cc, 0x01cc, 0x01cc, 0x01cc, 0x01cc, 0x01cc, + 0x01cc, 0x01ce, 0x01ce, 0x01cf, 0x01cf, 0x01d0, 0x01d0, 0x01d0, + // Entry 280 - 2BF + 0x01d0, 0x01d0, 0x01d0, 0x01d0, 0x01d0, 0x01d0, 0x01d0, 0x01d0, + 0x01d0, 0x01d0, 0x01d0, 0x01d0, 0x01d0, 0x01d0, 0x01d0, 0x01d0, + 0x01d2, 0x01d2, 0x01d2, 0x01d2, 0x01d2, 0x01d2, 0x01d5, 0x01d5, + 0x01d5, 0x01d5, 0x01d5, 0x01d5, 0x01d5, 0x01d5, 0x01d8, 0x01d8, + 0x01d8, 0x01d8, 0x01d9, 0x01d9, 0x01d9, 0x01d9, 0x01d9, 0x01d9, + 0x01da, 0x01da, 0x01da, 0x01da, 0x01da, 0x01db, 0x01db, 0x01db, + 0x01db, 0x01db, 0x01db, 0x01db, 0x01dc, 0x01dc, 0x01dc, 0x01dc, + 0x01dc, 0x01dc, 0x01dc, 0x01dc, 0x01dc, 0x01dc, 0x01dc, 0x01dc, + // Entry 2C0 - 2FF + 0x01de, 0x01de, 0x01de, 0x01de, 0x01de, 0x01de, 0x01de, 0x01de, + 0x01de, 0x01de, 0x01de, 0x01de, 0x01df, 0x01df, 0x01e0, 0x01e0, + 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, + 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e1, 0x01e1, + 0x01e1, 0x01e1, 0x01e1, 0x01e1, 0x01e1, 0x01e1, 0x01e1, 0x01e1, + 0x01e1, 0x01e1, 0x01e1, 0x01e1, 0x01e1, 0x01e1, 0x01e1, 0x01e1, + 0x01e1, 0x01e1, 0x01e1, 0x01e1, 0x01e1, 0x01e1, 0x01e1, 0x01e1, + 0x01e1, 0x01e1, 0x01e2, 0x01e2, 0x01e2, 0x01e2, 0x01e2, 0x01e2, + // Entry 300 - 33F + 0x01e3, 0x01e3, 0x01e3, 0x01e3, 0x01eb, 0x01eb, 0x01eb, 0x01eb, +} // Size: 1576 bytes + +var narrowSymIndex = []curToIndex{ // 491 elements + 0: {cur: 0x9, idx: 0x1}, + 1: {cur: 0x11, idx: 0x4}, + 2: {cur: 0x13, idx: 0x4}, + 3: {cur: 0x18, idx: 0x9}, + 4: {cur: 0x1a, idx: 0x4}, + 5: {cur: 0x1b, idx: 0xc}, + 6: {cur: 0x25, idx: 0x4}, + 7: {cur: 0x26, idx: 0x4}, + 8: {cur: 0x27, idx: 0x10}, + 9: {cur: 0x2e, idx: 0x13}, + 10: {cur: 0x32, idx: 0x4}, + 11: {cur: 0x35, idx: 0x16}, + 12: {cur: 0x37, idx: 0x18}, + 13: {cur: 0x39, idx: 0x4}, + 14: {cur: 0x3a, idx: 0x4}, + 15: {cur: 0x41, idx: 0x4}, + 16: {cur: 0x44, idx: 0x25}, + 17: {cur: 0x45, idx: 0x4}, + 18: {cur: 0x47, idx: 0x28}, + 19: {cur: 0x4a, idx: 0x4}, + 20: {cur: 0x4b, idx: 0x4}, + 21: {cur: 0x4e, idx: 0x2c}, + 22: {cur: 0x52, idx: 0x30}, + 23: {cur: 0x53, idx: 0x4}, + 24: {cur: 0x58, idx: 0x33}, + 25: {cur: 0x5c, idx: 0x37}, + 26: {cur: 0x5e, idx: 0x3b}, + 27: {cur: 0x60, idx: 0x4}, + 28: {cur: 0x61, idx: 0x3f}, + 29: {cur: 0x63, idx: 0x3f}, + 30: {cur: 0x65, idx: 0x42}, + 31: {cur: 0x68, idx: 0x3f}, + 32: {cur: 0x6a, idx: 0x46}, + 33: {cur: 0x6e, idx: 0x49}, + 34: {cur: 0x71, idx: 0x4}, + 35: {cur: 0x72, idx: 0x4}, + 36: {cur: 0x73, idx: 0x4f}, + 37: {cur: 0x75, idx: 0x51}, + 38: {cur: 0x77, idx: 0x54}, + 39: {cur: 0x78, idx: 0x57}, + 40: {cur: 0x7c, idx: 0x5a}, + 41: {cur: 0x7d, idx: 0x5e}, + 42: {cur: 0x81, idx: 0x30}, + 43: {cur: 0x83, idx: 0x4}, + 44: {cur: 0x85, idx: 0x25}, + 45: {cur: 0x88, idx: 0x67}, + 46: {cur: 0x89, idx: 0x6b}, + 47: {cur: 0x8a, idx: 0x6e}, + 48: {cur: 0x8d, idx: 0x6e}, + 49: {cur: 0x8f, idx: 0x4}, + 50: {cur: 0x90, idx: 0x72}, + 51: {cur: 0x91, idx: 0x76}, + 52: {cur: 0x92, idx: 0x7a}, + 53: {cur: 0x93, idx: 0x7e}, + 54: {cur: 0x94, idx: 0x4}, + 55: {cur: 0x96, idx: 0x81}, + 56: {cur: 0x9b, idx: 0x84}, + 57: {cur: 0xa3, idx: 0x87}, + 58: {cur: 0xa8, idx: 0x8a}, + 59: {cur: 0xa9, idx: 0x8c}, + 60: {cur: 0xae, idx: 0x7e}, + 61: {cur: 0xb2, idx: 0x4}, + 62: {cur: 0xb5, idx: 0x94}, + 63: {cur: 0xb9, idx: 0x4}, + 64: {cur: 0xba, idx: 0x97}, + 65: {cur: 0xbc, idx: 0x9b}, + 66: {cur: 0xbe, idx: 0x30}, + 67: {cur: 0xbf, idx: 0x7e}, + 68: {cur: 0xc0, idx: 0x4}, + 69: {cur: 0xc7, idx: 0xa2}, + 70: {cur: 0xc8, idx: 0x7e}, + 71: {cur: 0xc9, idx: 0xa6}, + 72: {cur: 0xcc, idx: 0xaa}, + 73: {cur: 0xd0, idx: 0xae}, + 74: {cur: 0xd2, idx: 0xb2}, + 75: {cur: 0xd3, idx: 0x18}, + 76: {cur: 0xd4, idx: 0xb6}, + 77: {cur: 0xd6, idx: 0x4}, + 78: {cur: 0xdb, idx: 0x30}, + 79: {cur: 0xdc, idx: 0x4}, + 80: {cur: 0xdd, idx: 0x3f}, + 81: {cur: 0xe2, idx: 0x4}, + 82: {cur: 0xe4, idx: 0x3f}, + 83: {cur: 0xe5, idx: 0xb9}, + 84: {cur: 0xe9, idx: 0x3f}, + 85: {cur: 0xeb, idx: 0xbc}, + 86: {cur: 0xf1, idx: 0xc0}, + 87: {cur: 0xf4, idx: 0xc3}, + 88: {cur: 0xf5, idx: 0x4}, + 89: {cur: 0xf6, idx: 0x4}, + 90: {cur: 0xf8, idx: 0xcb}, + 91: {cur: 0xfc, idx: 0x4}, + 92: {cur: 0x101, idx: 0x4}, + 93: {cur: 0x104, idx: 0x10}, + 94: {cur: 0x105, idx: 0xd3}, + 95: {cur: 0x110, idx: 0x4}, + 96: {cur: 0x125, idx: 0xe9}, + 97: {cur: 0x127, idx: 0xeb}, + 98: {cur: 0xd0, idx: 0xee}, + 99: {cur: 0xf6, idx: 0xc7}, + 100: {cur: 0xf6, idx: 0xc7}, + 101: {cur: 0x11, idx: 0x128}, + 102: {cur: 0x13, idx: 0xf8}, + 103: {cur: 0x1a, idx: 0x12c}, + 104: {cur: 0x25, idx: 0x13a}, + 105: {cur: 0x26, idx: 0x13e}, + 106: {cur: 0x32, idx: 0x142}, + 107: {cur: 0x39, idx: 0x146}, + 108: {cur: 0x3a, idx: 0x1c}, + 109: {cur: 0x41, idx: 0x14a}, + 110: {cur: 0x44, idx: 0x20}, + 111: {cur: 0x45, idx: 0x14e}, + 112: {cur: 0x4b, idx: 0x152}, + 113: {cur: 0x53, idx: 0x156}, + 114: {cur: 0x60, idx: 0x16e}, + 115: {cur: 0x63, idx: 0x172}, + 116: {cur: 0x71, idx: 0x177}, + 117: {cur: 0x72, idx: 0x4b}, + 118: {cur: 0x83, idx: 0x18c}, + 119: {cur: 0x85, idx: 0x62}, + 120: {cur: 0x8f, idx: 0x1a4}, + 121: {cur: 0xb2, idx: 0x90}, + 122: {cur: 0xc0, idx: 0x9e}, + 123: {cur: 0xd6, idx: 0x1ee}, + 124: {cur: 0xe2, idx: 0x203}, + 125: {cur: 0xf5, idx: 0x21b}, + 126: {cur: 0xf6, idx: 0xc7}, + 127: {cur: 0xfc, idx: 0xcf}, + 128: {cur: 0x101, idx: 0x21f}, + 129: {cur: 0x26, idx: 0x4}, + 130: {cur: 0x37, idx: 0x0}, + 131: {cur: 0x52, idx: 0x0}, + 132: {cur: 0x75, idx: 0x0}, + 133: {cur: 0x81, idx: 0x0}, + 134: {cur: 0xbe, idx: 0x0}, + 135: {cur: 0xc9, idx: 0x0}, + 136: {cur: 0xd3, idx: 0x0}, + 137: {cur: 0xdb, idx: 0x0}, + 138: {cur: 0xf6, idx: 0xc7}, + 139: {cur: 0xd0, idx: 0x244}, + 140: {cur: 0xe9, idx: 0x248}, + 141: {cur: 0xf6, idx: 0xc7}, + 142: {cur: 0x13, idx: 0x6}, + 143: {cur: 0x1a, idx: 0x24c}, + 144: {cur: 0x25, idx: 0x251}, + 145: {cur: 0x32, idx: 0x255}, + 146: {cur: 0x37, idx: 0x258}, + 147: {cur: 0x39, idx: 0x146}, + 148: {cur: 0x3a, idx: 0x1c}, + 149: {cur: 0x4a, idx: 0x25b}, + 150: {cur: 0x4b, idx: 0x260}, + 151: {cur: 0x53, idx: 0x264}, + 152: {cur: 0x60, idx: 0x16e}, + 153: {cur: 0x61, idx: 0x268}, + 154: {cur: 0x71, idx: 0x26d}, + 155: {cur: 0x81, idx: 0x270}, + 156: {cur: 0x83, idx: 0x275}, + 157: {cur: 0x8f, idx: 0x278}, + 158: {cur: 0x94, idx: 0x27c}, + 159: {cur: 0xb2, idx: 0x90}, + 160: {cur: 0xb9, idx: 0x27f}, + 161: {cur: 0xc0, idx: 0x9e}, + 162: {cur: 0xd2, idx: 0x282}, + 163: {cur: 0xd6, idx: 0x28a}, + 164: {cur: 0xdc, idx: 0x28e}, + 165: {cur: 0xf5, idx: 0x21b}, + 166: {cur: 0x101, idx: 0x291}, + 167: {cur: 0x110, idx: 0xdc}, + 168: {cur: 0x11, idx: 0x0}, + 169: {cur: 0x13, idx: 0x0}, + 170: {cur: 0x1a, idx: 0x0}, + 171: {cur: 0x1b, idx: 0x0}, + 172: {cur: 0x25, idx: 0x0}, + 173: {cur: 0x26, idx: 0x0}, + 174: {cur: 0x2e, idx: 0x0}, + 175: {cur: 0x32, idx: 0x0}, + 176: {cur: 0x37, idx: 0x0}, + 177: {cur: 0x39, idx: 0x0}, + 178: {cur: 0x3a, idx: 0x0}, + 179: {cur: 0x41, idx: 0x0}, + 180: {cur: 0x44, idx: 0x0}, + 181: {cur: 0x45, idx: 0x0}, + 182: {cur: 0x47, idx: 0x0}, + 183: {cur: 0x4b, idx: 0x0}, + 184: {cur: 0x53, idx: 0x0}, + 185: {cur: 0x60, idx: 0x0}, + 186: {cur: 0x68, idx: 0x0}, + 187: {cur: 0x71, idx: 0x0}, + 188: {cur: 0x72, idx: 0x0}, + 189: {cur: 0x7c, idx: 0x0}, + 190: {cur: 0x7d, idx: 0x0}, + 191: {cur: 0x83, idx: 0x0}, + 192: {cur: 0x88, idx: 0x0}, + 193: {cur: 0x8d, idx: 0x0}, + 194: {cur: 0x8f, idx: 0x0}, + 195: {cur: 0x90, idx: 0x0}, + 196: {cur: 0x91, idx: 0x0}, + 197: {cur: 0x94, idx: 0x0}, + 198: {cur: 0xa9, idx: 0x0}, + 199: {cur: 0xb2, idx: 0x0}, + 200: {cur: 0xb9, idx: 0x0}, + 201: {cur: 0xba, idx: 0x0}, + 202: {cur: 0xc0, idx: 0x0}, + 203: {cur: 0xc7, idx: 0x0}, + 204: {cur: 0xcc, idx: 0x0}, + 205: {cur: 0xd0, idx: 0x0}, + 206: {cur: 0xd6, idx: 0x0}, + 207: {cur: 0xdc, idx: 0x0}, + 208: {cur: 0xe2, idx: 0x0}, + 209: {cur: 0xe4, idx: 0x0}, + 210: {cur: 0xf4, idx: 0x0}, + 211: {cur: 0xf5, idx: 0x0}, + 212: {cur: 0xf6, idx: 0x0}, + 213: {cur: 0xf8, idx: 0x0}, + 214: {cur: 0x101, idx: 0x0}, + 215: {cur: 0x105, idx: 0x0}, + 216: {cur: 0xf6, idx: 0xc7}, + 217: {cur: 0x58, idx: 0x2a8}, + 218: {cur: 0x92, idx: 0x2b8}, + 219: {cur: 0xf1, idx: 0x2c1}, + 220: {cur: 0xf6, idx: 0xc7}, + 221: {cur: 0x104, idx: 0x0}, + 222: {cur: 0xf6, idx: 0xc7}, + 223: {cur: 0xd0, idx: 0x2ed}, + 224: {cur: 0xd0, idx: 0x4f}, + 225: {cur: 0xf6, idx: 0xc7}, + 226: {cur: 0x1b, idx: 0x301}, + 227: {cur: 0x35, idx: 0x0}, + 228: {cur: 0x72, idx: 0x4b}, + 229: {cur: 0xf6, idx: 0xc7}, + 230: {cur: 0x125, idx: 0x0}, + 231: {cur: 0x127, idx: 0x0}, + 232: {cur: 0x52, idx: 0x304}, + 233: {cur: 0x81, idx: 0x304}, + 234: {cur: 0xbe, idx: 0x304}, + 235: {cur: 0xd0, idx: 0x4f}, + 236: {cur: 0xdb, idx: 0x304}, + 237: {cur: 0xf6, idx: 0xc7}, + 238: {cur: 0x4a, idx: 0x318}, + 239: {cur: 0x61, idx: 0x320}, + 240: {cur: 0x6a, idx: 0x325}, + 241: {cur: 0x89, idx: 0x32a}, + 242: {cur: 0xd0, idx: 0x4f}, + 243: {cur: 0xd4, idx: 0x32d}, + 244: {cur: 0xe9, idx: 0x0}, + 245: {cur: 0xf6, idx: 0xc7}, + 246: {cur: 0x127, idx: 0x8a}, + 247: {cur: 0x5e, idx: 0x0}, + 248: {cur: 0x1b, idx: 0x349}, + 249: {cur: 0x27, idx: 0x34c}, + 250: {cur: 0x4b, idx: 0xa2}, + 251: {cur: 0x58, idx: 0x3f}, + 252: {cur: 0x81, idx: 0x34f}, + 253: {cur: 0xcc, idx: 0x352}, + 254: {cur: 0xdb, idx: 0x34f}, + 255: {cur: 0x101, idx: 0x291}, + 256: {cur: 0x58, idx: 0x0}, + 257: {cur: 0xd0, idx: 0x4f}, + 258: {cur: 0xf6, idx: 0xc7}, + 259: {cur: 0x58, idx: 0x33}, + 260: {cur: 0x61, idx: 0x268}, + 261: {cur: 0xe4, idx: 0x37b}, + 262: {cur: 0xe9, idx: 0x248}, + 263: {cur: 0x104, idx: 0x380}, + 264: {cur: 0x37, idx: 0x384}, + 265: {cur: 0x61, idx: 0x3f}, + 266: {cur: 0xd0, idx: 0xae}, + 267: {cur: 0xe4, idx: 0x3f}, + 268: {cur: 0xe9, idx: 0x3f}, + 269: {cur: 0x61, idx: 0x3f}, + 270: {cur: 0xd0, idx: 0xae}, + 271: {cur: 0xe4, idx: 0x3f}, + 272: {cur: 0xe9, idx: 0x3f}, + 273: {cur: 0x104, idx: 0x392}, + 274: {cur: 0xf6, idx: 0xc7}, + 275: {cur: 0xf6, idx: 0xc7}, + 276: {cur: 0x9, idx: 0x0}, + 277: {cur: 0x11, idx: 0x0}, + 278: {cur: 0x13, idx: 0x0}, + 279: {cur: 0x18, idx: 0x0}, + 280: {cur: 0x1a, idx: 0x0}, + 281: {cur: 0x1b, idx: 0x0}, + 282: {cur: 0x25, idx: 0x0}, + 283: {cur: 0x26, idx: 0x0}, + 284: {cur: 0x27, idx: 0x0}, + 285: {cur: 0x2e, idx: 0x0}, + 286: {cur: 0x32, idx: 0x0}, + 287: {cur: 0x35, idx: 0x0}, + 288: {cur: 0x37, idx: 0x0}, + 289: {cur: 0x39, idx: 0x0}, + 290: {cur: 0x3a, idx: 0x0}, + 291: {cur: 0x41, idx: 0x0}, + 292: {cur: 0x44, idx: 0x0}, + 293: {cur: 0x45, idx: 0x0}, + 294: {cur: 0x47, idx: 0x0}, + 295: {cur: 0x4a, idx: 0x0}, + 296: {cur: 0x4b, idx: 0x0}, + 297: {cur: 0x4e, idx: 0x0}, + 298: {cur: 0x52, idx: 0x0}, + 299: {cur: 0x53, idx: 0x0}, + 300: {cur: 0x58, idx: 0x0}, + 301: {cur: 0x5c, idx: 0x0}, + 302: {cur: 0x60, idx: 0x0}, + 303: {cur: 0x61, idx: 0x0}, + 304: {cur: 0x65, idx: 0x0}, + 305: {cur: 0x68, idx: 0x0}, + 306: {cur: 0x6a, idx: 0x0}, + 307: {cur: 0x6e, idx: 0x0}, + 308: {cur: 0x71, idx: 0x0}, + 309: {cur: 0x72, idx: 0x0}, + 310: {cur: 0x73, idx: 0x0}, + 311: {cur: 0x75, idx: 0x0}, + 312: {cur: 0x77, idx: 0x0}, + 313: {cur: 0x78, idx: 0x0}, + 314: {cur: 0x7c, idx: 0x0}, + 315: {cur: 0x7d, idx: 0x0}, + 316: {cur: 0x81, idx: 0x0}, + 317: {cur: 0x83, idx: 0x0}, + 318: {cur: 0x88, idx: 0x0}, + 319: {cur: 0x89, idx: 0x0}, + 320: {cur: 0x8a, idx: 0x0}, + 321: {cur: 0x8d, idx: 0x0}, + 322: {cur: 0x8f, idx: 0x0}, + 323: {cur: 0x90, idx: 0x0}, + 324: {cur: 0x91, idx: 0x0}, + 325: {cur: 0x92, idx: 0x0}, + 326: {cur: 0x93, idx: 0x0}, + 327: {cur: 0x94, idx: 0x0}, + 328: {cur: 0x96, idx: 0x0}, + 329: {cur: 0x9b, idx: 0x0}, + 330: {cur: 0xa3, idx: 0x0}, + 331: {cur: 0xa8, idx: 0x0}, + 332: {cur: 0xa9, idx: 0x0}, + 333: {cur: 0xae, idx: 0x0}, + 334: {cur: 0xb2, idx: 0x0}, + 335: {cur: 0xb5, idx: 0x0}, + 336: {cur: 0xb9, idx: 0x0}, + 337: {cur: 0xba, idx: 0x0}, + 338: {cur: 0xbc, idx: 0x0}, + 339: {cur: 0xbe, idx: 0x0}, + 340: {cur: 0xbf, idx: 0x0}, + 341: {cur: 0xc0, idx: 0x0}, + 342: {cur: 0xc7, idx: 0x0}, + 343: {cur: 0xc8, idx: 0x0}, + 344: {cur: 0xc9, idx: 0x0}, + 345: {cur: 0xcc, idx: 0x0}, + 346: {cur: 0xd0, idx: 0x0}, + 347: {cur: 0xd3, idx: 0x0}, + 348: {cur: 0xd4, idx: 0x0}, + 349: {cur: 0xd6, idx: 0x0}, + 350: {cur: 0xdb, idx: 0x0}, + 351: {cur: 0xdc, idx: 0x0}, + 352: {cur: 0xdd, idx: 0x0}, + 353: {cur: 0xe2, idx: 0x0}, + 354: {cur: 0xe4, idx: 0x0}, + 355: {cur: 0xe5, idx: 0x0}, + 356: {cur: 0xe9, idx: 0x0}, + 357: {cur: 0xeb, idx: 0x0}, + 358: {cur: 0xf1, idx: 0x0}, + 359: {cur: 0xf4, idx: 0x0}, + 360: {cur: 0xf5, idx: 0x0}, + 361: {cur: 0xf6, idx: 0x0}, + 362: {cur: 0xf8, idx: 0x0}, + 363: {cur: 0x101, idx: 0x0}, + 364: {cur: 0x104, idx: 0x0}, + 365: {cur: 0x105, idx: 0x0}, + 366: {cur: 0x110, idx: 0x0}, + 367: {cur: 0x125, idx: 0x0}, + 368: {cur: 0x127, idx: 0x0}, + 369: {cur: 0xf6, idx: 0xc7}, + 370: {cur: 0x58, idx: 0x3e5}, + 371: {cur: 0x89, idx: 0x32a}, + 372: {cur: 0x92, idx: 0x2b8}, + 373: {cur: 0xbc, idx: 0x41a}, + 374: {cur: 0xd0, idx: 0x4f}, + 375: {cur: 0xd4, idx: 0x421}, + 376: {cur: 0xf6, idx: 0xc7}, + 377: {cur: 0x127, idx: 0x441}, + 378: {cur: 0x37, idx: 0x258}, + 379: {cur: 0x65, idx: 0x0}, + 380: {cur: 0x89, idx: 0x6b}, + 381: {cur: 0xbc, idx: 0x9b}, + 382: {cur: 0x127, idx: 0xeb}, + 383: {cur: 0xf6, idx: 0xc7}, + 384: {cur: 0xd0, idx: 0xee}, + 385: {cur: 0xf6, idx: 0xc7}, + 386: {cur: 0x89, idx: 0x32a}, + 387: {cur: 0xd2, idx: 0x46d}, + 388: {cur: 0xf6, idx: 0xc7}, + 389: {cur: 0xae, idx: 0x474}, + 390: {cur: 0xf6, idx: 0xc7}, + 391: {cur: 0xf6, idx: 0xc7}, + 392: {cur: 0xd0, idx: 0x48e}, + 393: {cur: 0xf6, idx: 0xc7}, + 394: {cur: 0xf6, idx: 0xc7}, + 395: {cur: 0xf6, idx: 0xc7}, + 396: {cur: 0xf6, idx: 0xc7}, + 397: {cur: 0xf6, idx: 0xc7}, + 398: {cur: 0xf6, idx: 0xc7}, + 399: {cur: 0x37, idx: 0x258}, + 400: {cur: 0x58, idx: 0x3e5}, + 401: {cur: 0xbe, idx: 0x49b}, + 402: {cur: 0xf6, idx: 0xc7}, + 403: {cur: 0x44, idx: 0x4a3}, + 404: {cur: 0x85, idx: 0x4a3}, + 405: {cur: 0xd0, idx: 0x4a7}, + 406: {cur: 0xf6, idx: 0xc7}, + 407: {cur: 0xf6, idx: 0xc7}, + 408: {cur: 0xf6, idx: 0xc7}, + 409: {cur: 0xd0, idx: 0x4b2}, + 410: {cur: 0xf6, idx: 0xc7}, + 411: {cur: 0xd0, idx: 0x4f}, + 412: {cur: 0xf6, idx: 0xc7}, + 413: {cur: 0x25, idx: 0x251}, + 414: {cur: 0x32, idx: 0x255}, + 415: {cur: 0x39, idx: 0x146}, + 416: {cur: 0x3a, idx: 0x9b}, + 417: {cur: 0x53, idx: 0x264}, + 418: {cur: 0x58, idx: 0x4b9}, + 419: {cur: 0x72, idx: 0x4b}, + 420: {cur: 0x75, idx: 0x4bc}, + 421: {cur: 0x83, idx: 0x275}, + 422: {cur: 0xf5, idx: 0x21b}, + 423: {cur: 0xf6, idx: 0xc7}, + 424: {cur: 0xf6, idx: 0xc7}, + 425: {cur: 0xf6, idx: 0xc7}, + 426: {cur: 0x1b, idx: 0x0}, + 427: {cur: 0x37, idx: 0x258}, + 428: {cur: 0x7c, idx: 0x0}, + 429: {cur: 0x7d, idx: 0x0}, + 430: {cur: 0x88, idx: 0x0}, + 431: {cur: 0x91, idx: 0x0}, + 432: {cur: 0xa9, idx: 0x0}, + 433: {cur: 0xc9, idx: 0x4c6}, + 434: {cur: 0xcc, idx: 0x352}, + 435: {cur: 0xd2, idx: 0x4c9}, + 436: {cur: 0x105, idx: 0x0}, + 437: {cur: 0xf6, idx: 0xc7}, + 438: {cur: 0xf6, idx: 0xc7}, + 439: {cur: 0xf6, idx: 0xc7}, + 440: {cur: 0xdb, idx: 0x4d7}, + 441: {cur: 0xf6, idx: 0xc7}, + 442: {cur: 0xf6, idx: 0xc7}, + 443: {cur: 0xf6, idx: 0xc7}, + 444: {cur: 0x1a, idx: 0x24c}, + 445: {cur: 0x32, idx: 0x255}, + 446: {cur: 0xd0, idx: 0x4f}, + 447: {cur: 0xf6, idx: 0xc7}, + 448: {cur: 0xbf, idx: 0x4f1}, + 449: {cur: 0xf6, idx: 0xc7}, + 450: {cur: 0xf6, idx: 0xc7}, + 451: {cur: 0xd0, idx: 0x500}, + 452: {cur: 0xf6, idx: 0xc7}, + 453: {cur: 0xd0, idx: 0x4f}, + 454: {cur: 0xf6, idx: 0xc7}, + 455: {cur: 0xf6, idx: 0xc7}, + 456: {cur: 0x65, idx: 0x515}, + 457: {cur: 0xd0, idx: 0x4f}, + 458: {cur: 0xf6, idx: 0xc7}, + 459: {cur: 0x37, idx: 0x258}, + 460: {cur: 0x93, idx: 0x52c}, + 461: {cur: 0xf6, idx: 0xc7}, + 462: {cur: 0xf6, idx: 0xc7}, + 463: {cur: 0xf6, idx: 0xc7}, + 464: {cur: 0x65, idx: 0x515}, + 465: {cur: 0xf6, idx: 0xc7}, + 466: {cur: 0x37, idx: 0x552}, + 467: {cur: 0x65, idx: 0x515}, + 468: {cur: 0xf6, idx: 0xc7}, + 469: {cur: 0x5c, idx: 0x0}, + 470: {cur: 0xd0, idx: 0x4f}, + 471: {cur: 0xf6, idx: 0xc7}, + 472: {cur: 0xf6, idx: 0xc7}, + 473: {cur: 0xf6, idx: 0xc7}, + 474: {cur: 0xf6, idx: 0xc7}, + 475: {cur: 0xf6, idx: 0xc7}, + 476: {cur: 0xd0, idx: 0x4f}, + 477: {cur: 0xf6, idx: 0xc7}, + 478: {cur: 0xf6, idx: 0xc7}, + 479: {cur: 0xf6, idx: 0xc7}, + 480: {cur: 0xf6, idx: 0xc7}, + 481: {cur: 0xf6, idx: 0xc7}, + 482: {cur: 0xd0, idx: 0x4f}, + 483: {cur: 0x37, idx: 0x59e}, + 484: {cur: 0x52, idx: 0x34f}, + 485: {cur: 0x75, idx: 0x4bc}, + 486: {cur: 0x81, idx: 0x34f}, + 487: {cur: 0xbe, idx: 0x34f}, + 488: {cur: 0xc9, idx: 0x5a1}, + 489: {cur: 0xdb, idx: 0x34f}, + 490: {cur: 0xf6, idx: 0xc7}, +} // Size: 1988 bytes + +// Total table size 18885 bytes (18KiB); checksum: BE08FD0B diff --git a/vendor/golang.org/x/text/internal/format/format.go b/vendor/golang.org/x/text/internal/format/format.go new file mode 100644 index 00000000000..ee1c57a3c58 --- /dev/null +++ b/vendor/golang.org/x/text/internal/format/format.go @@ -0,0 +1,41 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package format contains types for defining language-specific formatting of +// values. +// +// This package is internal now, but will eventually be exposed after the API +// settles. +package format // import "golang.org/x/text/internal/format" + +import ( + "fmt" + + "golang.org/x/text/language" +) + +// State represents the printer state passed to custom formatters. It provides +// access to the fmt.State interface and the sentence and language-related +// context. +type State interface { + fmt.State + + // Language reports the requested language in which to render a message. + Language() language.Tag + + // TODO: consider this and removing rune from the Format method in the + // Formatter interface. + // + // Verb returns the format variant to render, analogous to the types used + // in fmt. Use 'v' for the default or only variant. + // Verb() rune + + // TODO: more info: + // - sentence context such as linguistic features passed by the translator. +} + +// Formatter is analogous to fmt.Formatter. +type Formatter interface { + Format(state State, verb rune) +} diff --git a/vendor/golang.org/x/text/internal/format/parser.go b/vendor/golang.org/x/text/internal/format/parser.go new file mode 100644 index 00000000000..855aed71dbb --- /dev/null +++ b/vendor/golang.org/x/text/internal/format/parser.go @@ -0,0 +1,358 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package format + +import ( + "reflect" + "unicode/utf8" +) + +// A Parser parses a format string. The result from the parse are set in the +// struct fields. +type Parser struct { + Verb rune + + WidthPresent bool + PrecPresent bool + Minus bool + Plus bool + Sharp bool + Space bool + Zero bool + + // For the formats %+v %#v, we set the plusV/sharpV flags + // and clear the plus/sharp flags since %+v and %#v are in effect + // different, flagless formats set at the top level. + PlusV bool + SharpV bool + + HasIndex bool + + Width int + Prec int // precision + + // retain arguments across calls. + Args []interface{} + // retain current argument number across calls + ArgNum int + + // reordered records whether the format string used argument reordering. + Reordered bool + // goodArgNum records whether the most recent reordering directive was valid. + goodArgNum bool + + // position info + format string + startPos int + endPos int + Status Status +} + +// Reset initializes a parser to scan format strings for the given args. +func (p *Parser) Reset(args []interface{}) { + p.Args = args + p.ArgNum = 0 + p.startPos = 0 + p.Reordered = false +} + +// Text returns the part of the format string that was parsed by the last call +// to Scan. It returns the original substitution clause if the current scan +// parsed a substitution. +func (p *Parser) Text() string { return p.format[p.startPos:p.endPos] } + +// SetFormat sets a new format string to parse. It does not reset the argument +// count. +func (p *Parser) SetFormat(format string) { + p.format = format + p.startPos = 0 + p.endPos = 0 +} + +// Status indicates the result type of a call to Scan. +type Status int + +const ( + StatusText Status = iota + StatusSubstitution + StatusBadWidthSubstitution + StatusBadPrecSubstitution + StatusNoVerb + StatusBadArgNum + StatusMissingArg +) + +// ClearFlags reset the parser to default behavior. +func (p *Parser) ClearFlags() { + p.WidthPresent = false + p.PrecPresent = false + p.Minus = false + p.Plus = false + p.Sharp = false + p.Space = false + p.Zero = false + + p.PlusV = false + p.SharpV = false + + p.HasIndex = false +} + +// Scan scans the next part of the format string and sets the status to +// indicate whether it scanned a string literal, substitution or error. +func (p *Parser) Scan() bool { + p.Status = StatusText + format := p.format + end := len(format) + if p.endPos >= end { + return false + } + afterIndex := false // previous item in format was an index like [3]. + + p.startPos = p.endPos + p.goodArgNum = true + i := p.startPos + for i < end && format[i] != '%' { + i++ + } + if i > p.startPos { + p.endPos = i + return true + } + // Process one verb + i++ + + p.Status = StatusSubstitution + + // Do we have flags? + p.ClearFlags() + +simpleFormat: + for ; i < end; i++ { + c := p.format[i] + switch c { + case '#': + p.Sharp = true + case '0': + p.Zero = !p.Minus // Only allow zero padding to the left. + case '+': + p.Plus = true + case '-': + p.Minus = true + p.Zero = false // Do not pad with zeros to the right. + case ' ': + p.Space = true + default: + // Fast path for common case of ascii lower case simple verbs + // without precision or width or argument indices. + if 'a' <= c && c <= 'z' && p.ArgNum < len(p.Args) { + if c == 'v' { + // Go syntax + p.SharpV = p.Sharp + p.Sharp = false + // Struct-field syntax + p.PlusV = p.Plus + p.Plus = false + } + p.Verb = rune(c) + p.ArgNum++ + p.endPos = i + 1 + return true + } + // Format is more complex than simple flags and a verb or is malformed. + break simpleFormat + } + } + + // Do we have an explicit argument index? + i, afterIndex = p.updateArgNumber(format, i) + + // Do we have width? + if i < end && format[i] == '*' { + i++ + p.Width, p.WidthPresent = p.intFromArg() + + if !p.WidthPresent { + p.Status = StatusBadWidthSubstitution + } + + // We have a negative width, so take its value and ensure + // that the minus flag is set + if p.Width < 0 { + p.Width = -p.Width + p.Minus = true + p.Zero = false // Do not pad with zeros to the right. + } + afterIndex = false + } else { + p.Width, p.WidthPresent, i = parsenum(format, i, end) + if afterIndex && p.WidthPresent { // "%[3]2d" + p.goodArgNum = false + } + } + + // Do we have precision? + if i+1 < end && format[i] == '.' { + i++ + if afterIndex { // "%[3].2d" + p.goodArgNum = false + } + i, afterIndex = p.updateArgNumber(format, i) + if i < end && format[i] == '*' { + i++ + p.Prec, p.PrecPresent = p.intFromArg() + // Negative precision arguments don't make sense + if p.Prec < 0 { + p.Prec = 0 + p.PrecPresent = false + } + if !p.PrecPresent { + p.Status = StatusBadPrecSubstitution + } + afterIndex = false + } else { + p.Prec, p.PrecPresent, i = parsenum(format, i, end) + if !p.PrecPresent { + p.Prec = 0 + p.PrecPresent = true + } + } + } + + if !afterIndex { + i, afterIndex = p.updateArgNumber(format, i) + } + p.HasIndex = afterIndex + + if i >= end { + p.endPos = i + p.Status = StatusNoVerb + return true + } + + verb, w := utf8.DecodeRuneInString(format[i:]) + p.endPos = i + w + p.Verb = verb + + switch { + case verb == '%': // Percent does not absorb operands and ignores f.wid and f.prec. + p.startPos = p.endPos - 1 + p.Status = StatusText + case !p.goodArgNum: + p.Status = StatusBadArgNum + case p.ArgNum >= len(p.Args): // No argument left over to print for the current verb. + p.Status = StatusMissingArg + p.ArgNum++ + case verb == 'v': + // Go syntax + p.SharpV = p.Sharp + p.Sharp = false + // Struct-field syntax + p.PlusV = p.Plus + p.Plus = false + fallthrough + default: + p.ArgNum++ + } + return true +} + +// intFromArg gets the ArgNumth element of Args. On return, isInt reports +// whether the argument has integer type. +func (p *Parser) intFromArg() (num int, isInt bool) { + if p.ArgNum < len(p.Args) { + arg := p.Args[p.ArgNum] + num, isInt = arg.(int) // Almost always OK. + if !isInt { + // Work harder. + switch v := reflect.ValueOf(arg); v.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + n := v.Int() + if int64(int(n)) == n { + num = int(n) + isInt = true + } + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + n := v.Uint() + if int64(n) >= 0 && uint64(int(n)) == n { + num = int(n) + isInt = true + } + default: + // Already 0, false. + } + } + p.ArgNum++ + if tooLarge(num) { + num = 0 + isInt = false + } + } + return +} + +// parseArgNumber returns the value of the bracketed number, minus 1 +// (explicit argument numbers are one-indexed but we want zero-indexed). +// The opening bracket is known to be present at format[0]. +// The returned values are the index, the number of bytes to consume +// up to the closing paren, if present, and whether the number parsed +// ok. The bytes to consume will be 1 if no closing paren is present. +func parseArgNumber(format string) (index int, wid int, ok bool) { + // There must be at least 3 bytes: [n]. + if len(format) < 3 { + return 0, 1, false + } + + // Find closing bracket. + for i := 1; i < len(format); i++ { + if format[i] == ']' { + width, ok, newi := parsenum(format, 1, i) + if !ok || newi != i { + return 0, i + 1, false + } + return width - 1, i + 1, true // arg numbers are one-indexed and skip paren. + } + } + return 0, 1, false +} + +// updateArgNumber returns the next argument to evaluate, which is either the value of the passed-in +// argNum or the value of the bracketed integer that begins format[i:]. It also returns +// the new value of i, that is, the index of the next byte of the format to process. +func (p *Parser) updateArgNumber(format string, i int) (newi int, found bool) { + if len(format) <= i || format[i] != '[' { + return i, false + } + p.Reordered = true + index, wid, ok := parseArgNumber(format[i:]) + if ok && 0 <= index && index < len(p.Args) { + p.ArgNum = index + return i + wid, true + } + p.goodArgNum = false + return i + wid, ok +} + +// tooLarge reports whether the magnitude of the integer is +// too large to be used as a formatting width or precision. +func tooLarge(x int) bool { + const max int = 1e6 + return x > max || x < -max +} + +// parsenum converts ASCII to integer. num is 0 (and isnum is false) if no number present. +func parsenum(s string, start, end int) (num int, isnum bool, newi int) { + if start >= end { + return 0, false, end + } + for newi = start; newi < end && '0' <= s[newi] && s[newi] <= '9'; newi++ { + if tooLarge(num) { + return 0, false, end // Overflow; crazy long number most likely. + } + num = num*10 + int(s[newi]-'0') + isnum = true + } + return +} diff --git a/vendor/golang.org/x/text/internal/number/common.go b/vendor/golang.org/x/text/internal/number/common.go new file mode 100644 index 00000000000..a6e9c8e0d54 --- /dev/null +++ b/vendor/golang.org/x/text/internal/number/common.go @@ -0,0 +1,55 @@ +// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. + +package number + +import ( + "unicode/utf8" + + "golang.org/x/text/internal/language/compact" +) + +// A system identifies a CLDR numbering system. +type system byte + +type systemData struct { + id system + digitSize byte // number of UTF-8 bytes per digit + zero [utf8.UTFMax]byte // UTF-8 sequence of zero digit. +} + +// A SymbolType identifies a symbol of a specific kind. +type SymbolType int + +const ( + SymDecimal SymbolType = iota + SymGroup + SymList + SymPercentSign + SymPlusSign + SymMinusSign + SymExponential + SymSuperscriptingExponent + SymPerMille + SymInfinity + SymNan + SymTimeSeparator + + NumSymbolTypes +) + +const hasNonLatnMask = 0x8000 + +// symOffset is an offset into altSymData if the bit indicated by hasNonLatnMask +// is not 0 (with this bit masked out), and an offset into symIndex otherwise. +// +// TODO: this type can be a byte again if we use an indirection into altsymData +// and introduce an alt -> offset slice (the length of this will be number of +// alternatives plus 1). This also allows getting rid of the compactTag field +// in altSymData. In total this will save about 1K. +type symOffset uint16 + +type altSymData struct { + compactTag compact.ID + symIndex symOffset + system system +} diff --git a/vendor/golang.org/x/text/internal/number/decimal.go b/vendor/golang.org/x/text/internal/number/decimal.go new file mode 100644 index 00000000000..e128cf34377 --- /dev/null +++ b/vendor/golang.org/x/text/internal/number/decimal.go @@ -0,0 +1,500 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:generate stringer -type RoundingMode + +package number + +import ( + "math" + "strconv" +) + +// RoundingMode determines how a number is rounded to the desired precision. +type RoundingMode byte + +const ( + ToNearestEven RoundingMode = iota // towards the nearest integer, or towards an even number if equidistant. + ToNearestZero // towards the nearest integer, or towards zero if equidistant. + ToNearestAway // towards the nearest integer, or away from zero if equidistant. + ToPositiveInf // towards infinity + ToNegativeInf // towards negative infinity + ToZero // towards zero + AwayFromZero // away from zero + numModes +) + +const maxIntDigits = 20 + +// A Decimal represents a floating point number in decimal format. +// Digits represents a number [0, 1.0), and the absolute value represented by +// Decimal is Digits * 10^Exp. Leading and trailing zeros may be omitted and Exp +// may point outside a valid position in Digits. +// +// Examples: +// +// Number Decimal +// 12345 Digits: [1, 2, 3, 4, 5], Exp: 5 +// 12.345 Digits: [1, 2, 3, 4, 5], Exp: 2 +// 12000 Digits: [1, 2], Exp: 5 +// 12000.00 Digits: [1, 2], Exp: 5 +// 0.00123 Digits: [1, 2, 3], Exp: -2 +// 0 Digits: [], Exp: 0 +type Decimal struct { + digits + + buf [maxIntDigits]byte +} + +type digits struct { + Digits []byte // mantissa digits, big-endian + Exp int32 // exponent + Neg bool + Inf bool // Takes precedence over Digits and Exp. + NaN bool // Takes precedence over Inf. +} + +// Digits represents a floating point number represented in digits of the +// base in which a number is to be displayed. It is similar to Decimal, but +// keeps track of trailing fraction zeros and the comma placement for +// engineering notation. Digits must have at least one digit. +// +// Examples: +// +// Number Decimal +// decimal +// 12345 Digits: [1, 2, 3, 4, 5], Exp: 5 End: 5 +// 12.345 Digits: [1, 2, 3, 4, 5], Exp: 2 End: 5 +// 12000 Digits: [1, 2], Exp: 5 End: 5 +// 12000.00 Digits: [1, 2], Exp: 5 End: 7 +// 0.00123 Digits: [1, 2, 3], Exp: -2 End: 3 +// 0 Digits: [], Exp: 0 End: 1 +// scientific (actual exp is Exp - Comma) +// 0e0 Digits: [0], Exp: 1, End: 1, Comma: 1 +// .0e0 Digits: [0], Exp: 0, End: 1, Comma: 0 +// 0.0e0 Digits: [0], Exp: 1, End: 2, Comma: 1 +// 1.23e4 Digits: [1, 2, 3], Exp: 5, End: 3, Comma: 1 +// .123e5 Digits: [1, 2, 3], Exp: 5, End: 3, Comma: 0 +// engineering +// 12.3e3 Digits: [1, 2, 3], Exp: 5, End: 3, Comma: 2 +type Digits struct { + digits + // End indicates the end position of the number. + End int32 // For decimals Exp <= End. For scientific len(Digits) <= End. + // Comma is used for the comma position for scientific (always 0 or 1) and + // engineering notation (always 0, 1, 2, or 3). + Comma uint8 + // IsScientific indicates whether this number is to be rendered as a + // scientific number. + IsScientific bool +} + +func (d *Digits) NumFracDigits() int { + if d.Exp >= d.End { + return 0 + } + return int(d.End - d.Exp) +} + +// normalize returns a new Decimal with leading and trailing zeros removed. +func (d *Decimal) normalize() (n Decimal) { + n = *d + b := n.Digits + // Strip leading zeros. Resulting number of digits is significant digits. + for len(b) > 0 && b[0] == 0 { + b = b[1:] + n.Exp-- + } + // Strip trailing zeros + for len(b) > 0 && b[len(b)-1] == 0 { + b = b[:len(b)-1] + } + if len(b) == 0 { + n.Exp = 0 + } + n.Digits = b + return n +} + +func (d *Decimal) clear() { + b := d.Digits + if b == nil { + b = d.buf[:0] + } + *d = Decimal{} + d.Digits = b[:0] +} + +func (x *Decimal) String() string { + if x.NaN { + return "NaN" + } + var buf []byte + if x.Neg { + buf = append(buf, '-') + } + if x.Inf { + buf = append(buf, "Inf"...) + return string(buf) + } + switch { + case len(x.Digits) == 0: + buf = append(buf, '0') + case x.Exp <= 0: + // 0.00ddd + buf = append(buf, "0."...) + buf = appendZeros(buf, -int(x.Exp)) + buf = appendDigits(buf, x.Digits) + + case /* 0 < */ int(x.Exp) < len(x.Digits): + // dd.ddd + buf = appendDigits(buf, x.Digits[:x.Exp]) + buf = append(buf, '.') + buf = appendDigits(buf, x.Digits[x.Exp:]) + + default: // len(x.Digits) <= x.Exp + // ddd00 + buf = appendDigits(buf, x.Digits) + buf = appendZeros(buf, int(x.Exp)-len(x.Digits)) + } + return string(buf) +} + +func appendDigits(buf []byte, digits []byte) []byte { + for _, c := range digits { + buf = append(buf, c+'0') + } + return buf +} + +// appendZeros appends n 0 digits to buf and returns buf. +func appendZeros(buf []byte, n int) []byte { + for ; n > 0; n-- { + buf = append(buf, '0') + } + return buf +} + +func (d *digits) round(mode RoundingMode, n int) { + if n >= len(d.Digits) { + return + } + // Make rounding decision: The result mantissa is truncated ("rounded down") + // by default. Decide if we need to increment, or "round up", the (unsigned) + // mantissa. + inc := false + switch mode { + case ToNegativeInf: + inc = d.Neg + case ToPositiveInf: + inc = !d.Neg + case ToZero: + // nothing to do + case AwayFromZero: + inc = true + case ToNearestEven: + inc = d.Digits[n] > 5 || d.Digits[n] == 5 && + (len(d.Digits) > n+1 || n == 0 || d.Digits[n-1]&1 != 0) + case ToNearestAway: + inc = d.Digits[n] >= 5 + case ToNearestZero: + inc = d.Digits[n] > 5 || d.Digits[n] == 5 && len(d.Digits) > n+1 + default: + panic("unreachable") + } + if inc { + d.roundUp(n) + } else { + d.roundDown(n) + } +} + +// roundFloat rounds a floating point number. +func (r RoundingMode) roundFloat(x float64) float64 { + // Make rounding decision: The result mantissa is truncated ("rounded down") + // by default. Decide if we need to increment, or "round up", the (unsigned) + // mantissa. + abs := x + if x < 0 { + abs = -x + } + i, f := math.Modf(abs) + if f == 0.0 { + return x + } + inc := false + switch r { + case ToNegativeInf: + inc = x < 0 + case ToPositiveInf: + inc = x >= 0 + case ToZero: + // nothing to do + case AwayFromZero: + inc = true + case ToNearestEven: + // TODO: check overflow + inc = f > 0.5 || f == 0.5 && int64(i)&1 != 0 + case ToNearestAway: + inc = f >= 0.5 + case ToNearestZero: + inc = f > 0.5 + default: + panic("unreachable") + } + if inc { + i += 1 + } + if abs != x { + i = -i + } + return i +} + +func (x *digits) roundUp(n int) { + if n < 0 || n >= len(x.Digits) { + return // nothing to do + } + // find first digit < 9 + for n > 0 && x.Digits[n-1] >= 9 { + n-- + } + + if n == 0 { + // all digits are 9s => round up to 1 and update exponent + x.Digits[0] = 1 // ok since len(x.Digits) > n + x.Digits = x.Digits[:1] + x.Exp++ + return + } + x.Digits[n-1]++ + x.Digits = x.Digits[:n] + // x already trimmed +} + +func (x *digits) roundDown(n int) { + if n < 0 || n >= len(x.Digits) { + return // nothing to do + } + x.Digits = x.Digits[:n] + trim(x) +} + +// trim cuts off any trailing zeros from x's mantissa; +// they are meaningless for the value of x. +func trim(x *digits) { + i := len(x.Digits) + for i > 0 && x.Digits[i-1] == 0 { + i-- + } + x.Digits = x.Digits[:i] + if i == 0 { + x.Exp = 0 + } +} + +// A Converter converts a number into decimals according to the given rounding +// criteria. +type Converter interface { + Convert(d *Decimal, r RoundingContext) +} + +const ( + signed = true + unsigned = false +) + +// Convert converts the given number to the decimal representation using the +// supplied RoundingContext. +func (d *Decimal) Convert(r RoundingContext, number interface{}) { + switch f := number.(type) { + case Converter: + d.clear() + f.Convert(d, r) + case float32: + d.ConvertFloat(r, float64(f), 32) + case float64: + d.ConvertFloat(r, f, 64) + case int: + d.ConvertInt(r, signed, uint64(f)) + case int8: + d.ConvertInt(r, signed, uint64(f)) + case int16: + d.ConvertInt(r, signed, uint64(f)) + case int32: + d.ConvertInt(r, signed, uint64(f)) + case int64: + d.ConvertInt(r, signed, uint64(f)) + case uint: + d.ConvertInt(r, unsigned, uint64(f)) + case uint8: + d.ConvertInt(r, unsigned, uint64(f)) + case uint16: + d.ConvertInt(r, unsigned, uint64(f)) + case uint32: + d.ConvertInt(r, unsigned, uint64(f)) + case uint64: + d.ConvertInt(r, unsigned, f) + + default: + d.NaN = true + // TODO: + // case string: if produced by strconv, allows for easy arbitrary pos. + // case reflect.Value: + // case big.Float + // case big.Int + // case big.Rat? + // catch underlyings using reflect or will this already be done by the + // message package? + } +} + +// ConvertInt converts an integer to decimals. +func (d *Decimal) ConvertInt(r RoundingContext, signed bool, x uint64) { + if r.Increment > 0 { + // TODO: if uint64 is too large, fall back to float64 + if signed { + d.ConvertFloat(r, float64(int64(x)), 64) + } else { + d.ConvertFloat(r, float64(x), 64) + } + return + } + d.clear() + if signed && int64(x) < 0 { + x = uint64(-int64(x)) + d.Neg = true + } + d.fillIntDigits(x) + d.Exp = int32(len(d.Digits)) +} + +// ConvertFloat converts a floating point number to decimals. +func (d *Decimal) ConvertFloat(r RoundingContext, x float64, size int) { + d.clear() + if math.IsNaN(x) { + d.NaN = true + return + } + // Simple case: decimal notation + if r.Increment > 0 { + scale := int(r.IncrementScale) + mult := 1.0 + if scale >= len(scales) { + mult = math.Pow(10, float64(scale)) + } else { + mult = scales[scale] + } + // We multiply x instead of dividing inc as it gives less rounding + // issues. + x *= mult + x /= float64(r.Increment) + x = r.Mode.roundFloat(x) + x *= float64(r.Increment) + x /= mult + } + + abs := x + if x < 0 { + d.Neg = true + abs = -x + } + if math.IsInf(abs, 1) { + d.Inf = true + return + } + + // By default we get the exact decimal representation. + verb := byte('g') + prec := -1 + // As the strconv API does not return the rounding accuracy, we can only + // round using ToNearestEven. + if r.Mode == ToNearestEven { + if n := r.RoundSignificantDigits(); n >= 0 { + prec = n + } else if n = r.RoundFractionDigits(); n >= 0 { + prec = n + verb = 'f' + } + } else { + // TODO: At this point strconv's rounding is imprecise to the point that + // it is not usable for this purpose. + // See https://github.com/golang/go/issues/21714 + // If rounding is requested, we ask for a large number of digits and + // round from there to simulate rounding only once. + // Ideally we would have strconv export an AppendDigits that would take + // a rounding mode and/or return an accuracy. Something like this would + // work: + // AppendDigits(dst []byte, x float64, base, size, prec int) (digits []byte, exp, accuracy int) + hasPrec := r.RoundSignificantDigits() >= 0 + hasScale := r.RoundFractionDigits() >= 0 + if hasPrec || hasScale { + // prec is the number of mantissa bits plus some extra for safety. + // We need at least the number of mantissa bits as decimals to + // accurately represent the floating point without rounding, as each + // bit requires one more decimal to represent: 0.5, 0.25, 0.125, ... + prec = 60 + } + } + + b := strconv.AppendFloat(d.Digits[:0], abs, verb, prec, size) + i := 0 + k := 0 + beforeDot := 1 + for i < len(b) { + if c := b[i]; '0' <= c && c <= '9' { + b[k] = c - '0' + k++ + d.Exp += int32(beforeDot) + } else if c == '.' { + beforeDot = 0 + d.Exp = int32(k) + } else { + break + } + i++ + } + d.Digits = b[:k] + if i != len(b) { + i += len("e") + pSign := i + exp := 0 + for i++; i < len(b); i++ { + exp *= 10 + exp += int(b[i] - '0') + } + if b[pSign] == '-' { + exp = -exp + } + d.Exp = int32(exp) + 1 + } +} + +func (d *Decimal) fillIntDigits(x uint64) { + if cap(d.Digits) < maxIntDigits { + d.Digits = d.buf[:] + } else { + d.Digits = d.buf[:maxIntDigits] + } + i := 0 + for ; x > 0; x /= 10 { + d.Digits[i] = byte(x % 10) + i++ + } + d.Digits = d.Digits[:i] + for p := 0; p < i; p++ { + i-- + d.Digits[p], d.Digits[i] = d.Digits[i], d.Digits[p] + } +} + +var scales [70]float64 + +func init() { + x := 1.0 + for i := range scales { + scales[i] = x + x *= 10 + } +} diff --git a/vendor/golang.org/x/text/internal/number/format.go b/vendor/golang.org/x/text/internal/number/format.go new file mode 100644 index 00000000000..1aadcf40777 --- /dev/null +++ b/vendor/golang.org/x/text/internal/number/format.go @@ -0,0 +1,533 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package number + +import ( + "strconv" + "unicode/utf8" + + "golang.org/x/text/language" +) + +// TODO: +// - grouping of fractions +// - allow user-defined superscript notation (such as 4) +// - same for non-breaking spaces, like   + +// A VisibleDigits computes digits, comma placement and trailing zeros as they +// will be shown to the user. +type VisibleDigits interface { + Digits(buf []byte, t language.Tag, scale int) Digits + // TODO: Do we also need to add the verb or pass a format.State? +} + +// Formatting proceeds along the following lines: +// 0) Compose rounding information from format and context. +// 1) Convert a number into a Decimal. +// 2) Sanitize Decimal by adding trailing zeros, removing leading digits, and +// (non-increment) rounding. The Decimal that results from this is suitable +// for determining the plural form. +// 3) Render the Decimal in the localized form. + +// Formatter contains all the information needed to render a number. +type Formatter struct { + Pattern + Info +} + +func (f *Formatter) init(t language.Tag, index []uint8) { + f.Info = InfoFromTag(t) + f.Pattern = formats[index[tagToID(t)]] +} + +// InitPattern initializes a Formatter for the given Pattern. +func (f *Formatter) InitPattern(t language.Tag, pat *Pattern) { + f.Info = InfoFromTag(t) + f.Pattern = *pat +} + +// InitDecimal initializes a Formatter using the default Pattern for the given +// language. +func (f *Formatter) InitDecimal(t language.Tag) { + f.init(t, tagToDecimal) +} + +// InitScientific initializes a Formatter using the default Pattern for the +// given language. +func (f *Formatter) InitScientific(t language.Tag) { + f.init(t, tagToScientific) + f.Pattern.MinFractionDigits = 0 + f.Pattern.MaxFractionDigits = -1 +} + +// InitEngineering initializes a Formatter using the default Pattern for the +// given language. +func (f *Formatter) InitEngineering(t language.Tag) { + f.init(t, tagToScientific) + f.Pattern.MinFractionDigits = 0 + f.Pattern.MaxFractionDigits = -1 + f.Pattern.MaxIntegerDigits = 3 + f.Pattern.MinIntegerDigits = 1 +} + +// InitPercent initializes a Formatter using the default Pattern for the given +// language. +func (f *Formatter) InitPercent(t language.Tag) { + f.init(t, tagToPercent) +} + +// InitPerMille initializes a Formatter using the default Pattern for the given +// language. +func (f *Formatter) InitPerMille(t language.Tag) { + f.init(t, tagToPercent) + f.Pattern.DigitShift = 3 +} + +func (f *Formatter) Append(dst []byte, x interface{}) []byte { + var d Decimal + r := f.RoundingContext + d.Convert(r, x) + return f.Render(dst, FormatDigits(&d, r)) +} + +func FormatDigits(d *Decimal, r RoundingContext) Digits { + if r.isScientific() { + return scientificVisibleDigits(r, d) + } + return decimalVisibleDigits(r, d) +} + +func (f *Formatter) Format(dst []byte, d *Decimal) []byte { + return f.Render(dst, FormatDigits(d, f.RoundingContext)) +} + +func (f *Formatter) Render(dst []byte, d Digits) []byte { + var result []byte + var postPrefix, preSuffix int + if d.IsScientific { + result, postPrefix, preSuffix = appendScientific(dst, f, &d) + } else { + result, postPrefix, preSuffix = appendDecimal(dst, f, &d) + } + if f.PadRune == 0 { + return result + } + width := int(f.FormatWidth) + if count := utf8.RuneCount(result); count < width { + insertPos := 0 + switch f.Flags & PadMask { + case PadAfterPrefix: + insertPos = postPrefix + case PadBeforeSuffix: + insertPos = preSuffix + case PadAfterSuffix: + insertPos = len(result) + } + num := width - count + pad := [utf8.UTFMax]byte{' '} + sz := 1 + if r := f.PadRune; r != 0 { + sz = utf8.EncodeRune(pad[:], r) + } + extra := sz * num + if n := len(result) + extra; n < cap(result) { + result = result[:n] + copy(result[insertPos+extra:], result[insertPos:]) + } else { + buf := make([]byte, n) + copy(buf, result[:insertPos]) + copy(buf[insertPos+extra:], result[insertPos:]) + result = buf + } + for ; num > 0; num-- { + insertPos += copy(result[insertPos:], pad[:sz]) + } + } + return result +} + +// decimalVisibleDigits converts d according to the RoundingContext. Note that +// the exponent may change as a result of this operation. +func decimalVisibleDigits(r RoundingContext, d *Decimal) Digits { + if d.NaN || d.Inf { + return Digits{digits: digits{Neg: d.Neg, NaN: d.NaN, Inf: d.Inf}} + } + n := Digits{digits: d.normalize().digits} + + exp := n.Exp + exp += int32(r.DigitShift) + + // Cap integer digits. Remove *most-significant* digits. + if r.MaxIntegerDigits > 0 { + if p := int(exp) - int(r.MaxIntegerDigits); p > 0 { + if p > len(n.Digits) { + p = len(n.Digits) + } + if n.Digits = n.Digits[p:]; len(n.Digits) == 0 { + exp = 0 + } else { + exp -= int32(p) + } + // Strip leading zeros. + for len(n.Digits) > 0 && n.Digits[0] == 0 { + n.Digits = n.Digits[1:] + exp-- + } + } + } + + // Rounding if not already done by Convert. + p := len(n.Digits) + if maxSig := int(r.MaxSignificantDigits); maxSig > 0 { + p = maxSig + } + if maxFrac := int(r.MaxFractionDigits); maxFrac >= 0 { + if cap := int(exp) + maxFrac; cap < p { + p = int(exp) + maxFrac + } + if p < 0 { + p = 0 + } + } + n.round(r.Mode, p) + + // set End (trailing zeros) + n.End = int32(len(n.Digits)) + if n.End == 0 { + exp = 0 + if r.MinFractionDigits > 0 { + n.End = int32(r.MinFractionDigits) + } + if p := int32(r.MinSignificantDigits) - 1; p > n.End { + n.End = p + } + } else { + if end := exp + int32(r.MinFractionDigits); end > n.End { + n.End = end + } + if n.End < int32(r.MinSignificantDigits) { + n.End = int32(r.MinSignificantDigits) + } + } + n.Exp = exp + return n +} + +// appendDecimal appends a formatted number to dst. It returns two possible +// insertion points for padding. +func appendDecimal(dst []byte, f *Formatter, n *Digits) (b []byte, postPre, preSuf int) { + if dst, ok := f.renderSpecial(dst, n); ok { + return dst, 0, len(dst) + } + digits := n.Digits + exp := n.Exp + + // Split in integer and fraction part. + var intDigits, fracDigits []byte + numInt := 0 + numFrac := int(n.End - n.Exp) + if exp > 0 { + numInt = int(exp) + if int(exp) >= len(digits) { // ddddd | ddddd00 + intDigits = digits + } else { // ddd.dd + intDigits = digits[:exp] + fracDigits = digits[exp:] + } + } else { + fracDigits = digits + } + + neg := n.Neg + affix, suffix := f.getAffixes(neg) + dst = appendAffix(dst, f, affix, neg) + savedLen := len(dst) + + minInt := int(f.MinIntegerDigits) + if minInt == 0 && f.MinSignificantDigits > 0 { + minInt = 1 + } + // add leading zeros + for i := minInt; i > numInt; i-- { + dst = f.AppendDigit(dst, 0) + if f.needsSep(i) { + dst = append(dst, f.Symbol(SymGroup)...) + } + } + i := 0 + for ; i < len(intDigits); i++ { + dst = f.AppendDigit(dst, intDigits[i]) + if f.needsSep(numInt - i) { + dst = append(dst, f.Symbol(SymGroup)...) + } + } + for ; i < numInt; i++ { + dst = f.AppendDigit(dst, 0) + if f.needsSep(numInt - i) { + dst = append(dst, f.Symbol(SymGroup)...) + } + } + + if numFrac > 0 || f.Flags&AlwaysDecimalSeparator != 0 { + dst = append(dst, f.Symbol(SymDecimal)...) + } + // Add trailing zeros + i = 0 + for n := -int(n.Exp); i < n; i++ { + dst = f.AppendDigit(dst, 0) + } + for _, d := range fracDigits { + i++ + dst = f.AppendDigit(dst, d) + } + for ; i < numFrac; i++ { + dst = f.AppendDigit(dst, 0) + } + return appendAffix(dst, f, suffix, neg), savedLen, len(dst) +} + +func scientificVisibleDigits(r RoundingContext, d *Decimal) Digits { + if d.NaN || d.Inf { + return Digits{digits: digits{Neg: d.Neg, NaN: d.NaN, Inf: d.Inf}} + } + n := Digits{digits: d.normalize().digits, IsScientific: true} + + // Normalize to have at least one digit. This simplifies engineering + // notation. + if len(n.Digits) == 0 { + n.Digits = append(n.Digits, 0) + n.Exp = 1 + } + + // Significant digits are transformed by the parser for scientific notation + // and do not need to be handled here. + maxInt, numInt := int(r.MaxIntegerDigits), int(r.MinIntegerDigits) + if numInt == 0 { + numInt = 1 + } + + // If a maximum number of integers is specified, the minimum must be 1 + // and the exponent is grouped by this number (e.g. for engineering) + if maxInt > numInt { + // Correct the exponent to reflect a single integer digit. + numInt = 1 + // engineering + // 0.01234 ([12345]e-1) -> 1.2345e-2 12.345e-3 + // 12345 ([12345]e+5) -> 1.2345e4 12.345e3 + d := int(n.Exp-1) % maxInt + if d < 0 { + d += maxInt + } + numInt += d + } + + p := len(n.Digits) + if maxSig := int(r.MaxSignificantDigits); maxSig > 0 { + p = maxSig + } + if maxFrac := int(r.MaxFractionDigits); maxFrac >= 0 && numInt+maxFrac < p { + p = numInt + maxFrac + } + n.round(r.Mode, p) + + n.Comma = uint8(numInt) + n.End = int32(len(n.Digits)) + if minSig := int32(r.MinFractionDigits) + int32(numInt); n.End < minSig { + n.End = minSig + } + return n +} + +// appendScientific appends a formatted number to dst. It returns two possible +// insertion points for padding. +func appendScientific(dst []byte, f *Formatter, n *Digits) (b []byte, postPre, preSuf int) { + if dst, ok := f.renderSpecial(dst, n); ok { + return dst, 0, 0 + } + digits := n.Digits + numInt := int(n.Comma) + numFrac := int(n.End) - int(n.Comma) + + var intDigits, fracDigits []byte + if numInt <= len(digits) { + intDigits = digits[:numInt] + fracDigits = digits[numInt:] + } else { + intDigits = digits + } + neg := n.Neg + affix, suffix := f.getAffixes(neg) + dst = appendAffix(dst, f, affix, neg) + savedLen := len(dst) + + i := 0 + for ; i < len(intDigits); i++ { + dst = f.AppendDigit(dst, intDigits[i]) + if f.needsSep(numInt - i) { + dst = append(dst, f.Symbol(SymGroup)...) + } + } + for ; i < numInt; i++ { + dst = f.AppendDigit(dst, 0) + if f.needsSep(numInt - i) { + dst = append(dst, f.Symbol(SymGroup)...) + } + } + + if numFrac > 0 || f.Flags&AlwaysDecimalSeparator != 0 { + dst = append(dst, f.Symbol(SymDecimal)...) + } + i = 0 + for ; i < len(fracDigits); i++ { + dst = f.AppendDigit(dst, fracDigits[i]) + } + for ; i < numFrac; i++ { + dst = f.AppendDigit(dst, 0) + } + + // exp + buf := [12]byte{} + // TODO: use exponential if superscripting is not available (no Latin + // numbers or no tags) and use exponential in all other cases. + exp := n.Exp - int32(n.Comma) + exponential := f.Symbol(SymExponential) + if exponential == "E" { + dst = append(dst, f.Symbol(SymSuperscriptingExponent)...) + dst = f.AppendDigit(dst, 1) + dst = f.AppendDigit(dst, 0) + switch { + case exp < 0: + dst = append(dst, superMinus...) + exp = -exp + case f.Flags&AlwaysExpSign != 0: + dst = append(dst, superPlus...) + } + b = strconv.AppendUint(buf[:0], uint64(exp), 10) + for i := len(b); i < int(f.MinExponentDigits); i++ { + dst = append(dst, superDigits[0]...) + } + for _, c := range b { + dst = append(dst, superDigits[c-'0']...) + } + } else { + dst = append(dst, exponential...) + switch { + case exp < 0: + dst = append(dst, f.Symbol(SymMinusSign)...) + exp = -exp + case f.Flags&AlwaysExpSign != 0: + dst = append(dst, f.Symbol(SymPlusSign)...) + } + b = strconv.AppendUint(buf[:0], uint64(exp), 10) + for i := len(b); i < int(f.MinExponentDigits); i++ { + dst = f.AppendDigit(dst, 0) + } + for _, c := range b { + dst = f.AppendDigit(dst, c-'0') + } + } + return appendAffix(dst, f, suffix, neg), savedLen, len(dst) +} + +const ( + superMinus = "\u207B" // SUPERSCRIPT HYPHEN-MINUS + superPlus = "\u207A" // SUPERSCRIPT PLUS SIGN +) + +var ( + // Note: the digits are not sequential!!! + superDigits = []string{ + "\u2070", // SUPERSCRIPT DIGIT ZERO + "\u00B9", // SUPERSCRIPT DIGIT ONE + "\u00B2", // SUPERSCRIPT DIGIT TWO + "\u00B3", // SUPERSCRIPT DIGIT THREE + "\u2074", // SUPERSCRIPT DIGIT FOUR + "\u2075", // SUPERSCRIPT DIGIT FIVE + "\u2076", // SUPERSCRIPT DIGIT SIX + "\u2077", // SUPERSCRIPT DIGIT SEVEN + "\u2078", // SUPERSCRIPT DIGIT EIGHT + "\u2079", // SUPERSCRIPT DIGIT NINE + } +) + +func (f *Formatter) getAffixes(neg bool) (affix, suffix string) { + str := f.Affix + if str != "" { + if f.NegOffset > 0 { + if neg { + str = str[f.NegOffset:] + } else { + str = str[:f.NegOffset] + } + } + sufStart := 1 + str[0] + affix = str[1:sufStart] + suffix = str[sufStart+1:] + } + // TODO: introduce a NeedNeg sign to indicate if the left pattern already + // has a sign marked? + if f.NegOffset == 0 && (neg || f.Flags&AlwaysSign != 0) { + affix = "-" + affix + } + return affix, suffix +} + +func (f *Formatter) renderSpecial(dst []byte, d *Digits) (b []byte, ok bool) { + if d.NaN { + return fmtNaN(dst, f), true + } + if d.Inf { + return fmtInfinite(dst, f, d), true + } + return dst, false +} + +func fmtNaN(dst []byte, f *Formatter) []byte { + return append(dst, f.Symbol(SymNan)...) +} + +func fmtInfinite(dst []byte, f *Formatter, d *Digits) []byte { + affix, suffix := f.getAffixes(d.Neg) + dst = appendAffix(dst, f, affix, d.Neg) + dst = append(dst, f.Symbol(SymInfinity)...) + dst = appendAffix(dst, f, suffix, d.Neg) + return dst +} + +func appendAffix(dst []byte, f *Formatter, affix string, neg bool) []byte { + quoting := false + escaping := false + for _, r := range affix { + switch { + case escaping: + // escaping occurs both inside and outside of quotes + dst = append(dst, string(r)...) + escaping = false + case r == '\\': + escaping = true + case r == '\'': + quoting = !quoting + case quoting: + dst = append(dst, string(r)...) + case r == '%': + if f.DigitShift == 3 { + dst = append(dst, f.Symbol(SymPerMille)...) + } else { + dst = append(dst, f.Symbol(SymPercentSign)...) + } + case r == '-' || r == '+': + if neg { + dst = append(dst, f.Symbol(SymMinusSign)...) + } else if f.Flags&ElideSign == 0 { + dst = append(dst, f.Symbol(SymPlusSign)...) + } else { + dst = append(dst, ' ') + } + default: + dst = append(dst, string(r)...) + } + } + return dst +} diff --git a/vendor/golang.org/x/text/internal/number/number.go b/vendor/golang.org/x/text/internal/number/number.go new file mode 100644 index 00000000000..e1d933c3f7e --- /dev/null +++ b/vendor/golang.org/x/text/internal/number/number.go @@ -0,0 +1,152 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:generate go run gen.go gen_common.go + +// Package number contains tools and data for formatting numbers. +package number + +import ( + "unicode/utf8" + + "golang.org/x/text/internal/language/compact" + "golang.org/x/text/language" +) + +// Info holds number formatting configuration data. +type Info struct { + system systemData // numbering system information + symIndex symOffset // index to symbols +} + +// InfoFromLangID returns a Info for the given compact language identifier and +// numbering system identifier. If system is the empty string, the default +// numbering system will be taken for that language. +func InfoFromLangID(compactIndex compact.ID, numberSystem string) Info { + p := langToDefaults[compactIndex] + // Lookup the entry for the language. + pSymIndex := symOffset(0) // Default: Latin, default symbols + system, ok := systemMap[numberSystem] + if !ok { + // Take the value for the default numbering system. This is by far the + // most common case as an alternative numbering system is hardly used. + if p&hasNonLatnMask == 0 { // Latn digits. + pSymIndex = p + } else { // Non-Latn or multiple numbering systems. + // Take the first entry from the alternatives list. + data := langToAlt[p&^hasNonLatnMask] + pSymIndex = data.symIndex + system = data.system + } + } else { + langIndex := compactIndex + ns := system + outerLoop: + for ; ; p = langToDefaults[langIndex] { + if p&hasNonLatnMask == 0 { + if ns == 0 { + // The index directly points to the symbol data. + pSymIndex = p + break + } + // Move to the parent and retry. + langIndex = langIndex.Parent() + } else { + // The index points to a list of symbol data indexes. + for _, e := range langToAlt[p&^hasNonLatnMask:] { + if e.compactTag != langIndex { + if langIndex == 0 { + // The CLDR root defines full symbol information for + // all numbering systems (even though mostly by + // means of aliases). Fall back to the default entry + // for Latn if there is no data for the numbering + // system of this language. + if ns == 0 { + break + } + // Fall back to Latin and start from the original + // language. See + // https://unicode.org/reports/tr35/#Locale_Inheritance. + ns = numLatn + langIndex = compactIndex + continue outerLoop + } + // Fall back to parent. + langIndex = langIndex.Parent() + } else if e.system == ns { + pSymIndex = e.symIndex + break outerLoop + } + } + } + } + } + if int(system) >= len(numSysData) { // algorithmic + // Will generate ASCII digits in case the user inadvertently calls + // WriteDigit or Digit on it. + d := numSysData[0] + d.id = system + return Info{ + system: d, + symIndex: pSymIndex, + } + } + return Info{ + system: numSysData[system], + symIndex: pSymIndex, + } +} + +// InfoFromTag returns a Info for the given language tag. +func InfoFromTag(t language.Tag) Info { + return InfoFromLangID(tagToID(t), t.TypeForKey("nu")) +} + +// IsDecimal reports if the numbering system can convert decimal to native +// symbols one-to-one. +func (n Info) IsDecimal() bool { + return int(n.system.id) < len(numSysData) +} + +// WriteDigit writes the UTF-8 sequence for n corresponding to the given ASCII +// digit to dst and reports the number of bytes written. dst must be large +// enough to hold the rune (can be up to utf8.UTFMax bytes). +func (n Info) WriteDigit(dst []byte, asciiDigit rune) int { + copy(dst, n.system.zero[:n.system.digitSize]) + dst[n.system.digitSize-1] += byte(asciiDigit - '0') + return int(n.system.digitSize) +} + +// AppendDigit appends the UTF-8 sequence for n corresponding to the given digit +// to dst and reports the number of bytes written. dst must be large enough to +// hold the rune (can be up to utf8.UTFMax bytes). +func (n Info) AppendDigit(dst []byte, digit byte) []byte { + dst = append(dst, n.system.zero[:n.system.digitSize]...) + dst[len(dst)-1] += digit + return dst +} + +// Digit returns the digit for the numbering system for the corresponding ASCII +// value. For example, ni.Digit('3') could return '三'. Note that the argument +// is the rune constant '3', which equals 51, not the integer constant 3. +func (n Info) Digit(asciiDigit rune) rune { + var x [utf8.UTFMax]byte + n.WriteDigit(x[:], asciiDigit) + r, _ := utf8.DecodeRune(x[:]) + return r +} + +// Symbol returns the string for the given symbol type. +func (n Info) Symbol(t SymbolType) string { + return symData.Elem(int(symIndex[n.symIndex][t])) +} + +func formatForLang(t language.Tag, index []byte) *Pattern { + return &formats[index[tagToID(t)]] +} + +func tagToID(t language.Tag) compact.ID { + id, _ := compact.RegionalID(compact.Tag(t)) + return id +} diff --git a/vendor/golang.org/x/text/internal/number/pattern.go b/vendor/golang.org/x/text/internal/number/pattern.go new file mode 100644 index 00000000000..06e59559a96 --- /dev/null +++ b/vendor/golang.org/x/text/internal/number/pattern.go @@ -0,0 +1,485 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package number + +import ( + "errors" + "unicode/utf8" +) + +// This file contains a parser for the CLDR number patterns as described in +// https://unicode.org/reports/tr35/tr35-numbers.html#Number_Format_Patterns. +// +// The following BNF is derived from this standard. +// +// pattern := subpattern (';' subpattern)? +// subpattern := affix? number exponent? affix? +// number := decimal | sigDigits +// decimal := '#'* '0'* ('.' fraction)? | '#' | '0' +// fraction := '0'* '#'* +// sigDigits := '#'* '@' '@'* '#'* +// exponent := 'E' '+'? '0'* '0' +// padSpec := '*' \L +// +// Notes: +// - An affix pattern may contain any runes, but runes with special meaning +// should be escaped. +// - Sequences of digits, '#', and '@' in decimal and sigDigits may have +// interstitial commas. + +// TODO: replace special characters in affixes (-, +, ¤) with control codes. + +// Pattern holds information for formatting numbers. It is designed to hold +// information from CLDR number patterns. +// +// This pattern is precompiled for all patterns for all languages. Even though +// the number of patterns is not very large, we want to keep this small. +// +// This type is only intended for internal use. +type Pattern struct { + RoundingContext + + Affix string // includes prefix and suffix. First byte is prefix length. + Offset uint16 // Offset into Affix for prefix and suffix + NegOffset uint16 // Offset into Affix for negative prefix and suffix or 0. + PadRune rune + FormatWidth uint16 + + GroupingSize [2]uint8 + Flags PatternFlag +} + +// A RoundingContext indicates how a number should be converted to digits. +// It contains all information needed to determine the "visible digits" as +// required by the pluralization rules. +type RoundingContext struct { + // TODO: unify these two fields so that there is a more unambiguous meaning + // of how precision is handled. + MaxSignificantDigits int16 // -1 is unlimited + MaxFractionDigits int16 // -1 is unlimited + + Increment uint32 + IncrementScale uint8 // May differ from printed scale. + + Mode RoundingMode + + DigitShift uint8 // Number of decimals to shift. Used for % and ‰. + + // Number of digits. + MinIntegerDigits uint8 + + MaxIntegerDigits uint8 + MinFractionDigits uint8 + MinSignificantDigits uint8 + + MinExponentDigits uint8 +} + +// RoundSignificantDigits returns the number of significant digits an +// implementation of Convert may round to or n < 0 if there is no maximum or +// a maximum is not recommended. +func (r *RoundingContext) RoundSignificantDigits() (n int) { + if r.MaxFractionDigits == 0 && r.MaxSignificantDigits > 0 { + return int(r.MaxSignificantDigits) + } else if r.isScientific() && r.MaxIntegerDigits == 1 { + if r.MaxSignificantDigits == 0 || + int(r.MaxFractionDigits+1) == int(r.MaxSignificantDigits) { + // Note: don't add DigitShift: it is only used for decimals. + return int(r.MaxFractionDigits) + 1 + } + } + return -1 +} + +// RoundFractionDigits returns the number of fraction digits an implementation +// of Convert may round to or n < 0 if there is no maximum or a maximum is not +// recommended. +func (r *RoundingContext) RoundFractionDigits() (n int) { + if r.MinExponentDigits == 0 && + r.MaxSignificantDigits == 0 && + r.MaxFractionDigits >= 0 { + return int(r.MaxFractionDigits) + int(r.DigitShift) + } + return -1 +} + +// SetScale fixes the RoundingContext to a fixed number of fraction digits. +func (r *RoundingContext) SetScale(scale int) { + r.MinFractionDigits = uint8(scale) + r.MaxFractionDigits = int16(scale) +} + +func (r *RoundingContext) SetPrecision(prec int) { + r.MaxSignificantDigits = int16(prec) +} + +func (r *RoundingContext) isScientific() bool { + return r.MinExponentDigits > 0 +} + +func (f *Pattern) needsSep(pos int) bool { + p := pos - 1 + size := int(f.GroupingSize[0]) + if size == 0 || p == 0 { + return false + } + if p == size { + return true + } + if p -= size; p < 0 { + return false + } + // TODO: make second groupingsize the same as first if 0 so that we can + // avoid this check. + if x := int(f.GroupingSize[1]); x != 0 { + size = x + } + return p%size == 0 +} + +// A PatternFlag is a bit mask for the flag field of a Pattern. +type PatternFlag uint8 + +const ( + AlwaysSign PatternFlag = 1 << iota + ElideSign // Use space instead of plus sign. AlwaysSign must be true. + AlwaysExpSign + AlwaysDecimalSeparator + ParenthesisForNegative // Common pattern. Saves space. + + PadAfterNumber + PadAfterAffix + + PadBeforePrefix = 0 // Default + PadAfterPrefix = PadAfterAffix + PadBeforeSuffix = PadAfterNumber + PadAfterSuffix = PadAfterNumber | PadAfterAffix + PadMask = PadAfterNumber | PadAfterAffix +) + +type parser struct { + *Pattern + + leadingSharps int + + pos int + err error + doNotTerminate bool + groupingCount uint + hasGroup bool + buf []byte +} + +func (p *parser) setError(err error) { + if p.err == nil { + p.err = err + } +} + +func (p *parser) updateGrouping() { + if p.hasGroup && + 0 < p.groupingCount && p.groupingCount < 255 { + p.GroupingSize[1] = p.GroupingSize[0] + p.GroupingSize[0] = uint8(p.groupingCount) + } + p.groupingCount = 0 + p.hasGroup = true +} + +var ( + // TODO: more sensible and localizeable error messages. + errMultiplePadSpecifiers = errors.New("format: pattern has multiple pad specifiers") + errInvalidPadSpecifier = errors.New("format: invalid pad specifier") + errInvalidQuote = errors.New("format: invalid quote") + errAffixTooLarge = errors.New("format: prefix or suffix exceeds maximum UTF-8 length of 256 bytes") + errDuplicatePercentSign = errors.New("format: duplicate percent sign") + errDuplicatePermilleSign = errors.New("format: duplicate permille sign") + errUnexpectedEnd = errors.New("format: unexpected end of pattern") +) + +// ParsePattern extracts formatting information from a CLDR number pattern. +// +// See https://unicode.org/reports/tr35/tr35-numbers.html#Number_Format_Patterns. +func ParsePattern(s string) (f *Pattern, err error) { + p := parser{Pattern: &Pattern{}} + + s = p.parseSubPattern(s) + + if s != "" { + // Parse negative sub pattern. + if s[0] != ';' { + p.setError(errors.New("format: error parsing first sub pattern")) + return nil, p.err + } + neg := parser{Pattern: &Pattern{}} // just for extracting the affixes. + s = neg.parseSubPattern(s[len(";"):]) + p.NegOffset = uint16(len(p.buf)) + p.buf = append(p.buf, neg.buf...) + } + if s != "" { + p.setError(errors.New("format: spurious characters at end of pattern")) + } + if p.err != nil { + return nil, p.err + } + if affix := string(p.buf); affix == "\x00\x00" || affix == "\x00\x00\x00\x00" { + // No prefix or suffixes. + p.NegOffset = 0 + } else { + p.Affix = affix + } + if p.Increment == 0 { + p.IncrementScale = 0 + } + return p.Pattern, nil +} + +func (p *parser) parseSubPattern(s string) string { + s = p.parsePad(s, PadBeforePrefix) + s = p.parseAffix(s) + s = p.parsePad(s, PadAfterPrefix) + + s = p.parse(p.number, s) + p.updateGrouping() + + s = p.parsePad(s, PadBeforeSuffix) + s = p.parseAffix(s) + s = p.parsePad(s, PadAfterSuffix) + return s +} + +func (p *parser) parsePad(s string, f PatternFlag) (tail string) { + if len(s) >= 2 && s[0] == '*' { + r, sz := utf8.DecodeRuneInString(s[1:]) + if p.PadRune != 0 { + p.err = errMultiplePadSpecifiers + } else { + p.Flags |= f + p.PadRune = r + } + return s[1+sz:] + } + return s +} + +func (p *parser) parseAffix(s string) string { + x := len(p.buf) + p.buf = append(p.buf, 0) // placeholder for affix length + + s = p.parse(p.affix, s) + + n := len(p.buf) - x - 1 + if n > 0xFF { + p.setError(errAffixTooLarge) + } + p.buf[x] = uint8(n) + return s +} + +// state implements a state transition. It returns the new state. A state +// function may set an error on the parser or may simply return on an incorrect +// token and let the next phase fail. +type state func(r rune) state + +// parse repeatedly applies a state function on the given string until a +// termination condition is reached. +func (p *parser) parse(fn state, s string) (tail string) { + for i, r := range s { + p.doNotTerminate = false + if fn = fn(r); fn == nil || p.err != nil { + return s[i:] + } + p.FormatWidth++ + } + if p.doNotTerminate { + p.setError(errUnexpectedEnd) + } + return "" +} + +func (p *parser) affix(r rune) state { + switch r { + case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '#', '@', '.', '*', ',', ';': + return nil + case '\'': + p.FormatWidth-- + return p.escapeFirst + case '%': + if p.DigitShift != 0 { + p.setError(errDuplicatePercentSign) + } + p.DigitShift = 2 + case '\u2030': // ‰ Per mille + if p.DigitShift != 0 { + p.setError(errDuplicatePermilleSign) + } + p.DigitShift = 3 + // TODO: handle currency somehow: ¤, ¤¤, ¤¤¤, ¤¤¤¤ + } + p.buf = append(p.buf, string(r)...) + return p.affix +} + +func (p *parser) escapeFirst(r rune) state { + switch r { + case '\'': + p.buf = append(p.buf, "\\'"...) + return p.affix + default: + p.buf = append(p.buf, '\'') + p.buf = append(p.buf, string(r)...) + } + return p.escape +} + +func (p *parser) escape(r rune) state { + switch r { + case '\'': + p.FormatWidth-- + p.buf = append(p.buf, '\'') + return p.affix + default: + p.buf = append(p.buf, string(r)...) + } + return p.escape +} + +// number parses a number. The BNF says the integer part should always have +// a '0', but that does not appear to be the case according to the rest of the +// documentation. We will allow having only '#' numbers. +func (p *parser) number(r rune) state { + switch r { + case '#': + p.groupingCount++ + p.leadingSharps++ + case '@': + p.groupingCount++ + p.leadingSharps = 0 + p.MaxFractionDigits = -1 + return p.sigDigits(r) + case ',': + if p.leadingSharps == 0 { // no leading commas + return nil + } + p.updateGrouping() + case 'E': + p.MaxIntegerDigits = uint8(p.leadingSharps) + return p.exponent + case '.': // allow ".##" etc. + p.updateGrouping() + return p.fraction + case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': + return p.integer(r) + default: + return nil + } + return p.number +} + +func (p *parser) integer(r rune) state { + if !('0' <= r && r <= '9') { + var next state + switch r { + case 'E': + if p.leadingSharps > 0 { + p.MaxIntegerDigits = uint8(p.leadingSharps) + p.MinIntegerDigits + } + next = p.exponent + case '.': + next = p.fraction + case ',': + next = p.integer + } + p.updateGrouping() + return next + } + p.Increment = p.Increment*10 + uint32(r-'0') + p.groupingCount++ + p.MinIntegerDigits++ + return p.integer +} + +func (p *parser) sigDigits(r rune) state { + switch r { + case '@': + p.groupingCount++ + p.MaxSignificantDigits++ + p.MinSignificantDigits++ + case '#': + return p.sigDigitsFinal(r) + case 'E': + p.updateGrouping() + return p.normalizeSigDigitsWithExponent() + default: + p.updateGrouping() + return nil + } + return p.sigDigits +} + +func (p *parser) sigDigitsFinal(r rune) state { + switch r { + case '#': + p.groupingCount++ + p.MaxSignificantDigits++ + case 'E': + p.updateGrouping() + return p.normalizeSigDigitsWithExponent() + default: + p.updateGrouping() + return nil + } + return p.sigDigitsFinal +} + +func (p *parser) normalizeSigDigitsWithExponent() state { + p.MinIntegerDigits, p.MaxIntegerDigits = 1, 1 + p.MinFractionDigits = p.MinSignificantDigits - 1 + p.MaxFractionDigits = p.MaxSignificantDigits - 1 + p.MinSignificantDigits, p.MaxSignificantDigits = 0, 0 + return p.exponent +} + +func (p *parser) fraction(r rune) state { + switch r { + case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': + p.Increment = p.Increment*10 + uint32(r-'0') + p.IncrementScale++ + p.MinFractionDigits++ + p.MaxFractionDigits++ + case '#': + p.MaxFractionDigits++ + case 'E': + if p.leadingSharps > 0 { + p.MaxIntegerDigits = uint8(p.leadingSharps) + p.MinIntegerDigits + } + return p.exponent + default: + return nil + } + return p.fraction +} + +func (p *parser) exponent(r rune) state { + switch r { + case '+': + // Set mode and check it wasn't already set. + if p.Flags&AlwaysExpSign != 0 || p.MinExponentDigits > 0 { + break + } + p.Flags |= AlwaysExpSign + p.doNotTerminate = true + return p.exponent + case '0': + p.MinExponentDigits++ + return p.exponent + } + // termination condition + if p.MinExponentDigits == 0 { + p.setError(errors.New("format: need at least one digit")) + } + return nil +} diff --git a/vendor/golang.org/x/text/internal/number/roundingmode_string.go b/vendor/golang.org/x/text/internal/number/roundingmode_string.go new file mode 100644 index 00000000000..bcc22471db8 --- /dev/null +++ b/vendor/golang.org/x/text/internal/number/roundingmode_string.go @@ -0,0 +1,30 @@ +// Code generated by "stringer -type RoundingMode"; DO NOT EDIT. + +package number + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[ToNearestEven-0] + _ = x[ToNearestZero-1] + _ = x[ToNearestAway-2] + _ = x[ToPositiveInf-3] + _ = x[ToNegativeInf-4] + _ = x[ToZero-5] + _ = x[AwayFromZero-6] + _ = x[numModes-7] +} + +const _RoundingMode_name = "ToNearestEvenToNearestZeroToNearestAwayToPositiveInfToNegativeInfToZeroAwayFromZeronumModes" + +var _RoundingMode_index = [...]uint8{0, 13, 26, 39, 52, 65, 71, 83, 91} + +func (i RoundingMode) String() string { + if i >= RoundingMode(len(_RoundingMode_index)-1) { + return "RoundingMode(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _RoundingMode_name[_RoundingMode_index[i]:_RoundingMode_index[i+1]] +} diff --git a/vendor/golang.org/x/text/internal/number/tables.go b/vendor/golang.org/x/text/internal/number/tables.go new file mode 100644 index 00000000000..8efce81b562 --- /dev/null +++ b/vendor/golang.org/x/text/internal/number/tables.go @@ -0,0 +1,1219 @@ +// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. + +package number + +import "golang.org/x/text/internal/stringset" + +// CLDRVersion is the CLDR version from which the tables in this package are derived. +const CLDRVersion = "32" + +var numSysData = []systemData{ // 59 elements + 0: {id: 0x0, digitSize: 0x1, zero: [4]uint8{0x30, 0x0, 0x0, 0x0}}, + 1: {id: 0x1, digitSize: 0x4, zero: [4]uint8{0xf0, 0x9e, 0xa5, 0x90}}, + 2: {id: 0x2, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x9c, 0xb0}}, + 3: {id: 0x3, digitSize: 0x2, zero: [4]uint8{0xd9, 0xa0, 0x0, 0x0}}, + 4: {id: 0x4, digitSize: 0x2, zero: [4]uint8{0xdb, 0xb0, 0x0, 0x0}}, + 5: {id: 0x5, digitSize: 0x3, zero: [4]uint8{0xe1, 0xad, 0x90, 0x0}}, + 6: {id: 0x6, digitSize: 0x3, zero: [4]uint8{0xe0, 0xa7, 0xa6, 0x0}}, + 7: {id: 0x7, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0xb1, 0x90}}, + 8: {id: 0x8, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x81, 0xa6}}, + 9: {id: 0x9, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x84, 0xb6}}, + 10: {id: 0xa, digitSize: 0x3, zero: [4]uint8{0xea, 0xa9, 0x90, 0x0}}, + 11: {id: 0xb, digitSize: 0x3, zero: [4]uint8{0xe0, 0xa5, 0xa6, 0x0}}, + 12: {id: 0xc, digitSize: 0x3, zero: [4]uint8{0xef, 0xbc, 0x90, 0x0}}, + 13: {id: 0xd, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0xb5, 0x90}}, + 14: {id: 0xe, digitSize: 0x3, zero: [4]uint8{0xe0, 0xab, 0xa6, 0x0}}, + 15: {id: 0xf, digitSize: 0x3, zero: [4]uint8{0xe0, 0xa9, 0xa6, 0x0}}, + 16: {id: 0x10, digitSize: 0x4, zero: [4]uint8{0xf0, 0x96, 0xad, 0x90}}, + 17: {id: 0x11, digitSize: 0x3, zero: [4]uint8{0xea, 0xa7, 0x90, 0x0}}, + 18: {id: 0x12, digitSize: 0x3, zero: [4]uint8{0xea, 0xa4, 0x80, 0x0}}, + 19: {id: 0x13, digitSize: 0x3, zero: [4]uint8{0xe1, 0x9f, 0xa0, 0x0}}, + 20: {id: 0x14, digitSize: 0x3, zero: [4]uint8{0xe0, 0xb3, 0xa6, 0x0}}, + 21: {id: 0x15, digitSize: 0x3, zero: [4]uint8{0xe1, 0xaa, 0x80, 0x0}}, + 22: {id: 0x16, digitSize: 0x3, zero: [4]uint8{0xe1, 0xaa, 0x90, 0x0}}, + 23: {id: 0x17, digitSize: 0x3, zero: [4]uint8{0xe0, 0xbb, 0x90, 0x0}}, + 24: {id: 0x18, digitSize: 0x3, zero: [4]uint8{0xe1, 0xb1, 0x80, 0x0}}, + 25: {id: 0x19, digitSize: 0x3, zero: [4]uint8{0xe1, 0xa5, 0x86, 0x0}}, + 26: {id: 0x1a, digitSize: 0x4, zero: [4]uint8{0xf0, 0x9d, 0x9f, 0x8e}}, + 27: {id: 0x1b, digitSize: 0x4, zero: [4]uint8{0xf0, 0x9d, 0x9f, 0x98}}, + 28: {id: 0x1c, digitSize: 0x4, zero: [4]uint8{0xf0, 0x9d, 0x9f, 0xb6}}, + 29: {id: 0x1d, digitSize: 0x4, zero: [4]uint8{0xf0, 0x9d, 0x9f, 0xac}}, + 30: {id: 0x1e, digitSize: 0x4, zero: [4]uint8{0xf0, 0x9d, 0x9f, 0xa2}}, + 31: {id: 0x1f, digitSize: 0x3, zero: [4]uint8{0xe0, 0xb5, 0xa6, 0x0}}, + 32: {id: 0x20, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x99, 0x90}}, + 33: {id: 0x21, digitSize: 0x3, zero: [4]uint8{0xe1, 0xa0, 0x90, 0x0}}, + 34: {id: 0x22, digitSize: 0x4, zero: [4]uint8{0xf0, 0x96, 0xa9, 0xa0}}, + 35: {id: 0x23, digitSize: 0x3, zero: [4]uint8{0xea, 0xaf, 0xb0, 0x0}}, + 36: {id: 0x24, digitSize: 0x3, zero: [4]uint8{0xe1, 0x81, 0x80, 0x0}}, + 37: {id: 0x25, digitSize: 0x3, zero: [4]uint8{0xe1, 0x82, 0x90, 0x0}}, + 38: {id: 0x26, digitSize: 0x3, zero: [4]uint8{0xea, 0xa7, 0xb0, 0x0}}, + 39: {id: 0x27, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x91, 0x90}}, + 40: {id: 0x28, digitSize: 0x2, zero: [4]uint8{0xdf, 0x80, 0x0, 0x0}}, + 41: {id: 0x29, digitSize: 0x3, zero: [4]uint8{0xe1, 0xb1, 0x90, 0x0}}, + 42: {id: 0x2a, digitSize: 0x3, zero: [4]uint8{0xe0, 0xad, 0xa6, 0x0}}, + 43: {id: 0x2b, digitSize: 0x4, zero: [4]uint8{0xf0, 0x90, 0x92, 0xa0}}, + 44: {id: 0x2c, digitSize: 0x3, zero: [4]uint8{0xea, 0xa3, 0x90, 0x0}}, + 45: {id: 0x2d, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x87, 0x90}}, + 46: {id: 0x2e, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x8b, 0xb0}}, + 47: {id: 0x2f, digitSize: 0x3, zero: [4]uint8{0xe0, 0xb7, 0xa6, 0x0}}, + 48: {id: 0x30, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x83, 0xb0}}, + 49: {id: 0x31, digitSize: 0x3, zero: [4]uint8{0xe1, 0xae, 0xb0, 0x0}}, + 50: {id: 0x32, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x9b, 0x80}}, + 51: {id: 0x33, digitSize: 0x3, zero: [4]uint8{0xe1, 0xa7, 0x90, 0x0}}, + 52: {id: 0x34, digitSize: 0x3, zero: [4]uint8{0xe0, 0xaf, 0xa6, 0x0}}, + 53: {id: 0x35, digitSize: 0x3, zero: [4]uint8{0xe0, 0xb1, 0xa6, 0x0}}, + 54: {id: 0x36, digitSize: 0x3, zero: [4]uint8{0xe0, 0xb9, 0x90, 0x0}}, + 55: {id: 0x37, digitSize: 0x3, zero: [4]uint8{0xe0, 0xbc, 0xa0, 0x0}}, + 56: {id: 0x38, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x93, 0x90}}, + 57: {id: 0x39, digitSize: 0x3, zero: [4]uint8{0xea, 0x98, 0xa0, 0x0}}, + 58: {id: 0x3a, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0xa3, 0xa0}}, +} // Size: 378 bytes + +const ( + numAdlm = 0x1 + numAhom = 0x2 + numArab = 0x3 + numArabext = 0x4 + numArmn = 0x3b + numArmnlow = 0x3c + numBali = 0x5 + numBeng = 0x6 + numBhks = 0x7 + numBrah = 0x8 + numCakm = 0x9 + numCham = 0xa + numCyrl = 0x3d + numDeva = 0xb + numEthi = 0x3e + numFullwide = 0xc + numGeor = 0x3f + numGonm = 0xd + numGrek = 0x40 + numGreklow = 0x41 + numGujr = 0xe + numGuru = 0xf + numHanidays = 0x42 + numHanidec = 0x43 + numHans = 0x44 + numHansfin = 0x45 + numHant = 0x46 + numHantfin = 0x47 + numHebr = 0x48 + numHmng = 0x10 + numJava = 0x11 + numJpan = 0x49 + numJpanfin = 0x4a + numKali = 0x12 + numKhmr = 0x13 + numKnda = 0x14 + numLana = 0x15 + numLanatham = 0x16 + numLaoo = 0x17 + numLatn = 0x0 + numLepc = 0x18 + numLimb = 0x19 + numMathbold = 0x1a + numMathdbl = 0x1b + numMathmono = 0x1c + numMathsanb = 0x1d + numMathsans = 0x1e + numMlym = 0x1f + numModi = 0x20 + numMong = 0x21 + numMroo = 0x22 + numMtei = 0x23 + numMymr = 0x24 + numMymrshan = 0x25 + numMymrtlng = 0x26 + numNewa = 0x27 + numNkoo = 0x28 + numOlck = 0x29 + numOrya = 0x2a + numOsma = 0x2b + numRoman = 0x4b + numRomanlow = 0x4c + numSaur = 0x2c + numShrd = 0x2d + numSind = 0x2e + numSinh = 0x2f + numSora = 0x30 + numSund = 0x31 + numTakr = 0x32 + numTalu = 0x33 + numTaml = 0x4d + numTamldec = 0x34 + numTelu = 0x35 + numThai = 0x36 + numTibt = 0x37 + numTirh = 0x38 + numVaii = 0x39 + numWara = 0x3a + numNumberSystems +) + +var systemMap = map[string]system{ + "adlm": numAdlm, + "ahom": numAhom, + "arab": numArab, + "arabext": numArabext, + "armn": numArmn, + "armnlow": numArmnlow, + "bali": numBali, + "beng": numBeng, + "bhks": numBhks, + "brah": numBrah, + "cakm": numCakm, + "cham": numCham, + "cyrl": numCyrl, + "deva": numDeva, + "ethi": numEthi, + "fullwide": numFullwide, + "geor": numGeor, + "gonm": numGonm, + "grek": numGrek, + "greklow": numGreklow, + "gujr": numGujr, + "guru": numGuru, + "hanidays": numHanidays, + "hanidec": numHanidec, + "hans": numHans, + "hansfin": numHansfin, + "hant": numHant, + "hantfin": numHantfin, + "hebr": numHebr, + "hmng": numHmng, + "java": numJava, + "jpan": numJpan, + "jpanfin": numJpanfin, + "kali": numKali, + "khmr": numKhmr, + "knda": numKnda, + "lana": numLana, + "lanatham": numLanatham, + "laoo": numLaoo, + "latn": numLatn, + "lepc": numLepc, + "limb": numLimb, + "mathbold": numMathbold, + "mathdbl": numMathdbl, + "mathmono": numMathmono, + "mathsanb": numMathsanb, + "mathsans": numMathsans, + "mlym": numMlym, + "modi": numModi, + "mong": numMong, + "mroo": numMroo, + "mtei": numMtei, + "mymr": numMymr, + "mymrshan": numMymrshan, + "mymrtlng": numMymrtlng, + "newa": numNewa, + "nkoo": numNkoo, + "olck": numOlck, + "orya": numOrya, + "osma": numOsma, + "roman": numRoman, + "romanlow": numRomanlow, + "saur": numSaur, + "shrd": numShrd, + "sind": numSind, + "sinh": numSinh, + "sora": numSora, + "sund": numSund, + "takr": numTakr, + "talu": numTalu, + "taml": numTaml, + "tamldec": numTamldec, + "telu": numTelu, + "thai": numThai, + "tibt": numTibt, + "tirh": numTirh, + "vaii": numVaii, + "wara": numWara, +} + +var symIndex = [][12]uint8{ // 81 elements + 0: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb}, + 1: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb}, + 2: [12]uint8{0x0, 0x1, 0x2, 0xd, 0xe, 0xf, 0x6, 0x7, 0x8, 0x9, 0x10, 0xb}, + 3: [12]uint8{0x1, 0x0, 0x2, 0xd, 0xe, 0xf, 0x6, 0x7, 0x8, 0x9, 0x10, 0xb}, + 4: [12]uint8{0x0, 0x1, 0x2, 0x11, 0xe, 0xf, 0x6, 0x7, 0x8, 0x9, 0x10, 0xb}, + 5: [12]uint8{0x1, 0x0, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x12, 0xb}, + 6: [12]uint8{0x1, 0x0, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb}, + 7: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x13, 0xb}, + 8: [12]uint8{0x0, 0x1, 0x2, 0x3, 0xe, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb}, + 9: [12]uint8{0x1, 0x0, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0x0}, + 10: [12]uint8{0x1, 0x0, 0x2, 0x3, 0x4, 0x5, 0x6, 0x14, 0x8, 0x9, 0xa, 0xb}, + 11: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x14, 0x8, 0x9, 0xa, 0xb}, + 12: [12]uint8{0x0, 0x15, 0x2, 0x3, 0x4, 0x5, 0x6, 0x14, 0x8, 0x9, 0xa, 0xb}, + 13: [12]uint8{0x0, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb}, + 14: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x16, 0xb}, + 15: [12]uint8{0x1, 0x0, 0x2, 0x3, 0x4, 0x5, 0x17, 0x7, 0x8, 0x9, 0xa, 0xb}, + 16: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x17, 0x7, 0x8, 0x9, 0xa, 0x0}, + 17: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x17, 0x7, 0x8, 0x9, 0xa, 0xb}, + 18: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0x0}, + 19: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x18, 0x7, 0x8, 0x9, 0xa, 0xb}, + 20: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x19, 0x1a, 0xa, 0xb}, + 21: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x1b, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb}, + 22: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x1b, 0x18, 0x7, 0x8, 0x9, 0xa, 0xb}, + 23: [12]uint8{0x1, 0x0, 0x2, 0x3, 0x4, 0x1b, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb}, + 24: [12]uint8{0x0, 0x1, 0x2, 0x3, 0xe, 0x1c, 0x6, 0x7, 0x8, 0x9, 0x1d, 0xb}, + 25: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x1b, 0x6, 0x7, 0x8, 0x9, 0x1e, 0x0}, + 26: [12]uint8{0x0, 0x15, 0x2, 0x3, 0x4, 0x1b, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb}, + 27: [12]uint8{0x0, 0x1, 0x2, 0x3, 0xe, 0xf, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb}, + 28: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x1f, 0xb}, + 29: [12]uint8{0x0, 0x15, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb}, + 30: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x20, 0xb}, + 31: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x21, 0x7, 0x8, 0x9, 0x22, 0xb}, + 32: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x23, 0xb}, + 33: [12]uint8{0x1, 0x0, 0x2, 0x3, 0x4, 0x1b, 0x18, 0x14, 0x8, 0x9, 0x24, 0xb}, + 34: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x1b, 0x18, 0x7, 0x8, 0x9, 0x24, 0xb}, + 35: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x25, 0xb}, + 36: [12]uint8{0x1, 0x0, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x26, 0xb}, + 37: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x27, 0xb}, + 38: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x28, 0xb}, + 39: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x29, 0xb}, + 40: [12]uint8{0x1, 0x0, 0x2, 0x3, 0xe, 0x1c, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb}, + 41: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x2a, 0xb}, + 42: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x2b, 0xb}, + 43: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x1b, 0x2c, 0x14, 0x8, 0x9, 0x24, 0xb}, + 44: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0x0}, + 45: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x17, 0x7, 0x8, 0x9, 0xa, 0xb}, + 46: [12]uint8{0x1, 0x0, 0x2, 0x3, 0x4, 0x1b, 0x17, 0x7, 0x8, 0x9, 0xa, 0xb}, + 47: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x2d, 0x0}, + 48: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x2e, 0xb}, + 49: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x2f, 0xb}, + 50: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x30, 0x7, 0x8, 0x9, 0xa, 0xb}, + 51: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x31, 0xb}, + 52: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x32, 0xb}, + 53: [12]uint8{0x1, 0x15, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb}, + 54: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x33, 0xb}, + 55: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x34, 0xb}, + 56: [12]uint8{0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x7, 0x3c, 0x9, 0xa, 0xb}, + 57: [12]uint8{0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x7, 0x3c, 0x9, 0x3d, 0xb}, + 58: [12]uint8{0x35, 0x36, 0x37, 0x11, 0x3e, 0x3f, 0x3b, 0x7, 0x3c, 0x9, 0xa, 0xb}, + 59: [12]uint8{0x35, 0x36, 0x37, 0x11, 0x39, 0x3a, 0x3b, 0x7, 0x3c, 0x9, 0xa, 0xb}, + 60: [12]uint8{0x35, 0x36, 0x37, 0x11, 0x39, 0x40, 0x3b, 0x7, 0x3c, 0x9, 0xa, 0xb}, + 61: [12]uint8{0x35, 0x36, 0x37, 0x41, 0x3e, 0x3f, 0x3b, 0x7, 0x3c, 0x9, 0xa, 0xb}, + 62: [12]uint8{0x35, 0x36, 0x37, 0x38, 0x3e, 0x3f, 0x3b, 0x7, 0x3c, 0x9, 0xa, 0xb}, + 63: [12]uint8{0x35, 0xc, 0x37, 0x38, 0x39, 0x42, 0x3b, 0x7, 0x3c, 0x9, 0xa, 0x0}, + 64: [12]uint8{0x35, 0xc, 0x37, 0x38, 0x39, 0x42, 0x43, 0x7, 0x44, 0x9, 0x24, 0xb}, + 65: [12]uint8{0x35, 0x36, 0x37, 0x38, 0x39, 0x5, 0x3b, 0x7, 0x3c, 0x9, 0x33, 0xb}, + 66: [12]uint8{0x35, 0x36, 0x37, 0x11, 0x45, 0x46, 0x43, 0x7, 0x3c, 0x9, 0xa, 0x35}, + 67: [12]uint8{0x35, 0x36, 0x37, 0x11, 0xe, 0x1c, 0x43, 0x7, 0x3c, 0x9, 0x1d, 0xb}, + 68: [12]uint8{0x35, 0x36, 0x37, 0x11, 0xe, 0x1c, 0x43, 0x7, 0x3c, 0x9, 0xa, 0x35}, + 69: [12]uint8{0x35, 0x36, 0x37, 0x11, 0x45, 0x5, 0x43, 0x7, 0x3c, 0x9, 0xa, 0x35}, + 70: [12]uint8{0x1, 0xc, 0x37, 0x11, 0x45, 0x47, 0x43, 0x7, 0x3c, 0x9, 0xa, 0x0}, + 71: [12]uint8{0x35, 0x1, 0x37, 0x11, 0x4, 0x5, 0x43, 0x7, 0x3c, 0x9, 0xa, 0x35}, + 72: [12]uint8{0x1, 0xc, 0x37, 0x11, 0x45, 0x47, 0x43, 0x7, 0x3c, 0x9, 0x24, 0xb}, + 73: [12]uint8{0x35, 0x36, 0x2, 0x3, 0x45, 0x46, 0x43, 0x7, 0x8, 0x9, 0xa, 0x35}, + 74: [12]uint8{0x35, 0x36, 0x37, 0x11, 0x4, 0x5, 0x43, 0x7, 0x3c, 0x9, 0x31, 0x35}, + 75: [12]uint8{0x35, 0x36, 0x37, 0x11, 0x4, 0x5, 0x43, 0x7, 0x3c, 0x9, 0x32, 0x35}, + 76: [12]uint8{0x35, 0x36, 0x37, 0x11, 0x48, 0x46, 0x43, 0x7, 0x3c, 0x9, 0x33, 0x35}, + 77: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0x49}, + 78: [12]uint8{0x0, 0x1, 0x4a, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x28, 0xb}, + 79: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x4b, 0xb}, + 80: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x4c, 0x4d, 0xb}, +} // Size: 996 bytes + +var symData = stringset.Set{ + Data: "" + // Size: 599 bytes + ".,;%+-E׉∞NaN:\u00a0\u200e%\u200e\u200e+\u200e-ليس\u00a0رقمًا٪NDТерхьаш" + + "\u00a0дац·’mnne×10^0/00INF−\u200e−ناعددepälukuՈչԹარ\u00a0არის\u00a0რიცხვ" + + "იZMdMсан\u00a0емес¤¤¤сан\u00a0эмесບໍ່\u200bແມ່ນ\u200bໂຕ\u200bເລກNSဂဏန်" + + "းမဟုတ်သောННне\u00a0числочыыһыла\u00a0буотах·10^epilohosan\u00a0dälTFЕs" + + "on\u00a0emasҳақиқий\u00a0сон\u00a0эмас非數值非数值٫٬؛٪\u061c\u061c+\u061c-اس؉ل" + + "يس\u00a0رقم\u200f+\u200f-\u200f−٪\u200f\u061c−×۱۰^؉\u200f\u200e+\u200e" + + "\u200e-\u200e\u200e−\u200e+\u200e:၊ཨང་མེན་གྲངས་མེདཨང་མད", + Index: []uint16{ // 79 elements + // Entry 0 - 3F + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, + 0x0009, 0x000c, 0x000f, 0x0012, 0x0013, 0x0015, 0x001c, 0x0020, + 0x0024, 0x0036, 0x0038, 0x003a, 0x0050, 0x0052, 0x0055, 0x0058, + 0x0059, 0x005e, 0x0062, 0x0065, 0x0068, 0x006e, 0x0078, 0x0080, + 0x0086, 0x00ae, 0x00af, 0x00b2, 0x00c2, 0x00c8, 0x00d8, 0x0105, + 0x0107, 0x012e, 0x0132, 0x0142, 0x015e, 0x0163, 0x016a, 0x0173, + 0x0175, 0x0177, 0x0180, 0x01a0, 0x01a9, 0x01b2, 0x01b4, 0x01b6, + 0x01b8, 0x01bc, 0x01bf, 0x01c2, 0x01c6, 0x01c8, 0x01d6, 0x01da, + // Entry 40 - 7F + 0x01de, 0x01e4, 0x01e9, 0x01ee, 0x01f5, 0x01fa, 0x0201, 0x0208, + 0x0211, 0x0215, 0x0218, 0x021b, 0x0230, 0x0248, 0x0257, + }, +} // Size: 797 bytes + +// langToDefaults maps a compact language index to the default numbering system +// and default symbol set +var langToDefaults = [775]symOffset{ + // Entry 0 - 3F + 0x8000, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0000, + 0x0000, 0x0000, 0x8003, 0x0002, 0x0002, 0x0002, 0x0002, 0x0003, + 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, + 0x0003, 0x0003, 0x0003, 0x0003, 0x0002, 0x0002, 0x0002, 0x0004, + 0x0002, 0x0004, 0x0002, 0x0002, 0x0002, 0x0003, 0x0002, 0x0000, + 0x8005, 0x0000, 0x0000, 0x0000, 0x8006, 0x0005, 0x0006, 0x0006, + 0x0006, 0x0006, 0x0006, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000, + // Entry 40 - 7F + 0x8009, 0x0000, 0x0000, 0x800a, 0x0000, 0x0000, 0x800c, 0x0001, + 0x0000, 0x0000, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, + 0x0006, 0x0006, 0x0006, 0x0006, 0x800e, 0x0000, 0x0000, 0x0007, + 0x0007, 0x0000, 0x0000, 0x0000, 0x0000, 0x800f, 0x0008, 0x0008, + 0x8011, 0x0001, 0x0001, 0x0001, 0x803c, 0x0000, 0x0009, 0x0009, + 0x0009, 0x0000, 0x0000, 0x000a, 0x000b, 0x000a, 0x000c, 0x000a, + 0x000a, 0x000c, 0x000a, 0x000d, 0x000d, 0x000a, 0x000a, 0x0001, + 0x0001, 0x0000, 0x0001, 0x0001, 0x803f, 0x0000, 0x0000, 0x0000, + // Entry 80 - BF + 0x000e, 0x000e, 0x000e, 0x000f, 0x000f, 0x000f, 0x0000, 0x0000, + 0x0006, 0x0000, 0x0000, 0x0000, 0x000a, 0x0010, 0x0000, 0x0006, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0011, 0x0000, 0x000a, + 0x0000, 0x0000, 0x0000, 0x0000, 0x000a, 0x0000, 0x0009, 0x0000, + 0x0000, 0x0012, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + // Entry C0 - FF + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0013, 0x0000, + 0x0000, 0x000f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000, 0x0015, + 0x0015, 0x0006, 0x0000, 0x0006, 0x0006, 0x0000, 0x0000, 0x0006, + 0x0006, 0x0001, 0x0000, 0x0000, 0x0006, 0x0006, 0x0006, 0x0006, + // Entry 100 - 13F + 0x0000, 0x0000, 0x0006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0006, + 0x0000, 0x0006, 0x0000, 0x0000, 0x0006, 0x0006, 0x0016, 0x0016, + 0x0017, 0x0017, 0x0001, 0x0001, 0x8041, 0x0018, 0x0018, 0x0001, + 0x0001, 0x0001, 0x0001, 0x0001, 0x0019, 0x0019, 0x0000, 0x0000, + 0x0017, 0x0017, 0x0017, 0x8044, 0x0001, 0x0001, 0x0001, 0x0001, + 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, + 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, + 0x0001, 0x0001, 0x0006, 0x0006, 0x0001, 0x0001, 0x0001, 0x0001, + // Entry 140 - 17F + 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, + 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, + 0x0001, 0x0001, 0x0006, 0x0006, 0x0006, 0x0006, 0x0000, 0x0000, + 0x8047, 0x0000, 0x0006, 0x0006, 0x001a, 0x001a, 0x001a, 0x001a, + 0x804a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x804c, 0x001b, 0x0000, + 0x0000, 0x0006, 0x0006, 0x0006, 0x000a, 0x000a, 0x0001, 0x0001, + 0x001c, 0x001c, 0x0009, 0x0009, 0x804f, 0x0000, 0x0000, 0x0000, + // Entry 180 - 1BF + 0x0000, 0x0000, 0x8052, 0x0006, 0x0006, 0x001d, 0x0006, 0x0006, + 0x0006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0006, 0x0006, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x001e, 0x001e, 0x001f, + 0x001f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, + 0x0001, 0x000d, 0x000d, 0x0000, 0x0000, 0x0020, 0x0020, 0x0006, + 0x0006, 0x0021, 0x0021, 0x0000, 0x0000, 0x0006, 0x0006, 0x0000, + 0x0000, 0x8054, 0x0000, 0x0000, 0x0000, 0x0000, 0x8056, 0x001b, + 0x0000, 0x0000, 0x0001, 0x0001, 0x0022, 0x0022, 0x0000, 0x0000, + // Entry 1C0 - 1FF + 0x0000, 0x0023, 0x0023, 0x0000, 0x0000, 0x0006, 0x0006, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, + 0x0024, 0x0024, 0x8058, 0x0000, 0x0000, 0x0016, 0x0016, 0x0006, + 0x0006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0025, 0x0025, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x000d, 0x000d, 0x0000, 0x0000, + 0x0006, 0x0006, 0x0000, 0x0000, 0x0006, 0x0006, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x805a, 0x0000, 0x0000, 0x0006, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0006, 0x0006, 0x805b, 0x0026, 0x805d, + // Entry 200 - 23F + 0x0000, 0x0000, 0x0000, 0x0000, 0x805e, 0x0015, 0x0015, 0x0000, + 0x0000, 0x0006, 0x0006, 0x0006, 0x8061, 0x0000, 0x0000, 0x8062, + 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0001, + 0x0001, 0x0015, 0x0015, 0x0006, 0x0006, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0027, 0x0027, 0x0027, 0x8065, 0x8067, + 0x001b, 0x0000, 0x0000, 0x0000, 0x0001, 0x0001, 0x0001, 0x0001, + 0x8069, 0x0028, 0x0006, 0x0001, 0x0006, 0x0001, 0x0001, 0x0001, + // Entry 240 - 27F + 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, + 0x0006, 0x0000, 0x0000, 0x001a, 0x001a, 0x0006, 0x0006, 0x0006, + 0x0006, 0x0006, 0x0000, 0x0000, 0x0029, 0x0029, 0x0029, 0x0029, + 0x0029, 0x0029, 0x0029, 0x0006, 0x0006, 0x0000, 0x0000, 0x002a, + 0x002a, 0x0000, 0x0000, 0x0000, 0x0000, 0x806b, 0x0000, 0x0000, + 0x002b, 0x002b, 0x002b, 0x002b, 0x0006, 0x0006, 0x000d, 0x000d, + 0x0006, 0x0006, 0x0000, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, + 0x002c, 0x002c, 0x002d, 0x002d, 0x002e, 0x002e, 0x0000, 0x0000, + // Entry 280 - 2BF + 0x0000, 0x002f, 0x002f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0001, 0x0001, 0x0001, 0x0001, 0x0006, + 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, + 0x0006, 0x0006, 0x0000, 0x0000, 0x0000, 0x806d, 0x0022, 0x0022, + 0x0022, 0x0000, 0x0006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0030, 0x0030, 0x0000, 0x0000, 0x8071, 0x0031, 0x0006, + // Entry 2C0 - 2FF + 0x0006, 0x0006, 0x0000, 0x0001, 0x0001, 0x000d, 0x000d, 0x0001, + 0x0001, 0x0000, 0x0000, 0x0032, 0x0032, 0x8074, 0x8076, 0x001b, + 0x8077, 0x8079, 0x0028, 0x807b, 0x0034, 0x0033, 0x0033, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0006, 0x0006, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0035, 0x0035, 0x0006, 0x0006, + 0x0000, 0x0000, 0x0000, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0036, 0x0037, 0x0037, 0x0036, 0x0036, 0x0001, + 0x0001, 0x807d, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8080, + // Entry 300 - 33F + 0x0036, 0x0036, 0x0036, 0x0000, 0x0000, 0x0006, 0x0014, +} // Size: 1550 bytes + +// langToAlt is a list of numbering system and symbol set pairs, sorted and +// marked by compact language index. +var langToAlt = []altSymData{ // 131 elements + 1: {compactTag: 0x0, symIndex: 0x38, system: 0x3}, + 2: {compactTag: 0x0, symIndex: 0x42, system: 0x4}, + 3: {compactTag: 0xa, symIndex: 0x39, system: 0x3}, + 4: {compactTag: 0xa, symIndex: 0x2, system: 0x0}, + 5: {compactTag: 0x28, symIndex: 0x0, system: 0x6}, + 6: {compactTag: 0x2c, symIndex: 0x5, system: 0x0}, + 7: {compactTag: 0x2c, symIndex: 0x3a, system: 0x3}, + 8: {compactTag: 0x2c, symIndex: 0x42, system: 0x4}, + 9: {compactTag: 0x40, symIndex: 0x0, system: 0x6}, + 10: {compactTag: 0x43, symIndex: 0x0, system: 0x0}, + 11: {compactTag: 0x43, symIndex: 0x4f, system: 0x37}, + 12: {compactTag: 0x46, symIndex: 0x1, system: 0x0}, + 13: {compactTag: 0x46, symIndex: 0x38, system: 0x3}, + 14: {compactTag: 0x54, symIndex: 0x0, system: 0x9}, + 15: {compactTag: 0x5d, symIndex: 0x3a, system: 0x3}, + 16: {compactTag: 0x5d, symIndex: 0x8, system: 0x0}, + 17: {compactTag: 0x60, symIndex: 0x1, system: 0x0}, + 18: {compactTag: 0x60, symIndex: 0x38, system: 0x3}, + 19: {compactTag: 0x60, symIndex: 0x42, system: 0x4}, + 20: {compactTag: 0x60, symIndex: 0x0, system: 0x5}, + 21: {compactTag: 0x60, symIndex: 0x0, system: 0x6}, + 22: {compactTag: 0x60, symIndex: 0x0, system: 0x8}, + 23: {compactTag: 0x60, symIndex: 0x0, system: 0x9}, + 24: {compactTag: 0x60, symIndex: 0x0, system: 0xa}, + 25: {compactTag: 0x60, symIndex: 0x0, system: 0xb}, + 26: {compactTag: 0x60, symIndex: 0x0, system: 0xc}, + 27: {compactTag: 0x60, symIndex: 0x0, system: 0xd}, + 28: {compactTag: 0x60, symIndex: 0x0, system: 0xe}, + 29: {compactTag: 0x60, symIndex: 0x0, system: 0xf}, + 30: {compactTag: 0x60, symIndex: 0x0, system: 0x11}, + 31: {compactTag: 0x60, symIndex: 0x0, system: 0x12}, + 32: {compactTag: 0x60, symIndex: 0x0, system: 0x13}, + 33: {compactTag: 0x60, symIndex: 0x0, system: 0x14}, + 34: {compactTag: 0x60, symIndex: 0x0, system: 0x15}, + 35: {compactTag: 0x60, symIndex: 0x0, system: 0x16}, + 36: {compactTag: 0x60, symIndex: 0x0, system: 0x17}, + 37: {compactTag: 0x60, symIndex: 0x0, system: 0x18}, + 38: {compactTag: 0x60, symIndex: 0x0, system: 0x19}, + 39: {compactTag: 0x60, symIndex: 0x0, system: 0x1f}, + 40: {compactTag: 0x60, symIndex: 0x0, system: 0x21}, + 41: {compactTag: 0x60, symIndex: 0x0, system: 0x23}, + 42: {compactTag: 0x60, symIndex: 0x0, system: 0x24}, + 43: {compactTag: 0x60, symIndex: 0x0, system: 0x25}, + 44: {compactTag: 0x60, symIndex: 0x0, system: 0x28}, + 45: {compactTag: 0x60, symIndex: 0x0, system: 0x29}, + 46: {compactTag: 0x60, symIndex: 0x0, system: 0x2a}, + 47: {compactTag: 0x60, symIndex: 0x0, system: 0x2b}, + 48: {compactTag: 0x60, symIndex: 0x0, system: 0x2c}, + 49: {compactTag: 0x60, symIndex: 0x0, system: 0x2d}, + 50: {compactTag: 0x60, symIndex: 0x0, system: 0x30}, + 51: {compactTag: 0x60, symIndex: 0x0, system: 0x31}, + 52: {compactTag: 0x60, symIndex: 0x0, system: 0x32}, + 53: {compactTag: 0x60, symIndex: 0x0, system: 0x33}, + 54: {compactTag: 0x60, symIndex: 0x0, system: 0x34}, + 55: {compactTag: 0x60, symIndex: 0x0, system: 0x35}, + 56: {compactTag: 0x60, symIndex: 0x0, system: 0x36}, + 57: {compactTag: 0x60, symIndex: 0x0, system: 0x37}, + 58: {compactTag: 0x60, symIndex: 0x0, system: 0x39}, + 59: {compactTag: 0x60, symIndex: 0x0, system: 0x43}, + 60: {compactTag: 0x64, symIndex: 0x0, system: 0x0}, + 61: {compactTag: 0x64, symIndex: 0x38, system: 0x3}, + 62: {compactTag: 0x64, symIndex: 0x42, system: 0x4}, + 63: {compactTag: 0x7c, symIndex: 0x50, system: 0x37}, + 64: {compactTag: 0x7c, symIndex: 0x0, system: 0x0}, + 65: {compactTag: 0x114, symIndex: 0x43, system: 0x4}, + 66: {compactTag: 0x114, symIndex: 0x18, system: 0x0}, + 67: {compactTag: 0x114, symIndex: 0x3b, system: 0x3}, + 68: {compactTag: 0x123, symIndex: 0x1, system: 0x0}, + 69: {compactTag: 0x123, symIndex: 0x3c, system: 0x3}, + 70: {compactTag: 0x123, symIndex: 0x44, system: 0x4}, + 71: {compactTag: 0x158, symIndex: 0x0, system: 0x0}, + 72: {compactTag: 0x158, symIndex: 0x3b, system: 0x3}, + 73: {compactTag: 0x158, symIndex: 0x45, system: 0x4}, + 74: {compactTag: 0x160, symIndex: 0x0, system: 0x0}, + 75: {compactTag: 0x160, symIndex: 0x38, system: 0x3}, + 76: {compactTag: 0x16d, symIndex: 0x1b, system: 0x0}, + 77: {compactTag: 0x16d, symIndex: 0x0, system: 0x9}, + 78: {compactTag: 0x16d, symIndex: 0x0, system: 0xa}, + 79: {compactTag: 0x17c, symIndex: 0x0, system: 0x0}, + 80: {compactTag: 0x17c, symIndex: 0x3d, system: 0x3}, + 81: {compactTag: 0x17c, symIndex: 0x42, system: 0x4}, + 82: {compactTag: 0x182, symIndex: 0x6, system: 0x0}, + 83: {compactTag: 0x182, symIndex: 0x38, system: 0x3}, + 84: {compactTag: 0x1b1, symIndex: 0x0, system: 0x0}, + 85: {compactTag: 0x1b1, symIndex: 0x3e, system: 0x3}, + 86: {compactTag: 0x1b6, symIndex: 0x42, system: 0x4}, + 87: {compactTag: 0x1b6, symIndex: 0x1b, system: 0x0}, + 88: {compactTag: 0x1d2, symIndex: 0x42, system: 0x4}, + 89: {compactTag: 0x1d2, symIndex: 0x0, system: 0x0}, + 90: {compactTag: 0x1f3, symIndex: 0x0, system: 0xb}, + 91: {compactTag: 0x1fd, symIndex: 0x4e, system: 0x24}, + 92: {compactTag: 0x1fd, symIndex: 0x26, system: 0x0}, + 93: {compactTag: 0x1ff, symIndex: 0x42, system: 0x4}, + 94: {compactTag: 0x204, symIndex: 0x15, system: 0x0}, + 95: {compactTag: 0x204, symIndex: 0x3f, system: 0x3}, + 96: {compactTag: 0x204, symIndex: 0x46, system: 0x4}, + 97: {compactTag: 0x20c, symIndex: 0x0, system: 0xb}, + 98: {compactTag: 0x20f, symIndex: 0x6, system: 0x0}, + 99: {compactTag: 0x20f, symIndex: 0x38, system: 0x3}, + 100: {compactTag: 0x20f, symIndex: 0x42, system: 0x4}, + 101: {compactTag: 0x22e, symIndex: 0x0, system: 0x0}, + 102: {compactTag: 0x22e, symIndex: 0x47, system: 0x4}, + 103: {compactTag: 0x22f, symIndex: 0x42, system: 0x4}, + 104: {compactTag: 0x22f, symIndex: 0x1b, system: 0x0}, + 105: {compactTag: 0x238, symIndex: 0x42, system: 0x4}, + 106: {compactTag: 0x238, symIndex: 0x28, system: 0x0}, + 107: {compactTag: 0x265, symIndex: 0x38, system: 0x3}, + 108: {compactTag: 0x265, symIndex: 0x0, system: 0x0}, + 109: {compactTag: 0x29d, symIndex: 0x22, system: 0x0}, + 110: {compactTag: 0x29d, symIndex: 0x40, system: 0x3}, + 111: {compactTag: 0x29d, symIndex: 0x48, system: 0x4}, + 112: {compactTag: 0x29d, symIndex: 0x4d, system: 0xc}, + 113: {compactTag: 0x2bd, symIndex: 0x31, system: 0x0}, + 114: {compactTag: 0x2bd, symIndex: 0x3e, system: 0x3}, + 115: {compactTag: 0x2bd, symIndex: 0x42, system: 0x4}, + 116: {compactTag: 0x2cd, symIndex: 0x1b, system: 0x0}, + 117: {compactTag: 0x2cd, symIndex: 0x49, system: 0x4}, + 118: {compactTag: 0x2ce, symIndex: 0x49, system: 0x4}, + 119: {compactTag: 0x2d0, symIndex: 0x33, system: 0x0}, + 120: {compactTag: 0x2d0, symIndex: 0x4a, system: 0x4}, + 121: {compactTag: 0x2d1, symIndex: 0x42, system: 0x4}, + 122: {compactTag: 0x2d1, symIndex: 0x28, system: 0x0}, + 123: {compactTag: 0x2d3, symIndex: 0x34, system: 0x0}, + 124: {compactTag: 0x2d3, symIndex: 0x4b, system: 0x4}, + 125: {compactTag: 0x2f9, symIndex: 0x0, system: 0x0}, + 126: {compactTag: 0x2f9, symIndex: 0x38, system: 0x3}, + 127: {compactTag: 0x2f9, symIndex: 0x42, system: 0x4}, + 128: {compactTag: 0x2ff, symIndex: 0x36, system: 0x0}, + 129: {compactTag: 0x2ff, symIndex: 0x41, system: 0x3}, + 130: {compactTag: 0x2ff, symIndex: 0x4c, system: 0x4}, +} // Size: 810 bytes + +var tagToDecimal = []uint8{ // 775 elements + // Entry 0 - 3F + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x05, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + // Entry 40 - 7F + 0x05, 0x05, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x05, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x05, 0x05, 0x05, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x05, 0x05, 0x01, 0x01, + // Entry 80 - BF + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + // Entry C0 - FF + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + // Entry 100 - 13F + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + // Entry 140 - 17F + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x05, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, + 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + // Entry 180 - 1BF + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x05, 0x05, 0x05, 0x05, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + // Entry 1C0 - 1FF + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x05, + 0x01, 0x01, 0x01, 0x05, 0x05, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + // Entry 200 - 23F + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x05, 0x05, 0x01, 0x01, 0x01, 0x05, 0x01, + 0x01, 0x05, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + // Entry 240 - 27F + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + // Entry 280 - 2BF + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, + 0x05, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + // Entry 2C0 - 2FF + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + // Entry 300 - 33F + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, +} // Size: 799 bytes + +var tagToScientific = []uint8{ // 775 elements + // Entry 0 - 3F + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + // Entry 40 - 7F + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + // Entry 80 - BF + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + // Entry C0 - FF + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + // Entry 100 - 13F + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + // Entry 140 - 17F + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x0c, 0x0c, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x0c, + 0x0c, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + // Entry 180 - 1BF + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + // Entry 1C0 - 1FF + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x0d, 0x0d, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x0c, 0x0c, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + // Entry 200 - 23F + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x0c, 0x02, + 0x02, 0x0c, 0x0c, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + // Entry 240 - 27F + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x0d, 0x0d, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + // Entry 280 - 2BF + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + // Entry 2C0 - 2FF + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + // Entry 300 - 33F + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x09, +} // Size: 799 bytes + +var tagToPercent = []uint8{ // 775 elements + // Entry 0 - 3F + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x06, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + // Entry 40 - 7F + 0x06, 0x06, 0x06, 0x04, 0x04, 0x04, 0x03, 0x03, + 0x06, 0x06, 0x03, 0x04, 0x04, 0x03, 0x03, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x06, 0x06, 0x06, 0x03, + 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, + 0x03, 0x04, 0x04, 0x03, 0x03, 0x03, 0x04, 0x03, + 0x03, 0x04, 0x03, 0x04, 0x04, 0x03, 0x03, 0x03, + 0x03, 0x04, 0x04, 0x04, 0x07, 0x07, 0x04, 0x04, + // Entry 80 - BF + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x03, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x03, 0x04, 0x03, 0x04, + 0x04, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + // Entry C0 - FF + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + // Entry 100 - 13F + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, + 0x0b, 0x0b, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x04, 0x04, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + // Entry 140 - 17F + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x06, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x06, + 0x06, 0x04, 0x04, 0x04, 0x03, 0x03, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + // Entry 180 - 1BF + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x06, 0x06, 0x06, 0x06, + 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x04, 0x04, + // Entry 1C0 - 1FF + 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + // Entry 200 - 23F + 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x06, 0x06, 0x04, 0x04, 0x04, 0x06, 0x04, + 0x04, 0x06, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + // Entry 240 - 27F + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, + // Entry 280 - 2BF + 0x04, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, + 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x06, + 0x06, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x0e, + // Entry 2C0 - 2FF + 0x0e, 0x0e, 0x04, 0x03, 0x03, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, + 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + // Entry 300 - 33F + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0a, +} // Size: 799 bytes + +var formats = []Pattern{Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0, + MaxFractionDigits: 0, + Increment: 0x0, + IncrementScale: 0x0, + Mode: 0x0, + DigitShift: 0x0, + MinIntegerDigits: 0x0, + MaxIntegerDigits: 0x0, + MinFractionDigits: 0x0, + MinSignificantDigits: 0x0, + MinExponentDigits: 0x0}, + Affix: "", + Offset: 0x0, + NegOffset: 0x0, + PadRune: 0, + FormatWidth: 0x0, + GroupingSize: [2]uint8{0x0, + 0x0}, + Flags: 0x0}, + Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0, + MaxFractionDigits: 3, + Increment: 0x0, + IncrementScale: 0x0, + Mode: 0x0, + DigitShift: 0x0, + MinIntegerDigits: 0x1, + MaxIntegerDigits: 0x0, + MinFractionDigits: 0x0, + MinSignificantDigits: 0x0, + MinExponentDigits: 0x0}, + Affix: "", + Offset: 0x0, + NegOffset: 0x0, + PadRune: 0, + FormatWidth: 0x9, + GroupingSize: [2]uint8{0x3, + 0x0}, + Flags: 0x0}, + Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0, + MaxFractionDigits: 0, + Increment: 0x0, + IncrementScale: 0x0, + Mode: 0x0, + DigitShift: 0x0, + MinIntegerDigits: 0x0, + MaxIntegerDigits: 0x1, + MinFractionDigits: 0x0, + MinSignificantDigits: 0x0, + MinExponentDigits: 0x1}, + Affix: "", + Offset: 0x0, + NegOffset: 0x0, + PadRune: 0, + FormatWidth: 0x3, + GroupingSize: [2]uint8{0x0, + 0x0}, + Flags: 0x0}, + Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0, + MaxFractionDigits: 0, + Increment: 0x0, + IncrementScale: 0x0, + Mode: 0x0, + DigitShift: 0x2, + MinIntegerDigits: 0x1, + MaxIntegerDigits: 0x0, + MinFractionDigits: 0x0, + MinSignificantDigits: 0x0, + MinExponentDigits: 0x0}, + Affix: "\x00\x03\u00a0%", + Offset: 0x0, + NegOffset: 0x0, + PadRune: 0, + FormatWidth: 0x7, + GroupingSize: [2]uint8{0x3, + 0x0}, + Flags: 0x0}, + Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0, + MaxFractionDigits: 0, + Increment: 0x0, + IncrementScale: 0x0, + Mode: 0x0, + DigitShift: 0x2, + MinIntegerDigits: 0x1, + MaxIntegerDigits: 0x0, + MinFractionDigits: 0x0, + MinSignificantDigits: 0x0, + MinExponentDigits: 0x0}, + Affix: "\x00\x01%", + Offset: 0x0, + NegOffset: 0x0, + PadRune: 0, + FormatWidth: 0x6, + GroupingSize: [2]uint8{0x3, + 0x0}, + Flags: 0x0}, + Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0, + MaxFractionDigits: 3, + Increment: 0x0, + IncrementScale: 0x0, + Mode: 0x0, + DigitShift: 0x0, + MinIntegerDigits: 0x1, + MaxIntegerDigits: 0x0, + MinFractionDigits: 0x0, + MinSignificantDigits: 0x0, + MinExponentDigits: 0x0}, + Affix: "", + Offset: 0x0, + NegOffset: 0x0, + PadRune: 0, + FormatWidth: 0xc, + GroupingSize: [2]uint8{0x3, + 0x2}, + Flags: 0x0}, + Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0, + MaxFractionDigits: 0, + Increment: 0x0, + IncrementScale: 0x0, + Mode: 0x0, + DigitShift: 0x2, + MinIntegerDigits: 0x1, + MaxIntegerDigits: 0x0, + MinFractionDigits: 0x0, + MinSignificantDigits: 0x0, + MinExponentDigits: 0x0}, + Affix: "\x00\x01%", + Offset: 0x0, + NegOffset: 0x0, + PadRune: 0, + FormatWidth: 0x9, + GroupingSize: [2]uint8{0x3, + 0x2}, + Flags: 0x0}, + Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0, + MaxFractionDigits: 0, + Increment: 0x0, + IncrementScale: 0x0, + Mode: 0x0, + DigitShift: 0x2, + MinIntegerDigits: 0x1, + MaxIntegerDigits: 0x0, + MinFractionDigits: 0x0, + MinSignificantDigits: 0x0, + MinExponentDigits: 0x0}, + Affix: "\x00\x03\u00a0%", + Offset: 0x0, + NegOffset: 0x0, + PadRune: 0, + FormatWidth: 0xa, + GroupingSize: [2]uint8{0x3, + 0x2}, + Flags: 0x0}, + Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0, + MaxFractionDigits: 6, + Increment: 0x0, + IncrementScale: 0x0, + Mode: 0x0, + DigitShift: 0x0, + MinIntegerDigits: 0x1, + MaxIntegerDigits: 0x0, + MinFractionDigits: 0x0, + MinSignificantDigits: 0x0, + MinExponentDigits: 0x0}, + Affix: "", + Offset: 0x0, + NegOffset: 0x0, + PadRune: 0, + FormatWidth: 0x8, + GroupingSize: [2]uint8{0x0, + 0x0}, + Flags: 0x0}, + Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0, + MaxFractionDigits: 6, + Increment: 0x0, + IncrementScale: 0x0, + Mode: 0x0, + DigitShift: 0x0, + MinIntegerDigits: 0x1, + MaxIntegerDigits: 0x0, + MinFractionDigits: 0x6, + MinSignificantDigits: 0x0, + MinExponentDigits: 0x3}, + Affix: "", + Offset: 0x0, + NegOffset: 0x0, + PadRune: 0, + FormatWidth: 0xd, + GroupingSize: [2]uint8{0x0, + 0x0}, + Flags: 0x4}, + Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0, + MaxFractionDigits: 0, + Increment: 0x0, + IncrementScale: 0x0, + Mode: 0x0, + DigitShift: 0x2, + MinIntegerDigits: 0x1, + MaxIntegerDigits: 0x0, + MinFractionDigits: 0x0, + MinSignificantDigits: 0x0, + MinExponentDigits: 0x0}, + Affix: "\x00\x01%", + Offset: 0x0, + NegOffset: 0x0, + PadRune: 0, + FormatWidth: 0x2, + GroupingSize: [2]uint8{0x0, + 0x0}, + Flags: 0x0}, + Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0, + MaxFractionDigits: 0, + Increment: 0x0, + IncrementScale: 0x0, + Mode: 0x0, + DigitShift: 0x2, + MinIntegerDigits: 0x1, + MaxIntegerDigits: 0x0, + MinFractionDigits: 0x0, + MinSignificantDigits: 0x0, + MinExponentDigits: 0x0}, + Affix: "\x03%\u00a0\x00", + Offset: 0x0, + NegOffset: 0x0, + PadRune: 0, + FormatWidth: 0x7, + GroupingSize: [2]uint8{0x3, + 0x0}, + Flags: 0x0}, + Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0, + MaxFractionDigits: 0, + Increment: 0x0, + IncrementScale: 0x0, + Mode: 0x0, + DigitShift: 0x0, + MinIntegerDigits: 0x0, + MaxIntegerDigits: 0x1, + MinFractionDigits: 0x0, + MinSignificantDigits: 0x0, + MinExponentDigits: 0x1}, + Affix: "\x01[\x01]", + Offset: 0x0, + NegOffset: 0x0, + PadRune: 0, + FormatWidth: 0x5, + GroupingSize: [2]uint8{0x0, + 0x0}, + Flags: 0x0}, + Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0, + MaxFractionDigits: 0, + Increment: 0x0, + IncrementScale: 0x0, + Mode: 0x0, + DigitShift: 0x0, + MinIntegerDigits: 0x0, + MaxIntegerDigits: 0x0, + MinFractionDigits: 0x0, + MinSignificantDigits: 0x0, + MinExponentDigits: 0x0}, + Affix: "", + Offset: 0x0, + NegOffset: 0x0, + PadRune: 0, + FormatWidth: 0x1, + GroupingSize: [2]uint8{0x0, + 0x0}, + Flags: 0x0}, + Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0, + MaxFractionDigits: 0, + Increment: 0x0, + IncrementScale: 0x0, + Mode: 0x0, + DigitShift: 0x2, + MinIntegerDigits: 0x1, + MaxIntegerDigits: 0x0, + MinFractionDigits: 0x0, + MinSignificantDigits: 0x0, + MinExponentDigits: 0x0}, + Affix: "\x01%\x00", + Offset: 0x0, + NegOffset: 0x0, + PadRune: 0, + FormatWidth: 0x6, + GroupingSize: [2]uint8{0x3, + 0x0}, + Flags: 0x0}} + +// Total table size 8634 bytes (8KiB); checksum: 8F23386D diff --git a/vendor/golang.org/x/text/internal/stringset/set.go b/vendor/golang.org/x/text/internal/stringset/set.go new file mode 100644 index 00000000000..bb2fffbc75b --- /dev/null +++ b/vendor/golang.org/x/text/internal/stringset/set.go @@ -0,0 +1,86 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package stringset provides a way to represent a collection of strings +// compactly. +package stringset + +import "sort" + +// A Set holds a collection of strings that can be looked up by an index number. +type Set struct { + // These fields are exported to allow for code generation. + + Data string + Index []uint16 +} + +// Elem returns the string with index i. It panics if i is out of range. +func (s *Set) Elem(i int) string { + return s.Data[s.Index[i]:s.Index[i+1]] +} + +// Len returns the number of strings in the set. +func (s *Set) Len() int { + return len(s.Index) - 1 +} + +// Search returns the index of the given string or -1 if it is not in the set. +// The Set must have been created with strings in sorted order. +func Search(s *Set, str string) int { + // TODO: optimize this if it gets used a lot. + n := len(s.Index) - 1 + p := sort.Search(n, func(i int) bool { + return s.Elem(i) >= str + }) + if p == n || str != s.Elem(p) { + return -1 + } + return p +} + +// A Builder constructs Sets. +type Builder struct { + set Set + index map[string]int +} + +// NewBuilder returns a new and initialized Builder. +func NewBuilder() *Builder { + return &Builder{ + set: Set{ + Index: []uint16{0}, + }, + index: map[string]int{}, + } +} + +// Set creates the set created so far. +func (b *Builder) Set() Set { + return b.set +} + +// Index returns the index for the given string, which must have been added +// before. +func (b *Builder) Index(s string) int { + return b.index[s] +} + +// Add adds a string to the index. Strings that are added by a single Add will +// be stored together, unless they match an existing string. +func (b *Builder) Add(ss ...string) { + // First check if the string already exists. + for _, s := range ss { + if _, ok := b.index[s]; ok { + continue + } + b.index[s] = len(b.set.Index) - 1 + b.set.Data += s + x := len(b.set.Data) + if x > 0xFFFF { + panic("Index too > 0xFFFF") + } + b.set.Index = append(b.set.Index, uint16(x)) + } +} diff --git a/vendor/golang.org/x/tools/go/types/objectpath/objectpath.go b/vendor/golang.org/x/tools/go/types/objectpath/objectpath.go index 0d6d0bced0f..9c7401c9ba5 100644 --- a/vendor/golang.org/x/tools/go/types/objectpath/objectpath.go +++ b/vendor/golang.org/x/tools/go/types/objectpath/objectpath.go @@ -30,6 +30,7 @@ import ( "slices" "strconv" "strings" + "sync" "golang.org/x/tools/internal/typesinternal" ) @@ -126,7 +127,8 @@ func For(obj types.Object) (Path, error) { // An Encoder amortizes the cost of encoding the paths of multiple objects. // The zero value of an Encoder is ready to use. type Encoder struct { - pkgIndex map[*types.Package]*pkgIndex + pkgIndexMu sync.Mutex + pkgIndex map[*types.Package]*pkgIndex } // A traversal encapsulates the state of a single traversal of the object/type graph. @@ -191,6 +193,8 @@ type pkgIndex struct { // For returns the path to an object relative to its package, // or an error if the object is not accessible from the package's Scope. // +// For is safe for concurrent use. +// // The For function guarantees to return a path only for the following objects: // - package-level types // - exported package-level non-types @@ -320,6 +324,9 @@ func (enc *Encoder) For(obj types.Object) (Path, error) { panic(obj) } + enc.pkgIndexMu.Lock() + defer enc.pkgIndexMu.Unlock() + // 4. Search the object/type graph for the path to // the var (field/param/result) or method. ix, ok := enc.pkgIndex[pkg] diff --git a/vendor/golang.org/x/tools/internal/stdlib/deps.go b/vendor/golang.org/x/tools/internal/stdlib/deps.go index 0f73c719cd1..b049e5f9775 100644 --- a/vendor/golang.org/x/tools/internal/stdlib/deps.go +++ b/vendor/golang.org/x/tools/internal/stdlib/deps.go @@ -12,386 +12,387 @@ type pkginfo struct { } var deps = [...]pkginfo{ - {"archive/tar", "\x03{\x03F>\x01\n\x01&\x01\x01\x02\x05\b\x02\x01\x02\x02\r"}, - {"archive/zip", "\x02\x04j\x0e\x03\x12\x022>\x01-\x05\x01\x0f\x03\x02\x0f\x04"}, - {"bufio", "\x03{\x87\x01F\x15"}, - {"bytes", "~*]\x03\fJ\x02\x02"}, + {"archive/tar", "\x03|\x03F>\x01\n\x01&\x01\x01\x02\x05\b\x02\x01\x02\x02\r"}, + {"archive/zip", "\x02\x04k\x0e\x03\x12\x022>\x01-\x05\x01\x0f\x03\x02\x0f\x04"}, + {"bufio", "\x03|\x87\x01F\x15"}, + {"bytes", "\x7f*]\x03\fJ\x02\x02"}, {"cmp", ""}, - {"compress/bzip2", "\x02\x02\x81\x02C"}, - {"compress/flate", "\x02|\x03\x84\x01\f\x034\x02\x03"}, - {"compress/gzip", "\x02\x04j\x0e\x03\x14pW"}, - {"compress/lzw", "\x02|\x03\x84\x01"}, - {"compress/zlib", "\x02\x04j\x0e\x03\x12\x01q"}, - {"container/heap", "\xc9\x02"}, + {"compress/bzip2", "\x02\x02\x82\x02C"}, + {"compress/flate", "\x02}\x03\x84\x01\f\x034\x02\x03"}, + {"compress/gzip", "\x02\x04k\x0e\x03\x14pW"}, + {"compress/lzw", "\x02}\x03\x84\x01"}, + {"compress/zlib", "\x02\x04k\x0e\x03\x12\x01q"}, + {"container/heap", "\xca\x02"}, {"container/list", ""}, {"container/ring", ""}, - {"context", "~]r\x01\x0e"}, - {"crypto", "\x93\x01rE"}, - {"crypto/aes", "\x10\v\n\xa5\x02"}, - {"crypto/cipher", "\x03\"\x01\x01 \x13$+\\"}, - {"crypto/des", "\x10\x17 7+\xa1\x01\x03"}, - {"crypto/dsa", "G\x034\x87\x01\r"}, - {"crypto/ecdh", "\x03\v\r\x11\x04\x17\x03\x10$\x87\x01"}, - {"crypto/ecdsa", "\x0e\x05\x03\x05\x01\x11\b\v\x06\x01\x03\x0f\x01$\x87\x01\r\x05O\x01"}, - {"crypto/ed25519", "\x0e \x12\a\x03\t\a$I>E"}, - {"crypto/elliptic", "5I\x87\x01\r;"}, - {"crypto/fips140", "$\x05\x9e\x01\x9b\x01"}, - {"crypto/hkdf", "1\x15\x017\x15"}, - {"crypto/hmac", "\x1b\x17\x14\x01\x139"}, - {"crypto/hpke", "\x03\v\x02\x03\x04\x01\r\x01\x05\x1f\x06\a\x01\x01%\x03\x12\x16\x9f\x01\x1d"}, - {"crypto/internal/boring", "\x0e\x02\x0eu"}, - {"crypto/internal/boring/bbig", "\x1b\xf7\x01P"}, - {"crypto/internal/boring/bcache", "\xce\x02\x14"}, + {"context", "\x7f]r\x01\x0e"}, + {"crypto", "\x94\x01rE"}, + {"crypto/aes", "\x10\v\v\xa5\x02"}, + {"crypto/cipher", "\x03#\x01\x01 \x13$+\\"}, + {"crypto/des", "\x10\x18 7+\xa1\x01\x03"}, + {"crypto/dsa", "H\x034\x87\x01\r"}, + {"crypto/ecdh", "\x03\v\r\x12\x04\x17\x03\x10$\x87\x01"}, + {"crypto/ecdsa", "\x0e\x05\x03\x05\x01\x12\b\v\x06\x01\x03\x0f\x01$\x87\x01\r\x05O\x01"}, + {"crypto/ed25519", "\x0e!\x12\a\x03\t\a$I>E"}, + {"crypto/elliptic", "6I\x87\x01\r;"}, + {"crypto/fips140", "%\x05\x9e\x01\x9b\x01"}, + {"crypto/hkdf", "2\x15\x017\x15"}, + {"crypto/hmac", "\x1b\x18\x14\x01\x139"}, + {"crypto/hpke", "\x03\v\x02\x03\x04\x01\x0e\x01\x05\x1f\x06\a\x01\x01%\x03\x12\x16\x9f\x01\x1d"}, + {"crypto/internal/boring", "\x0e\x02\x0ev"}, + {"crypto/internal/boring/bbig", "\x1b\xf8\x01P"}, + {"crypto/internal/boring/bcache", "\xcf\x02\x14"}, {"crypto/internal/boring/sig", ""}, {"crypto/internal/constanttime", ""}, - {"crypto/internal/cryptotest", "\x03\r\v\t%\x11\x1a\r\x12\x12!\x04\x06\n\x19\x01\x11\x11\x1d\x01\a\x03\x02\b\x02\x01\x05\f"}, - {"crypto/internal/cryptotest/wycheproof", "\x0e\x12S\x01\f\x01r@\x05\x03\x15\x10"}, - {"crypto/internal/entropy", "L"}, - {"crypto/internal/entropy/v1.0.0", "E9\x96\x01:\x14"}, - {"crypto/internal/fips140", "D:\xc2\x01\v\x17"}, - {"crypto/internal/fips140/aes", "\x03!\x03\x02\x14\x05\x01\x01\x055\x96\x016"}, - {"crypto/internal/fips140/aes/gcm", "$\x01\x02\x02\x02\x12\x05\x01\x065\x93\x01"}, - {"crypto/internal/fips140/alias", "\xe2\x02"}, - {"crypto/internal/fips140/bigmod", ")\x19\x01\x065\x96\x01"}, - {"crypto/internal/fips140/check", "$\x0e\a\t\x02\xc1\x01]"}, - {"crypto/internal/fips140/check/checktest", ")\x97\x02\""}, - {"crypto/internal/fips140/drbg", "\x03 \x01\x01\x04\x14\x05\n2\x87\x01\x0f9\x01"}, - {"crypto/internal/fips140/ecdh", "\x03!\x05\x02\n\r<\x87\x01\x0f9"}, - {"crypto/internal/fips140/ecdsa", "\x03!\x04\x01\x02\a\x03\x06C\x15r\x0f9"}, - {"crypto/internal/fips140/ed25519", "\x03!\x05\x02\x04\fC\xcc\x01\x03"}, - {"crypto/internal/fips140/edwards25519", "\x1f\n\a\x12<\x96\x019"}, - {"crypto/internal/fips140/edwards25519/field", ")\x14\x05<\x96\x01"}, - {"crypto/internal/fips140/hkdf", "\x03!\x05\t\aE\x15"}, - {"crypto/internal/fips140/hmac", "\x03!\x15\x01\x01C\x15"}, - {"crypto/internal/fips140/mldsa", "\x03\x1c\x05\x05\x02\x0e\x01\x03\x05<\x96\x019"}, - {"crypto/internal/fips140/mlkem", "\x03!\x05\x02\x0f\x03\x05<\xcf\x01"}, - {"crypto/internal/fips140/nistec", "\x1f\n\r\f<\x96\x01,\r\x15"}, - {"crypto/internal/fips140/nistec/fiat", ")\x14A\x96\x01"}, - {"crypto/internal/fips140/pbkdf2", "\x03!\x05\t\aE\x15"}, - {"crypto/internal/fips140/rsa", "\x03\x1c\x05\x04\x01\x02\x0e\x01\x01\x02A\x15rH"}, - {"crypto/internal/fips140/sha256", "\x03!\x1e\x01\x065\x15\x81\x01"}, - {"crypto/internal/fips140/sha3", "\x03!\x19\x05\x01;\x96\x01N"}, - {"crypto/internal/fips140/sha512", "\x03!\x1e\x01\x065\x15\x81\x01"}, - {"crypto/internal/fips140/ssh", ")j"}, - {"crypto/internal/fips140/subtle", "\x1f\b\x1b\xd2\x01"}, - {"crypto/internal/fips140/tls12", "\x03!\x05\t\a\x02C\x15"}, - {"crypto/internal/fips140/tls13", "\x03!\x05\b\b\t<\x15"}, - {"crypto/internal/fips140cache", "\xc0\x02\r."}, + {"crypto/internal/cryptotest", "\x03\r\v\n%\x11\x1a\r\x12\x12!\x04\x06\n\x19\x01\x11\x11\x1d\x01\a\x03\x02\b\x02\x01\x05\f"}, + {"crypto/internal/cryptotest/wycheproof", "\x0e\x12T\x01\f\x01r@\x05\x03\x15\x10"}, + {"crypto/internal/cryptotest/x509limbo", "u\n\x03\xba\x01\x03\x1e"}, + {"crypto/internal/entropy", "M"}, + {"crypto/internal/entropy/v1.0.0", "F9\x96\x01:\x14"}, + {"crypto/internal/fips140", "E:\xc2\x01\v\x17"}, + {"crypto/internal/fips140/aes", "\x03\"\x03\x02\x14\x05\x01\x01\x055\x96\x016"}, + {"crypto/internal/fips140/aes/gcm", "%\x01\x02\x02\x02\x12\x05\x01\x065\x93\x01"}, + {"crypto/internal/fips140/alias", "\xe3\x02"}, + {"crypto/internal/fips140/bigmod", "*\x19\x01\x065\x96\x01"}, + {"crypto/internal/fips140/check", "%\x0e\a\t\x02\xc1\x01]"}, + {"crypto/internal/fips140/check/checktest", "*\x97\x02\""}, + {"crypto/internal/fips140/drbg", "\x03!\x01\x01\x04\x14\x05\n2\x87\x01\x0f9\x01"}, + {"crypto/internal/fips140/ecdh", "\x03\"\x05\x02\n\r<\x87\x01\x0f9"}, + {"crypto/internal/fips140/ecdsa", "\x03\"\x04\x01\x02\a\x03\x06C\x15r\x0f9"}, + {"crypto/internal/fips140/ed25519", "\x03\"\x05\x02\x04\fC\xcc\x01\x03"}, + {"crypto/internal/fips140/edwards25519", "\x1f\v\a\x12<\x96\x019"}, + {"crypto/internal/fips140/edwards25519/field", "*\x14\x05<\x96\x01"}, + {"crypto/internal/fips140/hkdf", "\x03\"\x05\t\aE\x15"}, + {"crypto/internal/fips140/hmac", "\x03\"\x15\x01\x01C\x15"}, + {"crypto/internal/fips140/mldsa", "\x03\x1c\x06\x05\x02\x0e\x01\x03\x05<\x96\x019"}, + {"crypto/internal/fips140/mlkem", "\x03\"\x05\x02\x0f\x03\x05<\xcf\x01"}, + {"crypto/internal/fips140/nistec", "\x1f\v\r\f<\x96\x01,\r\x15"}, + {"crypto/internal/fips140/nistec/fiat", "*\x14A\x96\x01"}, + {"crypto/internal/fips140/pbkdf2", "\x03\"\x05\t\aE\x15"}, + {"crypto/internal/fips140/rsa", "\x03\x1c\x06\x04\x01\x02\x0e\x01\x01\x02A\x15rH"}, + {"crypto/internal/fips140/sha256", "\x03\"\x1e\x01\x065\x15\x81\x01"}, + {"crypto/internal/fips140/sha3", "\x03\"\x19\x05\x01;\x96\x01N"}, + {"crypto/internal/fips140/sha512", "\x03\"\x1e\x01\x065\x15\x81\x01"}, + {"crypto/internal/fips140/ssh", "*j"}, + {"crypto/internal/fips140/subtle", "\x1f\t\x1b\xd2\x01"}, + {"crypto/internal/fips140/tls12", "\x03\"\x05\t\a\x02C\x15"}, + {"crypto/internal/fips140/tls13", "\x03\"\x05\b\b\t<\x15"}, + {"crypto/internal/fips140cache", "\xc1\x02\r."}, {"crypto/internal/fips140deps", ""}, - {"crypto/internal/fips140deps/byteorder", "\xa9\x01"}, - {"crypto/internal/fips140deps/cpu", "\xbe\x01\b"}, - {"crypto/internal/fips140deps/godebug", "\xc7\x01"}, - {"crypto/internal/fips140deps/time", "\xe2\x02"}, - {"crypto/internal/fips140hash", ":\x1e;\xcf\x01"}, - {"crypto/internal/fips140only", "\x17\x14\x0e\x01\x01Xr"}, + {"crypto/internal/fips140deps/byteorder", "\xaa\x01"}, + {"crypto/internal/fips140deps/cpu", "\xbf\x01\b"}, + {"crypto/internal/fips140deps/godebug", "\xc8\x01"}, + {"crypto/internal/fips140deps/time", "\xe3\x02"}, + {"crypto/internal/fips140hash", ";\x1e;\xcf\x01"}, + {"crypto/internal/fips140only", "\x17\x15\x0e\x01\x01Xr"}, {"crypto/internal/fips140test", ""}, - {"crypto/internal/impl", "\xcb\x02"}, - {"crypto/internal/rand", "\x1b\x10 |>]"}, - {"crypto/internal/randutil", "\x85\x02\x12"}, - {"crypto/internal/sysrand", "~r!\"\r\r\x01\x01\r\x06"}, - {"crypto/internal/sysrand/internal/seccomp", "~"}, - {"crypto/md5", "\x0e97\x15\x16k"}, - {"crypto/mldsa", "\x0e%K\x87\x01"}, - {"crypto/mlkem", "\x0e&"}, - {"crypto/mlkem/mlkemtest", "4\x13\t."}, - {"crypto/pbkdf2", "7\x0f\x017\x15"}, - {"crypto/rand", "\x1b\x10\x1c\x034\x87\x01\rP"}, - {"crypto/rc4", "' 7\xcc\x01"}, - {"crypto/rsa", "\x0e\r\x01\f\x10\x0e\x01\x03\t\a$\x03\x124>\f\x01"}, - {"crypto/sha1", "\x0e\r,\x025\x15\x16\x15V"}, - {"crypto/sha256", "\x0e\r\x1eZ"}, - {"crypto/sha3", "\x0e,Y\xcf\x01"}, - {"crypto/sha512", "\x0e\r X"}, - {"crypto/subtle", "\x1f\x1e\xa9\x01|"}, - {"crypto/tls", "\x03\b\x02\x01\x01\x01\x01\x02\x01\x01\x01\x01\x01\x01\x01\x01\n\x01\x18\x01\x0f\x01\x01\x03\x01\x01\x01\x01\x02\x01\x02\x01\x1f\x02\x03\x12\x16\x15\t>\x16\x18\r\b\x01\x01\x01\x02\x01\x0e\x06\x03\x01\x15"}, - {"crypto/tls/internal/fips140tls", "\x17\xb7\x02"}, - {"crypto/x509", "\x03\v\x01\x01\x01\x01\x01\x01\x01\x01\x017\x01\x06\x01\x01\x02\x05\x0f\x06\t\x02\x03F\x03;\x01\x02\b\x01\x01\x02\a\x12\x05\x01\x06\a\b\x02\x01\x02\x0f\x02\x01\x01\x02\x04\x01"}, - {"crypto/x509/pkix", "m\x06\x0e\x91\x019\x11"}, - {"database/sql", "\x03\nS\x01\x1d\x03\x84\x01\v\a$\x05\b\x02\x03\x01\x0e\x02\x02\x02\x01"}, - {"database/sql/driver", "\rT\x1d\x03\xba\x01\x0f\x12\a"}, + {"crypto/internal/impl", "\xcc\x02"}, + {"crypto/internal/rand", "\x1b\x11 |>]"}, + {"crypto/internal/randutil", "\x86\x02\x12"}, + {"crypto/internal/sysrand", "\x7fr!\"\r\r\x01\x01\r\x06"}, + {"crypto/internal/sysrand/internal/seccomp", "\x7f"}, + {"crypto/md5", "\x0e:7\x15\x16k"}, + {"crypto/mldsa", "\x0e&K\x87\x01"}, + {"crypto/mlkem", "\x0e'"}, + {"crypto/mlkem/mlkemtest", "5\x13\t."}, + {"crypto/pbkdf2", "8\x0f\x017\x15"}, + {"crypto/rand", "\x1b\x11\x1c\x034\x87\x01\rP"}, + {"crypto/rc4", "( 7\xcc\x01"}, + {"crypto/rsa", "\x0e\r\x01\r\x10\x0e\x01\x03\t\a$\x03\x124>\f\x01"}, + {"crypto/sha1", "\x0e\r-\x025\x15\x16\x15V"}, + {"crypto/sha256", "\x0e\r\x1fZ"}, + {"crypto/sha3", "\x0e-Y\xcf\x01"}, + {"crypto/sha512", "\x0e\r!X"}, + {"crypto/subtle", "\x1f\x1f\xa9\x01|"}, + {"crypto/tls", "\x03\b\x02\x01\x01\x01\x01\x02\x01\x01\x01\x01\x01\x01\x01\x01\v\x01\x18\x01\x0f\x01\x01\x03\x01\x01\x01\x01\x02\x01\x02\x01\x1f\x02\x03\x12\x16\x15\t>\x16\x18\r\b\x01\x01\x01\x02\x01\x0e\x06\x03\x01\x15"}, + {"crypto/tls/internal/fips140tls", "\x17\xb8\x02"}, + {"crypto/x509", "\x03\v\x01\x01\x01\x01\x01\x01\x01\x01\x018\x01\x06\x01\x01\x02\x05\x0f\x06\t\x02\x03F\x03;\x01\x02\b\x01\x01\x02\a\x12\x05\x01\x06\a\b\x02\x01\x02\x0f\x02\x01\x01\x02\x04\x01"}, + {"crypto/x509/pkix", "n\x06\x0e\x91\x019\x11"}, + {"database/sql", "\x03\nT\x01\x1d\x03\x84\x01\v\a$\x05\b\x02\x03\x01\x0e\x02\x02\x02\x01"}, + {"database/sql/driver", "\rU\x1d\x03\xba\x01\x0f\x12\a"}, {"database/sql/internal", ""}, - {"debug/buildinfo", "\x03a\x02\x01\x01\b\x0e\x03h\x1a\x02\x01-\x0f "}, - {"debug/dwarf", "\x03m\x0e\x03\x84\x013\x11\x01\x01"}, - {"debug/elf", "\x03\x06Z\r\x0e\x03h\x1b\x01\f\"\x17\x01\x17"}, - {"debug/gosym", "\x03m\x11#\xa5\x01\x01\x01\x02"}, - {"debug/macho", "\x03\x06Z\r\x11h\x1c.\x17\x01"}, - {"debug/pe", "\x03\x06Z\r\x0e\x03h\x1c.\x17\x01\x17"}, - {"debug/plan9obj", "p\x0e\x03h\x1c."}, - {"embed", "~*D\x19\x01V"}, + {"debug/buildinfo", "\x03b\x02\x01\x01\b\x0e\x03h\x1a\x02\x01-\x0f "}, + {"debug/dwarf", "\x03n\x0e\x03\x84\x013\x11\x01\x01"}, + {"debug/elf", "\x03\x06[\r\x0e\x03h\x1b\x01\f\"\x17\x01\x17"}, + {"debug/gosym", "\x03n\x11#\xa5\x01\x01\x01\x02"}, + {"debug/macho", "\x03\x06[\r\x11h\x1c.\x17\x01"}, + {"debug/pe", "\x03\x06[\r\x0e\x03h\x1c.\x17\x01\x17"}, + {"debug/plan9obj", "q\x0e\x03h\x1c."}, + {"embed", "\x7f*D\x19\x01V"}, {"embed/internal/embedtest", ""}, {"encoding", ""}, - {"encoding/ascii85", "\x85\x02E"}, - {"encoding/asn1", "\x03{\x03h(\x01)\r\x02\x01\x11\x03\x01"}, - {"encoding/base32", "\x85\x02C\x02"}, - {"encoding/base64", "\xa9\x01\\C\x02"}, - {"encoding/binary", "~\x87\x01\f*\r\x05"}, - {"encoding/csv", "\x02\x01{\x03\x84\x01F\x13\x02"}, - {"encoding/gob", "\x02i\x05\x0e\x03h\x1c\v\x01\x03\x1f\b\x12\x01\x10\x02"}, - {"encoding/hex", "~\x03\x84\x01C\x03"}, - {"encoding/json", "\x03\x01g\n\x01\x01\x02\x01\x01\x03\x03\x84\x016\x0f\x01"}, - {"encoding/json/internal", "~"}, - {"encoding/json/internal/jsonflags", "u"}, - {"encoding/json/internal/jsonopts", "u\x01"}, - {"encoding/json/internal/jsontest", "\x03f\x15\x03\x83\x01\x01\x012\b\b\x03\x02\x0f"}, - {"encoding/json/internal/jsonwire", "\x04r\b\x87\x01\f7\x02\x01\x13\x01\x01"}, - {"encoding/json/jsontext", "\x03r\x01\x01\x02\x05\x87\x01\x03\t\x034\x02\x01\x02\x13"}, - {"encoding/json/v2", "\x03\x01g\x03\x01\x01\x03\x02\x01\x01\x02\x01\x04\x03\x84\x01\f\x03'\r\x02\x01\x02\x0f\x02\x02"}, - {"encoding/pem", "\x03l\x0f\x87\x01C\x03"}, - {"encoding/xml", "\x02\x01h\x13\x03\x84\x016\x05\n\x01\x02\x11\x02"}, - {"errors", "\xdb\x01\x87\x01"}, - {"expvar", "tSB\b\v\x17\r\b\x02\x03\x01\x12"}, - {"flag", "k\x13\x03\x84\x01.\b\x05\b\x02\x01\x11"}, - {"fmt", "~E)\x19\f\"\b\r\x02\x03\x13"}, - {"go/ast", "\x03\x01}\x0e\x01u\x03+\b\r\x02\x01\x13\x02"}, - {"go/build", "\x02\x01{\x03\x01\x02\x02\a\x02\x01\x17 \x04\x02\t\x1c\x13\x01-\x01\x04\x01\a\b\x02\x01\x13\x02\x02"}, - {"go/build/constraint", "~\xcc\x01\x01\x13\x02"}, - {"go/constant", "\x81\x01\x0f\x81\x01\x01\x026\x01\x02\x13"}, - {"go/doc", "\x04}\x01\x05\t>73\x10\x02\x01\x13\x02"}, - {"go/doc/comment", "\x03~\xc7\x01\x01\x01\x01\x13\x02"}, - {"go/format", "\x03~\x01\v\x01\x02uF"}, - {"go/importer", "\x83\x01\a\x01\x01\x04\x01t;"}, - {"go/internal/gccgoimporter", "\x02\x01a\x1a\x03\x04\v\x01r\x02.\x01\x05\x11\x01\r\b"}, - {"go/internal/gcimporter", "\x02\x7f\x0f\x010\x140.\x15\x03\x02"}, - {"go/internal/srcimporter", "\x81\x01\x01\x01\n\x03\x01t.\x01\x05\x12\x02\x15"}, - {"go/parser", "\x03{\x03\x01\x02\v\x01u\x01-\x06\x12"}, - {"go/printer", "\x81\x01\x01\x02\x03\tu\f\"\x15\x02\x01\x02\f\x05\x02"}, - {"go/scanner", "\x03~\x0fu4\x10\x01\x14\x02"}, - {"go/token", "\x04}\x87\x01@\x02\x03\x01\x10\x02"}, - {"go/types", "\x03\x01\x06t\x03\x01\x03\b\x03\x02\x0654\x04\x03\t\"\x06\a\b\x01\x01\x01\x02\x01\x10\x02\x02"}, - {"go/version", "\xcc\x01\x7f"}, - {"hash", "\x85\x02"}, - {"hash/adler32", "~\x15\x16"}, - {"hash/crc32", "~\x15\x16\x15\x8f\x01\x01\x14"}, - {"hash/crc64", "~\x15\x16\xa4\x01"}, - {"hash/fnv", "~\x15\x16k"}, - {"hash/maphash", "\x93\x01\x11>\x80\x01"}, - {"html", "\xcb\x02\x02\x13"}, - {"html/template", "\x03q\r\x18.>\x01\n#\x05\x01\x02\x03\n\x02\x01\x02\r\x01\x03\x02"}, - {"image", "\x02|\x1ei\x0f6\x03\x01"}, + {"encoding/ascii85", "\x86\x02E"}, + {"encoding/asn1", "\x03|\x03h(\x01)\r\x02\x01\x11\x03\x01"}, + {"encoding/base32", "\x86\x02C\x02"}, + {"encoding/base64", "\xaa\x01\\C\x02"}, + {"encoding/binary", "\x7f\x87\x01\f*\r\x05"}, + {"encoding/csv", "\x02\x01|\x03\x84\x01F\x13\x02"}, + {"encoding/gob", "\x02j\x05\x0e\x03h\x1c\v\x01\x03\x1f\b\x12\x01\x10\x02"}, + {"encoding/hex", "\x7f\x03\x84\x01C\x03"}, + {"encoding/json", "\x03\x01h\n\x01\x01\x02\x01\x01\x03\x03\x84\x016\x0f\x01"}, + {"encoding/json/internal", "\x7f"}, + {"encoding/json/internal/jsonflags", "v"}, + {"encoding/json/internal/jsonopts", "v\x01"}, + {"encoding/json/internal/jsontest", "\x03g\x15\x03\x83\x01\x01\x012\b\b\x03\x02\x0f"}, + {"encoding/json/internal/jsonwire", "\x04s\b\x87\x01\f7\x02\x01\x13\x01\x01"}, + {"encoding/json/jsontext", "\x03s\x01\x01\x02\x05\x87\x01\x03\t\x034\x02\x01\x02\x13"}, + {"encoding/json/v2", "\x03\x01h\x03\x01\x01\x03\x02\x01\x01\x02\x01\x04\x03\x84\x01\f\x03'\r\x02\x01\x02\x0f\x02\x02"}, + {"encoding/pem", "\x03m\x0f\x87\x01C\x03"}, + {"encoding/xml", "\x02\x01i\x13\x03\x84\x016\x05\n\x01\x02\x11\x02"}, + {"errors", "\xdc\x01\x87\x01"}, + {"expvar", "uSB\b\v\x17\r\b\x02\x03\x01\x12"}, + {"flag", "l\x13\x03\x84\x01.\b\x05\b\x02\x01\x11"}, + {"fmt", "\x7fE)\x19\f\"\b\r\x02\x03\x13"}, + {"go/ast", "\x03\x01~\x0e\x01u\x03+\b\r\x02\x01\x13\x02"}, + {"go/build", "\x02\x01|\x03\x01\x02\x02\a\x02\x01\x17 \x04\x02\t\x1c\x13\x01-\x01\x04\x01\a\b\x02\x01\x13\x02\x02"}, + {"go/build/constraint", "\x7f\xcc\x01\x01\x13\x02"}, + {"go/constant", "\x82\x01\x0f\x81\x01\x01\x026\x01\x02\x13"}, + {"go/doc", "\x04~\x01\x05\t>73\x10\x02\x01\x13\x02"}, + {"go/doc/comment", "\x03\x7f\xc7\x01\x01\x01\x01\x13\x02"}, + {"go/format", "\x03\x7f\x01\v\x01\x02uF"}, + {"go/importer", "\x84\x01\a\x01\x01\x04\x01t;"}, + {"go/internal/gccgoimporter", "\x02\x01b\x1a\x03\x04\v\x01r\x02.\x01\x05\x11\x01\r\b"}, + {"go/internal/gcimporter", "\x02\x80\x01\x0f\x010\x140.\x15\x03\x02"}, + {"go/internal/srcimporter", "\x82\x01\x01\x01\n\x03\x01t.\x01\x05\x12\x02\x15"}, + {"go/parser", "\x03|\x03\x01\x02\v\x01u\x01-\x06\x12"}, + {"go/printer", "\x82\x01\x01\x02\x03\tu\f\"\x15\x02\x01\x02\f\x05\x02"}, + {"go/scanner", "\x03\x7f\x0fu4\x10\x01\x14\x02"}, + {"go/token", "\x04~\x87\x01@\x02\x03\x01\x10\x02"}, + {"go/types", "\x03\x01\x06u\x03\x01\x03\b\x03\x02\x0654\x04\x03\t\"\x06\a\b\x01\x01\x01\x02\x01\x10\x02\x02"}, + {"go/version", "\xcd\x01\x7f"}, + {"hash", "\x86\x02"}, + {"hash/adler32", "\x7f\x15\x16"}, + {"hash/crc32", "\x7f\x15\x16\x15\x8f\x01\x01\x14"}, + {"hash/crc64", "\x7f\x15\x16\xa4\x01"}, + {"hash/fnv", "\x7f\x15\x16k"}, + {"hash/maphash", "\x94\x01\x11>\x80\x01"}, + {"html", "\xcc\x02\x02\x13"}, + {"html/template", "\x03r\r\x18.>\x01\n#\x05\x01\x02\x03\n\x02\x01\x02\r\x01\x03\x02"}, + {"image", "\x02}\x1ei\x0f6\x03\x01"}, {"image/color", ""}, - {"image/color/palette", "\x9c\x01"}, - {"image/draw", "\x9b\x01\x01\x04"}, - {"image/gif", "\x02\x01\x05v\x03\x1a\x01\x01\x01\v\\\x0f"}, - {"image/internal/imageutil", "\x9b\x01"}, - {"image/jpeg", "\x02|\x1d\x01\x04e"}, - {"image/png", "\x02\ag\x11\x12\x02\x06\x01iE"}, - {"index/suffixarray", "\x03m\x0e\x87\x01\f-\n\x01"}, - {"internal/abi", "\xc6\x01\x9c\x01"}, - {"internal/asan", "\xe2\x02"}, - {"internal/bisect", "\xc0\x02\r\x01"}, - {"internal/buildcfg", "\x81\x01Hj\x06\x02\x05\n\x01"}, - {"internal/bytealg", "\xbe\x01\xa4\x01"}, + {"image/color/palette", "\x9d\x01"}, + {"image/draw", "\x9c\x01\x01\x04"}, + {"image/gif", "\x02\x01\x05w\x03\x1a\x01\x01\x01\v\\\x0f"}, + {"image/internal/imageutil", "\x9c\x01"}, + {"image/jpeg", "\x02}\x1d\x01\x04e"}, + {"image/png", "\x02\ah\x11\x12\x02\x06\x01iE"}, + {"index/suffixarray", "\x03n\x0e\x87\x01\f-\n\x01"}, + {"internal/abi", "\xc7\x01\x9c\x01"}, + {"internal/asan", "\xe3\x02"}, + {"internal/bisect", "\xc1\x02\r\x01"}, + {"internal/buildcfg", "\x82\x01Hj\x06\x02\x05\n\x01"}, + {"internal/bytealg", "\xbf\x01\xa4\x01"}, {"internal/byteorder", ""}, {"internal/cfg", ""}, - {"internal/cgrouptest", "\x81\x01\\V\x06\x0f\x02\x01\x04\x01"}, - {"internal/chacha8rand", "\xa9\x01\x15\b\x9c\x01"}, + {"internal/cgrouptest", "\x82\x01\\V\x06\x0f\x02\x01\x04\x01"}, + {"internal/chacha8rand", "\xaa\x01\x15\b\x9c\x01"}, {"internal/copyright", ""}, {"internal/coverage", ""}, {"internal/coverage/calloc", ""}, - {"internal/coverage/cfile", "t\r\x16\x17\x01\x02\x01\x01\x01\x01\x01\x01\x01$\x02'.\x06\a\n\x01\x03\x0e\x06"}, - {"internal/coverage/cformat", "\x04}-\x04S\v8\x01\x02\x0e"}, - {"internal/coverage/cmerge", "\x81\x01-c"}, - {"internal/coverage/decodecounter", "p\x11-\v\x02J.\x17\x18"}, - {"internal/coverage/decodemeta", "\x02n\x11\x16\x17\v\x02J."}, - {"internal/coverage/encodecounter", "\x02n\x11-\f\x01\x02H\v#\x15"}, - {"internal/coverage/encodemeta", "\x02\x01m\x11\x12\x04\x17\r\x02H./"}, - {"internal/coverage/pods", "\x04}-\x85\x01\x06\x05\n\x02\x01"}, - {"internal/coverage/rtcov", "\xe2\x02"}, - {"internal/coverage/slicereader", "p\x11\x84\x01]"}, - {"internal/coverage/slicewriter", "\x81\x01\x84\x01"}, - {"internal/coverage/stringtab", "\x81\x018\x04H"}, + {"internal/coverage/cfile", "u\r\x16\x17\x01\x02\x01\x01\x01\x01\x01\x01\x01$\x02'.\x06\a\n\x01\x03\x0e\x06"}, + {"internal/coverage/cformat", "\x04~-\x04S\v8\x01\x02\x0e"}, + {"internal/coverage/cmerge", "\x82\x01-c"}, + {"internal/coverage/decodecounter", "q\x11-\v\x02J.\x17\x18"}, + {"internal/coverage/decodemeta", "\x02o\x11\x16\x17\v\x02J."}, + {"internal/coverage/encodecounter", "\x02o\x11-\f\x01\x02H\v#\x15"}, + {"internal/coverage/encodemeta", "\x02\x01n\x11\x12\x04\x17\r\x02H./"}, + {"internal/coverage/pods", "\x04~-\x85\x01\x06\x05\n\x02\x01"}, + {"internal/coverage/rtcov", "\xe3\x02"}, + {"internal/coverage/slicereader", "q\x11\x84\x01]"}, + {"internal/coverage/slicewriter", "\x82\x01\x84\x01"}, + {"internal/coverage/stringtab", "\x82\x018\x04H"}, {"internal/coverage/test", ""}, {"internal/coverage/uleb128", ""}, - {"internal/cpu", "\xe2\x02"}, - {"internal/dag", "\x04}\xc7\x01\x03"}, - {"internal/diff", "\x03~\xc8\x01\x02"}, - {"internal/exportdata", "\x02\x01{\x03\x02f\x1c.\x01\x05\x11\x01\x02"}, - {"internal/filepathlite", "~*D\x1aB"}, - {"internal/fmtsort", "\x04\xb7\x02\r"}, - {"internal/fuzz", "\x03\nJ\x19\x04\n\x03\x01\v\x037>\f\x03\x1f\x01\x05\x02\x05\n\x01\x02\x01\x01\r\x04\x02"}, + {"internal/cpu", "\xe3\x02"}, + {"internal/dag", "\x04~\xc7\x01\x03"}, + {"internal/diff", "\x03\x7f\xc8\x01\x02"}, + {"internal/exportdata", "\x02\x01|\x03\x02f\x1c.\x01\x05\x11\x01\x02"}, + {"internal/filepathlite", "\x7f*D\x1aB"}, + {"internal/fmtsort", "\x04\xb8\x02\r"}, + {"internal/fuzz", "\x03\nK\x19\x04\n\x03\x01\v\x037>\f\x03\x1f\x01\x05\x02\x05\n\x01\x02\x01\x01\r\x04\x02"}, {"internal/gate", "\r"}, {"internal/goarch", ""}, - {"internal/godebug", "\xa6\x01\"\x85\x01\x01\x14"}, + {"internal/godebug", "\xa7\x01\"\x85\x01\x01\x14"}, {"internal/godebugs", ""}, {"internal/goexperiment", ""}, {"internal/goos", ""}, - {"internal/goroot", "\xb3\x02\x01\x05\x12\x02"}, + {"internal/goroot", "\xb4\x02\x01\x05\x12\x02"}, {"internal/gover", "\x04"}, {"internal/goversion", ""}, - {"internal/lazyregexp", "\xb3\x02\v\r\x02"}, - {"internal/lazytemplate", "\x85\x02.\x18\x02\r"}, - {"internal/msan", "\xe2\x02"}, - {"internal/nettest", "\x03\nqG@\f\n\x12\x06\x15\x05\x0f"}, + {"internal/lazyregexp", "\xb4\x02\v\r\x02"}, + {"internal/lazytemplate", "\x86\x02.\x18\x02\r"}, + {"internal/msan", "\xe3\x02"}, + {"internal/nettest", "\x03\nrG@\f\n\x12\x06\x15\x05\x0f"}, {"internal/nettrace", ""}, - {"internal/obscuretestdata", "o\x96\x01."}, - {"internal/oserror", "~"}, - {"internal/pkgbits", "\x03T\x19\x0e\x03\x04\vu\r!\r\n\x01"}, + {"internal/obscuretestdata", "p\x96\x01."}, + {"internal/oserror", "\x7f"}, + {"internal/pkgbits", "\x03U\x19\x0e\x03\x04\vu\r!\r\n\x01"}, {"internal/platform", ""}, - {"internal/poll", "~m\x05\x15;\r\x01\x01\r\x06"}, - {"internal/profile", "\x03\x04w\x03\x84\x019\n\x01\x01\x01\x11"}, + {"internal/poll", "\x7fm\x05\x15;\r\x01\x01\r\x06"}, + {"internal/profile", "\x03\x04x\x03\x84\x019\n\x01\x01\x01\x11"}, {"internal/profilerecord", ""}, - {"internal/race", "\xa4\x01\xbe\x01"}, - {"internal/reflectlite", "\xa4\x01\"<>\""}, - {"internal/runtime/atomic", "\xc6\x01\x9c\x01"}, - {"internal/runtime/cgroup", "\xa8\x01?\x04w"}, - {"internal/runtime/exithook", "\xdc\x01\x86\x01"}, - {"internal/runtime/gc", "\xc6\x01"}, - {"internal/runtime/gc/internal/gen", "\nf\x11\x17m\x04\v\x1f\b\x10\x02"}, - {"internal/runtime/gc/scan", "\xbe\x01\b\x19\a|"}, - {"internal/runtime/maps", "\xa4\x01\x01\x04\x15\b\x03\a\n\t\x03.N"}, - {"internal/runtime/math", "\xc6\x01"}, + {"internal/race", "\xa5\x01\xbe\x01"}, + {"internal/reflectlite", "\xa5\x01\"<>\""}, + {"internal/runtime/atomic", "\xc7\x01\x9c\x01"}, + {"internal/runtime/cgroup", "\xa9\x01?\x04w"}, + {"internal/runtime/exithook", "\xdd\x01\x86\x01"}, + {"internal/runtime/gc", "\xc7\x01"}, + {"internal/runtime/gc/internal/gen", "\ng\x11\x17m\x04\v\x1f\b\x10\x02"}, + {"internal/runtime/gc/scan", "\xbf\x01\b\x19\a|"}, + {"internal/runtime/maps", "\xa5\x01\x01\x04\x15\b\x03\a\n\t\x03.N"}, + {"internal/runtime/math", "\xc7\x01"}, {"internal/runtime/pprof/label", ""}, {"internal/runtime/startlinetest", ""}, - {"internal/runtime/sys", "\xc6\x01\x04"}, - {"internal/runtime/syscall/linux", "\xc6\x01\x9c\x01"}, + {"internal/runtime/sys", "\xc7\x01\x04"}, + {"internal/runtime/syscall/linux", "\xc7\x01\x9c\x01"}, {"internal/runtime/wasitest", ""}, - {"internal/saferio", "\x85\x02]"}, - {"internal/singleflight", "\xcd\x02"}, - {"internal/strconv", "\x94\x02N"}, - {"internal/stringslite", "\xa8\x01\xba\x01"}, - {"internal/sync", "\xa4\x01\"\x14t\x14"}, - {"internal/synctest", "\xa4\x01\xbe\x01"}, - {"internal/syscall/execenv", "\xcf\x02"}, - {"internal/syscall/unix", "\xeb\x01U\x0e\x01\x13"}, - {"internal/sysinfo", "\x02\x01\xbb\x01G.\x18\x02"}, + {"internal/saferio", "\x86\x02]"}, + {"internal/singleflight", "\xce\x02"}, + {"internal/strconv", "\x95\x02N"}, + {"internal/stringslite", "\xa9\x01\xba\x01"}, + {"internal/sync", "\xa5\x01\"\x14t\x14"}, + {"internal/synctest", "\xa5\x01\xbe\x01"}, + {"internal/syscall/execenv", "\xd0\x02"}, + {"internal/syscall/unix", "\xec\x01U\x0e\x01\x13"}, + {"internal/sysinfo", "\x02\x01\xbc\x01G.\x18\x02"}, {"internal/syslist", ""}, - {"internal/testenv", "\x03\nq\x02\x01)\x1c\x100-\x01\x05\a\n\x01\x02\x02\x01\f"}, - {"internal/testhash", "\x03\x90\x01r\x11:\f"}, - {"internal/testlog", "\xcd\x02\x01\x14"}, - {"internal/testpty", "~\x03\xb2\x01"}, - {"internal/trace", "\x02\x01\x01\x06f\x0e\x03x\x03\x03\x06\x03\t-\n\x01\x01\x01\x11\x06"}, - {"internal/trace/internal/testgen", "\x03m\x11v\x03\x02\x03\x013\v\r\x11"}, - {"internal/trace/internal/tracev1", "\x03\x01l\x0e\x03~\x06\f7\x01"}, - {"internal/trace/raw", "\x02n\x11{\x03\x06E\x01\x13"}, - {"internal/trace/testtrace", "\x02\x01{\x03r\x04\x03\x05\x01\x05.\v\x02\b\x02\x01\x05"}, + {"internal/testenv", "\x03\nr\x02\x01)\x1c\x100-\x01\x05\a\n\x01\x02\x02\x01\f"}, + {"internal/testhash", "\x03\x91\x01r\x11:\f"}, + {"internal/testlog", "\xce\x02\x01\x14"}, + {"internal/testpty", "\x7f\x03\xb2\x01"}, + {"internal/trace", "\x02\x01\x01\x06g\x0e\x03x\x03\x03\x06\x03\t-\n\x01\x01\x01\x11\x06"}, + {"internal/trace/internal/testgen", "\x03n\x11v\x03\x02\x03\x013\v\r\x11"}, + {"internal/trace/internal/tracev1", "\x03\x01m\x0e\x03~\x06\f7\x01"}, + {"internal/trace/raw", "\x02o\x11{\x03\x06E\x01\x13"}, + {"internal/trace/testtrace", "\x02\x01|\x03r\x04\x03\x05\x01\x05.\v\x02\b\x02\x01\x05"}, {"internal/trace/tracev2", ""}, - {"internal/trace/traceviewer", "\x02g\v\r\x19>\x1f\a\a\x04\b\v\x17\x01\x05\a\n\x01\x02\x0f"}, + {"internal/trace/traceviewer", "\x02h\v\r\x19>\x1f\a\a\x04\b\v\x17\x01\x05\a\n\x01\x02\x0f"}, {"internal/trace/traceviewer/format", ""}, - {"internal/trace/version", "\x81\x01{\t"}, - {"internal/txtar", "\x03~\xb2\x01\x18"}, - {"internal/types/errors", "\xca\x02"}, - {"internal/unsafeheader", "\xe2\x02"}, - {"internal/xcoff", "c\r\x0e\x03h\x1c.\x17\x01"}, - {"internal/zstd", "p\x0e\x03\x84\x01\x0f"}, - {"io", "~\xcf\x01"}, - {"io/fs", "~*,13\x10\x14\x04"}, - {"io/ioutil", "\x85\x02\x01-\x15\x03"}, - {"iter", "\xda\x01f\""}, - {"log", "\x81\x01\x84\x01\x05)\r\r\x01\x0e"}, + {"internal/trace/version", "\x82\x01{\t"}, + {"internal/txtar", "\x03\x7f\xb2\x01\x18"}, + {"internal/types/errors", "\xcb\x02"}, + {"internal/unsafeheader", "\xe3\x02"}, + {"internal/xcoff", "d\r\x0e\x03h\x1c.\x17\x01"}, + {"internal/zstd", "q\x0e\x03\x84\x01\x0f"}, + {"io", "\x7f\xcf\x01"}, + {"io/fs", "\x7f*,13\x10\x14\x04"}, + {"io/ioutil", "\x86\x02\x01-\x15\x03"}, + {"iter", "\xdb\x01f\""}, + {"log", "\x82\x01\x84\x01\x05)\r\r\x01\x0e"}, {"log/internal", ""}, - {"log/slog", "\x03\n^\t\n\x03H<\x04\x01\x02\x02\x03*\x05\b\x02\x01\x02\x01\x0e\x02\x02\x02"}, + {"log/slog", "\x03\n_\t\n\x03H<\x04\x01\x02\x02\x03*\x05\b\x02\x01\x02\x01\x0e\x02\x02\x02"}, {"log/slog/internal", ""}, - {"log/slog/internal/benchmarks", "\rq\x03\x84\x01\x06\x03<\x12"}, - {"log/slog/internal/buffer", "\xcd\x02"}, - {"log/syslog", "~\x03\x88\x01\x12\x18\x18\x02\x0f"}, - {"maps", "\x88\x02Z"}, - {"math", "\xbe\x01VN"}, - {"math/big", "\x03{\x03(\x15G\f\x03\x022\x02\x01\x02\x15"}, - {"math/big/internal/asmgen", "\x03\x01}\x93\x014\x03"}, - {"math/bits", "\xe2\x02"}, - {"math/cmplx", "\x91\x02\x03"}, - {"math/rand", "\xc7\x01J<\x01\x14"}, - {"math/rand/v2", "~+\x03e\x03N"}, - {"mime", "\x02\x01l\x0f\x03\x84\x01\v#\x15\x03\x02\x11\x02"}, - {"mime/multipart", "\x02\x01P+\x03F>\v\x01\a\x02\x17\x02\x06\x0f\x02\x01\x17"}, - {"mime/quotedprintable", "\x02\x01~\x84\x01"}, - {"net", "\x04\tq*\x1f\v\x05\x13\x01\x01\x04\x15\x01'\x06\r\b\x05\x01\x01\r\x06\t"}, - {"net/http", "\x02\x01\x03\x01\x04\x02N\x14\x0f\x03F>\x01\x03\a\x01\x06\x01\x01\x02\x06\x02\x01\x01\f\x01\x01\x05\x01\x02\x05\b\x01\x01\x01\x02\x01\x0e\x02\x02\x02\n\x01\x03"}, - {"net/http/cgi", "\x02Y#\x03\x84\x01\x04\a\v\x01\x15\x01\x01\x01\x04\x01\x05\x02\b\x02\x01\x11\x10"}, - {"net/http/cookiejar", "\x04z\x03\x9a\x01\x01\b\t\x05\x16\x03\x02\x0f\x04"}, - {"net/http/fcgi", "\x02\x01\nc\x0e\x03\x84\x01\x16\x01\x01\x16\x18\x02\x0f"}, - {"net/http/httptest", "\x02\x01\nN\x02#\x01P4\x04\x12\x01\f\t\x02\r\n\x01\x02\x03\f\x06\n"}, - {"net/http/httptrace", "\rNwI\x16+"}, - {"net/http/httputil", "\x02\x01\nq\x03F>\x04\x0f\x03\x01\x05\x02\x01\r\x01\x19\x02\x01\x0e\x10"}, - {"net/http/internal", "\x02\x01m\x0e\x03\x84\x01"}, - {"net/http/internal/ascii", "\xcb\x02\x13"}, - {"net/http/internal/http2", "\x02\x01\x03\x01\x06F\b\x15\x0e\x03\x84\x01\x01\x03\b\x03\x02\x03\x02\x06\x02\x03\x01\n\x01\x01\b\x05\b\x02\x01\x02\x01\x0e\x10\x02\x02"}, - {"net/http/internal/httpcommon", "\rq\x03\xa0\x01\x10\x01\x17\x01\x01\x02\x1f\x02"}, - {"net/http/internal/httpsfv", "\xc8\x02\x02\x01\x11\x04"}, - {"net/http/internal/testcert", "\xcb\x02"}, - {"net/http/pprof", "\x02\x01\nt\x18.\x11-\x04\x13\x16\x01\r\x04\x03\x01\x02\x01\x11"}, + {"log/slog/internal/benchmarks", "\rr\x03\x84\x01\x06\x03<\x12"}, + {"log/slog/internal/buffer", "\xce\x02"}, + {"log/syslog", "\x7f\x03\x88\x01\x12\x18\x18\x02\x0f"}, + {"maps", "\x89\x02Z"}, + {"math", "\xbf\x01VN"}, + {"math/big", "\x03|\x03(\x15G\f\x03\x022\x02\x01\x02\x15"}, + {"math/big/internal/asmgen", "\x03\x01~\x93\x014\x03"}, + {"math/bits", "\xe3\x02"}, + {"math/cmplx", "\x92\x02\x03"}, + {"math/rand", "\xc8\x01J<\x01\x14"}, + {"math/rand/v2", "\x7f+\x03e\x03N"}, + {"mime", "\x02\x01m\x0f\x03\x84\x01\v#\x15\x03\x02\x11\x02"}, + {"mime/multipart", "\x02\x01Q+\x03F>\v\x01\a\x02\x17\x02\x06\x0f\x02\x01\x17"}, + {"mime/quotedprintable", "\x02\x01\x7f\x84\x01"}, + {"net", "\x04\tr*\x1f\v\x05\x13\x01\x01\x04\x15\x01'\x06\r\b\x05\x01\x01\r\x06\t"}, + {"net/http", "\x02\x01\x03\x01\x04\x02O\x14\x0f\x03F>\x01\x03\a\x01\x06\x01\x01\x02\x06\x02\x01\x01\f\x01\x01\x05\x01\x02\x05\b\x01\x01\x01\x02\x01\x0e\x02\x02\x02\n\x01\x03"}, + {"net/http/cgi", "\x02Z#\x03\x84\x01\x04\a\v\x01\x15\x01\x01\x01\x04\x01\x05\x02\b\x02\x01\x11\x10"}, + {"net/http/cookiejar", "\x04{\x03\x9a\x01\x01\b\t\x05\x16\x03\x02\x0f\x04"}, + {"net/http/fcgi", "\x02\x01\nd\x0e\x03\x84\x01\x16\x01\x01\x16\x18\x02\x0f"}, + {"net/http/httptest", "\x02\x01\nO\x02#\x01P4\x04\x12\x01\f\t\x02\r\n\x01\x02\x03\f\x06\n"}, + {"net/http/httptrace", "\rOwI\x16+"}, + {"net/http/httputil", "\x02\x01\nr\x03F>\x04\x0f\x03\x01\x05\x02\x01\r\x01\x19\x02\x0f\x10"}, + {"net/http/internal", "\x02\x01n\x0e\x03\x84\x01"}, + {"net/http/internal/ascii", "\xcc\x02\x13"}, + {"net/http/internal/http2", "\x02\x01\x03\x01\x06G\b\x15\x0e\x03\x84\x01\x01\x03\b\x03\x02\x03\x02\x06\x02\x03\x01\n\x01\x01\b\x05\b\x02\x01\x02\x01\x0e\x10\x02\x02"}, + {"net/http/internal/httpcommon", "\rr\x03\xa0\x01\x10\x01\x17\x01\x01\x02\x1f\x02"}, + {"net/http/internal/httpsfv", "\xc9\x02\x02\x01\x11\x04"}, + {"net/http/internal/testcert", "\xcc\x02"}, + {"net/http/pprof", "\x02\x01\nu\x18.\x11-\x04\x13\x16\x01\r\x04\x03\x01\x02\x01\x11"}, {"net/internal/cgotest", ""}, - {"net/internal/socktest", "\x81\x01\xcc\x01\x02"}, - {"net/mail", "\x02|\x03\x84\x01\x04\x0f\x03\x16\x1a\x02\x0f\x04"}, - {"net/netip", "\x04z*\x01h\x036\x17"}, - {"net/rpc", "\x02p\f\x03\x0f\nk\x04\x12\x01\x1f\r\x03\x02"}, - {"net/rpc/jsonrpc", "t\n\x03\x84\x01\x16\x13\x1f"}, - {"net/smtp", "\x195\r\x14\x0f\x03\x84\x01\x16\x16\x1a"}, - {"net/textproto", "\x02\x01{\x03\x84\x01\f\n/\x01\x02\x15"}, - {"net/url", "~\x03Ff\v\x10\x02\x01\x17"}, - {"os", "~*\x01\x19\x04\x11\x14\x01\x03\x01\x05\x10\x01:\b\x05\x01\x01\r\x06"}, - {"os/exec", "\x03\nqI(\x01\x15\x01-\x06\a\n\x01\x03\x01\r"}, - {"os/exec/internal/fdtest", "\xcf\x02"}, - {"os/signal", "\r\xa6\x02\x15\x05\x02"}, - {"os/user", "\x02\x01{\x03\x84\x01.\r\n\x01\x02"}, - {"path", "~*\xb8\x01"}, - {"path/filepath", "~*\x1aD-\r\b\x03\x04\x11"}, - {"plugin", "~"}, - {"reflect", "~&\x04\x1e\x03\x11\b\x04\x05\x17\x06\t/\n\x03\x11\x02\x02"}, + {"net/internal/socktest", "\x82\x01\xcc\x01\x02"}, + {"net/mail", "\x02}\x03\x84\x01\x04\x0f\x03\x16\x1a\x02\x0f\x04"}, + {"net/netip", "\x04{*\x01h\x036\x17"}, + {"net/rpc", "\x02q\f\x03\x0f\nk\x04\x12\x01\x1f\r\x03\x02"}, + {"net/rpc/jsonrpc", "u\n\x03\x84\x01\x16\x13\x1f"}, + {"net/smtp", "\x196\r\x14\x0f\x03\x84\x01\x16\x16\x1a"}, + {"net/textproto", "\x02\x01|\x03\x84\x01\f\n/\x01\x02\x15"}, + {"net/url", "\x7f\x03Ff\v\x10\x02\x01\x17"}, + {"os", "\x7f*\x01\x19\x04\x11\x14\x01\x03\x01\x05\x10\x01:\b\x05\x01\x01\r\x06"}, + {"os/exec", "\x03\nrI(\x01\x15\x01-\x06\a\n\x01\x03\x01\r"}, + {"os/exec/internal/fdtest", "\xd0\x02"}, + {"os/signal", "\r\xa7\x02\x15\x05\x02"}, + {"os/user", "\x02\x01|\x03\x84\x01.\r\n\x01\x02"}, + {"path", "\x7f*\xb8\x01"}, + {"path/filepath", "\x7f*\x1aD-\r\b\x03\x04\x11"}, + {"plugin", "\x7f"}, + {"reflect", "\x7f&\x04\x1e\x03\x11\b\x04\x05\x17\x06\t/\n\x03\x11\x02\x02"}, {"reflect/internal/example1", ""}, {"reflect/internal/example2", ""}, - {"regexp", "\x03\x82\x02\x037\t\x02\x01\x02\x11\x02"}, - {"regexp/syntax", "\xc8\x02\x01\x01\x01\x02\x11\x02"}, - {"runtime", "\xa4\x01\x04\x01\x03\f\x06\b\x02\x01\x01\x0f\x03\x01\x01\x01\x02\x01\x01\x01\x02\x01\x04\x01\x10\x18N"}, - {"runtime/coverage", "\xb0\x01U"}, - {"runtime/debug", "\x81\x01V\\\r\b\x02\x01\x11\x06"}, - {"runtime/metrics", "\xc8\x01I/\""}, - {"runtime/pprof", "\x02\x01\x01\x03\x06c\x0e\x03#5\v!\f\"\r\b\x01\x01\x01\x02\x02\n\x03\x06"}, - {"runtime/race", "\xc6\x02"}, + {"regexp", "\x03\x83\x02\x037\t\x02\x01\x02\x11\x02"}, + {"regexp/syntax", "\xc9\x02\x01\x01\x01\x02\x11\x02"}, + {"runtime", "\xa5\x01\x04\x01\x03\f\x06\b\x02\x01\x01\x0f\x03\x01\x01\x01\x02\x01\x01\x01\x02\x01\x04\x01\x10\x18N"}, + {"runtime/coverage", "\xb1\x01U"}, + {"runtime/debug", "\x82\x01V\\\r\b\x02\x01\x11\x06"}, + {"runtime/metrics", "\xc9\x01I/\""}, + {"runtime/pprof", "\x02\x01\x01\x03\x06d\x0e\x03#5\v!\f\"\r\b\x01\x01\x01\x02\x02\n\x03\x06"}, + {"runtime/race", "\xc7\x02"}, {"runtime/race/internal/amd64v1", ""}, - {"runtime/trace", "\rq\x03{\t;\b\x05\x01\x0e\x06"}, - {"slices", "\x04\x84\x02\fN"}, - {"sort", "\xdb\x0194"}, - {"strconv", "~*C\x01t"}, - {"strings", "~&\x04D\x19\x03\f9\x11\x02\x02"}, + {"runtime/trace", "\rr\x03{\t;\b\x05\x01\x0e\x06"}, + {"slices", "\x04\x85\x02\fN"}, + {"sort", "\xdc\x0194"}, + {"strconv", "\x7f*C\x01t"}, + {"strings", "\x7f&\x04D\x19\x03\f9\x11\x02\x02"}, {"structs", ""}, - {"sync", "\xda\x01\x02\x11\x01R\x0e\x14"}, - {"sync/atomic", "\xe2\x02"}, - {"syscall", "~'\x03\x01\x1d\n\x04\x06\r\x04U\b\x05\x01\x14"}, - {"testing", "\x03\nq\x02\x01Y\x17\x14\f\x05\x1d\x06\x02\x05\x02\x05\x01\x02\x01\x02\x01\x0e\x02\x04"}, - {"testing/cryptotest", "SV\\\x126\x03\x12"}, - {"testing/fstest", "~\x03\x84\x01\x01\n(\x10\x03\t\b"}, - {"testing/internal/testdeps", "\x02\v\xb7\x011\x10.\x03\x05\x03\x06\a\x02\x0f"}, - {"testing/iotest", "\x03{\x03\x84\x01\x04"}, - {"testing/quick", "\x80\x01\x01\x90\x01\x05%\x10\x11"}, - {"testing/slogtest", "\rq\x03\x8a\x010\x05\x10\f"}, - {"testing/synctest", "\xee\x01b\f\x06"}, - {"text/scanner", "\x03~\x84\x01.+\x02"}, - {"text/tabwriter", "\x81\x01\x84\x01["}, - {"text/template", "~\x03BB\x01\n\"\x01\x05\x01\x02\x05\v\x02\x0e\x03\x02"}, - {"text/template/parse", "\x03~\xbf\x01\n\x01\x13\x02"}, - {"time", "~*D(,\r\x02\x13"}, - {"time/tzdata", "~\xd1\x01\x13"}, + {"sync", "\xdb\x01\x02\x11\x01R\x0e\x14"}, + {"sync/atomic", "\xe3\x02"}, + {"syscall", "\x7f'\x03\x01\x1d\n\x04\x06\r\x04U\b\x05\x01\x14"}, + {"testing", "\x03\nr\x02\x01Y\x17\x14\f\x05\x1d\x06\x02\x05\x02\x05\x01\x02\x01\x02\x01\x0e\x02\x04"}, + {"testing/cryptotest", "TV\\\x126\x03\x12"}, + {"testing/fstest", "\x7f\x03\x84\x01\x01\n(\x10\x03\t\b"}, + {"testing/internal/testdeps", "\x02\v\xb8\x011\x10.\x03\x05\x03\x06\a\x02\x0f"}, + {"testing/iotest", "\x03|\x03\x84\x01\x04"}, + {"testing/quick", "\x81\x01\x01\x90\x01\x05%\x10\x11"}, + {"testing/slogtest", "\rr\x03\x8a\x010\x05\x10\f"}, + {"testing/synctest", "\xef\x01b\f\x06"}, + {"text/scanner", "\x03\x7f\x84\x01.+\x02"}, + {"text/tabwriter", "\x82\x01\x84\x01["}, + {"text/template", "\x7f\x03BB\x01\n\"\x01\x05\x01\x02\x05\v\x02\x0e\x03\x02"}, + {"text/template/parse", "\x03\x7f\xbf\x01\n\x01\x13\x02"}, + {"time", "\x7f*D(,\r\x02\x13"}, + {"time/tzdata", "\x7f\xd1\x01\x13"}, {"unicode", ""}, {"unicode/utf16", ""}, {"unicode/utf8", ""}, - {"unique", "\xa4\x01\"&\x01S\r\x01\x14\x19"}, + {"unique", "\xa5\x01\"&\x01S\r\x01\x14\x19"}, {"unsafe", ""}, - {"uuid", "\x03\x01O\x1d\x03\v\xcf\x01\x0f"}, - {"vendor/golang.org/x/crypto/chacha20", "\x10`\x0e\x96\x01,)"}, - {"vendor/golang.org/x/crypto/chacha20poly1305", "\x10\aY\x0e\xe6\x01\x05\x01\f"}, - {"vendor/golang.org/x/crypto/cryptobyte", "m\x11\x03\x91\x01)!\v"}, + {"uuid", "\x03\x01P\x1d\x03\v\xcf\x01\x0f"}, + {"vendor/golang.org/x/crypto/chacha20", "\x10a\x0e\x96\x01,)"}, + {"vendor/golang.org/x/crypto/chacha20poly1305", "\x10\aZ\x0e\xe6\x01\x05\x01\f"}, + {"vendor/golang.org/x/crypto/cryptobyte", "n\x11\x03\x91\x01)!\v"}, {"vendor/golang.org/x/crypto/cryptobyte/asn1", ""}, - {"vendor/golang.org/x/crypto/hkdf", "\x18\x01e\x15r"}, - {"vendor/golang.org/x/crypto/internal/alias", "\xe2\x02"}, - {"vendor/golang.org/x/crypto/internal/poly1305", "Z\x16\xa4\x01"}, - {"vendor/golang.org/x/net/dns/dnsmessage", "~\xca\x01"}, - {"vendor/golang.org/x/net/http/httpguts", "\x9b\x02\x16\x1a\x15\x10"}, - {"vendor/golang.org/x/net/http/httpproxy", "~\x03\x9a\x01\x12\x05\x01\x18\x15\x10"}, - {"vendor/golang.org/x/net/http2/hpack", "\x03{\x03\x84\x01H"}, - {"vendor/golang.org/x/net/http3", "\x9c\x02@\x06\x0f\x04"}, - {"vendor/golang.org/x/net/idna", "\x81\x01\x90\x01:\x13\x02\x17\x02\x01"}, - {"vendor/golang.org/x/net/internal/http3", "\rN#\x03\x84\x01\v\x04\a\x01\x05\x10\x01\x16\x02\x01\x02\x0f\x10\x02\x04\x03"}, - {"vendor/golang.org/x/net/internal/httpcommon", "\rq\x03\xa0\x01\x10\x01\x17\x01\x01\x02\x1f\x02"}, - {"vendor/golang.org/x/net/internal/quic/quicwire", "p"}, - {"vendor/golang.org/x/net/nettest", "\x03m\x0e\x03\x84\x01\x11\x05\x18\x01\f\n\x01\x02\x02\x01\f"}, - {"vendor/golang.org/x/net/quic", "\x03\n\x01\x01\x01\t:\x04\x04\x15\x03\v\x03\x12r\x06\x06\x06\x04\x12\x06\x15\x02\x01\x02\x01\x01\r\x06\x02\x01\x01\x02\v"}, - {"vendor/golang.org/x/sys/cpu", "\xb3\x02\r\n\x01\x17"}, - {"vendor/golang.org/x/text/secure/bidirule", "~\xe2\x01\x18\x01"}, - {"vendor/golang.org/x/text/transform", "\x03{\x87\x01["}, - {"vendor/golang.org/x/text/unicode/bidi", "\x03\bv\x88\x01@\x17"}, - {"vendor/golang.org/x/text/unicode/norm", "p\x11\x84\x01H\x13\x18"}, - {"weak", "\xa4\x01\x9c\x01\""}, + {"vendor/golang.org/x/crypto/hkdf", "\x18\x01f\x15r"}, + {"vendor/golang.org/x/crypto/internal/alias", "\xe3\x02"}, + {"vendor/golang.org/x/crypto/internal/poly1305", "[\x16\xa4\x01"}, + {"vendor/golang.org/x/net/dns/dnsmessage", "\x7f\xca\x01"}, + {"vendor/golang.org/x/net/http/httpguts", "\x9c\x02\x16\x1a\x15\x10"}, + {"vendor/golang.org/x/net/http/httpproxy", "\x7f\x03\x9a\x01\x12\x05\x01\x18\x15\x10"}, + {"vendor/golang.org/x/net/http2/hpack", "\x03|\x03\x84\x01H"}, + {"vendor/golang.org/x/net/http3", "\x9d\x02@\x06\x0f\x04"}, + {"vendor/golang.org/x/net/idna", "\x82\x01\x90\x01:\x13\x02\x17\x02\x01"}, + {"vendor/golang.org/x/net/internal/http3", "\rO#\x03\x84\x01\v\x04\a\x01\x05\x10\x01\x16\x02\x01\x02\x0f\x10\x02\x04\x03"}, + {"vendor/golang.org/x/net/internal/httpcommon", "\rr\x03\xa0\x01\x10\x01\x17\x01\x01\x02\x1f\x02"}, + {"vendor/golang.org/x/net/internal/quic/quicwire", "q"}, + {"vendor/golang.org/x/net/nettest", "\x03n\x0e\x03\x84\x01\x11\x05\x18\x01\f\n\x01\x02\x02\x01\f"}, + {"vendor/golang.org/x/net/quic", "\x03\n\x01\x01\x01\t;\x04\x04\x15\x03\v\x03\x12r\x06\x06\x06\x04\x12\x06\x15\x02\x01\x02\x01\x01\r\x06\x02\x01\x01\x02\v"}, + {"vendor/golang.org/x/sys/cpu", "\xb4\x02\r\n\x01\x17"}, + {"vendor/golang.org/x/text/secure/bidirule", "\x7f\xe2\x01\x18\x01"}, + {"vendor/golang.org/x/text/transform", "\x03|\x87\x01["}, + {"vendor/golang.org/x/text/unicode/bidi", "\x03\bw\x88\x01@\x17"}, + {"vendor/golang.org/x/text/unicode/norm", "q\x11\x84\x01H\x13\x18"}, + {"weak", "\xa5\x01\x9c\x01\""}, } // bootstrap is the list of bootstrap packages extracted from cmd/dist. diff --git a/vendor/golang.org/x/tools/internal/stdlib/manifest.go b/vendor/golang.org/x/tools/internal/stdlib/manifest.go index 2180c296ec0..e11abf04553 100644 --- a/vendor/golang.org/x/tools/internal/stdlib/manifest.go +++ b/vendor/golang.org/x/tools/internal/stdlib/manifest.go @@ -9153,6 +9153,7 @@ var PackageSymbols = map[string][]Symbol{ {"CrossOriginProtection", Type, 25, ""}, {"DefaultClient", Var, 0, ""}, {"DefaultMaxHeaderBytes", Const, 0, ""}, + {"DefaultMaxHeaderValueCount", Const, 27, ""}, {"DefaultMaxIdleConnsPerHost", Const, 0, ""}, {"DefaultServeMux", Var, 0, ""}, {"DefaultTransport", Var, 0, ""}, @@ -9317,6 +9318,7 @@ var PackageSymbols = map[string][]Symbol{ {"Server.Handler", Field, 0, ""}, {"Server.IdleTimeout", Field, 8, ""}, {"Server.MaxHeaderBytes", Field, 0, ""}, + {"Server.MaxHeaderValueCount", Field, 27, ""}, {"Server.Protocols", Field, 24, ""}, {"Server.ReadHeaderTimeout", Field, 8, ""}, {"Server.ReadTimeout", Field, 0, ""}, diff --git a/vendor/google.golang.org/protobuf/encoding/protodelim/protodelim.go b/vendor/google.golang.org/protobuf/encoding/protodelim/protodelim.go index 2ef36bbcf92..ec63689e725 100644 --- a/vendor/google.golang.org/protobuf/encoding/protodelim/protodelim.go +++ b/vendor/google.golang.org/protobuf/encoding/protodelim/protodelim.go @@ -10,6 +10,7 @@ import ( "encoding/binary" "fmt" "io" + "math" "google.golang.org/protobuf/encoding/protowire" "google.golang.org/protobuf/internal/errors" @@ -117,7 +118,13 @@ func (o UnmarshalOptions) UnmarshalFrom(r Reader, m proto.Message) error { if maxSize == 0 { maxSize = defaultMaxSize } - if maxSize != -1 && size > uint64(maxSize) { + if maxSize == -1 { + // No limit specified: Just check that size fits into an integer, + // otherwise the make([]byte, size) call below will panic. + if size > math.MaxInt { + return errors.Wrap(&SizeTooLargeError{Size: size, MaxSize: math.MaxInt}, "") + } + } else if size > uint64(maxSize) { return errors.Wrap(&SizeTooLargeError{Size: size, MaxSize: uint64(maxSize)}, "") } diff --git a/vendor/google.golang.org/protobuf/encoding/protojson/decode.go b/vendor/google.golang.org/protobuf/encoding/protojson/decode.go index 737d6876d5e..1d6608dc7d5 100644 --- a/vendor/google.golang.org/protobuf/encoding/protojson/decode.go +++ b/vendor/google.golang.org/protobuf/encoding/protojson/decode.go @@ -365,6 +365,10 @@ func unmarshalInt(tok json.Token, bitSize int) (protoreflect.Value, bool) { if err != nil { return protoreflect.Value{}, false } + // Ensure there is no non-number content in this string. + if next, err := dec.Read(); err != nil || next.Kind() != json.EOF { + return protoreflect.Value{}, false + } return getInt(tok, bitSize) } return protoreflect.Value{}, false @@ -397,6 +401,10 @@ func unmarshalUint(tok json.Token, bitSize int) (protoreflect.Value, bool) { if err != nil { return protoreflect.Value{}, false } + // Ensure there is no non-number content in this string. + if next, err := dec.Read(); err != nil || next.Kind() != json.EOF { + return protoreflect.Value{}, false + } return getUint(tok, bitSize) } return protoreflect.Value{}, false @@ -447,6 +455,10 @@ func unmarshalFloat(tok json.Token, bitSize int) (protoreflect.Value, bool) { if err != nil { return protoreflect.Value{}, false } + // Ensure there is no non-number content in this string. + if next, err := dec.Read(); err != nil || next.Kind() != json.EOF { + return protoreflect.Value{}, false + } return getFloat(tok, bitSize) } return protoreflect.Value{}, false diff --git a/vendor/google.golang.org/protobuf/encoding/protojson/well_known_types.go b/vendor/google.golang.org/protobuf/encoding/protojson/well_known_types.go index e9fe1039437..d2eab469474 100644 --- a/vendor/google.golang.org/protobuf/encoding/protojson/well_known_types.go +++ b/vendor/google.golang.org/protobuf/encoding/protojson/well_known_types.go @@ -52,7 +52,10 @@ func wellKnownTypeMarshaler(name protoreflect.FullName) marshalFunc { case genid.FieldMask_message_name: return encoder.marshalFieldMask case genid.Empty_message_name: - return encoder.marshalEmpty + // The spec explicitly specifies that the Empty message + // is not considered to have any special JSON mapping: + // https://protobuf.dev/programming-guides/json/#any + return nil } } return nil diff --git a/vendor/google.golang.org/protobuf/encoding/prototext/decode.go b/vendor/google.golang.org/protobuf/encoding/prototext/decode.go index b53805056a9..20ec09e1948 100644 --- a/vendor/google.golang.org/protobuf/encoding/prototext/decode.go +++ b/vendor/google.golang.org/protobuf/encoding/prototext/decode.go @@ -8,6 +8,7 @@ import ( "fmt" "unicode/utf8" + "google.golang.org/protobuf/encoding/protowire" "google.golang.org/protobuf/internal/encoding/messageset" "google.golang.org/protobuf/internal/encoding/text" "google.golang.org/protobuf/internal/errors" @@ -49,12 +50,19 @@ type UnmarshalOptions struct { protoregistry.MessageTypeResolver protoregistry.ExtensionTypeResolver } + + // RecursionLimit limits how deeply messages may be nested. + // If zero, a default limit is applied. + RecursionLimit int } // Unmarshal reads the given []byte and populates the given [proto.Message] // using options in the UnmarshalOptions object. // The provided message must be mutable (e.g., a non-nil pointer to a message). func (o UnmarshalOptions) Unmarshal(b []byte, m proto.Message) error { + if o.RecursionLimit == 0 { + o.RecursionLimit = protowire.DefaultRecursionLimit + } return o.unmarshal(b, m) } @@ -102,8 +110,14 @@ func (d decoder) syntaxError(pos int, f string, x ...any) error { return errors.New(head+f, x...) } +var errRecursionDepth = errors.New("exceeded maximum recursion depth") + // unmarshalMessage unmarshals into the given protoreflect.Message. func (d decoder) unmarshalMessage(m protoreflect.Message, checkDelims bool) error { + if d.opts.RecursionLimit--; d.opts.RecursionLimit < 0 { + return errRecursionDepth + } + messageDesc := m.Descriptor() if !flags.ProtoLegacy && messageset.IsMessageSet(messageDesc) { return errors.New("no support for proto1 MessageSets") @@ -437,6 +451,10 @@ func (d decoder) unmarshalList(fd protoreflect.FieldDescriptor, list protoreflec // unmarshalMap unmarshals into given protoreflect.Map. A map value is a // textproto message containing {key: , value: }. func (d decoder) unmarshalMap(fd protoreflect.FieldDescriptor, mmap protoreflect.Map) error { + if d.opts.RecursionLimit--; d.opts.RecursionLimit < 0 { + return errRecursionDepth + } + // Determine ahead whether map entry is a scalar type or a message type in // order to call the appropriate unmarshalMapValue func inside // unmarshalMapEntry. diff --git a/vendor/google.golang.org/protobuf/internal/descfmt/stringer.go b/vendor/google.golang.org/protobuf/internal/descfmt/stringer.go index 87e46bd4dfb..0b0dfacbe5a 100644 --- a/vendor/google.golang.org/protobuf/internal/descfmt/stringer.go +++ b/vendor/google.golang.org/protobuf/internal/descfmt/stringer.go @@ -83,12 +83,13 @@ func formatListOpt(vs list, isRoot, allowMulti bool) string { case protoreflect.FileImports: for i := 0; i < vs.Len(); i++ { var rs records - rv := reflect.ValueOf(vs.Get(i)) - rs.Append(rv, []methodAndName{ - {rv.MethodByName("Path"), "Path"}, - {rv.MethodByName("Package"), "Package"}, - {rv.MethodByName("IsPublic"), "IsPublic"}, - {rv.MethodByName("IsWeak"), "IsWeak"}, + fi := vs.Get(i) + rv := reflect.ValueOf(fi) + rs.Append(rv, []attrAndName{ + {fi.Path(), "Path"}, + {fi.Package(), "Package"}, + {fi.IsPublic, "IsPublic"}, + {fi.IsWeak, "IsWeak"}, }...) ss = append(ss, "{"+rs.Join()+"}") } @@ -104,9 +105,9 @@ func formatListOpt(vs list, isRoot, allowMulti bool) string { } } -type methodAndName struct { - method reflect.Value - name string +type attrAndName struct { + attr any + name string } func FormatDesc(s fmt.State, r rune, t protoreflect.Descriptor) { @@ -126,58 +127,58 @@ func formatDescOpt(t protoreflect.Descriptor, isRoot, allowMulti bool, record fu start = rt.Name() + "{" } - _, isFile := t.(protoreflect.FileDescriptor) + fd, isFile := t.(protoreflect.FileDescriptor) rs := records{ allowMulti: allowMulti, record: record, } if t.IsPlaceholder() { if isFile { - rs.Append(rv, []methodAndName{ - {rv.MethodByName("Path"), "Path"}, - {rv.MethodByName("Package"), "Package"}, - {rv.MethodByName("IsPlaceholder"), "IsPlaceholder"}, + rs.Append(rv, []attrAndName{ + {fd.Path(), "Path"}, + {fd.Package(), "Package"}, + {fd.IsPlaceholder(), "IsPlaceholder"}, }...) } else { - rs.Append(rv, []methodAndName{ - {rv.MethodByName("FullName"), "FullName"}, - {rv.MethodByName("IsPlaceholder"), "IsPlaceholder"}, + rs.Append(rv, []attrAndName{ + {t.FullName(), "FullName"}, + {t.IsPlaceholder(), "IsPlaceholder"}, }...) } } else { switch { case isFile: - rs.Append(rv, methodAndName{rv.MethodByName("Syntax"), "Syntax"}) + rs.Append(rv, attrAndName{fd.Syntax(), "Syntax"}) case isRoot: - rs.Append(rv, []methodAndName{ - {rv.MethodByName("Syntax"), "Syntax"}, - {rv.MethodByName("FullName"), "FullName"}, + rs.Append(rv, []attrAndName{ + {t.Syntax(), "Syntax"}, + {t.FullName(), "FullName"}, }...) default: - rs.Append(rv, methodAndName{rv.MethodByName("Name"), "Name"}) + rs.Append(rv, attrAndName{t.Name(), "Name"}) } switch t := t.(type) { case protoreflect.FieldDescriptor: - accessors := []methodAndName{ - {rv.MethodByName("Number"), "Number"}, - {rv.MethodByName("Cardinality"), "Cardinality"}, - {rv.MethodByName("Kind"), "Kind"}, - {rv.MethodByName("HasJSONName"), "HasJSONName"}, - {rv.MethodByName("JSONName"), "JSONName"}, - {rv.MethodByName("HasPresence"), "HasPresence"}, - {rv.MethodByName("IsExtension"), "IsExtension"}, - {rv.MethodByName("IsPacked"), "IsPacked"}, - {rv.MethodByName("IsWeak"), "IsWeak"}, - {rv.MethodByName("IsList"), "IsList"}, - {rv.MethodByName("IsMap"), "IsMap"}, - {rv.MethodByName("MapKey"), "MapKey"}, - {rv.MethodByName("MapValue"), "MapValue"}, - {rv.MethodByName("HasDefault"), "HasDefault"}, - {rv.MethodByName("Default"), "Default"}, - {rv.MethodByName("ContainingOneof"), "ContainingOneof"}, - {rv.MethodByName("ContainingMessage"), "ContainingMessage"}, - {rv.MethodByName("Message"), "Message"}, - {rv.MethodByName("Enum"), "Enum"}, + accessors := []attrAndName{ + {t.Number(), "Number"}, + {t.Cardinality(), "Cardinality"}, + {t.Kind(), "Kind"}, + {t.HasJSONName(), "HasJSONName"}, + {t.JSONName(), "JSONName"}, + {t.HasPresence(), "HasPresence"}, + {t.IsExtension(), "IsExtension"}, + {t.IsPacked(), "IsPacked"}, + {t.IsWeak(), "IsWeak"}, + {t.IsList(), "IsList"}, + {t.IsMap(), "IsMap"}, + {t.MapKey(), "MapKey"}, + {t.MapValue(), "MapValue"}, + {t.HasDefault(), "HasDefault"}, + {t.Default(), "Default"}, + {t.ContainingOneof(), "ContainingOneof"}, + {t.ContainingMessage(), "ContainingMessage"}, + {t.Message(), "Message"}, + {t.Enum(), "Enum"}, } for _, s := range accessors { switch s.name { @@ -223,58 +224,54 @@ func formatDescOpt(t protoreflect.Descriptor, isRoot, allowMulti bool, record fu } case protoreflect.FileDescriptor: - rs.Append(rv, []methodAndName{ - {rv.MethodByName("Path"), "Path"}, - {rv.MethodByName("Package"), "Package"}, - {rv.MethodByName("Imports"), "Imports"}, - {rv.MethodByName("Messages"), "Messages"}, - {rv.MethodByName("Enums"), "Enums"}, - {rv.MethodByName("Extensions"), "Extensions"}, - {rv.MethodByName("Services"), "Services"}, + rs.Append(rv, []attrAndName{ + {t.Path(), "Path"}, + {t.Package(), "Package"}, + {t.Imports(), "Imports"}, + {t.Messages(), "Messages"}, + {t.Enums(), "Enums"}, + {t.Extensions(), "Extensions"}, + {t.Services(), "Services"}, }...) case protoreflect.MessageDescriptor: - rs.Append(rv, []methodAndName{ - {rv.MethodByName("IsMapEntry"), "IsMapEntry"}, - {rv.MethodByName("Fields"), "Fields"}, - {rv.MethodByName("Oneofs"), "Oneofs"}, - {rv.MethodByName("ReservedNames"), "ReservedNames"}, - {rv.MethodByName("ReservedRanges"), "ReservedRanges"}, - {rv.MethodByName("RequiredNumbers"), "RequiredNumbers"}, - {rv.MethodByName("ExtensionRanges"), "ExtensionRanges"}, - {rv.MethodByName("Messages"), "Messages"}, - {rv.MethodByName("Enums"), "Enums"}, - {rv.MethodByName("Extensions"), "Extensions"}, + rs.Append(rv, []attrAndName{ + {t.IsMapEntry(), "IsMapEntry"}, + {t.Fields(), "Fields"}, + {t.Oneofs(), "Oneofs"}, + {t.ReservedNames(), "ReservedNames"}, + {t.ReservedRanges(), "ReservedRanges"}, + {t.RequiredNumbers(), "RequiredNumbers"}, + {t.ExtensionRanges(), "ExtensionRanges"}, + {t.Messages(), "Messages"}, + {t.Enums(), "Enums"}, + {t.Extensions(), "Extensions"}, }...) case protoreflect.EnumDescriptor: - rs.Append(rv, []methodAndName{ - {rv.MethodByName("Values"), "Values"}, - {rv.MethodByName("ReservedNames"), "ReservedNames"}, - {rv.MethodByName("ReservedRanges"), "ReservedRanges"}, - {rv.MethodByName("IsClosed"), "IsClosed"}, + rs.Append(rv, []attrAndName{ + {t.Values(), "Values"}, + {t.ReservedNames(), "ReservedNames"}, + {t.ReservedRanges(), "ReservedRanges"}, + {t.IsClosed(), "IsClosed"}, }...) case protoreflect.EnumValueDescriptor: - rs.Append(rv, []methodAndName{ - {rv.MethodByName("Number"), "Number"}, - }...) + rs.Append(rv, attrAndName{t.Number(), "Number"}) case protoreflect.ServiceDescriptor: - rs.Append(rv, []methodAndName{ - {rv.MethodByName("Methods"), "Methods"}, - }...) + rs.Append(rv, attrAndName{t.Methods(), "Methods"}) case protoreflect.MethodDescriptor: - rs.Append(rv, []methodAndName{ - {rv.MethodByName("Input"), "Input"}, - {rv.MethodByName("Output"), "Output"}, - {rv.MethodByName("IsStreamingClient"), "IsStreamingClient"}, - {rv.MethodByName("IsStreamingServer"), "IsStreamingServer"}, + rs.Append(rv, []attrAndName{ + {t.Input(), "Input"}, + {t.Output(), "Output"}, + {t.IsStreamingClient(), "IsStreamingClient"}, + {t.IsStreamingServer(), "IsStreamingServer"}, }...) } - if m := rv.MethodByName("GoType"); m.IsValid() { - rs.Append(rv, methodAndName{m, "GoType"}) + if m, ok := t.(interface{ GoType() reflect.Type }); ok { + rs.Append(rv, attrAndName{m.GoType(), "GoType"}) } } return start + rs.Join() + end @@ -297,68 +294,66 @@ func (rs *records) AppendRecs(fieldName string, newRecs [2]string) { rs.recs = append(rs.recs, newRecs) } -func (rs *records) Append(v reflect.Value, accessors ...methodAndName) { - for _, a := range accessors { - if rs.record != nil { - rs.record(a.name) - } - var rv reflect.Value - if a.method.IsValid() { - rv = a.method.Call(nil)[0] - } - if v.Kind() == reflect.Struct && !rv.IsValid() { - rv = v.FieldByName(a.name) - } - if !rv.IsValid() { - panic(fmt.Sprintf("unknown accessor: %v.%s", v.Type(), a.name)) - } - if _, ok := rv.Interface().(protoreflect.Value); ok { - rv = rv.MethodByName("Interface").Call(nil)[0] - if !rv.IsNil() { - rv = rv.Elem() - } - } +func (rs *records) Append(v reflect.Value, results ...attrAndName) { + for _, r := range results { + rs.appendAttribute(v, r.name, r.attr) + } +} - // Ignore zero values. - var isZero bool - switch rv.Kind() { - case reflect.Interface, reflect.Slice: - isZero = rv.IsNil() - case reflect.Bool: - isZero = rv.Bool() == false - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - isZero = rv.Int() == 0 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - isZero = rv.Uint() == 0 - case reflect.String: - isZero = rv.String() == "" - } - if n, ok := rv.Interface().(list); ok { - isZero = n.Len() == 0 - } - if isZero { - continue +func (rs *records) appendAttribute(val reflect.Value, name string, attrVal any) { + if rs.record != nil { + rs.record(name) + } + if attrVal == nil { + return + } + rv := reflect.ValueOf(attrVal) + if _, ok := rv.Interface().(protoreflect.Value); ok { + rv = rv.MethodByName("Interface").Call(nil)[0] + if !rv.IsNil() { + rv = rv.Elem() } + } - // Format the value. - var s string - v := rv.Interface() - switch v := v.(type) { - case list: - s = formatListOpt(v, false, rs.allowMulti) - case protoreflect.FieldDescriptor, protoreflect.OneofDescriptor, protoreflect.EnumValueDescriptor, protoreflect.MethodDescriptor: - s = string(v.(protoreflect.Descriptor).Name()) - case protoreflect.Descriptor: - s = string(v.FullName()) - case string: - s = strconv.Quote(v) - case []byte: - s = fmt.Sprintf("%q", v) - default: - s = fmt.Sprint(v) - } - rs.recs = append(rs.recs, [2]string{a.name, s}) + // Ignore zero values. + var isZero bool + switch rv.Kind() { + case reflect.Interface, reflect.Slice: + isZero = rv.IsNil() + case reflect.Bool: + isZero = rv.Bool() == false + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + isZero = rv.Int() == 0 + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + isZero = rv.Uint() == 0 + case reflect.String: + isZero = rv.String() == "" + } + if n, ok := rv.Interface().(list); ok { + isZero = n.Len() == 0 + } + if isZero { + return + } + + // Format the value. + var s string + v := rv.Interface() + switch v := v.(type) { + case list: + s = formatListOpt(v, false, rs.allowMulti) + case protoreflect.FieldDescriptor, protoreflect.OneofDescriptor, protoreflect.EnumValueDescriptor, protoreflect.MethodDescriptor: + s = string(v.(protoreflect.Descriptor).Name()) + case protoreflect.Descriptor: + s = string(v.FullName()) + case string: + s = strconv.Quote(v) + case []byte: + s = fmt.Sprintf("%q", v) + default: + s = fmt.Sprint(v) } + rs.recs = append(rs.recs, [2]string{name, s}) } func (rs *records) Join() string { diff --git a/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb b/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb index 04696351eee..ad35ea4c449 100644 Binary files a/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb and b/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb differ diff --git a/vendor/google.golang.org/protobuf/internal/encoding/defval/default.go b/vendor/google.golang.org/protobuf/internal/encoding/defval/default.go index 328dc733b04..079a53dd15a 100644 --- a/vendor/google.golang.org/protobuf/internal/encoding/defval/default.go +++ b/vendor/google.golang.org/protobuf/internal/encoding/defval/default.go @@ -69,19 +69,19 @@ func Unmarshal(s string, k protoreflect.Kind, evs protoreflect.EnumValueDescript } } case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind: - if v, err := strconv.ParseInt(s, 10, 32); err == nil { + if v, err := strconv.ParseInt(s, 0, 32); err == nil { return protoreflect.ValueOfInt32(int32(v)), nil, nil } case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind: - if v, err := strconv.ParseInt(s, 10, 64); err == nil { + if v, err := strconv.ParseInt(s, 0, 64); err == nil { return protoreflect.ValueOfInt64(int64(v)), nil, nil } case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: - if v, err := strconv.ParseUint(s, 10, 32); err == nil { + if v, err := strconv.ParseUint(s, 0, 32); err == nil { return protoreflect.ValueOfUint32(uint32(v)), nil, nil } case protoreflect.Uint64Kind, protoreflect.Fixed64Kind: - if v, err := strconv.ParseUint(s, 10, 64); err == nil { + if v, err := strconv.ParseUint(s, 0, 64); err == nil { return protoreflect.ValueOfUint64(uint64(v)), nil, nil } case protoreflect.FloatKind, protoreflect.DoubleKind: diff --git a/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go b/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go index 65aaf4d210a..58aeff8456d 100644 --- a/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go +++ b/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go @@ -26,6 +26,7 @@ const ( Edition_EDITION_PROTO3_enum_value = 999 Edition_EDITION_2023_enum_value = 1000 Edition_EDITION_2024_enum_value = 1001 + Edition_EDITION_2026_enum_value = 1002 Edition_EDITION_UNSTABLE_enum_value = 9999 Edition_EDITION_1_TEST_ONLY_enum_value = 1 Edition_EDITION_2_TEST_ONLY_enum_value = 2 @@ -806,11 +807,13 @@ const ( FieldOptions_FeatureSupport_EditionDeprecated_field_name protoreflect.Name = "edition_deprecated" FieldOptions_FeatureSupport_DeprecationWarning_field_name protoreflect.Name = "deprecation_warning" FieldOptions_FeatureSupport_EditionRemoved_field_name protoreflect.Name = "edition_removed" + FieldOptions_FeatureSupport_RemovalError_field_name protoreflect.Name = "removal_error" FieldOptions_FeatureSupport_EditionIntroduced_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport.edition_introduced" FieldOptions_FeatureSupport_EditionDeprecated_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport.edition_deprecated" FieldOptions_FeatureSupport_DeprecationWarning_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport.deprecation_warning" FieldOptions_FeatureSupport_EditionRemoved_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport.edition_removed" + FieldOptions_FeatureSupport_RemovalError_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport.removal_error" ) // Field numbers for google.protobuf.FieldOptions.FeatureSupport. @@ -819,6 +822,7 @@ const ( FieldOptions_FeatureSupport_EditionDeprecated_field_number protoreflect.FieldNumber = 2 FieldOptions_FeatureSupport_DeprecationWarning_field_number protoreflect.FieldNumber = 3 FieldOptions_FeatureSupport_EditionRemoved_field_number protoreflect.FieldNumber = 4 + FieldOptions_FeatureSupport_RemovalError_field_number protoreflect.FieldNumber = 5 ) // Names for google.protobuf.OneofOptions. @@ -1152,6 +1156,7 @@ const ( FeatureSet_ENFORCE_NAMING_STYLE_UNKNOWN_enum_value = 0 FeatureSet_STYLE2024_enum_value = 1 FeatureSet_STYLE_LEGACY_enum_value = 2 + FeatureSet_STYLE2026_enum_value = 3 ) // Names for google.protobuf.FeatureSet.VisibilityFeature. diff --git a/vendor/google.golang.org/protobuf/internal/version/version.go b/vendor/google.golang.org/protobuf/internal/version/version.go index 763fd82841c..58ff0e24644 100644 --- a/vendor/google.golang.org/protobuf/internal/version/version.go +++ b/vendor/google.golang.org/protobuf/internal/version/version.go @@ -52,7 +52,7 @@ import ( const ( Major = 1 Minor = 36 - Patch = 11 + Patch = 12 PreRelease = "" ) diff --git a/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go b/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go index c826ad04303..84a3228edb4 100644 --- a/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go +++ b/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go @@ -201,6 +201,7 @@ func (r descsByName) initExtensionDeclarations(xds []*descriptorpb.FieldDescript return nil, err } x.L1.EditionFeatures = mergeEditionFeatures(parent, xd.GetOptions().GetFeatures()) + x.L2.IsProto3Optional = xd.GetProto3Optional() if opts := xd.GetOptions(); opts != nil { opts = proto.Clone(opts).(*descriptorpb.FieldOptions) x.L2.Options = func() protoreflect.ProtoMessage { return opts } diff --git a/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go b/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go index 730331e6668..86f0d092620 100644 --- a/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go +++ b/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go @@ -546,6 +546,8 @@ func (p *SourcePath) appendFieldOptions_FeatureSupport(b []byte) []byte { b = p.appendSingularField(b, "deprecation_warning", nil) case 4: b = p.appendSingularField(b, "edition_removed", nil) + case 5: + b = p.appendSingularField(b, "removal_error", nil) } return b } diff --git a/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go b/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go index 0b23faa957c..a51cb1e546c 100644 --- a/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go +++ b/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go @@ -1,32 +1,9 @@ // Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ +// Copyright 2008 Google LLC. All rights reserved. // -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd // Author: kenton@google.com (Kenton Varda) // Based on original Protocol Buffers design by @@ -69,6 +46,7 @@ const ( // comparison. Edition_EDITION_2023 Edition = 1000 Edition_EDITION_2024 Edition = 1001 + Edition_EDITION_2026 Edition = 1002 // A placeholder edition for developing and testing unscheduled features. Edition_EDITION_UNSTABLE Edition = 9999 // Placeholder editions for testing feature resolution. These should not be @@ -93,6 +71,7 @@ var ( 999: "EDITION_PROTO3", 1000: "EDITION_2023", 1001: "EDITION_2024", + 1002: "EDITION_2026", 9999: "EDITION_UNSTABLE", 1: "EDITION_1_TEST_ONLY", 2: "EDITION_2_TEST_ONLY", @@ -108,6 +87,7 @@ var ( "EDITION_PROTO3": 999, "EDITION_2023": 1000, "EDITION_2024": 1001, + "EDITION_2026": 1002, "EDITION_UNSTABLE": 9999, "EDITION_1_TEST_ONLY": 1, "EDITION_2_TEST_ONLY": 2, @@ -1213,6 +1193,7 @@ const ( FeatureSet_ENFORCE_NAMING_STYLE_UNKNOWN FeatureSet_EnforceNamingStyle = 0 FeatureSet_STYLE2024 FeatureSet_EnforceNamingStyle = 1 FeatureSet_STYLE_LEGACY FeatureSet_EnforceNamingStyle = 2 + FeatureSet_STYLE2026 FeatureSet_EnforceNamingStyle = 3 ) // Enum value maps for FeatureSet_EnforceNamingStyle. @@ -1221,11 +1202,13 @@ var ( 0: "ENFORCE_NAMING_STYLE_UNKNOWN", 1: "STYLE2024", 2: "STYLE_LEGACY", + 3: "STYLE2026", } FeatureSet_EnforceNamingStyle_value = map[string]int32{ "ENFORCE_NAMING_STYLE_UNKNOWN": 0, "STYLE2024": 1, "STYLE_LEGACY": 2, + "STYLE2026": 3, } ) @@ -4204,8 +4187,11 @@ type FieldOptions_FeatureSupport struct { // this one, the last default assigned will be used, and proto files will // not be able to override it. EditionRemoved *Edition `protobuf:"varint,4,opt,name=edition_removed,json=editionRemoved,enum=google.protobuf.Edition" json:"edition_removed,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + // The removal error text if this feature is used after the edition it was + // removed in. + RemovalError *string `protobuf:"bytes,5,opt,name=removal_error,json=removalError" json:"removal_error,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *FieldOptions_FeatureSupport) Reset() { @@ -4266,6 +4252,13 @@ func (x *FieldOptions_FeatureSupport) GetEditionRemoved() Edition { return Edition_EDITION_UNKNOWN } +func (x *FieldOptions_FeatureSupport) GetRemovalError() string { + if x != nil && x.RemovalError != nil { + return *x.RemovalError + } + return "" +} + // The name of the uninterpreted option. Each string represents a segment in // a dot-separated name. is_extension is true iff a segment represents an // extension (denoted with parentheses in options specs in .proto files). @@ -4719,7 +4712,7 @@ const file_google_protobuf_descriptor_proto_rawDesc = "" + "\aoptions\x18\x03 \x01(\v2&.google.protobuf.ExtensionRangeOptionsR\aoptions\x1a7\n" + "\rReservedRange\x12\x14\n" + "\x05start\x18\x01 \x01(\x05R\x05start\x12\x10\n" + - "\x03end\x18\x02 \x01(\x05R\x03end\"\xcc\x04\n" + + "\x03end\x18\x02 \x01(\x05R\x03end\"\xd4\x04\n" + "\x15ExtensionRangeOptions\x12X\n" + "\x14uninterpreted_option\x18\xe7\a \x03(\v2$.google.protobuf.UninterpretedOptionR\x13uninterpretedOption\x12Y\n" + "\vdeclaration\x18\x02 \x03(\v22.google.protobuf.ExtensionRangeOptions.DeclarationB\x03\x88\x01\x02R\vdeclaration\x127\n" + @@ -4735,7 +4728,7 @@ const file_google_protobuf_descriptor_proto_rawDesc = "" + "\x11VerificationState\x12\x0f\n" + "\vDECLARATION\x10\x00\x12\x0e\n" + "\n" + - "UNVERIFIED\x10\x01*\t\b\xe8\a\x10\x80\x80\x80\x80\x02\"\xc1\x06\n" + + "UNVERIFIED\x10\x01*\x06\b\xde\a\x10\xe7\a*\t\b\xe8\a\x10\x80\x80\x80\x80\x02\"\xc1\x06\n" + "\x14FieldDescriptorProto\x12\x12\n" + "\x04name\x18\x01 \x01(\tR\x04name\x12\x16\n" + "\x06number\x18\x03 \x01(\x05R\x06number\x12A\n" + @@ -4810,12 +4803,13 @@ const file_google_protobuf_descriptor_proto_rawDesc = "" + "outputType\x128\n" + "\aoptions\x18\x04 \x01(\v2\x1e.google.protobuf.MethodOptionsR\aoptions\x120\n" + "\x10client_streaming\x18\x05 \x01(\b:\x05falseR\x0fclientStreaming\x120\n" + - "\x10server_streaming\x18\x06 \x01(\b:\x05falseR\x0fserverStreaming\"\xad\t\n" + + "\x10server_streaming\x18\x06 \x01(\b:\x05falseR\x0fserverStreaming\"\xfa\n" + + "\n" + "\vFileOptions\x12!\n" + "\fjava_package\x18\x01 \x01(\tR\vjavaPackage\x120\n" + - "\x14java_outer_classname\x18\b \x01(\tR\x12javaOuterClassname\x125\n" + + "\x14java_outer_classname\x18\b \x01(\tR\x12javaOuterClassname\x12\xf9\x01\n" + "\x13java_multiple_files\x18\n" + - " \x01(\b:\x05falseR\x11javaMultipleFiles\x12D\n" + + " \x01(\b:\x05falseB\xc1\x01\xb2\x01\xbd\x01\b\xe6\a \xe9\a*\xb4\x01This behavior is enabled by default in editions 2024 and above. To disable it, you can set `features.(pb.java).nest_in_file_class = YES` on individual messages, enums, or services.R\x11javaMultipleFiles\x12D\n" + "\x1djava_generate_equals_and_hash\x18\x14 \x01(\bB\x02\x18\x01R\x19javaGenerateEqualsAndHash\x12:\n" + "\x16java_string_check_utf8\x18\x1b \x01(\b:\x05falseR\x13javaStringCheckUtf8\x12S\n" + "\foptimize_for\x18\t \x01(\x0e2).google.protobuf.FileOptions.OptimizeMode:\x05SPEEDR\voptimizeFor\x12\x1d\n" + @@ -4840,7 +4834,7 @@ const file_google_protobuf_descriptor_proto_rawDesc = "" + "\fOptimizeMode\x12\t\n" + "\x05SPEED\x10\x01\x12\r\n" + "\tCODE_SIZE\x10\x02\x12\x10\n" + - "\fLITE_RUNTIME\x10\x03*\t\b\xe8\a\x10\x80\x80\x80\x80\x02J\x04\b*\x10+J\x04\b&\x10'R\x14php_generic_services\"\xf4\x03\n" + + "\fLITE_RUNTIME\x10\x03*\x06\b\xde\a\x10\xe7\a*\t\b\xe8\a\x10\x80\x80\x80\x80\x02J\x04\b*\x10+J\x04\b&\x10'R\x14php_generic_services\"\xfc\x03\n" + "\x0eMessageOptions\x12<\n" + "\x17message_set_wire_format\x18\x01 \x01(\b:\x05falseR\x14messageSetWireFormat\x12L\n" + "\x1fno_standard_descriptor_accessor\x18\x02 \x01(\b:\x05falseR\x1cnoStandardDescriptorAccessor\x12%\n" + @@ -4850,8 +4844,8 @@ const file_google_protobuf_descriptor_proto_rawDesc = "" + "\tmap_entry\x18\a \x01(\bR\bmapEntry\x12V\n" + "&deprecated_legacy_json_field_conflicts\x18\v \x01(\bB\x02\x18\x01R\"deprecatedLegacyJsonFieldConflicts\x127\n" + "\bfeatures\x18\f \x01(\v2\x1b.google.protobuf.FeatureSetR\bfeatures\x12X\n" + - "\x14uninterpreted_option\x18\xe7\a \x03(\v2$.google.protobuf.UninterpretedOptionR\x13uninterpretedOption*\t\b\xe8\a\x10\x80\x80\x80\x80\x02J\x04\b\x04\x10\x05J\x04\b\x05\x10\x06J\x04\b\x06\x10\aJ\x04\b\b\x10\tJ\x04\b\t\x10\n" + - "\"\xa1\r\n" + + "\x14uninterpreted_option\x18\xe7\a \x03(\v2$.google.protobuf.UninterpretedOptionR\x13uninterpretedOption*\x06\b\xde\a\x10\xe7\a*\t\b\xe8\a\x10\x80\x80\x80\x80\x02J\x04\b\x04\x10\x05J\x04\b\x05\x10\x06J\x04\b\x06\x10\aJ\x04\b\b\x10\tJ\x04\b\t\x10\n" + + "\"\xce\r\n" + "\fFieldOptions\x12A\n" + "\x05ctype\x18\x01 \x01(\x0e2#.google.protobuf.FieldOptions.CType:\x06STRINGR\x05ctype\x12\x16\n" + "\x06packed\x18\x02 \x01(\bR\x06packed\x12G\n" + @@ -4872,12 +4866,13 @@ const file_google_protobuf_descriptor_proto_rawDesc = "" + "\x14uninterpreted_option\x18\xe7\a \x03(\v2$.google.protobuf.UninterpretedOptionR\x13uninterpretedOption\x1aZ\n" + "\x0eEditionDefault\x122\n" + "\aedition\x18\x03 \x01(\x0e2\x18.google.protobuf.EditionR\aedition\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value\x1a\x96\x02\n" + + "\x05value\x18\x02 \x01(\tR\x05value\x1a\xbb\x02\n" + "\x0eFeatureSupport\x12G\n" + "\x12edition_introduced\x18\x01 \x01(\x0e2\x18.google.protobuf.EditionR\x11editionIntroduced\x12G\n" + "\x12edition_deprecated\x18\x02 \x01(\x0e2\x18.google.protobuf.EditionR\x11editionDeprecated\x12/\n" + "\x13deprecation_warning\x18\x03 \x01(\tR\x12deprecationWarning\x12A\n" + - "\x0fedition_removed\x18\x04 \x01(\x0e2\x18.google.protobuf.EditionR\x0eeditionRemoved\"/\n" + + "\x0fedition_removed\x18\x04 \x01(\x0e2\x18.google.protobuf.EditionR\x0eeditionRemoved\x12#\n" + + "\rremoval_error\x18\x05 \x01(\tR\fremovalError\"/\n" + "\x05CType\x12\n" + "\n" + "\x06STRING\x10\x00\x12\b\n" + @@ -4901,10 +4896,10 @@ const file_google_protobuf_descriptor_proto_rawDesc = "" + "\x10TARGET_TYPE_ENUM\x10\x06\x12\x1a\n" + "\x16TARGET_TYPE_ENUM_ENTRY\x10\a\x12\x17\n" + "\x13TARGET_TYPE_SERVICE\x10\b\x12\x16\n" + - "\x12TARGET_TYPE_METHOD\x10\t*\t\b\xe8\a\x10\x80\x80\x80\x80\x02J\x04\b\x04\x10\x05J\x04\b\x12\x10\x13\"\xac\x01\n" + + "\x12TARGET_TYPE_METHOD\x10\t*\x06\b\xde\a\x10\xe7\a*\t\b\xe8\a\x10\x80\x80\x80\x80\x02J\x04\b\x04\x10\x05J\x04\b\x12\x10\x13\"\xb4\x01\n" + "\fOneofOptions\x127\n" + "\bfeatures\x18\x01 \x01(\v2\x1b.google.protobuf.FeatureSetR\bfeatures\x12X\n" + - "\x14uninterpreted_option\x18\xe7\a \x03(\v2$.google.protobuf.UninterpretedOptionR\x13uninterpretedOption*\t\b\xe8\a\x10\x80\x80\x80\x80\x02\"\xd1\x02\n" + + "\x14uninterpreted_option\x18\xe7\a \x03(\v2$.google.protobuf.UninterpretedOptionR\x13uninterpretedOption*\x06\b\xde\a\x10\xe7\a*\t\b\xe8\a\x10\x80\x80\x80\x80\x02\"\xd9\x02\n" + "\vEnumOptions\x12\x1f\n" + "\vallow_alias\x18\x02 \x01(\bR\n" + "allowAlias\x12%\n" + @@ -4913,7 +4908,7 @@ const file_google_protobuf_descriptor_proto_rawDesc = "" + "deprecated\x12V\n" + "&deprecated_legacy_json_field_conflicts\x18\x06 \x01(\bB\x02\x18\x01R\"deprecatedLegacyJsonFieldConflicts\x127\n" + "\bfeatures\x18\a \x01(\v2\x1b.google.protobuf.FeatureSetR\bfeatures\x12X\n" + - "\x14uninterpreted_option\x18\xe7\a \x03(\v2$.google.protobuf.UninterpretedOptionR\x13uninterpretedOption*\t\b\xe8\a\x10\x80\x80\x80\x80\x02J\x04\b\x05\x10\x06\"\xd8\x02\n" + + "\x14uninterpreted_option\x18\xe7\a \x03(\v2$.google.protobuf.UninterpretedOptionR\x13uninterpretedOption*\x06\b\xde\a\x10\xe7\a*\t\b\xe8\a\x10\x80\x80\x80\x80\x02J\x04\b\x05\x10\x06\"\xe0\x02\n" + "\x10EnumValueOptions\x12%\n" + "\n" + "deprecated\x18\x01 \x01(\b:\x05falseR\n" + @@ -4921,13 +4916,13 @@ const file_google_protobuf_descriptor_proto_rawDesc = "" + "\bfeatures\x18\x02 \x01(\v2\x1b.google.protobuf.FeatureSetR\bfeatures\x12(\n" + "\fdebug_redact\x18\x03 \x01(\b:\x05falseR\vdebugRedact\x12U\n" + "\x0ffeature_support\x18\x04 \x01(\v2,.google.protobuf.FieldOptions.FeatureSupportR\x0efeatureSupport\x12X\n" + - "\x14uninterpreted_option\x18\xe7\a \x03(\v2$.google.protobuf.UninterpretedOptionR\x13uninterpretedOption*\t\b\xe8\a\x10\x80\x80\x80\x80\x02\"\xd5\x01\n" + + "\x14uninterpreted_option\x18\xe7\a \x03(\v2$.google.protobuf.UninterpretedOptionR\x13uninterpretedOption*\x06\b\xde\a\x10\xe7\a*\t\b\xe8\a\x10\x80\x80\x80\x80\x02\"\xdd\x01\n" + "\x0eServiceOptions\x127\n" + "\bfeatures\x18\" \x01(\v2\x1b.google.protobuf.FeatureSetR\bfeatures\x12%\n" + "\n" + "deprecated\x18! \x01(\b:\x05falseR\n" + "deprecated\x12X\n" + - "\x14uninterpreted_option\x18\xe7\a \x03(\v2$.google.protobuf.UninterpretedOptionR\x13uninterpretedOption*\t\b\xe8\a\x10\x80\x80\x80\x80\x02\"\x99\x03\n" + + "\x14uninterpreted_option\x18\xe7\a \x03(\v2$.google.protobuf.UninterpretedOptionR\x13uninterpretedOption*\x06\b\xde\a\x10\xe7\a*\t\b\xe8\a\x10\x80\x80\x80\x80\x02\"\xa1\x03\n" + "\rMethodOptions\x12%\n" + "\n" + "deprecated\x18! \x01(\b:\x05falseR\n" + @@ -4939,7 +4934,7 @@ const file_google_protobuf_descriptor_proto_rawDesc = "" + "\x13IDEMPOTENCY_UNKNOWN\x10\x00\x12\x13\n" + "\x0fNO_SIDE_EFFECTS\x10\x01\x12\x0e\n" + "\n" + - "IDEMPOTENT\x10\x02*\t\b\xe8\a\x10\x80\x80\x80\x80\x02\"\x9a\x03\n" + + "IDEMPOTENT\x10\x02*\x06\b\xde\a\x10\xe7\a*\t\b\xe8\a\x10\x80\x80\x80\x80\x02\"\x9a\x03\n" + "\x13UninterpretedOption\x12A\n" + "\x04name\x18\x02 \x03(\v2-.google.protobuf.UninterpretedOption.NamePartR\x04name\x12)\n" + "\x10identifier_value\x18\x03 \x01(\tR\x0fidentifierValue\x12,\n" + @@ -4950,7 +4945,7 @@ const file_google_protobuf_descriptor_proto_rawDesc = "" + "\x0faggregate_value\x18\b \x01(\tR\x0eaggregateValue\x1aJ\n" + "\bNamePart\x12\x1b\n" + "\tname_part\x18\x01 \x02(\tR\bnamePart\x12!\n" + - "\fis_extension\x18\x02 \x02(\bR\visExtension\"\x8e\x0f\n" + + "\fis_extension\x18\x02 \x02(\bR\visExtension\"\xae\x0f\n" + "\n" + "FeatureSet\x12\x91\x01\n" + "\x0efield_presence\x18\x01 \x01(\x0e2).google.protobuf.FeatureSet.FieldPresenceB?\x88\x01\x01\x98\x01\x04\x98\x01\x01\xa2\x01\r\x12\bEXPLICIT\x18\x84\a\xa2\x01\r\x12\bIMPLICIT\x18\xe7\a\xa2\x01\r\x12\bEXPLICIT\x18\xe8\a\xb2\x01\x03\b\xe8\aR\rfieldPresence\x12l\n" + @@ -4960,8 +4955,8 @@ const file_google_protobuf_descriptor_proto_rawDesc = "" + "\x10message_encoding\x18\x05 \x01(\x0e2+.google.protobuf.FeatureSet.MessageEncodingB&\x88\x01\x01\x98\x01\x04\x98\x01\x01\xa2\x01\x14\x12\x0fLENGTH_PREFIXED\x18\x84\a\xb2\x01\x03\b\xe8\aR\x0fmessageEncoding\x12\x82\x01\n" + "\vjson_format\x18\x06 \x01(\x0e2&.google.protobuf.FeatureSet.JsonFormatB9\x88\x01\x01\x98\x01\x03\x98\x01\x06\x98\x01\x01\xa2\x01\x17\x12\x12LEGACY_BEST_EFFORT\x18\x84\a\xa2\x01\n" + "\x12\x05ALLOW\x18\xe7\a\xb2\x01\x03\b\xe8\aR\n" + - "jsonFormat\x12\xab\x01\n" + - "\x14enforce_naming_style\x18\a \x01(\x0e2..google.protobuf.FeatureSet.EnforceNamingStyleBI\x88\x01\x02\x98\x01\x01\x98\x01\x02\x98\x01\x03\x98\x01\x04\x98\x01\x05\x98\x01\x06\x98\x01\a\x98\x01\b\x98\x01\t\xa2\x01\x11\x12\fSTYLE_LEGACY\x18\x84\a\xa2\x01\x0e\x12\tSTYLE2024\x18\xe9\a\xb2\x01\x03\b\xe9\aR\x12enforceNamingStyle\x12\xb9\x01\n" + + "jsonFormat\x12\xbc\x01\n" + + "\x14enforce_naming_style\x18\a \x01(\x0e2..google.protobuf.FeatureSet.EnforceNamingStyleBZ\x88\x01\x02\x98\x01\x01\x98\x01\x02\x98\x01\x03\x98\x01\x04\x98\x01\x05\x98\x01\x06\x98\x01\a\x98\x01\b\x98\x01\t\xa2\x01\x11\x12\fSTYLE_LEGACY\x18\x84\a\xa2\x01\x0e\x12\tSTYLE2024\x18\xe9\a\xa2\x01\x0e\x12\tSTYLE2026\x18\x8fN\xb2\x01\x03\b\xe9\aR\x12enforceNamingStyle\x12\xb9\x01\n" + "\x19default_symbol_visibility\x18\b \x01(\x0e2E.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibilityB6\x88\x01\x02\x98\x01\x01\xa2\x01\x0f\x12\n" + "EXPORT_ALL\x18\x84\a\xa2\x01\x15\x12\x10EXPORT_TOP_LEVEL\x18\xe9\a\xb2\x01\x03\b\xe9\aR\x17defaultSymbolVisibility\x1a\xa1\x01\n" + "\x11VisibilityFeature\"\x81\x01\n" + @@ -5001,11 +4996,12 @@ const file_google_protobuf_descriptor_proto_rawDesc = "" + "JsonFormat\x12\x17\n" + "\x13JSON_FORMAT_UNKNOWN\x10\x00\x12\t\n" + "\x05ALLOW\x10\x01\x12\x16\n" + - "\x12LEGACY_BEST_EFFORT\x10\x02\"W\n" + + "\x12LEGACY_BEST_EFFORT\x10\x02\"f\n" + "\x12EnforceNamingStyle\x12 \n" + "\x1cENFORCE_NAMING_STYLE_UNKNOWN\x10\x00\x12\r\n" + "\tSTYLE2024\x10\x01\x12\x10\n" + - "\fSTYLE_LEGACY\x10\x02*\x06\b\xe8\a\x10\x8bN*\x06\b\x8bN\x10\x90N*\x06\b\x90N\x10\x91NJ\x06\b\xe7\a\x10\xe8\a\"\xef\x03\n" + + "\fSTYLE_LEGACY\x10\x02\x12\r\n" + + "\tSTYLE2026\x10\x03*\x06\b\xe8\a\x10\x8bN*\x06\b\x8bN\x10\x90N*\x06\b\x90N\x10\x91NJ\x06\b\xe7\a\x10\xe8\a\"\xef\x03\n" + "\x12FeatureSetDefaults\x12X\n" + "\bdefaults\x18\x01 \x03(\v2<.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefaultR\bdefaults\x12A\n" + "\x0fminimum_edition\x18\x04 \x01(\x0e2\x18.google.protobuf.EditionR\x0eminimumEdition\x12A\n" + @@ -5037,14 +5033,15 @@ const file_google_protobuf_descriptor_proto_rawDesc = "" + "\bSemantic\x12\b\n" + "\x04NONE\x10\x00\x12\a\n" + "\x03SET\x10\x01\x12\t\n" + - "\x05ALIAS\x10\x02*\xbe\x02\n" + + "\x05ALIAS\x10\x02*\xd1\x02\n" + "\aEdition\x12\x13\n" + "\x0fEDITION_UNKNOWN\x10\x00\x12\x13\n" + "\x0eEDITION_LEGACY\x10\x84\a\x12\x13\n" + "\x0eEDITION_PROTO2\x10\xe6\a\x12\x13\n" + "\x0eEDITION_PROTO3\x10\xe7\a\x12\x11\n" + "\fEDITION_2023\x10\xe8\a\x12\x11\n" + - "\fEDITION_2024\x10\xe9\a\x12\x15\n" + + "\fEDITION_2024\x10\xe9\a\x12\x11\n" + + "\fEDITION_2026\x10\xea\a\x12\x15\n" + "\x10EDITION_UNSTABLE\x10\x8fN\x12\x17\n" + "\x13EDITION_1_TEST_ONLY\x10\x01\x12\x17\n" + "\x13EDITION_2_TEST_ONLY\x10\x02\x12\x1d\n" + diff --git a/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go b/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go index 1ff0d1494d4..510894f2b0d 100644 --- a/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go @@ -128,120 +128,66 @@ import ( // `Any` contains an arbitrary serialized protocol buffer message along with a // URL that describes the type of the serialized message. // -// Protobuf library provides support to pack/unpack Any values in the form -// of utility functions or additional generated methods of the Any type. -// -// Example 1: Pack and unpack a message in C++. -// -// Foo foo = ...; -// Any any; -// any.PackFrom(foo); -// ... -// if (any.UnpackTo(&foo)) { -// ... -// } -// -// Example 2: Pack and unpack a message in Java. -// -// Foo foo = ...; -// Any any = Any.pack(foo); -// ... -// if (any.is(Foo.class)) { -// foo = any.unpack(Foo.class); -// } -// // or ... -// if (any.isSameTypeAs(Foo.getDefaultInstance())) { -// foo = any.unpack(Foo.getDefaultInstance()); -// } -// -// Example 3: Pack and unpack a message in Python. -// -// foo = Foo(...) -// any = Any() -// any.Pack(foo) -// ... -// if any.Is(Foo.DESCRIPTOR): -// any.Unpack(foo) -// ... -// -// Example 4: Pack and unpack a message in Go -// -// foo := &pb.Foo{...} -// any, err := anypb.New(foo) -// if err != nil { -// ... -// } -// ... -// foo := &pb.Foo{} -// if err := any.UnmarshalTo(foo); err != nil { -// ... -// } -// -// The pack methods provided by protobuf library will by default use -// 'type.googleapis.com/full.type.name' as the type URL and the unpack -// methods only use the fully qualified type name after the last '/' -// in the type URL, for example "foo.bar.com/x/y.z" will yield type -// name "y.z". -// -// JSON -// ==== -// The JSON representation of an `Any` value uses the regular -// representation of the deserialized, embedded message, with an -// additional field `@type` which contains the type URL. Example: -// -// package google.profile; -// message Person { -// string first_name = 1; -// string last_name = 2; -// } -// -// { -// "@type": "type.googleapis.com/google.profile.Person", -// "firstName": , -// "lastName": -// } -// -// If the embedded message type is well-known and has a custom JSON -// representation, that representation will be embedded adding a field -// `value` which holds the custom JSON in addition to the `@type` -// field. Example (for message [google.protobuf.Duration][]): -// -// { -// "@type": "type.googleapis.com/google.protobuf.Duration", -// "value": "1.212s" -// } +// In its binary encoding, an `Any` is an ordinary message; but in other wire +// forms like JSON, it has a special encoding. The format of the type URL is +// described on the `type_url` field. +// +// Protobuf APIs provide utilities to interact with `Any` values: +// +// - A 'pack' operation accepts a message and constructs a generic `Any` wrapper +// around it. +// - An 'unpack' operation reads the content of an `Any` message, either into an +// existing message or a new one. Unpack operations must check the type of the +// value they unpack against the declared `type_url`. +// - An 'is' operation decides whether an `Any` contains a message of the given +// type, i.e. whether it can 'unpack' that type. +// +// The JSON format representation of an `Any` follows one of these cases: +// +// - For types without special-cased JSON encodings, the JSON format +// representation of the `Any` is the same as that of the message, with an +// additional `@type` field which contains the type URL. +// - For types with special-cased JSON encodings (typically called 'well-known' +// types, listed in https://protobuf.dev/programming-guides/json/#any), the +// JSON format representation has a key `@type` which contains the type URL +// and a key `value` which contains the JSON-serialized value. +// +// The text format representation of an `Any` is like a message with one field +// whose name is the type URL in brackets. For example, an `Any` containing a +// `foo.Bar` message may be written `[type.googleapis.com/foo.Bar] { a: 2 }`. type Any struct { state protoimpl.MessageState `protogen:"open.v1"` - // A URL/resource name that uniquely identifies the type of the serialized - // protocol buffer message. This string must contain at least - // one "/" character. The last segment of the URL's path must represent - // the fully qualified name of the type (as in - // `path/google.protobuf.Duration`). The name should be in a canonical form - // (e.g., leading "." is not accepted). + // Identifies the type of the serialized Protobuf message with a URI reference + // consisting of a prefix ending in a slash and the fully-qualified type name. + // + // Example: type.googleapis.com/google.protobuf.StringValue // - // In practice, teams usually precompile into the binary all types that they - // expect it to use in the context of Any. However, for URLs which use the - // scheme `http`, `https`, or no scheme, one can optionally set up a type - // server that maps type URLs to message definitions as follows: + // This string must contain at least one `/` character, and the content after + // the last `/` must be the fully-qualified name of the type in canonical + // form, without a leading dot. Do not write a scheme on these URI references + // so that clients do not attempt to contact them. // - // - If no scheme is provided, `https` is assumed. - // - An HTTP GET on the URL must yield a [google.protobuf.Type][] - // value in binary format, or produce an error. - // - Applications are allowed to cache lookup results based on the - // URL, or have them precompiled into a binary to avoid any - // lookup. Therefore, binary compatibility needs to be preserved - // on changes to types. (Use versioned type names to manage - // breaking changes.) + // The prefix is arbitrary and Protobuf implementations are expected to + // simply strip off everything up to and including the last `/` to identify + // the type. `type.googleapis.com/` is a common default prefix that some + // legacy implementations require. This prefix does not indicate the origin of + // the type, and URIs containing it are not expected to respond to any + // requests. // - // Note: this functionality is not currently available in the official - // protobuf release, and it is not used for type URLs beginning with - // type.googleapis.com. As of May 2023, there are no widely used type server - // implementations and no plans to implement one. + // All type URL strings must be legal URI references with the additional + // restriction (for the text format) that the content of the reference + // must consist only of alphanumeric characters, percent-encoded escapes, and + // characters in the following set (not including the outer backticks): + // `/-.~_!$&()*+,;=`. Despite our allowing percent encodings, implementations + // should not unescape them to prevent confusion with existing parsers. For + // example, `type.googleapis.com%2FFoo` should be rejected. // - // Schemes other than `http`, `https` (or the empty scheme) might be - // used with implementation specific semantics. + // In the original design of `Any`, the possibility of launching a type + // resolution service at these type URLs was considered but Protobuf never + // implemented one and considers contacting these URLs to be problematic and + // a potential security issue. Do not attempt to contact type URLs. TypeUrl string `protobuf:"bytes,1,opt,name=type_url,json=typeUrl,proto3" json:"type_url,omitempty"` - // Must be a valid serialized protocol buffer of the above specified type. + // Holds a Protobuf serialization of the type described by type_url. Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache diff --git a/vendor/google.golang.org/protobuf/types/known/fieldmaskpb/field_mask.pb.go b/vendor/google.golang.org/protobuf/types/known/fieldmaskpb/field_mask.pb.go index 91ee89a5cd9..4a0437911d9 100644 --- a/vendor/google.golang.org/protobuf/types/known/fieldmaskpb/field_mask.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/fieldmaskpb/field_mask.pb.go @@ -197,24 +197,22 @@ import ( // An implementation may provide options to override this default behavior for // repeated and message fields. // -// In order to reset a field's value to the default, the field must -// be in the mask and set to the default value in the provided resource. -// Hence, in order to reset all fields of a resource, provide a default -// instance of the resource and set all fields in the mask, or do -// not provide a mask as described below. -// -// If a field mask is not present on update, the operation applies to -// all fields (as if a field mask of all fields has been specified). -// Note that in the presence of schema evolution, this may mean that -// fields the client does not know and has therefore not filled into -// the request will be reset to their default. If this is unwanted -// behavior, a specific service may require a client to always specify -// a field mask, producing an error if not. -// -// As with get operations, the location of the resource which -// describes the updated values in the request message depends on the -// operation kind. In any case, the effect of the field mask is -// required to be honored by the API. +// Note that libraries which implement FieldMask resolution have various +// different behaviors in the face of empty masks or the special "*" mask. +// When implementing a service you should confirm these cases have the +// appropriate behavior in the underlying FieldMask library that you desire, +// and you may need to special case those cases in your application code if +// the underlying field mask library behavior differs from your intended +// service semantics. +// +// Update methods implementing https://google.aip.dev/134 +// - MUST support the special value * meaning "full replace" +// - MUST treat an omitted field mask as "replace fields which are present". +// +// Other methods implementing https://google.aip.dev/157 +// - SHOULD support the special value "*" to mean "get all". +// - MUST treat an omitted field mask to mean "get all", unless otherwise +// documented. // // ## Considerations for HTTP REST // diff --git a/vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go b/vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go index 30411b72838..8325a504892 100644 --- a/vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go @@ -131,10 +131,15 @@ import ( unsafe "unsafe" ) -// `NullValue` is a singleton enumeration to represent the null value for the -// `Value` type union. +// Represents a JSON `null`. // -// The JSON representation for `NullValue` is JSON `null`. +// `NullValue` is a sentinel, using an enum with only one value to represent +// the null value for the `Value` type union. +// +// A field of type `NullValue` with any value other than `0` is considered +// invalid. Most ProtoJSON serializers will emit a Value with a `null_value` set +// as a JSON `null` regardless of the integer value, and so will round trip to +// a `0` value. type NullValue int32 const ( @@ -179,14 +184,19 @@ func (NullValue) EnumDescriptor() ([]byte, []int) { return file_google_protobuf_struct_proto_rawDescGZIP(), []int{0} } -// `Struct` represents a structured data value, consisting of fields -// which map to dynamically typed values. In some languages, `Struct` -// might be supported by a native representation. For example, in -// scripting languages like JS a struct is represented as an -// object. The details of that representation are described together -// with the proto support for the language. +// Represents a JSON object. +// +// An unordered key-value map, intending to perfectly capture the semantics of a +// JSON object. This enables parsing any arbitrary JSON payload as a message +// field in ProtoJSON format. +// +// This follows RFC 8259 guidelines for interoperable JSON: notably this type +// cannot represent large Int64 values or `NaN`/`Infinity` numbers, +// since the JSON format generally does not support those values in its number +// type. // -// The JSON representation for `Struct` is JSON object. +// If you do not intend to parse arbitrary JSON into your message, a custom +// typed message should be preferred instead of using this type. type Struct struct { state protoimpl.MessageState `protogen:"open.v1"` // Unordered map of dynamically typed values. @@ -269,12 +279,12 @@ func (x *Struct) GetFields() map[string]*Value { return nil } +// Represents a JSON value. +// // `Value` represents a dynamically typed value which can be either // null, a number, a string, a boolean, a recursive struct value, or a // list of values. A producer of value is expected to set one of these -// variants. Absence of any variant indicates an error. -// -// The JSON representation for `Value` is JSON value. +// variants. Absence of any variant is an invalid state. type Value struct { state protoimpl.MessageState `protogen:"open.v1"` // The kind of value. @@ -548,32 +558,35 @@ type isValue_Kind interface { } type Value_NullValue struct { - // Represents a null value. + // Represents a JSON `null`. NullValue NullValue `protobuf:"varint,1,opt,name=null_value,json=nullValue,proto3,enum=google.protobuf.NullValue,oneof"` } type Value_NumberValue struct { - // Represents a double value. + // Represents a JSON number. Must not be `NaN`, `Infinity` or + // `-Infinity`, since those are not supported in JSON. This also cannot + // represent large Int64 values, since JSON format generally does not + // support them in its number type. NumberValue float64 `protobuf:"fixed64,2,opt,name=number_value,json=numberValue,proto3,oneof"` } type Value_StringValue struct { - // Represents a string value. + // Represents a JSON string. StringValue string `protobuf:"bytes,3,opt,name=string_value,json=stringValue,proto3,oneof"` } type Value_BoolValue struct { - // Represents a boolean value. + // Represents a JSON boolean (`true` or `false` literal in JSON). BoolValue bool `protobuf:"varint,4,opt,name=bool_value,json=boolValue,proto3,oneof"` } type Value_StructValue struct { - // Represents a structured value. + // Represents a JSON object. StructValue *Struct `protobuf:"bytes,5,opt,name=struct_value,json=structValue,proto3,oneof"` } type Value_ListValue struct { - // Represents a repeated `Value`. + // Represents a JSON array. ListValue *ListValue `protobuf:"bytes,6,opt,name=list_value,json=listValue,proto3,oneof"` } @@ -589,9 +602,7 @@ func (*Value_StructValue) isValue_Kind() {} func (*Value_ListValue) isValue_Kind() {} -// `ListValue` is a wrapper around a repeated field of values. -// -// The JSON representation for `ListValue` is JSON array. +// Represents a JSON array. type ListValue struct { state protoimpl.MessageState `protogen:"open.v1"` // Repeated field of dynamically typed values. diff --git a/vendor/google.golang.org/protobuf/types/known/timestamppb/timestamp.pb.go b/vendor/google.golang.org/protobuf/types/known/timestamppb/timestamp.pb.go index 484c21fd536..2cd60946cf0 100644 --- a/vendor/google.golang.org/protobuf/types/known/timestamppb/timestamp.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/timestamppb/timestamp.pb.go @@ -153,8 +153,8 @@ import ( // {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional // seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), // are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone -// is required. A proto3 JSON serializer should always use UTC (as indicated by -// "Z") when printing the Timestamp type and a proto3 JSON parser should be +// is required. A ProtoJSON serializer should always use UTC (as indicated by +// "Z") when printing the Timestamp type and a ProtoJSON parser should be // able to accept both UTC and other timezones (as indicated by an offset). // // For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past @@ -173,7 +173,7 @@ import ( type Timestamp struct { state protoimpl.MessageState `protogen:"open.v1"` // Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must - // be between -315576000000 and 315576000000 inclusive (which corresponds to + // be between -62135596800 and 253402300799 inclusive (which corresponds to // 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z). Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"` // Non-negative fractions of a second at nanosecond resolution. This field is diff --git a/vendor/gopkg.in/ini.v1/key.go b/vendor/gopkg.in/ini.v1/key.go index b1ef5c96d7f..800d04a473b 100644 --- a/vendor/gopkg.in/ini.v1/key.go +++ b/vendor/gopkg.in/ini.v1/key.go @@ -15,12 +15,12 @@ package ini import ( - "bytes" "errors" "fmt" "strconv" "strings" "time" + "unicode/utf8" ) // Key represents a key under a section. @@ -495,31 +495,38 @@ func (k *Key) Strings(delim string) []string { return []string{} } - runes := []rune(str) - vals := make([]string, 0, 2) - var buf bytes.Buffer - escape := false - idx := 0 + maxParts := strings.Count(str, delim) + 1 + vals := make([]string, 0, maxParts) + + var buf strings.Builder + buf.Grow(len(str)) + + i := 0 for { - if escape { - escape = false - if runes[idx] != '\\' && !strings.HasPrefix(string(runes[idx:]), delim) { + if str[i] == '\\' { + i++ + if i >= len(str) { + break + } + + if str[i] != '\\' && !strings.HasPrefix(str[i:], delim) { buf.WriteRune('\\') } - buf.WriteRune(runes[idx]) + + r, size := utf8.DecodeRuneInString(str[i:]) + i += size + buf.WriteRune(r) + } else if strings.HasPrefix(str[i:], delim) { + i += len(delim) + vals = append(vals, strings.TrimSpace(buf.String())) + buf.Reset() } else { - if runes[idx] == '\\' { - escape = true - } else if strings.HasPrefix(string(runes[idx:]), delim) { - idx += len(delim) - 1 - vals = append(vals, strings.TrimSpace(buf.String())) - buf.Reset() - } else { - buf.WriteRune(runes[idx]) - } + r, size := utf8.DecodeRuneInString(str[i:]) + i += size + buf.WriteRune(r) } - idx++ - if idx == len(runes) { + + if i >= len(str) { break } } diff --git a/vendor/modules.txt b/vendor/modules.txt index 8bc0fbb604b..90212298364 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -170,7 +170,7 @@ github.com/andybalholm/brotli/matchfinder # github.com/armon/go-metrics v0.4.1 ## explicit; go 1.12 github.com/armon/go-metrics -# github.com/aws/aws-sdk-go-v2 v1.42.0 +# github.com/aws/aws-sdk-go-v2 v1.43.6 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/aws github.com/aws/aws-sdk-go-v2/aws/defaults @@ -196,11 +196,11 @@ github.com/aws/aws-sdk-go-v2/internal/shareddefaults github.com/aws/aws-sdk-go-v2/internal/strings github.com/aws/aws-sdk-go-v2/internal/sync/singleflight github.com/aws/aws-sdk-go-v2/internal/timeconv -# github.com/aws/aws-sdk-go-v2/config v1.32.26 +# github.com/aws/aws-sdk-go-v2/config v1.32.37 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/config github.com/aws/aws-sdk-go-v2/config/internal/ini -# github.com/aws/aws-sdk-go-v2/credentials v1.19.25 +# github.com/aws/aws-sdk-go-v2/credentials v1.19.36 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/credentials github.com/aws/aws-sdk-go-v2/credentials/ec2rolecreds @@ -210,37 +210,37 @@ github.com/aws/aws-sdk-go-v2/credentials/logincreds github.com/aws/aws-sdk-go-v2/credentials/processcreds github.com/aws/aws-sdk-go-v2/credentials/ssocreds github.com/aws/aws-sdk-go-v2/credentials/stscreds -# github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.29 +# github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.37 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/feature/ec2/imds github.com/aws/aws-sdk-go-v2/feature/ec2/imds/internal/config -# github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.29 +# github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.37 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/internal/configsources -# github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.29 +# github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.37 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 -# github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.30 +# github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.38 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/internal/v4a github.com/aws/aws-sdk-go-v2/internal/v4a/internal/crypto github.com/aws/aws-sdk-go-v2/internal/v4a/internal/v4 -# github.com/aws/aws-sdk-go-v2/service/dynamodb v1.59.1 +# github.com/aws/aws-sdk-go-v2/service/dynamodb v1.63.3 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/dynamodb github.com/aws/aws-sdk-go-v2/service/dynamodb/internal/customizations github.com/aws/aws-sdk-go-v2/service/dynamodb/internal/endpoints github.com/aws/aws-sdk-go-v2/service/dynamodb/types -# github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.12 +# github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.17 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding -# github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.12.6 +# github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.12.14 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery -# github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.29 +# github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.37 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/internal/presigned-url -# github.com/aws/aws-sdk-go-v2/service/signin v1.2.1 +# github.com/aws/aws-sdk-go-v2/service/signin v1.5.6 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/signin github.com/aws/aws-sdk-go-v2/service/signin/internal/endpoints @@ -250,22 +250,22 @@ github.com/aws/aws-sdk-go-v2/service/signin/types github.com/aws/aws-sdk-go-v2/service/sns github.com/aws/aws-sdk-go-v2/service/sns/internal/endpoints github.com/aws/aws-sdk-go-v2/service/sns/types -# github.com/aws/aws-sdk-go-v2/service/sso v1.31.4 +# github.com/aws/aws-sdk-go-v2/service/sso v1.33.6 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/sso github.com/aws/aws-sdk-go-v2/service/sso/internal/endpoints github.com/aws/aws-sdk-go-v2/service/sso/types -# github.com/aws/aws-sdk-go-v2/service/ssooidc v1.36.7 +# github.com/aws/aws-sdk-go-v2/service/ssooidc v1.38.6 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/ssooidc github.com/aws/aws-sdk-go-v2/service/ssooidc/internal/endpoints github.com/aws/aws-sdk-go-v2/service/ssooidc/types -# github.com/aws/aws-sdk-go-v2/service/sts v1.43.4 +# github.com/aws/aws-sdk-go-v2/service/sts v1.45.6 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/sts github.com/aws/aws-sdk-go-v2/service/sts/internal/endpoints github.com/aws/aws-sdk-go-v2/service/sts/types -# github.com/aws/smithy-go v1.27.1 +# github.com/aws/smithy-go v1.27.8 ## explicit; go 1.24 github.com/aws/smithy-go github.com/aws/smithy-go/auth @@ -515,17 +515,18 @@ github.com/go-openapi/runtime/yamlpc # github.com/go-openapi/spec v0.22.4 => github.com/go-openapi/spec v0.20.6 ## explicit; go 1.13 github.com/go-openapi/spec -# github.com/go-openapi/strfmt v0.26.4 +# github.com/go-openapi/strfmt v0.27.0 ## explicit; go 1.25.0 github.com/go-openapi/strfmt github.com/go-openapi/strfmt/internal/bsonlite +github.com/go-openapi/strfmt/internal/countries # github.com/go-openapi/swag v0.26.0 ## explicit; go 1.25.0 github.com/go-openapi/swag # github.com/go-openapi/swag/cmdutils v0.26.0 ## explicit; go 1.25.0 github.com/go-openapi/swag/cmdutils -# github.com/go-openapi/swag/conv v0.27.0 +# github.com/go-openapi/swag/conv v0.28.0 ## explicit; go 1.25.0 github.com/go-openapi/swag/conv # github.com/go-openapi/swag/fileutils v0.26.0 @@ -534,7 +535,7 @@ github.com/go-openapi/swag/fileutils # github.com/go-openapi/swag/jsonname v0.26.0 ## explicit; go 1.25.0 github.com/go-openapi/swag/jsonname -# github.com/go-openapi/swag/jsonutils v0.27.0 +# github.com/go-openapi/swag/jsonutils v0.28.0 ## explicit; go 1.25.0 github.com/go-openapi/swag/jsonutils github.com/go-openapi/swag/jsonutils/adapters @@ -549,10 +550,13 @@ github.com/go-openapi/swag/mangling # github.com/go-openapi/swag/netutils v0.26.0 ## explicit; go 1.25.0 github.com/go-openapi/swag/netutils +# github.com/go-openapi/swag/pools v0.28.0 +## explicit; go 1.25.0 +github.com/go-openapi/swag/pools # github.com/go-openapi/swag/stringutils v0.26.0 ## explicit; go 1.25.0 github.com/go-openapi/swag/stringutils -# github.com/go-openapi/swag/typeutils v0.27.0 +# github.com/go-openapi/swag/typeutils v0.28.0 ## explicit; go 1.25.0 github.com/go-openapi/swag/typeutils # github.com/go-openapi/swag/yamlutils v0.26.0 @@ -705,7 +709,7 @@ github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/logging github.com/grpc-ecosystem/grpc-gateway/v2/internal/httprule github.com/grpc-ecosystem/grpc-gateway/v2/runtime github.com/grpc-ecosystem/grpc-gateway/v2/utilities -# github.com/hashicorp/consul/api v1.34.3 +# github.com/hashicorp/consul/api v1.34.4 ## explicit; go 1.26 github.com/hashicorp/consul/api # github.com/hashicorp/errwrap v1.1.0 @@ -720,9 +724,10 @@ github.com/hashicorp/go-hclog # github.com/hashicorp/go-immutable-radix v1.3.1 ## explicit github.com/hashicorp/go-immutable-radix -# github.com/hashicorp/go-metrics v0.6.0 -## explicit; go 1.25 +# github.com/hashicorp/go-metrics v0.6.1 +## explicit; go 1.25.0 github.com/hashicorp/go-metrics +github.com/hashicorp/go-metrics/compat github.com/hashicorp/go-metrics/prometheus # github.com/hashicorp/go-msgpack v0.5.5 ## explicit @@ -739,7 +744,7 @@ github.com/hashicorp/go-sockaddr # github.com/hashicorp/go-version v1.9.0 ## explicit github.com/hashicorp/go-version -# github.com/hashicorp/golang-lru v0.6.0 +# github.com/hashicorp/golang-lru v1.0.2 ## explicit; go 1.12 github.com/hashicorp/golang-lru/simplelru # github.com/hashicorp/golang-lru/v2 v2.0.7 @@ -748,11 +753,11 @@ github.com/hashicorp/golang-lru/v2 github.com/hashicorp/golang-lru/v2/expirable github.com/hashicorp/golang-lru/v2/internal github.com/hashicorp/golang-lru/v2/simplelru -# github.com/hashicorp/memberlist v0.5.4 => github.com/grafana/memberlist v0.3.1-0.20220714140823-09ffed8adbbe +# github.com/hashicorp/memberlist v0.6.0 => github.com/grafana/memberlist v0.3.1-0.20220714140823-09ffed8adbbe ## explicit; go 1.12 github.com/hashicorp/memberlist -# github.com/hashicorp/serf v0.10.1 -## explicit; go 1.12 +# github.com/hashicorp/serf v0.10.4 +## explicit; go 1.25.0 github.com/hashicorp/serf/coordinate # github.com/huaweicloud/huaweicloud-sdk-go-obs v3.25.4+incompatible ## explicit @@ -772,7 +777,7 @@ github.com/julienschmidt/httprouter # github.com/kamstrup/intmap v0.5.2 ## explicit; go 1.23 github.com/kamstrup/intmap -# github.com/klauspost/compress v1.18.7 +# github.com/klauspost/compress v1.19.2 ## explicit; go 1.24 github.com/klauspost/compress github.com/klauspost/compress/flate @@ -792,8 +797,8 @@ github.com/klauspost/compress/snappy github.com/klauspost/compress/zlib github.com/klauspost/compress/zstd github.com/klauspost/compress/zstd/internal/xxhash -# github.com/klauspost/cpuid/v2 v2.2.11 -## explicit; go 1.22 +# github.com/klauspost/cpuid/v2 v2.4.0 +## explicit; go 1.24.0 github.com/klauspost/cpuid/v2 # github.com/klauspost/crc32 v1.3.0 ## explicit; go 1.23.0 @@ -826,11 +831,11 @@ github.com/lib/pq/internal/pqutil github.com/lib/pq/internal/proto github.com/lib/pq/oid github.com/lib/pq/scram -# github.com/mattn/go-colorable v0.1.14 +# github.com/mattn/go-colorable v0.1.15 ## explicit; go 1.18 github.com/mattn/go-colorable -# github.com/mattn/go-isatty v0.0.20 -## explicit; go 1.15 +# github.com/mattn/go-isatty v0.0.22 +## explicit; go 1.21 github.com/mattn/go-isatty # github.com/mdlayher/socket v0.5.1 ## explicit; go 1.20 @@ -841,7 +846,7 @@ github.com/mdlayher/vsock # github.com/metalmatze/signal v0.0.0-20210307161603-1c9aa721a97a ## explicit; go 1.14 github.com/metalmatze/signal/server/signalhttp -# github.com/miekg/dns v1.1.69 +# github.com/miekg/dns v1.1.72 ## explicit; go 1.24.0 github.com/miekg/dns # github.com/minio/crc64nvme v1.1.1 @@ -850,7 +855,7 @@ github.com/minio/crc64nvme # github.com/minio/md5-simd v1.1.2 ## explicit; go 1.14 github.com/minio/md5-simd -# github.com/minio/minio-go/v7 v7.2.1 +# github.com/minio/minio-go/v7 v7.3.0 ## explicit; go 1.25.0 github.com/minio/minio-go/v7 github.com/minio/minio-go/v7/pkg/cors @@ -859,6 +864,7 @@ github.com/minio/minio-go/v7/pkg/encrypt github.com/minio/minio-go/v7/pkg/kvcache github.com/minio/minio-go/v7/pkg/lifecycle github.com/minio/minio-go/v7/pkg/notification +github.com/minio/minio-go/v7/pkg/policy github.com/minio/minio-go/v7/pkg/replication github.com/minio/minio-go/v7/pkg/s3utils github.com/minio/minio-go/v7/pkg/set @@ -908,7 +914,7 @@ github.com/oklog/run # github.com/oklog/ulid v1.3.1 ## explicit github.com/oklog/ulid -# github.com/oklog/ulid/v2 v2.1.1 +# github.com/oklog/ulid/v2 v2.1.2 ## explicit; go 1.15 github.com/oklog/ulid/v2 # github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics v0.142.0 @@ -954,7 +960,7 @@ github.com/parquet-go/bitpack/unsafecast # github.com/parquet-go/jsonlite v1.0.0 ## explicit; go 1.23 github.com/parquet-go/jsonlite -# github.com/parquet-go/parquet-go v0.30.1 +# github.com/parquet-go/parquet-go v0.32.0 ## explicit; go 1.24.9 github.com/parquet-go/parquet-go github.com/parquet-go/parquet-go/bloom @@ -1009,9 +1015,6 @@ github.com/planetscale/vtprotobuf/types/known/emptypb github.com/planetscale/vtprotobuf/types/known/structpb github.com/planetscale/vtprotobuf/types/known/timestamppb github.com/planetscale/vtprotobuf/types/known/wrapperspb -# github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 -## explicit -github.com/pmezard/go-difflib/difflib # github.com/prometheus-community/parquet-common v0.0.0-20260614025832-5f32460b5373 ## explicit; go 1.24.0 github.com/prometheus-community/parquet-common/convert @@ -1088,8 +1091,8 @@ github.com/prometheus/alertmanager/template github.com/prometheus/alertmanager/timeinterval github.com/prometheus/alertmanager/tracing github.com/prometheus/alertmanager/types -# github.com/prometheus/client_golang v1.23.2 -## explicit; go 1.23.0 +# github.com/prometheus/client_golang v1.24.1 +## explicit; go 1.25.0 github.com/prometheus/client_golang/api github.com/prometheus/client_golang/api/prometheus/v1 github.com/prometheus/client_golang/internal/github.com/golang/gddo/httputil @@ -1112,7 +1115,7 @@ github.com/prometheus/client_golang/exp/internal/github.com/efficientgo/core/bac # github.com/prometheus/client_model v0.6.2 ## explicit; go 1.22.0 github.com/prometheus/client_model/go -# github.com/prometheus/common v0.69.0 +# github.com/prometheus/common v0.70.1 ## explicit; go 1.25.0 github.com/prometheus/common/config github.com/prometheus/common/expfmt @@ -1127,7 +1130,7 @@ github.com/prometheus/exporter-toolkit/web # github.com/prometheus/otlptranslator v1.0.0 => github.com/prometheus/otlptranslator v1.0.0 ## explicit; go 1.23.0 github.com/prometheus/otlptranslator -# github.com/prometheus/procfs v0.21.0 +# github.com/prometheus/procfs v0.21.1 ## explicit; go 1.25.0 github.com/prometheus/procfs github.com/prometheus/procfs/internal/fs @@ -1255,13 +1258,15 @@ github.com/spiffe/go-spiffe/v2/internal/jwtutil github.com/spiffe/go-spiffe/v2/internal/pemutil github.com/spiffe/go-spiffe/v2/internal/x509util github.com/spiffe/go-spiffe/v2/spiffeid -# github.com/stretchr/objx v0.5.2 +# github.com/stretchr/objx v0.5.3 ## explicit; go 1.20 github.com/stretchr/objx -# github.com/stretchr/testify v1.11.1 +# github.com/stretchr/testify v1.12.1 ## explicit; go 1.17 github.com/stretchr/testify/assert github.com/stretchr/testify/assert/yaml +github.com/stretchr/testify/internal/difflib +github.com/stretchr/testify/internal/spew github.com/stretchr/testify/mock github.com/stretchr/testify/require # github.com/tencentyun/cos-go-sdk-v5 v0.7.66 @@ -1370,11 +1375,11 @@ github.com/thanos-io/thanos/pkg/tracing/interceptors github.com/thanos-io/thanos/pkg/tracing/migration github.com/thanos-io/thanos/pkg/tracing/tracing_middleware github.com/thanos-io/thanos/pkg/tracing/util/metautils -# github.com/tinylib/msgp v1.6.1 +# github.com/tinylib/msgp v1.6.4 ## explicit; go 1.24 github.com/tinylib/msgp/msgp github.com/tinylib/msgp/msgp/setof -# github.com/tjhop/slog-gokit v0.2.0 +# github.com/tjhop/slog-gokit v0.2.2 ## explicit; go 1.21 github.com/tjhop/slog-gokit # github.com/twmb/franz-go v1.21.2 @@ -1521,10 +1526,10 @@ go.opentelemetry.io/collector/confmap/xconfmap ## explicit; go 1.24.0 go.opentelemetry.io/collector/consumer go.opentelemetry.io/collector/consumer/internal -# go.opentelemetry.io/collector/featuregate v1.61.0 +# go.opentelemetry.io/collector/featuregate v1.65.0 ## explicit; go 1.25.0 go.opentelemetry.io/collector/featuregate -# go.opentelemetry.io/collector/pdata v1.61.0 +# go.opentelemetry.io/collector/pdata v1.65.0 ## explicit; go 1.25.0 go.opentelemetry.io/collector/pdata/internal go.opentelemetry.io/collector/pdata/internal/json @@ -1567,7 +1572,7 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/semconv # go.opentelemetry.io/contrib/propagators/autoprop v0.61.0 ## explicit; go 1.23.0 go.opentelemetry.io/contrib/propagators/autoprop -# go.opentelemetry.io/contrib/propagators/aws v1.44.0 +# go.opentelemetry.io/contrib/propagators/aws v1.45.0 ## explicit; go 1.25.0 go.opentelemetry.io/contrib/propagators/aws/xray # go.opentelemetry.io/contrib/propagators/b3 v1.36.0 @@ -1601,17 +1606,17 @@ go.opentelemetry.io/otel/semconv/v1.40.0 go.opentelemetry.io/otel/semconv/v1.40.0/httpconv go.opentelemetry.io/otel/semconv/v1.40.0/otelconv go.opentelemetry.io/otel/semconv/v1.41.0 -go.opentelemetry.io/otel/semconv/v1.41.0/otelconv go.opentelemetry.io/otel/semconv/v1.43.0 +go.opentelemetry.io/otel/semconv/v1.43.0/otelconv # go.opentelemetry.io/otel/bridge/opentracing v1.45.0 ## explicit; go 1.25.0 go.opentelemetry.io/otel/bridge/opentracing go.opentelemetry.io/otel/bridge/opentracing/migration -# go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.44.0 +# go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.45.0 ## explicit; go 1.25.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform -# go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.44.0 +# go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.45.0 ## explicit; go 1.25.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal @@ -1636,22 +1641,24 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/x go.opentelemetry.io/otel/metric go.opentelemetry.io/otel/metric/embedded go.opentelemetry.io/otel/metric/noop -# go.opentelemetry.io/otel/sdk v1.44.0 +# go.opentelemetry.io/otel/sdk v1.45.0 ## explicit; go 1.25.0 go.opentelemetry.io/otel/sdk go.opentelemetry.io/otel/sdk/instrumentation +go.opentelemetry.io/otel/sdk/internal/attrnorm go.opentelemetry.io/otel/sdk/internal/x go.opentelemetry.io/otel/sdk/resource go.opentelemetry.io/otel/sdk/trace go.opentelemetry.io/otel/sdk/trace/internal/env go.opentelemetry.io/otel/sdk/trace/internal/observ go.opentelemetry.io/otel/sdk/trace/tracetest -# go.opentelemetry.io/otel/sdk/metric v1.44.0 +# go.opentelemetry.io/otel/sdk/metric v1.45.0 ## explicit; go 1.25.0 go.opentelemetry.io/otel/sdk/metric go.opentelemetry.io/otel/sdk/metric/exemplar go.opentelemetry.io/otel/sdk/metric/internal go.opentelemetry.io/otel/sdk/metric/internal/aggregate +go.opentelemetry.io/otel/sdk/metric/internal/attrnorm go.opentelemetry.io/otel/sdk/metric/internal/observ go.opentelemetry.io/otel/sdk/metric/internal/reservoir go.opentelemetry.io/otel/sdk/metric/internal/x @@ -1662,8 +1669,8 @@ go.opentelemetry.io/otel/trace go.opentelemetry.io/otel/trace/embedded go.opentelemetry.io/otel/trace/internal/telemetry go.opentelemetry.io/otel/trace/noop -# go.opentelemetry.io/proto/otlp v1.10.0 -## explicit; go 1.24.0 +# go.opentelemetry.io/proto/otlp v1.11.0 +## explicit; go 1.25.0 go.opentelemetry.io/proto/otlp/collector/trace/v1 go.opentelemetry.io/proto/otlp/common/v1 go.opentelemetry.io/proto/otlp/resource/v1 @@ -1699,10 +1706,10 @@ go.uber.org/zap/zapgrpc # go.yaml.in/yaml/v2 v2.4.4 ## explicit; go 1.15 go.yaml.in/yaml/v2 -# go.yaml.in/yaml/v3 v3.0.4 +# go.yaml.in/yaml/v3 v3.0.5 ## explicit; go 1.16 go.yaml.in/yaml/v3 -# golang.org/x/crypto v0.54.0 +# golang.org/x/crypto v0.55.0 ## explicit; go 1.25.0 golang.org/x/crypto/argon2 golang.org/x/crypto/bcrypt @@ -1723,10 +1730,10 @@ golang.org/x/crypto/scrypt ## explicit; go 1.25.0 golang.org/x/exp/constraints golang.org/x/exp/slices -# golang.org/x/mod v0.37.0 +# golang.org/x/mod v0.38.0 ## explicit; go 1.25.0 golang.org/x/mod/semver -# golang.org/x/net v0.57.0 +# golang.org/x/net v0.58.0 ## explicit; go 1.25.0 golang.org/x/net/bpf golang.org/x/net/context @@ -1770,12 +1777,16 @@ golang.org/x/sys/cpu golang.org/x/sys/unix golang.org/x/sys/windows golang.org/x/sys/windows/registry -# golang.org/x/text v0.40.0 +# golang.org/x/text v0.41.0 ## explicit; go 1.25.0 golang.org/x/text/cases +golang.org/x/text/currency golang.org/x/text/internal +golang.org/x/text/internal/format golang.org/x/text/internal/language golang.org/x/text/internal/language/compact +golang.org/x/text/internal/number +golang.org/x/text/internal/stringset golang.org/x/text/internal/tag golang.org/x/text/language golang.org/x/text/runes @@ -1786,7 +1797,7 @@ golang.org/x/text/unicode/norm # golang.org/x/time v0.15.0 ## explicit; go 1.25.0 golang.org/x/time/rate -# golang.org/x/tools v0.47.0 +# golang.org/x/tools v0.48.0 ## explicit; go 1.25.0 golang.org/x/tools/go/ast/edge golang.org/x/tools/go/ast/inspector @@ -1836,7 +1847,7 @@ google.golang.org/genproto/googleapis/type/calendarperiod google.golang.org/genproto/googleapis/type/date google.golang.org/genproto/googleapis/type/expr google.golang.org/genproto/googleapis/type/timeofday -# google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa +# google.golang.org/genproto/googleapis/api v0.0.0-20260803160001-6ac0973c030d ## explicit; go 1.25.0 google.golang.org/genproto/googleapis/api google.golang.org/genproto/googleapis/api/annotations @@ -2017,7 +2028,7 @@ google.golang.org/grpc/xds google.golang.org/grpc/xds/bootstrap google.golang.org/grpc/xds/csds google.golang.org/grpc/xds/googledirectpath -# google.golang.org/protobuf v1.36.11 +# google.golang.org/protobuf v1.36.12 ## explicit; go 1.23 google.golang.org/protobuf/encoding/protodelim google.golang.org/protobuf/encoding/protojson @@ -2061,7 +2072,7 @@ google.golang.org/protobuf/types/known/fieldmaskpb google.golang.org/protobuf/types/known/structpb google.golang.org/protobuf/types/known/timestamppb google.golang.org/protobuf/types/known/wrapperspb -# gopkg.in/ini.v1 v1.67.2 +# gopkg.in/ini.v1 v1.67.3 ## explicit; go 1.13 gopkg.in/ini.v1 # gopkg.in/telebot.v3 v3.3.8