From e7ac9c6863baaed1455b2113eaabe5b200316fb6 Mon Sep 17 00:00:00 2001 From: beorn7 Date: Thu, 17 Mar 2016 14:37:24 +0100 Subject: [PATCH] Improvments based on review - Moved returns into the default section of switch statement that can only happen then. - Fix typo. --- storage/local/chunk.go | 2 +- storage/local/delta.go | 4 ++-- storage/local/doubledelta.go | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/storage/local/chunk.go b/storage/local/chunk.go index 2e9fcf4cf..55e39ecbd 100644 --- a/storage/local/chunk.go +++ b/storage/local/chunk.go @@ -285,7 +285,7 @@ type chunkIterator interface { // of the find... methods). It returns ZeroSamplePair before any of // those methods were called. value() model.SamplePair - // Returns the last error encountered. In general, an error signal data + // Returns the last error encountered. In general, an error signals data // corruption in the chunk and requires quarantining. err() error } diff --git a/storage/local/delta.go b/storage/local/delta.go index a74e0806a..58e028159 100644 --- a/storage/local/delta.go +++ b/storage/local/delta.go @@ -328,8 +328,8 @@ func (acc *deltaEncodedIndexAccessor) timestampAtIndex(idx int) model.Time { return model.Time(binary.LittleEndian.Uint64(acc.c[offset:])) default: acc.lastErr = fmt.Errorf("invalid number of bytes for time delta: %d", acc.tBytes) + return model.Earliest } - return model.Earliest } func (acc *deltaEncodedIndexAccessor) sampleValueAtIndex(idx int) model.SampleValue { @@ -358,7 +358,7 @@ func (acc *deltaEncodedIndexAccessor) sampleValueAtIndex(idx int) model.SampleVa return model.SampleValue(math.Float64frombits(binary.LittleEndian.Uint64(acc.c[offset:]))) default: acc.lastErr = fmt.Errorf("invalid number of bytes for floating point delta: %d", acc.vBytes) + return 0 } } - return 0 } diff --git a/storage/local/doubledelta.go b/storage/local/doubledelta.go index a53d41f6b..60e5667ad 100644 --- a/storage/local/doubledelta.go +++ b/storage/local/doubledelta.go @@ -452,8 +452,8 @@ func (acc *doubleDeltaEncodedIndexAccessor) timestampAtIndex(idx int) model.Time return model.Time(binary.LittleEndian.Uint64(acc.c[offset:])) default: acc.lastErr = fmt.Errorf("invalid number of bytes for time delta: %d", acc.tBytes) + return model.Earliest } - return model.Earliest } func (acc *doubleDeltaEncodedIndexAccessor) sampleValueAtIndex(idx int) model.SampleValue { @@ -491,6 +491,7 @@ func (acc *doubleDeltaEncodedIndexAccessor) sampleValueAtIndex(idx int) model.Sa // No d8 for ints. default: acc.lastErr = fmt.Errorf("invalid number of bytes for integer delta: %d", acc.vBytes) + return 0 } } else { switch acc.vBytes { @@ -503,7 +504,7 @@ func (acc *doubleDeltaEncodedIndexAccessor) sampleValueAtIndex(idx int) model.Sa return model.SampleValue(math.Float64frombits(binary.LittleEndian.Uint64(acc.c[offset:]))) default: acc.lastErr = fmt.Errorf("invalid number of bytes for floating point delta: %d", acc.vBytes) + return 0 } } - return 0 }