lib/storage: return dedup interval in milliseconds from GetDedupInterval()

This removes duplicate .Milliseconds() calls after GetDedupInterval() calls.
This commit is contained in:
Aliaksandr Valialkin 2021-12-15 13:26:35 +02:00
parent acd56603b0
commit 92070cbb67
No known key found for this signature in database
GPG Key ID: A72BEC6CD3D0DED1
3 changed files with 6 additions and 8 deletions

View File

@ -468,8 +468,7 @@ func (pts *packedTimeseries) Unpack(dst *Result, tbf *tmpBlocksFile, tr storage.
if firstErr != nil {
return firstErr
}
di := storage.GetDedupInterval()
dedupInterval := di.Milliseconds()
dedupInterval := storage.GetDedupInterval()
mergeSortBlocks(dst, sbs, dedupInterval)
return nil
}

View File

@ -187,8 +187,7 @@ func (bsw *blockStreamWriter) MustClose() {
func (bsw *blockStreamWriter) WriteExternalBlock(b *Block, ph *partHeader, rowsMerged *uint64, needDedup bool) {
atomic.AddUint64(rowsMerged, uint64(b.rowsCount()))
if needDedup {
di := GetDedupInterval()
dedupInterval := di.Milliseconds()
dedupInterval := GetDedupInterval()
b.deduplicateSamplesDuringMerge(dedupInterval)
}
headerData, timestampsData, valuesData := b.MarshalData(bsw.timestampsBlockOffset, bsw.valuesBlockOffset)

View File

@ -10,15 +10,15 @@ import (
//
// This function must be called before initializing the storage.
func SetDedupInterval(dedupInterval time.Duration) {
globalDedupInterval = dedupInterval
globalDedupInterval = dedupInterval.Milliseconds()
}
// GetDedupInterval returns the dedup interval set via SetDedupInterval.
func GetDedupInterval() time.Duration {
// GetDedupInterval returns the dedup interval in milliseconds, which has been set via SetDedupInterval.
func GetDedupInterval() int64 {
return globalDedupInterval
}
var globalDedupInterval time.Duration
var globalDedupInterval int64
// DeduplicateSamples removes samples from src* if they are closer to each other than dedupInterval in millseconds.
func DeduplicateSamples(srcTimestamps []int64, srcValues []float64, dedupInterval int64) ([]int64, []float64) {