memory()

Read(627) Label: memory,

Here’s how to use memory() function.

cs.memory( K,… )

Description:

Generate an in-memory table from a cursor.

Syntax:

cs.memory(K,…)

Note:

The function generates an in-memory table, whose key is K, from a cursor. When parameter K is absent, the newly-generated in-memory table will inherit the cursor’s key.

Parameters:

K

The key

cs

A cursor

Options:

@p

Group the would-be in-memory table by the first field, which must be ordered; when the first field is already segmented and the to-be-retrieved field, the result table will inherit the segmentation

@v

Use column-wise memory access

@z

Generate an in-memory table of a compressed format; the option should work with @v option

Return value:

An in-memory table

Example:

 

A

 

1

=demo.cursor("select EID,NAME,GENDER,SALARY from EMPLOYEE where EID<10")

Return the cursor with retrieved data

2

=A1.memory(EID)

Return an in-memory table whose key is EID

3

=demo.cursor("select EID,NAME,GENDER,SALARY from EMPLOYEE where EID<10")

Generate a compressed in-memory table to save space

4

=A3.memory@p(EID)

Use @p option to group the would-be in-memory table by the first field

cs.memory( K,… )

Description:

Generate a cluster in-memory table from a cluster cursor.

Syntax:

cs.memory(K,…)

Note:

According to cluster cursor cs, the function generates a cluster in-memory table that distributed the same way as cs and whose key is K. If cs is a cluster multicursor, load a series of cursors in order.

Parameters:

K

The key; can be omitted

cs

A cluster cursor

Return value:

A cluster in-memory table

Example:

 

A

 

1

=file("test0.ctx","169.254.121.62:8281")

Open a cluster file

2

=A1.open()

Open a cluster table

3

=A2.attach(table)

Retrieve cluster table table

4

=A3.cursor(NAME,GENDER;EID<6)

Get NAME field and GENDER field where EID<6 from cluster table table and return them as a cursor

 5

=A4.memory(GENDER)

Generate a cluster in-memory table whose key is GENDER from a cluster cursor

 

memory( h,V )

Description:

Generate a cluster in-memory table from a local in-memory table.

Syntax:

memory(h,V)

Note:

The function generates a cluster in-memory table from local in-memory table V, which is stored in a global variable, held in node sequence h.

Parameters:

h

A node sequence

V

An in-memory table’s global variable

Return value:

A cluster in-memory table

Example:

Suppose the global variable arg1 is already assigned value using env(v, data) in the initiation script init.dfx:

 

 

A

 

1

=memory(["192.168.31.72:8281","192.168.31.72:8291"],arg1)

Generate a cluster in-memory table from the local in-memory table arg1

2

=A1.cursor().fetch()

T.memory( C,…;w )

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.

Parameters:

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

Options:

@p

Group the would-be in-memory table by the first field, which must be ordered; when the first field is already segmented and the to-be-retrieved field, the result table will inherit the segmentation

@v

Use column-wise memory access

@z

Generate an in-memory table of a compressed format; the option should work with @v option

Return value:

  An 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

7

=file("emp.ctx").open()

 

8

=A7.memory@p(EID2,NAME,GENDER;GENDER=="M")

Use @p option to group the would-be in-memory table by the first field

9

=file("emp.ctx").open()

 

10

=A9.memory@vz()

Generate an in-memory table of a compressed format

T.memory( C,…;w )

Description:

Generate a cluster in-memory table from a cluster entity table.

Syntax:

T.memory(C,…;w)

Note:

The function generates a cluster in-memory table, which inherits the zone table expression, from a cluster entity table T, which must have at least one dimension that is used to segment T and facilitates the segmentation. Clear a node’s memory at exit; will perform auto-clear when timeout occurs.

Parameters:

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

A cluster composite table’s entity table with dimensions

Options:

@v

Use column-wise memory access

@z

Generate an in-memory table of a compressed format; the option should work with @v option

Return value:

  A cluster in-memory table object

Example:

 

A

 

1

=file("emp1.ctx",["192.168.0.116:8281","192.168.0.129:8281"])

Open a cluster file

2

=A1.open()

Generate a cluster table

3

=A2.attach(t1)

Get cluster table t1

4

=A3.memory(NAME,GENDER;EID<5)

Get columns NAME and GENDER with EID being less than 5 from t1 to generate an in-memory table

 

 

A

 

1

=file("STUDENTS.ctx":[1,2],["192.168.31.165:8281","192.168.31.39:8281"])

Open a cluster file

2

=A1.open()

Generate a cluster composite table

3

=A2.memory@vz()

Generate a cluster in-memory table of compressed format