In-memory query engine over typed columns. Tables are filled row by row or loaded from sources (CSV files, folders, the program's own objects) and queried with SQL-like statements; aggregates, Describe() and Finder (file search) are included. Compile with -lib query.
Predicate
A condition on a table's rows, built with Col and combined with AndAlso, OrElse and Negate. A condition names its columns, so the same one can be used on any table that has them. Comparisons are false for an empty cell; numbers compare by value whether Int or Float; a cell that cannot be ordered against the value (text and a number, say) satisfies only NE.
Example
p := Col->Of("score")->Gt(0.5)->AndAlso(Col->Of("label")->Eq("cat"));
rs := table->Where(p)->OrderBy("score", Order->DESC)->Limit(10);Operations
AndAlso #
Both this condition and another
method : public : AndAlso(condition:Predicate) ~ PredicateParameters
| Name | Type | Description |
|---|---|---|
| condition | Predicate | other condition |
Return
| Type | Description |
|---|---|
| Predicate | combined condition |
GetColumn #
Gets the column a comparison names
method : public : GetColumn() ~ StringReturn
| Type | Description |
|---|---|
| String | column name, Nil for AND, OR and NOT |
GetLeft #
Gets the first condition of AND, OR or NOT
method : public : GetLeft() ~ PredicateReturn
| Type | Description |
|---|---|
| Predicate | condition |
GetParam #
Gets the placeholder number a comparison takes its value from
method : public : GetParam() ~ IntReturn
| Type | Description |
|---|---|
| Int | placeholder number (1 based), 0 for none |
GetRight #
Gets the second condition of AND or OR
method : public : GetRight() ~ PredicateReturn
| Type | Description |
|---|---|
| Predicate | condition |
GetValue #
Gets the value a comparison uses
method : public : GetValue() ~ CompareReturn
| Type | Description |
|---|---|
| Compare | value |
Negate #
The rows this condition does not select, empty cells included
method : public : Negate() ~ PredicateReturn
| Type | Description |
|---|---|
| Predicate | negated condition |
New # constructor
Constructor for a comparison. Col builds these.
New(op:Op, column:String, value:Compare, param:Int)Parameters
| Name | Type | Description |
|---|---|---|
| op | Op | comparison |
| column | String | column name |
| value | Compare | value compared against, Nil for IS_NULL and NOT_NULL |
| param | Int | placeholder number (1 based) whose bound value replaces 'value', 0 for none |