本文整理汇总了Golang中github.com/SoftwareDefinedBuildings/btrdb.Quasar.QueryValues方法的典型用法代码示例。如果您正苦于以下问题:Golang Quasar.QueryValues方法的具体用法?Golang Quasar.QueryValues怎么用?Golang Quasar.QueryValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/SoftwareDefinedBuildings/btrdb.Quasar
的用法示例。
在下文中一共展示了Quasar.QueryValues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: request_get_VRANGE
//.........这里部分代码省略.........
divisor = 1
case "us":
divisor = 1000 //ns to us
case "s":
divisor = 1000000000 //ns to s
default:
doError(w, "unitoftime must be 'ns', 'ms', 'us' or 's'")
return
}
if st >= btrdb.MaximumTime/divisor ||
st <= btrdb.MinimumTime/divisor {
doError(w, "start time out of bounds")
return
}
if et >= btrdb.MaximumTime/divisor ||
et <= btrdb.MinimumTime/divisor {
doError(w, "end time out of bounds")
return
}
st *= divisor
et *= divisor
pws := r.Form.Get("pw")
pw := uint8(0)
if pws != "" {
pwl, ok, msg := parseInt(pws, 0, 63)
if !ok {
doError(w, "bad point width: "+msg)
return
}
if divisor != 1 {
doError(w, "statistical results require unitoftime=ns")
return
}
pw = uint8(pwl)
}
if pws != "" {
//log.Info("HTTP REQ id=%s pw=%v", id.String(), pw)
logh("QSV", fmt.Sprintf("st=%v et=%v pw=%v u=%s", st, et, pw, id.String()), r)
res, rgen, err := q.QueryStatisticalValues(id, st, et, version, pw)
if err != nil {
doError(w, "query error: "+err.Error())
return
}
resf := make([][]interface{}, len(res))
contents := make([]interface{}, len(res)*6)
for i := 0; i < len(res); i++ {
resf[i] = contents[i*6 : (i+1)*6]
resf[i][0] = res[i].Time / 1000000 //ms since epoch
resf[i][1] = res[i].Time % 1000000 //nanoseconds left over
resf[i][2] = res[i].Min
resf[i][3] = res[i].Mean
resf[i][4] = res[i].Max
resf[i][5] = res[i].Count
}
rv := []struct {
Uuid string `json:"uuid"`
XReadings [][]interface{}
Version uint64 `json:"version"`
}{
{id.String(), resf, rgen},
}
err = json.NewEncoder(w).Encode(rv)
if err != nil {
doError(w, "JSON error: "+err.Error())
return
}
return
} else {
logh("QV", fmt.Sprintf("st=%v et=%v pw=%v u=%s", st, et, pw, id.String()), r)
res, rgen, err := q.QueryValues(id, st, et, version)
if err != nil {
doError(w, "query error: "+err.Error())
return
}
resf := make([][]interface{}, len(res))
contents := make([]interface{}, len(res)*2)
for i := 0; i < len(res); i++ {
resf[i] = contents[i*2 : (i+1)*2]
resf[i][0] = res[i].Time / divisor
resf[i][1] = res[i].Val
}
//props := struct{Uot string `json:"UnitofTime"`}{"foo"}
rv := []struct {
Uuid string `json:"uuid"`
Readings [][]interface{}
Version uint64 `json:"version"`
Properties interface{} `json:"Properties"`
}{
{id.String(), resf, rgen, uot},
}
err = json.NewEncoder(w).Encode(rv)
if err != nil {
doError(w, "JSON error: "+err.Error())
return
}
return
}
//res, err := q.
}