@@ -10,14 +10,12 @@ import (
10
10
"math"
11
11
"time"
12
12
13
- hllNew "github.com/axiomhq/hyperloglog"
14
- hllOld "github.com/axiomhq/hyperloglog/000"
13
+ "github.com/axiomhq/hyperloglog"
15
14
"github.com/cockroachdb/cockroach/pkg/jobs"
16
15
"github.com/cockroachdb/cockroach/pkg/server/telemetry"
17
16
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb"
18
17
"github.com/cockroachdb/cockroach/pkg/sql/execinfra"
19
18
"github.com/cockroachdb/cockroach/pkg/sql/execinfrapb"
20
- "github.com/cockroachdb/cockroach/pkg/sql/execversion"
21
19
"github.com/cockroachdb/cockroach/pkg/sql/isql"
22
20
"github.com/cockroachdb/cockroach/pkg/sql/parser"
23
21
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode"
@@ -103,7 +101,6 @@ func newSampleAggregator(
103
101
return nil , errors .Errorf ("histograms require one column" )
104
102
}
105
103
}
106
- useNewHLL := execversion .FromContext (ctx ) >= execversion .V25_1
107
104
108
105
// Limit the memory use by creating a child monitor with a hard limit.
109
106
// The processor will disable histogram collection if this limit is not
@@ -144,14 +141,10 @@ func newSampleAggregator(
144
141
for i := range spec .Sketches {
145
142
s .sketches [i ] = sketchInfo {
146
143
spec : spec .Sketches [i ],
144
+ sketch : hyperloglog .New14 (),
147
145
numNulls : 0 ,
148
146
numRows : 0 ,
149
147
}
150
- if useNewHLL {
151
- s .sketches [i ].sketchNew = hllNew .New14 ()
152
- } else {
153
- s .sketches [i ].sketchOld = hllOld .New14 ()
154
- }
155
148
if spec .Sketches [i ].GenerateHistogram {
156
149
sampleCols .Add (int (spec .Sketches [i ].Columns [0 ]))
157
150
}
@@ -173,14 +166,10 @@ func newSampleAggregator(
173
166
s .invSr [col ] = & sr
174
167
s .invSketch [col ] = & sketchInfo {
175
168
spec : spec .InvertedSketches [i ],
169
+ sketch : hyperloglog .New14 (),
176
170
numNulls : 0 ,
177
171
numRows : 0 ,
178
172
}
179
- if useNewHLL {
180
- s .invSketch [col ].sketchNew = hllNew .New14 ()
181
- } else {
182
- s .invSketch [col ].sketchOld = hllOld .New14 ()
183
- }
184
173
}
185
174
186
175
if err := s .Init (
@@ -372,6 +361,8 @@ func (s *sampleAggregator) mainLoop(
372
361
func (s * sampleAggregator ) processSketchRow (
373
362
sketch * sketchInfo , row rowenc.EncDatumRow , da * tree.DatumAlloc ,
374
363
) error {
364
+ var tmpSketch hyperloglog.Sketch
365
+
375
366
numRows , err := row [s .numRowsCol ].GetInt ()
376
367
if err != nil {
377
368
return err
@@ -398,22 +389,11 @@ func (s *sampleAggregator) processSketchRow(
398
389
if d == tree .DNull {
399
390
return errors .AssertionFailedf ("NULL sketch data" )
400
391
}
401
- if sketch .sketchNew != nil {
402
- var tmpSketch hllNew.Sketch
403
- if err := tmpSketch .UnmarshalBinary ([]byte (* d .(* tree.DBytes ))); err != nil {
404
- return err
405
- }
406
- if err := sketch .sketchNew .Merge (& tmpSketch ); err != nil {
407
- return errors .NewAssertionErrorWithWrappedErrf (err , "merging sketch data" )
408
- }
409
- } else {
410
- var tmpSketch hllOld.Sketch
411
- if err := tmpSketch .UnmarshalBinary ([]byte (* d .(* tree.DBytes ))); err != nil {
412
- return err
413
- }
414
- if err := sketch .sketchOld .Merge (& tmpSketch ); err != nil {
415
- return errors .NewAssertionErrorWithWrappedErrf (err , "merging sketch data" )
416
- }
392
+ if err := tmpSketch .UnmarshalBinary ([]byte (* d .(* tree.DBytes ))); err != nil {
393
+ return err
394
+ }
395
+ if err := sketch .sketch .Merge (& tmpSketch ); err != nil {
396
+ return errors .NewAssertionErrorWithWrappedErrf (err , "merging sketch data" )
417
397
}
418
398
return nil
419
399
}
@@ -631,12 +611,7 @@ func (s *sampleAggregator) getAvgSize(si *sketchInfo) int64 {
631
611
// getDistinctCount returns the number of distinct values in the given sketch,
632
612
// optionally including null values.
633
613
func (s * sampleAggregator ) getDistinctCount (si * sketchInfo , includeNulls bool ) int64 {
634
- var distinctCount int64
635
- if si .sketchNew != nil {
636
- distinctCount = int64 (si .sketchNew .Estimate ())
637
- } else {
638
- distinctCount = int64 (si .sketchOld .Estimate ())
639
- }
614
+ distinctCount := int64 (si .sketch .Estimate ())
640
615
if si .numNulls > 0 && ! includeNulls {
641
616
// Nulls are included in the estimate, so reduce the count by 1 if nulls are
642
617
// not requested.
0 commit comments