mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-31 15:06:26 +00:00
wip
This commit is contained in:
parent
d08dfd8752
commit
306d6e4f6d
1 changed files with 19 additions and 7 deletions
|
@ -63,12 +63,18 @@ func (br *blockResult) reset() {
|
||||||
br.csInitialized = false
|
br.csInitialized = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// clone returns a clone of br, which owns its own memory.
|
// clone returns a clone of br, which owns its own data.
|
||||||
func (br *blockResult) clone() *blockResult {
|
func (br *blockResult) clone() *blockResult {
|
||||||
brNew := &blockResult{}
|
brNew := &blockResult{}
|
||||||
|
|
||||||
cs := br.getColumns()
|
cs := br.getColumns()
|
||||||
|
|
||||||
|
// Pre-populate valuesEncoded in every column in order to properly calculate the needed backing buffer size below.
|
||||||
|
for _, c := range cs {
|
||||||
|
_ = c.getValuesEncoded(br)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate the backing buffer size needed for cloning column values.
|
||||||
bufLen := 0
|
bufLen := 0
|
||||||
for _, c := range cs {
|
for _, c := range cs {
|
||||||
bufLen += c.neededBackingBufLen()
|
bufLen += c.neededBackingBufLen()
|
||||||
|
@ -1423,7 +1429,9 @@ type blockResultColumn struct {
|
||||||
|
|
||||||
// clone returns a clone of c backed by data from br.
|
// clone returns a clone of c backed by data from br.
|
||||||
//
|
//
|
||||||
// the clone is valid until br is reset.
|
// It is expected that c.valuesEncoded is already initialized for non-time column.
|
||||||
|
//
|
||||||
|
// The clone is valid until br is reset.
|
||||||
func (c *blockResultColumn) clone(br *blockResult) blockResultColumn {
|
func (c *blockResultColumn) clone(br *blockResult) blockResultColumn {
|
||||||
var cNew blockResultColumn
|
var cNew blockResultColumn
|
||||||
|
|
||||||
|
@ -1436,13 +1444,19 @@ func (c *blockResultColumn) clone(br *blockResult) blockResultColumn {
|
||||||
cNew.maxValue = c.maxValue
|
cNew.maxValue = c.maxValue
|
||||||
|
|
||||||
cNew.dictValues = br.cloneValues(c.dictValues)
|
cNew.dictValues = br.cloneValues(c.dictValues)
|
||||||
|
|
||||||
|
if !c.isTime && c.valuesEncoded == nil {
|
||||||
|
logger.Panicf("BUG: valuesEncoded must be non-nil for non-time column %q; isConst=%v; valueType=%d", c.name, c.isConst, c.valueType)
|
||||||
|
}
|
||||||
cNew.valuesEncoded = br.cloneValues(c.valuesEncoded)
|
cNew.valuesEncoded = br.cloneValues(c.valuesEncoded)
|
||||||
|
|
||||||
if c.valueType != valueTypeString {
|
if c.valueType != valueTypeString {
|
||||||
cNew.values = br.cloneValues(c.values)
|
cNew.values = br.cloneValues(c.values)
|
||||||
}
|
}
|
||||||
cNew.valuesBucketed = br.cloneValues(c.valuesBucketed)
|
cNew.valuesBucketed = br.cloneValues(c.valuesBucketed)
|
||||||
|
|
||||||
cNew.newValuesEncodedFunc = c.newValuesEncodedFunc
|
// Do not copy c.newValuesEncodedFunc, since it may refer to data, which may change over time.
|
||||||
|
// We already copied c.valuesEncoded, so cNew.newValuesEncodedFunc must be nil.
|
||||||
|
|
||||||
cNew.bucketSizeStr = c.bucketSizeStr
|
cNew.bucketSizeStr = c.bucketSizeStr
|
||||||
cNew.bucketOffsetStr = c.bucketOffsetStr
|
cNew.bucketOffsetStr = c.bucketOffsetStr
|
||||||
|
@ -1535,11 +1549,9 @@ func (c *blockResultColumn) getValuesEncoded(br *blockResult) []string {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if values := c.valuesEncoded; values != nil {
|
if c.valuesEncoded == nil {
|
||||||
return values
|
c.valuesEncoded = c.newValuesEncodedFunc(br)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.valuesEncoded = c.newValuesEncodedFunc(br)
|
|
||||||
return c.valuesEncoded
|
return c.valuesEncoded
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue