diff --git a/CHANGELOG.md b/CHANGELOG.md index 21f4e54b710..917d37be283 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Bugfixes - [#2255](https://github.com/influxdb/influxdb/pull/2255): Fix panic when changing default retention policy. +- [#2261](https://github.com/influxdb/influxdb/pull/2261): Support int64 value types. ## v0.9.0-rc23 [2015-04-11] diff --git a/database.go b/database.go index 09864abf46a..1d18c87248a 100644 --- a/database.go +++ b/database.go @@ -780,17 +780,14 @@ func (f *FieldCodec) EncodeFields(values map[string]interface{}) ([]byte, error) var buf []byte switch field.Type { - case influxql.Number: - var value float64 - // Convert integers to floats. - if intval, ok := v.(int); ok { - value = float64(intval) - } else { - value = v.(float64) - } - + case influxql.Float: + value := v.(float64) buf = make([]byte, 9) binary.BigEndian.PutUint64(buf[1:9], math.Float64bits(value)) + case influxql.Integer: + value := v.(int64) + buf = make([]byte, 9) + binary.BigEndian.PutUint64(buf[1:9], uint64(value)) case influxql.Boolean: value := v.(bool) @@ -850,10 +847,13 @@ func (f *FieldCodec) DecodeByID(targetID uint8, b []byte) (interface{}, error) { var value interface{} switch field.Type { - case influxql.Number: + case influxql.Float: // Move bytes forward. value = math.Float64frombits(binary.BigEndian.Uint64(b[1:9])) b = b[9:] + case influxql.Integer: + value = int64(binary.BigEndian.Uint16(b[1:9])) + b = b[9:] case influxql.Boolean: if b[1] == 1 { value = true @@ -904,10 +904,14 @@ func (f *FieldCodec) DecodeFields(b []byte) (map[uint8]interface{}, error) { var value interface{} switch field.Type { - case influxql.Number: + case influxql.Float: value = math.Float64frombits(binary.BigEndian.Uint64(b[1:9])) // Move bytes forward. b = b[9:] + case influxql.Integer: + value = int64(binary.BigEndian.Uint64(b[1:9])) + // Move bytes forward. + b = b[9:] case influxql.Boolean: if b[1] == 1 { value = true diff --git a/influxql/ast.go b/influxql/ast.go index 3db30ac87f9..a78006771be 100644 --- a/influxql/ast.go +++ b/influxql/ast.go @@ -17,8 +17,10 @@ type DataType string const ( // Unknown primitive data type. Unknown = DataType("") - // Number means the data type is an int or float. - Number = DataType("number") + // Float means the data type is a float + Float = DataType("float") + // Integer means the data type is a integer + Integer = DataType("integer") // Boolean means the data type is a boolean. Boolean = DataType("boolean") // String means the data type is a string of text. @@ -33,9 +35,9 @@ const ( func InspectDataType(v interface{}) DataType { switch v.(type) { case float64: - return Number - case int: - return Number + return Float + case int64, int32, int: + return Integer case bool: return Boolean case string: