From 3d35e6c963f55baec56de8c2c0dea31fe19c9d05 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Fri, 30 Nov 2018 08:51:46 +0000 Subject: [PATCH] Allow smaller varbit chunks on read The flag -store.fullsize-chunks should control writing only; on the reading side either size should be allowed. Signed-off-by: Bryan Boreham --- pkg/chunk/encoding/varbit.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/chunk/encoding/varbit.go b/pkg/chunk/encoding/varbit.go index 01a2ed74bb9..2b602065df6 100644 --- a/pkg/chunk/encoding/varbit.go +++ b/pkg/chunk/encoding/varbit.go @@ -287,7 +287,7 @@ func (c *varbitChunk) Slice(_, _ model.Time) Chunk { // Marshal implements chunk. func (c varbitChunk) Marshal(w io.Writer) error { - size := c.marshalLen() + size := c.Size() n, err := w.Write(c[:size]) if err != nil { return err @@ -327,9 +327,6 @@ func (MarshalConfig) RegisterFlags(f *flag.FlagSet) { // marshalLen returns the number of bytes that should be marshalled for this chunk func (c varbitChunk) marshalLen() int { - if alwaysMarshalFullsizeChunks { - return cap(c) - } bits := c.nextSampleOffset() if bits < varbitThirdSampleBitOffset { bits = varbitThirdSampleBitOffset @@ -351,6 +348,9 @@ func (c varbitChunk) Len() int { } func (c varbitChunk) Size() int { + if alwaysMarshalFullsizeChunks { + return cap(c) + } return c.marshalLen() }