mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Make Chunks return the number of samples inside
Signed-off-by: Goutham Veeramachaneni <cs14btech11014@iith.ac.in>
This commit is contained in:
parent
1263a68875
commit
401bdfd4a6
|
@ -43,6 +43,7 @@ type Chunk interface {
|
||||||
Encoding() Encoding
|
Encoding() Encoding
|
||||||
Appender() (Appender, error)
|
Appender() (Appender, error)
|
||||||
Iterator() Iterator
|
Iterator() Iterator
|
||||||
|
NumSamples() int
|
||||||
}
|
}
|
||||||
|
|
||||||
// FromData returns a chunk from a byte slice of chunk data.
|
// FromData returns a chunk from a byte slice of chunk data.
|
||||||
|
|
|
@ -72,6 +72,11 @@ func (c *XORChunk) Bytes() []byte {
|
||||||
return c.b.bytes()
|
return c.b.bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NumSamples returns the number of samples in the chunk.
|
||||||
|
func (c *XORChunk) NumSamples() int {
|
||||||
|
return int(binary.BigEndian.Uint16(c.Bytes()))
|
||||||
|
}
|
||||||
|
|
||||||
// Appender implements the Chunk interface.
|
// Appender implements the Chunk interface.
|
||||||
func (c *XORChunk) Appender() (Appender, error) {
|
func (c *XORChunk) Appender() (Appender, error) {
|
||||||
it := c.iterator()
|
it := c.iterator()
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
package tsdb
|
package tsdb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
|
@ -461,7 +460,7 @@ func populateBlock(blocks []Block, indexw IndexWriter, chunkw ChunkWriter) (*Blo
|
||||||
meta.Stats.NumChunks += uint64(len(chks))
|
meta.Stats.NumChunks += uint64(len(chks))
|
||||||
meta.Stats.NumSeries++
|
meta.Stats.NumSeries++
|
||||||
for _, chk := range chks {
|
for _, chk := range chks {
|
||||||
meta.Stats.NumSamples += uint64(binary.BigEndian.Uint16(chk.Chunk.Bytes()))
|
meta.Stats.NumSamples += uint64(chk.Chunk.NumSamples())
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, l := range lset {
|
for _, l := range lset {
|
||||||
|
|
Loading…
Reference in a new issue