Fix index bug in float encoder

pull/10300/head
Edd Robinson 2018-09-20 18:18:22 -07:00
parent 09da18c08e
commit 91d0a8c3d2
2 changed files with 9 additions and 1 deletions

View File

@ -68,7 +68,7 @@ func FloatArrayEncodeAll(src []float64, b []byte) ([]byte, error) {
// First the current bit of the current byte is set to indicate we're // First the current bit of the current byte is set to indicate we're
// writing a delta value to the stream. // writing a delta value to the stream.
if n>>3 >= uint64(len(b)) { // Grow b — no room in current byte. for n>>3 >= uint64(len(b)) { // Keep growing b until we can fit all bits in.
b = append(b, byte(0)) b = append(b, byte(0))
} }

View File

@ -15,6 +15,13 @@ import (
"github.com/influxdata/influxdb/tsdb/engine/tsm1" "github.com/influxdata/influxdb/tsdb/engine/tsm1"
) )
var fullBlockFloat64Ones []float64
func init() {
for i := 0; i < 1000; i++ {
fullBlockFloat64Ones = append(fullBlockFloat64Ones, 1.0)
}
}
func TestFloatArrayEncodeAll(t *testing.T) { func TestFloatArrayEncodeAll(t *testing.T) {
examples := [][]float64{ examples := [][]float64{
{12, 12, 24, 13, 24, 24, 24, 24}, // From example paper. {12, 12, 24, 13, 24, 24, 24, 24}, // From example paper.
@ -28,6 +35,7 @@ func TestFloatArrayEncodeAll(t *testing.T) {
3.5635180996210295e+307}, // Failed during early development 3.5635180996210295e+307}, // Failed during early development
{6.00065e+06, 6.000656e+06, 6.000657e+06, 6.000659e+06, 6.000661e+06}, // Similar values. {6.00065e+06, 6.000656e+06, 6.000657e+06, 6.000659e+06, 6.000661e+06}, // Similar values.
twoHoursData, twoHoursData,
fullBlockFloat64Ones,
{}, {},
} }