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


Golang influxql.IteratorOptions类代码示例

本文整理汇总了Golang中github.com/influxdata/influxdb/influxql.IteratorOptions的典型用法代码示例。如果您正苦于以下问题:Golang IteratorOptions类的具体用法?Golang IteratorOptions怎么用?Golang IteratorOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IteratorOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestIteratorOptions_ElapsedInterval_Default

func TestIteratorOptions_ElapsedInterval_Default(t *testing.T) {
	opt := influxql.IteratorOptions{}
	expected := influxql.Interval{Duration: time.Nanosecond}
	actual := opt.ElapsedInterval()
	if actual != expected {
		t.Errorf("expected elapsed interval to be %v, got %v", expected, actual)
	}
}
开发者ID:Vidhuran,项目名称:influxdb,代码行数:8,代码来源:iterator_test.go

示例2: TestIteratorOptions_DerivativeInterval_Default

func TestIteratorOptions_DerivativeInterval_Default(t *testing.T) {
	opt := influxql.IteratorOptions{}
	expected := influxql.Interval{Duration: time.Second}
	actual := opt.DerivativeInterval()
	if actual != expected {
		t.Errorf("expected derivative interval to be %v, got %v", expected, actual)
	}
}
开发者ID:seiflotfy,项目名称:influxdb,代码行数:8,代码来源:iterator_test.go

示例3: TestIteratorOptions_SeekTime_Descending

func TestIteratorOptions_SeekTime_Descending(t *testing.T) {
	opt := influxql.IteratorOptions{
		StartTime: 30,
		EndTime:   60,
		Ascending: false,
	}

	time := opt.SeekTime()
	if time != 60 {
		t.Errorf("expected time to be 60, got %d", time)
	}
}
开发者ID:seiflotfy,项目名称:influxdb,代码行数:12,代码来源:iterator_test.go

示例4: TestIteratorOptions_DerivativeInterval_GroupBy

func TestIteratorOptions_DerivativeInterval_GroupBy(t *testing.T) {
	opt := influxql.IteratorOptions{
		Interval: influxql.Interval{
			Duration: 10,
			Offset:   2,
		},
	}
	expected := influxql.Interval{Duration: 10}
	actual := opt.DerivativeInterval()
	if actual != expected {
		t.Errorf("expected derivative interval to be %v, got %v", expected, actual)
	}
}
开发者ID:seiflotfy,项目名称:influxdb,代码行数:13,代码来源:iterator_test.go

示例5: TestIteratorOptions_Window_Default

func TestIteratorOptions_Window_Default(t *testing.T) {
	opt := influxql.IteratorOptions{
		StartTime: 0,
		EndTime:   60,
	}

	start, end := opt.Window(34)
	if start != 0 {
		t.Errorf("expected start to be 0, got %d", start)
	}
	if end != 61 {
		t.Errorf("expected end to be 61, got %d", end)
	}
}
开发者ID:seiflotfy,项目名称:influxdb,代码行数:14,代码来源:iterator_test.go

示例6: TestIteratorOptions_Window_Interval

func TestIteratorOptions_Window_Interval(t *testing.T) {
	opt := influxql.IteratorOptions{
		Interval: influxql.Interval{
			Duration: 10,
		},
	}

	start, end := opt.Window(4)
	if start != 0 {
		t.Errorf("expected start to be 0, got %d", start)
	}
	if end != 10 {
		t.Errorf("expected end to be 10, got %d", end)
	}
}
开发者ID:seiflotfy,项目名称:influxdb,代码行数:15,代码来源:iterator_test.go

示例7: TestIteratorOptions_Window_Offset

func TestIteratorOptions_Window_Offset(t *testing.T) {
	opt := influxql.IteratorOptions{
		Interval: influxql.Interval{
			Duration: 10,
			Offset:   8,
		},
	}

	start, end := opt.Window(14)
	if start != 8 {
		t.Errorf("expected start to be 8, got %d", start)
	}
	if end != 18 {
		t.Errorf("expected end to be 18, got %d", end)
	}
}
开发者ID:seiflotfy,项目名称:influxdb,代码行数:16,代码来源:iterator_test.go

示例8: createVarRefIterator

// createVarRefIterator creates an iterator for a variable reference.
func (e *Engine) createVarRefIterator(opt influxql.IteratorOptions) ([]influxql.Iterator, error) {
	ref, _ := opt.Expr.(*influxql.VarRef)

	var itrs []influxql.Iterator
	if err := func() error {
		mms := tsdb.Measurements(e.index.MeasurementsByName(influxql.Sources(opt.Sources).Names()))

		for _, mm := range mms {
			// Determine tagsets for this measurement based on dimensions and filters.
			tagSets, err := mm.TagSets(opt.Dimensions, opt.Condition)
			if err != nil {
				return err
			}

			// Calculate tag sets and apply SLIMIT/SOFFSET.
			tagSets = influxql.LimitTagSets(tagSets, opt.SLimit, opt.SOffset)

			for _, t := range tagSets {
				inputs, err := e.createTagSetIterators(ref, mm, t, opt)
				if err != nil {
					return err
				}

				if len(inputs) > 0 && (opt.Limit > 0 || opt.Offset > 0) {
					var itr influxql.Iterator
					if opt.MergeSorted() {
						itr = influxql.NewSortedMergeIterator(inputs, opt)
					} else {
						itr = influxql.NewMergeIterator(inputs, opt)
					}
					itrs = append(itrs, newLimitIterator(itr, opt))
				} else {
					itrs = append(itrs, inputs...)
				}
			}
		}
		return nil
	}(); err != nil {
		influxql.Iterators(itrs).Close()
		return nil, err
	}

	return itrs, nil
}
开发者ID:jipperinbham,项目名称:influxdb,代码行数:45,代码来源:engine.go

示例9: CreateIterator

// CreateIterator returns an iterator for the data in the shard.
func (s *Shard) CreateIterator(opt influxql.IteratorOptions) (influxql.Iterator, error) {
	if err := s.ready(); err != nil {
		return nil, err
	}

	if influxql.Sources(opt.Sources).HasSystemSource() {
		return s.createSystemIterator(opt)
	}
	opt.Sources = influxql.Sources(opt.Sources).Filter(s.database, s.retentionPolicy)
	return s.engine.CreateIterator(opt)
}
开发者ID:influxdata,项目名称:kapacitor,代码行数:12,代码来源:shard.go

示例10: TestIteratorOptions_DerivativeInterval_Call

func TestIteratorOptions_DerivativeInterval_Call(t *testing.T) {
	opt := influxql.IteratorOptions{
		Expr: &influxql.Call{
			Name: "mean",
			Args: []influxql.Expr{
				&influxql.VarRef{Val: "value"},
				&influxql.DurationLiteral{Val: 2 * time.Second},
			},
		},
		Interval: influxql.Interval{
			Duration: 10,
			Offset:   2,
		},
	}
	expected := influxql.Interval{Duration: 2 * time.Second}
	actual := opt.DerivativeInterval()
	if actual != expected {
		t.Errorf("expected derivative interval to be %v, got %v", expected, actual)
	}
}
开发者ID:seiflotfy,项目名称:influxdb,代码行数:20,代码来源:iterator_test.go

示例11: CreateIterator

// CreateIterator returns an iterator for the data in the shard.
func (s *Shard) CreateIterator(opt influxql.IteratorOptions) (influxql.Iterator, error) {
	if s.closed() {
		return nil, ErrEngineClosed
	}

	if influxql.Sources(opt.Sources).HasSystemSource() {
		return s.createSystemIterator(opt)
	}
	opt.Sources = influxql.Sources(opt.Sources).Filter(s.database, s.retentionPolicy)
	return s.engine.CreateIterator(opt)
}
开发者ID:arussellsaw,项目名称:influxdb,代码行数:12,代码来源:shard.go

示例12: TestIteratorOptions_MarshalBinary_Measurement_Regex

// Ensure iterator options with a regex measurement can be marshaled.
func TestIteratorOptions_MarshalBinary_Measurement_Regex(t *testing.T) {
	opt := &influxql.IteratorOptions{
		Sources: []influxql.Source{
			&influxql.Measurement{Database: "db1", RetentionPolicy: "rp2", Regex: &influxql.RegexLiteral{Val: regexp.MustCompile(`series.+`)}},
		},
	}

	// Marshal to binary.
	buf, err := opt.MarshalBinary()
	if err != nil {
		t.Fatal(err)
	}

	// Unmarshal back to an object.
	var other influxql.IteratorOptions
	if err := other.UnmarshalBinary(buf); err != nil {
		t.Fatal(err)
	} else if v := other.Sources[0].(*influxql.Measurement).Regex.Val.String(); v != `/series.+/` {
		t.Fatalf("unexpected measurement regex: %s", v)
	}
}
开发者ID:seiflotfy,项目名称:influxdb,代码行数:22,代码来源:iterator_test.go

示例13: TestIteratorOptions_MarshalBinary

// Ensure iterator options can be marshaled to and from a binary format.
func TestIteratorOptions_MarshalBinary(t *testing.T) {
	opt := &influxql.IteratorOptions{
		Expr: MustParseExpr("count(value)"),
		Aux:  []string{"a", "b", "c"},
		Sources: []influxql.Source{
			&influxql.Measurement{Database: "db0", RetentionPolicy: "rp0", Name: "mm0"},
		},
		Interval: influxql.Interval{
			Duration: 1 * time.Hour,
			Offset:   20 * time.Minute,
		},
		Dimensions: []string{"region", "host"},
		Fill:       influxql.NumberFill,
		FillValue:  float64(100),
		Condition:  MustParseExpr(`foo = 'bar'`),
		StartTime:  1000,
		EndTime:    2000,
		Ascending:  true,
		Limit:      100,
		Offset:     200,
		SLimit:     300,
		SOffset:    400,
		Dedupe:     true,
	}

	// Marshal to binary.
	buf, err := opt.MarshalBinary()
	if err != nil {
		t.Fatal(err)
	}

	// Unmarshal back to an object.
	var other influxql.IteratorOptions
	if err := other.UnmarshalBinary(buf); err != nil {
		t.Fatal(err)
	} else if !reflect.DeepEqual(&other, opt) {
		t.Fatalf("unexpected options: %s", spew.Sdump(other))
	}
}
开发者ID:seiflotfy,项目名称:influxdb,代码行数:40,代码来源:iterator_test.go

示例14: CreateIterator

// CreateIterator returns a single combined iterator for the shards.
func (a Shards) CreateIterator(opt influxql.IteratorOptions) (influxql.Iterator, error) {
	if influxql.Sources(opt.Sources).HasSystemSource() {
		return a.createSystemIterator(opt)
	}

	// Create iterators for each shard.
	// Ensure that they are closed if an error occurs.
	itrs := make([]influxql.Iterator, 0, len(a))
	if err := func() error {
		for _, sh := range a {
			itr, err := sh.CreateIterator(opt)
			if err != nil {
				return err
			}
			itrs = append(itrs, itr)
		}
		return nil
	}(); err != nil {
		influxql.Iterators(itrs).Close()
		return nil, err
	}

	// Merge into a single iterator.
	if opt.MergeSorted() {
		return influxql.NewSortedMergeIterator(itrs, opt), nil
	}

	itr := influxql.NewMergeIterator(itrs, opt)
	if opt.Expr != nil {
		if expr, ok := opt.Expr.(*influxql.Call); ok && expr.Name == "count" {
			opt.Expr = &influxql.Call{
				Name: "sum",
				Args: expr.Args,
			}
		}
	}
	return influxql.NewCallIterator(itr, opt), nil
}
开发者ID:rwarren,项目名称:influxdb,代码行数:39,代码来源:shard.go

示例15: TestIteratorOptions_MergeSorted

func TestIteratorOptions_MergeSorted(t *testing.T) {
	opt := influxql.IteratorOptions{}
	sorted := opt.MergeSorted()
	if !sorted {
		t.Error("expected no expression to be sorted, got unsorted")
	}

	opt.Expr = &influxql.VarRef{}
	sorted = opt.MergeSorted()
	if !sorted {
		t.Error("expected expression with varref to be sorted, got unsorted")
	}

	opt.Expr = &influxql.Call{}
	sorted = opt.MergeSorted()
	if sorted {
		t.Error("expected expression without varref to be unsorted, got sorted")
	}
}
开发者ID:seiflotfy,项目名称:influxdb,代码行数:19,代码来源:iterator_test.go


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