mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Restructure files
This commit is contained in:
parent
63b887eb62
commit
3ef7da33c8
49
db.go
49
db.go
|
@ -280,3 +280,52 @@ func (db *DB) AppendVector(ts int64, v *Vector) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
const sep = '\xff'
|
||||
|
||||
// SeriesShard handles reads and writes of time series falling into
|
||||
// a hashed shard of a series.
|
||||
type SeriesShard struct {
|
||||
mtx sync.RWMutex
|
||||
blocks *Block
|
||||
head *HeadBlock
|
||||
}
|
||||
|
||||
// NewSeriesShard returns a new SeriesShard.
|
||||
func NewSeriesShard() *SeriesShard {
|
||||
return &SeriesShard{
|
||||
// TODO(fabxc): restore from checkpoint.
|
||||
head: &HeadBlock{
|
||||
index: newMemIndex(),
|
||||
descs: map[uint64][]*chunkDesc{},
|
||||
values: map[string][]string{},
|
||||
forward: map[uint32]*chunkDesc{},
|
||||
},
|
||||
// TODO(fabxc): provide access to persisted blocks.
|
||||
}
|
||||
}
|
||||
|
||||
// chunkDesc wraps a plain data chunk and provides cached meta data about it.
|
||||
type chunkDesc struct {
|
||||
lset Labels
|
||||
chunk chunks.Chunk
|
||||
|
||||
// Caching fields.
|
||||
lastTimestamp int64
|
||||
lastValue float64
|
||||
|
||||
app chunks.Appender // Current appender for the chunks.
|
||||
}
|
||||
|
||||
func (cd *chunkDesc) append(ts int64, v float64) (err error) {
|
||||
if cd.app == nil {
|
||||
cd.app, err = cd.chunk.Appender()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
cd.lastTimestamp = ts
|
||||
cd.lastValue = v
|
||||
|
||||
return cd.app.Append(ts, v)
|
||||
}
|
||||
|
|
|
@ -9,30 +9,6 @@ import (
|
|||
"github.com/fabxc/tsdb/chunks"
|
||||
)
|
||||
|
||||
const sep = '\xff'
|
||||
|
||||
// SeriesShard handles reads and writes of time series falling into
|
||||
// a hashed shard of a series.
|
||||
type SeriesShard struct {
|
||||
mtx sync.RWMutex
|
||||
blocks *Block
|
||||
head *HeadBlock
|
||||
}
|
||||
|
||||
// NewSeriesShard returns a new SeriesShard.
|
||||
func NewSeriesShard() *SeriesShard {
|
||||
return &SeriesShard{
|
||||
// TODO(fabxc): restore from checkpoint.
|
||||
head: &HeadBlock{
|
||||
index: newMemIndex(),
|
||||
descs: map[uint64][]*chunkDesc{},
|
||||
values: map[string][]string{},
|
||||
forward: map[uint32]*chunkDesc{},
|
||||
},
|
||||
// TODO(fabxc): provide access to persisted blocks.
|
||||
}
|
||||
}
|
||||
|
||||
// HeadBlock handles reads and writes of time series data within a time window.
|
||||
type HeadBlock struct {
|
||||
mtx sync.RWMutex
|
||||
|
@ -44,10 +20,6 @@ type HeadBlock struct {
|
|||
samples uint64
|
||||
}
|
||||
|
||||
// Block handles reads against a completed block of time series data within a time window.
|
||||
type Block struct {
|
||||
}
|
||||
|
||||
// WriteTo serializes the current head block contents into w.
|
||||
func (h *HeadBlock) WriteTo(w io.Writer) (int64, error) {
|
||||
h.mtx.RLock()
|
||||
|
@ -106,28 +78,3 @@ func (h *HeadBlock) append(hash uint64, lset Labels, ts int64, v float64) error
|
|||
h.samples++
|
||||
return nil
|
||||
}
|
||||
|
||||
// chunkDesc wraps a plain data chunk and provides cached meta data about it.
|
||||
type chunkDesc struct {
|
||||
lset Labels
|
||||
chunk chunks.Chunk
|
||||
|
||||
// Caching fields.
|
||||
lastTimestamp int64
|
||||
lastValue float64
|
||||
|
||||
app chunks.Appender // Current appender for the chunks.
|
||||
}
|
||||
|
||||
func (cd *chunkDesc) append(ts int64, v float64) (err error) {
|
||||
if cd.app == nil {
|
||||
cd.app, err = cd.chunk.Appender()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
cd.lastTimestamp = ts
|
||||
cd.lastValue = v
|
||||
|
||||
return cd.app.Append(ts, v)
|
||||
}
|
Loading…
Reference in a new issue