Description:
Create a composite table from a corresponding file.
f.create(C,…;x)
Note:
The function creates a composite table using composite table file f, and generates a multi-zone composite table if f is a file group. Parameter C is a column, which is a dimension if it is preceded by #, of the would-be composite table, and parameter x is a zone table expression. The dimension and all fields before it must be ordered.
Parameters:
f |
A composite table file or a file group |
C |
A column of the would-be composite table |
x |
A zone table expression |
Options:
@u |
Do not compress the file; default is to compress it |
@r |
Generate a rowwise file while default is columnar storage, which does not support the multicursor |
@y |
Force to re-create the file even if the target file already exists; defalut is to terminate computation and report error |
@p |
egment by the first field |
Return value:
A composite table or a file group
Example:
|
A |
|
1 |
=file("employee1.ctx") |
Generate composite table file employee1.ctx |
2 |
=A1.create(#EID,NAME,GENDER) |
Create A1’s base table whose columns are EID, NAME and GENDER; EID is the dimension |
3 |
=connect("demo").cursor("select EID,NAME,GENDER,SALARY from employee where GENDER='M' order by SALARY") |
|
4 |
=connect("demo").cursor("select EID,NAME,GENDER,SALARY from employee where GENDER='F' order by SALARY") |
|
5 |
=[A3,A4].mcursor() |
Return a multicursor |
6 |
=file("emp.ctx":[1,2]) |
Generate a file group, which contains two files 1.emp.ctx and 2.emp.ctx |
7 |
=A6.create@y(#EID,NAME,GENDER,SALARY;if(GENDER=="F",1,2)) |
Create a multi-zone composite table; if(GENDER=="F",1,2) is zone table expression and @y forces to re-create the target file even if it already exists |
8 |
=A7.append@i(A5) |
Append data in A5’s multicursor to A7’s multi-zone composite table; each part of the multicursor uniquely corresponds to A7’s one zone table |
9 |
=file("1.emp.ctx").open().cursor().fetch() |
View data in zone table 1.emp.ctx |
10 |
=file("2.emp.ctx").open().cursor().fetch() |
View data in zone table 2.emp.ctx |