Here’s how to use icursor() functions.
Use index to filter an entity table according to the filtering condition.
Syntax:
T.icursor(C,…;w,I)
Note:
The function filters entity table T according to filtering condition w using index I and returns an ordinary cursor; automatically get the index if parameter I is absent.
Parameters:
T |
An entity table |
C |
To-be-retrieved columns in the entity table; get all columns when the parameter is absent |
w |
Filtering condition, in which the filtering field for T must be the same as the indexing fiel; support >, >=, <, <=, == and contain in its syntax |
I |
Index name; can be omitted |
Options:
|
@s |
Make sure the result set is ordered by the index and large result sets are supported; the option supports multi-zone composite table |
||
|
@u |
Handle multiple conditions joined up with && from left to right while the default is handling them in an optimal order |
||
@m(…;n) |
Return a multicursor; n is the number of parallel threads; default value is that configured by the system |
|
||
Return value:
A single-thread cursor
Example:
|
A |
|
1 |
=file("D:\\emp1.ctx") |
|
2 |
=A1.create(#EID,NAME,DEPT,GENDER;EID) |
Create a composite table where EID field is the key by which records are segmented |
3 |
=demo.cursor("select EID,NAME,DEPT,GENDER from employee where EID<100") |
|
4 |
=A2.append(A3) |
|
5 |
=A4.index(test_index,GENDER=="F";DEPT;EID) |
Create an index named test_index |
6 |
=A4.icursor(;DEPT=="HR",test_index) |
Use index test_index to get all columns where DEPT is HR and return the result as a cursor |
7 |
=A5.fetch() |
Fetch data from the cursor
|
8 |
=A4.icursor@u(;like(DEPT,"*ale*")&&EID>=50,test_index).fetch() |
Handle the multiple conditions connected by && from left to right; use index test_index to find records where DEPT values containing “ale” and EID is greater and equal to 50 |
9 |
=A1.create(#EID,NAME,DEPT,GENDER;EID;EID%2+1) |
Create a multi-zone composite table where EID is the segmentation key |
10 |
=demo.cursor("select EID,NAME,DEPT,GENDER from employee") |
|
11 |
=A9.append(A10) |
|
12 |
=A11.index(test_index1,GENDER=="M";DEPT;EID) |
Create index test_index1 |
13 |
=A11.icursor@s(;DEPT=="HR",test_index1).fetch() |
Use index test_index1 to get records where DEPT is HR and return a result set ordered by the index |
14 |
=A11.icursor@m(;DEPT=="HR",test_index1;2) |
Return a multicursor that has 3 threads |
Description:
Use index to filter a cluster table according to the filtering condition.
Syntax:
T.icursor(C,…;w,I)
Note:
The function filters cluster table T according to filtering condition w using index I; automatically get the index if parameter I is absent.
Parameters:
T |
A cluster table |
C |
To-be-retrieved columns in the cluster table; get all columns when the parameter is absent |
w |
Filtering condition, in which the filtering field for T must be the same as the indexing field; support >, >=, <, <=, == and contain in its syntax |
I |
Index name; can be omitted |
Options:
@s Make the result set ordered by the index and support a big result set
Return value:
A cluster cursor
Example:
|
A |
|
1 |
=file("emp1.ctx":[2],"192.168.0.101:8281") |
Open a cluster file |
2 |
=A1.create() |
Create a cluster table |
3 |
=A2.attach(table1) |
Retrieve cluster table table1 |
4 |
=A3.index(test_index2,GENDER=="F";DEPT;) |
Create index file test_index2 |
5 |
=A3.icursor(;DEPT=="HR",test_index2) |
Use index test_index2 to get all columns in A3’s cluster table where DEPT is HR and return the result as a cluster cursor |
6 |
=A5.fetch() |
|
7 |
=A2.index(test_index1,EID<16;NAME;) |
Create index file test_index1 |
8 |
=A2.icursor(EID,SURNAME;NAME=="Smith",test_index1) |
Use index test_index1 to get EID column and SURNAME column in A2’s cluster table where NAME is SMITH and return the result as a cluster cursor |
9 |
=A8.fetch() |
|