Skip to content

Commit 87e42a8

Browse files
and and unless for native histograms
Signed-off-by: Saumya Shah <[email protected]>
1 parent c136226 commit 87e42a8

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

Diff for: engine/engine_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -5373,6 +5373,10 @@ histogram_sum(
53735373
name: "Binary AND",
53745374
query: `histogram_quantile(0.7, native_histogram_series) AND native_histogram_series`,
53755375
},
5376+
{
5377+
name: "Unless",
5378+
query: `sum without(foo) (native_histogram_series) unless native_histogram_series`,
5379+
},
53765380
}
53775381

53785382
defer pprof.StopCPUProfile()

Diff for: execution/binary/vector.go

+18-7
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,19 @@ func (o *vectorOperator) execBinaryAnd(lhs, rhs model.StepVector) (model.StepVec
232232
jp.sid = sampleID
233233
jp.ats = ts
234234
}
235-
for i, sampleID := range lhs.SampleIDs {
236-
if jp := o.hcJoinBuckets[sampleID]; jp.ats == ts {
237-
step.AppendSample(o.pool, o.outputSeriesID(sampleID+1, jp.sid+1), lhs.Samples[i])
238-
}
239-
}
240235

241236
for _, histogramID := range rhs.HistogramIDs {
242237
jp := o.lcJoinBuckets[histogramID]
243238
jp.sid = histogramID
244239
jp.ats = ts
245240
}
241+
242+
for i, sampleID := range lhs.SampleIDs {
243+
if jp := o.hcJoinBuckets[sampleID]; jp.ats == ts {
244+
step.AppendSample(o.pool, o.outputSeriesID(sampleID+1, jp.sid+1), lhs.Samples[i])
245+
}
246+
}
247+
246248
for i, histogramID := range lhs.HistogramIDs {
247249
if jp := o.hcJoinBuckets[histogramID]; jp.ats == ts {
248250
step.AppendHistogram(o.pool, o.outputSeriesID(histogramID+1, jp.sid+1), lhs.Histograms[i])
@@ -268,8 +270,7 @@ func (o *vectorOperator) execBinaryOr(lhs, rhs model.StepVector) (model.StepVect
268270
}
269271

270272
for i, sampleID := range rhs.SampleIDs {
271-
jp := o.lcJoinBuckets[sampleID]
272-
if jp.ats != ts {
273+
if jp := o.lcJoinBuckets[sampleID]; jp.ats != ts {
273274
step.AppendSample(o.pool, o.outputSeriesID(0, sampleID+1), rhs.Samples[i])
274275
}
275276
}
@@ -291,11 +292,21 @@ func (o *vectorOperator) execBinaryUnless(lhs, rhs model.StepVector) (model.Step
291292
jp := o.lcJoinBuckets[sampleID]
292293
jp.ats = ts
293294
}
295+
for _, histogramID := range rhs.HistogramIDs {
296+
jp := o.lcJoinBuckets[histogramID]
297+
jp.ats = ts
298+
}
299+
294300
for i, sampleID := range lhs.SampleIDs {
295301
if jp := o.hcJoinBuckets[sampleID]; jp.ats != ts {
296302
step.AppendSample(o.pool, o.outputSeriesID(sampleID+1, 0), lhs.Samples[i])
297303
}
298304
}
305+
for i, histogramID := range lhs.HistogramIDs {
306+
if jp := o.hcJoinBuckets[histogramID]; jp.ats != ts {
307+
step.AppendHistogram(o.pool, o.outputSeriesID(histogramID+1, 0), lhs.Histograms[i])
308+
}
309+
}
299310
return step, nil
300311
}
301312

0 commit comments

Comments
 (0)