fix(storage): Fix panic when read request results in empty an group
Moves the check to determine if a series has data for the current time range into the groupBySort function, which is consistent with the groupNoneSort function.pull/10616/head
parent
cae010be69
commit
f2891c3f59
|
@ -205,8 +205,8 @@ func groupNoneSort(g *groupResultSet) (int, error) {
|
||||||
n := 0
|
n := 0
|
||||||
row := cur.Next()
|
row := cur.Next()
|
||||||
for row != nil {
|
for row != nil {
|
||||||
n++
|
|
||||||
if allTime || g.seriesHasPoints(row) {
|
if allTime || g.seriesHasPoints(row) {
|
||||||
|
n++
|
||||||
g.km.mergeTagKeys(row.Tags)
|
g.km.mergeTagKeys(row.Tags)
|
||||||
}
|
}
|
||||||
row = cur.Next()
|
row = cur.Next()
|
||||||
|
@ -217,22 +217,16 @@ func groupNoneSort(g *groupResultSet) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func groupByNextGroup(g *groupResultSet) GroupCursor {
|
func groupByNextGroup(g *groupResultSet) GroupCursor {
|
||||||
next:
|
|
||||||
row := g.rows[g.i]
|
row := g.rows[g.i]
|
||||||
for i := range g.keys {
|
for i := range g.keys {
|
||||||
g.rgc.vals[i] = row.Tags.Get(g.keys[i])
|
g.rgc.vals[i] = row.Tags.Get(g.keys[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
g.km.clear()
|
g.km.clear()
|
||||||
allTime := g.req.Hints.HintSchemaAllTime()
|
|
||||||
c := 0
|
|
||||||
rowKey := row.SortKey
|
rowKey := row.SortKey
|
||||||
j := g.i
|
j := g.i
|
||||||
for j < len(g.rows) && bytes.Equal(rowKey, g.rows[j].SortKey) {
|
for j < len(g.rows) && bytes.Equal(rowKey, g.rows[j].SortKey) {
|
||||||
if allTime || g.seriesHasPoints(g.rows[j]) {
|
g.km.mergeTagKeys(g.rows[j].Tags)
|
||||||
g.km.mergeTagKeys(g.rows[j].Tags)
|
|
||||||
c++
|
|
||||||
}
|
|
||||||
j++
|
j++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,9 +236,6 @@ next:
|
||||||
g.i = j
|
g.i = j
|
||||||
if j == len(g.rows) {
|
if j == len(g.rows) {
|
||||||
g.eof = true
|
g.eof = true
|
||||||
} else if c == 0 {
|
|
||||||
// no rows with points
|
|
||||||
goto next
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &g.rgc
|
return &g.rgc
|
||||||
|
@ -261,28 +252,31 @@ func groupBySort(g *groupResultSet) (int, error) {
|
||||||
var rows []*SeriesRow
|
var rows []*SeriesRow
|
||||||
vals := make([][]byte, len(g.keys))
|
vals := make([][]byte, len(g.keys))
|
||||||
tagsBuf := &tagsBuffer{sz: 4096}
|
tagsBuf := &tagsBuffer{sz: 4096}
|
||||||
|
allTime := g.req.Hints.HintSchemaAllTime()
|
||||||
|
|
||||||
row := cur.Next()
|
row := cur.Next()
|
||||||
for row != nil {
|
for row != nil {
|
||||||
nr := *row
|
if allTime || g.seriesHasPoints(row) {
|
||||||
nr.SeriesTags = tagsBuf.copyTags(nr.SeriesTags)
|
nr := *row
|
||||||
nr.Tags = tagsBuf.copyTags(nr.Tags)
|
nr.SeriesTags = tagsBuf.copyTags(nr.SeriesTags)
|
||||||
|
nr.Tags = tagsBuf.copyTags(nr.Tags)
|
||||||
|
|
||||||
l := 0
|
l := 0
|
||||||
for i, k := range g.keys {
|
for i, k := range g.keys {
|
||||||
vals[i] = nr.Tags.Get(k)
|
vals[i] = nr.Tags.Get(k)
|
||||||
if len(vals[i]) == 0 {
|
if len(vals[i]) == 0 {
|
||||||
vals[i] = g.nilSort
|
vals[i] = g.nilSort
|
||||||
|
}
|
||||||
|
l += len(vals[i])
|
||||||
}
|
}
|
||||||
l += len(vals[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
nr.SortKey = make([]byte, 0, l)
|
nr.SortKey = make([]byte, 0, l)
|
||||||
for _, v := range vals {
|
for _, v := range vals {
|
||||||
nr.SortKey = append(nr.SortKey, v...)
|
nr.SortKey = append(nr.SortKey, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
rows = append(rows, &nr)
|
rows = append(rows, &nr)
|
||||||
|
}
|
||||||
row = cur.Next()
|
row = cur.Next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue