当前位置: 首页>>代码示例>>Golang>>正文


Golang RawQueryDerivativeProcessor.Process方法代码示例

本文整理汇总了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))
	}
}
开发者ID:kim-racktop,项目名称:influxdb,代码行数:11,代码来源:raw_test.go

示例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))
	}
}
开发者ID:kim-racktop,项目名称:influxdb,代码行数:19,代码来源:raw_test.go

示例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,
				},
				{
//.........这里部分代码省略.........
开发者ID:nooproblem,项目名称:influxdb,代码行数:101,代码来源:executor_test.go


注:本文中的github.com/influxdb/influxdb/tsdb.RawQueryDerivativeProcessor.Process方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。