本文整理汇总了Golang中github.com/SoftwareDefinedBuildings/btrdb.Quasar.QueryChangedRanges方法的典型用法代码示例。如果您正苦于以下问题:Golang Quasar.QueryChangedRanges方法的具体用法?Golang Quasar.QueryChangedRanges怎么用?Golang Quasar.QueryChangedRanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/SoftwareDefinedBuildings/btrdb.Quasar
的用法示例。
在下文中一共展示了Quasar.QueryChangedRanges方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: dispatchCommands
//.........这里部分代码省略.........
rvers.SetVersions(vlist)
resp.SetVersionList(rvers)
resp.SetFinal(true)
sendresp(rvseg)
case REQUEST_QUERYNEARESTVALUE:
resp, rvseg := mkresp()
t := req.QueryNearestValue().Time()
id := uuid.UUID(req.QueryNearestValue().Uuid())
ver := req.QueryNearestValue().Version()
if ver == 0 {
ver = btrdb.LatestGeneration
}
back := req.QueryNearestValue().Backward()
rv, gen, err := q.QueryNearestValue(id, t, back, ver)
switch err {
case nil:
resp.SetStatusCode(STATUSCODE_OK)
records := NewRecords(rvseg)
rl := NewRecordList(rvseg, 1)
rla := rl.ToArray()
rla[0].SetTime(rv.Time)
rla[0].SetValue(rv.Val)
records.SetVersion(gen)
records.SetValues(rl)
resp.SetRecords(records)
case qtree.ErrNoSuchPoint:
resp.SetStatusCode(STATUSCODE_NOSUCHPOINT)
default:
resp.SetStatusCode(STATUSCODE_INTERNALERROR)
}
resp.SetFinal(true)
sendresp(rvseg)
case REQUEST_QUERYCHANGEDRANGES:
resp, rvseg := mkresp()
id := uuid.UUID(req.QueryChangedRanges().Uuid())
sgen := req.QueryChangedRanges().FromGeneration()
egen := req.QueryChangedRanges().ToGeneration()
if egen == 0 {
egen = btrdb.LatestGeneration
}
resolution := req.QueryChangedRanges().Resolution()
rv, ver, err := q.QueryChangedRanges(id, sgen, egen, resolution)
switch err {
case nil:
resp.SetStatusCode(STATUSCODE_OK)
ranges := NewRanges(rvseg)
ranges.SetVersion(ver)
crl := NewChangedRangeList(rvseg, len(rv))
crla := crl.ToArray()
for i := 0; i < len(rv); i++ {
crla[i].SetStartTime(rv[i].Start)
crla[i].SetEndTime(rv[i].End)
}
ranges.SetValues(crl)
resp.SetChangedRngList(ranges)
default:
log.Critical("qcr error: ", err)
resp.SetStatusCode(STATUSCODE_INTERNALERROR)
}
resp.SetFinal(true)
sendresp(rvseg)
case REQUEST_INSERTVALUES:
resp, rvseg := mkresp()
uuid := uuid.UUID(req.InsertValues().Uuid())
rl := req.InsertValues().Values()
rla := rl.ToArray()
if len(rla) != 0 {
qtr := make([]qtree.Record, len(rla))
for i, v := range rla {
qtr[i] = qtree.Record{Time: v.Time(), Val: v.Value()}
}
q.InsertValues(uuid, qtr)
}
if req.InsertValues().Sync() {
q.Flush(uuid)
}
resp.SetFinal(true)
resp.SetStatusCode(STATUSCODE_OK)
sendresp(rvseg)
case REQUEST_DELETEVALUES:
resp, rvseg := mkresp()
id := uuid.UUID(req.DeleteValues().Uuid())
stime := req.DeleteValues().StartTime()
etime := req.DeleteValues().EndTime()
err := q.DeleteRange(id, stime, etime)
switch err {
case nil:
resp.SetStatusCode(STATUSCODE_OK)
default:
resp.SetStatusCode(STATUSCODE_INTERNALERROR)
}
resp.SetFinal(true)
sendresp(rvseg)
default:
log.Critical("weird segment")
}
}()
}
}