A .select()

Description:

Return members of a sequence which satisfy a condition.

Syntax:

A.select(x)

 

A.select(x1:y1, x2:y2, ......xi:yi)

The simplified syntax of multiple-condition query using "&&", which is equal to A.select(x1== y1 && x2== y2 &&...... xi==yi). In the case of the multiple-condition query with @b option, cmp() is not needed and you can just write A.select@b(x1:y1, x2:y2, ......xi:yi)

 

Note:

The function computes expression x against each member of the sequence A, and returns a new sequence composed of those members which make x return true.When there are no parameters, return all the members. If the name of a to-be-referenced column of the sequence is the same as a cell name, the sequence name should be attached before the column name in the expression.

Parameters:

A

A sequence.

x

A boolean expression, which may be null. when using @b option, x should be an expression whose return value is a number.

xi:yi

xi is an expression, and yi is a comparing value.

Options:

@1

Return the first member that fulfills the condition.

@z

Search the members from back to front

@b

Use binary search when A is an ordered sequence. If A is not an ordered one, then this option should not be used, or it may bring about the incorrect result. When the option works with A.select(x1:y1, x2:y2, ......xi:yi) to find out members that make x in cmp(x,y) return the value 0, you can just write A.select@b(x1:y1, x2:y2, ......xi:yi) without cmp().

@m

Use parallel algorithm to handle data-intensive or computation-intensive tasks; no definite order for the records in the result set; it can’t be used with @1bz options.

@t

Return an empty table sequence with data structure if the grouping and aggregate operation over the sequence returns null

Return value:

A new sequence composed of members which make the expression x return true

Example:

 

A

 

1

[2,5,4,3,2,1,4,1,3]

 

2

=A1.select(~>3)

[5,4,4]

3

=A1.select@1(~>3)

[5]

4

=A1.select@z(~>3)

[4,4,5]

5

=[1,2,3,4,5,6].select@b(~-4)

[4]

6

=demo.query("select * from EMPLOYEE order by EID")

 

7

=A6.select(EID==9)

 

8

=A6.select@b(EID-9)

The expression x needs to be converted to a number with @b.

9

=A6.select(EID:9)

 

10

=A6.select@b(EID:9)

It’s no need to execute the conversion by using the colon when @b exists.

11

=A6.select()

Return all members as there are no parameters.

12

=A6.select@m(EID==9)

Use @m option to increase performance of big data handling.

13

=A6.select@t(EID==501)

Return an empty table sequence with the data structure

14

=to(3).new(~:ID,~*~:A1)

15

=A13.select(A13.A1==4)

.Related functions:

A.pselect()

 

T.select()

Description:

Return members of a table sequence/memory table which satisfy a condition.

Syntax:

T.select(x)

 

Note:

The function computes expression x against each member of table sequence/memory table T, and returns a new table sequence/memory table composed of those members which make x return true

Options:

@i

Reuse T’s index, which may disrupt the order of the result set

Parameters:

T

A table sequence/memory table

x

Filtering expression; can be null

Return value:

A table sequence/memory table

Example:

 

A

 

1

=demo.query("select * from DEPT").keys@i(DEPTID)

Create an index

2

=A1.select@i(FATHER:12)

Reuse A1’s index