mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-31 15:06:26 +00:00
wip
This commit is contained in:
parent
4e5b24c53a
commit
30a6aee52a
1 changed files with 19 additions and 6 deletions
|
@ -1335,11 +1335,9 @@ func (br *blockResult) getColumnByName(columnName string) *blockResultColumn {
|
|||
}
|
||||
cs := br.getColumns()
|
||||
|
||||
// Search for the needed column in reverse order, since the old column may be overridden by new column in addResultColumn()
|
||||
for i := len(cs) - 1; i >= 0; i-- {
|
||||
if cs[i].name == columnName {
|
||||
return cs[i]
|
||||
}
|
||||
idx := getBlockResultColumnIdxByName(cs, columnName)
|
||||
if idx >= 0 {
|
||||
return cs[idx]
|
||||
}
|
||||
|
||||
br.addConstColumn(columnName, "")
|
||||
|
@ -1365,7 +1363,13 @@ func (br *blockResult) getColumns() []*blockResultColumn {
|
|||
clear(br.cs)
|
||||
cs := br.cs[:0]
|
||||
for i := range csBuf {
|
||||
cs = append(cs, &csBuf[i])
|
||||
c := &csBuf[i]
|
||||
idx := getBlockResultColumnIdxByName(cs, c.name)
|
||||
if idx >= 0 {
|
||||
cs[idx] = c
|
||||
} else {
|
||||
cs = append(cs, c)
|
||||
}
|
||||
}
|
||||
br.cs = cs
|
||||
br.csInitialized = true
|
||||
|
@ -1373,6 +1377,15 @@ func (br *blockResult) getColumns() []*blockResultColumn {
|
|||
return br.cs
|
||||
}
|
||||
|
||||
func getBlockResultColumnIdxByName(cs []*blockResultColumn, name string) int {
|
||||
for i, c := range cs {
|
||||
if c.name == name {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
func (br *blockResult) skipRows(skipRows int) {
|
||||
br.timestamps = append(br.timestamps[:0], br.timestamps[skipRows:]...)
|
||||
for _, c := range br.getColumns() {
|
||||
|
|
Loading…
Reference in a new issue