Merge pull request #2885 from influxdb/datatype-refactor

change influxql DataType from string to int
pull/2886/head
Paul Dix 2015-06-10 21:06:08 -07:00
commit 325ca4ab4b
4 changed files with 17 additions and 17 deletions

View File

@ -12,23 +12,23 @@ import (
)
// DataType represents the primitive data types available in InfluxQL.
type DataType string
type DataType int
const (
// Unknown primitive data type.
Unknown = DataType("")
Unknown DataType = 0
// Float means the data type is a float
Float = DataType("float")
Float = 1
// Integer means the data type is a integer
Integer = DataType("integer")
Integer = 2
// Boolean means the data type is a boolean.
Boolean = DataType("boolean")
Boolean = 3
// String means the data type is a string of text.
String = DataType("string")
String = 4
// Time means the data type is a time.
Time = DataType("time")
Time = 5
// Duration means the data type is a duration of time.
Duration = DataType("duration")
Duration = 6
)
// InspectDataType returns the data type of a given value.

View File

@ -1,12 +1,12 @@
// Code generated by protoc-gen-gogo.
// source: internal/meta.proto
// Code generated by protoc-gen-go.
// source: meta.proto
// DO NOT EDIT!
/*
Package internal is a generated protocol buffer package.
It is generated from these files:
internal/meta.proto
meta.proto
It has these top-level messages:
Series
@ -16,7 +16,7 @@ It has these top-level messages:
*/
package internal
import proto "github.com/gogo/protobuf/proto"
import proto "github.com/golang/protobuf/proto"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
@ -90,7 +90,7 @@ func (m *MeasurementFields) GetFields() []*Field {
type Field struct {
ID *int32 `protobuf:"varint,1,req" json:"ID,omitempty"`
Name *string `protobuf:"bytes,2,req" json:"Name,omitempty"`
Type *string `protobuf:"bytes,3,req" json:"Type,omitempty"`
Type *int32 `protobuf:"varint,3,req" json:"Type,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
@ -112,11 +112,11 @@ func (m *Field) GetName() string {
return ""
}
func (m *Field) GetType() string {
func (m *Field) GetType() int32 {
if m != nil && m.Type != nil {
return *m.Type
}
return ""
return 0
}
func init() {

View File

@ -23,5 +23,5 @@ message MeasurementFields {
message Field {
required int32 ID = 1;
required string Name = 2;
required string Type = 3;
required int32 Type = 3;
}

View File

@ -426,7 +426,7 @@ func (m *measurementFields) MarshalBinary() ([]byte, error) {
for _, f := range m.Fields {
id := int32(f.ID)
name := f.Name
t := string(f.Type)
t := int32(f.Type)
pb.Fields = append(pb.Fields, &internal.Field{ID: &id, Name: &name, Type: &t})
}
return proto.Marshal(&pb)