本文整理汇总了Golang中github.com/influxdata/influxdb/influxql.IteratorOptions.UnmarshalBinary方法的典型用法代码示例。如果您正苦于以下问题:Golang IteratorOptions.UnmarshalBinary方法的具体用法?Golang IteratorOptions.UnmarshalBinary怎么用?Golang IteratorOptions.UnmarshalBinary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/influxdata/influxdb/influxql.IteratorOptions
的用法示例。
在下文中一共展示了IteratorOptions.UnmarshalBinary方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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)
}
}
示例2: 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))
}
}