From f10c300765c5cd16e8afd4c78cb3279e2b400a19 Mon Sep 17 00:00:00 2001 From: Joe LeGasse Date: Wed, 30 Mar 2016 12:48:23 -0400 Subject: [PATCH 1/2] Update to conversion tool to work in current versions After adding type-switches to the tsm1 packages, the custom implementation found in the conversion tool broke. This change uses tsm1.NewValue() instead of a custom implementation. This change also ensures that the tsm1.Value interface can only be implemented internally to allow for the optimized type-switch based encoding --- cmd/influx_tsm/b1/reader.go | 19 ++++++----------- cmd/influx_tsm/bz1/reader.go | 19 ++++++----------- cmd/influx_tsm/tsdb/codec.go | 2 -- cmd/influx_tsm/tsdb/values.go | 39 ----------------------------------- tsdb/engine/tsm1/encoding.go | 8 +++++++ 5 files changed, 20 insertions(+), 67 deletions(-) delete mode 100644 cmd/influx_tsm/tsdb/values.go diff --git a/cmd/influx_tsm/b1/reader.go b/cmd/influx_tsm/b1/reader.go index 16a46c82d6..22f17769b2 100644 --- a/cmd/influx_tsm/b1/reader.go +++ b/cmd/influx_tsm/b1/reader.go @@ -30,10 +30,9 @@ type Reader struct { cursors []*cursor currCursor int - keyBuf string - tsmValues []tsm1.Value - values []tsdb.Value - valuePos int + keyBuf string + values []tsm1.Value + valuePos int fields map[string]*tsdb.MeasurementFields codecs map[string]*tsdb.FieldCodec @@ -54,12 +53,7 @@ func NewReader(path string, stats *stats.Stats, chunkSize int) *Reader { chunkSize = DefaultChunkSize } - // known-sized slice of a known type, in a contiguous chunk - r.values = make([]tsdb.Value, chunkSize) - r.tsmValues = make([]tsm1.Value, len(r.values)) - for i := range r.values { - r.tsmValues[i] = &r.values[i] - } + r.values = make([]tsm1.Value, chunkSize) return r } @@ -173,8 +167,7 @@ OUTER: } } - r.values[r.valuePos].T = k - r.values[r.valuePos].Val = v + r.values[r.valuePos] = tsm1.NewValue(k, v) r.valuePos++ if r.valuePos >= len(r.values) { @@ -188,7 +181,7 @@ OUTER: // emitted completely for every field, in every series, before the next field is processed. // Data from Read() adheres to the requirements for writing to tsm1 shards func (r *Reader) Read() (string, []tsm1.Value, error) { - return r.keyBuf, r.tsmValues[:r.valuePos], nil + return r.keyBuf, r.values[:r.valuePos], nil } // Close closes the reader. diff --git a/cmd/influx_tsm/bz1/reader.go b/cmd/influx_tsm/bz1/reader.go index d207a1a07f..eb65c29bea 100644 --- a/cmd/influx_tsm/bz1/reader.go +++ b/cmd/influx_tsm/bz1/reader.go @@ -28,10 +28,9 @@ type Reader struct { cursors []*cursor currCursor int - keyBuf string - tsmValues []tsm1.Value - values []tsdb.Value - valuePos int + keyBuf string + values []tsm1.Value + valuePos int fields map[string]*tsdb.MeasurementFields codecs map[string]*tsdb.FieldCodec @@ -52,12 +51,7 @@ func NewReader(path string, stats *stats.Stats, chunkSize int) *Reader { chunkSize = DefaultChunkSize } - // known-sized slice of a known type, in a contiguous chunk - r.values = make([]tsdb.Value, chunkSize) - r.tsmValues = make([]tsm1.Value, len(r.values)) - for i := range r.values { - r.tsmValues[i] = &r.values[i] - } + r.values = make([]tsm1.Value, chunkSize) return r } @@ -185,8 +179,7 @@ OUTER: } } - r.values[r.valuePos].T = k - r.values[r.valuePos].Val = v + r.values[r.valuePos] = tsm1.NewValue(k, v) r.valuePos++ if r.valuePos >= len(r.values) { @@ -200,7 +193,7 @@ OUTER: // emitted completely for every field, in every series, before the next field is processed. // Data from Read() adheres to the requirements for writing to tsm1 shards func (r *Reader) Read() (string, []tsm1.Value, error) { - return r.keyBuf, r.tsmValues[:r.valuePos], nil + return r.keyBuf, r.values[:r.valuePos], nil } // Close closes the reader. diff --git a/cmd/influx_tsm/tsdb/codec.go b/cmd/influx_tsm/tsdb/codec.go index d7751d0aeb..4c3a7b6140 100644 --- a/cmd/influx_tsm/tsdb/codec.go +++ b/cmd/influx_tsm/tsdb/codec.go @@ -7,8 +7,6 @@ import ( "math" ) -const maxStringLength = 64 * 1024 - const ( fieldFloat = 1 fieldInteger = 2 diff --git a/cmd/influx_tsm/tsdb/values.go b/cmd/influx_tsm/tsdb/values.go deleted file mode 100644 index 90ec1d4407..0000000000 --- a/cmd/influx_tsm/tsdb/values.go +++ /dev/null @@ -1,39 +0,0 @@ -package tsdb - -import ( - "fmt" - "time" -) - -type Value struct { - T int64 - Val interface{} -} - -func (v *Value) Time() time.Time { - return time.Unix(0, v.T) -} - -func (v *Value) UnixNano() int64 { - return v.T -} - -func (v *Value) Value() interface{} { - return v.Val -} - -func (v *Value) String() string { - return fmt.Sprintf("%v %v", v.Time(), v.Val) -} - -func (v *Value) Size() int { - switch vv := v.Val.(type) { - case int64, float64: - return 16 - case bool: - return 9 - case string: - return 8 + len(vv) - } - return 0 -} diff --git a/tsdb/engine/tsm1/encoding.go b/tsdb/engine/tsm1/encoding.go index cffa53f16f..2a89a8f634 100644 --- a/tsdb/engine/tsm1/encoding.go +++ b/tsdb/engine/tsm1/encoding.go @@ -33,6 +33,8 @@ type Value interface { Value() interface{} Size() int String() string + + internalOnly() } func NewValue(t int64, value interface{}) Value { @@ -57,6 +59,12 @@ func (e *EmptyValue) Value() interface{} { return nil } func (e *EmptyValue) Size() int { return 0 } func (e *EmptyValue) String() string { return "" } +func (_ *EmptyValue) internalOnly() {} +func (_ *StringValue) internalOnly() {} +func (_ *IntegerValue) internalOnly() {} +func (_ *BooleanValue) internalOnly() {} +func (_ *FloatValue) internalOnly() {} + // Values represented a time ascending sorted collection of Value types. // the underlying type should be the same across all values, but the interface // makes the code cleaner. From 59b9768655425fcc4a679363f3dc37d4eadab651 Mon Sep 17 00:00:00 2001 From: Joe LeGasse Date: Wed, 30 Mar 2016 13:34:48 -0400 Subject: [PATCH 2/2] updated CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b41c14769f..56ba6d8a83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ - [#5252](https://github.com/influxdata/influxdb/issues/5252): Release tarballs contain specific attributes on '.' - [#5554](https://github.com/influxdata/influxdb/issues/5554): Can't run in alpine linux - [#6094](https://github.com/influxdata/influxdb/issues/6094): Ensure CREATE RETENTION POLICY and CREATE CONTINUOUS QUERY are idempotent in the correct way. +- [#6092](https://github.com/influxdata/influxdb/issues/6092): Upgrading directly from 0.9.6.1 to 0.11.0 fails ## v0.11.0 [2016-03-22]