Description:
Generate an in-memory table from an entity table.
Syntax:
T.memory(C,…;w)
Note:
The function filters entity table T according to filtering condition w and imports the data into the memory to generate an in-memory table containing column C. we can handle an in-memory table as we do to a table sequence. When parameter C,… is absent but parameter w is present, the semicolon before w can’t be omitted. If a column C is preceded by # in the entity table, column C will be the key of in-memory table T. Use null to record a C value if it does not exist in T. The in-memory table inherits the entity table’s key if you don’t set a key for it.
Parameter:
C |
A column name; import all columns when the parameter is omitted |
w |
Filtering condition; won’t perform filtering when the parameter is omitted |
T |
An entity table in a composite table |
Option:
@p |
Group the would-be in-memory table by the first field, and this requires that the entity table must be ordered by the first field; when the entity table is already segmented and the to-be-imported fields include its first field, the result in-memory table will inherit the composite table’s segmentation property |
@v |
The option requires that the entity table be a pure table sequence and it enables to return a column-wise in-memory table |
@x |
Automatically close the entity table after the in-memory table is generated |
@w |
Used on a multizone composite table; Perform update merge; ignore the record in the zone table having the smaller number when there are same key values in two zone tables; Split zone tables according to the way of segmenting the first zone table; first read certain zone tables after the first one wholly if they are small enough |
Return value:
An in-memory table or a column-wise in-memory table
Example:
|
A |
|
1 |
=file("D:\\employees.ctx") |
employees is an existing composite table file. |
2 |
=A1.open() |
Open the composite table. |
3 |
=A2.attach(t1) |
Return the composite table’s attached table t1. |
4 |
=A2.memory() |
Generate an in-memory table using all columns of the base table.
|
5 |
=A2.memory(EID,Dept,Name;EID<5) |
Get some columns where EID<5 from the base table to generate an in-memory table.
|
6 |
=A3.memory() |
Get all columns from the attached table to generate an in-memory table.
|
|
A |
|
1 |
=connect("demo").cursor("select EID,NAME,GENDER,SALARY from employee").sortx(EID ) |
Return a cursor ordered by EID. |
2 |
=file("emp.ctx") |
Generate a composite table file. |
3 |
=A2.create@yp(#EID,NAME,GENDER,SALARY) |
Create the composite table’s base table and use the first field as the segmentation key. |
4 |
=A3.append@i(A1) |
Append data of the cursor to the base table. |
5 |
=A2.open() |
Open the composite table file. |
6 |
=A5.memory@p(EID,NAME) |
Generate an in-memory table from A5’s entity table; @p option enables using the first field as the segmentation field, and as the composite table is already segmented and the fields A6 retrieves include the first field EID, the generated in-memory table will inherit the composite table’s segmentation property. |
Create a column-wise in-memory table:
|
A |
|
1 |
=to(1000).new(~:ID,~*~:pNum).cursor() |
Return a cursor that contains a pure table sequence of the following structure:
|
2 |
=file("tb1.ctx") |
Generate a composite table file. |
3 |
=A2.create@y(#ID,pNum) |
Generate the composite table’s base table. |
4 |
=A3.append@i(A1) |
Append data of the cursor to the base table. |
5 |
=A4.memory@v() |
@v option enables to return a column-wise in-memory table. |
Generate an in-memory table from a multizone composite table:
|
A |
|
1 |
=connect("demo").cursor("select EID,NAME,GENDER from employee") |
Return a cursor whose content is as follows:
|
2 |
=file("em.ctx":[1,2]) |
Define a homo-name files group: 1.em.ctx and 2.em.ctx. |
3 |
=A2.create@y(#EID,NAME,GENDER;if(GENDER=="F",1,2)) |
Create a multizone composite table, set EID as its key, and put records where GENDER is F to 1.em.ctx and the other records to 2.em.ctx. |
4 |
=A3.append@ix(A1) |
Append cursor A1’s data to the multizone composite table. |
5 |
=create(EID,NAME,GENDER).record([1,"AAA","M"]).cursor() |
Return a cursor whose content is as follows:
|
6 |
=file("em.ctx":[3]) |
|
7 |
=A6.create@y(#EID,NAME,GENDER;3) |
Add a zone table named 3.em.ctx. |
8 |
=A7.append@i(A5) |
Append cursor A5’s data to zone table 3.em.ctx and now both 1.em.ctx and 3.em.ctx have a record whose primary key is [1] . |
9 |
=file("em.ctx":[1,2,3]).open() |
Open multizone composite table em.ctx. |
10 |
=A9.memory() |
Generate an in-memory table from the multizone composite table:
|
11 |
=A9.memory@w() |
Generate an in-memory table from the multizone composite table and use @w option to perform update merge.
|