pvt #59136004. get rid of ints and use int64 instead.
parent
e4b60654a7
commit
cac571d4fb
|
@ -31,9 +31,9 @@ func not(op BooleanOperation) BooleanOperation {
|
|||
|
||||
func commonType(leftType, rightType protocol.FieldDefinition_Type) (protocol.FieldDefinition_Type, error) {
|
||||
switch leftType {
|
||||
case protocol.FieldDefinition_INT64, protocol.FieldDefinition_INT32:
|
||||
case protocol.FieldDefinition_INT64:
|
||||
switch rightType {
|
||||
case protocol.FieldDefinition_INT32, protocol.FieldDefinition_INT64:
|
||||
case protocol.FieldDefinition_INT64:
|
||||
return protocol.FieldDefinition_INT64, nil
|
||||
case protocol.FieldDefinition_DOUBLE:
|
||||
return protocol.FieldDefinition_DOUBLE, nil
|
||||
|
@ -41,7 +41,7 @@ func commonType(leftType, rightType protocol.FieldDefinition_Type) (protocol.Fie
|
|||
|
||||
case protocol.FieldDefinition_DOUBLE:
|
||||
switch rightType {
|
||||
case protocol.FieldDefinition_INT64, protocol.FieldDefinition_INT32, protocol.FieldDefinition_DOUBLE:
|
||||
case protocol.FieldDefinition_INT64, protocol.FieldDefinition_DOUBLE:
|
||||
return protocol.FieldDefinition_DOUBLE, nil
|
||||
}
|
||||
|
||||
|
@ -65,9 +65,6 @@ func coerceValue(value *protocol.FieldValue, fromType, toType protocol.FieldDefi
|
|||
switch fromType {
|
||||
case protocol.FieldDefinition_INT64:
|
||||
return value
|
||||
case protocol.FieldDefinition_INT32:
|
||||
temp := int64(*value.IntValue)
|
||||
return &protocol.FieldValue{Int64Value: &temp}
|
||||
}
|
||||
|
||||
case protocol.FieldDefinition_DOUBLE:
|
||||
|
@ -77,9 +74,6 @@ func coerceValue(value *protocol.FieldValue, fromType, toType protocol.FieldDefi
|
|||
case protocol.FieldDefinition_INT64:
|
||||
temp := float64(*value.Int64Value)
|
||||
return &protocol.FieldValue{DoubleValue: &temp}
|
||||
case protocol.FieldDefinition_INT32:
|
||||
temp := float64(*value.IntValue)
|
||||
return &protocol.FieldValue{DoubleValue: &temp}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ func (self *DatastoreSuite) TestCanWriteAndRetrievePoints(c *C) {
|
|||
{
|
||||
"values": [
|
||||
{
|
||||
"int_value": 3
|
||||
"int64_value": 3
|
||||
}
|
||||
],
|
||||
"sequence_number": 1
|
||||
|
@ -80,7 +80,7 @@ func (self *DatastoreSuite) TestCanWriteAndRetrievePoints(c *C) {
|
|||
{
|
||||
"values": [
|
||||
{
|
||||
"int_value": 2
|
||||
"int64_value": 2
|
||||
}
|
||||
],
|
||||
"sequence_number": 2
|
||||
|
@ -89,7 +89,7 @@ func (self *DatastoreSuite) TestCanWriteAndRetrievePoints(c *C) {
|
|||
"name": "foo",
|
||||
"fields": [
|
||||
{
|
||||
"type": "INT32",
|
||||
"type": "INT64",
|
||||
"name": "value"
|
||||
}
|
||||
]
|
||||
|
@ -123,8 +123,8 @@ func (self *DatastoreSuite) TestCanWriteAndRetrievePoints(c *C) {
|
|||
c.Assert(*resultSeries.Points[1].SequenceNumber, Equals, uint32(1))
|
||||
c.Assert(*resultSeries.Points[0].Timestamp, Equals, pointTime)
|
||||
c.Assert(*resultSeries.Points[1].Timestamp, Equals, pointTime)
|
||||
c.Assert(*resultSeries.Points[0].Values[0].IntValue, Equals, int32(2))
|
||||
c.Assert(*resultSeries.Points[1].Values[0].IntValue, Equals, int32(3))
|
||||
c.Assert(*resultSeries.Points[0].Values[0].Int64Value, Equals, int64(2))
|
||||
c.Assert(*resultSeries.Points[1].Values[0].Int64Value, Equals, int64(3))
|
||||
c.Assert(resultSeries, Not(DeepEquals), series)
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ func (self *DatastoreSuite) TestCanPersistDataAndWriteNewData(c *C) {
|
|||
{
|
||||
"values": [
|
||||
{
|
||||
"int_value": 3
|
||||
"int64_value": 3
|
||||
}
|
||||
],
|
||||
"sequence_number": 1
|
||||
|
@ -146,7 +146,7 @@ func (self *DatastoreSuite) TestCanPersistDataAndWriteNewData(c *C) {
|
|||
"name": "foo",
|
||||
"fields": [
|
||||
{
|
||||
"type": "INT32",
|
||||
"type": "INT64",
|
||||
"name": "value"
|
||||
}
|
||||
]
|
||||
|
@ -176,9 +176,9 @@ func (self *DatastoreSuite) TestCanWriteDataWithDifferentTimesAndSeries(c *C) {
|
|||
err := db.WriteSeriesData("db1", eventsSeries)
|
||||
c.Assert(err, IsNil)
|
||||
mock = `{
|
||||
"points":[{"values":[{"int_value":4}],"sequence_number":3}],
|
||||
"points":[{"values":[{"int64_value":4}],"sequence_number":3}],
|
||||
"name": "foo",
|
||||
"fields": [{"type": "INT32", "name": "val"}]}`
|
||||
"fields": [{"type": "INT64", "name": "val"}]}`
|
||||
fooSeries := stringToSeries(mock, secondAgo, c)
|
||||
err = db.WriteSeriesData("db1", fooSeries)
|
||||
c.Assert(err, IsNil)
|
||||
|
@ -245,17 +245,17 @@ func (self *DatastoreSuite) TestCanQueryBasedOnTime(c *C) {
|
|||
minutesAgo := time.Now().Add(-10 * time.Minute).Unix()
|
||||
now := time.Now().Unix()
|
||||
mock := `{
|
||||
"points":[{"values":[{"int_value":4}],"sequence_number":3}],
|
||||
"points":[{"values":[{"int64_value":4}],"sequence_number":3}],
|
||||
"name": "foo",
|
||||
"fields": [{"type": "INT32", "name": "val"}]}`
|
||||
"fields": [{"type": "INT64", "name": "val"}]}`
|
||||
oldData := stringToSeries(mock, minutesAgo, c)
|
||||
err := db.WriteSeriesData("db1", oldData)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
mock = `{
|
||||
"points":[{"values":[{"int_value":3}],"sequence_number":3}],
|
||||
"points":[{"values":[{"int64_value":3}],"sequence_number":3}],
|
||||
"name": "foo",
|
||||
"fields": [{"type": "INT32", "name": "val"}]}`
|
||||
"fields": [{"type": "INT64", "name": "val"}]}`
|
||||
newData := stringToSeries(mock, now, c)
|
||||
err = db.WriteSeriesData("db1", newData)
|
||||
c.Assert(err, IsNil)
|
||||
|
@ -272,8 +272,8 @@ func (self *DatastoreSuite) TestCanQueryBasedOnTime(c *C) {
|
|||
c.Assert(*results.Points[1].SequenceNumber, Equals, uint32(3))
|
||||
c.Assert(*results.Points[0].Timestamp, Equals, now)
|
||||
c.Assert(*results.Points[1].Timestamp, Equals, minutesAgo)
|
||||
c.Assert(*results.Points[0].Values[0].IntValue, Equals, int32(3))
|
||||
c.Assert(*results.Points[1].Values[0].IntValue, Equals, int32(4))
|
||||
c.Assert(*results.Points[0].Values[0].Int64Value, Equals, int64(3))
|
||||
c.Assert(*results.Points[1].Values[0].Int64Value, Equals, int64(4))
|
||||
}
|
||||
|
||||
func (self *DatastoreSuite) TestCanDoWhereQueryEquals(c *C) {
|
||||
|
@ -306,10 +306,10 @@ func (self *DatastoreSuite) TestCanDoSelectStarQueries(c *C) {
|
|||
|
||||
mock := `{
|
||||
"points":[
|
||||
{"values":[{"int_value":3},{"string_value":"paul"}],"sequence_number":2},
|
||||
{"values":[{"int_value":1},{"string_value":"todd"}],"sequence_number":1}],
|
||||
{"values":[{"int64_value":3},{"string_value":"paul"}],"sequence_number":2},
|
||||
{"values":[{"int64_value":1},{"string_value":"todd"}],"sequence_number":1}],
|
||||
"name":"user_things",
|
||||
"fields":[{"type":"INT32","name":"count"},{"type":"STRING","name":"name"}]
|
||||
"fields":[{"type":"INT64","name":"count"},{"type":"STRING","name":"name"}]
|
||||
}`
|
||||
series := stringToSeries(mock, time.Now().Unix(), c)
|
||||
err := db.WriteSeriesData("foobar", series)
|
||||
|
@ -325,10 +325,10 @@ func (self *DatastoreSuite) TestCanDoCountStarQueries(c *C) {
|
|||
|
||||
mock := `{
|
||||
"points":[
|
||||
{"values":[{"int_value":3},{"string_value":"paul"}],"sequence_number":2},
|
||||
{"values":[{"int_value":1},{"string_value":"todd"}],"sequence_number":1}],
|
||||
{"values":[{"int64_value":3},{"string_value":"paul"}],"sequence_number":2},
|
||||
{"values":[{"int64_value":1},{"string_value":"todd"}],"sequence_number":1}],
|
||||
"name":"user_things",
|
||||
"fields":[{"type":"INT32","name":"count"},{"type":"STRING","name":"name"}]
|
||||
"fields":[{"type":"INT64","name":"count"},{"type":"STRING","name":"name"}]
|
||||
}`
|
||||
series := stringToSeries(mock, time.Now().Unix(), c)
|
||||
err := db.WriteSeriesData("foobar", series)
|
||||
|
@ -337,9 +337,9 @@ func (self *DatastoreSuite) TestCanDoCountStarQueries(c *C) {
|
|||
c.Assert(len(results.Points), Equals, 2)
|
||||
c.Assert(len(results.Fields), Equals, 1)
|
||||
c.Assert(*results.Points[0].SequenceNumber, Equals, uint32(2))
|
||||
c.Assert(*results.Points[0].Values[0].IntValue, Equals, int32(3))
|
||||
c.Assert(*results.Points[0].Values[0].Int64Value, Equals, int64(3))
|
||||
c.Assert(*results.Points[1].SequenceNumber, Equals, uint32(1))
|
||||
c.Assert(*results.Points[1].Values[0].IntValue, Equals, int32(1))
|
||||
c.Assert(*results.Points[1].Values[0].Int64Value, Equals, int64(1))
|
||||
}
|
||||
|
||||
func (self *DatastoreSuite) TestLimitsPointsReturnedBasedOnQuery(c *C) {
|
||||
|
@ -349,10 +349,10 @@ func (self *DatastoreSuite) TestLimitsPointsReturnedBasedOnQuery(c *C) {
|
|||
|
||||
mock := `{
|
||||
"points":[
|
||||
{"values":[{"int_value":3},{"string_value":"paul"}],"sequence_number":2},
|
||||
{"values":[{"int_value":1},{"string_value":"todd"}],"sequence_number":1}],
|
||||
{"values":[{"int64_value":3},{"string_value":"paul"}],"sequence_number":2},
|
||||
{"values":[{"int64_value":1},{"string_value":"todd"}],"sequence_number":1}],
|
||||
"name":"user_things",
|
||||
"fields":[{"type":"INT32","name":"count"},{"type":"STRING","name":"name"}]
|
||||
"fields":[{"type":"INT64","name":"count"},{"type":"STRING","name":"name"}]
|
||||
}`
|
||||
series := stringToSeries(mock, time.Now().Unix(), c)
|
||||
err := db.WriteSeriesData("foobar", series)
|
||||
|
@ -407,10 +407,10 @@ func (self *DatastoreSuite) TestCanDeleteARangeOfData(c *C) {
|
|||
minutesAgo := time.Now().Add(-5 * time.Minute).Unix()
|
||||
mock := `{
|
||||
"points":[
|
||||
{"values":[{"int_value":3},{"string_value":"paul"}],"sequence_number":2},
|
||||
{"values":[{"int_value":1},{"string_value":"todd"}],"sequence_number":1}],
|
||||
{"values":[{"int64_value":3},{"string_value":"paul"}],"sequence_number":2},
|
||||
{"values":[{"int64_value":1},{"string_value":"todd"}],"sequence_number":1}],
|
||||
"name":"user_things",
|
||||
"fields":[{"type":"INT32","name":"count"},{"type":"STRING","name":"name"}]
|
||||
"fields":[{"type":"INT64","name":"count"},{"type":"STRING","name":"name"}]
|
||||
}`
|
||||
series := stringToSeries(mock, minutesAgo, c)
|
||||
err := db.WriteSeriesData("foobar", series)
|
||||
|
@ -420,9 +420,9 @@ func (self *DatastoreSuite) TestCanDeleteARangeOfData(c *C) {
|
|||
|
||||
mock = `{
|
||||
"points":[
|
||||
{"values":[{"int_value":3},{"string_value":"john"}],"sequence_number":1}],
|
||||
{"values":[{"int64_value":3},{"string_value":"john"}],"sequence_number":1}],
|
||||
"name":"user_things",
|
||||
"fields":[{"type":"INT32","name":"count"},{"type":"STRING","name":"name"}]
|
||||
"fields":[{"type":"INT64","name":"count"},{"type":"STRING","name":"name"}]
|
||||
}`
|
||||
series = stringToSeries(mock, time.Now().Unix(), c)
|
||||
err = db.WriteSeriesData("foobar", series)
|
||||
|
@ -444,10 +444,10 @@ func (self *DatastoreSuite) TestCanDeleteRangeOfDataFromRegex(c *C) {
|
|||
|
||||
mock := `{
|
||||
"points":[
|
||||
{"values":[{"int_value":3},{"string_value":"paul"}],"sequence_number":2},
|
||||
{"values":[{"int_value":1},{"string_value":"todd"}],"sequence_number":1}],
|
||||
{"values":[{"int64_value":3},{"string_value":"paul"}],"sequence_number":2},
|
||||
{"values":[{"int64_value":1},{"string_value":"todd"}],"sequence_number":1}],
|
||||
"name":"events",
|
||||
"fields":[{"type":"INT32","name":"count"},{"type":"STRING","name":"name"}]
|
||||
"fields":[{"type":"INT64","name":"count"},{"type":"STRING","name":"name"}]
|
||||
}`
|
||||
series := stringToSeries(mock, time.Now().Unix(), c)
|
||||
err := db.WriteSeriesData("foobar", series)
|
||||
|
@ -493,10 +493,10 @@ func (self *DatastoreSuite) TestCanSelectFromARegex(c *C) {
|
|||
|
||||
mock := `{
|
||||
"points":[
|
||||
{"values":[{"int_value":3},{"string_value":"paul"}],"sequence_number":2},
|
||||
{"values":[{"int_value":1},{"string_value":"todd"}],"sequence_number":1}],
|
||||
{"values":[{"int64_value":3},{"string_value":"paul"}],"sequence_number":2},
|
||||
{"values":[{"int64_value":1},{"string_value":"todd"}],"sequence_number":1}],
|
||||
"name":"user_things",
|
||||
"fields":[{"type":"INT32","name":"count"},{"type":"STRING","name":"name"}]
|
||||
"fields":[{"type":"INT64","name":"count"},{"type":"STRING","name":"name"}]
|
||||
}`
|
||||
series := stringToSeries(mock, time.Now().Unix(), c)
|
||||
err := db.WriteSeriesData("foobar", series)
|
||||
|
|
|
@ -18,14 +18,14 @@ func (self *FilteringSuite) TestEqualityFiltering(c *C) {
|
|||
[
|
||||
{
|
||||
"points": [
|
||||
{"values": [{"int_value": 100},{"int_value": 5 }], "timestamp": 1381346631, "sequence_number": 1},
|
||||
{"values": [{"int_value": 100},{"int_value": 6 }], "timestamp": 1381346631, "sequence_number": 1},
|
||||
{"values": [{"int_value": 90 },{"int_value": 15}], "timestamp": 1381346632, "sequence_number": 1}
|
||||
{"values": [{"int64_value": 100},{"int64_value": 5 }], "timestamp": 1381346631, "sequence_number": 1},
|
||||
{"values": [{"int64_value": 100},{"int64_value": 6 }], "timestamp": 1381346631, "sequence_number": 1},
|
||||
{"values": [{"int64_value": 90 },{"int64_value": 15}], "timestamp": 1381346632, "sequence_number": 1}
|
||||
],
|
||||
"name": "t",
|
||||
"fields": [
|
||||
{"type": "INT32", "name": "column_one"},
|
||||
{"type": "INT32", "name": "column_two"}
|
||||
{"type": "INT64", "name": "column_one"},
|
||||
{"type": "INT64", "name": "column_two"}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -35,8 +35,8 @@ func (self *FilteringSuite) TestEqualityFiltering(c *C) {
|
|||
c.Assert(err, IsNil)
|
||||
c.Assert(result, NotNil)
|
||||
c.Assert(result.Points, HasLen, 1)
|
||||
c.Assert(*result.Points[0].Values[0].IntValue, Equals, int32(100))
|
||||
c.Assert(*result.Points[0].Values[1].IntValue, Equals, int32(5))
|
||||
c.Assert(*result.Points[0].Values[0].Int64Value, Equals, int64(100))
|
||||
c.Assert(*result.Points[0].Values[1].Int64Value, Equals, int64(5))
|
||||
}
|
||||
|
||||
func (self *FilteringSuite) TestRegexFiltering(c *C) {
|
||||
|
@ -73,14 +73,14 @@ func (self *FilteringSuite) TestInequalityFiltering(c *C) {
|
|||
[
|
||||
{
|
||||
"points": [
|
||||
{"values": [{"int_value": 100},{"int_value": 7 }], "timestamp": 1381346631, "sequence_number": 1},
|
||||
{"values": [{"int_value": 100},{"int_value": 6 }], "timestamp": 1381346631, "sequence_number": 1},
|
||||
{"values": [{"int_value": 90 },{"int_value": 15}], "timestamp": 1381346632, "sequence_number": 1}
|
||||
{"values": [{"int64_value": 100},{"int64_value": 7 }], "timestamp": 1381346631, "sequence_number": 1},
|
||||
{"values": [{"int64_value": 100},{"int64_value": 6 }], "timestamp": 1381346631, "sequence_number": 1},
|
||||
{"values": [{"int64_value": 90 },{"int64_value": 15}], "timestamp": 1381346632, "sequence_number": 1}
|
||||
],
|
||||
"name": "t",
|
||||
"fields": [
|
||||
{"type": "INT32", "name": "column_one"},
|
||||
{"type": "INT32", "name": "column_two"}
|
||||
{"type": "INT64", "name": "column_one"},
|
||||
{"type": "INT64", "name": "column_two"}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -90,6 +90,6 @@ func (self *FilteringSuite) TestInequalityFiltering(c *C) {
|
|||
c.Assert(err, IsNil)
|
||||
c.Assert(result, NotNil)
|
||||
c.Assert(result.Points, HasLen, 1)
|
||||
c.Assert(*result.Points[0].Values[0].IntValue, Equals, int32(100))
|
||||
c.Assert(*result.Points[0].Values[1].IntValue, Equals, int32(7))
|
||||
c.Assert(*result.Points[0].Values[0].Int64Value, Equals, int64(100))
|
||||
c.Assert(*result.Points[0].Values[1].Int64Value, Equals, int64(7))
|
||||
}
|
||||
|
|
|
@ -423,11 +423,9 @@ func (self *LevelDbDatastore) getFieldsForSeries(db, series string, columns []st
|
|||
if *f.Definition.Type == protocol.FieldDefinition_BOOL {
|
||||
bestField = f
|
||||
break
|
||||
} else if *f.Definition.Type == protocol.FieldDefinition_INT32 {
|
||||
} else if *f.Definition.Type == protocol.FieldDefinition_INT64 {
|
||||
bestField = f
|
||||
} else if *f.Definition.Type == protocol.FieldDefinition_INT64 && *bestField.Definition.Type != protocol.FieldDefinition_INT32 {
|
||||
bestField = f
|
||||
} else if *f.Definition.Type == protocol.FieldDefinition_DOUBLE && *bestField.Definition.Type != protocol.FieldDefinition_INT32 && *bestField.Definition.Type != protocol.FieldDefinition_INT64 {
|
||||
} else if *f.Definition.Type == protocol.FieldDefinition_DOUBLE && *bestField.Definition.Type != protocol.FieldDefinition_INT64 {
|
||||
bestField = f
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,13 +61,13 @@ func (self *CountAggregator) ColumnName() string {
|
|||
}
|
||||
|
||||
func (self *CountAggregator) ColumnType() protocol.FieldDefinition_Type {
|
||||
return protocol.FieldDefinition_INT32
|
||||
return protocol.FieldDefinition_INT64
|
||||
}
|
||||
|
||||
func (self *CountAggregator) GetValue(series string, group interface{}) []*protocol.FieldValue {
|
||||
returnValues := []*protocol.FieldValue{}
|
||||
value := self.counts[series][group]
|
||||
returnValues = append(returnValues, &protocol.FieldValue{IntValue: &value})
|
||||
value := int64(self.counts[series][group])
|
||||
returnValues = append(returnValues, &protocol.FieldValue{Int64Value: &value})
|
||||
|
||||
return returnValues
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ func (self *TimestampAggregator) ColumnName() string {
|
|||
}
|
||||
|
||||
func (self *TimestampAggregator) ColumnType() protocol.FieldDefinition_Type {
|
||||
return protocol.FieldDefinition_INT32
|
||||
return protocol.FieldDefinition_INT64
|
||||
}
|
||||
|
||||
func (self *TimestampAggregator) GetValue(series string, group interface{}) []*protocol.FieldValue {
|
||||
|
@ -162,8 +162,6 @@ func (self *MeanAggregator) AggregatePoint(series string, group interface{}, p *
|
|||
switch self.fieldType {
|
||||
case protocol.FieldDefinition_INT64:
|
||||
value = float64(*p.Values[self.fieldIndex].Int64Value)
|
||||
case protocol.FieldDefinition_INT32:
|
||||
value = float64(*p.Values[self.fieldIndex].IntValue)
|
||||
case protocol.FieldDefinition_DOUBLE:
|
||||
value = *p.Values[self.fieldIndex].DoubleValue
|
||||
}
|
||||
|
@ -198,8 +196,7 @@ func (self *MeanAggregator) InitializeFieldsMetadata(series *protocol.Series) er
|
|||
self.fieldType = *field.Type
|
||||
|
||||
switch self.fieldType {
|
||||
case protocol.FieldDefinition_INT32,
|
||||
protocol.FieldDefinition_INT64,
|
||||
case protocol.FieldDefinition_INT64,
|
||||
protocol.FieldDefinition_DOUBLE:
|
||||
// that's fine
|
||||
default:
|
||||
|
@ -233,39 +230,25 @@ type MedianAggregator struct {
|
|||
fieldName string
|
||||
fieldIndex int
|
||||
fieldType protocol.FieldDefinition_Type
|
||||
int_values map[string]map[interface{}][]int
|
||||
int_values map[string]map[interface{}][]int64
|
||||
float_values map[string]map[interface{}][]float64
|
||||
}
|
||||
|
||||
func (self *MedianAggregator) AggregatePoint(series string, group interface{}, p *protocol.Point) error {
|
||||
switch self.fieldType {
|
||||
case protocol.FieldDefinition_INT32:
|
||||
int_values := self.int_values[series]
|
||||
if int_values == nil {
|
||||
int_values = make(map[interface{}][]int)
|
||||
self.int_values[series] = int_values
|
||||
}
|
||||
|
||||
points := int_values[group]
|
||||
if points == nil {
|
||||
points = make([]int, 0)
|
||||
}
|
||||
|
||||
points = append(points, int(*p.Values[self.fieldIndex].IntValue))
|
||||
int_values[group] = points
|
||||
case protocol.FieldDefinition_INT64:
|
||||
int_values := self.int_values[series]
|
||||
if int_values == nil {
|
||||
int_values = make(map[interface{}][]int)
|
||||
int_values = make(map[interface{}][]int64)
|
||||
self.int_values[series] = int_values
|
||||
}
|
||||
|
||||
points := int_values[group]
|
||||
if points == nil {
|
||||
points = make([]int, 0)
|
||||
points = []int64{}
|
||||
}
|
||||
|
||||
points = append(points, int(*p.Values[self.fieldIndex].Int64Value))
|
||||
points = append(points, *p.Values[self.fieldIndex].Int64Value)
|
||||
int_values[group] = points
|
||||
case protocol.FieldDefinition_DOUBLE:
|
||||
float_values := self.float_values[series]
|
||||
|
@ -300,14 +283,8 @@ func (self *MedianAggregator) GetValue(series string, group interface{}) []*prot
|
|||
returnValues := []*protocol.FieldValue{}
|
||||
|
||||
switch self.fieldType {
|
||||
case protocol.FieldDefinition_INT32:
|
||||
sort.Ints(self.int_values[series][group])
|
||||
length := len(self.int_values[series][group])
|
||||
index := int(math.Floor(float64(length)*0.5+0.5)) - 1
|
||||
point := int32(self.int_values[series][group][index])
|
||||
returnValues = append(returnValues, &protocol.FieldValue{IntValue: &point})
|
||||
case protocol.FieldDefinition_INT64:
|
||||
sort.Ints(self.int_values[series][group])
|
||||
SortInt64(self.int_values[series][group])
|
||||
length := len(self.int_values[series][group])
|
||||
index := int(math.Floor(float64(length)*0.5+0.5)) - 1
|
||||
point := int64(self.int_values[series][group][index])
|
||||
|
@ -329,8 +306,7 @@ func (self *MedianAggregator) InitializeFieldsMetadata(series *protocol.Series)
|
|||
self.fieldType = *field.Type
|
||||
|
||||
switch self.fieldType {
|
||||
case protocol.FieldDefinition_INT32,
|
||||
protocol.FieldDefinition_INT64,
|
||||
case protocol.FieldDefinition_INT64,
|
||||
protocol.FieldDefinition_DOUBLE:
|
||||
// that's fine
|
||||
default:
|
||||
|
@ -351,7 +327,7 @@ func NewMedianAggregator(_ *parser.Query, value *parser.Value) (Aggregator, erro
|
|||
|
||||
return &MedianAggregator{
|
||||
fieldName: value.Elems[0].Name,
|
||||
int_values: make(map[string]map[interface{}][]int),
|
||||
int_values: make(map[string]map[interface{}][]int64),
|
||||
float_values: make(map[string]map[interface{}][]float64),
|
||||
}, nil
|
||||
}
|
||||
|
@ -365,39 +341,25 @@ type PercentileAggregator struct {
|
|||
fieldIndex int
|
||||
fieldType protocol.FieldDefinition_Type
|
||||
percentile float64
|
||||
int_values map[string]map[interface{}][]int
|
||||
int_values map[string]map[interface{}][]int64
|
||||
float_values map[string]map[interface{}][]float64
|
||||
}
|
||||
|
||||
func (self *PercentileAggregator) AggregatePoint(series string, group interface{}, p *protocol.Point) error {
|
||||
switch self.fieldType {
|
||||
case protocol.FieldDefinition_INT32:
|
||||
int_values := self.int_values[series]
|
||||
if int_values == nil {
|
||||
int_values = make(map[interface{}][]int)
|
||||
self.int_values[series] = int_values
|
||||
}
|
||||
|
||||
points := int_values[group]
|
||||
if points == nil {
|
||||
points = make([]int, 0)
|
||||
}
|
||||
|
||||
points = append(points, int(*p.Values[self.fieldIndex].IntValue))
|
||||
int_values[group] = points
|
||||
case protocol.FieldDefinition_INT64:
|
||||
int_values := self.int_values[series]
|
||||
if int_values == nil {
|
||||
int_values = make(map[interface{}][]int)
|
||||
int_values = make(map[interface{}][]int64)
|
||||
self.int_values[series] = int_values
|
||||
}
|
||||
|
||||
points := int_values[group]
|
||||
if points == nil {
|
||||
points = make([]int, 0)
|
||||
points = []int64{}
|
||||
}
|
||||
|
||||
points = append(points, int(*p.Values[self.fieldIndex].Int64Value))
|
||||
points = append(points, *p.Values[self.fieldIndex].Int64Value)
|
||||
int_values[group] = points
|
||||
case protocol.FieldDefinition_DOUBLE:
|
||||
float_values := self.float_values[series]
|
||||
|
@ -432,14 +394,8 @@ func (self *PercentileAggregator) GetValue(series string, group interface{}) []*
|
|||
returnValues := []*protocol.FieldValue{}
|
||||
|
||||
switch self.fieldType {
|
||||
case protocol.FieldDefinition_INT32:
|
||||
sort.Ints(self.int_values[series][group])
|
||||
length := len(self.int_values[series][group])
|
||||
index := int(math.Floor(float64(length)*self.percentile/100.0+0.5)) - 1
|
||||
point := int32(self.int_values[series][group][index])
|
||||
returnValues = append(returnValues, &protocol.FieldValue{IntValue: &point})
|
||||
case protocol.FieldDefinition_INT64:
|
||||
sort.Ints(self.int_values[series][group])
|
||||
SortInt64(self.int_values[series][group])
|
||||
length := len(self.int_values[series][group])
|
||||
index := int(math.Floor(float64(length)*self.percentile/100.0+0.5)) - 1
|
||||
point := int64(self.int_values[series][group][index])
|
||||
|
@ -462,8 +418,7 @@ func (self *PercentileAggregator) InitializeFieldsMetadata(series *protocol.Seri
|
|||
self.fieldType = *field.Type
|
||||
|
||||
switch self.fieldType {
|
||||
case protocol.FieldDefinition_INT32,
|
||||
protocol.FieldDefinition_INT64,
|
||||
case protocol.FieldDefinition_INT64,
|
||||
protocol.FieldDefinition_DOUBLE:
|
||||
// that's fine
|
||||
default:
|
||||
|
@ -490,7 +445,7 @@ func NewPercentileAggregator(_ *parser.Query, value *parser.Value) (Aggregator,
|
|||
return &PercentileAggregator{
|
||||
fieldName: value.Elems[0].Name,
|
||||
percentile: percentile,
|
||||
int_values: make(map[string]map[interface{}][]int),
|
||||
int_values: make(map[string]map[interface{}][]int64),
|
||||
float_values: make(map[string]map[interface{}][]float64),
|
||||
}, nil
|
||||
}
|
||||
|
@ -520,8 +475,6 @@ func (self *ModeAggregator) AggregatePoint(series string, group interface{}, p *
|
|||
|
||||
var value interface{}
|
||||
switch self.fieldType {
|
||||
case protocol.FieldDefinition_INT32:
|
||||
value = *p.Values[self.fieldIndex].IntValue
|
||||
case protocol.FieldDefinition_INT64:
|
||||
value = *p.Values[self.fieldIndex].Int64Value
|
||||
case protocol.FieldDefinition_DOUBLE:
|
||||
|
@ -562,9 +515,6 @@ func (self *ModeAggregator) GetValue(series string, group interface{}) []*protoc
|
|||
|
||||
for _, value := range values {
|
||||
switch self.fieldType {
|
||||
case protocol.FieldDefinition_INT32:
|
||||
v := value.(int32)
|
||||
returnValues = append(returnValues, &protocol.FieldValue{IntValue: &v})
|
||||
case protocol.FieldDefinition_INT64:
|
||||
v := value.(int64)
|
||||
returnValues = append(returnValues, &protocol.FieldValue{Int64Value: &v})
|
||||
|
@ -584,8 +534,7 @@ func (self *ModeAggregator) InitializeFieldsMetadata(series *protocol.Series) er
|
|||
self.fieldType = *field.Type
|
||||
|
||||
switch self.fieldType {
|
||||
case protocol.FieldDefinition_INT32,
|
||||
protocol.FieldDefinition_INT64,
|
||||
case protocol.FieldDefinition_INT64,
|
||||
protocol.FieldDefinition_DOUBLE:
|
||||
// that's fine
|
||||
default:
|
||||
|
@ -635,8 +584,6 @@ func (self *DistinctAggregator) AggregatePoint(series string, group interface{},
|
|||
|
||||
var value interface{}
|
||||
switch self.fieldType {
|
||||
case protocol.FieldDefinition_INT32:
|
||||
value = *p.Values[self.fieldIndex].IntValue
|
||||
case protocol.FieldDefinition_INT64:
|
||||
value = *p.Values[self.fieldIndex].Int64Value
|
||||
case protocol.FieldDefinition_DOUBLE:
|
||||
|
@ -664,9 +611,6 @@ func (self *DistinctAggregator) GetValue(series string, group interface{}) []*pr
|
|||
|
||||
for value, _ := range self.counts[series][group] {
|
||||
switch self.fieldType {
|
||||
case protocol.FieldDefinition_INT32:
|
||||
v := value.(int32)
|
||||
returnValues = append(returnValues, &protocol.FieldValue{IntValue: &v})
|
||||
case protocol.FieldDefinition_INT64:
|
||||
v := value.(int64)
|
||||
returnValues = append(returnValues, &protocol.FieldValue{Int64Value: &v})
|
||||
|
@ -686,8 +630,7 @@ func (self *DistinctAggregator) InitializeFieldsMetadata(series *protocol.Series
|
|||
self.fieldType = *field.Type
|
||||
|
||||
switch self.fieldType {
|
||||
case protocol.FieldDefinition_INT32,
|
||||
protocol.FieldDefinition_INT64,
|
||||
case protocol.FieldDefinition_INT64,
|
||||
protocol.FieldDefinition_DOUBLE:
|
||||
// that's fine
|
||||
default:
|
||||
|
@ -733,10 +676,6 @@ func (self *MaxAggregator) AggregatePoint(series string, group interface{}, p *p
|
|||
if value := *p.Values[self.fieldIndex].Int64Value; currentValue.Int64Value == nil || *currentValue.Int64Value < value {
|
||||
currentValue.Int64Value = &value
|
||||
}
|
||||
case protocol.FieldDefinition_INT32:
|
||||
if value := *p.Values[self.fieldIndex].IntValue; currentValue.IntValue == nil || *currentValue.IntValue < value {
|
||||
currentValue.IntValue = &value
|
||||
}
|
||||
case protocol.FieldDefinition_DOUBLE:
|
||||
if value := *p.Values[self.fieldIndex].DoubleValue; currentValue.DoubleValue == nil || *currentValue.DoubleValue < value {
|
||||
currentValue.DoubleValue = &value
|
||||
|
@ -769,8 +708,7 @@ func (self *MaxAggregator) InitializeFieldsMetadata(series *protocol.Series) err
|
|||
self.fieldType = *field.Type
|
||||
|
||||
switch self.fieldType {
|
||||
case protocol.FieldDefinition_INT32,
|
||||
protocol.FieldDefinition_INT64,
|
||||
case protocol.FieldDefinition_INT64,
|
||||
protocol.FieldDefinition_DOUBLE:
|
||||
// that's fine
|
||||
default:
|
||||
|
@ -820,10 +758,6 @@ func (self *MinAggregator) AggregatePoint(series string, group interface{}, p *p
|
|||
if value := *p.Values[self.fieldIndex].Int64Value; currentValue.Int64Value == nil || *currentValue.Int64Value > value {
|
||||
currentValue.Int64Value = &value
|
||||
}
|
||||
case protocol.FieldDefinition_INT32:
|
||||
if value := *p.Values[self.fieldIndex].IntValue; currentValue.IntValue == nil || *currentValue.IntValue > value {
|
||||
currentValue.IntValue = &value
|
||||
}
|
||||
case protocol.FieldDefinition_DOUBLE:
|
||||
if value := *p.Values[self.fieldIndex].DoubleValue; currentValue.DoubleValue == nil || *currentValue.DoubleValue > value {
|
||||
currentValue.DoubleValue = &value
|
||||
|
@ -856,8 +790,7 @@ func (self *MinAggregator) InitializeFieldsMetadata(series *protocol.Series) err
|
|||
self.fieldType = *field.Type
|
||||
|
||||
switch self.fieldType {
|
||||
case protocol.FieldDefinition_INT32,
|
||||
protocol.FieldDefinition_INT64,
|
||||
case protocol.FieldDefinition_INT64,
|
||||
protocol.FieldDefinition_DOUBLE:
|
||||
// that's fine
|
||||
default:
|
||||
|
@ -905,8 +838,6 @@ func (self *SumAggregator) AggregatePoint(series string, group interface{}, p *p
|
|||
switch self.fieldType {
|
||||
case protocol.FieldDefinition_INT64:
|
||||
currentValue += float64(*p.Values[self.fieldIndex].Int64Value)
|
||||
case protocol.FieldDefinition_INT32:
|
||||
currentValue += float64(*p.Values[self.fieldIndex].IntValue)
|
||||
case protocol.FieldDefinition_DOUBLE:
|
||||
currentValue += *p.Values[self.fieldIndex].DoubleValue
|
||||
}
|
||||
|
@ -927,9 +858,6 @@ func (self *SumAggregator) GetValue(series string, group interface{}) []*protoco
|
|||
returnValues := []*protocol.FieldValue{}
|
||||
|
||||
switch self.fieldType {
|
||||
case protocol.FieldDefinition_INT32:
|
||||
value := int32(self.sums[series][group])
|
||||
returnValues = append(returnValues, &protocol.FieldValue{IntValue: &value})
|
||||
case protocol.FieldDefinition_INT64:
|
||||
value := int64(self.sums[series][group])
|
||||
returnValues = append(returnValues, &protocol.FieldValue{Int64Value: &value})
|
||||
|
@ -948,8 +876,7 @@ func (self *SumAggregator) InitializeFieldsMetadata(series *protocol.Series) err
|
|||
self.fieldType = *field.Type
|
||||
|
||||
switch self.fieldType {
|
||||
case protocol.FieldDefinition_INT32,
|
||||
protocol.FieldDefinition_INT64,
|
||||
case protocol.FieldDefinition_INT64,
|
||||
protocol.FieldDefinition_DOUBLE:
|
||||
// that's fine
|
||||
default:
|
||||
|
|
|
@ -58,8 +58,6 @@ func getValueFromPoint(value *protocol.FieldValue, fType protocol.FieldDefinitio
|
|||
switch fType {
|
||||
case protocol.FieldDefinition_STRING:
|
||||
return *value.StringValue
|
||||
case protocol.FieldDefinition_INT32:
|
||||
return *value.IntValue
|
||||
case protocol.FieldDefinition_INT64:
|
||||
return *value.Int64Value
|
||||
case protocol.FieldDefinition_BOOL:
|
||||
|
@ -195,6 +193,11 @@ func createValuesToInterface(groupBy parser.GroupByClause, definitions []*protoc
|
|||
}
|
||||
|
||||
func (self *QueryEngine) executeCountQueryWithGroupBy(database string, query *parser.Query, yield func(*protocol.Series) error) error {
|
||||
duration, err := query.GetGroupByClause().GetGroupByTime()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
aggregators := []Aggregator{}
|
||||
for _, value := range query.GetColumnNames() {
|
||||
if value.IsFunctionCall() {
|
||||
|
@ -302,18 +305,24 @@ func (self *QueryEngine) executeCountQueryWithGroupBy(database string, query *pa
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME: this should be looking at the fields slice not the group by clause
|
||||
// FIXME: we should check whether the selected columns are in the group by clause
|
||||
for idx, _ := range groupBy {
|
||||
if duration != nil && idx == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
value := inverse(groupId, idx)
|
||||
|
||||
switch x := value.(type) {
|
||||
case string:
|
||||
point.Values = append(point.Values, &protocol.FieldValue{StringValue: &x})
|
||||
case int32:
|
||||
point.Values = append(point.Values, &protocol.FieldValue{IntValue: &x})
|
||||
case bool:
|
||||
point.Values = append(point.Values, &protocol.FieldValue{BoolValue: &x})
|
||||
case float64:
|
||||
point.Values = append(point.Values, &protocol.FieldValue{DoubleValue: &x})
|
||||
case int64:
|
||||
point.Values = append(point.Values, &protocol.FieldValue{Int64Value: &x})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ func (self *EngineSuite) TestCountQuery(c *C) {
|
|||
{
|
||||
"values": [
|
||||
{
|
||||
"int_value": 2
|
||||
"int64_value": 2
|
||||
}
|
||||
],
|
||||
"timestamp": 1381346631,
|
||||
|
@ -177,7 +177,7 @@ func (self *EngineSuite) TestCountQuery(c *C) {
|
|||
"name": "foo",
|
||||
"fields": [
|
||||
{
|
||||
"type": "INT32",
|
||||
"type": "INT64",
|
||||
"name": "count"
|
||||
}
|
||||
]
|
||||
|
@ -240,7 +240,7 @@ func (self *EngineSuite) TestCountQueryWithRegexTables(c *C) {
|
|||
{
|
||||
"values": [
|
||||
{
|
||||
"int_value": 1
|
||||
"int64_value": 1
|
||||
}
|
||||
],
|
||||
"timestamp": 1381346631,
|
||||
|
@ -250,7 +250,7 @@ func (self *EngineSuite) TestCountQueryWithRegexTables(c *C) {
|
|||
"name": "foo.bar",
|
||||
"fields": [
|
||||
{
|
||||
"type": "INT32",
|
||||
"type": "INT64",
|
||||
"name": "count"
|
||||
}
|
||||
]
|
||||
|
@ -260,7 +260,7 @@ func (self *EngineSuite) TestCountQueryWithRegexTables(c *C) {
|
|||
{
|
||||
"values": [
|
||||
{
|
||||
"int_value": 1
|
||||
"int64_value": 1
|
||||
}
|
||||
],
|
||||
"timestamp": 1381346631,
|
||||
|
@ -270,7 +270,7 @@ func (self *EngineSuite) TestCountQueryWithRegexTables(c *C) {
|
|||
"name": "foo.baz",
|
||||
"fields": [
|
||||
{
|
||||
"type": "INT32",
|
||||
"type": "INT64",
|
||||
"name": "count"
|
||||
}
|
||||
]
|
||||
|
@ -322,7 +322,7 @@ func (self *EngineSuite) TestCountQueryWithGroupByClause(c *C) {
|
|||
{
|
||||
"values": [
|
||||
{
|
||||
"int_value": 1
|
||||
"int64_value": 1
|
||||
},
|
||||
{
|
||||
"string_value": "some_value"
|
||||
|
@ -334,7 +334,7 @@ func (self *EngineSuite) TestCountQueryWithGroupByClause(c *C) {
|
|||
{
|
||||
"values": [
|
||||
{
|
||||
"int_value": 1
|
||||
"int64_value": 1
|
||||
},
|
||||
{
|
||||
"string_value": "another_value"
|
||||
|
@ -347,7 +347,7 @@ func (self *EngineSuite) TestCountQueryWithGroupByClause(c *C) {
|
|||
"name": "foo",
|
||||
"fields": [
|
||||
{
|
||||
"type": "INT32",
|
||||
"type": "INT64",
|
||||
"name": "count"
|
||||
},
|
||||
{
|
||||
|
@ -393,7 +393,7 @@ func (self *EngineSuite) TestCountQueryWithGroupByClauseWithMultipleColumns(c *C
|
|||
"string_value": "some_value"
|
||||
},
|
||||
{
|
||||
"int_value": 1
|
||||
"int64_value": 1
|
||||
}
|
||||
],
|
||||
"timestamp": 1381346631,
|
||||
|
@ -405,7 +405,7 @@ func (self *EngineSuite) TestCountQueryWithGroupByClauseWithMultipleColumns(c *C
|
|||
"string_value": "some_value"
|
||||
},
|
||||
{
|
||||
"int_value": 2
|
||||
"int64_value": 2
|
||||
}
|
||||
],
|
||||
"timestamp": 1381346631,
|
||||
|
@ -417,7 +417,7 @@ func (self *EngineSuite) TestCountQueryWithGroupByClauseWithMultipleColumns(c *C
|
|||
"string_value": "another_value"
|
||||
},
|
||||
{
|
||||
"int_value": 1
|
||||
"int64_value": 1
|
||||
}
|
||||
],
|
||||
"timestamp": 1381346631,
|
||||
|
@ -431,7 +431,7 @@ func (self *EngineSuite) TestCountQueryWithGroupByClauseWithMultipleColumns(c *C
|
|||
"name": "column_one"
|
||||
},
|
||||
{
|
||||
"type": "INT32",
|
||||
"type": "INT64",
|
||||
"name": "column_two"
|
||||
}
|
||||
|
||||
|
@ -446,13 +446,13 @@ func (self *EngineSuite) TestCountQueryWithGroupByClauseWithMultipleColumns(c *C
|
|||
{
|
||||
"values": [
|
||||
{
|
||||
"int_value": 1
|
||||
"int64_value": 1
|
||||
},
|
||||
{
|
||||
"string_value": "some_value"
|
||||
},
|
||||
{
|
||||
"int_value": 1
|
||||
"int64_value": 1
|
||||
}
|
||||
],
|
||||
"timestamp": 1381346631,
|
||||
|
@ -461,13 +461,13 @@ func (self *EngineSuite) TestCountQueryWithGroupByClauseWithMultipleColumns(c *C
|
|||
{
|
||||
"values": [
|
||||
{
|
||||
"int_value": 1
|
||||
"int64_value": 1
|
||||
},
|
||||
{
|
||||
"string_value": "some_value"
|
||||
},
|
||||
{
|
||||
"int_value": 2
|
||||
"int64_value": 2
|
||||
}
|
||||
],
|
||||
"timestamp": 1381346631,
|
||||
|
@ -476,13 +476,13 @@ func (self *EngineSuite) TestCountQueryWithGroupByClauseWithMultipleColumns(c *C
|
|||
{
|
||||
"values": [
|
||||
{
|
||||
"int_value": 1
|
||||
"int64_value": 1
|
||||
},
|
||||
{
|
||||
"string_value": "another_value"
|
||||
},
|
||||
{
|
||||
"int_value": 1
|
||||
"int64_value": 1
|
||||
}
|
||||
],
|
||||
"timestamp": 1381346631,
|
||||
|
@ -492,7 +492,7 @@ func (self *EngineSuite) TestCountQueryWithGroupByClauseWithMultipleColumns(c *C
|
|||
"name": "foo",
|
||||
"fields": [
|
||||
{
|
||||
"type": "INT32",
|
||||
"type": "INT64",
|
||||
"name": "count"
|
||||
},
|
||||
{
|
||||
|
@ -500,7 +500,7 @@ func (self *EngineSuite) TestCountQueryWithGroupByClauseWithMultipleColumns(c *C
|
|||
"name": "column_one"
|
||||
},
|
||||
{
|
||||
"type": "INT32",
|
||||
"type": "INT64",
|
||||
"name": "column_two"
|
||||
}
|
||||
]
|
||||
|
@ -560,7 +560,7 @@ func (self *EngineSuite) TestCountQueryWithGroupByTime(c *C) {
|
|||
{
|
||||
"values": [
|
||||
{
|
||||
"int_value": 1
|
||||
"int64_value": 1
|
||||
}
|
||||
],
|
||||
"timestamp": 1381346640,
|
||||
|
@ -569,7 +569,7 @@ func (self *EngineSuite) TestCountQueryWithGroupByTime(c *C) {
|
|||
{
|
||||
"values": [
|
||||
{
|
||||
"int_value": 2
|
||||
"int64_value": 2
|
||||
}
|
||||
],
|
||||
"timestamp": 1381346700,
|
||||
|
@ -579,7 +579,7 @@ func (self *EngineSuite) TestCountQueryWithGroupByTime(c *C) {
|
|||
"name": "foo",
|
||||
"fields": [
|
||||
{
|
||||
"type": "INT32",
|
||||
"type": "INT64",
|
||||
"name": "count"
|
||||
}
|
||||
]
|
||||
|
@ -606,13 +606,13 @@ func (self *EngineSuite) TestCountQueryWithGroupByTimeAndColumn(c *C) {
|
|||
runQuery(engine, "select count(*), column_one from foo group by time(1m), column_one;", c, `[
|
||||
{
|
||||
"points": [
|
||||
{ "values": [{ "int_value": 1 }, { "string_value": "some_value" }], "timestamp": 1381346640, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 1 }, { "string_value": "another_value" }], "timestamp": 1381346700, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 1 }, { "string_value": "some_value" }], "timestamp": 1381346700, "sequence_number": 1 }
|
||||
{ "values": [{ "int64_value": 1 }, { "string_value": "some_value" }], "timestamp": 1381346640, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 1 }, { "string_value": "another_value" }], "timestamp": 1381346700, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 1 }, { "string_value": "some_value" }], "timestamp": 1381346700, "sequence_number": 1 }
|
||||
],
|
||||
"name": "foo",
|
||||
"fields": [
|
||||
{ "type": "INT32", "name": "count" },
|
||||
{ "type": "INT64", "name": "count" },
|
||||
{ "type": "STRING", "name": "column_one" }
|
||||
]
|
||||
}
|
||||
|
@ -623,13 +623,13 @@ func (self *EngineSuite) TestMinQueryWithGroupByTime(c *C) {
|
|||
engine := createEngine(c, `[
|
||||
{
|
||||
"points": [
|
||||
{ "values": [{ "int_value": 3 }], "timestamp": 1381346641, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 8 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 4 }], "timestamp": 1381346721, "sequence_number": 1 }
|
||||
{ "values": [{ "int64_value": 3 }], "timestamp": 1381346641, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 8 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 4 }], "timestamp": 1381346721, "sequence_number": 1 }
|
||||
],
|
||||
"name": "foo",
|
||||
"fields": [
|
||||
{ "type": "INT32", "name": "column_one" }
|
||||
{ "type": "INT64", "name": "column_one" }
|
||||
]
|
||||
}
|
||||
]`)
|
||||
|
@ -637,12 +637,12 @@ func (self *EngineSuite) TestMinQueryWithGroupByTime(c *C) {
|
|||
runQuery(engine, "select min(column_one) from foo group by time(1m);", c, `[
|
||||
{
|
||||
"points": [
|
||||
{ "values": [{ "int_value": 3 }], "timestamp": 1381346640, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 4 }], "timestamp": 1381346700, "sequence_number": 1 }
|
||||
{ "values": [{ "int64_value": 3 }], "timestamp": 1381346640, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 4 }], "timestamp": 1381346700, "sequence_number": 1 }
|
||||
],
|
||||
"name": "foo",
|
||||
"fields": [
|
||||
{ "type": "INT32", "name": "min" }
|
||||
{ "type": "INT64", "name": "min" }
|
||||
]
|
||||
}
|
||||
]`)
|
||||
|
@ -652,13 +652,13 @@ func (self *EngineSuite) TestMaxQueryWithGroupByTime(c *C) {
|
|||
engine := createEngine(c, `[
|
||||
{
|
||||
"points": [
|
||||
{ "values": [{ "int_value": 3 }], "timestamp": 1381346641, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 8 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 4 }], "timestamp": 1381346721, "sequence_number": 1 }
|
||||
{ "values": [{ "int64_value": 3 }], "timestamp": 1381346641, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 8 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 4 }], "timestamp": 1381346721, "sequence_number": 1 }
|
||||
],
|
||||
"name": "foo",
|
||||
"fields": [
|
||||
{ "type": "INT32", "name": "column_one" }
|
||||
{ "type": "INT64", "name": "column_one" }
|
||||
]
|
||||
}
|
||||
]`)
|
||||
|
@ -666,12 +666,12 @@ func (self *EngineSuite) TestMaxQueryWithGroupByTime(c *C) {
|
|||
runQuery(engine, "select max(column_one) from foo group by time(1m);", c, `[
|
||||
{
|
||||
"points": [
|
||||
{ "values": [{ "int_value": 3 }], "timestamp": 1381346640, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 8 }], "timestamp": 1381346700, "sequence_number": 1 }
|
||||
{ "values": [{ "int64_value": 3 }], "timestamp": 1381346640, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 8 }], "timestamp": 1381346700, "sequence_number": 1 }
|
||||
],
|
||||
"name": "foo",
|
||||
"fields": [
|
||||
{ "type": "INT32", "name": "max" }
|
||||
{ "type": "INT64", "name": "max" }
|
||||
]
|
||||
}
|
||||
]`)
|
||||
|
@ -682,13 +682,13 @@ func (self *EngineSuite) TestMaxMinQueryWithGroupByTime(c *C) {
|
|||
engine := createEngine(c, `[
|
||||
{
|
||||
"points": [
|
||||
{ "values": [{ "int_value": 3 }], "timestamp": 1381346641, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 8 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 4 }], "timestamp": 1381346721, "sequence_number": 1 }
|
||||
{ "values": [{ "int64_value": 3 }], "timestamp": 1381346641, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 8 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 4 }], "timestamp": 1381346721, "sequence_number": 1 }
|
||||
],
|
||||
"name": "foo",
|
||||
"fields": [
|
||||
{ "type": "INT32", "name": "column_one" }
|
||||
{ "type": "INT64", "name": "column_one" }
|
||||
]
|
||||
}
|
||||
]`)
|
||||
|
@ -696,13 +696,13 @@ func (self *EngineSuite) TestMaxMinQueryWithGroupByTime(c *C) {
|
|||
runQuery(engine, "select max(column_one), min(column_one) from foo group by time(1m);", c, `[
|
||||
{
|
||||
"points": [
|
||||
{ "values": [{ "int_value": 3 }, { "int_value": 3 }], "timestamp": 1381346640, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 8 }, { "int_value": 4 }], "timestamp": 1381346700, "sequence_number": 1 }
|
||||
{ "values": [{ "int64_value": 3 }, { "int64_value": 3 }], "timestamp": 1381346640, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 8 }, { "int64_value": 4 }], "timestamp": 1381346700, "sequence_number": 1 }
|
||||
],
|
||||
"name": "foo",
|
||||
"fields": [
|
||||
{ "type": "INT32", "name": "max" },
|
||||
{ "type": "INT32", "name": "min" }
|
||||
{ "type": "INT64", "name": "max" },
|
||||
{ "type": "INT64", "name": "min" }
|
||||
]
|
||||
}
|
||||
]`)
|
||||
|
@ -713,24 +713,24 @@ func (self *EngineSuite) TestPercentileQueryWithGroupByTime(c *C) {
|
|||
engine := createEngine(c, `[
|
||||
{
|
||||
"points": [
|
||||
{ "values": [{ "int_value": 1 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 3 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 5 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 7 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 4 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 2 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 6 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 9 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 8 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 7 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 6 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 5 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 4 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 3 }], "timestamp": 1381346741, "sequence_number": 1 }
|
||||
{ "values": [{ "int64_value": 1 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 3 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 5 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 7 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 4 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 2 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 6 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 9 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 8 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 7 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 6 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 5 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 4 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 3 }], "timestamp": 1381346741, "sequence_number": 1 }
|
||||
],
|
||||
"name": "foo",
|
||||
"fields": [
|
||||
{ "type": "INT32", "name": "column_one" }
|
||||
{ "type": "INT64", "name": "column_one" }
|
||||
]
|
||||
}
|
||||
]`)
|
||||
|
@ -738,12 +738,12 @@ func (self *EngineSuite) TestPercentileQueryWithGroupByTime(c *C) {
|
|||
runQuery(engine, "select percentile(column_one, 80) from foo group by time(1m);", c, `[
|
||||
{
|
||||
"points": [
|
||||
{ "values": [{ "int_value": 6 }], "timestamp": 1381346700, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 8 }], "timestamp": 1381346760, "sequence_number": 1 }
|
||||
{ "values": [{ "int64_value": 6 }], "timestamp": 1381346700, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 8 }], "timestamp": 1381346760, "sequence_number": 1 }
|
||||
],
|
||||
"name": "foo",
|
||||
"fields": [
|
||||
{ "type": "INT32", "name": "percentile" }
|
||||
{ "type": "INT64", "name": "percentile" }
|
||||
]
|
||||
}
|
||||
]`)
|
||||
|
@ -753,24 +753,24 @@ func (self *EngineSuite) TestMedianQueryWithGroupByTime(c *C) {
|
|||
engine := createEngine(c, `[
|
||||
{
|
||||
"points": [
|
||||
{ "values": [{ "int_value": 1 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 3 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 5 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 7 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 4 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 2 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 6 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 9 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 8 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 7 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 6 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 5 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 4 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 1 }], "timestamp": 1381346741, "sequence_number": 1 }
|
||||
{ "values": [{ "int64_value": 1 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 3 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 5 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 7 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 4 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 2 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 6 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 9 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 8 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 7 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 6 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 5 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 4 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 1 }], "timestamp": 1381346741, "sequence_number": 1 }
|
||||
],
|
||||
"name": "foo",
|
||||
"fields": [
|
||||
{ "type": "INT32", "name": "column_one" }
|
||||
{ "type": "INT64", "name": "column_one" }
|
||||
]
|
||||
}
|
||||
]`)
|
||||
|
@ -778,12 +778,12 @@ func (self *EngineSuite) TestMedianQueryWithGroupByTime(c *C) {
|
|||
runQuery(engine, "select median(column_one) from foo group by time(1m);", c, `[
|
||||
{
|
||||
"points": [
|
||||
{ "values": [{ "int_value": 4 }], "timestamp": 1381346700, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 6 }], "timestamp": 1381346760, "sequence_number": 1 }
|
||||
{ "values": [{ "int64_value": 4 }], "timestamp": 1381346700, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 6 }], "timestamp": 1381346760, "sequence_number": 1 }
|
||||
],
|
||||
"name": "foo",
|
||||
"fields": [
|
||||
{ "type": "INT32", "name": "median" }
|
||||
{ "type": "INT64", "name": "median" }
|
||||
]
|
||||
}
|
||||
]`)
|
||||
|
@ -793,24 +793,24 @@ func (self *EngineSuite) TestMeanQueryWithGroupByTime(c *C) {
|
|||
engine := createEngine(c, `[
|
||||
{
|
||||
"points": [
|
||||
{ "values": [{ "int_value": 1 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 3 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 5 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 7 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 4 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 2 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 6 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 9 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 8 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 7 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 6 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 5 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 4 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 3 }], "timestamp": 1381346741, "sequence_number": 1 }
|
||||
{ "values": [{ "int64_value": 1 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 3 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 5 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 7 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 4 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 2 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 6 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 9 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 8 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 7 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 6 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 5 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 4 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 3 }], "timestamp": 1381346741, "sequence_number": 1 }
|
||||
],
|
||||
"name": "foo",
|
||||
"fields": [
|
||||
{ "type": "INT32", "name": "column_one" }
|
||||
{ "type": "INT64", "name": "column_one" }
|
||||
]
|
||||
}
|
||||
]`)
|
||||
|
@ -833,16 +833,16 @@ func (self *EngineSuite) TestSumQueryWithGroupByTime(c *C) {
|
|||
engine := createEngine(c, `[
|
||||
{
|
||||
"points": [
|
||||
{ "values": [{ "int_value": 1 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 4 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 6 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 8 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 5 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 3 }], "timestamp": 1381346741, "sequence_number": 1 }
|
||||
{ "values": [{ "int64_value": 1 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 4 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 6 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 8 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 5 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 3 }], "timestamp": 1381346741, "sequence_number": 1 }
|
||||
],
|
||||
"name": "foo",
|
||||
"fields": [
|
||||
{ "type": "INT32", "name": "column_one" }
|
||||
{ "type": "INT64", "name": "column_one" }
|
||||
]
|
||||
}
|
||||
]`)
|
||||
|
@ -850,12 +850,12 @@ func (self *EngineSuite) TestSumQueryWithGroupByTime(c *C) {
|
|||
runQuery(engine, "select sum(column_one) from foo group by time(1m);", c, `[
|
||||
{
|
||||
"points": [
|
||||
{ "values": [{ "int_value": 11 }], "timestamp": 1381346700, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 16 }], "timestamp": 1381346760, "sequence_number": 1 }
|
||||
{ "values": [{ "int64_value": 11 }], "timestamp": 1381346700, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 16 }], "timestamp": 1381346760, "sequence_number": 1 }
|
||||
],
|
||||
"name": "foo",
|
||||
"fields": [
|
||||
{ "type": "INT32", "name": "sum" }
|
||||
{ "type": "INT64", "name": "sum" }
|
||||
]
|
||||
}
|
||||
]`)
|
||||
|
@ -865,25 +865,25 @@ func (self *EngineSuite) TestModeQueryWithGroupByTime(c *C) {
|
|||
engine := createEngine(c, `[
|
||||
{
|
||||
"points": [
|
||||
{ "values": [{ "int_value": 1 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 1 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 1 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 4 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 5 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 6 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 6 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 3 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 8 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 7 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 6 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 5 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 4 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 3 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 3 }], "timestamp": 1381346741, "sequence_number": 1 }
|
||||
{ "values": [{ "int64_value": 1 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 1 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 1 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 4 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 5 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 6 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 6 }], "timestamp": 1381346701, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 3 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 8 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 7 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 6 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 5 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 4 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 3 }], "timestamp": 1381346741, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 3 }], "timestamp": 1381346741, "sequence_number": 1 }
|
||||
],
|
||||
"name": "foo",
|
||||
"fields": [
|
||||
{ "type": "INT32", "name": "column_one" }
|
||||
{ "type": "INT64", "name": "column_one" }
|
||||
]
|
||||
}
|
||||
]`)
|
||||
|
@ -891,12 +891,12 @@ func (self *EngineSuite) TestModeQueryWithGroupByTime(c *C) {
|
|||
runQuery(engine, "select mode(column_one) from foo group by time(1m);", c, `[
|
||||
{
|
||||
"points": [
|
||||
{ "values": [{ "int_value": 1 }], "timestamp": 1381346700, "sequence_number": 1 },
|
||||
{ "values": [{ "int_value": 3 }], "timestamp": 1381346760, "sequence_number": 1 }
|
||||
{ "values": [{ "int64_value": 1 }], "timestamp": 1381346700, "sequence_number": 1 },
|
||||
{ "values": [{ "int64_value": 3 }], "timestamp": 1381346760, "sequence_number": 1 }
|
||||
],
|
||||
"name": "foo",
|
||||
"fields": [
|
||||
{ "type": "INT32", "name": "mode" }
|
||||
{ "type": "INT64", "name": "mode" }
|
||||
]
|
||||
}
|
||||
]`)
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package engine
|
||||
|
||||
import (
|
||||
"sort"
|
||||
)
|
||||
|
||||
// Int64Slice attaches the methods of sort.Interface to []int64, sorting in increasing order.
|
||||
type Int64Slice []int64
|
||||
|
||||
func (p Int64Slice) Len() int { return len(p) }
|
||||
func (p Int64Slice) Less(i, j int) bool { return p[i] < p[j] }
|
||||
func (p Int64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||
|
||||
func SortInt64(ints []int64) {
|
||||
sort.Sort(Int64Slice(ints))
|
||||
}
|
|
@ -273,8 +273,6 @@ func serializeSeries(memSeries map[string]*protocol.Series) []*SerializedSeries
|
|||
switch *series.Fields[idx].Type {
|
||||
case protocol.FieldDefinition_STRING:
|
||||
rowValues = append(rowValues, *value.StringValue)
|
||||
case protocol.FieldDefinition_INT32:
|
||||
rowValues = append(rowValues, *value.IntValue)
|
||||
case protocol.FieldDefinition_INT64:
|
||||
rowValues = append(rowValues, *value.Int64Value)
|
||||
case protocol.FieldDefinition_DOUBLE:
|
||||
|
|
|
@ -38,41 +38,41 @@ func (self *MockEngine) RunQuery(_ string, query string, yield func(*protocol.Se
|
|||
"points": [
|
||||
{
|
||||
"values": [
|
||||
{ "string_value": "some_value"},{"int_value": 1}
|
||||
{ "string_value": "some_value"},{"int64_value": 1}
|
||||
],
|
||||
"timestamp": 1381346631,
|
||||
"sequence_number": 1
|
||||
},
|
||||
{
|
||||
"values": [
|
||||
{"string_value": "some_value"},{"int_value": 2}
|
||||
{"string_value": "some_value"},{"int64_value": 2}
|
||||
],
|
||||
"timestamp": 1381346632,
|
||||
"sequence_number": 2
|
||||
}
|
||||
],
|
||||
"name": "foo",
|
||||
"fields": [{"type": "STRING","name": "column_one"},{"type": "INT32","name": "column_two"}]
|
||||
"fields": [{"type": "STRING","name": "column_one"},{"type": "INT64","name": "column_two"}]
|
||||
},
|
||||
{
|
||||
"points": [
|
||||
{
|
||||
"values": [
|
||||
{ "string_value": "some_value"},{"int_value": 3}
|
||||
{ "string_value": "some_value"},{"int64_value": 3}
|
||||
],
|
||||
"timestamp": 1381346633,
|
||||
"sequence_number": 1
|
||||
},
|
||||
{
|
||||
"values": [
|
||||
{"string_value": "some_value"},{"int_value": 4}
|
||||
{"string_value": "some_value"},{"int64_value": 4}
|
||||
],
|
||||
"timestamp": 1381346634,
|
||||
"sequence_number": 2
|
||||
}
|
||||
],
|
||||
"name": "foo",
|
||||
"fields": [{"type": "STRING","name": "column_one"},{"type": "INT32","name": "column_two"}]
|
||||
"fields": [{"type": "STRING","name": "column_one"},{"type": "INT64","name": "column_two"}]
|
||||
}
|
||||
]
|
||||
`)
|
||||
|
@ -121,6 +121,7 @@ func (self *ApiSuite) TestNotChunkedQuery(c *C) {
|
|||
resp, err := http.Get(addr)
|
||||
c.Assert(err, IsNil)
|
||||
defer resp.Body.Close()
|
||||
c.Assert(resp.StatusCode, Equals, http.StatusOK)
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
c.Assert(err, IsNil)
|
||||
series := []SerializedSeries{}
|
||||
|
|
|
@ -17,7 +17,6 @@ type FieldDefinition_Type int32
|
|||
|
||||
const (
|
||||
FieldDefinition_STRING FieldDefinition_Type = 1
|
||||
FieldDefinition_INT32 FieldDefinition_Type = 2
|
||||
FieldDefinition_DOUBLE FieldDefinition_Type = 3
|
||||
FieldDefinition_BOOL FieldDefinition_Type = 4
|
||||
FieldDefinition_INT64 FieldDefinition_Type = 5
|
||||
|
@ -25,14 +24,12 @@ const (
|
|||
|
||||
var FieldDefinition_Type_name = map[int32]string{
|
||||
1: "STRING",
|
||||
2: "INT32",
|
||||
3: "DOUBLE",
|
||||
4: "BOOL",
|
||||
5: "INT64",
|
||||
}
|
||||
var FieldDefinition_Type_value = map[string]int32{
|
||||
"STRING": 1,
|
||||
"INT32": 2,
|
||||
"DOUBLE": 3,
|
||||
"BOOL": 4,
|
||||
"INT64": 5,
|
||||
|
@ -138,7 +135,6 @@ func (x *Response_Type) UnmarshalJSON(data []byte) error {
|
|||
|
||||
type FieldValue struct {
|
||||
StringValue *string `protobuf:"bytes,1,opt,name=string_value" json:"string_value,omitempty"`
|
||||
IntValue *int32 `protobuf:"varint,2,opt,name=int_value" json:"int_value,omitempty"`
|
||||
DoubleValue *float64 `protobuf:"fixed64,3,opt,name=double_value" json:"double_value,omitempty"`
|
||||
BoolValue *bool `protobuf:"varint,4,opt,name=bool_value" json:"bool_value,omitempty"`
|
||||
Int64Value *int64 `protobuf:"varint,5,opt,name=int64_value" json:"int64_value,omitempty"`
|
||||
|
@ -156,13 +152,6 @@ func (m *FieldValue) GetStringValue() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (m *FieldValue) GetIntValue() int32 {
|
||||
if m != nil && m.IntValue != nil {
|
||||
return *m.IntValue
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *FieldValue) GetDoubleValue() float64 {
|
||||
if m != nil && m.DoubleValue != nil {
|
||||
return *m.DoubleValue
|
||||
|
|
|
@ -2,7 +2,6 @@ package protocol;
|
|||
|
||||
message FieldValue {
|
||||
optional string string_value = 1;
|
||||
optional int32 int_value = 2;
|
||||
optional double double_value = 3;
|
||||
optional bool bool_value = 4;
|
||||
optional int64 int64_value = 5;
|
||||
|
@ -11,7 +10,6 @@ message FieldValue {
|
|||
message FieldDefinition {
|
||||
enum Type {
|
||||
STRING = 1;
|
||||
INT32 = 2;
|
||||
DOUBLE = 3;
|
||||
BOOL = 4;
|
||||
INT64 = 5;
|
||||
|
|
Loading…
Reference in New Issue