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.
RemoteSource
A table published by a TableServer (in the query_server library) on another machine, read as if it were local. Queries go to the server's /query endpoint as SQL, and results come back as .otab, so every type and empty cell arrives exactly. Load sends only the columns and row limit the scan hint asks for, and the condition given to SetWhere, so only the rows a query needs cross the network; the server applies them, and the local query applies its own WHERE again, so pushing a condition down never changes an answer.
Example
runs := RemoteSource->New("http://lab-server:8090", "runs");
runs->SetWhere("score > 0.9");
catalog := Catalog->New();
if(catalog->Load(runs)) {
catalog->Query("select label, count(*) from runs group by label")->ToCsv()->PrintLine();
};Operations
GetError #
Gets the reason the last request failed
method : public : GetError() ~ StringReturn
| Type | Description |
|---|---|
| String | error, Nil if none |
GetTables #
Gets the table's shape, by asking the server for none of its rows
method : public : GetTables() ~ TableSpec[]Return
| Type | Description |
|---|---|
| TableSpec | table shapes, Nil on error (see GetError) |
Load #
Loads the table into a catalog under its name
method : public : Load(catalog:Catalog, hint:ScanHint) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| catalog | Catalog | catalog |
| hint | ScanHint | columns and rows needed, Nil for everything |
Return
| Type | Description |
|---|---|
| Bool | true if loaded, false on error (see GetError) |
New # constructor
Constructor
New(base:String, name:String)Parameters
| Name | Type | Description |
|---|---|---|
| base | String | server address, such as 'http://localhost:8090' |
| name | String | published table's name |
Query #
Runs a SELECT on the server, over any of the tables it publishes
method : public : Query(statement:String) ~ TableParameters
| Name | Type | Description |
|---|---|---|
| statement | String | SQL SELECT |
Return
| Type | Description |
|---|---|
| Table | result, Nil on error (see GetError) |
Read #
Reads the table, or the part of it the hint and SetWhere ask for
method : public : Read(hint:ScanHint) ~ TableParameters
| Name | Type | Description |
|---|---|---|
| hint | ScanHint | columns and rows needed, Nil for everything |
Return
| Type | Description |
|---|---|
| Table | table, Nil on error (see GetError) |