You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
res=driver.query(conn,"SELECT COUNT(*) count, AVG(degree) AS av, MAX(degree), MIN(degree) FROM thermometer WHERE location='beijing' or location='tianjin' GROUP BY location, type")
ifres.code~=0then
print("select error:"..res.error)
return
else
print("in lua, result:")
fori=1, #(res.item) do
print("res:"..res.item[i].count)
end
end
functioncallback(t)
print("continuous query result:")
forkey, valueinpairs(t) do
print("key:"..key..", value:"..value)
end
end
localstream
res=driver.open_stream(conn,"SELECT COUNT(*) as count, AVG(degree) as avg, MAX(degree) as max, MIN(degree) as min FROM thermometer interval(2s) sliding(2s);)",0,callback)
ifres.code~=0then
print("open stream error:"..res.error)
return
else
print("openstream ok")
stream=res.stream
end
--From now on we begin continous query in an definite (infinite if you want) loop.
localloop_index=0
whileloop_index<20do
localt=os.time()*1000
localv=loop_index
res=driver.query(conn,string.format("INSERT INTO therm1 VALUES (%d, %d)",t,v))