本文整理汇总了Golang中github.com/influxdb/influxdb/tsdb.ProcessAggregateDerivative函数的典型用法代码示例。如果您正苦于以下问题:Golang ProcessAggregateDerivative函数的具体用法?Golang ProcessAggregateDerivative怎么用?Golang ProcessAggregateDerivative使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ProcessAggregateDerivative函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestProcessAggregateDerivative_SingleRow
func TestProcessAggregateDerivative_SingleRow(t *testing.T) {
results := tsdb.ProcessAggregateDerivative([][]interface{}{
[]interface{}{time.Unix(0, 0), 1.0},
}, false, 24*time.Hour)
if !reflect.DeepEqual(results, [][]interface{}{
[]interface{}{time.Unix(0, 0), 0.0},
}) {
t.Fatalf("unexpected results: %s", spew.Sdump(results))
}
}
开发者ID:kim-racktop,项目名称:influxdb,代码行数:11,代码来源:raw_test.go
示例2: TestProcessAggregateDerivative_Negative_NonNegative
func TestProcessAggregateDerivative_Negative_NonNegative(t *testing.T) {
results := tsdb.ProcessAggregateDerivative([][]interface{}{
[]interface{}{time.Unix(0, 0), 1.0},
[]interface{}{time.Unix(0, 0).Add(24 * time.Hour), 2.0},
[]interface{}{time.Unix(0, 0).Add(48 * time.Hour), 0.0},
[]interface{}{time.Unix(0, 0).Add(72 * time.Hour), 4.0},
}, true, 24*time.Hour)
if !reflect.DeepEqual(results, [][]interface{}{
[]interface{}{time.Unix(0, 0).Add(24 * time.Hour), 1.0},
[]interface{}{time.Unix(0, 0).Add(72 * time.Hour), 4.0},
}) {
t.Fatalf("unexpected results: %s", spew.Sdump(results))
}
}
开发者ID:kim-racktop,项目名称:influxdb,代码行数:15,代码来源:raw_test.go
示例3: TestProcessAggregateDerivative_String
func TestProcessAggregateDerivative_String(t *testing.T) {
results := tsdb.ProcessAggregateDerivative([][]interface{}{
[]interface{}{time.Unix(0, 0), "1.0"},
[]interface{}{time.Unix(0, 0).Add(24 * time.Hour), "2.0"},
[]interface{}{time.Unix(0, 0).Add(48 * time.Hour), "3.0"},
[]interface{}{time.Unix(0, 0).Add(72 * time.Hour), "4.0"},
}, false, 24*time.Hour)
if !reflect.DeepEqual(results, [][]interface{}{
[]interface{}{time.Unix(0, 0).Add(24 * time.Hour), nil},
[]interface{}{time.Unix(0, 0).Add(48 * time.Hour), nil},
[]interface{}{time.Unix(0, 0).Add(72 * time.Hour), nil},
}) {
t.Fatalf("unexpected results: %s", spew.Sdump(results))
}
}
开发者ID:kim-racktop,项目名称:influxdb,代码行数:16,代码来源:raw_test.go
示例4: TestProcessAggregateDerivative
// TestProccessAggregateDerivative tests the RawQueryDerivativeProcessor transformation function on the engine.
// The is called for a query with a GROUP BY.
func TestProcessAggregateDerivative(t *testing.T) {
tests := []struct {
name string
fn string
interval time.Duration
in [][]interface{}
exp [][]interface{}
}{
{
name: "empty input",
fn: "derivative",
interval: 24 * time.Hour,
in: [][]interface{}{},
exp: [][]interface{}{},
},
{
name: "single row returns 0.0",
fn: "derivative",
interval: 24 * time.Hour,
in: [][]interface{}{
[]interface{}{
time.Unix(0, 0), 1.0,
},
},
exp: [][]interface{}{
[]interface{}{
time.Unix(0, 0), 0.0,
},
},
},
{
name: "basic derivative",
fn: "derivative",
interval: 24 * time.Hour,
in: [][]interface{}{
[]interface{}{
time.Unix(0, 0), 1.0,
},
[]interface{}{
time.Unix(0, 0).Add(24 * time.Hour), 3.0,
},
[]interface{}{
time.Unix(0, 0).Add(48 * time.Hour), 5.0,
},
[]interface{}{
time.Unix(0, 0).Add(72 * time.Hour), 9.0,
},
},
exp: [][]interface{}{
[]interface{}{
time.Unix(0, 0).Add(24 * time.Hour), 2.0,
},
[]interface{}{
time.Unix(0, 0).Add(48 * time.Hour), 2.0,
},
[]interface{}{
time.Unix(0, 0).Add(72 * time.Hour), 4.0,
},
},
},
{
name: "12h interval",
fn: "derivative",
interval: 12 * time.Hour,
in: [][]interface{}{
[]interface{}{
time.Unix(0, 0), 1.0,
},
[]interface{}{
time.Unix(0, 0).Add(24 * time.Hour), 2.0,
},
[]interface{}{
time.Unix(0, 0).Add(48 * time.Hour), 3.0,
},
[]interface{}{
time.Unix(0, 0).Add(72 * time.Hour), 4.0,
},
},
exp: [][]interface{}{
[]interface{}{
time.Unix(0, 0).Add(24 * time.Hour), 0.5,
},
[]interface{}{
time.Unix(0, 0).Add(48 * time.Hour), 0.5,
},
[]interface{}{
time.Unix(0, 0).Add(72 * time.Hour), 0.5,
},
},
},
{
name: "negative derivatives",
fn: "derivative",
interval: 24 * time.Hour,
in: [][]interface{}{
[]interface{}{
time.Unix(0, 0), 1.0,
//.........这里部分代码省略.........
开发者ID:nooproblem,项目名称:influxdb,代码行数:101,代码来源:executor_test.go
示例5: TestProcessAggregateDerivative_Empty
func TestProcessAggregateDerivative_Empty(t *testing.T) {
results := tsdb.ProcessAggregateDerivative([][]interface{}{}, false, 24*time.Hour)
if !reflect.DeepEqual(results, [][]interface{}{}) {
t.Fatalf("unexpected results: %s", spew.Sdump(results))
}
}
开发者ID:kim-racktop,项目名称:influxdb,代码行数:6,代码来源:raw_test.go
注:本文中的github.com/influxdb/influxdb/tsdb.ProcessAggregateDerivative函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论