Skip to content

Commit

Permalink
Merge pull request #2448 from cannium/fix-data-type
Browse files Browse the repository at this point in the history
Fix inconsistent data type
  • Loading branch information
toddboom committed May 11, 2015
2 parents 58dd944 + 55106a6 commit 6b3bd90
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
21 changes: 21 additions & 0 deletions cmd/influxd/server_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,27 @@ func runTestsData(t *testing.T, testName string, nodes Cluster, database, retent
queryDb: "%DB%",
expected: `{"results":[{"series":[{"name":"cpu","columns":["time","mean","stddev"],"values":[["2000-01-01T00:00:00Z",5,2.138089935299395]]}]}]}`,
},
{
reset: false,
name: "first value",
query: `SELECT FIRST(value) FROM cpu`,
queryDb: "%DB%",
expected: `{"results":[{"series":[{"name":"cpu","columns":["time","first"],"values":[["1970-01-01T00:00:00Z",2]]}]}]}`,
},
{
reset: false,
name: "last value",
query: `SELECT LAST(value) FROM cpu`,
queryDb: "%DB%",
expected: `{"results":[{"series":[{"name":"cpu","columns":["time","last"],"values":[["1970-01-01T00:00:00Z",9]]}]}]}`,
},
{
reset: false,
name: "value spread",
query: `SELECT SPREAD(value) FROM cpu`,
queryDb: "%DB%",
expected: `{"results":[{"series":[{"name":"cpu","columns":["time","spread"],"values":[["1970-01-01T00:00:00Z",7]]}]}]}`,
},
{
name: "median - even sample size",
write: `{"database" : "%DB%", "retentionPolicy" : "%RP%", "points": [
Expand Down
18 changes: 9 additions & 9 deletions influxql/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ type spreadMapOutput struct {

// MapSpread collects the values to pass to the reducer
func MapSpread(itr Iterator) interface{} {
var out spreadMapOutput
out := &spreadMapOutput{}
pointsYielded := false

for _, k, v := itr.Next(); k != 0; _, k, v = itr.Next() {
Expand All @@ -535,14 +535,14 @@ func MapSpread(itr Iterator) interface{} {

// ReduceSpread computes the spread of values.
func ReduceSpread(values []interface{}) interface{} {
var result spreadMapOutput
result := &spreadMapOutput{}
pointsYielded := false

for _, v := range values {
if v == nil {
continue
}
val := v.(spreadMapOutput)
val := v.(*spreadMapOutput)
// Initialize
if !pointsYielded {
result.Max = val.Max
Expand Down Expand Up @@ -612,7 +612,7 @@ type firstLastMapOutput struct {

// MapFirst collects the values to pass to the reducer
func MapFirst(itr Iterator) interface{} {
out := firstLastMapOutput{}
out := &firstLastMapOutput{}
pointsYielded := false

for _, k, v := itr.Next(); k != 0; _, k, v = itr.Next() {
Expand All @@ -635,14 +635,14 @@ func MapFirst(itr Iterator) interface{} {

// ReduceFirst computes the first of value.
func ReduceFirst(values []interface{}) interface{} {
out := firstLastMapOutput{}
out := &firstLastMapOutput{}
pointsYielded := false

for _, v := range values {
if v == nil {
continue
}
val := v.(firstLastMapOutput)
val := v.(*firstLastMapOutput)
// Initialize first
if !pointsYielded {
out.Time = val.Time
Expand All @@ -662,7 +662,7 @@ func ReduceFirst(values []interface{}) interface{} {

// MapLast collects the values to pass to the reducer
func MapLast(itr Iterator) interface{} {
out := firstLastMapOutput{}
out := &firstLastMapOutput{}
pointsYielded := false

for _, k, v := itr.Next(); k != 0; _, k, v = itr.Next() {
Expand All @@ -685,15 +685,15 @@ func MapLast(itr Iterator) interface{} {

// ReduceLast computes the last of value.
func ReduceLast(values []interface{}) interface{} {
out := firstLastMapOutput{}
out := &firstLastMapOutput{}
pointsYielded := false

for _, v := range values {
if v == nil {
continue
}

val := v.(firstLastMapOutput)
val := v.(*firstLastMapOutput)
// Initialize last
if !pointsYielded {
out.Time = val.Time
Expand Down

0 comments on commit 6b3bd90

Please sign in to comment.