本文整理汇总了Golang中github.com/influxdb/influxdb/tsdb.RawQueryDerivativeProcessor.Process方法的典型用法代码示例。如果您正苦于以下问题:Golang RawQueryDerivativeProcessor.Process方法的具体用法?Golang RawQueryDerivativeProcessor.Process怎么用?Golang RawQueryDerivativeProcessor.Process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/influxdb/influxdb/tsdb.RawQueryDerivativeProcessor
的用法示例。
在下文中一共展示了RawQueryDerivativeProcessor.Process方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestRawQueryDerivative_Process_Empty
func TestRawQueryDerivative_Process_Empty(t *testing.T) {
p := tsdb.RawQueryDerivativeProcessor{
IsNonNegative: false,
DerivativeInterval: 24 * time.Hour,
}
results := p.Process([]*tsdb.MapperValue{})
if !reflect.DeepEqual(results, []*tsdb.MapperValue{}) {
t.Fatalf("unexpected results: %s", spew.Sdump(results))
}
}
示例2: TestRawQueryDerivative_Process_Negative_NonNegative
func TestRawQueryDerivative_Process_Negative_NonNegative(t *testing.T) {
p := tsdb.RawQueryDerivativeProcessor{
IsNonNegative: true,
DerivativeInterval: 24 * time.Hour,
}
results := p.Process([]*tsdb.MapperValue{
{Time: time.Unix(0, 0).Unix(), Value: 1.0},
{Time: time.Unix(0, 0).Add(24 * time.Hour).UnixNano(), Value: 2.0},
{Time: time.Unix(0, 0).Add(48 * time.Hour).UnixNano(), Value: 0.0},
{Time: time.Unix(0, 0).Add(72 * time.Hour).UnixNano(), Value: 4.0},
})
if !reflect.DeepEqual(results, []*tsdb.MapperValue{
{Time: time.Unix(0, 0).Add(24 * time.Hour).UnixNano(), Value: 1.0},
{Time: time.Unix(0, 0).Add(72 * time.Hour).UnixNano(), Value: 4.0},
}) {
t.Fatalf("unexpected results: %s", spew.Sdump(results))
}
}
示例3: TestProcessRawQueryDerivative
// TestProcessRawQueryDerivative tests the RawQueryDerivativeProcessor transformation function on the engine.
// The is called for a queries that do not have a group by.
func TestProcessRawQueryDerivative(t *testing.T) {
tests := []struct {
name string
fn string
interval time.Duration
in []*tsdb.MapperValue
exp []*tsdb.MapperValue
}{
{
name: "empty input",
fn: "derivative",
interval: 24 * time.Hour,
in: []*tsdb.MapperValue{},
exp: []*tsdb.MapperValue{},
},
{
name: "single row returns 0.0",
fn: "derivative",
interval: 24 * time.Hour,
in: []*tsdb.MapperValue{
{
Time: time.Unix(0, 0).Unix(),
Value: 1.0,
},
},
exp: []*tsdb.MapperValue{
{
Time: time.Unix(0, 0).Unix(),
Value: 0.0,
},
},
},
{
name: "basic derivative",
fn: "derivative",
interval: 24 * time.Hour,
in: []*tsdb.MapperValue{
{
Time: time.Unix(0, 0).Unix(),
Value: 0.0,
},
{
Time: time.Unix(0, 0).Add(24 * time.Hour).UnixNano(),
Value: 3.0,
},
{
Time: time.Unix(0, 0).Add(48 * time.Hour).UnixNano(),
Value: 5.0,
},
{
Time: time.Unix(0, 0).Add(72 * time.Hour).UnixNano(),
Value: 9.0,
},
},
exp: []*tsdb.MapperValue{
{
Time: time.Unix(0, 0).Add(24 * time.Hour).UnixNano(),
Value: 3.0,
},
{
Time: time.Unix(0, 0).Add(48 * time.Hour).UnixNano(),
Value: 2.0,
},
{
Time: time.Unix(0, 0).Add(72 * time.Hour).UnixNano(),
Value: 4.0,
},
},
},
{
name: "integer derivative",
fn: "derivative",
interval: 24 * time.Hour,
in: []*tsdb.MapperValue{
{
Time: time.Unix(0, 0).Unix(),
Value: int64(0),
},
{
Time: time.Unix(0, 0).Add(24 * time.Hour).UnixNano(),
Value: int64(3),
},
{
Time: time.Unix(0, 0).Add(48 * time.Hour).UnixNano(),
Value: int64(5),
},
{
Time: time.Unix(0, 0).Add(72 * time.Hour).UnixNano(),
Value: int64(9),
},
},
exp: []*tsdb.MapperValue{
{
Time: time.Unix(0, 0).Add(24 * time.Hour).UnixNano(),
Value: 3.0,
},
{
//.........这里部分代码省略.........