From 0e10d8d84726b5ab88a8c2ea9505391a194bb867 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 25 Feb 2025 14:41:41 +0000 Subject: [PATCH] fix(deps): update module github.com/datadog/sketches-go to v1.4.7 --- go.mod | 2 +- go.sum | 4 +- vendor/github.com/DataDog/sketches-go/LICENSE | 207 +++++++++++++++++- .../DataDog/sketches-go/ddsketch/ddsketch.go | 17 ++ .../mapping/cubically_interpolated_mapping.go | 6 + .../ddsketch/mapping/index_mapping.go | 1 + .../mapping/linearly_interpolated_mapping.go | 6 + .../ddsketch/mapping/logarithmic_mapping.go | 6 + .../ddsketch/pb/sketchpb/ddsketch.pb.go | 12 +- .../pb/sketchpb/ddsketch.proto_builder.go | 161 ++++++++++++++ .../ddsketch/store/buffered_paginated.go | 14 ++ .../sketches-go/ddsketch/store/dense_store.go | 11 + .../sketches-go/ddsketch/store/sparse.go | 10 + .../sketches-go/ddsketch/store/store.go | 2 +- vendor/modules.txt | 2 +- 15 files changed, 440 insertions(+), 21 deletions(-) create mode 100644 vendor/github.com/DataDog/sketches-go/ddsketch/pb/sketchpb/ddsketch.proto_builder.go diff --git a/go.mod b/go.mod index 353c5369ea722..1d55c0c1255fc 100644 --- a/go.mod +++ b/go.mod @@ -113,7 +113,7 @@ require ( require ( github.com/Azure/go-autorest/autorest v0.11.30 - github.com/DataDog/sketches-go v1.4.6 + github.com/DataDog/sketches-go v1.4.7 github.com/DmitriyVTitov/size v1.5.0 github.com/IBM/go-sdk-core/v5 v5.18.5 github.com/IBM/ibm-cos-sdk-go v1.12.1 diff --git a/go.sum b/go.sum index 62ac1b2294d21..7a8d2e9081d38 100644 --- a/go.sum +++ b/go.sum @@ -120,8 +120,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/Code-Hex/go-generics-cache v1.5.1 h1:6vhZGc5M7Y/YD8cIUcY8kcuQLB4cHR7U+0KMqAA0KcU= github.com/Code-Hex/go-generics-cache v1.5.1/go.mod h1:qxcC9kRVrct9rHeiYpFWSoW1vxyillCVzX13KZG8dl4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/DataDog/sketches-go v1.4.6 h1:acd5fb+QdUzGrosfNLwrIhqyrbMORpvBy7mE+vHlT3I= -github.com/DataDog/sketches-go v1.4.6/go.mod h1:7Y8GN8Jf66DLyDhc94zuWA3uHEt/7ttt8jHOBWWrSOg= +github.com/DataDog/sketches-go v1.4.7 h1:eHs5/0i2Sdf20Zkj0udVFWuCrXGRFig2Dcfm5rtcTxc= +github.com/DataDog/sketches-go v1.4.7/go.mod h1:eAmQ/EBmtSO+nQp7IZMZVRPT4BQTmIc5RZQ+deGlTPM= github.com/DmitriyVTitov/size v1.5.0 h1:/PzqxYrOyOUX1BXj6J9OuVRVGe+66VL4D9FlUaW515g= github.com/DmitriyVTitov/size v1.5.0/go.mod h1:le6rNI4CoLQV1b9gzp1+3d7hMAD/uu2QcJ+aYbNgiU0= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.25.0 h1:3c8yed4lgqTt+oTQ+JNMDo+F4xprBf+O/il4ZC0nRLw= diff --git a/vendor/github.com/DataDog/sketches-go/LICENSE b/vendor/github.com/DataDog/sketches-go/LICENSE index 7d3693beef732..7882f2d9e94c2 100644 --- a/vendor/github.com/DataDog/sketches-go/LICENSE +++ b/vendor/github.com/DataDog/sketches-go/LICENSE @@ -1,13 +1,200 @@ -Copyright 2021 DataDog, Inc. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ -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 + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - http://www.apache.org/licenses/LICENSE-2.0 + 1. Definitions. -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. + "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 2021 Datadog, 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. diff --git a/vendor/github.com/DataDog/sketches-go/ddsketch/ddsketch.go b/vendor/github.com/DataDog/sketches-go/ddsketch/ddsketch.go index 27bd0e7aef303..10445f0550aef 100644 --- a/vendor/github.com/DataDog/sketches-go/ddsketch/ddsketch.go +++ b/vendor/github.com/DataDog/sketches-go/ddsketch/ddsketch.go @@ -319,6 +319,23 @@ func (s *DDSketch) ToProto() *sketchpb.DDSketch { } } +func (s *DDSketch) EncodeProto(w io.Writer) { + builder := sketchpb.NewDDSketchBuilder(w) + + builder.SetMapping(func(indexMappingBuilder *sketchpb.IndexMappingBuilder) { + s.IndexMapping.EncodeProto(indexMappingBuilder) + }) + + builder.SetZeroCount(s.zeroCount) + builder.SetNegativeValues(func(storeBuilder *sketchpb.StoreBuilder) { + s.negativeValueStore.EncodeProto(storeBuilder) + }) + + builder.SetPositiveValues(func(storeBuilder *sketchpb.StoreBuilder) { + s.positiveValueStore.EncodeProto(storeBuilder) + }) +} + // FromProto builds a new instance of DDSketch based on the provided protobuf representation, using a Dense store. func FromProto(pb *sketchpb.DDSketch) (*DDSketch, error) { return FromProtoWithStoreProvider(pb, store.DenseStoreConstructor) diff --git a/vendor/github.com/DataDog/sketches-go/ddsketch/mapping/cubically_interpolated_mapping.go b/vendor/github.com/DataDog/sketches-go/ddsketch/mapping/cubically_interpolated_mapping.go index 933cdab667c46..477ded84238e9 100644 --- a/vendor/github.com/DataDog/sketches-go/ddsketch/mapping/cubically_interpolated_mapping.go +++ b/vendor/github.com/DataDog/sketches-go/ddsketch/mapping/cubically_interpolated_mapping.go @@ -131,6 +131,12 @@ func (m *CubicallyInterpolatedMapping) ToProto() *sketchpb.IndexMapping { } } +func (m *CubicallyInterpolatedMapping) EncodeProto(builder *sketchpb.IndexMappingBuilder) { + builder.SetGamma(m.gamma) + builder.SetIndexOffset(m.indexOffset) + builder.SetInterpolation(uint64(sketchpb.IndexMapping_CUBIC)) +} + func (m *CubicallyInterpolatedMapping) Encode(b *[]byte) { enc.EncodeFlag(b, enc.FlagIndexMappingBaseCubic) enc.EncodeFloat64LE(b, m.gamma) diff --git a/vendor/github.com/DataDog/sketches-go/ddsketch/mapping/index_mapping.go b/vendor/github.com/DataDog/sketches-go/ddsketch/mapping/index_mapping.go index 88b926592a23c..62262d2c4262e 100644 --- a/vendor/github.com/DataDog/sketches-go/ddsketch/mapping/index_mapping.go +++ b/vendor/github.com/DataDog/sketches-go/ddsketch/mapping/index_mapping.go @@ -29,6 +29,7 @@ type IndexMapping interface { // MaxIndexableValue returns the maximum positive value that can be mapped to an index. MaxIndexableValue() float64 ToProto() *sketchpb.IndexMapping + EncodeProto(builder *sketchpb.IndexMappingBuilder) // Encode encodes a mapping and appends its content to the provided []byte. Encode(b *[]byte) } diff --git a/vendor/github.com/DataDog/sketches-go/ddsketch/mapping/linearly_interpolated_mapping.go b/vendor/github.com/DataDog/sketches-go/ddsketch/mapping/linearly_interpolated_mapping.go index d9b0b7408a265..aa4499177cfd4 100644 --- a/vendor/github.com/DataDog/sketches-go/ddsketch/mapping/linearly_interpolated_mapping.go +++ b/vendor/github.com/DataDog/sketches-go/ddsketch/mapping/linearly_interpolated_mapping.go @@ -119,6 +119,12 @@ func (m *LinearlyInterpolatedMapping) ToProto() *sketchpb.IndexMapping { } } +func (m *LinearlyInterpolatedMapping) EncodeProto(builder *sketchpb.IndexMappingBuilder) { + builder.SetGamma(m.gamma) + builder.SetIndexOffset(m.indexOffset) + builder.SetInterpolation(uint64(sketchpb.IndexMapping_LINEAR)) +} + func (m *LinearlyInterpolatedMapping) Encode(b *[]byte) { enc.EncodeFlag(b, enc.FlagIndexMappingBaseLinear) enc.EncodeFloat64LE(b, m.gamma) diff --git a/vendor/github.com/DataDog/sketches-go/ddsketch/mapping/logarithmic_mapping.go b/vendor/github.com/DataDog/sketches-go/ddsketch/mapping/logarithmic_mapping.go index 474e74d932001..7ac2ac477a3d2 100644 --- a/vendor/github.com/DataDog/sketches-go/ddsketch/mapping/logarithmic_mapping.go +++ b/vendor/github.com/DataDog/sketches-go/ddsketch/mapping/logarithmic_mapping.go @@ -104,6 +104,12 @@ func (m *LogarithmicMapping) ToProto() *sketchpb.IndexMapping { } } +func (m *LogarithmicMapping) EncodeProto(builder *sketchpb.IndexMappingBuilder) { + builder.SetGamma(m.gamma) + builder.SetIndexOffset(m.indexOffset) + builder.SetInterpolation(uint64(sketchpb.IndexMapping_NONE)) +} + func (m *LogarithmicMapping) Encode(b *[]byte) { enc.EncodeFlag(b, enc.FlagIndexMappingBaseLogarithmic) enc.EncodeFloat64LE(b, m.gamma) diff --git a/vendor/github.com/DataDog/sketches-go/ddsketch/pb/sketchpb/ddsketch.pb.go b/vendor/github.com/DataDog/sketches-go/ddsketch/pb/sketchpb/ddsketch.pb.go index 9dbd6f2930c2f..3bff93da09ef2 100644 --- a/vendor/github.com/DataDog/sketches-go/ddsketch/pb/sketchpb/ddsketch.pb.go +++ b/vendor/github.com/DataDog/sketches-go/ddsketch/pb/sketchpb/ddsketch.pb.go @@ -4,8 +4,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.0 -// protoc v3.19.4 +// protoc-gen-go v1.34.2 +// protoc v4.25.1 // source: ddsketch.proto package sketchpb @@ -363,7 +363,7 @@ func file_ddsketch_proto_rawDescGZIP() []byte { var file_ddsketch_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_ddsketch_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_ddsketch_proto_goTypes = []interface{}{ +var file_ddsketch_proto_goTypes = []any{ (IndexMapping_Interpolation)(0), // 0: IndexMapping.Interpolation (*DDSketch)(nil), // 1: DDSketch (*IndexMapping)(nil), // 2: IndexMapping @@ -389,7 +389,7 @@ func file_ddsketch_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_ddsketch_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_ddsketch_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*DDSketch); i { case 0: return &v.state @@ -401,7 +401,7 @@ func file_ddsketch_proto_init() { return nil } } - file_ddsketch_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_ddsketch_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*IndexMapping); i { case 0: return &v.state @@ -413,7 +413,7 @@ func file_ddsketch_proto_init() { return nil } } - file_ddsketch_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_ddsketch_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*Store); i { case 0: return &v.state diff --git a/vendor/github.com/DataDog/sketches-go/ddsketch/pb/sketchpb/ddsketch.proto_builder.go b/vendor/github.com/DataDog/sketches-go/ddsketch/pb/sketchpb/ddsketch.proto_builder.go new file mode 100644 index 0000000000000..898ec3326bd19 --- /dev/null +++ b/vendor/github.com/DataDog/sketches-go/ddsketch/pb/sketchpb/ddsketch.proto_builder.go @@ -0,0 +1,161 @@ +// THIS IS A GENERATED FILE +// DO NOT EDIT +package sketchpb + +import ( + bytes "bytes" + protowire "google.golang.org/protobuf/encoding/protowire" + io "io" + math "math" +) + +type DDSketchBuilder struct { + writer io.Writer + buf bytes.Buffer + scratch []byte + indexMappingBuilder IndexMappingBuilder + storeBuilder StoreBuilder +} + +func NewDDSketchBuilder(writer io.Writer) *DDSketchBuilder { + return &DDSketchBuilder{ + writer: writer, + } +} +func (x *DDSketchBuilder) Reset(writer io.Writer) { + x.buf.Reset() + x.writer = writer +} +func (x *DDSketchBuilder) SetMapping(cb func(w *IndexMappingBuilder)) { + x.buf.Reset() + x.indexMappingBuilder.writer = &x.buf + x.indexMappingBuilder.scratch = x.scratch + cb(&x.indexMappingBuilder) + x.scratch = protowire.AppendVarint(x.scratch[:0], 0xa) + x.scratch = protowire.AppendVarint(x.scratch, uint64(x.buf.Len())) + x.writer.Write(x.scratch) + x.writer.Write(x.buf.Bytes()) +} +func (x *DDSketchBuilder) SetPositiveValues(cb func(w *StoreBuilder)) { + x.buf.Reset() + x.storeBuilder.writer = &x.buf + x.storeBuilder.scratch = x.scratch + cb(&x.storeBuilder) + x.scratch = protowire.AppendVarint(x.scratch[:0], 0x12) + x.scratch = protowire.AppendVarint(x.scratch, uint64(x.buf.Len())) + x.writer.Write(x.scratch) + x.writer.Write(x.buf.Bytes()) +} +func (x *DDSketchBuilder) SetNegativeValues(cb func(w *StoreBuilder)) { + x.buf.Reset() + x.storeBuilder.writer = &x.buf + x.storeBuilder.scratch = x.scratch + cb(&x.storeBuilder) + x.scratch = protowire.AppendVarint(x.scratch[:0], 0x1a) + x.scratch = protowire.AppendVarint(x.scratch, uint64(x.buf.Len())) + x.writer.Write(x.scratch) + x.writer.Write(x.buf.Bytes()) +} +func (x *DDSketchBuilder) SetZeroCount(v float64) { + x.scratch = protowire.AppendVarint(x.scratch[:0], 0x21) + x.scratch = protowire.AppendFixed64(x.scratch, math.Float64bits(v)) + x.writer.Write(x.scratch) +} + +type IndexMappingBuilder struct { + writer io.Writer + buf bytes.Buffer + scratch []byte +} + +func NewIndexMappingBuilder(writer io.Writer) *IndexMappingBuilder { + return &IndexMappingBuilder{ + writer: writer, + } +} +func (x *IndexMappingBuilder) Reset(writer io.Writer) { + x.buf.Reset() + x.writer = writer +} +func (x *IndexMappingBuilder) SetGamma(v float64) { + x.scratch = protowire.AppendVarint(x.scratch[:0], 0x9) + x.scratch = protowire.AppendFixed64(x.scratch, math.Float64bits(v)) + x.writer.Write(x.scratch) +} +func (x *IndexMappingBuilder) SetIndexOffset(v float64) { + x.scratch = protowire.AppendVarint(x.scratch[:0], 0x11) + x.scratch = protowire.AppendFixed64(x.scratch, math.Float64bits(v)) + x.writer.Write(x.scratch) +} +func (x *IndexMappingBuilder) SetInterpolation(v uint64) { + if v != 0 { + x.scratch = protowire.AppendVarint(x.scratch[:0], 0x18) + x.scratch = protowire.AppendVarint(x.scratch, v) + x.writer.Write(x.scratch) + } +} + +type StoreBuilder struct { + writer io.Writer + buf bytes.Buffer + scratch []byte + store_BinCountsEntryBuilder Store_BinCountsEntryBuilder +} + +func NewStoreBuilder(writer io.Writer) *StoreBuilder { + return &StoreBuilder{ + writer: writer, + } +} +func (x *StoreBuilder) Reset(writer io.Writer) { + x.buf.Reset() + x.writer = writer +} +func (x *StoreBuilder) AddBinCounts(cb func(w *Store_BinCountsEntryBuilder)) { + x.buf.Reset() + x.store_BinCountsEntryBuilder.writer = &x.buf + x.store_BinCountsEntryBuilder.scratch = x.scratch + cb(&x.store_BinCountsEntryBuilder) + x.scratch = protowire.AppendVarint(x.scratch[:0], 0xa) + x.scratch = protowire.AppendVarint(x.scratch, uint64(x.buf.Len())) + x.writer.Write(x.scratch) + x.writer.Write(x.buf.Bytes()) +} +func (x *StoreBuilder) AddContiguousBinCounts(v float64) { + x.scratch = protowire.AppendVarint(x.scratch[:0], 0x11) + x.scratch = protowire.AppendFixed64(x.scratch, math.Float64bits(v)) + x.writer.Write(x.scratch) +} +func (x *StoreBuilder) SetContiguousBinIndexOffset(v int32) { + x.scratch = x.scratch[:0] + x.scratch = protowire.AppendVarint(x.scratch, 0x18) + x.scratch = protowire.AppendVarint(x.scratch, protowire.EncodeZigZag(int64(v))) + x.writer.Write(x.scratch) +} + +type Store_BinCountsEntryBuilder struct { + writer io.Writer + buf bytes.Buffer + scratch []byte +} + +func NewStore_BinCountsEntryBuilder(writer io.Writer) *Store_BinCountsEntryBuilder { + return &Store_BinCountsEntryBuilder{ + writer: writer, + } +} +func (x *Store_BinCountsEntryBuilder) Reset(writer io.Writer) { + x.buf.Reset() + x.writer = writer +} +func (x *Store_BinCountsEntryBuilder) SetKey(v int32) { + x.scratch = x.scratch[:0] + x.scratch = protowire.AppendVarint(x.scratch, 0x8) + x.scratch = protowire.AppendVarint(x.scratch, protowire.EncodeZigZag(int64(v))) + x.writer.Write(x.scratch) +} +func (x *Store_BinCountsEntryBuilder) SetValue(v float64) { + x.scratch = protowire.AppendVarint(x.scratch[:0], 0x11) + x.scratch = protowire.AppendFixed64(x.scratch, math.Float64bits(v)) + x.writer.Write(x.scratch) +} diff --git a/vendor/github.com/DataDog/sketches-go/ddsketch/store/buffered_paginated.go b/vendor/github.com/DataDog/sketches-go/ddsketch/store/buffered_paginated.go index 11a56f9106dc6..a0a9e1e739501 100644 --- a/vendor/github.com/DataDog/sketches-go/ddsketch/store/buffered_paginated.go +++ b/vendor/github.com/DataDog/sketches-go/ddsketch/store/buffered_paginated.go @@ -555,6 +555,20 @@ func (s *BufferedPaginatedStore) ToProto() *sketchpb.Store { } } +func (s *BufferedPaginatedStore) EncodeProto(builder *sketchpb.StoreBuilder) { + if s.IsEmpty() { + return + } + + s.ForEach(func(index int, count float64) (stop bool) { + builder.AddBinCounts(func(w *sketchpb.Store_BinCountsEntryBuilder) { + w.SetKey(int32(index)) + w.SetValue(count) + }) + return false + }) +} + func (s *BufferedPaginatedStore) Reweight(w float64) error { if w <= 0 { return errors.New("can't reweight by a negative factor") diff --git a/vendor/github.com/DataDog/sketches-go/ddsketch/store/dense_store.go b/vendor/github.com/DataDog/sketches-go/ddsketch/store/dense_store.go index 2c4a3d4a08728..817d36e05899e 100644 --- a/vendor/github.com/DataDog/sketches-go/ddsketch/store/dense_store.go +++ b/vendor/github.com/DataDog/sketches-go/ddsketch/store/dense_store.go @@ -250,6 +250,17 @@ func (s *DenseStore) ToProto() *sketchpb.Store { } } +func (s *DenseStore) EncodeProto(builder *sketchpb.StoreBuilder) { + if s.IsEmpty() { + return + } + + for i := s.minIndex - s.offset; i < s.maxIndex-s.offset+1; i++ { + builder.AddContiguousBinCounts(s.bins[i]) + } + builder.SetContiguousBinIndexOffset(int32(s.minIndex)) +} + func (s *DenseStore) Reweight(w float64) error { if w <= 0 { return errors.New("can't reweight by a negative factor") diff --git a/vendor/github.com/DataDog/sketches-go/ddsketch/store/sparse.go b/vendor/github.com/DataDog/sketches-go/ddsketch/store/sparse.go index 9a07836e91eaf..e0163f972bd94 100644 --- a/vendor/github.com/DataDog/sketches-go/ddsketch/store/sparse.go +++ b/vendor/github.com/DataDog/sketches-go/ddsketch/store/sparse.go @@ -150,6 +150,16 @@ func (s *SparseStore) ToProto() *sketchpb.Store { return &sketchpb.Store{BinCounts: binCounts} } +func (s *SparseStore) EncodeProto(builder *sketchpb.StoreBuilder) { + + for index, count := range s.counts { + builder.AddBinCounts(func(w *sketchpb.Store_BinCountsEntryBuilder) { + w.SetKey(int32(index)) + w.SetValue(count) + }) + } +} + func (s *SparseStore) Reweight(w float64) error { if w <= 0 { return errors.New("can't reweight by a negative factor") diff --git a/vendor/github.com/DataDog/sketches-go/ddsketch/store/store.go b/vendor/github.com/DataDog/sketches-go/ddsketch/store/store.go index 64a5e3d508f79..ca4fd92f792ef 100644 --- a/vendor/github.com/DataDog/sketches-go/ddsketch/store/store.go +++ b/vendor/github.com/DataDog/sketches-go/ddsketch/store/store.go @@ -7,7 +7,6 @@ package store import ( "errors" - enc "github.com/DataDog/sketches-go/ddsketch/encoding" "github.com/DataDog/sketches-go/ddsketch/pb/sketchpb" ) @@ -54,6 +53,7 @@ type Store interface { KeyAtRank(rank float64) int MergeWith(store Store) ToProto() *sketchpb.Store + EncodeProto(builder *sketchpb.StoreBuilder) // Reweight multiplies all values from the store by w, but keeps the same global distribution. Reweight(w float64) error // Encode encodes the bins of the store and appends its content to the diff --git a/vendor/modules.txt b/vendor/modules.txt index e00d97c5aa485..160ac79366825 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -198,7 +198,7 @@ github.com/Code-Hex/go-generics-cache/policy/lfu github.com/Code-Hex/go-generics-cache/policy/lru github.com/Code-Hex/go-generics-cache/policy/mru github.com/Code-Hex/go-generics-cache/policy/simple -# github.com/DataDog/sketches-go v1.4.6 +# github.com/DataDog/sketches-go v1.4.7 ## explicit; go 1.18 github.com/DataDog/sketches-go/ddsketch github.com/DataDog/sketches-go/ddsketch/encoding