Description:
Create a composite table based on a file.
f.create(C,…;x;b)
Note:
The function creates a composite table using composite table file f and generates a multizone composite table if f is a homo-name files 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.
Only supported by esProc Enterprise Edition.
Parameter:
f |
A composite table file object or a homo-name files group object. |
C |
A column of the would-be composite table. |
x |
A zone table expression, whose result is the integer representing the corresponding zone table. |
b |
Block size, whose unit is byte. Default value is the “Composite table block size” configured in the configuration options; when esProc is integrated into a third-party application, the parameter’s default value is value of blockSize configured in raqsoftConfig.xml file. |
Option:
@u |
Do not compress the file; default is to compress it. |
@r |
Generate a row-wise 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. |
@p |
Use the first field as the grouping key. By default, use dimension fields as the segmentation key. |
@v |
When columnar storage is used to generate the composite table, check whether each of its columns is pure during data maintenance and save the data type. Only supported by esProc Enterprise Edition. |
@t |
Create key for the composite table (including multizone composite table) using dimensions and the last key field is the time key; in this case no attached table is allowed. |
@d |
Used on a multizone composite table; the first field after key fields is regarded as the update mark field, whose values fall in three types: null representing to-be-added, true representing to-be-deleted, and false meaning to-be-modified; the program retrieves data from a multizone composite table according to the update mark field value. |
Return value:
Composite table/Homo-name files 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' ").sortx(EID) |
|
4 |
=connect("demo").cursor("select EID,NAME,GENDER,SALARY from employee where GENDER='F' ").sortx(EID) |
|
5 |
=[A3,A4].mcursor() |
Return a multicursor. |
6 |
=file("emp.ctx":[1,2]) |
Generate a homo-name files 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 multizone 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 multizone 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. |
Use the first field as the segmentation key:
|
A |
|
1 |
=file("D:/orders.txt").import@t(SID,OID,OTime,Amount) |
Return a table sequence, whose content is as follows: There is a large amount of data in the table sequence where OID values are unique.
|
2 |
=file("D:/orders.ctx") |
Generate composite table file orders.ctx. |
3 |
=A2.create@py(SID,#OID,OTime,Amount) |
Create the base table for composite table orders.ctx and use @p option to make the first field SID the segmentation key. Records whose segmentation key values are equal will be put into the same column block. |
4 |
=A3.append(A1) |
Write data in A1’s table sequence to the composite table. |
5 |
=A3.cursor(;;1,10).fetch() |
Retrieve data from the composite table segment by segment. Records where values of segmentation key SID are equal will be put into the same column block, making sure that SID value of the last record of the nth segment is different from that of the first record of the (n+1)th segment. Dividing the table sequence into 10 segments and retrieve the 1st segment for example, the ending part is as follows:
|
6 |
=A3.cursor(;;2,10).fetch() |
Divide the table sequence into 10 segments and retrieve the 2nd segment, the beginning part is as follows: |
7 |
=A3.close() |
Close the composite table. |
Set the time key:
|
A |
|
1 |
=file("transaction.ctx") |
|
2 |
=A1.create@yt(#UID,#Time,Change,Amount) |
Create the composite table’s base table; @t option works to set UID as the basic key and Time as the time key. |
3 |
=file("transaction.txt").cursor@t().sortx(UID,Time) |
Return a cursor ordered by UID and Time. |
4 |
=A2.append@i(A3) |
Append cursor A3’s data to the base table. |
5 |
=A2.import() |
Retrieve data of the base table. |
When update mark field is present:
|
A |
|
1 |
=connect("demo").cursor("select EID,NAME,GENDER from employee") |
|
2 |
=A1.derive(null:Defiled) |
|
3 |
=A2.new(EID,Defiled,NAME,GENDER) |
Return a cursor, whose content is as follows: |
4 |
=file("ed.ctx":[1,2]) |
Homo-name files group: 1.ed.ctx and 2.ed.ctx. |
5 |
=A4.create@yd(#EID,Defiled,NAME,GENDER;if(GENDER=="F",1,2)) |
Create a composite table, set EID as the key, use @d option to make Defield field the deletion mark, and put records where GENDER is F to 1.ed.ctx and the other records to 2.ed.ctx. |
6 |
=A5.append@ix(A3) |
Append cursor A1’s data to the multizone composite table. |
7 |
=create(EID,Defiled,NAME,GENDER).record([1,true,,2,false, "ABC","F"]).cursor() |
Return a cursor, whose content is as follows: |
8 |
=file("ed.ctx":[3]) |
|
9 |
=A8.create@yd(#EID,Defiled,NAME,GENDER;3) |
Add zone table 3.ed.ctx |
10 |
=A9.append@i(A7) |
Append cursor A7’s data to zone table 3.ed.ctx. |
11 |
=file("ed.ctx":[1,2,3]) |
|
12 |
=A11.open() |
Open A11’s multizone composite table. |
13 |
=A12.cursor@w() |
Return the multizone composite table as a cursor, use @w option to handle the update mark, which means the record where EID field value is 1 recognized as the to-be-deleted and the one where EID is 2 is recognized as to-be-modified. |
14 |
=A13.fetch() |
Fetch data in cursor A13. We can see that the record where EID is 1 isn’t retrieved from the multizone composite table and NAME value of the one where EID is 2 is modified. |