Lua Module Functions
Users may create their own user-defined functions using LUA programming language. Below are some functions users can call when creating their own user-defined functions.
BigObject Module (bo) Functions
Name | Description |
---|---|
getTable(table_name,[workspace]) | Returns the table object if the specified table is accessible and otherwise returns nil, e.g., t = bo.getTable("sales") . |
getTree(tree_name,[workspace]) | Returns the tree object if the specified tree is accessible and otherwise returns nil, e.g., tr = bo.getTree("T3") . |
createTable(schema) | Returns a non-persistent table, e.g., t = bo.createTable("name STRING, age INT32") . |
createTree(table_name,[tree_description]) | Returns a non-persistent tree created from the given table and tree description. A tree description may include: schema which specifies the data field, rank which specifies the tree hierarchy, and filter which denotes the filter condition. For example, tr = bo.createTree("sales", {["schema"]="SUM(qty)", ["rank"]="Product.brand"}) . |
createAllTree(table_name,[tree_description]) | Returns a non-persistent complete tree object created from the given table and tree description. |
Table Functions
Name | Description |
---|---|
name() | Returns the table name. |
getValue(row,cols) | Returns the value of the specified column(s) at a given row. The second argument cols can be a column number, column name, or an array of mixed column number/name. For example, v = t:getValue(4, 0) , v = t:getValue(4, "id") , or v = t:getValue(4, {0, "id"}) . |
getColumnValue(col) | Returns the values of the specified column in an array, e.g. v = t:getColumnValue(0) or v = t:getColumnValue("id") . |
setValue(row,col,value) / setValue(row,{[col]=value,...}) | Sets the value of specified column(s) at a given row. For instance, t:setValue(4, 1, "Julia Kennedy") , t:setValue(4, {[1] = "Julia Kennedy", ["age"] = 30}) . |
setColumnValue(col, values) / setColumnValue({[col]=value,...}) | Sets the value of an array to the specified column, e.g., t:setColumnValue("ma", array1) or t:setColumnValue({[3] = array1, ["ma"] = array2}) . |
find(index) | Returns the row number or row numbers(in an array) associated with the given index otherwise nil if it's not found , e.g., row_num = t:find({"4"}) . |
insert(row) | Inserts a row into a table object, e.g., t:insert({"4", "Julia Kennedy", "Italian", "Florida", "Fivespan", "Female", "30"}) . |
size() | Returns the size of the table. |
rows() | Returns an iterator over the row number of the table. |
numColumns() | Returns the number of columns. |
Tree Functions
Name | Description |
---|---|
name() | Returns the tree name. |
root() | Returns the root node of the given tree object, e.g., r = tr:root() . |
Tree-Node Functions
Name | Description |
---|---|
count() | Returns the number of children of the given node. |
id() | Returns the name(identifier) of the given tree node. |
idValue() | Returns the value(number) of the given tree node |
isLeaf() | Returns true if the given node is leaf and otherwise returns false. |
find(name) | Returns the child index (starting from 0) if it is found and otherwise -1, e.g., c = n:find("Dole") . |
child(index) / child(name) | Returns the child node of the given node by an index or by a child's id. |
children() | Returns an iterator over the children of the given node. |
getValue(index) / getValue(var_name) | The getValue() accepts either a number (by the index in the data fields, starting from 0) or a data field name and returns its value, e.g., v = n:getValue("SUM(qty)") ; |
setValue(var, new_value) | Sets a value to the specified data field of a tree node. |
getChildrenValue(index) / getChildrenValue(var_name) | Returns the specified data field of all children in an array, e.g., v = n:getChildrenValue(0) or v=n:getChildrenValue("qty") . |
getChildrenId() | Returns the names of all children in an array. |
getChildrenIdIdValue(index) / getChildrenIdIdValue(var_name) | Returns the specified data field of all children in an array along with their names in a table. |
getPathId() | Returns an array of names from the root to the given node, e.g., path_name = n:getPathId() . |
setChildrenValue(var, value) / setChildrenValue({[var]=value,...}) | Sets the value in an array to the specified data field in each corresponding child node, e.g. n:setChildrenValue("ma", ma) or n:setChildrenValue({["ma"] = ma, [2] = array2}) . |
syncToTable(var) / syncToTable({[var]=value,...}) | Sets the value of the specified data field in the leaf nodes (or values in an array) to the same data field of the corresponding row in the source table. This function is only applicable to a tree object formed by CREATE ALL TREE statement. For example, n:syncToTable("ma") or n:syncToTable("ma7", {["ma14"] = array14}) . |
sum(index) / sum (var_name) | Returns the total of the specified data field for all children. |
max(index) / max(var_name) | Returns the maximum value of the specified data field among all children. |
min(index) / min(var_name) | Returns the minimum value of the specified data field among all children. |
average(index) / average(var_name) | Returns the average of of the specified data field among all children |
Date-Time Functions
Name | Description |
---|---|
year() | year of the date |
quarter() | 1-4, quarter of the date |
month() | month of the date |
day() | month day of the date |
yearday() | 0-365, day number of the year of the date. |
weekday() | 0 (Sunday) - 6 (Saturday), week day of the date. |
week() | week number of the date. |
yearweek() | week number of the date, e.g. 2016-W1 |
isoweek() | iso week number of the date, e.g. 2016-W2 |
hour() | hour of the date-time |
minute() | minute of the date-time |
second() | second of the date-time |
timestamp() | timestamp of the date-time |
Note