From 4fb635b0c973ab0e06b2837b762dad03e3b70dc1 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 6 Aug 2019 15:35:04 +0300 Subject: [PATCH] lib/storage: do not change timestamps to constant rate if values are constant or have constant delta This breaks the original timestamps, which results in issues like https://github.com/VictoriaMetrics/VictoriaMetrics/issues/120 and https://github.com/VictoriaMetrics/VictoriaMetrics/issues/141 . --- lib/storage/block.go | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/lib/storage/block.go b/lib/storage/block.go index f258f9393d..8199929a75 100644 --- a/lib/storage/block.go +++ b/lib/storage/block.go @@ -205,19 +205,6 @@ func (b *Block) MarshalData(timestampsBlockOffset, valuesBlockOffset uint64) ([] b.bh.ValuesBlockSize = uint32(len(b.valuesData)) b.values = b.values[:0] - if len(timestamps) > 1 && (b.bh.ValuesMarshalType == encoding.MarshalTypeConst || b.bh.ValuesMarshalType == encoding.MarshalTypeDeltaConst) { - // Special case - values are constant or are changed with constant rate. - // In this case we may 'cheat' by assuming timestamps are changed - // at ideal constant rate. This improves timestamps' compression rate. - minTimestamp := timestamps[0] - maxTimestamp := timestamps[len(timestamps)-1] - delta := (maxTimestamp - minTimestamp) / int64(len(timestamps)-1) - ts := minTimestamp - for i := 1; i < len(timestamps); i++ { - ts += delta - timestamps[i] = ts - } - } b.timestampsData, b.bh.TimestampsMarshalType, b.bh.MinTimestamp = encoding.MarshalTimestamps(b.timestampsData[:0], timestamps, b.bh.PrecisionBits) b.bh.TimestampsBlockOffset = timestampsBlockOffset b.bh.TimestampsBlockSize = uint32(len(b.timestampsData))