T.index( n )

Read(570) Label: memory table, hash index,

Description:

Create an index on the key of an in-memory table.

Syntax:

T.index(n)

Note:

The function creates an index whose length is n for the key of in-memory table T. Parameter n can be omitted if the key contains serial byte values. The index facilitates data searching when we need to perform multiple searches according to the primary key. The function assumes there is only one primary key in records.

Parameters:

T

An in-memory table with only one primary key

n

The length of index

Options:

@m

Create the index with parallel processing

@n

Create index on the sequence number key, which can be absent but should be present when there is the time key

@s

Create index on the serial byte key

Return value:

An in-memory table

Example:

 

A

 

1

=file("D:\\emp3.ctx")

 

2

=A1.create(#EID,NAME)

Create a composite table’s base table

3

=demo.cursor("select EID,NAME from employee where EID< 10")

 

4

=A2.append(A3)

 

5

=A2.attach(table3,#GENDER)

Add an attached table to the base table

6

=demo.cursor("select EID,GENDER from employee where EID< 10")

Return a cursor

7

=A5.append(A6)

Append cursor records to the attached table

8

=A5.memory()

Generate an in-memory table from A5’s attached table

9

=A8.keys(EID)

Set EID field as the in-memory table’s key

10

=A8.index(10)

Create an index whose length is 10

11

=demo.cursor("select * from employee").memory()

Return an in-memory table

12

=A12.keys@t(EID,HIREDATE)

Set EID as the basic key and HIERDATE as the time key for the in-memory table

13

=A12.index@n()

Create index for the in-memory table