Skip to content

Commit

Permalink
PromQL engine update
Browse files Browse the repository at this point in the history
* Prefer mapped values
  • Loading branch information
alpinskiy committed Nov 25, 2024
1 parent 83fb499 commit 0ab75f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
13 changes: 6 additions & 7 deletions internal/api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2847,14 +2847,13 @@ func (c *pointsSelectCols) rowAt(i int) tsSelectRow {
row.val[j] = c.val[j][i]
}
for j := range c.tag {
var hasSTag bool
if len(c.stag) != 0 {
hasSTag = c.stag[j].Pos[i].Start < c.stag[j].Pos[i].End && c.stag[j].Pos[i].End <= len(c.stag[j].Buf)
}
if hasSTag {
row.stag[c.tagIx[j]] = string(c.stag[j].Buf[c.stag[j].Pos[i].Start:c.stag[j].Pos[i].End])
} else {
if c.tag[j][i] != 0 {
row.tag[c.tagIx[j]] = c.tag[j][i]
} else if len(c.stag) != 0 {
hasSTag := c.stag[j].Pos[i].Start < c.stag[j].Pos[i].End && c.stag[j].Pos[i].End <= len(c.stag[j].Buf)
if hasSTag {
row.stag[c.tagIx[j]] = string(c.stag[j].Buf[c.stag[j].Pos[i].Start:c.stag[j].Pos[i].End])
}
}
}
if c.tagStr.Pos != nil && i < len(c.tagStr.Pos) {
Expand Down
9 changes: 7 additions & 2 deletions internal/api/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@ const (

func (pq *pointsQuery) cacheKey() string {
var sb strings.Builder
sb.WriteString(";v=")
sb.WriteString(fmt.Sprint(pq.version))
sb.WriteString("v=")
switch pq.version {
case Version1:
sb.WriteString(Version1)
default:
sb.WriteString(Version2)
}
sb.WriteString(";m=")
sb.WriteString(fmt.Sprint(pq.metricID))
sb.WriteString(";pk=")
Expand Down

0 comments on commit 0ab75f5

Please sign in to comment.