|
|
@ -57,7 +57,7 @@ func (c *compactor) close() error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (c *compactor) compact(dir string, a, b *persistedBlock) error {
|
|
|
|
func (c *compactor) compact(dir string, a, b block) error {
|
|
|
|
if err := os.MkdirAll(dir, 0777); err != nil {
|
|
|
|
if err := os.MkdirAll(dir, 0777); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -77,23 +77,32 @@ func (c *compactor) compact(dir string, a, b *persistedBlock) error {
|
|
|
|
defer index.Close()
|
|
|
|
defer index.Close()
|
|
|
|
defer series.Close()
|
|
|
|
defer series.Close()
|
|
|
|
|
|
|
|
|
|
|
|
aall, err := a.index.Postings("", "")
|
|
|
|
aall, err := a.index().Postings("", "")
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ball, err := b.index.Postings("", "")
|
|
|
|
ball, err := b.index().Postings("", "")
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
set, err := newCompactionMerger(
|
|
|
|
set, err := newCompactionMerger(
|
|
|
|
newCompactionSeriesSet(a.index, a.chunks, aall),
|
|
|
|
newCompactionSeriesSet(a.index(), a.series(), aall),
|
|
|
|
newCompactionSeriesSet(b.index, b.chunks, ball),
|
|
|
|
newCompactionSeriesSet(b.index(), b.series(), ball),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
astats, err := a.index().Stats()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bstats, err := a.index().Stats()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// We fully rebuild the postings list index from merged series.
|
|
|
|
// We fully rebuild the postings list index from merged series.
|
|
|
|
var (
|
|
|
|
var (
|
|
|
|
postings = &memPostings{m: make(map[term][]uint32, 512)}
|
|
|
|
postings = &memPostings{m: make(map[term][]uint32, 512)}
|
|
|
@ -101,9 +110,9 @@ func (c *compactor) compact(dir string, a, b *persistedBlock) error {
|
|
|
|
i = uint32(0)
|
|
|
|
i = uint32(0)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
stats := BlockStats{
|
|
|
|
stats := BlockStats{
|
|
|
|
MinTime: a.stats.MinTime,
|
|
|
|
MinTime: astats.MinTime,
|
|
|
|
MaxTime: b.stats.MaxTime,
|
|
|
|
MaxTime: bstats.MaxTime,
|
|
|
|
SampleCount: a.stats.SampleCount + b.stats.SampleCount,
|
|
|
|
SampleCount: astats.SampleCount + bstats.SampleCount,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for set.Next() {
|
|
|
|
for set.Next() {
|
|
|
|