View Full Version : Lua Limits on Table Size?
dsmes
October 19th, 2006, 02:14 AM
I'm collecting temperature data and writing it to a table in the format Temperature[SampleNumber]. Later I calculate the maximum temperatures using:
HighTemperature = math.max(unpack(Temperature))This worked fine until sample number 2049 when I got a Lua error that said "stack overflow (table too big to unpack)". Since 2048 is a binary 'power of 2' number, is this a table limit or just the depth of the stack?
Also, could someone suggest a work-around?
Rob H
October 19th, 2006, 03:07 AM
That's probably a stack limit, it certainly only applies to unpacking anyway.
How about something like
local HighTemperature = 0
for _, value in pairs(Temperature) do
HighTemperature = math.max(HighTemperature, value)
end
Although, unless you are discarding earlier values, it would be quicker to update the high temp value when you add a new temperature
dsmes
October 19th, 2006, 03:24 AM
Good points Rob. As always, thanks!
Axeman
October 20th, 2006, 06:41 AM
I'm collecting temperature data and writing it to a table in the format Temperature[SampleNumber]. Later I calculate the maximum temperatures using:
HighTemperature = math.max(unpack(Temperature))This worked fine until sample number 2049 when I got a Lua error that said "stack overflow (table too big to unpack)". Since 2048 is a binary 'power of 2' number, is this a table limit or just the depth of the stack?
Also, could someone suggest a work-around?
I would suggest saving the data to an SQL database and using SQL queries to get your required values. Having this info in a database will provide a MUCH more powerful use of your collected data over time. It is VERY easy to use SQL with girder. Just start reading. Here are a couple of helpful links:
http://www.promixis.com/forums/showthread.php?t=14572&highlight=sql
http://www.keplerproject.org/luasql/manual.html
Jim
Todd Reed
October 20th, 2006, 06:48 AM
Here is what I do...
filedirectory = "c:\\My Documents\\"
filename = "OcelotTempLog.txt"
saveasname = filedirectory..filename
fout = io.open(saveasname,'a+')
local data={}
airtemp=ADI.Var[8]
h2otemp=ADI.Var[7]
d=os.date("%b %d %X %p")
fout:write(d.." "..airtemp.." "..h2otemp.."\n")
fout:close()
Then I can graph my temps through several days...:)
Todd
dsmes
October 20th, 2006, 11:36 AM
Thanks for the reading material Axeman. I'm a little intimidated by databases but it does sound like the way to go. I currently do what Todd suggests with other data I collect. And Todd, I agree- what's the use of collecting data if you don't graph it!
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.