[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[mihini-dev] Mihini handle.TableNew function
|
Hi guys
i am sending the following code of datamanager.lua and i am trying to print
the complete table. please guide me on the following
1. how do i print whole table
2. how you are writing data to ".tbl" file
3. how you are sending from ".tbl" file
function handle.TableNew(asset, x)
print("*****-->Entering handle.TableNew*****************")
print("***********************************************")
table.foreach(x, print)
print("***********************************************")
asset=x.asset--Need to work with assetname
local path = upath.concat(asset, x.path)
local table_id = get_table_id (path, x.storage, x.columns)
local P = POLICIES[x.policy or 'default']
if not P then return errnum 'BAD_PARAMETER', "no such policy" end
-- check whether the table is created or reused from existing
local t = TABLES[table_id]
if t then
print("****** Table Already exists***********")
-- table already exists, if it is a destination table, it is incorrect
-- to retrieve it from a this method
if t.src_table then return errnum 'BAD_PARAMETER', "cannot create or retrieve "..table_id.." because it is a destination table." end
if x.purge then
local ok, msg = M.close_table(nil, table_id)
if not ok then return errnum 'BAD_PARAMETER', msg end
t = nil
elseif not match_columns(t, x.columns) then
return errnum 'BAD_PARAMETER', "cannot reuse "..table_id..": columns does not match"
end
end
-- create table if not exists or purged
if not t then
print("****** Creating New Table***********")
log('DATAMGR', 'DEBUG', "Create new table %s", table_id)
local sdb, errmsg = stagedb(table_id, x.columns)
if not sdb then return errnum 'UNSPECIFIED_ERROR', errmsg end
t = { id=table_id, path=path, sdb=sdb }
else log('DATAMGR', 'DEBUG', "Retrieving existing table %s", table_id) end
t.send_policy=P
P.tables[table_id] = t
TABLES[table_id] = t
print("*******Created table*****")
print("***********************************************")
for k , v in pairs(t.sdb) do
print(tostring(k).." "..tostring(v))
end
print("***********************************************")
return 0, table_id
end