當前位置: 首頁>>代碼示例>>Golang>>正文


Golang influxql.IteratorOptions類代碼示例

本文整理匯總了Golang中github.com/skia-dev/influxdb/influxql.IteratorOptions的典型用法代碼示例。如果您正苦於以下問題:Golang IteratorOptions類的具體用法?Golang IteratorOptions怎麽用?Golang IteratorOptions使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了IteratorOptions類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: 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:skia-dev,項目名稱:influxdb,代碼行數:8,代碼來源:iterator_test.go

示例2: 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:skia-dev,項目名稱:influxdb,代碼行數:12,代碼來源:iterator_test.go

示例3: 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:skia-dev,項目名稱:influxdb,代碼行數:13,代碼來源:iterator_test.go

示例4: 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:skia-dev,項目名稱:influxdb,代碼行數:14,代碼來源:iterator_test.go

示例5: 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:skia-dev,項目名稱:influxdb,代碼行數:15,代碼來源:iterator_test.go

示例6: 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:skia-dev,項目名稱:influxdb,代碼行數:16,代碼來源:iterator_test.go

示例7: 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:skia-dev,項目名稱:influxdb,代碼行數:20,代碼來源:iterator_test.go

示例8: 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:skia-dev,項目名稱:influxdb,代碼行數:22,代碼來源:iterator_test.go

示例9: 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:skia-dev,項目名稱:influxdb,代碼行數:40,代碼來源:iterator_test.go

示例10: 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:skia-dev,項目名稱:influxdb,代碼行數:19,代碼來源:iterator_test.go

示例11: buildBooleanCursor

// buildBooleanCursor creates a cursor for a boolean field.
func (e *Engine) buildBooleanCursor(measurement, seriesKey, field string, opt influxql.IteratorOptions) booleanCursor {
	cacheValues := e.Cache.Values(SeriesFieldKey(seriesKey, field))
	keyCursor := e.KeyCursor(SeriesFieldKey(seriesKey, field), opt.SeekTime(), opt.Ascending)
	return newBooleanCursor(opt.SeekTime(), opt.Ascending, cacheValues, keyCursor)
}
開發者ID:skia-dev,項目名稱:influxdb,代碼行數:6,代碼來源:engine.go


注:本文中的github.com/skia-dev/influxdb/influxql.IteratorOptions類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。