textparse: Optimize CreatedTimestamp; It returns int64 value now. (#16072)

..instead of *int64. This is as an optimization and ease of use. We already
accepted in many places (proto histograms, PRW) that CT (or any timestamp really) 0
means not set.

Signed-off-by: bwplotka <bwplotka@gmail.com>
This commit is contained in:
Bartlomiej Plotka 2025-03-07 13:43:13 +01:00 committed by GitHub
parent 71cb219eb6
commit dc85d677d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 180 additions and 107 deletions

View file

@ -83,7 +83,7 @@ type NHCBParser struct {
fhNHCB *histogram.FloatHistogram
lsetNHCB labels.Labels
exemplars []exemplar.Exemplar
ctNHCB *int64
ctNHCB int64
metricStringNHCB string
// Collates values from the classic histogram series to build
@ -92,7 +92,7 @@ type NHCBParser struct {
tempNHCB convertnhcb.TempHistogram
tempExemplars []exemplar.Exemplar
tempExemplarCount int
tempCT *int64
tempCT int64
// Remembers the last base histogram metric name (assuming it's
// a classic histogram) so we can tell if the next float series
@ -160,7 +160,7 @@ func (p *NHCBParser) Exemplar(ex *exemplar.Exemplar) bool {
return p.parser.Exemplar(ex)
}
func (p *NHCBParser) CreatedTimestamp() *int64 {
func (p *NHCBParser) CreatedTimestamp() int64 {
switch p.state {
case stateStart:
if p.entry == EntrySeries || p.entry == EntryHistogram {
@ -171,7 +171,7 @@ func (p *NHCBParser) CreatedTimestamp() *int64 {
case stateEmitting:
return p.ctNHCB
}
return nil
return 0
}
func (p *NHCBParser) Next() (Entry, error) {
@ -375,6 +375,6 @@ func (p *NHCBParser) processNHCB() bool {
}
p.tempNHCB.Reset()
p.tempExemplarCount = 0
p.tempCT = nil
p.tempCT = 0
return err == nil
}