本文整理汇总了Golang中github.com/SoftwareDefinedBuildings/btrdb.Quasar.QueryStatisticalValues方法的典型用法代码示例。如果您正苦于以下问题:Golang Quasar.QueryStatisticalValues方法的具体用法?Golang Quasar.QueryStatisticalValues怎么用?Golang Quasar.QueryStatisticalValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/SoftwareDefinedBuildings/btrdb.Quasar
的用法示例。
在下文中一共展示了Quasar.QueryStatisticalValues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: request_get_VRANGE
func request_get_VRANGE(q *btrdb.Quasar, w http.ResponseWriter, r *http.Request) {
atomic.AddInt32(&outstandingHttpReqs, 1)
defer func() {
atomic.AddInt32(&outstandingHttpReqs, -1)
}()
r.ParseForm()
ids := r.Form.Get(":uuid")
id := uuid.Parse(ids)
if id == nil {
log.Critical("ids: '%v'", ids)
doError(w, "malformed uuid")
return
}
st, ok, msg := parseInt(r.Form.Get("starttime"), -(16 << 56), (48 << 56))
if !ok {
doError(w, "bad start time: "+msg)
return
}
et, ok, msg := parseInt(r.Form.Get("endtime"), -(16 << 56), (48 << 56))
if !ok {
doError(w, "bad end time: "+msg)
return
}
if et <= st {
doError(w, "end time <= start time")
return
}
versions := r.Form.Get("ver")
if versions == "" {
versions = "0"
}
//Technically this is incorrect, but I doubt we will overflow this
versioni, ok, msg := parseInt(versions, 0, 1<<63-1)
version := uint64(versioni)
if !ok {
doError(w, "malformed version: "+msg)
return
}
if version == 0 {
version = btrdb.LatestGeneration
}
unitoftime := r.Form.Get("unitoftime")
uot := struct {
UnitofTime string
}{unitoftime}
divisor := int64(1)
switch unitoftime {
case "":
fallthrough
case "ms":
divisor = 1000000 //ns to ms
case "ns":
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
//.........这里部分代码省略.........