pr(tsdb): Feedback items from megacheck
* batch cursors and cursorIterator will be removed in a follow up PR using Arrow array data structurespull/10007/head
parent
910d0fe5e6
commit
497fc42779
|
@ -401,7 +401,6 @@ func (cmd *Command) processFrames(wr *bufio.Writer, frames []storage.ReadRespons
|
|||
wr.Write(strconv.AppendInt(line, p.Timestamps[i], 10))
|
||||
wr.WriteByte(' ')
|
||||
|
||||
line = buf[:0]
|
||||
if p.Values[i] {
|
||||
wr.WriteString("true")
|
||||
} else {
|
||||
|
|
|
@ -85,6 +85,9 @@ type multiShardBatchCursors struct {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO(sgc): temporary to keep megacheck happy; BatchCursors will be removed in subsequent PR
|
||||
var _ = newMultiShardBatchCursors
|
||||
|
||||
func newMultiShardBatchCursors(ctx context.Context, rr *readRequest) *multiShardBatchCursors {
|
||||
lim := rr.limit
|
||||
if lim < 0 {
|
||||
|
|
|
@ -113,7 +113,7 @@ func (c *floatArrayAscendingCursor) Next() *tsdb.FloatArray {
|
|||
pos += n
|
||||
c.tsm.pos += n
|
||||
if c.tsm.pos >= len(tvals.Timestamps) {
|
||||
tvals = c.nextTSM()
|
||||
c.nextTSM()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -381,27 +381,32 @@ func (c *integerArrayAscendingCursor) Next() *tsdb.IntegerArray {
|
|||
}
|
||||
|
||||
if pos < len(c.res.Timestamps) {
|
||||
if pos == 0 {
|
||||
// optimization: all points served from TSM data
|
||||
copy(c.res.Timestamps, tvals.Timestamps)
|
||||
pos += copy(c.res.Values, tvals.Values)
|
||||
c.nextTSM()
|
||||
} else {
|
||||
// copy as much as we can
|
||||
n := copy(c.res.Timestamps[pos:], tvals.Timestamps[c.tsm.pos:])
|
||||
copy(c.res.Values[pos:], tvals.Values[c.tsm.pos:])
|
||||
pos += n
|
||||
c.tsm.pos += n
|
||||
if c.tsm.pos >= len(tvals.Timestamps) {
|
||||
tvals = c.nextTSM()
|
||||
if c.tsm.pos < len(tvals.Timestamps) {
|
||||
if pos == 0 {
|
||||
// optimization: all points served from TSM data
|
||||
copy(c.res.Timestamps, tvals.Timestamps)
|
||||
pos += copy(c.res.Values, tvals.Values)
|
||||
c.nextTSM()
|
||||
} else {
|
||||
// copy as much as we can
|
||||
n := copy(c.res.Timestamps[pos:], tvals.Timestamps[c.tsm.pos:])
|
||||
copy(c.res.Values[pos:], tvals.Values[c.tsm.pos:])
|
||||
pos += n
|
||||
c.tsm.pos += n
|
||||
if c.tsm.pos >= len(tvals.Timestamps) {
|
||||
c.nextTSM()
|
||||
}
|
||||
}
|
||||
}
|
||||
// TSM was exhausted
|
||||
for pos < len(c.res.Timestamps) && c.cache.pos < len(cvals) {
|
||||
c.res.Timestamps[pos] = cvals[c.cache.pos].UnixNano()
|
||||
c.res.Values[pos] = cvals[c.cache.pos].(IntegerValue).value
|
||||
pos++
|
||||
c.cache.pos++
|
||||
|
||||
if c.cache.pos < len(cvals) {
|
||||
// TSM was exhausted
|
||||
for pos < len(c.res.Timestamps) && c.cache.pos < len(cvals) {
|
||||
c.res.Timestamps[pos] = cvals[c.cache.pos].UnixNano()
|
||||
c.res.Values[pos] = cvals[c.cache.pos].(IntegerValue).value
|
||||
pos++
|
||||
c.cache.pos++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -670,7 +675,7 @@ func (c *unsignedArrayAscendingCursor) Next() *tsdb.UnsignedArray {
|
|||
pos += n
|
||||
c.tsm.pos += n
|
||||
if c.tsm.pos >= len(tvals.Timestamps) {
|
||||
tvals = c.nextTSM()
|
||||
c.nextTSM()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -951,7 +956,7 @@ func (c *stringArrayAscendingCursor) Next() *tsdb.StringArray {
|
|||
pos += n
|
||||
c.tsm.pos += n
|
||||
if c.tsm.pos >= len(tvals.Timestamps) {
|
||||
tvals = c.nextTSM()
|
||||
c.nextTSM()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1232,7 +1237,7 @@ func (c *booleanArrayAscendingCursor) Next() *tsdb.BooleanArray {
|
|||
pos += n
|
||||
c.tsm.pos += n
|
||||
if c.tsm.pos >= len(tvals.Timestamps) {
|
||||
tvals = c.nextTSM()
|
||||
c.nextTSM()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ func (c *{{$type}}) Next() {{$arrayType}} {
|
|||
pos += n
|
||||
c.tsm.pos += n
|
||||
if c.tsm.pos >= len(tvals.Timestamps) {
|
||||
tvals = c.nextTSM()
|
||||
c.nextTSM()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,9 @@ type cursorIterator struct {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO(sgc): temporary to keep megacheck happy; cursorIterator will be removed in subsequent PR
|
||||
var _ cursorIterator
|
||||
|
||||
func (q *cursorIterator) Next(ctx context.Context, r *tsdb.CursorRequest) (tsdb.Cursor, error) {
|
||||
// Look up fields for measurement.
|
||||
mf := q.e.fieldset.Fields(r.Name)
|
||||
|
|
Loading…
Reference in New Issue